@urbicon-ui/blocks 6.2.0 → 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/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 +2 -2
- 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/style/semantic.css +5 -0
- package/dist/utils/variants.d.ts +17 -0
- package/package.json +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
-
import type { BreadcrumbVariants } from './breadcrumb.variants';
|
|
3
|
+
import type { BreadcrumbSlots, BreadcrumbVariants } from './breadcrumb.variants';
|
|
4
4
|
/** Single breadcrumb item definition */
|
|
5
5
|
export interface BreadcrumbItem {
|
|
6
6
|
/** Display label */
|
|
@@ -56,7 +56,7 @@ export interface BreadcrumbProps extends BreadcrumbVariants, Omit<HTMLAttributes
|
|
|
56
56
|
/** Remove default styles */
|
|
57
57
|
unstyled?: boolean;
|
|
58
58
|
/** Per-slot class overrides */
|
|
59
|
-
slotClasses?: Partial<Record<
|
|
59
|
+
slotClasses?: Partial<Record<BreadcrumbSlots, string>>;
|
|
60
60
|
/**
|
|
61
61
|
* Apply a named preset registered via `<BlocksProvider presets={{ Breadcrumb: {...} }}>`.
|
|
62
62
|
* Prefer this over `class` overrides when the requested look falls outside the
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { mintRegistry, Spinner } from '../..';
|
|
3
|
-
import { getBlocksConfig,
|
|
3
|
+
import { getBlocksConfig, resolveSlotClasses } from '../../provider';
|
|
4
4
|
import { getButtonGroupContext } from '../ButtonGroup/buttonGroup.context';
|
|
5
|
-
import { buttonVariants } from '..';
|
|
5
|
+
import { buttonVariants, type ButtonVariants } from '..';
|
|
6
6
|
import { getTierContext } from '../../utils/tier-context';
|
|
7
7
|
import type { ButtonProps } from './index';
|
|
8
8
|
|
|
@@ -30,13 +30,6 @@
|
|
|
30
30
|
|
|
31
31
|
const blocksConfig = getBlocksConfig();
|
|
32
32
|
const unstyled = $derived(unstyledProp || blocksConfig?.unstyled || false);
|
|
33
|
-
const slotClasses = $derived(
|
|
34
|
-
mergeSlotClasses(
|
|
35
|
-
blocksConfig?.defaults?.Button?.slotClasses,
|
|
36
|
-
resolvePresetSlotClasses(blocksConfig?.presets, 'Button', preset),
|
|
37
|
-
slotClassesProp
|
|
38
|
-
)
|
|
39
|
-
);
|
|
40
33
|
|
|
41
34
|
let buttonElement = $state<HTMLButtonElement>();
|
|
42
35
|
|
|
@@ -58,18 +51,25 @@
|
|
|
58
51
|
const effectivePressed = $derived(pressed);
|
|
59
52
|
const ariaProps = $derived(registration?.getButtonProps() ?? {});
|
|
60
53
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
54
|
+
// Variant props feed both the tv() style computation and the slot-class
|
|
55
|
+
// cascade — extracted into one derived so `resolveSlotClasses` can match
|
|
56
|
+
// conditional `overrides` against the button's active variants.
|
|
57
|
+
const variantProps: ButtonVariants = $derived({
|
|
58
|
+
tier: effectiveTier,
|
|
59
|
+
intent: effectiveIntent,
|
|
60
|
+
variant: effectiveVariant,
|
|
61
|
+
size: effectiveSize,
|
|
62
|
+
loading: loading || undefined,
|
|
63
|
+
loadingPlacement,
|
|
64
|
+
pressed: effectivePressed || undefined,
|
|
65
|
+
active: effectiveActive || undefined,
|
|
66
|
+
buttonGroupConnected: groupCtx?.connected || undefined
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const styles = $derived(buttonVariants(variantProps));
|
|
70
|
+
|
|
71
|
+
const slotClasses = $derived(
|
|
72
|
+
resolveSlotClasses(blocksConfig, 'Button', preset, variantProps, slotClassesProp)
|
|
73
73
|
);
|
|
74
74
|
|
|
75
75
|
$effect(() => {
|
|
@@ -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 buttonVariants: (props?: import("../../utils/variants").TVProps<{
|
|
3
3
|
tier: {
|
|
4
4
|
commit: {
|
|
@@ -132,3 +132,5 @@ export declare const buttonVariants: (props?: import("../../utils/variants").TVP
|
|
|
132
132
|
}) | undefined) => string;
|
|
133
133
|
};
|
|
134
134
|
export type ButtonVariants = VariantProps<typeof buttonVariants>;
|
|
135
|
+
/** Slot names derived from the `tv()` config above — single source of truth for `slotClasses`. */
|
|
136
|
+
export type ButtonSlots = SlotNames<typeof buttonVariants>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
3
3
|
import type { MintProp } from '../../mint';
|
|
4
|
-
import type { ButtonVariants } from './button.variants';
|
|
4
|
+
import type { ButtonSlots, ButtonVariants } from './button.variants';
|
|
5
5
|
/**
|
|
6
6
|
* Props interface for Button component
|
|
7
7
|
*
|
|
@@ -95,8 +95,8 @@ export interface ButtonProps extends ButtonVariants, Omit<HTMLButtonAttributes,
|
|
|
95
95
|
class?: string;
|
|
96
96
|
/** Remove default tailwind-variants classes. Only user classes apply. */
|
|
97
97
|
unstyled?: boolean;
|
|
98
|
-
/** Per-slot class overrides merged with tv styles: base | content | spinner */
|
|
99
|
-
slotClasses?: Partial<Record<
|
|
98
|
+
/** Per-slot class overrides merged with tv styles. Slots: base | content | spinner */
|
|
99
|
+
slotClasses?: Partial<Record<ButtonSlots, string>>;
|
|
100
100
|
/**
|
|
101
101
|
* Apply a named preset registered via `<BlocksProvider presets={{ Button: {...} }}>`.
|
|
102
102
|
* Prefer this over `class="bg-…!"` overrides when the requested look is outside the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { buttonGroupVariants } from '..';
|
|
3
|
-
import { getBlocksConfig,
|
|
2
|
+
import { buttonGroupVariants, type ButtonGroupVariants } from '..';
|
|
3
|
+
import { getBlocksConfig, resolveSlotClasses } from '../../provider';
|
|
4
4
|
import { getTierContext, setTierContext } from '../../utils/tier-context';
|
|
5
5
|
import type { ButtonGroupContext, ButtonGroupProps } from './index';
|
|
6
6
|
import { setButtonGroupContext } from './buttonGroup.context';
|
|
@@ -40,12 +40,17 @@
|
|
|
40
40
|
|
|
41
41
|
const blocksConfig = getBlocksConfig();
|
|
42
42
|
const unstyled = $derived(unstyledProp || blocksConfig?.unstyled || false);
|
|
43
|
+
|
|
44
|
+
const variantProps: ButtonGroupVariants = $derived({
|
|
45
|
+
orientation,
|
|
46
|
+
connected,
|
|
47
|
+
tier: effectiveTier,
|
|
48
|
+
disabled
|
|
49
|
+
});
|
|
50
|
+
const styles = $derived(buttonGroupVariants(variantProps));
|
|
51
|
+
|
|
43
52
|
const slotClasses = $derived(
|
|
44
|
-
|
|
45
|
-
blocksConfig?.defaults?.ButtonGroup?.slotClasses,
|
|
46
|
-
resolvePresetSlotClasses(blocksConfig?.presets, 'ButtonGroup', preset),
|
|
47
|
-
slotClassesProp
|
|
48
|
-
)
|
|
53
|
+
resolveSlotClasses(blocksConfig, 'ButtonGroup', preset, variantProps, slotClassesProp)
|
|
49
54
|
);
|
|
50
55
|
|
|
51
56
|
let selectedValues = $state<Set<string>>(new Set());
|
|
@@ -60,12 +65,6 @@
|
|
|
60
65
|
}
|
|
61
66
|
});
|
|
62
67
|
|
|
63
|
-
const styles = $derived(
|
|
64
|
-
unstyled
|
|
65
|
-
? { base: ({ class: c }: { class?: string }) => c || '' }
|
|
66
|
-
: buttonGroupVariants({ orientation, connected, tier: effectiveTier, disabled })
|
|
67
|
-
);
|
|
68
|
-
|
|
69
68
|
function registerButton(buttonValue: string | undefined) {
|
|
70
69
|
return {
|
|
71
70
|
get isSelected() {
|
|
@@ -138,7 +137,9 @@
|
|
|
138
137
|
|
|
139
138
|
<div
|
|
140
139
|
role={ariaRole}
|
|
141
|
-
class={
|
|
140
|
+
class={unstyled
|
|
141
|
+
? [slotClasses?.base, className].filter(Boolean).join(' ')
|
|
142
|
+
: styles.base({ class: [slotClasses?.base, className] })}
|
|
142
143
|
aria-label={ariaLabel}
|
|
143
144
|
aria-labelledby={ariaLabelledBy}
|
|
144
145
|
aria-disabled={disabled}
|
|
@@ -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 buttonGroupVariants: (props?: import("../../utils/variants").TVProps<{
|
|
3
3
|
orientation: {
|
|
4
4
|
horizontal: {
|
|
@@ -37,3 +37,5 @@ export declare const buttonGroupVariants: (props?: import("../../utils/variants"
|
|
|
37
37
|
}) | undefined) => string;
|
|
38
38
|
};
|
|
39
39
|
export type ButtonGroupVariants = VariantProps<typeof buttonGroupVariants>;
|
|
40
|
+
/** Slot names derived from the tv() config — single source of truth for slotClasses. */
|
|
41
|
+
export type ButtonGroupSlots = SlotNames<typeof buttonGroupVariants>;
|
|
@@ -3,6 +3,7 @@ import type { HTMLAttributes } from 'svelte/elements';
|
|
|
3
3
|
import type { MintProp } from '../../mint';
|
|
4
4
|
import type { ComponentIntent, ComponentSize, ComponentVariant, InteractiveTier } from '../../utils';
|
|
5
5
|
import type { ButtonVariants } from '../Button/button.variants';
|
|
6
|
+
import type { ButtonGroupSlots } from './buttongroup.variants';
|
|
6
7
|
export type ButtonGroupSelection = 'none' | 'single' | 'multiple';
|
|
7
8
|
export type ButtonGroupOrientation = 'horizontal' | 'vertical';
|
|
8
9
|
export type ButtonGroupValue = string | string[] | undefined;
|
|
@@ -70,8 +71,8 @@ export interface ButtonGroupProps extends Omit<HTMLAttributes<HTMLDivElement>, '
|
|
|
70
71
|
class?: string;
|
|
71
72
|
/** Remove all default tv classes. */
|
|
72
73
|
unstyled?: boolean;
|
|
73
|
-
/** Per-slot class overrides. */
|
|
74
|
-
slotClasses?: Partial<Record<
|
|
74
|
+
/** Per-slot class overrides. Slots: base */
|
|
75
|
+
slotClasses?: Partial<Record<ButtonGroupSlots, string>>;
|
|
75
76
|
/**
|
|
76
77
|
* Apply a named preset registered via `<BlocksProvider presets={{ ButtonGroup: {...} }}>`.
|
|
77
78
|
* Prefer this over `class` overrides when the requested look falls outside the
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { mintRegistry } from '../..';
|
|
3
|
-
import { getBlocksConfig,
|
|
4
|
-
import { cardVariants } from './card.variants';
|
|
3
|
+
import { getBlocksConfig, resolveSlotClasses } from '../../provider';
|
|
4
|
+
import { cardVariants, type CardVariants } from './card.variants';
|
|
5
5
|
import type { CardProps } from './index';
|
|
6
6
|
|
|
7
7
|
let {
|
|
@@ -26,13 +26,6 @@
|
|
|
26
26
|
|
|
27
27
|
const blocksConfig = getBlocksConfig();
|
|
28
28
|
const unstyled = $derived(unstyledProp || blocksConfig?.unstyled || false);
|
|
29
|
-
const slotClasses = $derived(
|
|
30
|
-
mergeSlotClasses(
|
|
31
|
-
blocksConfig?.defaults?.Card?.slotClasses,
|
|
32
|
-
resolvePresetSlotClasses(blocksConfig?.presets, 'Card', preset),
|
|
33
|
-
slotClassesProp
|
|
34
|
-
)
|
|
35
|
-
);
|
|
36
29
|
|
|
37
30
|
let cardElement = $state<HTMLElement>();
|
|
38
31
|
|
|
@@ -48,15 +41,19 @@
|
|
|
48
41
|
// element would falsely signal interactivity (WCAG 3.2 Predictable).
|
|
49
42
|
const isInteractive = $derived(clickable || !!onclick || !!href);
|
|
50
43
|
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
44
|
+
const variantProps: CardVariants = $derived({
|
|
45
|
+
variant,
|
|
46
|
+
padding,
|
|
47
|
+
dividers: dividers || undefined,
|
|
48
|
+
interactive: isInteractive || undefined,
|
|
49
|
+
elementType,
|
|
50
|
+
disabled: disabled || undefined
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const styles = $derived(cardVariants(variantProps));
|
|
54
|
+
|
|
55
|
+
const slotClasses = $derived(
|
|
56
|
+
resolveSlotClasses(blocksConfig, 'Card', preset, variantProps, slotClassesProp)
|
|
60
57
|
);
|
|
61
58
|
|
|
62
59
|
const elementProps = $derived.by(() => {
|
|
@@ -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 cardVariants: (props?: import("../../utils/variants").TVProps<{
|
|
3
3
|
variant: {
|
|
4
4
|
quiet: {
|
|
@@ -118,3 +118,5 @@ export declare const cardVariants: (props?: import("../../utils/variants").TVPro
|
|
|
118
118
|
}) | undefined) => string;
|
|
119
119
|
};
|
|
120
120
|
export type CardVariants = VariantProps<typeof cardVariants>;
|
|
121
|
+
/** Slot names derived from the tv() config — single source of truth for slotClasses. */
|
|
122
|
+
export type CardSlots = SlotNames<typeof cardVariants>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
3
|
import type { MintProp } from '../../mint';
|
|
4
|
-
import type { CardVariants } from './card.variants';
|
|
4
|
+
import type { CardSlots, CardVariants } from './card.variants';
|
|
5
5
|
/**
|
|
6
6
|
* @description Flexible container for grouping related content with optional header, footer,
|
|
7
7
|
* and interactive states. Renders as div, button, or anchor depending on the provided props.
|
|
@@ -66,8 +66,8 @@ export interface CardProps extends Omit<CardVariants, 'elementType' | 'interacti
|
|
|
66
66
|
class?: string;
|
|
67
67
|
/** Remove all default tv classes. */
|
|
68
68
|
unstyled?: boolean;
|
|
69
|
-
/** Per-slot class overrides. */
|
|
70
|
-
slotClasses?: Partial<Record<
|
|
69
|
+
/** Per-slot class overrides. Slots: base | header | content | footer */
|
|
70
|
+
slotClasses?: Partial<Record<CardSlots, string>>;
|
|
71
71
|
/**
|
|
72
72
|
* Apply a named preset registered via `<BlocksProvider presets={{ Card: {...} }}>`.
|
|
73
73
|
* Prefer this over `class` overrides when the requested look falls outside the
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { mintRegistry } from '../..';
|
|
3
|
-
import { getBlocksConfig,
|
|
3
|
+
import { getBlocksConfig, resolveSlotClasses } from '../../provider';
|
|
4
4
|
import { getTierContext, useFormField } from '../../utils';
|
|
5
|
-
import { checkboxVariants } from '..';
|
|
5
|
+
import { checkboxVariants, type CheckboxVariants } from '..';
|
|
6
6
|
import { resolveIcon } from '../../icons';
|
|
7
7
|
import CheckIconDefault from '../../icons/CheckIcon.svelte';
|
|
8
8
|
import MinusIconDefault from '../../icons/MinusIcon.svelte';
|
|
@@ -53,30 +53,30 @@
|
|
|
53
53
|
|
|
54
54
|
const blocksConfig = getBlocksConfig();
|
|
55
55
|
const unstyled = $derived(unstyledProp || blocksConfig?.unstyled || false);
|
|
56
|
-
const slotClasses = $derived(
|
|
57
|
-
mergeSlotClasses(
|
|
58
|
-
blocksConfig?.defaults?.Checkbox?.slotClasses,
|
|
59
|
-
resolvePresetSlotClasses(blocksConfig?.presets, 'Checkbox', preset),
|
|
60
|
-
slotClassesProp
|
|
61
|
-
)
|
|
62
|
-
);
|
|
63
56
|
|
|
64
57
|
let controlElement = $state<HTMLElement>();
|
|
65
58
|
let inputRef = $state<HTMLInputElement>();
|
|
66
59
|
|
|
67
60
|
const dataState = $derived(indeterminate ? 'indeterminate' : checked ? 'checked' : 'unchecked');
|
|
68
61
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
62
|
+
// Variant props feed both the tv() style computation and the slot-class
|
|
63
|
+
// cascade — extracted into one derived so `resolveSlotClasses` can match
|
|
64
|
+
// conditional `overrides` against the checkbox's active variants.
|
|
65
|
+
const variantProps: CheckboxVariants = $derived({
|
|
66
|
+
tier: effectiveTier,
|
|
67
|
+
size,
|
|
68
|
+
intent,
|
|
69
|
+
variant,
|
|
70
|
+
checked,
|
|
71
|
+
indeterminate,
|
|
72
|
+
disabled,
|
|
73
|
+
error: !!error
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const styles = $derived(checkboxVariants(variantProps));
|
|
77
|
+
|
|
78
|
+
const slotClasses = $derived(
|
|
79
|
+
resolveSlotClasses(blocksConfig, 'Checkbox', preset, variantProps, slotClassesProp)
|
|
80
80
|
);
|
|
81
81
|
|
|
82
82
|
$effect(() => {
|
|
@@ -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 checkboxVariants: (props?: import("../../utils/variants").TVProps<{
|
|
3
3
|
tier: {
|
|
4
4
|
commit: {
|
|
@@ -144,3 +144,5 @@ export declare const checkboxVariants: (props?: import("../../utils/variants").T
|
|
|
144
144
|
}) | undefined) => string;
|
|
145
145
|
};
|
|
146
146
|
export type CheckboxVariants = VariantProps<typeof checkboxVariants>;
|
|
147
|
+
/** Slot names derived from the `tv()` config above — single source of truth for `slotClasses`. */
|
|
148
|
+
export type CheckboxSlots = SlotNames<typeof checkboxVariants>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
2
2
|
import type { MintProp } from '../../mint';
|
|
3
3
|
import type { InteractiveTier } from '../../utils';
|
|
4
|
-
import type { CheckboxVariants } from './checkbox.variants';
|
|
4
|
+
import type { CheckboxSlots, CheckboxVariants } from './checkbox.variants';
|
|
5
5
|
/**
|
|
6
6
|
* @description Accessible checkbox with indeterminate support, semantic intents, and form integration.
|
|
7
7
|
* Uses a hidden native input for correct form behavior and ARIA semantics.
|
|
@@ -47,8 +47,12 @@ export interface CheckboxProps extends Omit<CheckboxVariants, 'error' | 'checked
|
|
|
47
47
|
class?: string;
|
|
48
48
|
/** Strip all default tailwind-variants classes. Use with `slotClasses` for a fully custom look. The box exposes `data-state` for conditional styling. */
|
|
49
49
|
unstyled?: boolean;
|
|
50
|
-
/**
|
|
51
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Per-slot class overrides merged with (or replacing, when `unstyled`) the
|
|
52
|
+
* default styles. Slots: wrapper (root — what `class` also targets) | control |
|
|
53
|
+
* box | icon | label | message.
|
|
54
|
+
*/
|
|
55
|
+
slotClasses?: Partial<Record<CheckboxSlots, string>>;
|
|
52
56
|
/**
|
|
53
57
|
* Apply a named preset registered via `<BlocksProvider presets={{ Checkbox: {...} }}>`.
|
|
54
58
|
* Prefer this over `class` overrides when the requested look falls outside the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { getBlocksConfig,
|
|
3
|
-
import { collapsibleVariants } from './collapsible.variants';
|
|
2
|
+
import { getBlocksConfig, resolveSlotClasses } from '../../provider';
|
|
3
|
+
import { collapsibleVariants, type CollapsibleVariants } from './collapsible.variants';
|
|
4
4
|
import { resolveIcon } from '../../icons';
|
|
5
5
|
import ChevronDownIconDefault from '../../icons/ChevronDownIcon.svelte';
|
|
6
6
|
import type { CollapsibleProps } from './index';
|
|
@@ -27,13 +27,6 @@
|
|
|
27
27
|
|
|
28
28
|
const blocksConfig = getBlocksConfig();
|
|
29
29
|
const unstyled = $derived(unstyledProp || blocksConfig?.unstyled || false);
|
|
30
|
-
const slotClasses = $derived(
|
|
31
|
-
mergeSlotClasses(
|
|
32
|
-
blocksConfig?.defaults?.Collapsible?.slotClasses,
|
|
33
|
-
resolvePresetSlotClasses(blocksConfig?.presets, 'Collapsible', preset),
|
|
34
|
-
slotClassesProp
|
|
35
|
-
)
|
|
36
|
-
);
|
|
37
30
|
|
|
38
31
|
let internalOpen = $state(defaultOpen ?? false);
|
|
39
32
|
const isOpen = $derived(open !== undefined ? open : internalOpen);
|
|
@@ -49,23 +42,12 @@
|
|
|
49
42
|
onOpenChange?.(next);
|
|
50
43
|
}
|
|
51
44
|
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
? {
|
|
55
|
-
base: () => '',
|
|
56
|
-
trigger: () => '',
|
|
57
|
-
chevron: () => '',
|
|
58
|
-
content: () => '',
|
|
59
|
-
contentInner: () => ''
|
|
60
|
-
}
|
|
61
|
-
: collapsibleVariants({ variant, size })
|
|
62
|
-
);
|
|
45
|
+
const variantProps: CollapsibleVariants = $derived({ variant, size });
|
|
46
|
+
const styles = $derived(collapsibleVariants(variantProps));
|
|
63
47
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return styles[key]({ class: overrides });
|
|
68
|
-
}
|
|
48
|
+
const slotClasses = $derived(
|
|
49
|
+
resolveSlotClasses(blocksConfig, 'Collapsible', preset, variantProps, slotClassesProp)
|
|
50
|
+
);
|
|
69
51
|
|
|
70
52
|
const propsId = $props.id();
|
|
71
53
|
const fallbackName = `collapsible-${propsId}`;
|
|
@@ -74,21 +56,33 @@
|
|
|
74
56
|
const contentId = $derived(`${uid}-content`);
|
|
75
57
|
</script>
|
|
76
58
|
|
|
77
|
-
<div
|
|
59
|
+
<div
|
|
60
|
+
class={unstyled
|
|
61
|
+
? [slotClasses?.base, className].filter(Boolean).join(' ')
|
|
62
|
+
: styles.base({ class: [slotClasses?.base, className] })}
|
|
63
|
+
data-state={isOpen ? 'open' : 'closed'}
|
|
64
|
+
{...restProps}
|
|
65
|
+
>
|
|
78
66
|
{#if trigger}
|
|
79
67
|
{@render trigger({ open: isOpen, toggle, disabled, triggerId, contentId })}
|
|
80
68
|
{:else}
|
|
81
69
|
<button
|
|
82
70
|
id={triggerId}
|
|
83
71
|
type="button"
|
|
84
|
-
class={
|
|
72
|
+
class={unstyled
|
|
73
|
+
? (slotClasses?.trigger ?? '')
|
|
74
|
+
: styles.trigger({ class: slotClasses?.trigger })}
|
|
85
75
|
aria-expanded={isOpen}
|
|
86
76
|
aria-controls={contentId}
|
|
87
77
|
{disabled}
|
|
88
78
|
onclick={toggle}
|
|
89
79
|
>
|
|
90
80
|
<span>{title ?? ''}</span>
|
|
91
|
-
<ChevronDownIcon
|
|
81
|
+
<ChevronDownIcon
|
|
82
|
+
class={unstyled
|
|
83
|
+
? [slotClasses?.chevron, isOpen ? 'rotate-180' : ''].filter(Boolean).join(' ')
|
|
84
|
+
: styles.chevron({ class: [slotClasses?.chevron, isOpen ? 'rotate-180' : ''] })}
|
|
85
|
+
/>
|
|
92
86
|
</button>
|
|
93
87
|
{/if}
|
|
94
88
|
|
|
@@ -96,11 +90,17 @@
|
|
|
96
90
|
id={contentId}
|
|
97
91
|
role="region"
|
|
98
92
|
aria-labelledby={triggerId}
|
|
99
|
-
class={
|
|
93
|
+
class={unstyled
|
|
94
|
+
? (slotClasses?.content ?? '')
|
|
95
|
+
: styles.content({ class: slotClasses?.content })}
|
|
100
96
|
style="display:grid; grid-template-rows: {isOpen ? '1fr' : '0fr'};"
|
|
101
97
|
>
|
|
102
98
|
<div class="overflow-hidden">
|
|
103
|
-
<div
|
|
99
|
+
<div
|
|
100
|
+
class={unstyled
|
|
101
|
+
? (slotClasses?.contentInner ?? '')
|
|
102
|
+
: styles.contentInner({ class: slotClasses?.contentInner })}
|
|
103
|
+
>
|
|
104
104
|
{@render children()}
|
|
105
105
|
</div>
|
|
106
106
|
</div>
|
|
@@ -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 collapsibleVariants: (props?: import("../../utils/variants").TVProps<{
|
|
3
3
|
variant: {
|
|
4
4
|
default: {};
|
|
@@ -66,3 +66,5 @@ export declare const collapsibleVariants: (props?: import("../../utils/variants"
|
|
|
66
66
|
}) | undefined) => string;
|
|
67
67
|
};
|
|
68
68
|
export type CollapsibleVariants = VariantProps<typeof collapsibleVariants>;
|
|
69
|
+
/** Slot names derived from the tv() config — single source of truth for slotClasses. */
|
|
70
|
+
export type CollapsibleSlots = SlotNames<typeof collapsibleVariants>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
-
import type { CollapsibleVariants } from './collapsible.variants';
|
|
3
|
+
import type { CollapsibleSlots, CollapsibleVariants } from './collapsible.variants';
|
|
4
4
|
/**
|
|
5
5
|
* Props interface for the Collapsible component
|
|
6
6
|
*
|
|
@@ -60,8 +60,8 @@ export interface CollapsibleProps extends CollapsibleVariants, Omit<HTMLAttribut
|
|
|
60
60
|
class?: string;
|
|
61
61
|
/** Remove default styles */
|
|
62
62
|
unstyled?: boolean;
|
|
63
|
-
/** Per-slot class overrides */
|
|
64
|
-
slotClasses?: Partial<Record<
|
|
63
|
+
/** Per-slot class overrides. Slots: base | trigger | chevron | content | contentInner */
|
|
64
|
+
slotClasses?: Partial<Record<CollapsibleSlots, string>>;
|
|
65
65
|
/**
|
|
66
66
|
* Apply a named preset registered via `<BlocksProvider presets={{ Collapsible: {...} }}>`.
|
|
67
67
|
* Prefer this over `class` overrides when the requested look falls outside the
|
|
@@ -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
|