@urbicon-ui/blocks 6.1.8 → 6.3.1
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 +12 -2
- package/dist/components/AreaChart/AreaChart.svelte +2 -6
- package/dist/components/BarChart/BarChart.svelte +2 -6
- package/dist/components/Calendar/Calendar.svelte +12 -10
- package/dist/components/Calendar/calendar.variants.d.ts +2 -1
- package/dist/components/Calendar/index.d.ts +2 -2
- package/dist/components/CommandPalette/CommandPalette.svelte +106 -39
- package/dist/components/CommandPalette/commandPalette.variants.d.ts +3 -7
- package/dist/components/CommandPalette/commandPalette.variants.js +0 -1
- package/dist/components/CommandPalette/index.d.ts +2 -2
- package/dist/components/CompositionBar/CompositionBar.svelte +12 -15
- package/dist/components/CompositionBar/composition-bar.variants.d.ts +3 -1
- package/dist/components/CompositionBar/index.d.ts +2 -2
- package/dist/components/DonutChart/DonutChart.svelte +2 -6
- package/dist/components/EmptyState/EmptyState.svelte +8 -9
- package/dist/components/EmptyState/emptyState.variants.d.ts +3 -1
- package/dist/components/EmptyState/index.d.ts +3 -3
- package/dist/components/FileUpload/FileUpload.svelte +17 -17
- package/dist/components/FileUpload/fileUpload.variants.d.ts +3 -11
- package/dist/components/FileUpload/fileUpload.variants.js +0 -5
- package/dist/components/FileUpload/index.d.ts +4 -3
- package/dist/components/Guide/Guide.svelte +5 -8
- package/dist/components/Guide/GuideArticle.svelte +5 -8
- package/dist/components/Guide/GuideBeacon.svelte +5 -8
- package/dist/components/Guide/GuideHint.svelte +5 -8
- package/dist/components/Guide/GuideMarker.svelte +5 -8
- package/dist/components/Guide/GuideMention.svelte +5 -8
- package/dist/components/Guide/GuidePanel.svelte +5 -8
- package/dist/components/Guide/guide.variants.d.ts +9 -1
- package/dist/components/Guide/index.d.ts +12 -9
- package/dist/components/LineChart/LineChart.svelte +2 -6
- package/dist/components/Planner/Planner.svelte +7 -10
- package/dist/components/Planner/index.d.ts +4 -4
- package/dist/components/Planner/planner.variants.d.ts +3 -1
- package/dist/components/Sankey/Sankey.svelte +8 -9
- package/dist/components/Sankey/index.d.ts +2 -2
- package/dist/components/Sankey/sankey.variants.d.ts +3 -1
- package/dist/components/SidebarLayout/SidebarLayout.svelte +17 -17
- package/dist/components/SidebarLayout/index.d.ts +8 -2
- package/dist/components/SidebarLayout/sidebar-layout.variants.d.ts +3 -1
- package/dist/components/ThemeSwitcher/ThemeSwitcher.svelte +30 -38
- package/dist/components/ThemeSwitcher/index.d.ts +6 -4
- package/dist/components/ThemeSwitcher/themeSwitcher.variants.d.ts +3 -1
- package/dist/primitives/Accordion/Accordion.svelte +7 -9
- package/dist/primitives/Accordion/AccordionItem.svelte +8 -20
- package/dist/primitives/Accordion/accordion.variants.d.ts +3 -1
- package/dist/primitives/Accordion/index.d.ts +6 -6
- package/dist/primitives/Alert/Alert.svelte +7 -21
- package/dist/primitives/Alert/alert.variants.d.ts +3 -1
- package/dist/primitives/Alert/index.d.ts +3 -3
- package/dist/primitives/Avatar/Avatar.svelte +17 -20
- package/dist/primitives/Avatar/avatar.variants.d.ts +3 -1
- package/dist/primitives/Avatar/index.d.ts +3 -3
- package/dist/primitives/Badge/Badge.svelte +20 -23
- package/dist/primitives/Badge/badge.variants.d.ts +3 -1
- package/dist/primitives/Badge/index.d.ts +2 -2
- package/dist/primitives/Breadcrumb/Breadcrumb.svelte +30 -32
- package/dist/primitives/Breadcrumb/breadcrumb.variants.d.ts +3 -1
- package/dist/primitives/Breadcrumb/index.d.ts +2 -2
- package/dist/primitives/Button/Button.svelte +21 -21
- package/dist/primitives/Button/button.variants.d.ts +3 -1
- package/dist/primitives/Button/index.d.ts +3 -3
- package/dist/primitives/ButtonGroup/ButtonGroup.svelte +15 -14
- package/dist/primitives/ButtonGroup/buttongroup.variants.d.ts +3 -1
- package/dist/primitives/ButtonGroup/index.d.ts +3 -2
- package/dist/primitives/Card/Card.svelte +15 -18
- package/dist/primitives/Card/card.variants.d.ts +3 -1
- package/dist/primitives/Card/index.d.ts +3 -3
- package/dist/primitives/Checkbox/Checkbox.svelte +20 -20
- package/dist/primitives/Checkbox/checkbox.variants.d.ts +3 -1
- package/dist/primitives/Checkbox/index.d.ts +7 -3
- package/dist/primitives/Collapsible/Collapsible.svelte +30 -30
- package/dist/primitives/Collapsible/collapsible.variants.d.ts +3 -1
- package/dist/primitives/Collapsible/index.d.ts +3 -3
- package/dist/primitives/Combobox/Combobox.svelte +20 -31
- package/dist/primitives/Combobox/combobox.variants.d.ts +3 -1
- package/dist/primitives/Combobox/index.d.ts +5 -3
- package/dist/primitives/Dialog/Dialog.svelte +7 -10
- package/dist/primitives/Dialog/dialog.variants.d.ts +3 -1
- package/dist/primitives/Dialog/index.d.ts +2 -2
- package/dist/primitives/Drawer/Drawer.svelte +7 -10
- package/dist/primitives/Drawer/drawer.variants.d.ts +3 -1
- package/dist/primitives/Drawer/index.d.ts +2 -2
- package/dist/primitives/Input/Input.svelte +54 -30
- package/dist/primitives/Input/index.d.ts +7 -3
- package/dist/primitives/Input/input.variants.d.ts +3 -1
- package/dist/primitives/Menu/Menu.svelte +23 -23
- package/dist/primitives/Menu/index.d.ts +4 -1
- package/dist/primitives/Menu/menu.variants.d.ts +3 -1
- package/dist/primitives/Pagination/Pagination.svelte +18 -16
- package/dist/primitives/Pagination/index.d.ts +2 -2
- package/dist/primitives/Pagination/pagination.variants.d.ts +3 -1
- package/dist/primitives/Popover/Popover.svelte +2 -6
- package/dist/primitives/Progress/Progress.svelte +17 -17
- package/dist/primitives/Progress/index.d.ts +8 -3
- package/dist/primitives/Progress/progress.variants.d.ts +3 -1
- package/dist/primitives/RadioGroup/RadioGroup.svelte +16 -16
- package/dist/primitives/RadioGroup/RadioItem.svelte +19 -19
- package/dist/primitives/RadioGroup/index.d.ts +3 -3
- package/dist/primitives/RadioGroup/radioGroup.variants.d.ts +4 -1
- package/dist/primitives/SegmentGroup/SegmentGroup.svelte +14 -11
- package/dist/primitives/SegmentGroup/SegmentItem.svelte +12 -11
- package/dist/primitives/SegmentGroup/index.d.ts +3 -3
- package/dist/primitives/SegmentGroup/segmentgroup.variants.d.ts +3 -1
- package/dist/primitives/Select/Select.svelte +31 -22
- package/dist/primitives/Select/index.d.ts +8 -3
- package/dist/primitives/Select/select.variants.d.ts +3 -1
- package/dist/primitives/Separator/Separator.svelte +2 -6
- package/dist/primitives/Sidebar/Sidebar.svelte +6 -9
- package/dist/primitives/Sidebar/index.d.ts +2 -2
- package/dist/primitives/Sidebar/sidebar.variants.d.ts +3 -1
- package/dist/primitives/Skeleton/Skeleton.svelte +7 -9
- package/dist/primitives/Skeleton/index.d.ts +3 -3
- package/dist/primitives/Skeleton/skeleton.variants.d.ts +3 -1
- package/dist/primitives/Skeleton/skeleton.variants.js +5 -6
- package/dist/primitives/Slider/Slider.svelte +19 -19
- package/dist/primitives/Slider/index.d.ts +8 -3
- package/dist/primitives/Slider/slider.variants.d.ts +3 -1
- package/dist/primitives/Spinner/Spinner.svelte +7 -9
- package/dist/primitives/Spinner/index.d.ts +5 -3
- package/dist/primitives/Spinner/spinner.variants.d.ts +3 -1
- package/dist/primitives/Stepper/Stepper.svelte +13 -18
- package/dist/primitives/Stepper/StepperStep.svelte +18 -19
- package/dist/primitives/Stepper/index.d.ts +5 -5
- package/dist/primitives/Stepper/stepper.variants.d.ts +3 -1
- package/dist/primitives/Tab/Tab.svelte +14 -17
- package/dist/primitives/Tab/TabItem.svelte +18 -19
- package/dist/primitives/Tab/TabPanel.svelte +10 -13
- package/dist/primitives/Tab/index.d.ts +7 -7
- package/dist/primitives/Tab/tab.variants.d.ts +3 -1
- package/dist/primitives/Textarea/Textarea.svelte +23 -23
- package/dist/primitives/Textarea/index.d.ts +7 -3
- package/dist/primitives/Textarea/textarea.variants.d.ts +3 -1
- package/dist/primitives/Toast/Toaster.svelte +5 -6
- package/dist/primitives/Toast/index.d.ts +2 -2
- package/dist/primitives/Toast/toast.variants.d.ts +3 -1
- package/dist/primitives/Toggle/Toggle.svelte +19 -19
- package/dist/primitives/Toggle/index.d.ts +7 -3
- package/dist/primitives/Toggle/toggle.variants.d.ts +3 -1
- package/dist/primitives/Toolbar/Toolbar.svelte +7 -9
- package/dist/primitives/Toolbar/index.d.ts +4 -3
- package/dist/primitives/Toolbar/toolbar.variants.d.ts +3 -1
- package/dist/primitives/Tooltip/Tooltip.svelte +7 -9
- package/dist/primitives/Tooltip/index.d.ts +2 -2
- package/dist/primitives/Tooltip/tooltip.variants.d.ts +3 -1
- package/dist/provider/blocks-context.d.ts +45 -0
- package/dist/provider/blocks-context.js +57 -0
- package/dist/provider/index.d.ts +1 -1
- package/dist/provider/index.js +1 -1
- package/dist/style/semantic.css +5 -0
- package/dist/utils/variants.d.ts +32 -0
- package/dist/utils/variants.js +26 -1
- package/package.json +3 -3
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script lang="ts" generics="T extends string | number | boolean = string">
|
|
2
2
|
import { useBlocksI18n, mintRegistry } from '../..';
|
|
3
3
|
import { tick } from 'svelte';
|
|
4
|
-
import { comboboxVariants } from './combobox.variants';
|
|
5
|
-
import { getBlocksConfig,
|
|
4
|
+
import { comboboxVariants, type ComboboxVariants } from './combobox.variants';
|
|
5
|
+
import { getBlocksConfig, resolveSlotClasses } from '../../provider';
|
|
6
6
|
import { resolveIcon } from '../../icons';
|
|
7
7
|
import CloseIconDefault from '../../icons/CloseIcon.svelte';
|
|
8
8
|
import ChevronDownIconDefault from '../../icons/ChevronDownIcon.svelte';
|
|
@@ -64,13 +64,6 @@
|
|
|
64
64
|
|
|
65
65
|
const blocksConfig = getBlocksConfig();
|
|
66
66
|
const unstyled = $derived(unstyledProp || blocksConfig?.unstyled || false);
|
|
67
|
-
const slotClasses = $derived(
|
|
68
|
-
mergeSlotClasses(
|
|
69
|
-
blocksConfig?.defaults?.Combobox?.slotClasses,
|
|
70
|
-
resolvePresetSlotClasses(blocksConfig?.presets, 'Combobox', preset),
|
|
71
|
-
slotClassesProp
|
|
72
|
-
)
|
|
73
|
-
);
|
|
74
67
|
|
|
75
68
|
let inputEl = $state<HTMLInputElement>();
|
|
76
69
|
let listboxEl = $state<HTMLElement>();
|
|
@@ -95,25 +88,11 @@
|
|
|
95
88
|
return options.filter((o) => filterFn(o, query.trim()));
|
|
96
89
|
});
|
|
97
90
|
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
requiredMark: () => '',
|
|
104
|
-
inputWrapper: () => '',
|
|
105
|
-
input: () => '',
|
|
106
|
-
message: () => '',
|
|
107
|
-
hint: () => '',
|
|
108
|
-
listbox: () => '',
|
|
109
|
-
option: () => '',
|
|
110
|
-
optionActive: () => '',
|
|
111
|
-
optionSelected: () => '',
|
|
112
|
-
noResults: () => '',
|
|
113
|
-
clear: () => '',
|
|
114
|
-
chevron: () => ''
|
|
115
|
-
}
|
|
116
|
-
: comboboxVariants({ tier: effectiveTier, size, open, disabled })
|
|
91
|
+
const variantProps: ComboboxVariants = $derived({ tier: effectiveTier, size, open, disabled });
|
|
92
|
+
const styles = $derived(comboboxVariants(variantProps));
|
|
93
|
+
|
|
94
|
+
const slotClasses = $derived(
|
|
95
|
+
resolveSlotClasses(blocksConfig, 'Combobox', preset, variantProps, slotClassesProp)
|
|
117
96
|
);
|
|
118
97
|
|
|
119
98
|
// Focus-restoration policy follows the ARIA Combobox pattern:
|
|
@@ -384,12 +363,22 @@
|
|
|
384
363
|
data-active={isActive}
|
|
385
364
|
disabled={opt.disabled}
|
|
386
365
|
class={unstyled
|
|
387
|
-
?
|
|
366
|
+
? [
|
|
367
|
+
slotClasses?.option,
|
|
368
|
+
isActive ? slotClasses?.optionActive : undefined,
|
|
369
|
+
isSelected ? slotClasses?.optionSelected : undefined
|
|
370
|
+
]
|
|
371
|
+
.filter(Boolean)
|
|
372
|
+
.join(' ')
|
|
388
373
|
: styles.option({
|
|
389
374
|
class: [
|
|
390
375
|
slotClasses?.option,
|
|
391
|
-
isActive
|
|
392
|
-
|
|
376
|
+
isActive
|
|
377
|
+
? styles.optionActive({ class: slotClasses?.optionActive })
|
|
378
|
+
: undefined,
|
|
379
|
+
isSelected
|
|
380
|
+
? styles.optionSelected({ class: slotClasses?.optionSelected })
|
|
381
|
+
: undefined
|
|
393
382
|
].filter(Boolean)
|
|
394
383
|
})}
|
|
395
384
|
onclick={() => select(opt)}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type VariantProps } from '../../utils/variants';
|
|
1
|
+
import { type SlotNames, type VariantProps } from '../../utils/variants';
|
|
2
2
|
export declare const comboboxVariants: (props?: import("../../utils/variants").TVProps<{
|
|
3
3
|
tier: {
|
|
4
4
|
modify: {
|
|
@@ -161,3 +161,5 @@ export declare const comboboxVariants: (props?: import("../../utils/variants").T
|
|
|
161
161
|
}) | undefined) => string;
|
|
162
162
|
};
|
|
163
163
|
export type ComboboxVariants = VariantProps<typeof comboboxVariants>;
|
|
164
|
+
/** Slot names derived from the tv() config — single source of truth for slotClasses. */
|
|
165
|
+
export type ComboboxSlots = SlotNames<typeof comboboxVariants>;
|
|
@@ -2,7 +2,7 @@ import type { Snippet } from 'svelte';
|
|
|
2
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
3
|
import type { MintProp } from '../../mint';
|
|
4
4
|
import type { SelectValue } from '../Select/index';
|
|
5
|
-
import type { ComboboxVariants } from './combobox.variants';
|
|
5
|
+
import type { ComboboxSlots, ComboboxVariants } from './combobox.variants';
|
|
6
6
|
/** A single combobox option with label, value, and optional disabled state. */
|
|
7
7
|
export interface ComboboxOption<T extends SelectValue = string> {
|
|
8
8
|
label: string;
|
|
@@ -114,8 +114,10 @@ export interface ComboboxProps<T extends SelectValue = string> extends ComboboxV
|
|
|
114
114
|
class?: string;
|
|
115
115
|
/** Remove all default tv() classes — only user-provided classes apply. @default false */
|
|
116
116
|
unstyled?: boolean;
|
|
117
|
-
/** Per-slot class overrides merged with tv() styles.
|
|
118
|
-
|
|
117
|
+
/** Per-slot class overrides merged with tv() styles. Slots: base | label | requiredMark |
|
|
118
|
+
* inputWrapper | input | message | hint | listbox | option | optionActive | optionSelected |
|
|
119
|
+
* noResults | clear | chevron */
|
|
120
|
+
slotClasses?: Partial<Record<ComboboxSlots, string>>;
|
|
119
121
|
/**
|
|
120
122
|
* Apply a named preset registered via `<BlocksProvider presets={{ Combobox: {...} }}>`.
|
|
121
123
|
* Prefer this over `class` overrides when the requested look falls outside the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { useBlocksI18n } from '../..';
|
|
3
|
-
import { getBlocksConfig,
|
|
3
|
+
import { getBlocksConfig, resolveSlotClasses } from '../../provider';
|
|
4
4
|
import { resolveIcon } from '../../icons';
|
|
5
5
|
import CloseIconDefault from '../../icons/CloseIcon.svelte';
|
|
6
6
|
import { onDestroy } from 'svelte';
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
import { overlayStack, getOverlayMotion } from '../../utils';
|
|
15
15
|
import Button from '../Button/Button.svelte';
|
|
16
16
|
import type { DialogProps } from './index';
|
|
17
|
-
import { dialogVariants } from './dialog.variants';
|
|
17
|
+
import { dialogVariants, type DialogVariants } from './dialog.variants';
|
|
18
18
|
|
|
19
19
|
const bt = useBlocksI18n();
|
|
20
20
|
|
|
@@ -62,13 +62,6 @@
|
|
|
62
62
|
|
|
63
63
|
const blocksConfig = getBlocksConfig();
|
|
64
64
|
const unstyled = $derived(unstyledProp || blocksConfig?.unstyled || false);
|
|
65
|
-
const slotClasses = $derived(
|
|
66
|
-
mergeSlotClasses(
|
|
67
|
-
blocksConfig?.defaults?.Dialog?.slotClasses,
|
|
68
|
-
resolvePresetSlotClasses(blocksConfig?.presets, 'Dialog', preset),
|
|
69
|
-
slotClassesProp
|
|
70
|
-
)
|
|
71
|
-
);
|
|
72
65
|
|
|
73
66
|
let dialogEl = $state<HTMLDialogElement>();
|
|
74
67
|
let panelEl = $state<HTMLElement>();
|
|
@@ -82,7 +75,11 @@
|
|
|
82
75
|
const bodyId = `dialog-body-${uid}`;
|
|
83
76
|
const overlayId = `dialog-${uid}`;
|
|
84
77
|
|
|
85
|
-
const
|
|
78
|
+
const variantProps: DialogVariants = $derived({ size, placement, intent });
|
|
79
|
+
const styles = $derived(dialogVariants(variantProps));
|
|
80
|
+
const slotClasses = $derived(
|
|
81
|
+
resolveSlotClasses(blocksConfig, 'Dialog', preset, variantProps, slotClassesProp)
|
|
82
|
+
);
|
|
86
83
|
|
|
87
84
|
function requestClose() {
|
|
88
85
|
if (!isVisible || !open) return;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type VariantProps } from '../../utils/variants';
|
|
1
|
+
import { type SlotNames, type VariantProps } from '../../utils/variants';
|
|
2
2
|
export declare const dialogVariants: (props?: import("../../utils/variants").TVProps<{
|
|
3
3
|
size: {
|
|
4
4
|
sm: {
|
|
@@ -103,3 +103,5 @@ export declare const dialogVariants: (props?: import("../../utils/variants").TVP
|
|
|
103
103
|
}) | undefined) => string;
|
|
104
104
|
};
|
|
105
105
|
export type DialogVariants = VariantProps<typeof dialogVariants>;
|
|
106
|
+
/** Slot names derived from the `tv()` config above — single source of truth for `slotClasses`. */
|
|
107
|
+
export type DialogSlots = SlotNames<typeof dialogVariants>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { HTMLDialogAttributes } from 'svelte/elements';
|
|
3
|
-
import type { DialogVariants } from './dialog.variants';
|
|
3
|
+
import type { DialogSlots, DialogVariants } from './dialog.variants';
|
|
4
4
|
/**
|
|
5
5
|
* @description Overlay dialog built on native dialog element. Can be used as a simple
|
|
6
6
|
* content-agnostic overlay or as a structured dialog with title, footer, and intent accent.
|
|
@@ -76,7 +76,7 @@ export interface DialogProps extends Omit<HTMLDialogAttributes, 'children' | 'op
|
|
|
76
76
|
/** Strip all default styles. Combine with slotClasses for fully custom appearance. */
|
|
77
77
|
unstyled?: boolean;
|
|
78
78
|
/** Per-slot class overrides merged with variant styles. */
|
|
79
|
-
slotClasses?: Partial<Record<
|
|
79
|
+
slotClasses?: Partial<Record<DialogSlots, string>>;
|
|
80
80
|
/**
|
|
81
81
|
* Apply a named preset registered via `<BlocksProvider presets={{ Dialog: {...} }}>`.
|
|
82
82
|
* Prefer this over `class` overrides when the requested look falls outside the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { useBlocksI18n } from '../..';
|
|
3
|
-
import { getBlocksConfig,
|
|
3
|
+
import { getBlocksConfig, resolveSlotClasses } from '../../provider';
|
|
4
4
|
import { resolveIcon } from '../../icons';
|
|
5
5
|
import CloseIconDefault from '../../icons/CloseIcon.svelte';
|
|
6
6
|
import { onDestroy } from 'svelte';
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
import { overlayStack, getOverlayMotion } from '../../utils';
|
|
15
15
|
import Button from '../Button/Button.svelte';
|
|
16
16
|
import type { DrawerProps } from './index';
|
|
17
|
-
import { drawerVariants } from './drawer.variants';
|
|
17
|
+
import { drawerVariants, type DrawerVariants } from './drawer.variants';
|
|
18
18
|
|
|
19
19
|
const bt = useBlocksI18n();
|
|
20
20
|
|
|
@@ -54,13 +54,6 @@
|
|
|
54
54
|
|
|
55
55
|
const blocksConfig = getBlocksConfig();
|
|
56
56
|
const unstyled = $derived(unstyledProp || blocksConfig?.unstyled || false);
|
|
57
|
-
const slotClasses = $derived(
|
|
58
|
-
mergeSlotClasses(
|
|
59
|
-
blocksConfig?.defaults?.Drawer?.slotClasses,
|
|
60
|
-
resolvePresetSlotClasses(blocksConfig?.presets, 'Drawer', preset),
|
|
61
|
-
slotClassesProp
|
|
62
|
-
)
|
|
63
|
-
);
|
|
64
57
|
|
|
65
58
|
let dialogElement = $state<HTMLDialogElement>();
|
|
66
59
|
let panelElement = $state<HTMLElement>();
|
|
@@ -72,7 +65,11 @@
|
|
|
72
65
|
const bodyId = `drawer-body-${uid}`;
|
|
73
66
|
const overlayId = `drawer-${uid}`;
|
|
74
67
|
|
|
75
|
-
const
|
|
68
|
+
const variantProps: DrawerVariants = $derived({ placement, size, intent });
|
|
69
|
+
const styles = $derived(drawerVariants(variantProps));
|
|
70
|
+
const slotClasses = $derived(
|
|
71
|
+
resolveSlotClasses(blocksConfig, 'Drawer', preset, variantProps, slotClassesProp)
|
|
72
|
+
);
|
|
76
73
|
|
|
77
74
|
const motion = $derived(
|
|
78
75
|
getOverlayMotion({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type VariantProps } from '../../utils/variants';
|
|
1
|
+
import { type SlotNames, type VariantProps } from '../../utils/variants';
|
|
2
2
|
export declare const drawerVariants: (props?: import("../../utils/variants").TVProps<{
|
|
3
3
|
placement: {
|
|
4
4
|
left: {
|
|
@@ -92,3 +92,5 @@ export declare const drawerVariants: (props?: import("../../utils/variants").TVP
|
|
|
92
92
|
}) | undefined) => string;
|
|
93
93
|
};
|
|
94
94
|
export type DrawerVariants = VariantProps<typeof drawerVariants>;
|
|
95
|
+
/** Slot names derived from the `tv()` config above — single source of truth for `slotClasses`. */
|
|
96
|
+
export type DrawerSlots = SlotNames<typeof drawerVariants>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { HTMLDialogAttributes } from 'svelte/elements';
|
|
3
|
-
import type { DrawerVariants } from './drawer.variants';
|
|
3
|
+
import type { DrawerSlots, DrawerVariants } from './drawer.variants';
|
|
4
4
|
/**
|
|
5
5
|
* @description Slide-in panel overlay from any edge of the viewport.
|
|
6
6
|
* Uses native dialog with focus trap, backdrop click dismiss, and Escape key support.
|
|
@@ -66,7 +66,7 @@ export interface DrawerProps extends Omit<HTMLDialogAttributes, 'children' | 'op
|
|
|
66
66
|
/** Strip all default styles. Combine with slotClasses for fully custom appearance. */
|
|
67
67
|
unstyled?: boolean;
|
|
68
68
|
/** Per-slot class overrides merged with variant styles. */
|
|
69
|
-
slotClasses?: Partial<Record<
|
|
69
|
+
slotClasses?: Partial<Record<DrawerSlots, string>>;
|
|
70
70
|
/**
|
|
71
71
|
* Apply a named preset registered via `<BlocksProvider presets={{ Drawer: {...} }}>`.
|
|
72
72
|
* Prefer this over `class` overrides when the requested look falls outside the
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { useBlocksI18n, mintRegistry, createPersistentState } from '../..';
|
|
3
|
-
import { getBlocksConfig,
|
|
3
|
+
import { getBlocksConfig, resolveSlotClasses } from '../../provider';
|
|
4
4
|
import { useFormField, getTierContext } from '../../utils';
|
|
5
5
|
import type { InputProps } from '.';
|
|
6
|
-
import { inputVariants } from './input.variants';
|
|
6
|
+
import { inputVariants, type InputVariants } from './input.variants';
|
|
7
7
|
import { resolveIcon } from '../../icons';
|
|
8
8
|
import CloseIconDefault from '../../icons/CloseIcon.svelte';
|
|
9
9
|
|
|
@@ -50,13 +50,6 @@
|
|
|
50
50
|
|
|
51
51
|
const blocksConfig = getBlocksConfig();
|
|
52
52
|
const unstyled = $derived(unstyledProp || blocksConfig?.unstyled || false);
|
|
53
|
-
const slotClasses = $derived(
|
|
54
|
-
mergeSlotClasses(
|
|
55
|
-
blocksConfig?.defaults?.Input?.slotClasses,
|
|
56
|
-
resolvePresetSlotClasses(blocksConfig?.presets, 'Input', preset),
|
|
57
|
-
slotClassesProp
|
|
58
|
-
)
|
|
59
|
-
);
|
|
60
53
|
|
|
61
54
|
let inputRef = $state<HTMLInputElement>();
|
|
62
55
|
|
|
@@ -99,20 +92,27 @@
|
|
|
99
92
|
const hasLeftIcon = $derived(!!leftIcon);
|
|
100
93
|
const hasRightIcon = $derived(!!(effectiveRightIcon || shouldShowClear));
|
|
101
94
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
95
|
+
// Variant props feed both the tv() style computation and the slot-class
|
|
96
|
+
// cascade — extracted into one derived so `resolveSlotClasses` can match
|
|
97
|
+
// conditional `overrides` against the input's active variants.
|
|
98
|
+
const variantProps: InputVariants = $derived({
|
|
99
|
+
tier: effectiveTier,
|
|
100
|
+
variant,
|
|
101
|
+
size,
|
|
102
|
+
intent,
|
|
103
|
+
disabled: disabled || undefined,
|
|
104
|
+
readonly: readonly || undefined,
|
|
105
|
+
error: !!error || undefined,
|
|
106
|
+
required: required || undefined,
|
|
107
|
+
hasLeftIcon: hasLeftIcon || undefined,
|
|
108
|
+
hasRightIcon: hasRightIcon || undefined,
|
|
109
|
+
messageType: error ? 'error' : 'helper'
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
const styles = $derived(inputVariants(variantProps));
|
|
113
|
+
|
|
114
|
+
const slotClasses = $derived(
|
|
115
|
+
resolveSlotClasses(blocksConfig, 'Input', preset, variantProps, slotClassesProp)
|
|
116
116
|
);
|
|
117
117
|
|
|
118
118
|
// ARIA wiring is shared with every form primitive — see XC-2.
|
|
@@ -179,11 +179,17 @@
|
|
|
179
179
|
: styles.container({ class: slotClasses?.container })}
|
|
180
180
|
>
|
|
181
181
|
{#if leftIcon}
|
|
182
|
-
<div
|
|
182
|
+
<div
|
|
183
|
+
class={unstyled
|
|
184
|
+
? (slotClasses?.iconContainer ?? '')
|
|
185
|
+
: styles.iconContainer({ iconPosition: 'left', class: slotClasses?.iconContainer })}
|
|
186
|
+
>
|
|
183
187
|
{#if onLeftIconClick}
|
|
184
188
|
<button
|
|
185
189
|
type="button"
|
|
186
|
-
class={
|
|
190
|
+
class={unstyled
|
|
191
|
+
? (slotClasses?.iconButton ?? '')
|
|
192
|
+
: styles.iconButton({ class: slotClasses?.iconButton })}
|
|
187
193
|
onclick={handleLeftIconClick}
|
|
188
194
|
{disabled}
|
|
189
195
|
aria-label={leftIconAriaLabel}
|
|
@@ -191,7 +197,11 @@
|
|
|
191
197
|
{@render leftIcon()}
|
|
192
198
|
</button>
|
|
193
199
|
{:else}
|
|
194
|
-
<span
|
|
200
|
+
<span
|
|
201
|
+
class={unstyled
|
|
202
|
+
? (slotClasses?.iconDecoration ?? '')
|
|
203
|
+
: styles.iconDecoration({ class: slotClasses?.iconDecoration })}
|
|
204
|
+
>
|
|
195
205
|
{@render leftIcon()}
|
|
196
206
|
</span>
|
|
197
207
|
{/if}
|
|
@@ -220,7 +230,9 @@
|
|
|
220
230
|
>
|
|
221
231
|
<button
|
|
222
232
|
type="button"
|
|
223
|
-
class={
|
|
233
|
+
class={unstyled
|
|
234
|
+
? (slotClasses?.iconButton ?? '')
|
|
235
|
+
: styles.iconButton({ class: slotClasses?.iconButton })}
|
|
224
236
|
onclick={handleClear}
|
|
225
237
|
aria-label={bt('accessibility.clearInput')}
|
|
226
238
|
>
|
|
@@ -236,7 +248,9 @@
|
|
|
236
248
|
{#if onRightIconClick}
|
|
237
249
|
<button
|
|
238
250
|
type="button"
|
|
239
|
-
class={
|
|
251
|
+
class={unstyled
|
|
252
|
+
? (slotClasses?.iconButton ?? '')
|
|
253
|
+
: styles.iconButton({ class: slotClasses?.iconButton })}
|
|
240
254
|
onclick={handleRightIconClick}
|
|
241
255
|
{disabled}
|
|
242
256
|
aria-label={rightIconAriaLabel}
|
|
@@ -244,7 +258,11 @@
|
|
|
244
258
|
{@render effectiveRightIcon()}
|
|
245
259
|
</button>
|
|
246
260
|
{:else}
|
|
247
|
-
<span
|
|
261
|
+
<span
|
|
262
|
+
class={unstyled
|
|
263
|
+
? (slotClasses?.iconDecoration ?? '')
|
|
264
|
+
: styles.iconDecoration({ class: slotClasses?.iconDecoration })}
|
|
265
|
+
>
|
|
248
266
|
{@render effectiveRightIcon()}
|
|
249
267
|
</span>
|
|
250
268
|
{/if}
|
|
@@ -253,7 +271,13 @@
|
|
|
253
271
|
</div>
|
|
254
272
|
|
|
255
273
|
{#if ff.errorId}
|
|
256
|
-
<div
|
|
274
|
+
<div
|
|
275
|
+
id={ff.errorId}
|
|
276
|
+
class={unstyled
|
|
277
|
+
? (slotClasses?.message ?? '')
|
|
278
|
+
: styles.message({ class: slotClasses?.message })}
|
|
279
|
+
role="alert"
|
|
280
|
+
>
|
|
257
281
|
{error}
|
|
258
282
|
</div>
|
|
259
283
|
{:else if ff.hintId}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
3
3
|
import type { MintProp } from '../../mint';
|
|
4
|
-
import type { InputVariants } from './input.variants';
|
|
4
|
+
import type { InputSlots, InputVariants } from './input.variants';
|
|
5
5
|
/**
|
|
6
6
|
* @description Text input with labels, validation states, icons, and clearable functionality.
|
|
7
7
|
* Supports outlined, filled, and ghost visual variants with automatic ARIA linking.
|
|
@@ -68,8 +68,12 @@ export interface InputProps extends Omit<InputVariants, 'error'>, Omit<HTMLInput
|
|
|
68
68
|
class?: string;
|
|
69
69
|
/** Remove all default tv() classes — only user-provided classes apply. */
|
|
70
70
|
unstyled?: boolean;
|
|
71
|
-
/**
|
|
72
|
-
|
|
71
|
+
/**
|
|
72
|
+
* Per-slot class overrides merged with tv() styles. Slots: wrapper (root —
|
|
73
|
+
* what `class` also targets) | container | base (the `<input>` element) |
|
|
74
|
+
* label | message | iconContainer | iconButton | iconDecoration.
|
|
75
|
+
*/
|
|
76
|
+
slotClasses?: Partial<Record<InputSlots, string>>;
|
|
73
77
|
/**
|
|
74
78
|
* Apply a named preset registered via `<BlocksProvider presets={{ Input: {...} }}>`.
|
|
75
79
|
* Prefer this over `class` overrides when the requested look falls outside the
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type VariantProps } from '../../utils/variants';
|
|
1
|
+
import { type SlotNames, type VariantProps } from '../../utils/variants';
|
|
2
2
|
export declare const inputVariants: (props?: import("../../utils/variants").TVProps<{
|
|
3
3
|
tier: {
|
|
4
4
|
modify: {
|
|
@@ -252,3 +252,5 @@ export declare const inputVariants: (props?: import("../../utils/variants").TVPr
|
|
|
252
252
|
}) | undefined) => string;
|
|
253
253
|
};
|
|
254
254
|
export type InputVariants = VariantProps<typeof inputVariants>;
|
|
255
|
+
/** Slot names derived from the `tv()` config above — single source of truth for `slotClasses`. */
|
|
256
|
+
export type InputSlots = SlotNames<typeof inputVariants>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts" generics="TItem extends MenuItemType = MenuItemType">
|
|
2
2
|
import { useBlocksI18n } from '../..';
|
|
3
|
-
import { getBlocksConfig,
|
|
4
|
-
import { Button, menuVariants } from '..';
|
|
3
|
+
import { getBlocksConfig, resolveSlotClasses } from '../../provider';
|
|
4
|
+
import { Button, menuVariants, type MenuVariants } from '..';
|
|
5
5
|
import { resolveIcon } from '../../icons';
|
|
6
6
|
import ChevronDownIconDefault from '../../icons/ChevronDownIcon.svelte';
|
|
7
7
|
import { getTierContext } from '../../utils/tier-context';
|
|
@@ -52,13 +52,6 @@
|
|
|
52
52
|
|
|
53
53
|
const blocksConfig = getBlocksConfig();
|
|
54
54
|
const unstyled = $derived(unstyledProp || blocksConfig?.unstyled || false);
|
|
55
|
-
const slotClasses = $derived(
|
|
56
|
-
mergeSlotClasses(
|
|
57
|
-
blocksConfig?.defaults?.Menu?.slotClasses,
|
|
58
|
-
resolvePresetSlotClasses(blocksConfig?.presets, 'Menu', preset),
|
|
59
|
-
slotClassesProp
|
|
60
|
-
)
|
|
61
|
-
);
|
|
62
55
|
|
|
63
56
|
const propsId = $props.id();
|
|
64
57
|
const rootId = $derived(idProp ?? `menu-${propsId}`);
|
|
@@ -230,20 +223,27 @@
|
|
|
230
223
|
return 'md';
|
|
231
224
|
}
|
|
232
225
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
226
|
+
// Variant props feed both the tv() style computation and the slot-class
|
|
227
|
+
// cascade — extracted into one derived so `resolveSlotClasses` can match
|
|
228
|
+
// conditional `overrides` against the menu's active variants.
|
|
229
|
+
const variantProps: MenuVariants = $derived({
|
|
230
|
+
open,
|
|
231
|
+
itemSize: itemSizeForDepth(0),
|
|
232
|
+
syncWidth,
|
|
233
|
+
placement,
|
|
234
|
+
chevronAnimation,
|
|
235
|
+
usePortal,
|
|
236
|
+
// Drives the floating panel's corner radius via the `tier` axis on
|
|
237
|
+
// menuVariants — keeps the panel visually attached to its trigger
|
|
238
|
+
// (e.g. pill trigger → rounded-lg panel instead of near-flat
|
|
239
|
+
// rounded-contain).
|
|
240
|
+
tier: effectiveTier
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
const styles = $derived(menuVariants(variantProps));
|
|
244
|
+
|
|
245
|
+
const slotClasses = $derived(
|
|
246
|
+
resolveSlotClasses(blocksConfig, 'Menu', preset, variantProps, slotClassesProp)
|
|
247
247
|
);
|
|
248
248
|
|
|
249
249
|
const ctx: MenuContext = {
|
|
@@ -5,6 +5,7 @@ import type { ButtonVariants, MenuVariants } from '..';
|
|
|
5
5
|
import type { AnimationProps } from '../../utils';
|
|
6
6
|
import type { Placement } from '../../utils/floating';
|
|
7
7
|
import type { InteractiveTier } from '../../utils/tier-context';
|
|
8
|
+
import type { MenuSlots } from './menu.variants';
|
|
8
9
|
/**
|
|
9
10
|
* @description Action menu (`role="menu"`) triggered by a button. Items are
|
|
10
11
|
* verbs the user can invoke — Edit, Delete, Share, Export — and dispatch an
|
|
@@ -69,8 +70,10 @@ export interface MenuSpecificProps<TItem extends MenuItemType = MenuItemType> {
|
|
|
69
70
|
unstyled?: boolean;
|
|
70
71
|
/**
|
|
71
72
|
* Per-slot class overrides merged with tailwind-variants styles.
|
|
73
|
+
* Slots: base | trigger | triggerText | chevron | content | header | section |
|
|
74
|
+
* divider | items | item | indicator | submenu | footer
|
|
72
75
|
*/
|
|
73
|
-
slotClasses?: Partial<Record<
|
|
76
|
+
slotClasses?: Partial<Record<MenuSlots, string>>;
|
|
74
77
|
/**
|
|
75
78
|
* Apply a named preset registered via `<BlocksProvider presets={{ Menu: {...} }}>`.
|
|
76
79
|
* Prefer this over `class` overrides when the requested look falls outside the
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type VariantProps } from '../../utils/variants';
|
|
1
|
+
import { type SlotNames, type VariantProps } from '../../utils/variants';
|
|
2
2
|
export declare const menuVariants: (props?: import("../../utils/variants").TVProps<{
|
|
3
3
|
open: {
|
|
4
4
|
true: {
|
|
@@ -242,3 +242,5 @@ export declare const menuIconVariants: (props?: import("../../utils/variants").T
|
|
|
242
242
|
}> | undefined) => string;
|
|
243
243
|
export type MenuVariants = VariantProps<typeof menuVariants>;
|
|
244
244
|
export type MenuIconVariants = VariantProps<typeof menuIconVariants>;
|
|
245
|
+
/** Slot names derived from the tv() config — single source of truth for slotClasses. */
|
|
246
|
+
export type MenuSlots = SlotNames<typeof menuVariants>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import PaginationItem from './PaginationItem.svelte';
|
|
3
3
|
import { useBlocksI18n } from '../..';
|
|
4
|
-
import { getBlocksConfig,
|
|
4
|
+
import { getBlocksConfig, resolveSlotClasses } from '../../provider';
|
|
5
5
|
import { paginationVariants } from '..';
|
|
6
|
+
import type { PaginationVariants } from './pagination.variants';
|
|
6
7
|
import { MediaQuery } from 'svelte/reactivity';
|
|
7
8
|
import { computeEllipsisState, computeVisiblePageNumbers } from './pagination.engine';
|
|
8
9
|
import type { PaginationProps } from '.';
|
|
@@ -49,21 +50,18 @@
|
|
|
49
50
|
|
|
50
51
|
const blocksConfig = getBlocksConfig();
|
|
51
52
|
const unstyled = $derived(unstyledProp || blocksConfig?.unstyled || false);
|
|
52
|
-
const slotClasses = $derived(
|
|
53
|
-
mergeSlotClasses(
|
|
54
|
-
blocksConfig?.defaults?.Pagination?.slotClasses,
|
|
55
|
-
resolvePresetSlotClasses(blocksConfig?.presets, 'Pagination', preset),
|
|
56
|
-
slotClassesProp
|
|
57
|
-
)
|
|
58
|
-
);
|
|
59
53
|
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
54
|
+
const variantProps: PaginationVariants = $derived({
|
|
55
|
+
layout,
|
|
56
|
+
size,
|
|
57
|
+
disabled,
|
|
58
|
+
loading
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const styles = $derived(paginationVariants(variantProps));
|
|
62
|
+
|
|
63
|
+
const slotClasses = $derived(
|
|
64
|
+
resolveSlotClasses(blocksConfig, 'Pagination', preset, variantProps, slotClassesProp)
|
|
67
65
|
);
|
|
68
66
|
|
|
69
67
|
// Calculate pagination info for table layout
|
|
@@ -264,7 +262,11 @@
|
|
|
264
262
|
</div>
|
|
265
263
|
{:else}
|
|
266
264
|
<!-- Default Layout: Full pagination -->
|
|
267
|
-
<div
|
|
265
|
+
<div
|
|
266
|
+
class={unstyled
|
|
267
|
+
? (slotClasses?.controls ?? '')
|
|
268
|
+
: styles.controls({ class: slotClasses?.controls })}
|
|
269
|
+
>
|
|
268
270
|
{#if showFirstLast && !isFirstPage && showStartEllipsis}
|
|
269
271
|
<PaginationItem
|
|
270
272
|
{size}
|
|
@@ -2,7 +2,7 @@ import type { Snippet } from 'svelte';
|
|
|
2
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
3
|
import type { MintProp } from '../../mint';
|
|
4
4
|
import type { InteractiveTier } from '../../utils/tier-context';
|
|
5
|
-
import type { PaginationVariants } from './pagination.variants';
|
|
5
|
+
import type { PaginationSlots, PaginationVariants } from './pagination.variants';
|
|
6
6
|
export interface PaginationPageItem {
|
|
7
7
|
label: string;
|
|
8
8
|
value: number;
|
|
@@ -90,7 +90,7 @@ export interface PaginationProps extends Omit<PaginationVariants, 'disabled' | '
|
|
|
90
90
|
/** Strip all default tailwind-variants classes for a fully custom build. */
|
|
91
91
|
unstyled?: boolean;
|
|
92
92
|
/** Per-slot class overrides merged with (or replacing, when unstyled) tv styles. Slots: base, info, controls, ellipsis. */
|
|
93
|
-
slotClasses?: Partial<Record<
|
|
93
|
+
slotClasses?: Partial<Record<PaginationSlots, string>>;
|
|
94
94
|
/**
|
|
95
95
|
* Apply a named preset registered via `<BlocksProvider presets={{ Pagination: {...} }}>`.
|
|
96
96
|
* Prefer this over `class` overrides when the requested look falls outside the
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type VariantProps } from '../../utils/variants';
|
|
1
|
+
import { type SlotNames, type VariantProps } from '../../utils/variants';
|
|
2
2
|
export declare const paginationVariants: (props?: import("../../utils/variants").TVProps<{
|
|
3
3
|
layout: {
|
|
4
4
|
default: {
|
|
@@ -79,3 +79,5 @@ export declare const paginationVariants: (props?: import("../../utils/variants")
|
|
|
79
79
|
}) | undefined) => string;
|
|
80
80
|
};
|
|
81
81
|
export type PaginationVariants = VariantProps<typeof paginationVariants>;
|
|
82
|
+
/** Slot names derived from the tv() config — single source of truth for slotClasses. */
|
|
83
|
+
export type PaginationSlots = SlotNames<typeof paginationVariants>;
|