@tabelhadev/tabelhawebui 0.28.4
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/LICENSE +661 -0
- package/README.md +222 -0
- package/README.pt-BR.md +217 -0
- package/dist/actions/click-outside.d.ts +3 -0
- package/dist/actions/click-outside.js +12 -0
- package/dist/actions/combobox-keyboard-nav.d.ts +9 -0
- package/dist/actions/combobox-keyboard-nav.js +28 -0
- package/dist/actions/focus-trap.d.ts +1 -0
- package/dist/actions/focus-trap.js +34 -0
- package/dist/actions/scroll-lock.d.ts +1 -0
- package/dist/actions/scroll-lock.js +17 -0
- package/dist/components/actions/Button.svelte +169 -0
- package/dist/components/actions/Button.svelte.d.ts +19 -0
- package/dist/components/appshell/AppShell.svelte +50 -0
- package/dist/components/appshell/AppShell.svelte.d.ts +19 -0
- package/dist/components/appshell/AppShellBottomNav.svelte +67 -0
- package/dist/components/appshell/AppShellBottomNav.svelte.d.ts +9 -0
- package/dist/components/appshell/AppShellContent.svelte +38 -0
- package/dist/components/appshell/AppShellContent.svelte.d.ts +10 -0
- package/dist/components/appshell/AppShellSidebar.svelte +196 -0
- package/dist/components/appshell/AppShellSidebar.svelte.d.ts +15 -0
- package/dist/components/appshell/types.d.ts +6 -0
- package/dist/components/appshell/types.js +1 -0
- package/dist/components/appshell/utils.d.ts +1 -0
- package/dist/components/appshell/utils.js +3 -0
- package/dist/components/card/Card.svelte +31 -0
- package/dist/components/card/Card.svelte.d.ts +9 -0
- package/dist/components/card/CardAction.svelte +57 -0
- package/dist/components/card/CardAction.svelte.d.ts +10 -0
- package/dist/components/card/CardContent.svelte +25 -0
- package/dist/components/card/CardContent.svelte.d.ts +8 -0
- package/dist/components/card/CardDescription.svelte +24 -0
- package/dist/components/card/CardDescription.svelte.d.ts +8 -0
- package/dist/components/card/CardFooter.svelte +25 -0
- package/dist/components/card/CardFooter.svelte.d.ts +8 -0
- package/dist/components/card/CardHeader.svelte +54 -0
- package/dist/components/card/CardHeader.svelte.d.ts +10 -0
- package/dist/components/card/CardTitle.svelte +25 -0
- package/dist/components/card/CardTitle.svelte.d.ts +8 -0
- package/dist/components/chat/ChatMessage.svelte +104 -0
- package/dist/components/chat/ChatMessage.svelte.d.ts +10 -0
- package/dist/components/choice/Listbox.svelte +183 -0
- package/dist/components/choice/Listbox.svelte.d.ts +15 -0
- package/dist/components/choice/MultiSelect.svelte +278 -0
- package/dist/components/choice/MultiSelect.svelte.d.ts +18 -0
- package/dist/components/choice/Rating.svelte +91 -0
- package/dist/components/choice/Rating.svelte.d.ts +12 -0
- package/dist/components/choice/Toggle.svelte +112 -0
- package/dist/components/choice/Toggle.svelte.d.ts +12 -0
- package/dist/components/feedback/Badge.svelte +66 -0
- package/dist/components/feedback/Badge.svelte.d.ts +9 -0
- package/dist/components/feedback/ErrorPage.svelte +99 -0
- package/dist/components/feedback/ErrorPage.svelte.d.ts +13 -0
- package/dist/components/feedback/Message.svelte +130 -0
- package/dist/components/feedback/Message.svelte.d.ts +14 -0
- package/dist/components/feedback/ProgressBar.svelte +69 -0
- package/dist/components/feedback/ProgressBar.svelte.d.ts +8 -0
- package/dist/components/feedback/Skeleton.svelte +47 -0
- package/dist/components/feedback/Skeleton.svelte.d.ts +9 -0
- package/dist/components/feedback/Status.svelte +75 -0
- package/dist/components/feedback/Status.svelte.d.ts +10 -0
- package/dist/components/feedback/StatusPill.svelte +94 -0
- package/dist/components/feedback/StatusPill.svelte.d.ts +13 -0
- package/dist/components/feedback/Toaster.svelte +122 -0
- package/dist/components/feedback/Toaster.svelte.d.ts +7 -0
- package/dist/components/feedback/Tooltip.svelte +126 -0
- package/dist/components/feedback/Tooltip.svelte.d.ts +10 -0
- package/dist/components/feedback/toast.svelte.d.ts +27 -0
- package/dist/components/feedback/toast.svelte.js +23 -0
- package/dist/components/forms/Checkbox.svelte +96 -0
- package/dist/components/forms/Checkbox.svelte.d.ts +11 -0
- package/dist/components/forms/DatePicker.svelte +372 -0
- package/dist/components/forms/DatePicker.svelte.d.ts +21 -0
- package/dist/components/forms/Field.svelte +47 -0
- package/dist/components/forms/Field.svelte.d.ts +11 -0
- package/dist/components/forms/FileUpload.svelte +504 -0
- package/dist/components/forms/FileUpload.svelte.d.ts +43 -0
- package/dist/components/forms/Input.svelte +93 -0
- package/dist/components/forms/Input.svelte.d.ts +9 -0
- package/dist/components/forms/Label.svelte +30 -0
- package/dist/components/forms/Label.svelte.d.ts +10 -0
- package/dist/components/forms/Radio.svelte +80 -0
- package/dist/components/forms/Radio.svelte.d.ts +11 -0
- package/dist/components/forms/Select.svelte +322 -0
- package/dist/components/forms/Select.svelte.d.ts +22 -0
- package/dist/components/forms/TagInput.svelte +336 -0
- package/dist/components/forms/TagInput.svelte.d.ts +16 -0
- package/dist/components/forms/Textarea.svelte +64 -0
- package/dist/components/forms/Textarea.svelte.d.ts +9 -0
- package/dist/components/landing/Landing.svelte +47 -0
- package/dist/components/landing/Landing.svelte.d.ts +8 -0
- package/dist/components/landing/LandingFeatures.svelte +92 -0
- package/dist/components/landing/LandingFeatures.svelte.d.ts +15 -0
- package/dist/components/landing/LandingHero.svelte +92 -0
- package/dist/components/landing/LandingHero.svelte.d.ts +13 -0
- package/dist/components/landing/LandingRoadmap.svelte +42 -0
- package/dist/components/landing/LandingRoadmap.svelte.d.ts +11 -0
- package/dist/components/landing/LandingSection.svelte +25 -0
- package/dist/components/landing/LandingSection.svelte.d.ts +9 -0
- package/dist/components/landing/LandingSectionHeading.svelte +19 -0
- package/dist/components/landing/LandingSectionHeading.svelte.d.ts +10 -0
- package/dist/components/landing/LandingSteps.svelte +100 -0
- package/dist/components/landing/LandingSteps.svelte.d.ts +13 -0
- package/dist/components/layout/BracketLink.svelte +41 -0
- package/dist/components/layout/BracketLink.svelte.d.ts +9 -0
- package/dist/components/layout/Divider.svelte +70 -0
- package/dist/components/layout/Divider.svelte.d.ts +9 -0
- package/dist/components/layout/Eyebrow.svelte +24 -0
- package/dist/components/layout/Eyebrow.svelte.d.ts +8 -0
- package/dist/components/layout/PageHeader.svelte +106 -0
- package/dist/components/layout/PageHeader.svelte.d.ts +15 -0
- package/dist/components/layout/PageSeo.svelte +34 -0
- package/dist/components/layout/PageSeo.svelte.d.ts +10 -0
- package/dist/components/layout/PageShell.svelte +25 -0
- package/dist/components/layout/PageShell.svelte.d.ts +8 -0
- package/dist/components/layout/Panel.svelte +105 -0
- package/dist/components/layout/Panel.svelte.d.ts +12 -0
- package/dist/components/layout/Prose.svelte +101 -0
- package/dist/components/layout/Prose.svelte.d.ts +7 -0
- package/dist/components/layout/RuleCard.svelte +63 -0
- package/dist/components/layout/RuleCard.svelte.d.ts +13 -0
- package/dist/components/layout/SectionHeading.svelte +57 -0
- package/dist/components/layout/SectionHeading.svelte.d.ts +10 -0
- package/dist/components/layout/StatTile.svelte +76 -0
- package/dist/components/layout/StatTile.svelte.d.ts +12 -0
- package/dist/components/layout/TerminalWindow.svelte +81 -0
- package/dist/components/layout/TerminalWindow.svelte.d.ts +9 -0
- package/dist/components/layout/Wordmark.svelte +26 -0
- package/dist/components/layout/Wordmark.svelte.d.ts +8 -0
- package/dist/components/list/List.svelte +40 -0
- package/dist/components/list/List.svelte.d.ts +13 -0
- package/dist/components/list/ListItem.svelte +81 -0
- package/dist/components/list/ListItem.svelte.d.ts +13 -0
- package/dist/components/marketing/MarketingShell.svelte +170 -0
- package/dist/components/marketing/MarketingShell.svelte.d.ts +23 -0
- package/dist/components/marketing/MarketingShellFooter.svelte +92 -0
- package/dist/components/marketing/MarketingShellFooter.svelte.d.ts +14 -0
- package/dist/components/navigation/Accordion.svelte +110 -0
- package/dist/components/navigation/Accordion.svelte.d.ts +15 -0
- package/dist/components/navigation/Carousel.svelte +115 -0
- package/dist/components/navigation/Carousel.svelte.d.ts +12 -0
- package/dist/components/navigation/InstructionStep.svelte +115 -0
- package/dist/components/navigation/InstructionStep.svelte.d.ts +10 -0
- package/dist/components/navigation/InstructionSteps.svelte +39 -0
- package/dist/components/navigation/InstructionSteps.svelte.d.ts +8 -0
- package/dist/components/navigation/Nav.svelte +102 -0
- package/dist/components/navigation/Nav.svelte.d.ts +14 -0
- package/dist/components/navigation/Stepper.svelte +112 -0
- package/dist/components/navigation/Stepper.svelte.d.ts +12 -0
- package/dist/components/navigation/TabCard.svelte +62 -0
- package/dist/components/navigation/TabCard.svelte.d.ts +10 -0
- package/dist/components/navigation/Tabs.svelte +83 -0
- package/dist/components/navigation/Tabs.svelte.d.ts +12 -0
- package/dist/components/navigation/ThemeToggle.svelte +118 -0
- package/dist/components/navigation/ThemeToggle.svelte.d.ts +20 -0
- package/dist/components/overlay/Dialog.svelte +200 -0
- package/dist/components/overlay/Dialog.svelte.d.ts +19 -0
- package/dist/components/overlay/DialogActions.svelte +50 -0
- package/dist/components/overlay/DialogActions.svelte.d.ts +9 -0
- package/dist/components/overlay/Dropdown.svelte +110 -0
- package/dist/components/overlay/Dropdown.svelte.d.ts +10 -0
- package/dist/components/overlay/FloatingActionPill.svelte +96 -0
- package/dist/components/overlay/FloatingActionPill.svelte.d.ts +14 -0
- package/dist/components/overlay/Sidebar.svelte +258 -0
- package/dist/components/overlay/Sidebar.svelte.d.ts +18 -0
- package/dist/components/table/Table.svelte +550 -0
- package/dist/components/table/Table.svelte.d.ts +42 -0
- package/dist/components/timeline/Timeline.svelte +25 -0
- package/dist/components/timeline/Timeline.svelte.d.ts +8 -0
- package/dist/components/timeline/TimelineItem.svelte +220 -0
- package/dist/components/timeline/TimelineItem.svelte.d.ts +18 -0
- package/dist/index.d.ts +156 -0
- package/dist/index.js +149 -0
- package/dist/theme/theme.css +348 -0
- package/package.json +52 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
children,
|
|
7
|
+
for: forAttr,
|
|
8
|
+
class: className = '',
|
|
9
|
+
...rest
|
|
10
|
+
}: {
|
|
11
|
+
children: Snippet;
|
|
12
|
+
for?: string;
|
|
13
|
+
class?: string;
|
|
14
|
+
} & HTMLAttributes<HTMLLabelElement> = $props();
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<label class="twui-label {className}" for={forAttr} {...rest}>
|
|
18
|
+
{@render children()}
|
|
19
|
+
</label>
|
|
20
|
+
|
|
21
|
+
<style>
|
|
22
|
+
.twui-label {
|
|
23
|
+
display: inline-flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
font-family: var(--twui-font-mono);
|
|
26
|
+
font-size: 13px;
|
|
27
|
+
font-weight: 500;
|
|
28
|
+
color: var(--twui-ink);
|
|
29
|
+
}
|
|
30
|
+
</style>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
children: Snippet;
|
|
5
|
+
for?: string;
|
|
6
|
+
class?: string;
|
|
7
|
+
} & HTMLAttributes<HTMLLabelElement>;
|
|
8
|
+
declare const Label: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
9
|
+
type Label = ReturnType<typeof Label>;
|
|
10
|
+
export default Label;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
3
|
+
|
|
4
|
+
let {
|
|
5
|
+
class: className = '',
|
|
6
|
+
checked = $bindable(false),
|
|
7
|
+
name,
|
|
8
|
+
value,
|
|
9
|
+
disabled = false,
|
|
10
|
+
label,
|
|
11
|
+
...rest
|
|
12
|
+
}: HTMLInputAttributes & {
|
|
13
|
+
checked?: boolean;
|
|
14
|
+
name?: string;
|
|
15
|
+
value?: string;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
label?: string;
|
|
18
|
+
} = $props();
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<label class="twui-choice {disabled ? 'twui-choice-disabled' : ''} {className}">
|
|
22
|
+
<input
|
|
23
|
+
{...rest}
|
|
24
|
+
type="radio"
|
|
25
|
+
{name}
|
|
26
|
+
{value}
|
|
27
|
+
{disabled}
|
|
28
|
+
checked={checked}
|
|
29
|
+
onchange={(e) => (checked = e.currentTarget.checked)}
|
|
30
|
+
class="twui-choice-input"
|
|
31
|
+
/>
|
|
32
|
+
<span class="twui-choice-dot" aria-hidden="true"></span>
|
|
33
|
+
{#if label}
|
|
34
|
+
<span class="twui-choice-label">{label}</span>
|
|
35
|
+
{/if}
|
|
36
|
+
</label>
|
|
37
|
+
|
|
38
|
+
<style>
|
|
39
|
+
.twui-choice {
|
|
40
|
+
display: inline-flex;
|
|
41
|
+
align-items: center;
|
|
42
|
+
gap: 8px;
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
font-family: var(--twui-font-mono);
|
|
45
|
+
font-size: 14px;
|
|
46
|
+
color: var(--twui-ink);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.twui-choice-input {
|
|
50
|
+
position: absolute;
|
|
51
|
+
opacity: 0;
|
|
52
|
+
pointer-events: none;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.twui-choice-dot {
|
|
56
|
+
width: 14px;
|
|
57
|
+
height: 14px;
|
|
58
|
+
border: 1px solid var(--twui-rule);
|
|
59
|
+
background: var(--twui-paper);
|
|
60
|
+
border-radius: 9999px;
|
|
61
|
+
transition:
|
|
62
|
+
border-color 0.15s ease,
|
|
63
|
+
background 0.15s ease;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.twui-choice-input:checked + .twui-choice-dot {
|
|
67
|
+
border-color: var(--twui-accent);
|
|
68
|
+
background: var(--twui-accent);
|
|
69
|
+
box-shadow: inset 0 0 0 3px var(--twui-paper);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.twui-choice:has(.twui-choice-input:focus-visible) .twui-choice-dot {
|
|
73
|
+
box-shadow: 0 0 0 2px var(--twui-accent-soft);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.twui-choice-disabled {
|
|
77
|
+
opacity: 0.5;
|
|
78
|
+
cursor: not-allowed;
|
|
79
|
+
}
|
|
80
|
+
</style>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
2
|
+
type $$ComponentProps = HTMLInputAttributes & {
|
|
3
|
+
checked?: boolean;
|
|
4
|
+
name?: string;
|
|
5
|
+
value?: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
label?: string;
|
|
8
|
+
};
|
|
9
|
+
declare const Radio: import("svelte").Component<$$ComponentProps, {}, "checked">;
|
|
10
|
+
type Radio = ReturnType<typeof Radio>;
|
|
11
|
+
export default Radio;
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { fade } from 'svelte/transition';
|
|
3
|
+
import { clickOutside } from '../../actions/click-outside';
|
|
4
|
+
import { comboboxKeydown } from '../../actions/combobox-keyboard-nav';
|
|
5
|
+
|
|
6
|
+
export type SelectOption = { value: string; label: string; disabled?: boolean };
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
options = [],
|
|
10
|
+
value = $bindable(''),
|
|
11
|
+
label,
|
|
12
|
+
name,
|
|
13
|
+
disabled = false,
|
|
14
|
+
placeholder = 'Selecione...',
|
|
15
|
+
filter = false,
|
|
16
|
+
filterPlaceholder = 'Buscar...',
|
|
17
|
+
'aria-label': ariaLabel,
|
|
18
|
+
class: className = '',
|
|
19
|
+
...rest
|
|
20
|
+
}: {
|
|
21
|
+
options?: SelectOption[];
|
|
22
|
+
value?: string;
|
|
23
|
+
label?: string;
|
|
24
|
+
name?: string;
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
placeholder?: string;
|
|
27
|
+
filter?: boolean;
|
|
28
|
+
filterPlaceholder?: string;
|
|
29
|
+
class?: string;
|
|
30
|
+
} & { 'aria-label'?: string; id?: string } = $props();
|
|
31
|
+
|
|
32
|
+
let open = $state(false);
|
|
33
|
+
let rootEl = $state<HTMLDivElement | undefined>();
|
|
34
|
+
let popoverEl = $state<HTMLDivElement | undefined>();
|
|
35
|
+
let popoverRect = $state<{ top: number; left: number; width: number } | null>(null);
|
|
36
|
+
let activeIndex = $state(-1);
|
|
37
|
+
let query = $state('');
|
|
38
|
+
|
|
39
|
+
const selected = $derived(options.find((o) => o.value === value));
|
|
40
|
+
const visibleOptions = $derived(
|
|
41
|
+
filter && query.trim()
|
|
42
|
+
? options.filter((o) => o.label.toLowerCase().includes(query.trim().toLowerCase()))
|
|
43
|
+
: options
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
// Fixed positioning: the popover escapes any `overflow` ancestor (a dialog
|
|
47
|
+
// body with `overflow-y: auto` would otherwise clip the list), so the
|
|
48
|
+
// dropdown floats on top of the modal instead of being contained in it.
|
|
49
|
+
const popoverStyle = $derived(
|
|
50
|
+
popoverRect
|
|
51
|
+
? `position: fixed; top: ${popoverRect.top}px; left: ${popoverRect.left}px; width: ${popoverRect.width}px;`
|
|
52
|
+
: 'position: fixed;'
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
function positionPopover() {
|
|
56
|
+
if (!rootEl) return;
|
|
57
|
+
const rect = rootEl.getBoundingClientRect();
|
|
58
|
+
const height = popoverEl?.offsetHeight ?? 0;
|
|
59
|
+
// Flip above the trigger when there is not enough room below (the
|
|
60
|
+
// popover opens down by default).
|
|
61
|
+
const spaceBelow = window.innerHeight - rect.bottom - 4;
|
|
62
|
+
const openUp = height > 0 && spaceBelow < height && rect.top > height;
|
|
63
|
+
const top = openUp ? rect.top - height - 4 : rect.bottom + 4;
|
|
64
|
+
popoverRect = { top, left: rect.left, width: rect.width };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// While open, follow the trigger: reposition on any scroll (capture — the
|
|
68
|
+
// dialog body scrolls too) and on resize, so the list stays glued to the
|
|
69
|
+
// select instead of drifting.
|
|
70
|
+
$effect(() => {
|
|
71
|
+
if (!open) return;
|
|
72
|
+
positionPopover();
|
|
73
|
+
const onReposition = () => positionPopover();
|
|
74
|
+
window.addEventListener('scroll', onReposition, true);
|
|
75
|
+
window.addEventListener('resize', onReposition);
|
|
76
|
+
return () => {
|
|
77
|
+
window.removeEventListener('scroll', onReposition, true);
|
|
78
|
+
window.removeEventListener('resize', onReposition);
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
function toggle() {
|
|
83
|
+
if (disabled) return;
|
|
84
|
+
open = !open;
|
|
85
|
+
if (open) {
|
|
86
|
+
query = '';
|
|
87
|
+
activeIndex = visibleOptions.findIndex((o) => o.value === value);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function selectOption(option: SelectOption) {
|
|
92
|
+
if (option.disabled) return;
|
|
93
|
+
value = option.value;
|
|
94
|
+
open = false;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const onKeydown = comboboxKeydown({
|
|
98
|
+
get open() { return open; },
|
|
99
|
+
get activeIndex() { return activeIndex; },
|
|
100
|
+
get itemCount() { return visibleOptions.length; },
|
|
101
|
+
onActiveIndexChange: (i) => (activeIndex = i),
|
|
102
|
+
onClose: () => (open = false),
|
|
103
|
+
onConfirm: (i) => selectOption(visibleOptions[i]),
|
|
104
|
+
onOpen: () => toggle()
|
|
105
|
+
});
|
|
106
|
+
</script>
|
|
107
|
+
|
|
108
|
+
<div
|
|
109
|
+
class="twui-select-wrap {className}"
|
|
110
|
+
bind:this={rootEl}
|
|
111
|
+
use:clickOutside={() => (open = false)}
|
|
112
|
+
>
|
|
113
|
+
<button
|
|
114
|
+
type="button"
|
|
115
|
+
class="twui-select-trigger"
|
|
116
|
+
{...rest}
|
|
117
|
+
aria-label={ariaLabel ?? label}
|
|
118
|
+
disabled={disabled}
|
|
119
|
+
aria-haspopup="listbox"
|
|
120
|
+
aria-expanded={open}
|
|
121
|
+
onclick={toggle}
|
|
122
|
+
onkeydown={onKeydown}
|
|
123
|
+
>
|
|
124
|
+
<span class="twui-select-value {selected ? '' : 'twui-select-placeholder'}">
|
|
125
|
+
{selected?.label ?? placeholder}
|
|
126
|
+
</span>
|
|
127
|
+
<svg
|
|
128
|
+
class="twui-select-chevron {open ? 'twui-select-chevron-open' : ''}"
|
|
129
|
+
width="16"
|
|
130
|
+
height="16"
|
|
131
|
+
viewBox="0 0 24 24"
|
|
132
|
+
fill="none"
|
|
133
|
+
stroke="currentColor"
|
|
134
|
+
stroke-width="2"
|
|
135
|
+
stroke-linecap="round"
|
|
136
|
+
stroke-linejoin="round"
|
|
137
|
+
aria-hidden="true"
|
|
138
|
+
><path d="m6 9 6 6 6-6" /></svg>
|
|
139
|
+
</button>
|
|
140
|
+
|
|
141
|
+
{#if name}
|
|
142
|
+
<input type="hidden" {name} value={value} />
|
|
143
|
+
{/if}
|
|
144
|
+
|
|
145
|
+
{#if open}
|
|
146
|
+
<div
|
|
147
|
+
class="twui-select-popover"
|
|
148
|
+
role="listbox"
|
|
149
|
+
transition:fade={{ duration: 100 }}
|
|
150
|
+
bind:this={popoverEl}
|
|
151
|
+
style={popoverStyle}
|
|
152
|
+
>
|
|
153
|
+
{#if filter}
|
|
154
|
+
<div class="twui-select-filter">
|
|
155
|
+
<input
|
|
156
|
+
type="text"
|
|
157
|
+
class="twui-select-filter-input"
|
|
158
|
+
placeholder={filterPlaceholder}
|
|
159
|
+
bind:value={query}
|
|
160
|
+
aria-label={filterPlaceholder}
|
|
161
|
+
/>
|
|
162
|
+
</div>
|
|
163
|
+
{/if}
|
|
164
|
+
{#if visibleOptions.length > 0}
|
|
165
|
+
{#each visibleOptions as option, i (option.value)}
|
|
166
|
+
<button
|
|
167
|
+
type="button"
|
|
168
|
+
role="option"
|
|
169
|
+
aria-selected={option.value === value}
|
|
170
|
+
class="twui-select-option {i === activeIndex ? 'twui-select-option-active' : ''} {option.value ===
|
|
171
|
+
value
|
|
172
|
+
? 'twui-select-option-selected'
|
|
173
|
+
: ''}"
|
|
174
|
+
disabled={option.disabled}
|
|
175
|
+
onclick={() => selectOption(option)}
|
|
176
|
+
onmouseenter={() => (activeIndex = i)}
|
|
177
|
+
>
|
|
178
|
+
{option.label}
|
|
179
|
+
</button>
|
|
180
|
+
{/each}
|
|
181
|
+
{:else}
|
|
182
|
+
<div class="twui-select-empty">Nenhum resultado</div>
|
|
183
|
+
{/if}
|
|
184
|
+
</div>
|
|
185
|
+
{/if}
|
|
186
|
+
</div>
|
|
187
|
+
|
|
188
|
+
<style>
|
|
189
|
+
.twui-select-wrap {
|
|
190
|
+
position: relative;
|
|
191
|
+
display: block;
|
|
192
|
+
width: 100%;
|
|
193
|
+
color: var(--twui-ink-soft);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.twui-select-trigger {
|
|
197
|
+
display: flex;
|
|
198
|
+
align-items: center;
|
|
199
|
+
justify-content: space-between;
|
|
200
|
+
gap: 8px;
|
|
201
|
+
width: 100%;
|
|
202
|
+
padding: 8px 12px;
|
|
203
|
+
border: 1px solid var(--twui-rule);
|
|
204
|
+
background: var(--twui-paper);
|
|
205
|
+
font-family: var(--twui-font-mono);
|
|
206
|
+
font-size: 14px;
|
|
207
|
+
text-align: left;
|
|
208
|
+
color: var(--twui-ink);
|
|
209
|
+
cursor: pointer;
|
|
210
|
+
transition:
|
|
211
|
+
border-color 0.15s ease,
|
|
212
|
+
box-shadow 0.15s ease;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.twui-select-trigger:focus-visible {
|
|
216
|
+
border-color: var(--twui-accent);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.twui-select-trigger:disabled {
|
|
220
|
+
opacity: 0.5;
|
|
221
|
+
cursor: not-allowed;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.twui-select-value {
|
|
225
|
+
overflow: hidden;
|
|
226
|
+
text-overflow: ellipsis;
|
|
227
|
+
white-space: nowrap;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.twui-select-placeholder {
|
|
231
|
+
color: var(--twui-ink-faint);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.twui-select-chevron {
|
|
235
|
+
flex-shrink: 0;
|
|
236
|
+
transition: transform 0.15s ease;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.twui-select-chevron-open {
|
|
240
|
+
transform: rotate(180deg);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.twui-select-popover {
|
|
244
|
+
/* position/coordinates come inline (fixed, computed from the trigger's
|
|
245
|
+
rect) so the list escapes any overflow ancestor — see popoverStyle. */
|
|
246
|
+
z-index: 60;
|
|
247
|
+
max-height: 240px;
|
|
248
|
+
overflow-y: auto;
|
|
249
|
+
/* Hide the native scrollbar (ugly in mono) while keeping keyboard/wheel
|
|
250
|
+
scroll — the list is short and the indicator adds nothing. */
|
|
251
|
+
scrollbar-width: none;
|
|
252
|
+
border: 1px solid var(--twui-rule);
|
|
253
|
+
background: var(--twui-paper-raised);
|
|
254
|
+
box-shadow: var(--twui-shadow-offset, 3px 3px 0 0 var(--twui-rule));
|
|
255
|
+
padding: 4px;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.twui-select-popover::-webkit-scrollbar {
|
|
259
|
+
display: none;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.twui-select-filter {
|
|
263
|
+
padding: 4px 4px 8px;
|
|
264
|
+
border-bottom: 1px solid var(--twui-rule);
|
|
265
|
+
margin-bottom: 4px;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.twui-select-filter-input {
|
|
269
|
+
width: 100%;
|
|
270
|
+
padding: 6px 8px;
|
|
271
|
+
border: 1px solid var(--twui-rule);
|
|
272
|
+
background: var(--twui-paper);
|
|
273
|
+
font-family: var(--twui-font-mono);
|
|
274
|
+
font-size: 13px;
|
|
275
|
+
color: var(--twui-ink);
|
|
276
|
+
outline: none;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
.twui-select-filter-input::placeholder {
|
|
280
|
+
color: var(--twui-ink-faint);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
.twui-select-filter-input:focus-visible {
|
|
284
|
+
border-color: var(--twui-accent);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
.twui-select-empty {
|
|
288
|
+
padding: 8px 10px;
|
|
289
|
+
font-family: var(--twui-font-mono);
|
|
290
|
+
font-size: 13px;
|
|
291
|
+
color: var(--twui-ink-faint);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
.twui-select-option {
|
|
295
|
+
display: block;
|
|
296
|
+
width: 100%;
|
|
297
|
+
padding: 6px 10px;
|
|
298
|
+
border: none;
|
|
299
|
+
background: transparent;
|
|
300
|
+
font-family: var(--twui-font-mono);
|
|
301
|
+
font-size: 13px;
|
|
302
|
+
text-align: left;
|
|
303
|
+
color: var(--twui-ink);
|
|
304
|
+
cursor: pointer;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.twui-select-option:hover,
|
|
308
|
+
.twui-select-option-active {
|
|
309
|
+
background: var(--twui-accent-soft);
|
|
310
|
+
color: var(--twui-accent);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
.twui-select-option-selected {
|
|
314
|
+
color: var(--twui-accent);
|
|
315
|
+
font-weight: 500;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
.twui-select-option:disabled {
|
|
319
|
+
opacity: 0.4;
|
|
320
|
+
cursor: not-allowed;
|
|
321
|
+
}
|
|
322
|
+
</style>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type SelectOption = {
|
|
2
|
+
value: string;
|
|
3
|
+
label: string;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
};
|
|
6
|
+
type $$ComponentProps = {
|
|
7
|
+
options?: SelectOption[];
|
|
8
|
+
value?: string;
|
|
9
|
+
label?: string;
|
|
10
|
+
name?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
filter?: boolean;
|
|
14
|
+
filterPlaceholder?: string;
|
|
15
|
+
class?: string;
|
|
16
|
+
} & {
|
|
17
|
+
'aria-label'?: string;
|
|
18
|
+
id?: string;
|
|
19
|
+
};
|
|
20
|
+
declare const Select: import("svelte").Component<$$ComponentProps, {}, "value">;
|
|
21
|
+
type Select = ReturnType<typeof Select>;
|
|
22
|
+
export default Select;
|