@sentropic/design-system-svelte 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Accordion.svelte +187 -0
- package/dist/Accordion.svelte.d.ts +20 -0
- package/dist/Accordion.svelte.d.ts.map +1 -0
- package/dist/Combobox.svelte +390 -0
- package/dist/Combobox.svelte.d.ts +28 -0
- package/dist/Combobox.svelte.d.ts.map +1 -0
- package/dist/DataTable.svelte +543 -0
- package/dist/DataTable.svelte.d.ts +50 -0
- package/dist/DataTable.svelte.d.ts.map +1 -0
- package/dist/MultiSelect.svelte +427 -0
- package/dist/MultiSelect.svelte.d.ts +28 -0
- package/dist/MultiSelect.svelte.d.ts.map +1 -0
- package/dist/NumberInput.svelte +256 -0
- package/dist/NumberInput.svelte.d.ts +19 -0
- package/dist/NumberInput.svelte.d.ts.map +1 -0
- package/dist/PasswordInput.svelte +205 -0
- package/dist/PasswordInput.svelte.d.ts +17 -0
- package/dist/PasswordInput.svelte.d.ts.map +1 -0
- package/dist/ProgressBar.svelte +176 -0
- package/dist/ProgressBar.svelte.d.ts +17 -0
- package/dist/ProgressBar.svelte.d.ts.map +1 -0
- package/dist/Search.svelte +218 -0
- package/dist/Search.svelte.d.ts +16 -0
- package/dist/Search.svelte.d.ts.map +1 -0
- package/dist/Slider.svelte +279 -0
- package/dist/Slider.svelte.d.ts +20 -0
- package/dist/Slider.svelte.d.ts.map +1 -0
- package/dist/Tag.svelte +140 -0
- package/dist/Tag.svelte.d.ts +16 -0
- package/dist/Tag.svelte.d.ts.map +1 -0
- package/dist/Toggle.svelte +135 -0
- package/dist/Toggle.svelte.d.ts +14 -0
- package/dist/Toggle.svelte.d.ts.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -0
- package/package.json +2 -2
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
export interface AccordionItem {
|
|
3
|
+
id: string;
|
|
4
|
+
title: string;
|
|
5
|
+
content: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<script lang="ts">
|
|
11
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
12
|
+
|
|
13
|
+
type AccordionProps = Omit<HTMLAttributes<HTMLDivElement>, "class" | "onchange"> & {
|
|
14
|
+
items: AccordionItem[];
|
|
15
|
+
multiple?: boolean;
|
|
16
|
+
open?: string[];
|
|
17
|
+
align?: "start" | "end";
|
|
18
|
+
size?: "sm" | "md" | "lg";
|
|
19
|
+
class?: string;
|
|
20
|
+
onchange?: (open: string[]) => void;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
let {
|
|
24
|
+
items,
|
|
25
|
+
multiple = false,
|
|
26
|
+
open = $bindable<string[]>([]),
|
|
27
|
+
align = "end",
|
|
28
|
+
size = "md",
|
|
29
|
+
class: className,
|
|
30
|
+
onchange,
|
|
31
|
+
...rest
|
|
32
|
+
}: AccordionProps = $props();
|
|
33
|
+
|
|
34
|
+
const classes = () =>
|
|
35
|
+
["st-accordion", `st-accordion--${size}`, `st-accordion--align-${align}`, className]
|
|
36
|
+
.filter(Boolean)
|
|
37
|
+
.join(" ");
|
|
38
|
+
|
|
39
|
+
function isOpen(id: string) {
|
|
40
|
+
return open.includes(id);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function toggle(id: string, disabled?: boolean) {
|
|
44
|
+
if (disabled) return;
|
|
45
|
+
let next: string[];
|
|
46
|
+
if (open.includes(id)) {
|
|
47
|
+
next = open.filter((v) => v !== id);
|
|
48
|
+
} else {
|
|
49
|
+
next = multiple ? [...open, id] : [id];
|
|
50
|
+
}
|
|
51
|
+
open = next;
|
|
52
|
+
onchange?.(next);
|
|
53
|
+
}
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<div {...rest} class={classes()}>
|
|
57
|
+
{#each items as item (item.id)}
|
|
58
|
+
{@const expanded = isOpen(item.id)}
|
|
59
|
+
<div class="st-accordion__item" class:st-accordion__item--open={expanded}>
|
|
60
|
+
<h3 class="st-accordion__heading">
|
|
61
|
+
<button
|
|
62
|
+
type="button"
|
|
63
|
+
class="st-accordion__trigger"
|
|
64
|
+
aria-expanded={expanded ? "true" : "false"}
|
|
65
|
+
aria-controls={`st-accordion-panel-${item.id}`}
|
|
66
|
+
id={`st-accordion-trigger-${item.id}`}
|
|
67
|
+
disabled={item.disabled}
|
|
68
|
+
onclick={() => toggle(item.id, item.disabled)}
|
|
69
|
+
>
|
|
70
|
+
{#if align === "start"}
|
|
71
|
+
<span class="st-accordion__icon" aria-hidden="true">▾</span>
|
|
72
|
+
<span class="st-accordion__title">{item.title}</span>
|
|
73
|
+
{:else}
|
|
74
|
+
<span class="st-accordion__title">{item.title}</span>
|
|
75
|
+
<span class="st-accordion__icon" aria-hidden="true">▾</span>
|
|
76
|
+
{/if}
|
|
77
|
+
</button>
|
|
78
|
+
</h3>
|
|
79
|
+
{#if expanded}
|
|
80
|
+
<div
|
|
81
|
+
class="st-accordion__panel"
|
|
82
|
+
role="region"
|
|
83
|
+
id={`st-accordion-panel-${item.id}`}
|
|
84
|
+
aria-labelledby={`st-accordion-trigger-${item.id}`}
|
|
85
|
+
>
|
|
86
|
+
{item.content}
|
|
87
|
+
</div>
|
|
88
|
+
{/if}
|
|
89
|
+
</div>
|
|
90
|
+
{/each}
|
|
91
|
+
</div>
|
|
92
|
+
|
|
93
|
+
<style>
|
|
94
|
+
.st-accordion {
|
|
95
|
+
border-block: 1px solid var(--st-component-control-border, var(--st-semantic-border-subtle));
|
|
96
|
+
color: var(--st-semantic-text-primary);
|
|
97
|
+
display: grid;
|
|
98
|
+
width: 100%;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.st-accordion__item + .st-accordion__item {
|
|
102
|
+
border-top: 1px solid var(--st-component-control-border, var(--st-semantic-border-subtle));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.st-accordion__heading {
|
|
106
|
+
margin: 0;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.st-accordion__trigger {
|
|
110
|
+
align-items: center;
|
|
111
|
+
background: transparent;
|
|
112
|
+
border: 0;
|
|
113
|
+
color: inherit;
|
|
114
|
+
cursor: pointer;
|
|
115
|
+
display: flex;
|
|
116
|
+
font: inherit;
|
|
117
|
+
font-weight: 600;
|
|
118
|
+
gap: 0.75rem;
|
|
119
|
+
justify-content: space-between;
|
|
120
|
+
padding: 0.875rem 0.5rem;
|
|
121
|
+
text-align: start;
|
|
122
|
+
transition: background-color var(--st-motion-fast, 120ms) var(--st-motion-easing, ease);
|
|
123
|
+
width: 100%;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.st-accordion--sm .st-accordion__trigger {
|
|
127
|
+
font-size: 0.875rem;
|
|
128
|
+
padding: 0.625rem 0.5rem;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.st-accordion--lg .st-accordion__trigger {
|
|
132
|
+
font-size: 1rem;
|
|
133
|
+
padding: 1.125rem 0.5rem;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.st-accordion--align-start .st-accordion__trigger {
|
|
137
|
+
justify-content: flex-start;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.st-accordion__trigger:hover:not(:disabled) {
|
|
141
|
+
background: var(--st-component-control-hoverBackground, var(--st-semantic-surface-subtle));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.st-accordion__trigger:focus-visible {
|
|
145
|
+
outline: 2px solid var(--st-component-control-focusRing, var(--st-semantic-border-interactive));
|
|
146
|
+
outline-offset: -2px;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.st-accordion__trigger:disabled {
|
|
150
|
+
color: var(--st-semantic-text-muted);
|
|
151
|
+
cursor: not-allowed;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.st-accordion__title {
|
|
155
|
+
flex: 1 1 auto;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.st-accordion--align-start .st-accordion__title {
|
|
159
|
+
flex: 0 1 auto;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.st-accordion__icon {
|
|
163
|
+
color: var(--st-semantic-text-secondary);
|
|
164
|
+
display: inline-flex;
|
|
165
|
+
flex: 0 0 auto;
|
|
166
|
+
font-size: 0.875rem;
|
|
167
|
+
transition: transform var(--st-motion-fast, 120ms) var(--st-motion-easing, ease);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.st-accordion__item--open .st-accordion__icon {
|
|
171
|
+
transform: rotate(180deg);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.st-accordion__panel {
|
|
175
|
+
color: var(--st-semantic-text-secondary);
|
|
176
|
+
line-height: 1.5;
|
|
177
|
+
padding: 0 0.5rem 0.875rem;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.st-accordion--sm .st-accordion__panel {
|
|
181
|
+
padding-bottom: 0.625rem;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.st-accordion--lg .st-accordion__panel {
|
|
185
|
+
padding-bottom: 1.125rem;
|
|
186
|
+
}
|
|
187
|
+
</style>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface AccordionItem {
|
|
2
|
+
id: string;
|
|
3
|
+
title: string;
|
|
4
|
+
content: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
8
|
+
type AccordionProps = Omit<HTMLAttributes<HTMLDivElement>, "class" | "onchange"> & {
|
|
9
|
+
items: AccordionItem[];
|
|
10
|
+
multiple?: boolean;
|
|
11
|
+
open?: string[];
|
|
12
|
+
align?: "start" | "end";
|
|
13
|
+
size?: "sm" | "md" | "lg";
|
|
14
|
+
class?: string;
|
|
15
|
+
onchange?: (open: string[]) => void;
|
|
16
|
+
};
|
|
17
|
+
declare const Accordion: import("svelte").Component<AccordionProps, {}, "open">;
|
|
18
|
+
type Accordion = ReturnType<typeof Accordion>;
|
|
19
|
+
export default Accordion;
|
|
20
|
+
//# sourceMappingURL=Accordion.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Accordion.svelte.d.ts","sourceRoot":"","sources":["../src/lib/Accordion.svelte.ts"],"names":[],"mappings":"AAGE,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGpD,KAAK,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC,GAAG;IACjF,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IACxB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CACrC,CAAC;AAoEJ,QAAA,MAAM,SAAS,wDAAwC,CAAC;AACxD,KAAK,SAAS,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC;AAC9C,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
export interface ComboboxOption {
|
|
3
|
+
label: string;
|
|
4
|
+
value: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<script lang="ts">
|
|
10
|
+
import type { HTMLInputAttributes } from "svelte/elements";
|
|
11
|
+
|
|
12
|
+
type ComboboxProps = Omit<
|
|
13
|
+
HTMLInputAttributes,
|
|
14
|
+
"class" | "size" | "type" | "value" | "onchange"
|
|
15
|
+
> & {
|
|
16
|
+
label?: string;
|
|
17
|
+
helperText?: string;
|
|
18
|
+
errorText?: string;
|
|
19
|
+
invalid?: boolean;
|
|
20
|
+
size?: "sm" | "md" | "lg";
|
|
21
|
+
options: ComboboxOption[];
|
|
22
|
+
value?: string;
|
|
23
|
+
placeholder?: string;
|
|
24
|
+
allowCustomValue?: boolean;
|
|
25
|
+
noResultsLabel?: string;
|
|
26
|
+
clearLabel?: string;
|
|
27
|
+
toggleLabel?: string;
|
|
28
|
+
listLabel?: string;
|
|
29
|
+
class?: string;
|
|
30
|
+
onselect?: (value: string) => void;
|
|
31
|
+
onchange?: (value: string) => void;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
let {
|
|
35
|
+
label,
|
|
36
|
+
helperText,
|
|
37
|
+
errorText,
|
|
38
|
+
invalid = false,
|
|
39
|
+
size = "md",
|
|
40
|
+
options,
|
|
41
|
+
value = $bindable(""),
|
|
42
|
+
placeholder = "Select or type",
|
|
43
|
+
allowCustomValue = true,
|
|
44
|
+
noResultsLabel = "No results",
|
|
45
|
+
clearLabel = "Clear selection",
|
|
46
|
+
toggleLabel = "Toggle options",
|
|
47
|
+
listLabel,
|
|
48
|
+
disabled,
|
|
49
|
+
class: className,
|
|
50
|
+
onselect,
|
|
51
|
+
onchange,
|
|
52
|
+
...rest
|
|
53
|
+
}: ComboboxProps = $props();
|
|
54
|
+
|
|
55
|
+
let expanded = $state(false);
|
|
56
|
+
let activeIndex = $state(-1);
|
|
57
|
+
|
|
58
|
+
const fieldClasses = () => ["st-field", className].filter(Boolean).join(" ");
|
|
59
|
+
const groupClasses = () => ["st-combobox", `st-combobox--${size}`].join(" ");
|
|
60
|
+
const isInvalid = () => invalid || Boolean(errorText);
|
|
61
|
+
|
|
62
|
+
const filtered = $derived.by(() => {
|
|
63
|
+
const q = value?.trim().toLowerCase() ?? "";
|
|
64
|
+
if (!q) return options;
|
|
65
|
+
return options.filter((opt) => opt.label.toLowerCase().includes(q));
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
function open() {
|
|
69
|
+
if (disabled) return;
|
|
70
|
+
expanded = true;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function close() {
|
|
74
|
+
expanded = false;
|
|
75
|
+
activeIndex = -1;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function selectOption(option: ComboboxOption) {
|
|
79
|
+
if (option.disabled) return;
|
|
80
|
+
value = option.label;
|
|
81
|
+
close();
|
|
82
|
+
onselect?.(option.value);
|
|
83
|
+
onchange?.(option.value);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function onInput(event: Event) {
|
|
87
|
+
value = (event.currentTarget as HTMLInputElement).value;
|
|
88
|
+
expanded = true;
|
|
89
|
+
activeIndex = -1;
|
|
90
|
+
if (allowCustomValue) onchange?.(value);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function clear() {
|
|
94
|
+
value = "";
|
|
95
|
+
onchange?.("");
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function onKeyDown(event: KeyboardEvent) {
|
|
99
|
+
if (event.key === "ArrowDown") {
|
|
100
|
+
event.preventDefault();
|
|
101
|
+
expanded = true;
|
|
102
|
+
const max = filtered.length;
|
|
103
|
+
if (max === 0) return;
|
|
104
|
+
activeIndex = (activeIndex + 1) % max;
|
|
105
|
+
} else if (event.key === "ArrowUp") {
|
|
106
|
+
event.preventDefault();
|
|
107
|
+
expanded = true;
|
|
108
|
+
const max = filtered.length;
|
|
109
|
+
if (max === 0) return;
|
|
110
|
+
activeIndex = (activeIndex - 1 + max) % max;
|
|
111
|
+
} else if (event.key === "Enter") {
|
|
112
|
+
if (expanded && activeIndex >= 0 && filtered[activeIndex]) {
|
|
113
|
+
event.preventDefault();
|
|
114
|
+
selectOption(filtered[activeIndex]);
|
|
115
|
+
}
|
|
116
|
+
} else if (event.key === "Escape") {
|
|
117
|
+
if (expanded) {
|
|
118
|
+
event.preventDefault();
|
|
119
|
+
close();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function onBlur() {
|
|
125
|
+
setTimeout(() => {
|
|
126
|
+
expanded = false;
|
|
127
|
+
activeIndex = -1;
|
|
128
|
+
}, 120);
|
|
129
|
+
}
|
|
130
|
+
</script>
|
|
131
|
+
|
|
132
|
+
<div class={fieldClasses()}>
|
|
133
|
+
<label class="st-field__control">
|
|
134
|
+
{#if label}<span class="st-field__label">{label}</span>{/if}
|
|
135
|
+
<span class={groupClasses()}>
|
|
136
|
+
<input
|
|
137
|
+
{...rest}
|
|
138
|
+
type="text"
|
|
139
|
+
class="st-combobox__control"
|
|
140
|
+
role="combobox"
|
|
141
|
+
aria-expanded={expanded ? "true" : "false"}
|
|
142
|
+
aria-autocomplete="list"
|
|
143
|
+
aria-controls="st-combobox-list"
|
|
144
|
+
aria-invalid={isInvalid() ? "true" : undefined}
|
|
145
|
+
{placeholder}
|
|
146
|
+
{disabled}
|
|
147
|
+
bind:value
|
|
148
|
+
oninput={onInput}
|
|
149
|
+
onfocus={open}
|
|
150
|
+
onblur={onBlur}
|
|
151
|
+
onkeydown={onKeyDown}
|
|
152
|
+
/>
|
|
153
|
+
{#if value}
|
|
154
|
+
<button
|
|
155
|
+
type="button"
|
|
156
|
+
class="st-combobox__clear"
|
|
157
|
+
aria-label={clearLabel}
|
|
158
|
+
{disabled}
|
|
159
|
+
onclick={clear}
|
|
160
|
+
>
|
|
161
|
+
<span aria-hidden="true">×</span>
|
|
162
|
+
</button>
|
|
163
|
+
{/if}
|
|
164
|
+
<button
|
|
165
|
+
type="button"
|
|
166
|
+
class="st-combobox__toggle"
|
|
167
|
+
aria-label={toggleLabel}
|
|
168
|
+
aria-expanded={expanded ? "true" : "false"}
|
|
169
|
+
{disabled}
|
|
170
|
+
onclick={() => (expanded = !expanded)}
|
|
171
|
+
>
|
|
172
|
+
<span aria-hidden="true">▾</span>
|
|
173
|
+
</button>
|
|
174
|
+
</span>
|
|
175
|
+
</label>
|
|
176
|
+
{#if expanded}
|
|
177
|
+
<div
|
|
178
|
+
id="st-combobox-list"
|
|
179
|
+
class="st-combobox__list"
|
|
180
|
+
role="listbox"
|
|
181
|
+
aria-label={listLabel ?? label ?? "Options"}
|
|
182
|
+
>
|
|
183
|
+
{#if filtered.length === 0}
|
|
184
|
+
<div class="st-combobox__empty" role="option" aria-selected="false" aria-disabled="true">
|
|
185
|
+
{noResultsLabel}
|
|
186
|
+
</div>
|
|
187
|
+
{:else}
|
|
188
|
+
{#each filtered as option, i (option.value)}
|
|
189
|
+
<button
|
|
190
|
+
class="st-combobox__option"
|
|
191
|
+
class:st-combobox__option--active={i === activeIndex}
|
|
192
|
+
type="button"
|
|
193
|
+
role="option"
|
|
194
|
+
aria-selected={value === option.label ? "true" : "false"}
|
|
195
|
+
aria-disabled={option.disabled ? "true" : undefined}
|
|
196
|
+
disabled={option.disabled}
|
|
197
|
+
onmousedown={(e) => {
|
|
198
|
+
e.preventDefault();
|
|
199
|
+
selectOption(option);
|
|
200
|
+
}}
|
|
201
|
+
>
|
|
202
|
+
{option.label}
|
|
203
|
+
</button>
|
|
204
|
+
{/each}
|
|
205
|
+
{/if}
|
|
206
|
+
</div>
|
|
207
|
+
{/if}
|
|
208
|
+
{#if errorText}
|
|
209
|
+
<span class="st-field__error">{errorText}</span>
|
|
210
|
+
{:else if helperText}
|
|
211
|
+
<span class="st-field__help">{helperText}</span>
|
|
212
|
+
{/if}
|
|
213
|
+
</div>
|
|
214
|
+
|
|
215
|
+
<style>
|
|
216
|
+
.st-field {
|
|
217
|
+
color: var(--st-component-field-labelText, var(--st-semantic-text-primary));
|
|
218
|
+
display: grid;
|
|
219
|
+
gap: var(--st-component-field-gap, 0.5rem);
|
|
220
|
+
max-width: var(--st-component-field-maxWidth, 28rem);
|
|
221
|
+
position: relative;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.st-field__control {
|
|
225
|
+
display: grid;
|
|
226
|
+
gap: var(--st-component-field-gap, 0.5rem);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.st-field__label {
|
|
230
|
+
font-size: 0.875rem;
|
|
231
|
+
font-weight: 600;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.st-field__help,
|
|
235
|
+
.st-field__error {
|
|
236
|
+
font-size: 0.8125rem;
|
|
237
|
+
line-height: 1.4;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.st-field__help {
|
|
241
|
+
color: var(--st-component-field-helpText, var(--st-semantic-text-secondary));
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.st-field__error {
|
|
245
|
+
color: var(--st-component-field-errorText, var(--st-semantic-feedback-error));
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.st-combobox {
|
|
249
|
+
align-items: center;
|
|
250
|
+
background: var(--st-component-control-background, var(--st-semantic-surface-default));
|
|
251
|
+
border: 1px solid var(--st-component-control-border, var(--st-semantic-border-subtle));
|
|
252
|
+
border-radius: var(--st-component-control-radius, 0.375rem);
|
|
253
|
+
color: var(--st-component-control-text, var(--st-semantic-text-primary));
|
|
254
|
+
display: inline-flex;
|
|
255
|
+
transition:
|
|
256
|
+
border-color var(--st-motion-fast, 120ms) var(--st-motion-easing, ease),
|
|
257
|
+
box-shadow var(--st-motion-fast, 120ms) var(--st-motion-easing, ease);
|
|
258
|
+
width: 100%;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
.st-combobox--sm {
|
|
262
|
+
min-height: var(--st-component-control-smHeight, 2rem);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.st-combobox--md {
|
|
266
|
+
min-height: var(--st-component-control-mdHeight, 2.5rem);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.st-combobox--lg {
|
|
270
|
+
min-height: var(--st-component-control-lgHeight, 3rem);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
.st-combobox:hover:not(:has(input:disabled)) {
|
|
274
|
+
border-color: var(--st-component-control-hoverBorder, var(--st-semantic-border-strong));
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.st-combobox:focus-within {
|
|
278
|
+
border-color: var(--st-component-control-focusRing, var(--st-semantic-border-interactive));
|
|
279
|
+
box-shadow: 0 0 0 2px var(--st-component-control-focusRing, var(--st-semantic-border-interactive));
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.st-combobox:has([aria-invalid="true"]) {
|
|
283
|
+
border-color: var(--st-component-control-invalidBorder, var(--st-semantic-feedback-error));
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.st-combobox__control {
|
|
287
|
+
background: transparent;
|
|
288
|
+
border: 0;
|
|
289
|
+
color: inherit;
|
|
290
|
+
flex: 1 1 auto;
|
|
291
|
+
font: inherit;
|
|
292
|
+
min-width: 0;
|
|
293
|
+
padding: 0 0.75rem;
|
|
294
|
+
width: 100%;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
.st-combobox__control:focus {
|
|
298
|
+
outline: none;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.st-combobox__control::placeholder {
|
|
302
|
+
color: var(--st-component-control-placeholderText, var(--st-semantic-text-muted));
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
.st-combobox__control:disabled {
|
|
306
|
+
color: var(--st-component-control-disabledText, var(--st-semantic-text-muted));
|
|
307
|
+
cursor: not-allowed;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
.st-combobox__clear,
|
|
311
|
+
.st-combobox__toggle {
|
|
312
|
+
align-items: center;
|
|
313
|
+
background: transparent;
|
|
314
|
+
border: 0;
|
|
315
|
+
color: var(--st-semantic-text-secondary);
|
|
316
|
+
cursor: pointer;
|
|
317
|
+
display: inline-flex;
|
|
318
|
+
flex: 0 0 auto;
|
|
319
|
+
font: inherit;
|
|
320
|
+
height: 100%;
|
|
321
|
+
justify-content: center;
|
|
322
|
+
padding: 0 0.5rem;
|
|
323
|
+
transition: background-color var(--st-motion-fast, 120ms) var(--st-motion-easing, ease);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
.st-combobox__clear:hover:not(:disabled),
|
|
327
|
+
.st-combobox__toggle:hover:not(:disabled) {
|
|
328
|
+
background: var(--st-component-control-hoverBackground, var(--st-semantic-surface-subtle));
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
.st-combobox__clear:focus-visible,
|
|
332
|
+
.st-combobox__toggle:focus-visible {
|
|
333
|
+
outline: 2px solid var(--st-component-control-focusRing, var(--st-semantic-border-interactive));
|
|
334
|
+
outline-offset: -2px;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
.st-combobox__clear:disabled,
|
|
338
|
+
.st-combobox__toggle:disabled {
|
|
339
|
+
cursor: not-allowed;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
.st-combobox__list {
|
|
343
|
+
background: var(--st-component-dropdown-background, var(--st-semantic-surface-default));
|
|
344
|
+
border: 1px solid var(--st-component-dropdown-border, var(--st-semantic-border-subtle));
|
|
345
|
+
border-radius: var(--st-component-dropdown-radius, 0.375rem);
|
|
346
|
+
box-shadow: var(--st-component-dropdown-shadow, 0 8px 24px rgb(15 23 42 / 0.14));
|
|
347
|
+
display: grid;
|
|
348
|
+
left: 0;
|
|
349
|
+
margin-top: var(--st-spacing-1, 0.25rem);
|
|
350
|
+
max-height: 16rem;
|
|
351
|
+
overflow-y: auto;
|
|
352
|
+
position: absolute;
|
|
353
|
+
right: 0;
|
|
354
|
+
top: 100%;
|
|
355
|
+
z-index: var(--st-component-popover-zIndex, 80);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
.st-combobox__empty {
|
|
359
|
+
color: var(--st-semantic-text-muted);
|
|
360
|
+
padding: var(--st-spacing-2, 0.5rem) var(--st-spacing-3, 0.75rem);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
.st-combobox__option {
|
|
364
|
+
background: transparent;
|
|
365
|
+
border: 0;
|
|
366
|
+
color: var(--st-component-dropdown-text, var(--st-semantic-text-primary));
|
|
367
|
+
cursor: pointer;
|
|
368
|
+
font: inherit;
|
|
369
|
+
padding: var(--st-spacing-2, 0.5rem) var(--st-spacing-3, 0.75rem);
|
|
370
|
+
text-align: left;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
.st-combobox__option:hover:not(:disabled),
|
|
374
|
+
.st-combobox__option--active {
|
|
375
|
+
background: var(
|
|
376
|
+
--st-component-dropdown-optionHoverBackground,
|
|
377
|
+
var(--st-semantic-surface-subtle)
|
|
378
|
+
);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
.st-combobox__option[aria-selected="true"] {
|
|
382
|
+
background: var(--st-component-dropdown-selectedBackground, var(--st-semantic-action-primary));
|
|
383
|
+
color: var(--st-component-dropdown-selectedText, var(--st-semantic-action-primaryText));
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
.st-combobox__option:disabled {
|
|
387
|
+
color: var(--st-semantic-text-muted);
|
|
388
|
+
cursor: not-allowed;
|
|
389
|
+
}
|
|
390
|
+
</style>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface ComboboxOption {
|
|
2
|
+
label: string;
|
|
3
|
+
value: string;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
}
|
|
6
|
+
import type { HTMLInputAttributes } from "svelte/elements";
|
|
7
|
+
type ComboboxProps = Omit<HTMLInputAttributes, "class" | "size" | "type" | "value" | "onchange"> & {
|
|
8
|
+
label?: string;
|
|
9
|
+
helperText?: string;
|
|
10
|
+
errorText?: string;
|
|
11
|
+
invalid?: boolean;
|
|
12
|
+
size?: "sm" | "md" | "lg";
|
|
13
|
+
options: ComboboxOption[];
|
|
14
|
+
value?: string;
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
allowCustomValue?: boolean;
|
|
17
|
+
noResultsLabel?: string;
|
|
18
|
+
clearLabel?: string;
|
|
19
|
+
toggleLabel?: string;
|
|
20
|
+
listLabel?: string;
|
|
21
|
+
class?: string;
|
|
22
|
+
onselect?: (value: string) => void;
|
|
23
|
+
onchange?: (value: string) => void;
|
|
24
|
+
};
|
|
25
|
+
declare const Combobox: import("svelte").Component<ComboboxProps, {}, "value">;
|
|
26
|
+
type Combobox = ReturnType<typeof Combobox>;
|
|
27
|
+
export default Combobox;
|
|
28
|
+
//# sourceMappingURL=Combobox.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Combobox.svelte.d.ts","sourceRoot":"","sources":["../src/lib/Combobox.svelte.ts"],"names":[],"mappings":"AAGE,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAGzD,KAAK,aAAa,GAAG,IAAI,CACvB,mBAAmB,EACnB,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,CACjD,GAAG;IACF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC,CAAC;AAqJJ,QAAA,MAAM,QAAQ,wDAAwC,CAAC;AACvD,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC;AAC5C,eAAe,QAAQ,CAAC"}
|