seblify 0.2.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +145 -49
- package/dist/components/AppShell.svelte +1 -1
- package/dist/components/Banner.svelte +3 -3
- package/dist/components/Button.svelte +4 -4
- package/dist/components/action/button/button/Button.svelte +1041 -0
- package/dist/components/action/button/button/Button.svelte.d.ts +28 -0
- package/dist/components/action/button/button-group/ButtonGroup.svelte +146 -0
- package/dist/components/action/button/button-group/ButtonGroup.svelte.d.ts +14 -0
- package/dist/components/action/button/floating-action-button/FloatingActionButton.svelte +1102 -0
- package/dist/components/action/button/floating-action-button/FloatingActionButton.svelte.d.ts +26 -0
- package/dist/components/action/button/icon-button/IconButton.svelte +954 -0
- package/dist/components/action/button/icon-button/IconButton.svelte.d.ts +22 -0
- package/dist/components/action/button/timed-button/TimedButton.svelte +1143 -0
- package/dist/components/action/button/timed-button/TimedButton.svelte.d.ts +32 -0
- package/dist/components/action/button/toggle-button/ToggleButton.svelte +1109 -0
- package/dist/components/action/button/toggle-button/ToggleButton.svelte.d.ts +28 -0
- package/dist/components/action/button/toggle-button-group/ToggleButtonGroup.svelte +242 -0
- package/dist/components/action/button/toggle-button-group/ToggleButtonGroup.svelte.d.ts +19 -0
- package/dist/components/action/button/toggle-button-group/ToggleButtonGroup.test.svelte +36 -0
- package/dist/components/action/button/toggle-button-group/ToggleButtonGroup.test.svelte.d.ts +11 -0
- package/dist/components/action/button/toggle-button-group/context.d.ts +8 -0
- package/dist/components/action/button/toggle-button-group/context.js +8 -0
- package/dist/components/action/input/field/pin-input/PinInput.svelte +4 -4
- package/dist/components/action/input/select/checkbox/Checkbox.svelte +4704 -25
- package/dist/components/action/input/select/checkbox/Checkbox.svelte.d.ts +28 -0
- package/dist/components/action/input/select/checkbox/checkbox-relations.svelte.d.ts +46 -0
- package/dist/components/action/input/select/checkbox/checkbox-relations.svelte.js +202 -0
- package/dist/components/action/input/select/checkbox/tests/visual-fixtures/bounce.d.ts +1 -0
- package/dist/components/action/input/select/checkbox/tests/visual-fixtures/bounce.html +27 -0
- package/dist/components/action/input/select/checkbox/tests/visual-fixtures/bounce.js +13 -0
- package/dist/components/action/input/select/checkbox/tests/visual-fixtures/bump.d.ts +1 -0
- package/dist/components/action/input/select/checkbox/tests/visual-fixtures/bump.html +12 -0
- package/dist/components/action/input/select/checkbox/tests/visual-fixtures/bump.js +13 -0
- package/dist/components/action/input/select/checkbox/tests/visual-fixtures/draw.d.ts +1 -0
- package/dist/components/action/input/select/checkbox/tests/visual-fixtures/draw.html +12 -0
- package/dist/components/action/input/select/checkbox/tests/visual-fixtures/draw.js +12 -0
- package/dist/components/action/input/select/checkbox/tests/visual-fixtures/fade.d.ts +1 -0
- package/dist/components/action/input/select/checkbox/tests/visual-fixtures/fade.html +12 -0
- package/dist/components/action/input/select/checkbox/tests/visual-fixtures/fade.js +12 -0
- package/dist/components/action/input/select/checkbox/tests/visual-fixtures/pop.d.ts +1 -0
- package/dist/components/action/input/select/checkbox/tests/visual-fixtures/pop.html +12 -0
- package/dist/components/action/input/select/checkbox/tests/visual-fixtures/pop.js +13 -0
- package/dist/components/action/input/select/checkbox/tests/visual-fixtures/rise.d.ts +1 -0
- package/dist/components/action/input/select/checkbox/tests/visual-fixtures/rise.html +27 -0
- package/dist/components/action/input/select/checkbox/tests/visual-fixtures/rise.js +13 -0
- package/dist/components/action/input/select/checkbox/tests/visual-fixtures/scale.d.ts +1 -0
- package/dist/components/action/input/select/checkbox/tests/visual-fixtures/scale.html +27 -0
- package/dist/components/action/input/select/checkbox/tests/visual-fixtures/scale.js +13 -0
- package/dist/components/action/input/select/checkbox/tests/visual-fixtures/visual-state.d.ts +1 -0
- package/dist/components/action/input/select/checkbox/tests/visual-fixtures/visual-state.html +12 -0
- package/dist/components/action/input/select/checkbox/tests/visual-fixtures/visual-state.js +278 -0
- package/dist/components/action/input/select/{theme-switch/ThemeSwitch.svelte → color-mode-switch/ColorModeSwitch.svelte} +8 -8
- package/dist/components/action/input/select/color-mode-switch/ColorModeSwitch.svelte.d.ts +10 -0
- package/dist/components/action/input/select/segment-control/SegmentControl.svelte +2 -2
- package/dist/components/action/input/select/slider/Slider.svelte +1 -1
- package/dist/components/action/input/select/switch/Switch.svelte +1004 -99
- package/dist/components/action/input/select/switch/Switch.svelte.d.ts +8 -3
- package/dist/components/display/annotation/badge/Badge.svelte +732 -63
- package/dist/components/display/annotation/badge/Badge.svelte.d.ts +1 -1
- package/dist/components/display/annotation/tag/Tag.svelte +670 -58
- package/dist/components/display/annotation/tag/Tag.svelte.d.ts +3 -1
- package/dist/components/display/data-display/metric/date-time/DateTimeValue.svelte +59 -0
- package/dist/components/display/data-display/metric/date-time/DateTimeValue.svelte.d.ts +13 -0
- package/dist/components/display/data-display/metric/date-time/DateValue.svelte +52 -0
- package/dist/components/display/data-display/metric/date-time/DateValue.svelte.d.ts +11 -0
- package/dist/components/display/data-display/metric/date-time/TimeValue.svelte +55 -0
- package/dist/components/display/data-display/metric/date-time/TimeValue.svelte.d.ts +12 -0
- package/dist/components/display/data-display/metric/duration/Duration.svelte +64 -0
- package/dist/components/display/data-display/metric/duration/Duration.svelte.d.ts +16 -0
- package/dist/components/display/data-display/metric/relative-time/RelativeTime.svelte +121 -0
- package/dist/components/display/data-display/metric/relative-time/RelativeTime.svelte.d.ts +21 -0
- package/dist/components/display/data-display/metric/timestamp-card/TimestampCard.svelte +121 -0
- package/dist/components/display/data-display/metric/timestamp-card/TimestampCard.svelte.d.ts +25 -0
- package/dist/components/display/data-display/visual/timeline/TimelineItem.svelte +660 -51
- package/dist/components/display/data-display/visual/timeline/context.d.ts +1 -1
- package/dist/components/display/feedback/loading/loading-dots/LoadingDots.svelte +657 -48
- package/dist/components/display/feedback/loading/loading-dots/LoadingDots.svelte.d.ts +1 -1
- package/dist/components/display/feedback/loading/spinner/Spinner.svelte +657 -48
- package/dist/components/display/feedback/loading/spinner/Spinner.svelte.d.ts +1 -1
- package/dist/components/display/motion/collapse/Collapse.svelte +115 -0
- package/dist/components/display/motion/collapse/Collapse.svelte.d.ts +17 -0
- package/dist/components/display/typography/accordion/Accordion.svelte +347 -0
- package/dist/components/display/typography/accordion/Accordion.svelte.d.ts +13 -0
- package/dist/components/display/typography/accordion/AccordionGroup.svelte +132 -0
- package/dist/components/display/typography/accordion/AccordionGroup.svelte.d.ts +11 -0
- package/dist/components/display/typography/accordion/context.d.ts +8 -0
- package/dist/components/display/typography/accordion/context.js +8 -0
- package/dist/components/display/typography/code-snippet/CodeSnippet.svelte +3 -3
- package/dist/components/display/typography/eyebrow/Eyebrow.svelte +2 -2
- package/dist/components/display/typography/highlight/Highlight.svelte +719 -59
- package/dist/components/display/typography/highlight/Highlight.svelte.d.ts +1 -1
- package/dist/components/framework/layout/container/app-shell/AppShell.svelte +16 -2
- package/dist/components/framework/navigation/context/breadcrumb/Breadcrumb.svelte +1 -1
- package/dist/components/framework/navigation/sidebar/sidebar/Sidebar.svelte +35 -10
- package/dist/components/framework/navigation/sidebar/sidenav/Sidenav.svelte +5 -5
- package/dist/components/framework/overlay/tooltip/Tooltip.svelte +1011 -0
- package/dist/components/framework/overlay/tooltip/Tooltip.svelte.d.ts +31 -0
- package/dist/components/framework/surface/paper/Paper.svelte +730 -87
- package/dist/components/framework/surface/paper/Paper.svelte.d.ts +1 -1
- package/dist/components/utility/format/date-time/formatDateTime.d.ts +23 -0
- package/dist/components/utility/format/date-time/formatDateTime.js +33 -0
- package/dist/components/utility/format/duration/formatDuration.d.ts +15 -0
- package/dist/components/utility/format/duration/formatDuration.js +218 -0
- package/dist/components/utility/format/relative-time/formatRelativeTime.d.ts +42 -0
- package/dist/components/utility/format/relative-time/formatRelativeTime.js +530 -0
- package/dist/design-system/inheritance/tokens.js +6 -0
- package/dist/design-system/reserved-props/allowed-options.d.ts +9 -4
- package/dist/design-system/theme/tokens.d.ts +72 -2
- package/dist/design-system/theme/tokens.js +173 -134
- package/dist/icons/generated/check-thick.svelte +16 -0
- package/dist/icons/generated/check-thick.svelte.d.ts +7 -0
- package/dist/icons/generated/check.svelte +16 -0
- package/dist/icons/generated/check.svelte.d.ts +7 -0
- package/dist/icons/generated/close-thick.svelte +16 -0
- package/dist/icons/generated/close-thick.svelte.d.ts +7 -0
- package/dist/icons/generated/close.svelte +16 -0
- package/dist/icons/generated/close.svelte.d.ts +7 -0
- package/dist/icons/generated/index.d.ts +4 -0
- package/dist/icons/generated/index.js +4 -0
- package/dist/icons/generated/manifest.js +28 -0
- package/dist/index.d.ts +22 -2
- package/dist/index.js +22 -2
- package/dist/styles/tone-context.css +656 -46
- package/dist/theme.css +1 -161
- package/dist/themes/canopy.css +373 -0
- package/dist/themes/cobalt.css +373 -0
- package/dist/themes/iris.css +373 -0
- package/dist/themes/lumen.css +373 -0
- package/dist/themes/mono.css +373 -0
- package/dist/themes/moss.css +373 -0
- package/dist/themes/noir.css +373 -0
- package/dist/themes/plain.css +373 -0
- package/dist/themes/pulse.css +373 -0
- package/dist/themes/signal.css +373 -0
- package/dist/themes/slate.css +373 -0
- package/dist/themes/solar.css +373 -0
- package/dist/themes/sorbet.css +373 -0
- package/dist/themes/studio.css +369 -0
- package/dist/themes/vesper.css +373 -0
- package/package.json +32 -4
- package/dist/components/action/input/select/theme-switch/ThemeSwitch.svelte.d.ts +0 -10
|
@@ -1,9 +1,37 @@
|
|
|
1
|
+
import type { CustomCssSize } from 'seblify';
|
|
2
|
+
type CheckboxAnimation = 'none' | 'fade' | 'scale' | 'bump' | 'pop' | 'draw' | 'rise' | 'bounce';
|
|
3
|
+
type CheckboxVariant = 'solid' | 'outline' | 'soft' | 'tint' | 'plain' | 'blank' | 'inset' | 'overflow';
|
|
4
|
+
type CheckboxRadius = 'none' | 'sm' | 'md' | 'lg' | 'full' | CustomCssSize;
|
|
5
|
+
type CheckboxSize = 'sm' | 'md' | 'lg' | 'xl' | CustomCssSize;
|
|
6
|
+
type CheckboxIntermediateMark = 'dash' | 'tilde' | 'dot' | 'square';
|
|
7
|
+
type CheckboxTone = 'neutral' | 'strong' | 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info';
|
|
8
|
+
type CheckboxVisualState = 'default' | 'derived' | 'indirect' | 'direct-and-derived' | 'direct-and-indirect';
|
|
9
|
+
type CheckboxManagedState = {
|
|
10
|
+
checked: boolean;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
indeterminate?: boolean;
|
|
13
|
+
toggle?: () => void;
|
|
14
|
+
trigger?: () => void;
|
|
15
|
+
visualState?: CheckboxVisualState;
|
|
16
|
+
};
|
|
1
17
|
declare const Checkbox: import("svelte").Component<{
|
|
18
|
+
animation?: CheckboxAnimation | undefined;
|
|
19
|
+
ariaLabel?: string | undefined;
|
|
2
20
|
checked?: boolean | undefined;
|
|
3
21
|
disabled?: boolean | undefined;
|
|
22
|
+
duration?: number | undefined;
|
|
4
23
|
label?: string | undefined;
|
|
5
24
|
description?: string | undefined;
|
|
25
|
+
indeterminate?: boolean | undefined;
|
|
26
|
+
intermediateMark?: CheckboxIntermediateMark | undefined;
|
|
27
|
+
managed?: CheckboxManagedState | undefined;
|
|
6
28
|
name?: string | undefined;
|
|
29
|
+
onclick?: ((event: MouseEvent) => void) | undefined;
|
|
30
|
+
radius?: CheckboxRadius | undefined;
|
|
31
|
+
size?: CheckboxSize | undefined;
|
|
32
|
+
tone?: CheckboxTone | undefined;
|
|
33
|
+
variant?: CheckboxVariant | undefined;
|
|
34
|
+
visualState?: CheckboxVisualState | undefined;
|
|
7
35
|
value?: string | undefined;
|
|
8
36
|
}, {}, "checked">;
|
|
9
37
|
type Checkbox = ReturnType<typeof Checkbox>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export type CheckboxRelationsId = string;
|
|
2
|
+
export interface CheckboxRelationsItemConfig {
|
|
3
|
+
checked?: boolean;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
requires?: CheckboxRelationsId[];
|
|
6
|
+
selects?: CheckboxRelationsId[];
|
|
7
|
+
}
|
|
8
|
+
export type CheckboxRelationsGroupConfig = CheckboxRelationsId[] | {
|
|
9
|
+
itemIds: CheckboxRelationsId[];
|
|
10
|
+
};
|
|
11
|
+
export interface CheckboxRelationsConfig {
|
|
12
|
+
groups?: Record<CheckboxRelationsId, CheckboxRelationsGroupConfig>;
|
|
13
|
+
items: Record<CheckboxRelationsId, CheckboxRelationsItemConfig>;
|
|
14
|
+
}
|
|
15
|
+
export type CheckboxRelationsVisualState = 'default' | 'indirect';
|
|
16
|
+
export interface CheckboxRelationsState {
|
|
17
|
+
blockedBy: CheckboxRelationsId[];
|
|
18
|
+
checked: boolean;
|
|
19
|
+
directChecked: boolean;
|
|
20
|
+
directSelectedCount: number;
|
|
21
|
+
disabled: boolean;
|
|
22
|
+
indeterminate: boolean;
|
|
23
|
+
indirectChecked: boolean;
|
|
24
|
+
indirectSelectedCount: number;
|
|
25
|
+
itemIds: CheckboxRelationsId[];
|
|
26
|
+
requires: CheckboxRelationsId[];
|
|
27
|
+
selects: CheckboxRelationsId[];
|
|
28
|
+
selectedCount: number;
|
|
29
|
+
selectableCount: number;
|
|
30
|
+
setChecked: (checked: boolean) => void;
|
|
31
|
+
toggle: () => void;
|
|
32
|
+
trigger: () => void;
|
|
33
|
+
visualState: CheckboxRelationsVisualState;
|
|
34
|
+
}
|
|
35
|
+
export type CheckboxRelationsItemState = CheckboxRelationsState;
|
|
36
|
+
export type CheckboxRelationsGroupState = CheckboxRelationsState;
|
|
37
|
+
export interface CheckboxRelations {
|
|
38
|
+
group: (id: CheckboxRelationsId) => CheckboxRelationsGroupState;
|
|
39
|
+
item: (id: CheckboxRelationsId) => CheckboxRelationsItemState;
|
|
40
|
+
setChecked: (id: CheckboxRelationsId, checked: boolean) => void;
|
|
41
|
+
setItemChecked: (id: CheckboxRelationsId, checked: boolean) => void;
|
|
42
|
+
toggleGroup: (id: CheckboxRelationsId) => void;
|
|
43
|
+
toggleItem: (id: CheckboxRelationsId) => void;
|
|
44
|
+
trigger: (id: CheckboxRelationsId) => void;
|
|
45
|
+
}
|
|
46
|
+
export declare function createCheckboxManager(config: CheckboxRelationsConfig): CheckboxRelations;
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
export function createCheckboxManager(config) {
|
|
2
|
+
const items = config.items;
|
|
3
|
+
const groups = normalizeGroups(config.groups ?? {});
|
|
4
|
+
let directChecked = $state(Object.fromEntries(Object.entries(items).map(([id, item]) => [id, item.checked === true])));
|
|
5
|
+
const effectiveChecked = $derived(resolveEffectiveChecked(items, groups, directChecked));
|
|
6
|
+
function item(id) {
|
|
7
|
+
if (items[id]) {
|
|
8
|
+
return leafItem(id);
|
|
9
|
+
}
|
|
10
|
+
if (groups[id]) {
|
|
11
|
+
return group(id);
|
|
12
|
+
}
|
|
13
|
+
throw new Error(`Unknown checkbox relations item or group "${id}".`);
|
|
14
|
+
}
|
|
15
|
+
function leafItem(id) {
|
|
16
|
+
const config = getItemConfig(items, id);
|
|
17
|
+
const blockedBy = getBlockedBy(items, id, effectiveChecked);
|
|
18
|
+
const checked = effectiveChecked.has(id);
|
|
19
|
+
const direct = directChecked[id] === true && checked;
|
|
20
|
+
const indirect = checked && !direct;
|
|
21
|
+
const selectableCount = config.disabled === true || blockedBy.length > 0 ? 0 : 1;
|
|
22
|
+
return {
|
|
23
|
+
blockedBy,
|
|
24
|
+
checked,
|
|
25
|
+
directChecked: direct,
|
|
26
|
+
directSelectedCount: direct ? 1 : 0,
|
|
27
|
+
disabled: config.disabled === true || blockedBy.length > 0,
|
|
28
|
+
indeterminate: false,
|
|
29
|
+
indirectChecked: indirect,
|
|
30
|
+
indirectSelectedCount: indirect ? 1 : 0,
|
|
31
|
+
itemIds: [id],
|
|
32
|
+
requires: config.requires ?? [],
|
|
33
|
+
selects: config.selects ?? [],
|
|
34
|
+
selectedCount: checked ? 1 : 0,
|
|
35
|
+
selectableCount,
|
|
36
|
+
setChecked: (checked) => setItemChecked(id, checked),
|
|
37
|
+
toggle: () => trigger(id),
|
|
38
|
+
trigger: () => trigger(id),
|
|
39
|
+
visualState: indirect ? 'indirect' : 'default',
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function group(id) {
|
|
43
|
+
const itemIds = getGroupItemIds(groups, id);
|
|
44
|
+
const selectableItems = itemIds
|
|
45
|
+
.map((itemId) => leafItem(itemId))
|
|
46
|
+
.filter((itemState) => !itemState.disabled);
|
|
47
|
+
const selectedCount = selectableItems.filter((itemState) => itemState.checked).length;
|
|
48
|
+
const directSelectedCount = selectableItems.filter((itemState) => itemState.directChecked).length;
|
|
49
|
+
const indirectSelectedCount = selectableItems.filter((itemState) => itemState.indirectChecked).length;
|
|
50
|
+
const checked = selectableItems.length > 0 && selectedCount === selectableItems.length;
|
|
51
|
+
const visualState = selectedCount > 0 && directSelectedCount === 0 ? 'indirect' : 'default';
|
|
52
|
+
return {
|
|
53
|
+
blockedBy: [],
|
|
54
|
+
checked,
|
|
55
|
+
directChecked: checked && directSelectedCount > 0,
|
|
56
|
+
directSelectedCount,
|
|
57
|
+
disabled: selectableItems.length === 0,
|
|
58
|
+
indeterminate: selectedCount > 0 && !checked,
|
|
59
|
+
indirectChecked: checked && directSelectedCount === 0,
|
|
60
|
+
indirectSelectedCount,
|
|
61
|
+
itemIds,
|
|
62
|
+
requires: [],
|
|
63
|
+
selects: [],
|
|
64
|
+
selectedCount,
|
|
65
|
+
selectableCount: selectableItems.length,
|
|
66
|
+
setChecked: (checked) => setGroupChecked(id, checked),
|
|
67
|
+
toggle: () => trigger(id),
|
|
68
|
+
trigger: () => trigger(id),
|
|
69
|
+
visualState,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function trigger(id) {
|
|
73
|
+
if (items[id]) {
|
|
74
|
+
toggleItem(id);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (groups[id]) {
|
|
78
|
+
toggleGroup(id);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
throw new Error(`Unknown checkbox relations item or group "${id}".`);
|
|
82
|
+
}
|
|
83
|
+
function setChecked(id, checked) {
|
|
84
|
+
if (items[id]) {
|
|
85
|
+
setItemChecked(id, checked);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (groups[id]) {
|
|
89
|
+
setGroupChecked(id, checked);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
throw new Error(`Unknown checkbox relations item or group "${id}".`);
|
|
93
|
+
}
|
|
94
|
+
function setItemChecked(id, checked) {
|
|
95
|
+
const currentItem = leafItem(id);
|
|
96
|
+
if (currentItem.disabled && checked) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
directChecked[id] = checked;
|
|
100
|
+
}
|
|
101
|
+
function toggleItem(id) {
|
|
102
|
+
const currentItem = leafItem(id);
|
|
103
|
+
if (currentItem.disabled) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
directChecked[id] = !currentItem.directChecked;
|
|
107
|
+
}
|
|
108
|
+
function setGroupChecked(id, checked) {
|
|
109
|
+
const groupItemIds = getGroupItemIds(groups, id);
|
|
110
|
+
if (!checked) {
|
|
111
|
+
const selectableItemIds = groupItemIds.filter((itemId) => !leafItem(itemId).disabled);
|
|
112
|
+
for (const itemId of selectableItemIds) {
|
|
113
|
+
directChecked[itemId] = false;
|
|
114
|
+
}
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
let changed = true;
|
|
118
|
+
while (changed) {
|
|
119
|
+
changed = false;
|
|
120
|
+
for (const itemId of groupItemIds) {
|
|
121
|
+
const currentItem = leafItem(itemId);
|
|
122
|
+
if (!currentItem.disabled && directChecked[itemId] !== true) {
|
|
123
|
+
directChecked[itemId] = true;
|
|
124
|
+
changed = true;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function toggleGroup(id) {
|
|
130
|
+
const currentGroup = group(id);
|
|
131
|
+
setGroupChecked(id, !(currentGroup.checked && currentGroup.directSelectedCount > 0));
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
group,
|
|
135
|
+
item,
|
|
136
|
+
setChecked,
|
|
137
|
+
setItemChecked,
|
|
138
|
+
toggleGroup,
|
|
139
|
+
toggleItem,
|
|
140
|
+
trigger,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function normalizeGroups(groups) {
|
|
144
|
+
return Object.fromEntries(Object.entries(groups).map(([id, group]) => [
|
|
145
|
+
id,
|
|
146
|
+
Array.isArray(group) ? group : group.itemIds,
|
|
147
|
+
]));
|
|
148
|
+
}
|
|
149
|
+
function getItemConfig(items, id) {
|
|
150
|
+
const item = items[id];
|
|
151
|
+
if (!item) {
|
|
152
|
+
throw new Error(`Unknown checkbox relations item "${id}".`);
|
|
153
|
+
}
|
|
154
|
+
return item;
|
|
155
|
+
}
|
|
156
|
+
function getGroupItemIds(groups, id) {
|
|
157
|
+
const itemIds = groups[id];
|
|
158
|
+
if (!itemIds) {
|
|
159
|
+
throw new Error(`Unknown checkbox relations group "${id}".`);
|
|
160
|
+
}
|
|
161
|
+
return itemIds;
|
|
162
|
+
}
|
|
163
|
+
function resolveEffectiveChecked(items, groups, directChecked) {
|
|
164
|
+
const effectiveChecked = new Set();
|
|
165
|
+
let changed = true;
|
|
166
|
+
while (changed) {
|
|
167
|
+
changed = false;
|
|
168
|
+
for (const [id, item] of Object.entries(items)) {
|
|
169
|
+
if (directChecked[id] === true &&
|
|
170
|
+
item.disabled !== true &&
|
|
171
|
+
hasRequiredItems(item, effectiveChecked) &&
|
|
172
|
+
!effectiveChecked.has(id)) {
|
|
173
|
+
effectiveChecked.add(id);
|
|
174
|
+
changed = true;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
for (const id of Array.from(effectiveChecked)) {
|
|
178
|
+
for (const selectedId of getSelectedItemIds(items, groups, id)) {
|
|
179
|
+
const selectedItem = getItemConfig(items, selectedId);
|
|
180
|
+
if (selectedItem.disabled !== true &&
|
|
181
|
+
hasRequiredItems(selectedItem, effectiveChecked) &&
|
|
182
|
+
!effectiveChecked.has(selectedId)) {
|
|
183
|
+
effectiveChecked.add(selectedId);
|
|
184
|
+
changed = true;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return effectiveChecked;
|
|
190
|
+
}
|
|
191
|
+
function getSelectedItemIds(items, groups, id) {
|
|
192
|
+
return (items[id]?.selects ?? []).flatMap((selectedId) => [
|
|
193
|
+
...(items[selectedId] ? [selectedId] : []),
|
|
194
|
+
...(groups[selectedId] ?? []),
|
|
195
|
+
]);
|
|
196
|
+
}
|
|
197
|
+
function hasRequiredItems(item, effectiveChecked) {
|
|
198
|
+
return (item.requires ?? []).every((id) => effectiveChecked.has(id));
|
|
199
|
+
}
|
|
200
|
+
function getBlockedBy(items, id, effectiveChecked) {
|
|
201
|
+
return (getItemConfig(items, id).requires ?? []).filter((requiredId) => !effectiveChecked.has(requiredId));
|
|
202
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../../../../../../../theme.css';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>Checkbox Bounce Visual Test</title>
|
|
7
|
+
<script type="module" src="./bounce.ts"></script>
|
|
8
|
+
<style>
|
|
9
|
+
body {
|
|
10
|
+
min-height: 100vh;
|
|
11
|
+
margin: 0;
|
|
12
|
+
background: #f5f7fb;
|
|
13
|
+
color: #172033;
|
|
14
|
+
display: grid;
|
|
15
|
+
place-items: center;
|
|
16
|
+
font-family:
|
|
17
|
+
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
|
|
18
|
+
'Segoe UI', sans-serif;
|
|
19
|
+
}
|
|
20
|
+
</style>
|
|
21
|
+
</head>
|
|
22
|
+
<body>
|
|
23
|
+
<main>
|
|
24
|
+
<div id="checkbox-root"></div>
|
|
25
|
+
</main>
|
|
26
|
+
</body>
|
|
27
|
+
</html>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { mount } from 'svelte';
|
|
2
|
+
import '../../../../../../../theme.css';
|
|
3
|
+
import Checkbox from '../../Checkbox.svelte';
|
|
4
|
+
mount(Checkbox, {
|
|
5
|
+
target: document.getElementById('checkbox-root'),
|
|
6
|
+
props: {
|
|
7
|
+
animation: 'bounce',
|
|
8
|
+
duration: 900,
|
|
9
|
+
label: 'Bounce checkbox',
|
|
10
|
+
size: 'xl',
|
|
11
|
+
tone: 'primary',
|
|
12
|
+
},
|
|
13
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../../../../../../../theme.css';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>Checkbox bump animation fixture</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="checkbox-root"></div>
|
|
10
|
+
<script type="module" src="./bump.ts"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { mount } from 'svelte';
|
|
2
|
+
import '../../../../../../../theme.css';
|
|
3
|
+
import Checkbox from '../../Checkbox.svelte';
|
|
4
|
+
mount(Checkbox, {
|
|
5
|
+
target: document.getElementById('checkbox-root'),
|
|
6
|
+
props: {
|
|
7
|
+
animation: 'bump',
|
|
8
|
+
duration: 1000,
|
|
9
|
+
label: 'Bump checkbox',
|
|
10
|
+
size: 'xl',
|
|
11
|
+
tone: 'primary',
|
|
12
|
+
},
|
|
13
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../../../../../../../theme.css';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>Checkbox draw animation fixture</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="checkbox-root"></div>
|
|
10
|
+
<script type="module" src="./draw.ts"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { mount } from 'svelte';
|
|
2
|
+
import '../../../../../../../theme.css';
|
|
3
|
+
import Checkbox from '../../Checkbox.svelte';
|
|
4
|
+
mount(Checkbox, {
|
|
5
|
+
target: document.getElementById('checkbox-root'),
|
|
6
|
+
props: {
|
|
7
|
+
animation: 'draw',
|
|
8
|
+
label: 'Draw checkbox',
|
|
9
|
+
size: 'xl',
|
|
10
|
+
tone: 'primary',
|
|
11
|
+
},
|
|
12
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../../../../../../../theme.css';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>Checkbox fade animation fixture</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="checkbox-root"></div>
|
|
10
|
+
<script type="module" src="./fade.ts"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { mount } from 'svelte';
|
|
2
|
+
import '../../../../../../../theme.css';
|
|
3
|
+
import Checkbox from '../../Checkbox.svelte';
|
|
4
|
+
mount(Checkbox, {
|
|
5
|
+
target: document.getElementById('checkbox-root'),
|
|
6
|
+
props: {
|
|
7
|
+
animation: 'fade',
|
|
8
|
+
label: 'Fade checkbox',
|
|
9
|
+
size: 'xl',
|
|
10
|
+
tone: 'primary',
|
|
11
|
+
},
|
|
12
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../../../../../../../theme.css';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>Checkbox pop animation fixture</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="checkbox-root"></div>
|
|
10
|
+
<script type="module" src="./pop.ts"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { mount } from 'svelte';
|
|
2
|
+
import '../../../../../../../theme.css';
|
|
3
|
+
import Checkbox from '../../Checkbox.svelte';
|
|
4
|
+
mount(Checkbox, {
|
|
5
|
+
target: document.getElementById('checkbox-root'),
|
|
6
|
+
props: {
|
|
7
|
+
animation: 'pop',
|
|
8
|
+
duration: 1000,
|
|
9
|
+
label: 'Pop checkbox',
|
|
10
|
+
size: 'xl',
|
|
11
|
+
tone: 'primary',
|
|
12
|
+
},
|
|
13
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../../../../../../../theme.css';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>Checkbox Rise Visual Test</title>
|
|
7
|
+
<script type="module" src="./rise.ts"></script>
|
|
8
|
+
<style>
|
|
9
|
+
body {
|
|
10
|
+
min-height: 100vh;
|
|
11
|
+
margin: 0;
|
|
12
|
+
background: #f5f7fb;
|
|
13
|
+
color: #172033;
|
|
14
|
+
display: grid;
|
|
15
|
+
place-items: center;
|
|
16
|
+
font-family:
|
|
17
|
+
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
|
|
18
|
+
'Segoe UI', sans-serif;
|
|
19
|
+
}
|
|
20
|
+
</style>
|
|
21
|
+
</head>
|
|
22
|
+
<body>
|
|
23
|
+
<main>
|
|
24
|
+
<div id="checkbox-root"></div>
|
|
25
|
+
</main>
|
|
26
|
+
</body>
|
|
27
|
+
</html>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { mount } from 'svelte';
|
|
2
|
+
import '../../../../../../../theme.css';
|
|
3
|
+
import Checkbox from '../../Checkbox.svelte';
|
|
4
|
+
mount(Checkbox, {
|
|
5
|
+
target: document.getElementById('checkbox-root'),
|
|
6
|
+
props: {
|
|
7
|
+
animation: 'rise',
|
|
8
|
+
duration: 800,
|
|
9
|
+
label: 'Rise checkbox',
|
|
10
|
+
size: 'xl',
|
|
11
|
+
tone: 'primary',
|
|
12
|
+
},
|
|
13
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../../../../../../../theme.css';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>Checkbox Scale Visual Test</title>
|
|
7
|
+
<script type="module" src="./scale.ts"></script>
|
|
8
|
+
<style>
|
|
9
|
+
body {
|
|
10
|
+
min-height: 100vh;
|
|
11
|
+
margin: 0;
|
|
12
|
+
background: #f5f7fb;
|
|
13
|
+
color: #172033;
|
|
14
|
+
display: grid;
|
|
15
|
+
place-items: center;
|
|
16
|
+
font-family:
|
|
17
|
+
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
|
|
18
|
+
'Segoe UI', sans-serif;
|
|
19
|
+
}
|
|
20
|
+
</style>
|
|
21
|
+
</head>
|
|
22
|
+
<body>
|
|
23
|
+
<main>
|
|
24
|
+
<div id="checkbox-root"></div>
|
|
25
|
+
</main>
|
|
26
|
+
</body>
|
|
27
|
+
</html>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { mount } from 'svelte';
|
|
2
|
+
import '../../../../../../../theme.css';
|
|
3
|
+
import Checkbox from '../../Checkbox.svelte';
|
|
4
|
+
mount(Checkbox, {
|
|
5
|
+
target: document.getElementById('checkbox-root'),
|
|
6
|
+
props: {
|
|
7
|
+
animation: 'scale',
|
|
8
|
+
duration: 1000,
|
|
9
|
+
label: 'Scale checkbox',
|
|
10
|
+
size: 'xl',
|
|
11
|
+
tone: 'primary',
|
|
12
|
+
},
|
|
13
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../../../../../../../theme.css';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>Checkbox visual state fixture</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="checkbox-root"></div>
|
|
10
|
+
<script type="module" src="./visual-state.ts"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|