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
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CustomCssSize } from 'seblify';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
type ToggleButtonRadius = 'none' | 'sm' | 'md' | 'lg' | 'full' | CustomCssSize;
|
|
4
|
+
type ToggleButtonSize = 'sm' | 'md' | 'lg' | 'xl' | CustomCssSize;
|
|
5
|
+
type ToggleButtonTone = 'neutral' | 'strong' | 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info';
|
|
6
|
+
type ToggleButtonVariant = 'solid' | 'soft' | 'tint' | 'outline' | 'plain';
|
|
7
|
+
declare const ToggleButton: import("svelte").Component<{
|
|
8
|
+
[x: string]: unknown;
|
|
9
|
+
ariaLabel?: string | undefined;
|
|
10
|
+
children?: Snippet | undefined;
|
|
11
|
+
class?: string | undefined;
|
|
12
|
+
disabled?: boolean | undefined;
|
|
13
|
+
end?: Snippet | undefined;
|
|
14
|
+
fullWidth?: boolean | undefined;
|
|
15
|
+
iconOnly?: boolean | undefined;
|
|
16
|
+
label?: string | undefined;
|
|
17
|
+
onclick?: ((event: MouseEvent) => void) | undefined;
|
|
18
|
+
pressed?: boolean | undefined;
|
|
19
|
+
radius?: ToggleButtonRadius | undefined;
|
|
20
|
+
size?: ToggleButtonSize | undefined;
|
|
21
|
+
start?: Snippet | undefined;
|
|
22
|
+
tone?: ToggleButtonTone | undefined;
|
|
23
|
+
type?: "Guard: `type` prop not allowed. Use `variant` instead" | undefined;
|
|
24
|
+
value?: string | undefined;
|
|
25
|
+
variant?: ToggleButtonVariant | undefined;
|
|
26
|
+
}, {}, "pressed">;
|
|
27
|
+
type ToggleButton = ReturnType<typeof ToggleButton>;
|
|
28
|
+
export default ToggleButton;
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { CustomCssSize, SeblifyProps } from 'seblify';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
import { setToggleButtonGroupContext } from './context';
|
|
5
|
+
|
|
6
|
+
type ToggleButtonGroupOrientation = 'horizontal' | 'vertical';
|
|
7
|
+
type ToggleButtonGroupRadius =
|
|
8
|
+
| 'none'
|
|
9
|
+
| 'sm'
|
|
10
|
+
| 'md'
|
|
11
|
+
| 'lg'
|
|
12
|
+
| 'full'
|
|
13
|
+
| CustomCssSize;
|
|
14
|
+
type ToggleButtonGroupSelectionMode = 'multiple' | 'single';
|
|
15
|
+
|
|
16
|
+
type Props = SeblifyProps<{
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
ariaLabel?: string;
|
|
19
|
+
children?: Snippet;
|
|
20
|
+
class?: string;
|
|
21
|
+
orientation?: ToggleButtonGroupOrientation;
|
|
22
|
+
radius?: ToggleButtonGroupRadius;
|
|
23
|
+
required?: boolean;
|
|
24
|
+
selectionMode?: ToggleButtonGroupSelectionMode;
|
|
25
|
+
value?: string;
|
|
26
|
+
values?: string[];
|
|
27
|
+
}>;
|
|
28
|
+
|
|
29
|
+
const TOGGLE_BUTTON_GROUP_RADIUS_MAP: Record<
|
|
30
|
+
Exclude<ToggleButtonGroupRadius, CustomCssSize>,
|
|
31
|
+
string
|
|
32
|
+
> = {
|
|
33
|
+
none: '0',
|
|
34
|
+
sm: '0.25rem',
|
|
35
|
+
md: '0.375rem',
|
|
36
|
+
lg: '0.5rem',
|
|
37
|
+
full: '999px',
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
let {
|
|
41
|
+
ariaLabel,
|
|
42
|
+
children,
|
|
43
|
+
class: className,
|
|
44
|
+
orientation = 'horizontal',
|
|
45
|
+
radius = 'md',
|
|
46
|
+
required = false,
|
|
47
|
+
selectionMode = 'multiple',
|
|
48
|
+
value = $bindable(''),
|
|
49
|
+
values = $bindable([]),
|
|
50
|
+
...restProps
|
|
51
|
+
}: Props = $props();
|
|
52
|
+
|
|
53
|
+
let registeredValues = $state<string[]>([]);
|
|
54
|
+
|
|
55
|
+
function cssSize(value: CustomCssSize): string {
|
|
56
|
+
return typeof value === 'number' ? `${value}px` : value;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function resolveRadiusValue(value: ToggleButtonGroupRadius): string {
|
|
60
|
+
if (typeof value === 'number') {
|
|
61
|
+
return cssSize(value);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
TOGGLE_BUTTON_GROUP_RADIUS_MAP[
|
|
66
|
+
value as keyof typeof TOGGLE_BUTTON_GROUP_RADIUS_MAP
|
|
67
|
+
] ?? value
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function addValue(nextValue: string) {
|
|
72
|
+
if (values.includes(nextValue)) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
values = [...values, nextValue];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function removeValue(nextValue: string) {
|
|
80
|
+
values = values.filter((currentValue) => currentValue !== nextValue);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function register(nextValue: string, initialPressed: boolean) {
|
|
84
|
+
if (!registeredValues.includes(nextValue)) {
|
|
85
|
+
registeredValues = [...registeredValues, nextValue];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (!initialPressed) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (selectionMode === 'single') {
|
|
93
|
+
if (!value) {
|
|
94
|
+
value = nextValue;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
addValue(nextValue);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function unregister(nextValue: string) {
|
|
104
|
+
registeredValues = registeredValues.filter(
|
|
105
|
+
(currentValue) => currentValue !== nextValue,
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
if (selectionMode === 'single' && value === nextValue) {
|
|
109
|
+
value = '';
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (selectionMode === 'multiple') {
|
|
113
|
+
removeValue(nextValue);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function isPressed(nextValue: string): boolean {
|
|
118
|
+
return selectionMode === 'single'
|
|
119
|
+
? value === nextValue
|
|
120
|
+
: values.includes(nextValue);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function toggle(nextValue: string) {
|
|
124
|
+
if (selectionMode === 'single') {
|
|
125
|
+
if (value === nextValue) {
|
|
126
|
+
if (!required) {
|
|
127
|
+
value = '';
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
value = nextValue;
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (values.includes(nextValue)) {
|
|
138
|
+
removeValue(nextValue);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
addValue(nextValue);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const radiusValue = $derived(resolveRadiusValue(radius));
|
|
146
|
+
|
|
147
|
+
$effect(() => {
|
|
148
|
+
if (selectionMode !== 'single' || !required || value) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const firstValue = registeredValues[0];
|
|
153
|
+
|
|
154
|
+
if (firstValue) {
|
|
155
|
+
value = firstValue;
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
setToggleButtonGroupContext({
|
|
160
|
+
isPressed,
|
|
161
|
+
register,
|
|
162
|
+
toggle,
|
|
163
|
+
unregister,
|
|
164
|
+
});
|
|
165
|
+
</script>
|
|
166
|
+
|
|
167
|
+
<div
|
|
168
|
+
{...restProps}
|
|
169
|
+
aria-label={ariaLabel}
|
|
170
|
+
class={`toggle-button-group${className ? ` ${className}` : ''}`}
|
|
171
|
+
data-orientation={orientation}
|
|
172
|
+
data-selection-mode={selectionMode}
|
|
173
|
+
role="group"
|
|
174
|
+
style:--toggle-button-group-radius={radiusValue}
|
|
175
|
+
>
|
|
176
|
+
{#if children}
|
|
177
|
+
{@render children()}
|
|
178
|
+
{/if}
|
|
179
|
+
</div>
|
|
180
|
+
|
|
181
|
+
<style>
|
|
182
|
+
.toggle-button-group {
|
|
183
|
+
display: inline-flex;
|
|
184
|
+
max-width: 100%;
|
|
185
|
+
align-items: stretch;
|
|
186
|
+
vertical-align: middle;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.toggle-button-group[data-orientation='horizontal'] {
|
|
190
|
+
flex-direction: row;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.toggle-button-group[data-orientation='vertical'] {
|
|
194
|
+
flex-direction: column;
|
|
195
|
+
width: fit-content;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.toggle-button-group :global(.toggle-button) {
|
|
199
|
+
position: relative;
|
|
200
|
+
border-radius: 0;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.toggle-button-group :global(.toggle-button:focus-visible) {
|
|
204
|
+
z-index: 2;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.toggle-button-group[data-orientation='horizontal']
|
|
208
|
+
:global(.toggle-button) {
|
|
209
|
+
margin-inline-start: -1px;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.toggle-button-group[data-orientation='horizontal']
|
|
213
|
+
:global(.toggle-button:first-child) {
|
|
214
|
+
margin-inline-start: 0;
|
|
215
|
+
border-start-start-radius: var(--toggle-button-group-radius);
|
|
216
|
+
border-end-start-radius: var(--toggle-button-group-radius);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.toggle-button-group[data-orientation='horizontal']
|
|
220
|
+
:global(.toggle-button:last-child) {
|
|
221
|
+
border-start-end-radius: var(--toggle-button-group-radius);
|
|
222
|
+
border-end-end-radius: var(--toggle-button-group-radius);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.toggle-button-group[data-orientation='vertical'] :global(.toggle-button) {
|
|
226
|
+
width: 100%;
|
|
227
|
+
margin-block-start: -1px;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.toggle-button-group[data-orientation='vertical']
|
|
231
|
+
:global(.toggle-button:first-child) {
|
|
232
|
+
margin-block-start: 0;
|
|
233
|
+
border-start-start-radius: var(--toggle-button-group-radius);
|
|
234
|
+
border-start-end-radius: var(--toggle-button-group-radius);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.toggle-button-group[data-orientation='vertical']
|
|
238
|
+
:global(.toggle-button:last-child) {
|
|
239
|
+
border-end-start-radius: var(--toggle-button-group-radius);
|
|
240
|
+
border-end-end-radius: var(--toggle-button-group-radius);
|
|
241
|
+
}
|
|
242
|
+
</style>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CustomCssSize } from 'seblify';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
type ToggleButtonGroupOrientation = 'horizontal' | 'vertical';
|
|
4
|
+
type ToggleButtonGroupRadius = 'none' | 'sm' | 'md' | 'lg' | 'full' | CustomCssSize;
|
|
5
|
+
type ToggleButtonGroupSelectionMode = 'multiple' | 'single';
|
|
6
|
+
declare const ToggleButtonGroup: import("svelte").Component<{
|
|
7
|
+
[x: string]: unknown;
|
|
8
|
+
ariaLabel?: string | undefined;
|
|
9
|
+
children?: Snippet | undefined;
|
|
10
|
+
class?: string | undefined;
|
|
11
|
+
orientation?: ToggleButtonGroupOrientation | undefined;
|
|
12
|
+
radius?: ToggleButtonGroupRadius | undefined;
|
|
13
|
+
required?: boolean | undefined;
|
|
14
|
+
selectionMode?: ToggleButtonGroupSelectionMode | undefined;
|
|
15
|
+
value?: string | undefined;
|
|
16
|
+
values?: string[] | undefined;
|
|
17
|
+
}, {}, "value" | "values">;
|
|
18
|
+
type ToggleButtonGroup = ReturnType<typeof ToggleButtonGroup>;
|
|
19
|
+
export default ToggleButtonGroup;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import ToggleButton from '../toggle-button/ToggleButton.svelte';
|
|
3
|
+
import ToggleButtonGroup from './ToggleButtonGroup.svelte';
|
|
4
|
+
|
|
5
|
+
type Props = {
|
|
6
|
+
orientation?: 'horizontal' | 'vertical';
|
|
7
|
+
required?: boolean;
|
|
8
|
+
selectionMode?: 'multiple' | 'single';
|
|
9
|
+
value?: string;
|
|
10
|
+
values?: string[];
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
let {
|
|
14
|
+
orientation = 'horizontal',
|
|
15
|
+
required = false,
|
|
16
|
+
selectionMode = 'multiple',
|
|
17
|
+
value = $bindable(''),
|
|
18
|
+
values = $bindable([]),
|
|
19
|
+
}: Props = $props();
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<ToggleButtonGroup
|
|
23
|
+
ariaLabel="Text formatting"
|
|
24
|
+
bind:value
|
|
25
|
+
bind:values
|
|
26
|
+
{orientation}
|
|
27
|
+
{required}
|
|
28
|
+
{selectionMode}
|
|
29
|
+
>
|
|
30
|
+
<ToggleButton value="bold">Bold</ToggleButton>
|
|
31
|
+
<ToggleButton value="italic">Italic</ToggleButton>
|
|
32
|
+
<ToggleButton value="underline" disabled>Underline</ToggleButton>
|
|
33
|
+
</ToggleButtonGroup>
|
|
34
|
+
|
|
35
|
+
<span data-testid="selected-value">{value}</span>
|
|
36
|
+
<span data-testid="selected-values">{values.join(',')}</span>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import ToggleButtonGroup from './ToggleButtonGroup.svelte';
|
|
2
|
+
type Props = {
|
|
3
|
+
orientation?: 'horizontal' | 'vertical';
|
|
4
|
+
required?: boolean;
|
|
5
|
+
selectionMode?: 'multiple' | 'single';
|
|
6
|
+
value?: string;
|
|
7
|
+
values?: string[];
|
|
8
|
+
};
|
|
9
|
+
declare const ToggleButtonGroup: import("svelte").Component<Props, {}, "value" | "values">;
|
|
10
|
+
type ToggleButtonGroup = ReturnType<typeof ToggleButtonGroup>;
|
|
11
|
+
export default ToggleButtonGroup;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface ToggleButtonGroupContext {
|
|
2
|
+
isPressed: (value: string) => boolean;
|
|
3
|
+
register: (value: string, initialPressed: boolean) => void;
|
|
4
|
+
toggle: (value: string) => void;
|
|
5
|
+
unregister: (value: string) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function setToggleButtonGroupContext(value: ToggleButtonGroupContext): void;
|
|
8
|
+
export declare function getToggleButtonGroupContext(): ToggleButtonGroupContext | undefined;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { getContext, setContext } from 'svelte';
|
|
2
|
+
const toggleButtonGroupContextKey = Symbol('seblify-toggle-button-group');
|
|
3
|
+
export function setToggleButtonGroupContext(value) {
|
|
4
|
+
setContext(toggleButtonGroupContextKey, value);
|
|
5
|
+
}
|
|
6
|
+
export function getToggleButtonGroupContext() {
|
|
7
|
+
return getContext(toggleButtonGroupContextKey);
|
|
8
|
+
}
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
.cells:focus-visible .cell {
|
|
108
|
-
border-color: var(--seblify-color-fill
|
|
108
|
+
border-color: var(--seblify-color-primary-fill, #146a6f);
|
|
109
109
|
box-shadow: 0 0 0 3px var(--seblify-color-focus-ring, #9bd4d8);
|
|
110
110
|
}
|
|
111
111
|
|
|
@@ -125,14 +125,14 @@
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
.filled {
|
|
128
|
-
border-color: var(--seblify-color-border
|
|
129
|
-
background: var(--seblify-color-surface
|
|
128
|
+
border-color: var(--seblify-color-primary-border, #9ab7ba);
|
|
129
|
+
background: var(--seblify-color-primary-surface, #f7fbfb);
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
.caret {
|
|
133
133
|
width: 2px;
|
|
134
134
|
height: 20px;
|
|
135
|
-
background: var(--seblify-color-fill
|
|
135
|
+
background: var(--seblify-color-primary-fill, #146a6f);
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
.input {
|