mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11: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 |
|
||||
| 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 |
|
||||
| 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 |
|
||||
| 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 |
|
||||
|
|
|
@ -9641,7 +9641,7 @@
|
|||
"type": "string",
|
||||
"isFunction": false,
|
||||
"isFunctionDeclaration": false,
|
||||
"isRequired": false,
|
||||
"isRequired": true,
|
||||
"constant": false,
|
||||
"reactive": false
|
||||
},
|
||||
|
|
|
@ -79,7 +79,7 @@ Use the `selected` prop to bind and update the selected value.
|
|||
|
||||
## Skeleton
|
||||
|
||||
<RadioButtonGroup legendText="Storage tier (disk)">
|
||||
<RadioButtonGroup legendText="Storage tier (disk)" name="skeleton">
|
||||
<RadioButtonSkeleton />
|
||||
<RadioButtonSkeleton />
|
||||
<RadioButtonSkeleton />
|
||||
|
@ -87,7 +87,7 @@ Use the `selected` prop to bind and update the selected value.
|
|||
|
||||
## Skeleton (vertical)
|
||||
|
||||
<RadioButtonGroup orientation="vertical" legendText="Storage tier (disk)">
|
||||
<RadioButtonGroup orientation="vertical" legendText="Storage tier (disk)" name="skeleton-vertical">
|
||||
<RadioButtonSkeleton />
|
||||
<RadioButtonSkeleton />
|
||||
<RadioButtonSkeleton />
|
||||
|
|
|
@ -10,7 +10,11 @@
|
|||
|
||||
<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}
|
||||
<RadioButton labelText="{value}" value="{value}" />
|
||||
{/each}
|
||||
|
|
|
@ -10,7 +10,11 @@
|
|||
|
||||
<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}
|
||||
<RadioButton labelText="{value}" value="{value}" />
|
||||
{/each}
|
||||
|
|
|
@ -118,6 +118,7 @@
|
|||
<RadioButtonGroup
|
||||
style="margin-top: var(--cds-spacing-08)"
|
||||
legendText="Carbon themes"
|
||||
name="theme"
|
||||
bind:selected="{$theme}"
|
||||
>
|
||||
{#each ["white", "g10", "g80", "g90", "g100"] as value}
|
||||
|
|
|
@ -54,6 +54,22 @@
|
|||
}
|
||||
|
||||
$: 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>
|
||||
|
||||
<div
|
||||
|
@ -72,10 +88,9 @@
|
|||
value="{value}"
|
||||
class:bx--radio-button="{true}"
|
||||
on:change
|
||||
on:change="{() => {
|
||||
if (update) {
|
||||
update(value);
|
||||
}
|
||||
on:change="{onChange}"
|
||||
on:carbon:checked-change="{(e) => {
|
||||
checked = e.currentTarget.checked;
|
||||
}}"
|
||||
/>
|
||||
<label class:bx--radio-button__label="{true}" for="{id}">
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
* Specify a name attribute for the radio button inputs
|
||||
* @type {string}
|
||||
*/
|
||||
export let name = undefined;
|
||||
export let name;
|
||||
|
||||
/** Specify the legend text */
|
||||
export let legendText = "";
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<Checkbox id="checkbox-2" labelText="Checkbox Label" disabled />
|
||||
</FormGroup>
|
||||
<FormGroup legendText="Radio buttons">
|
||||
<RadioButtonGroup selected="default-selected">
|
||||
<RadioButtonGroup selected="default-selected" name="radio-group">
|
||||
<RadioButton
|
||||
id="radio-1"
|
||||
value="standard"
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
<RadioButtonGroup
|
||||
legendText="Storage tier (disk)"
|
||||
name="group-1"
|
||||
selected="standard"
|
||||
on:change="{(e) => {
|
||||
console.log(e.detail); // string
|
||||
|
@ -16,6 +17,7 @@
|
|||
|
||||
<RadioButtonGroup
|
||||
legendText="Storage tier (disk)"
|
||||
name="group-2"
|
||||
labelPosition="left"
|
||||
selected="standard"
|
||||
>
|
||||
|
@ -24,7 +26,11 @@
|
|||
<RadioButton labelText="Pro (128 GB)" value="pro" />
|
||||
</RadioButtonGroup>
|
||||
|
||||
<RadioButtonGroup orientation="vertical" legendText="Storage tier (disk)">
|
||||
<RadioButtonGroup
|
||||
orientation="vertical"
|
||||
legendText="Storage tier (disk)"
|
||||
name="group-3"
|
||||
>
|
||||
<RadioButtonSkeleton />
|
||||
<RadioButtonSkeleton />
|
||||
<RadioButtonSkeleton />
|
||||
|
|
|
@ -26,7 +26,7 @@ type $Props = {
|
|||
* Specify a name attribute for the radio button inputs
|
||||
* @default undefined
|
||||
*/
|
||||
name?: string;
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* Specify the legend text
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue