mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
refactor: use $$restProps API
- add ref prop for applicable components (#196) - add slot to Content Switcher `Switch` component (#183) - remove fillArray, css utilities
This commit is contained in:
parent
4e2959080b
commit
e886d772c7
288 changed files with 4681 additions and 4498 deletions
|
@ -1,24 +1,31 @@
|
|||
<script>
|
||||
let className = undefined;
|
||||
export { className as class };
|
||||
export let disabled = false;
|
||||
export let hidden = false;
|
||||
export let style = undefined;
|
||||
export let text = '';
|
||||
export let value = '';
|
||||
export let text = "";
|
||||
export let value = "";
|
||||
|
||||
import { getContext } from 'svelte';
|
||||
import { cx } from '../../lib';
|
||||
import { getContext, onDestroy } from "svelte";
|
||||
|
||||
const ctx = getContext('Select') || getContext('TimePickerSelect');
|
||||
const ctx = getContext("Select") || getContext("TimePickerSelect");
|
||||
|
||||
let selected = false;
|
||||
|
||||
ctx.selectedValue.subscribe(currentValue => {
|
||||
selected = currentValue === value;
|
||||
const unsubscribe = ctx.selectedValue.subscribe($ => {
|
||||
selected = $ === value;
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
unsubscribe();
|
||||
});
|
||||
</script>
|
||||
|
||||
<option class={cx('--select-option', className)} {value} {disabled} {hidden} {style} {selected}>
|
||||
<option
|
||||
{value}
|
||||
{disabled}
|
||||
{hidden}
|
||||
{selected}
|
||||
class:bx--select-option={true}
|
||||
class={$$restProps.class}
|
||||
style={$$restProps.style}>
|
||||
{text || value}
|
||||
</option>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue