@nqmcreative/ui 0.2.1 → 0.2.2
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/README.md +7 -5
- package/dist/styles/sprout/Accordion.svelte +17 -0
- package/dist/styles/sprout/Accordion.svelte.d.ts +8 -0
- package/dist/styles/sprout/AccordionItem.svelte +46 -0
- package/dist/styles/sprout/AccordionItem.svelte.d.ts +14 -0
- package/dist/styles/sprout/Alert.svelte +100 -0
- package/dist/styles/sprout/Alert.svelte.d.ts +18 -0
- package/dist/styles/sprout/Avatar.svelte +60 -0
- package/dist/styles/sprout/Avatar.svelte.d.ts +16 -0
- package/dist/styles/sprout/AvatarGroup.svelte +17 -0
- package/dist/styles/sprout/AvatarGroup.svelte.d.ts +8 -0
- package/dist/styles/sprout/Badge.svelte +58 -0
- package/dist/styles/sprout/Badge.svelte.d.ts +16 -0
- package/dist/styles/sprout/Breadcrumb.svelte +49 -0
- package/dist/styles/sprout/Breadcrumb.svelte.d.ts +14 -0
- package/dist/styles/sprout/Button.svelte +105 -0
- package/dist/styles/sprout/Button.svelte.d.ts +21 -0
- package/dist/styles/sprout/CTASection.svelte +77 -0
- package/dist/styles/sprout/CTASection.svelte.d.ts +18 -0
- package/dist/styles/sprout/Calendar.svelte +202 -0
- package/dist/styles/sprout/Calendar.svelte.d.ts +22 -0
- package/dist/styles/sprout/Card.svelte +82 -0
- package/dist/styles/sprout/Card.svelte.d.ts +21 -0
- package/dist/styles/sprout/Checkbox.svelte +76 -0
- package/dist/styles/sprout/Checkbox.svelte.d.ts +15 -0
- package/dist/styles/sprout/CheckboxGroup.svelte +112 -0
- package/dist/styles/sprout/CheckboxGroup.svelte.d.ts +30 -0
- package/dist/styles/sprout/Combobox.svelte +267 -0
- package/dist/styles/sprout/Combobox.svelte.d.ts +29 -0
- package/dist/styles/sprout/CommandPalette.svelte +210 -0
- package/dist/styles/sprout/CommandPalette.svelte.d.ts +32 -0
- package/dist/styles/sprout/ConfirmDialog.svelte +97 -0
- package/dist/styles/sprout/ConfirmDialog.svelte.d.ts +22 -0
- package/dist/styles/sprout/ContextMenu.svelte +89 -0
- package/dist/styles/sprout/ContextMenu.svelte.d.ts +15 -0
- package/dist/styles/sprout/DatePicker.svelte +193 -0
- package/dist/styles/sprout/DatePicker.svelte.d.ts +23 -0
- package/dist/styles/sprout/Divider.svelte +30 -0
- package/dist/styles/sprout/Divider.svelte.d.ts +10 -0
- package/dist/styles/sprout/Drawer.svelte +166 -0
- package/dist/styles/sprout/Drawer.svelte.d.ts +20 -0
- package/dist/styles/sprout/Dropdown.svelte +95 -0
- package/dist/styles/sprout/Dropdown.svelte.d.ts +23 -0
- package/dist/styles/sprout/Dropzone.svelte +211 -0
- package/dist/styles/sprout/Dropzone.svelte.d.ts +29 -0
- package/dist/styles/sprout/EmptyState.svelte +71 -0
- package/dist/styles/sprout/EmptyState.svelte.d.ts +18 -0
- package/dist/styles/sprout/FeatureCard.svelte +61 -0
- package/dist/styles/sprout/FeatureCard.svelte.d.ts +16 -0
- package/dist/styles/sprout/FeatureGrid.svelte +62 -0
- package/dist/styles/sprout/FeatureGrid.svelte.d.ts +16 -0
- package/dist/styles/sprout/Field.svelte +42 -0
- package/dist/styles/sprout/Field.svelte.d.ts +16 -0
- package/dist/styles/sprout/Footer.svelte +91 -0
- package/dist/styles/sprout/Footer.svelte.d.ts +25 -0
- package/dist/styles/sprout/HeroSection.svelte +86 -0
- package/dist/styles/sprout/HeroSection.svelte.d.ts +21 -0
- package/dist/styles/sprout/Input.svelte +61 -0
- package/dist/styles/sprout/Input.svelte.d.ts +18 -0
- package/dist/styles/sprout/InputGroup.svelte +20 -0
- package/dist/styles/sprout/InputGroup.svelte.d.ts +11 -0
- package/dist/styles/sprout/Kbd.svelte +18 -0
- package/dist/styles/sprout/Kbd.svelte.d.ts +8 -0
- package/dist/styles/sprout/Label.svelte +16 -0
- package/dist/styles/sprout/Label.svelte.d.ts +9 -0
- package/dist/styles/sprout/Link.svelte +44 -0
- package/dist/styles/sprout/Link.svelte.d.ts +16 -0
- package/dist/styles/sprout/LocaleProvider.svelte +24 -0
- package/dist/styles/sprout/LocaleProvider.svelte.d.ts +10 -0
- package/dist/styles/sprout/LogoCloud.svelte +61 -0
- package/dist/styles/sprout/LogoCloud.svelte.d.ts +19 -0
- package/dist/styles/sprout/MenuItem.svelte +64 -0
- package/dist/styles/sprout/MenuItem.svelte.d.ts +18 -0
- package/dist/styles/sprout/MenuSeparator.svelte +22 -0
- package/dist/styles/sprout/MenuSeparator.svelte.d.ts +8 -0
- package/dist/styles/sprout/Modal.svelte +119 -0
- package/dist/styles/sprout/Modal.svelte.d.ts +21 -0
- package/dist/styles/sprout/MultiSelect.svelte +288 -0
- package/dist/styles/sprout/MultiSelect.svelte.d.ts +31 -0
- package/dist/styles/sprout/Navbar.svelte +201 -0
- package/dist/styles/sprout/Navbar.svelte.d.ts +33 -0
- package/dist/styles/sprout/NumberInput.svelte +97 -0
- package/dist/styles/sprout/NumberInput.svelte.d.ts +15 -0
- package/dist/styles/sprout/Pagination.svelte +84 -0
- package/dist/styles/sprout/Pagination.svelte.d.ts +15 -0
- package/dist/styles/sprout/PasswordInput.svelte +101 -0
- package/dist/styles/sprout/PasswordInput.svelte.d.ts +12 -0
- package/dist/styles/sprout/Popover.svelte +90 -0
- package/dist/styles/sprout/Popover.svelte.d.ts +19 -0
- package/dist/styles/sprout/PricingCard.svelte +109 -0
- package/dist/styles/sprout/PricingCard.svelte.d.ts +25 -0
- package/dist/styles/sprout/Progress.svelte +59 -0
- package/dist/styles/sprout/Progress.svelte.d.ts +17 -0
- package/dist/styles/sprout/Radio.svelte +56 -0
- package/dist/styles/sprout/Radio.svelte.d.ts +15 -0
- package/dist/styles/sprout/RadioGroup.svelte +96 -0
- package/dist/styles/sprout/RadioGroup.svelte.d.ts +27 -0
- package/dist/styles/sprout/SegmentedControl.svelte +89 -0
- package/dist/styles/sprout/SegmentedControl.svelte.d.ts +25 -0
- package/dist/styles/sprout/Select.svelte +62 -0
- package/dist/styles/sprout/Select.svelte.d.ts +20 -0
- package/dist/styles/sprout/Sidebar.svelte +206 -0
- package/dist/styles/sprout/Sidebar.svelte.d.ts +36 -0
- package/dist/styles/sprout/Skeleton.svelte +46 -0
- package/dist/styles/sprout/Skeleton.svelte.d.ts +13 -0
- package/dist/styles/sprout/Slider.svelte +80 -0
- package/dist/styles/sprout/Slider.svelte.d.ts +19 -0
- package/dist/styles/sprout/Spinner.svelte +34 -0
- package/dist/styles/sprout/Spinner.svelte.d.ts +13 -0
- package/dist/styles/sprout/Stat.svelte +51 -0
- package/dist/styles/sprout/Stat.svelte.d.ts +16 -0
- package/dist/styles/sprout/StatsBand.svelte +64 -0
- package/dist/styles/sprout/StatsBand.svelte.d.ts +20 -0
- package/dist/styles/sprout/Steps.svelte +143 -0
- package/dist/styles/sprout/Steps.svelte.d.ts +24 -0
- package/dist/styles/sprout/Switch.svelte +65 -0
- package/dist/styles/sprout/Switch.svelte.d.ts +14 -0
- package/dist/styles/sprout/Table.svelte +218 -0
- package/dist/styles/sprout/Table.svelte.d.ts +66 -0
- package/dist/styles/sprout/Tabs.svelte +103 -0
- package/dist/styles/sprout/Tabs.svelte.d.ts +23 -0
- package/dist/styles/sprout/Testimonial.svelte +65 -0
- package/dist/styles/sprout/Testimonial.svelte.d.ts +19 -0
- package/dist/styles/sprout/Textarea.svelte +55 -0
- package/dist/styles/sprout/Textarea.svelte.d.ts +12 -0
- package/dist/styles/sprout/ThemeToggle.svelte +131 -0
- package/dist/styles/sprout/ThemeToggle.svelte.d.ts +16 -0
- package/dist/styles/sprout/Toaster.svelte +133 -0
- package/dist/styles/sprout/Toaster.svelte.d.ts +8 -0
- package/dist/styles/sprout/Tooltip.svelte +34 -0
- package/dist/styles/sprout/Tooltip.svelte.d.ts +12 -0
- package/dist/styles/sprout/fonts.css +78 -0
- package/dist/styles/sprout/index.d.ts +109 -0
- package/dist/styles/sprout/index.js +83 -0
- package/dist/styles/sprout/lift.d.ts +40 -0
- package/dist/styles/sprout/lift.js +36 -0
- package/dist/styles/sprout/theme.css +255 -0
- package/package.json +269 -3
- package/registry.json +137 -65
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
4
|
+
import { peerFocusRing, tonePeerChecked, tonePeerFocus, type Tone } from '../../core/tones.js';
|
|
5
|
+
import { edge } from './lift.js';
|
|
6
|
+
|
|
7
|
+
interface Props extends Omit<HTMLInputAttributes, 'type' | 'size'> {
|
|
8
|
+
/** Bind the same variable across a set of radios. */
|
|
9
|
+
group?: string;
|
|
10
|
+
value: string;
|
|
11
|
+
label?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
tone?: Tone;
|
|
14
|
+
children?: Snippet;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let {
|
|
18
|
+
group = $bindable(''),
|
|
19
|
+
value,
|
|
20
|
+
label,
|
|
21
|
+
description,
|
|
22
|
+
tone = 'brand',
|
|
23
|
+
disabled = false,
|
|
24
|
+
class: className = '',
|
|
25
|
+
children,
|
|
26
|
+
...rest
|
|
27
|
+
}: Props = $props();
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<label
|
|
31
|
+
class="group inline-flex items-start gap-2.5 font-sans text-sm
|
|
32
|
+
{disabled ? 'pointer-events-none opacity-50' : 'cursor-pointer'} {className}"
|
|
33
|
+
>
|
|
34
|
+
<input type="radio" bind:group {value} {disabled} class="peer sr-only" {...rest} />
|
|
35
|
+
<span
|
|
36
|
+
class="mt-0.5 flex size-[18px] shrink-0 items-center justify-center rounded-full border border-hairline-strong bg-bg {edge} transition-colors duration-150 ease-brand-out
|
|
37
|
+
{tonePeerChecked[tone]} {peerFocusRing} {tonePeerFocus[tone]}"
|
|
38
|
+
aria-hidden="true"
|
|
39
|
+
>
|
|
40
|
+
<span
|
|
41
|
+
class="size-1.5 rounded-full bg-text-inverse opacity-0 transition-opacity duration-150 group-has-[:checked]:opacity-100"
|
|
42
|
+
></span>
|
|
43
|
+
</span>
|
|
44
|
+
{#if label || description || children}
|
|
45
|
+
<span class="flex flex-col gap-0.5">
|
|
46
|
+
{#if children}
|
|
47
|
+
{@render children()}
|
|
48
|
+
{:else if label}
|
|
49
|
+
<span class="leading-snug text-text">{label}</span>
|
|
50
|
+
{/if}
|
|
51
|
+
{#if description}
|
|
52
|
+
<span class="text-[13px] leading-snug text-text-muted">{description}</span>
|
|
53
|
+
{/if}
|
|
54
|
+
</span>
|
|
55
|
+
{/if}
|
|
56
|
+
</label>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
3
|
+
import { type Tone } from '../../core/tones.js';
|
|
4
|
+
interface Props extends Omit<HTMLInputAttributes, 'type' | 'size'> {
|
|
5
|
+
/** Bind the same variable across a set of radios. */
|
|
6
|
+
group?: string;
|
|
7
|
+
value: string;
|
|
8
|
+
label?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
tone?: Tone;
|
|
11
|
+
children?: Snippet;
|
|
12
|
+
}
|
|
13
|
+
declare const Radio: import("svelte").Component<Props, {}, "group">;
|
|
14
|
+
type Radio = ReturnType<typeof Radio>;
|
|
15
|
+
export default Radio;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { HTMLFieldsetAttributes } from 'svelte/elements';
|
|
4
|
+
import Radio from './Radio.svelte';
|
|
5
|
+
import { toneBorder, toneSurface, type Tone } from '../../core/tones.js';
|
|
6
|
+
import { edge } from './lift.js';
|
|
7
|
+
|
|
8
|
+
export interface RadioOption {
|
|
9
|
+
value: string;
|
|
10
|
+
label: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface Props extends HTMLFieldsetAttributes {
|
|
16
|
+
/** Bindable — the selected option's `value`. */
|
|
17
|
+
value?: string;
|
|
18
|
+
options?: RadioOption[];
|
|
19
|
+
legend?: string;
|
|
20
|
+
hint?: string;
|
|
21
|
+
error?: string;
|
|
22
|
+
required?: boolean;
|
|
23
|
+
tone?: Tone;
|
|
24
|
+
orientation?: 'vertical' | 'horizontal';
|
|
25
|
+
/** Wraps each option in a bordered, clickable card. */
|
|
26
|
+
boxed?: boolean;
|
|
27
|
+
/** Pass your own `Radio`s instead of `options`. */
|
|
28
|
+
children?: Snippet;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let {
|
|
32
|
+
value = $bindable(''),
|
|
33
|
+
options,
|
|
34
|
+
legend,
|
|
35
|
+
hint,
|
|
36
|
+
error,
|
|
37
|
+
required = false,
|
|
38
|
+
tone = 'brand',
|
|
39
|
+
orientation = 'vertical',
|
|
40
|
+
boxed = false,
|
|
41
|
+
class: className = '',
|
|
42
|
+
children,
|
|
43
|
+
...rest
|
|
44
|
+
}: Props = $props();
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<fieldset class="flex flex-col gap-3 border-0 p-0 {className}" {...rest}>
|
|
48
|
+
{#if legend}
|
|
49
|
+
<legend class="mb-1 font-sans text-sm font-medium text-text">
|
|
50
|
+
{legend}
|
|
51
|
+
{#if required}<span class="ml-0.5 text-danger" aria-hidden="true">*</span>{/if}
|
|
52
|
+
</legend>
|
|
53
|
+
{/if}
|
|
54
|
+
|
|
55
|
+
<div class="flex gap-2.5 {orientation === 'horizontal' ? 'flex-row flex-wrap' : 'flex-col'}">
|
|
56
|
+
{#if options}
|
|
57
|
+
{#each options as option (option.value)}
|
|
58
|
+
{#if boxed}
|
|
59
|
+
<label
|
|
60
|
+
class="flex flex-1 cursor-pointer items-start gap-3 rounded-[20px] border p-4 {edge} transition-colors duration-150 ease-brand-out
|
|
61
|
+
{value === option.value
|
|
62
|
+
? `${toneBorder[tone]} ${toneSurface[tone]}`
|
|
63
|
+
: 'border-hairline bg-bg hover:border-hairline-strong'}
|
|
64
|
+
{option.disabled ? 'pointer-events-none opacity-50' : ''}"
|
|
65
|
+
>
|
|
66
|
+
<Radio
|
|
67
|
+
bind:group={value}
|
|
68
|
+
value={option.value}
|
|
69
|
+
label={option.label}
|
|
70
|
+
description={option.description}
|
|
71
|
+
disabled={option.disabled}
|
|
72
|
+
{tone}
|
|
73
|
+
/>
|
|
74
|
+
</label>
|
|
75
|
+
{:else}
|
|
76
|
+
<Radio
|
|
77
|
+
bind:group={value}
|
|
78
|
+
value={option.value}
|
|
79
|
+
label={option.label}
|
|
80
|
+
description={option.description}
|
|
81
|
+
disabled={option.disabled}
|
|
82
|
+
{tone}
|
|
83
|
+
/>
|
|
84
|
+
{/if}
|
|
85
|
+
{/each}
|
|
86
|
+
{:else if children}
|
|
87
|
+
{@render children()}
|
|
88
|
+
{/if}
|
|
89
|
+
</div>
|
|
90
|
+
|
|
91
|
+
{#if error}
|
|
92
|
+
<p class="font-sans text-[13px] text-danger">{error}</p>
|
|
93
|
+
{:else if hint}
|
|
94
|
+
<p class="font-sans text-[13px] text-text-muted">{hint}</p>
|
|
95
|
+
{/if}
|
|
96
|
+
</fieldset>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLFieldsetAttributes } from 'svelte/elements';
|
|
3
|
+
import { type Tone } from '../../core/tones.js';
|
|
4
|
+
export interface RadioOption {
|
|
5
|
+
value: string;
|
|
6
|
+
label: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface Props extends HTMLFieldsetAttributes {
|
|
11
|
+
/** Bindable — the selected option's `value`. */
|
|
12
|
+
value?: string;
|
|
13
|
+
options?: RadioOption[];
|
|
14
|
+
legend?: string;
|
|
15
|
+
hint?: string;
|
|
16
|
+
error?: string;
|
|
17
|
+
required?: boolean;
|
|
18
|
+
tone?: Tone;
|
|
19
|
+
orientation?: 'vertical' | 'horizontal';
|
|
20
|
+
/** Wraps each option in a bordered, clickable card. */
|
|
21
|
+
boxed?: boolean;
|
|
22
|
+
/** Pass your own `Radio`s instead of `options`. */
|
|
23
|
+
children?: Snippet;
|
|
24
|
+
}
|
|
25
|
+
declare const RadioGroup: import("svelte").Component<Props, {}, "value">;
|
|
26
|
+
type RadioGroup = ReturnType<typeof RadioGroup>;
|
|
27
|
+
export default RadioGroup;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import { focusRing, toneRing, type Tone } from '../../core/tones.js';
|
|
4
|
+
import { edge } from './lift.js';
|
|
5
|
+
|
|
6
|
+
export interface SegmentOption {
|
|
7
|
+
value: string;
|
|
8
|
+
label: string;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type SegmentedSize = 'sm' | 'md';
|
|
13
|
+
|
|
14
|
+
interface Props extends Omit<HTMLAttributes<HTMLDivElement>, 'onchange'> {
|
|
15
|
+
/** Bindable — the selected option's `value`. */
|
|
16
|
+
value?: string;
|
|
17
|
+
options: SegmentOption[];
|
|
18
|
+
/** Submits with a form when set. */
|
|
19
|
+
name?: string;
|
|
20
|
+
size?: SegmentedSize;
|
|
21
|
+
tone?: Tone;
|
|
22
|
+
/** Spread the segments evenly across the full width. */
|
|
23
|
+
fullWidth?: boolean;
|
|
24
|
+
label?: string;
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
onchange?: (value: string) => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let {
|
|
30
|
+
value = $bindable(''),
|
|
31
|
+
options,
|
|
32
|
+
name,
|
|
33
|
+
size = 'md',
|
|
34
|
+
tone = 'brand',
|
|
35
|
+
fullWidth = false,
|
|
36
|
+
label,
|
|
37
|
+
disabled = false,
|
|
38
|
+
class: className = '',
|
|
39
|
+
onchange,
|
|
40
|
+
...rest
|
|
41
|
+
}: Props = $props();
|
|
42
|
+
|
|
43
|
+
const sizes: Record<SegmentedSize, string> = {
|
|
44
|
+
sm: 'h-7 px-2.5 text-[13px]',
|
|
45
|
+
md: 'h-8 px-3.5 text-sm'
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
function select(option: SegmentOption) {
|
|
49
|
+
if (option.disabled || disabled) return;
|
|
50
|
+
value = option.value;
|
|
51
|
+
onchange?.(option.value);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function onKeydown(event: KeyboardEvent) {
|
|
55
|
+
const step = event.key === 'ArrowRight' ? 1 : event.key === 'ArrowLeft' ? -1 : 0;
|
|
56
|
+
if (!step) return;
|
|
57
|
+
event.preventDefault();
|
|
58
|
+
const usable = options.filter((option) => !option.disabled);
|
|
59
|
+
const index = usable.findIndex((option) => option.value === value);
|
|
60
|
+
select(usable[(index + step + usable.length) % usable.length]);
|
|
61
|
+
}
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<div
|
|
65
|
+
role="radiogroup"
|
|
66
|
+
aria-label={label}
|
|
67
|
+
onkeydown={onKeydown}
|
|
68
|
+
class="inline-flex items-center gap-1 rounded-2xl border border-hairline bg-bg-inset p-1
|
|
69
|
+
{fullWidth ? 'flex w-full *:flex-1' : ''}
|
|
70
|
+
{disabled ? 'pointer-events-none opacity-50' : ''} {className}"
|
|
71
|
+
{...rest}
|
|
72
|
+
>
|
|
73
|
+
{#each options as option (option.value)}
|
|
74
|
+
<button
|
|
75
|
+
type="button"
|
|
76
|
+
role="radio"
|
|
77
|
+
aria-checked={value === option.value}
|
|
78
|
+
disabled={option.disabled || disabled}
|
|
79
|
+
tabindex={value === option.value ? 0 : -1}
|
|
80
|
+
onclick={() => select(option)}
|
|
81
|
+
class="inline-flex items-center justify-center rounded-xl font-sans font-medium whitespace-nowrap transition-all duration-150 ease-brand-out disabled:pointer-events-none disabled:opacity-40
|
|
82
|
+
{sizes[size]} {focusRing} {toneRing[tone]}
|
|
83
|
+
{value === option.value ? `bg-bg text-text ${edge}` : 'text-text-muted hover:text-text'}"
|
|
84
|
+
>
|
|
85
|
+
{option.label}
|
|
86
|
+
</button>
|
|
87
|
+
{/each}
|
|
88
|
+
{#if name}<input type="hidden" {name} {value} />{/if}
|
|
89
|
+
</div>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
+
import { type Tone } from '../../core/tones.js';
|
|
3
|
+
export interface SegmentOption {
|
|
4
|
+
value: string;
|
|
5
|
+
label: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export type SegmentedSize = 'sm' | 'md';
|
|
9
|
+
interface Props extends Omit<HTMLAttributes<HTMLDivElement>, 'onchange'> {
|
|
10
|
+
/** Bindable — the selected option's `value`. */
|
|
11
|
+
value?: string;
|
|
12
|
+
options: SegmentOption[];
|
|
13
|
+
/** Submits with a form when set. */
|
|
14
|
+
name?: string;
|
|
15
|
+
size?: SegmentedSize;
|
|
16
|
+
tone?: Tone;
|
|
17
|
+
/** Spread the segments evenly across the full width. */
|
|
18
|
+
fullWidth?: boolean;
|
|
19
|
+
label?: string;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
onchange?: (value: string) => void;
|
|
22
|
+
}
|
|
23
|
+
declare const SegmentedControl: import("svelte").Component<Props, {}, "value">;
|
|
24
|
+
type SegmentedControl = ReturnType<typeof SegmentedControl>;
|
|
25
|
+
export default SegmentedControl;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { HTMLSelectAttributes } from 'svelte/elements';
|
|
4
|
+
import { toneFocusBorder, type Tone } from '../../core/tones.js';
|
|
5
|
+
import { edge } from './lift.js';
|
|
6
|
+
|
|
7
|
+
export interface SelectOption {
|
|
8
|
+
value: string;
|
|
9
|
+
label: string;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface Props extends HTMLSelectAttributes {
|
|
14
|
+
value?: string;
|
|
15
|
+
/** Data-driven options. Omit and pass `children` to write `<option>`s yourself. */
|
|
16
|
+
options?: SelectOption[];
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
tone?: Tone;
|
|
19
|
+
invalid?: boolean;
|
|
20
|
+
children?: Snippet;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let {
|
|
24
|
+
value = $bindable(''),
|
|
25
|
+
options,
|
|
26
|
+
placeholder,
|
|
27
|
+
tone = 'brand',
|
|
28
|
+
invalid = false,
|
|
29
|
+
class: className = '',
|
|
30
|
+
children,
|
|
31
|
+
...rest
|
|
32
|
+
}: Props = $props();
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<span class="relative inline-flex w-full items-center">
|
|
36
|
+
<select
|
|
37
|
+
bind:value
|
|
38
|
+
aria-invalid={invalid ? 'true' : undefined}
|
|
39
|
+
class="h-10 w-full appearance-none rounded-xl border bg-bg py-0 pr-9 pl-3 font-sans text-sm text-text {edge} transition-colors duration-150 ease-brand-out focus:outline-none disabled:pointer-events-none disabled:opacity-50
|
|
40
|
+
{invalid ? 'border-danger' : `border-hairline-strong ${toneFocusBorder[tone]}`} {className}"
|
|
41
|
+
{...rest}
|
|
42
|
+
>
|
|
43
|
+
{#if placeholder}
|
|
44
|
+
<option value="" disabled>{placeholder}</option>
|
|
45
|
+
{/if}
|
|
46
|
+
{#if options}
|
|
47
|
+
{#each options as option (option.value)}
|
|
48
|
+
<option value={option.value} disabled={option.disabled}>{option.label}</option>
|
|
49
|
+
{/each}
|
|
50
|
+
{:else if children}
|
|
51
|
+
{@render children()}
|
|
52
|
+
{/if}
|
|
53
|
+
</select>
|
|
54
|
+
<svg
|
|
55
|
+
class="pointer-events-none absolute right-3 size-4 text-text-muted"
|
|
56
|
+
viewBox="0 0 16 16"
|
|
57
|
+
fill="none"
|
|
58
|
+
aria-hidden="true"
|
|
59
|
+
>
|
|
60
|
+
<path d="m4 6 4 4 4-4" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" />
|
|
61
|
+
</svg>
|
|
62
|
+
</span>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLSelectAttributes } from 'svelte/elements';
|
|
3
|
+
import { type Tone } from '../../core/tones.js';
|
|
4
|
+
export interface SelectOption {
|
|
5
|
+
value: string;
|
|
6
|
+
label: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
interface Props extends HTMLSelectAttributes {
|
|
10
|
+
value?: string;
|
|
11
|
+
/** Data-driven options. Omit and pass `children` to write `<option>`s yourself. */
|
|
12
|
+
options?: SelectOption[];
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
tone?: Tone;
|
|
15
|
+
invalid?: boolean;
|
|
16
|
+
children?: Snippet;
|
|
17
|
+
}
|
|
18
|
+
declare const Select: import("svelte").Component<Props, {}, "value">;
|
|
19
|
+
type Select = ReturnType<typeof Select>;
|
|
20
|
+
export default Select;
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
export interface SidebarItem {
|
|
3
|
+
/** Stable id used for the active state. Falls back to `href`. */
|
|
4
|
+
id?: string;
|
|
5
|
+
label: string;
|
|
6
|
+
href?: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
badge?: string | number;
|
|
9
|
+
/** Nested links — the parent becomes a collapsible group. */
|
|
10
|
+
items?: SidebarItem[];
|
|
11
|
+
/** Open the group on first render. */
|
|
12
|
+
open?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface SidebarSection {
|
|
16
|
+
/** Small heading above a run of items. */
|
|
17
|
+
label?: string;
|
|
18
|
+
items: SidebarItem[];
|
|
19
|
+
}
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<script lang="ts">
|
|
23
|
+
import type { Snippet } from 'svelte';
|
|
24
|
+
import { useLocale } from '../../core/locale.svelte.js';
|
|
25
|
+
import { focusRing, toneRing, toneSoft, type Tone } from '../../core/tones.js';
|
|
26
|
+
|
|
27
|
+
interface Props {
|
|
28
|
+
sections: SidebarSection[];
|
|
29
|
+
/** Bindable — the `id` (or `href`) of the current item. */
|
|
30
|
+
value?: string;
|
|
31
|
+
/** Bindable — narrow rail mode. */
|
|
32
|
+
collapsed?: boolean;
|
|
33
|
+
/** Show the collapse button. */
|
|
34
|
+
collapsible?: boolean;
|
|
35
|
+
tone?: Tone;
|
|
36
|
+
header?: Snippet;
|
|
37
|
+
footer?: Snippet;
|
|
38
|
+
onnavigate?: (item: SidebarItem) => void;
|
|
39
|
+
class?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
let {
|
|
43
|
+
sections,
|
|
44
|
+
value = $bindable(''),
|
|
45
|
+
collapsed = $bindable(false),
|
|
46
|
+
collapsible = true,
|
|
47
|
+
tone = 'brand',
|
|
48
|
+
header,
|
|
49
|
+
footer,
|
|
50
|
+
onnavigate,
|
|
51
|
+
class: className = ''
|
|
52
|
+
}: Props = $props();
|
|
53
|
+
|
|
54
|
+
const t = useLocale();
|
|
55
|
+
|
|
56
|
+
const keyOf = (item: SidebarItem) => item.id ?? item.href ?? item.label;
|
|
57
|
+
|
|
58
|
+
/** Groups start open when asked, or when they contain the active item. */
|
|
59
|
+
let opened = $state<Record<string, boolean>>({});
|
|
60
|
+
|
|
61
|
+
const isOpen = (item: SidebarItem) =>
|
|
62
|
+
opened[keyOf(item)] ?? (item.open || item.items!.some((child) => keyOf(child) === value));
|
|
63
|
+
|
|
64
|
+
function toggle(item: SidebarItem) {
|
|
65
|
+
opened = { ...opened, [keyOf(item)]: !isOpen(item) };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function go(item: SidebarItem) {
|
|
69
|
+
if (item.disabled) return;
|
|
70
|
+
value = keyOf(item);
|
|
71
|
+
onnavigate?.(item);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const row =
|
|
75
|
+
'flex w-full items-center gap-3 rounded-xl px-2.5 py-2 text-left font-sans text-sm transition-colors duration-150 ease-brand-out disabled:pointer-events-none disabled:opacity-40';
|
|
76
|
+
</script>
|
|
77
|
+
|
|
78
|
+
<aside
|
|
79
|
+
class="flex h-full shrink-0 flex-col border-r border-hairline bg-bg-alt transition-[width] duration-200 ease-brand-out
|
|
80
|
+
{collapsed ? 'w-16' : 'w-60'} {className}"
|
|
81
|
+
>
|
|
82
|
+
{#if header}
|
|
83
|
+
<div class="flex h-16 shrink-0 items-center gap-3 border-b border-hairline px-3">
|
|
84
|
+
{@render header()}
|
|
85
|
+
</div>
|
|
86
|
+
{/if}
|
|
87
|
+
|
|
88
|
+
<nav aria-label={t.current.navigation} class="flex-1 overflow-y-auto p-2">
|
|
89
|
+
{#each sections as section, i (section.label ?? i)}
|
|
90
|
+
<div class="flex flex-col gap-0.5 {i > 0 ? 'mt-4' : ''}">
|
|
91
|
+
{#if section.label && !collapsed}
|
|
92
|
+
<p class="px-2.5 pb-1 font-sans text-[11px] font-semibold text-text-muted">
|
|
93
|
+
{section.label}
|
|
94
|
+
</p>
|
|
95
|
+
{:else if section.label && collapsed && i > 0}
|
|
96
|
+
<div class="mx-2 mb-1 h-px bg-hairline" role="separator"></div>
|
|
97
|
+
{/if}
|
|
98
|
+
|
|
99
|
+
{#each section.items as item (keyOf(item))}
|
|
100
|
+
{#if item.items?.length}
|
|
101
|
+
<button
|
|
102
|
+
type="button"
|
|
103
|
+
onclick={() => toggle(item)}
|
|
104
|
+
aria-expanded={isOpen(item)}
|
|
105
|
+
title={collapsed ? item.label : undefined}
|
|
106
|
+
class="{row} {focusRing} {toneRing[
|
|
107
|
+
tone
|
|
108
|
+
]} text-text-secondary hover:bg-bg-inset hover:text-text"
|
|
109
|
+
>
|
|
110
|
+
<span class="min-w-0 flex-1 truncate {collapsed ? 'sr-only' : ''}">{item.label}</span>
|
|
111
|
+
{#if !collapsed}
|
|
112
|
+
<svg
|
|
113
|
+
class="size-3.5 shrink-0 transition-transform duration-200 {isOpen(item)
|
|
114
|
+
? 'rotate-90'
|
|
115
|
+
: ''}"
|
|
116
|
+
viewBox="0 0 16 16"
|
|
117
|
+
fill="none"
|
|
118
|
+
aria-hidden="true"
|
|
119
|
+
>
|
|
120
|
+
<path
|
|
121
|
+
d="m6 4 4 4-4 4"
|
|
122
|
+
stroke="currentColor"
|
|
123
|
+
stroke-width="1.6"
|
|
124
|
+
stroke-linecap="round"
|
|
125
|
+
/>
|
|
126
|
+
</svg>
|
|
127
|
+
{/if}
|
|
128
|
+
</button>
|
|
129
|
+
|
|
130
|
+
{#if isOpen(item) && !collapsed}
|
|
131
|
+
<div class="ml-4 flex flex-col gap-0.5 border-l border-hairline pl-2">
|
|
132
|
+
{#each item.items as child (keyOf(child))}
|
|
133
|
+
<a
|
|
134
|
+
href={child.href}
|
|
135
|
+
onclick={() => go(child)}
|
|
136
|
+
aria-current={value === keyOf(child) ? 'page' : undefined}
|
|
137
|
+
class="{row} {focusRing} {toneRing[tone]} {value === keyOf(child)
|
|
138
|
+
? `${toneSoft[tone]} font-medium`
|
|
139
|
+
: 'text-text-muted hover:bg-bg-inset hover:text-text'} {child.disabled
|
|
140
|
+
? 'pointer-events-none opacity-40'
|
|
141
|
+
: ''}"
|
|
142
|
+
>
|
|
143
|
+
<span class="min-w-0 flex-1 truncate">{child.label}</span>
|
|
144
|
+
{#if child.badge !== undefined}
|
|
145
|
+
<span class="shrink-0 text-[11px] tabular-nums">{child.badge}</span>
|
|
146
|
+
{/if}
|
|
147
|
+
</a>
|
|
148
|
+
{/each}
|
|
149
|
+
</div>
|
|
150
|
+
{/if}
|
|
151
|
+
{:else}
|
|
152
|
+
<a
|
|
153
|
+
href={item.href}
|
|
154
|
+
onclick={() => go(item)}
|
|
155
|
+
aria-current={value === keyOf(item) ? 'page' : undefined}
|
|
156
|
+
title={collapsed ? item.label : undefined}
|
|
157
|
+
class="{row} {focusRing} {toneRing[tone]} {value === keyOf(item)
|
|
158
|
+
? `${toneSoft[tone]} font-medium`
|
|
159
|
+
: 'text-text-secondary hover:bg-bg-inset hover:text-text'} {item.disabled
|
|
160
|
+
? 'pointer-events-none opacity-40'
|
|
161
|
+
: ''}"
|
|
162
|
+
>
|
|
163
|
+
<span class="min-w-0 flex-1 truncate {collapsed ? 'sr-only' : ''}">{item.label}</span>
|
|
164
|
+
{#if item.badge !== undefined && !collapsed}
|
|
165
|
+
<span class="shrink-0 text-[11px] text-text-muted tabular-nums">{item.badge}</span>
|
|
166
|
+
{/if}
|
|
167
|
+
</a>
|
|
168
|
+
{/if}
|
|
169
|
+
{/each}
|
|
170
|
+
</div>
|
|
171
|
+
{/each}
|
|
172
|
+
</nav>
|
|
173
|
+
|
|
174
|
+
{#if footer || collapsible}
|
|
175
|
+
<div class="flex shrink-0 flex-col gap-2 border-t border-hairline p-2">
|
|
176
|
+
{#if footer}
|
|
177
|
+
{@render footer()}
|
|
178
|
+
{/if}
|
|
179
|
+
{#if collapsible}
|
|
180
|
+
<button
|
|
181
|
+
type="button"
|
|
182
|
+
onclick={() => (collapsed = !collapsed)}
|
|
183
|
+
aria-label={collapsed ? t.current.expandSidebar : t.current.collapseSidebar}
|
|
184
|
+
class="inline-flex h-8 items-center justify-center gap-2 rounded-xl font-sans text-xs text-text-muted transition-colors duration-150 hover:bg-bg-inset hover:text-text {focusRing} {toneRing[
|
|
185
|
+
tone
|
|
186
|
+
]}"
|
|
187
|
+
>
|
|
188
|
+
<svg
|
|
189
|
+
class="size-4 transition-transform duration-200 {collapsed ? 'rotate-180' : ''}"
|
|
190
|
+
viewBox="0 0 16 16"
|
|
191
|
+
fill="none"
|
|
192
|
+
aria-hidden="true"
|
|
193
|
+
>
|
|
194
|
+
<path
|
|
195
|
+
d="m10 4-4 4 4 4"
|
|
196
|
+
stroke="currentColor"
|
|
197
|
+
stroke-width="1.6"
|
|
198
|
+
stroke-linecap="round"
|
|
199
|
+
/>
|
|
200
|
+
</svg>
|
|
201
|
+
{#if !collapsed}<span>{t.current.collapseSidebar}</span>{/if}
|
|
202
|
+
</button>
|
|
203
|
+
{/if}
|
|
204
|
+
</div>
|
|
205
|
+
{/if}
|
|
206
|
+
</aside>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export interface SidebarItem {
|
|
2
|
+
/** Stable id used for the active state. Falls back to `href`. */
|
|
3
|
+
id?: string;
|
|
4
|
+
label: string;
|
|
5
|
+
href?: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
badge?: string | number;
|
|
8
|
+
/** Nested links — the parent becomes a collapsible group. */
|
|
9
|
+
items?: SidebarItem[];
|
|
10
|
+
/** Open the group on first render. */
|
|
11
|
+
open?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface SidebarSection {
|
|
14
|
+
/** Small heading above a run of items. */
|
|
15
|
+
label?: string;
|
|
16
|
+
items: SidebarItem[];
|
|
17
|
+
}
|
|
18
|
+
import type { Snippet } from 'svelte';
|
|
19
|
+
import { type Tone } from '../../core/tones.js';
|
|
20
|
+
interface Props {
|
|
21
|
+
sections: SidebarSection[];
|
|
22
|
+
/** Bindable — the `id` (or `href`) of the current item. */
|
|
23
|
+
value?: string;
|
|
24
|
+
/** Bindable — narrow rail mode. */
|
|
25
|
+
collapsed?: boolean;
|
|
26
|
+
/** Show the collapse button. */
|
|
27
|
+
collapsible?: boolean;
|
|
28
|
+
tone?: Tone;
|
|
29
|
+
header?: Snippet;
|
|
30
|
+
footer?: Snippet;
|
|
31
|
+
onnavigate?: (item: SidebarItem) => void;
|
|
32
|
+
class?: string;
|
|
33
|
+
}
|
|
34
|
+
declare const Sidebar: import("svelte").Component<Props, {}, "value" | "collapsed">;
|
|
35
|
+
type Sidebar = ReturnType<typeof Sidebar>;
|
|
36
|
+
export default Sidebar;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
|
|
4
|
+
export type SkeletonVariant = 'text' | 'block' | 'circle';
|
|
5
|
+
|
|
6
|
+
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
7
|
+
variant?: SkeletonVariant;
|
|
8
|
+
/** `text` only — number of stacked lines, the last one runs short. */
|
|
9
|
+
lines?: number;
|
|
10
|
+
/** Any CSS length, e.g. `'12rem'` or `'60%'`. */
|
|
11
|
+
width?: string;
|
|
12
|
+
height?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let {
|
|
16
|
+
variant = 'text',
|
|
17
|
+
lines = 1,
|
|
18
|
+
width,
|
|
19
|
+
height,
|
|
20
|
+
class: className = '',
|
|
21
|
+
...rest
|
|
22
|
+
}: Props = $props();
|
|
23
|
+
|
|
24
|
+
const variants: Record<SkeletonVariant, string> = {
|
|
25
|
+
text: 'h-4 w-full rounded-xl',
|
|
26
|
+
block: 'h-24 w-full rounded-2xl',
|
|
27
|
+
circle: 'size-10 rounded-full'
|
|
28
|
+
};
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
{#if variant === 'text' && lines > 1}
|
|
32
|
+
<div class="flex w-full flex-col gap-2 {className}" {...rest}>
|
|
33
|
+
{#each { length: lines }, i (i)}
|
|
34
|
+
<div
|
|
35
|
+
class="h-4 animate-pulse rounded-xl bg-bg-inset {i === lines - 1 ? 'w-2/3' : 'w-full'}"
|
|
36
|
+
style={width && i !== lines - 1 ? `width:${width}` : undefined}
|
|
37
|
+
></div>
|
|
38
|
+
{/each}
|
|
39
|
+
</div>
|
|
40
|
+
{:else}
|
|
41
|
+
<div
|
|
42
|
+
class="animate-pulse bg-bg-inset {variants[variant]} {className}"
|
|
43
|
+
style="{width ? `width:${width};` : ''}{height ? `height:${height};` : ''}"
|
|
44
|
+
{...rest}
|
|
45
|
+
></div>
|
|
46
|
+
{/if}
|