mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 10:21:05 +00:00
chore: lift components folder
This commit is contained in:
parent
76df51674d
commit
2200b29b92
301 changed files with 57 additions and 76 deletions
54
src/TimePicker/TimePickerSelect.svelte
Normal file
54
src/TimePicker/TimePickerSelect.svelte
Normal file
|
@ -0,0 +1,54 @@
|
|||
<script>
|
||||
export let value = "";
|
||||
export let name = undefined;
|
||||
export let disabled = false;
|
||||
export let iconDescription = "Open list of options";
|
||||
export let id = "ccs-" + Math.random().toString(36);
|
||||
export let labelText = "";
|
||||
export let hideLabel = true;
|
||||
|
||||
import { setContext } from "svelte";
|
||||
import { writable } from "svelte/store";
|
||||
import ChevronDownGlyph from "carbon-icons-svelte/lib/ChevronDownGlyph";
|
||||
|
||||
const selectedValue = writable(value);
|
||||
|
||||
setContext("TimePickerSelect", { selectedValue });
|
||||
|
||||
$: selectedValue.set(value);
|
||||
$: value = $selectedValue;
|
||||
</script>
|
||||
|
||||
<div
|
||||
class:bx--select={true}
|
||||
class:bx--time-picker__select={true}
|
||||
{...$$restProps}
|
||||
on:click
|
||||
on:mouseover
|
||||
on:mouseenter
|
||||
on:mouseleave>
|
||||
{#if labelText}
|
||||
<label
|
||||
for={id}
|
||||
class:bx--label={true}
|
||||
class:bx--visually-hidden={hideLabel}>
|
||||
{labelText}
|
||||
</label>
|
||||
{/if}
|
||||
<!-- svelte-ignore a11y-no-onchange -->
|
||||
<select
|
||||
class:bx--select-input={true}
|
||||
on:change={({ target }) => {
|
||||
selectedValue.set(target.value);
|
||||
}}
|
||||
{id}
|
||||
{name}
|
||||
{disabled}
|
||||
{value}>
|
||||
<slot />
|
||||
</select>
|
||||
<ChevronDownGlyph
|
||||
aria-label={iconDescription}
|
||||
title={iconDescription}
|
||||
class="bx--select__arrow" />
|
||||
</div>
|
Loading…
Add table
Add a link
Reference in a new issue