mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 10:21:05 +00:00
parent
b8a5d7bdcc
commit
d326bf1fce
12 changed files with 341 additions and 0 deletions
37
src/components/StructuredList/StructuredListInput.svelte
Normal file
37
src/components/StructuredList/StructuredListInput.svelte
Normal file
|
@ -0,0 +1,37 @@
|
|||
<script>
|
||||
let className = undefined;
|
||||
export { className as class };
|
||||
export let id = Math.random();
|
||||
export let value = 'value';
|
||||
export let title = 'title';
|
||||
export let name = '';
|
||||
export let checked = false;
|
||||
export let style = undefined;
|
||||
|
||||
import { getContext } from 'svelte';
|
||||
import { cx } from '../../lib';
|
||||
|
||||
const _class = cx('--structured-list-input', className);
|
||||
|
||||
const { selected, update } = getContext('StructuredListWrapper');
|
||||
|
||||
if (checked) {
|
||||
update(value);
|
||||
}
|
||||
|
||||
$: checked = $selected === value;
|
||||
</script>
|
||||
|
||||
<input
|
||||
type="radio"
|
||||
tabindex="-1"
|
||||
class={_class}
|
||||
on:change={() => {
|
||||
update(value);
|
||||
}}
|
||||
{value}
|
||||
{name}
|
||||
{title}
|
||||
{style}
|
||||
{id}
|
||||
{checked} />
|
Loading…
Add table
Add a link
Reference in a new issue