mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 10:21:05 +00:00
Merge 5b715d1ab2
into 4881ff7ffd
This commit is contained in:
commit
1cb3fc59fb
11 changed files with 45 additions and 15 deletions
|
@ -2974,7 +2974,7 @@ None.
|
||||||
| selected | No | <code>let</code> | Yes | <code>string | number</code> | <code>undefined</code> | Set the selected radio button value |
|
| selected | No | <code>let</code> | Yes | <code>string | number</code> | <code>undefined</code> | Set the selected radio button value |
|
||||||
| disabled | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to disable the radio buttons |
|
| disabled | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to disable the radio buttons |
|
||||||
| required | No | <code>let</code> | No | <code>boolean</code> | <code>undefined</code> | Set to `true` to require the selection of a radio button |
|
| required | No | <code>let</code> | No | <code>boolean</code> | <code>undefined</code> | Set to `true` to require the selection of a radio button |
|
||||||
| name | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify a name attribute for the radio button inputs |
|
| name | Yes | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify a name attribute for the radio button inputs |
|
||||||
| legendText | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the legend text |
|
| legendText | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the legend text |
|
||||||
| hideLegend | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to visually hide the legend |
|
| hideLegend | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to visually hide the legend |
|
||||||
| labelPosition | No | <code>let</code> | No | <code>"right" | "left"</code> | <code>"right"</code> | Specify the label position |
|
| labelPosition | No | <code>let</code> | No | <code>"right" | "left"</code> | <code>"right"</code> | Specify the label position |
|
||||||
|
|
|
@ -9641,7 +9641,7 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"isFunction": false,
|
"isFunction": false,
|
||||||
"isFunctionDeclaration": false,
|
"isFunctionDeclaration": false,
|
||||||
"isRequired": false,
|
"isRequired": true,
|
||||||
"constant": false,
|
"constant": false,
|
||||||
"reactive": false
|
"reactive": false
|
||||||
},
|
},
|
||||||
|
|
|
@ -79,7 +79,7 @@ Use the `selected` prop to bind and update the selected value.
|
||||||
|
|
||||||
## Skeleton
|
## Skeleton
|
||||||
|
|
||||||
<RadioButtonGroup legendText="Storage tier (disk)">
|
<RadioButtonGroup legendText="Storage tier (disk)" name="skeleton">
|
||||||
<RadioButtonSkeleton />
|
<RadioButtonSkeleton />
|
||||||
<RadioButtonSkeleton />
|
<RadioButtonSkeleton />
|
||||||
<RadioButtonSkeleton />
|
<RadioButtonSkeleton />
|
||||||
|
@ -87,8 +87,8 @@ Use the `selected` prop to bind and update the selected value.
|
||||||
|
|
||||||
## Skeleton (vertical)
|
## Skeleton (vertical)
|
||||||
|
|
||||||
<RadioButtonGroup orientation="vertical" legendText="Storage tier (disk)">
|
<RadioButtonGroup orientation="vertical" legendText="Storage tier (disk)" name="skeleton-vertical">
|
||||||
<RadioButtonSkeleton />
|
<RadioButtonSkeleton />
|
||||||
<RadioButtonSkeleton />
|
<RadioButtonSkeleton />
|
||||||
<RadioButtonSkeleton />
|
<RadioButtonSkeleton />
|
||||||
</RadioButtonGroup>
|
</RadioButtonGroup>
|
||||||
|
|
|
@ -10,7 +10,11 @@
|
||||||
|
|
||||||
<Theme bind:theme />
|
<Theme bind:theme />
|
||||||
|
|
||||||
<RadioButtonGroup legendText="Carbon theme" bind:selected="{theme}">
|
<RadioButtonGroup
|
||||||
|
legendText="Carbon theme"
|
||||||
|
name="theme"
|
||||||
|
bind:selected="{theme}"
|
||||||
|
>
|
||||||
{#each ["white", "g10", "g80", "g90", "g100"] as value}
|
{#each ["white", "g10", "g80", "g90", "g100"] as value}
|
||||||
<RadioButton labelText="{value}" value="{value}" />
|
<RadioButton labelText="{value}" value="{value}" />
|
||||||
{/each}
|
{/each}
|
||||||
|
|
|
@ -10,7 +10,11 @@
|
||||||
|
|
||||||
<Theme bind:theme persist persistKey="__carbon-theme" />
|
<Theme bind:theme persist persistKey="__carbon-theme" />
|
||||||
|
|
||||||
<RadioButtonGroup legendText="Carbon theme" bind:selected="{theme}">
|
<RadioButtonGroup
|
||||||
|
legendText="Carbon theme"
|
||||||
|
name="theme"
|
||||||
|
bind:selected="{theme}"
|
||||||
|
>
|
||||||
{#each ["white", "g10", "g80", "g90", "g100"] as value}
|
{#each ["white", "g10", "g80", "g90", "g100"] as value}
|
||||||
<RadioButton labelText="{value}" value="{value}" />
|
<RadioButton labelText="{value}" value="{value}" />
|
||||||
{/each}
|
{/each}
|
||||||
|
|
|
@ -118,6 +118,7 @@
|
||||||
<RadioButtonGroup
|
<RadioButtonGroup
|
||||||
style="margin-top: var(--cds-spacing-08)"
|
style="margin-top: var(--cds-spacing-08)"
|
||||||
legendText="Carbon themes"
|
legendText="Carbon themes"
|
||||||
|
name="theme"
|
||||||
bind:selected="{$theme}"
|
bind:selected="{$theme}"
|
||||||
>
|
>
|
||||||
{#each ["white", "g10", "g80", "g90", "g100"] as value}
|
{#each ["white", "g10", "g80", "g90", "g100"] as value}
|
||||||
|
|
|
@ -54,6 +54,22 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$: checked = $selectedValue === value;
|
$: checked = $selectedValue === value;
|
||||||
|
|
||||||
|
function onChange() {
|
||||||
|
if (update) {
|
||||||
|
update(value);
|
||||||
|
} else {
|
||||||
|
checked = ref.checked;
|
||||||
|
|
||||||
|
if (name != null && name != "") {
|
||||||
|
Array.from(document.getElementsByName(name))
|
||||||
|
.filter((element) => element !== ref)
|
||||||
|
.forEach((element) =>
|
||||||
|
element.dispatchEvent(new CustomEvent("carbon:checked-change"))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
@ -72,10 +88,9 @@
|
||||||
value="{value}"
|
value="{value}"
|
||||||
class:bx--radio-button="{true}"
|
class:bx--radio-button="{true}"
|
||||||
on:change
|
on:change
|
||||||
on:change="{() => {
|
on:change="{onChange}"
|
||||||
if (update) {
|
on:carbon:checked-change="{(e) => {
|
||||||
update(value);
|
checked = e.currentTarget.checked;
|
||||||
}
|
|
||||||
}}"
|
}}"
|
||||||
/>
|
/>
|
||||||
<label class:bx--radio-button__label="{true}" for="{id}">
|
<label class:bx--radio-button__label="{true}" for="{id}">
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
* Specify a name attribute for the radio button inputs
|
* Specify a name attribute for the radio button inputs
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
export let name = undefined;
|
export let name;
|
||||||
|
|
||||||
/** Specify the legend text */
|
/** Specify the legend text */
|
||||||
export let legendText = "";
|
export let legendText = "";
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
<Checkbox id="checkbox-2" labelText="Checkbox Label" disabled />
|
<Checkbox id="checkbox-2" labelText="Checkbox Label" disabled />
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
<FormGroup legendText="Radio buttons">
|
<FormGroup legendText="Radio buttons">
|
||||||
<RadioButtonGroup selected="default-selected">
|
<RadioButtonGroup selected="default-selected" name="radio-group">
|
||||||
<RadioButton
|
<RadioButton
|
||||||
id="radio-1"
|
id="radio-1"
|
||||||
value="standard"
|
value="standard"
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
<RadioButtonGroup
|
<RadioButtonGroup
|
||||||
legendText="Storage tier (disk)"
|
legendText="Storage tier (disk)"
|
||||||
|
name="group-1"
|
||||||
selected="standard"
|
selected="standard"
|
||||||
on:change="{(e) => {
|
on:change="{(e) => {
|
||||||
console.log(e.detail); // string
|
console.log(e.detail); // string
|
||||||
|
@ -16,6 +17,7 @@
|
||||||
|
|
||||||
<RadioButtonGroup
|
<RadioButtonGroup
|
||||||
legendText="Storage tier (disk)"
|
legendText="Storage tier (disk)"
|
||||||
|
name="group-2"
|
||||||
labelPosition="left"
|
labelPosition="left"
|
||||||
selected="standard"
|
selected="standard"
|
||||||
>
|
>
|
||||||
|
@ -24,7 +26,11 @@
|
||||||
<RadioButton labelText="Pro (128 GB)" value="pro" />
|
<RadioButton labelText="Pro (128 GB)" value="pro" />
|
||||||
</RadioButtonGroup>
|
</RadioButtonGroup>
|
||||||
|
|
||||||
<RadioButtonGroup orientation="vertical" legendText="Storage tier (disk)">
|
<RadioButtonGroup
|
||||||
|
orientation="vertical"
|
||||||
|
legendText="Storage tier (disk)"
|
||||||
|
name="group-3"
|
||||||
|
>
|
||||||
<RadioButtonSkeleton />
|
<RadioButtonSkeleton />
|
||||||
<RadioButtonSkeleton />
|
<RadioButtonSkeleton />
|
||||||
<RadioButtonSkeleton />
|
<RadioButtonSkeleton />
|
||||||
|
|
|
@ -26,7 +26,7 @@ type $Props = {
|
||||||
* Specify a name attribute for the radio button inputs
|
* Specify a name attribute for the radio button inputs
|
||||||
* @default undefined
|
* @default undefined
|
||||||
*/
|
*/
|
||||||
name?: string;
|
name: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify the legend text
|
* Specify the legend text
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue