@tangible/ui 0.1.0 → 0.2.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/components/Button/types.d.ts +5 -2
- package/components/Chip/Chip.d.ts +28 -0
- package/components/Chip/Chip.js +19 -3
- package/components/ColorPicker/ColorArea.d.ts +24 -0
- package/components/ColorPicker/ColorArea.js +62 -0
- package/components/ColorPicker/ColorField.d.ts +59 -0
- package/components/ColorPicker/ColorField.js +88 -0
- package/components/ColorPicker/ColorPicker.d.ts +36 -0
- package/components/ColorPicker/ColorPicker.js +215 -0
- package/components/ColorPicker/ColorSlider.d.ts +20 -0
- package/components/ColorPicker/ColorSlider.js +38 -0
- package/components/ColorPicker/index.d.ts +14 -0
- package/components/ColorPicker/index.js +7 -0
- package/components/ColorPicker/labels.d.ts +42 -0
- package/components/ColorPicker/labels.js +38 -0
- package/components/ColorPicker/tracks.d.ts +4 -0
- package/components/ColorPicker/tracks.js +4 -0
- package/components/ColorPicker/usePointerDrag.d.ts +13 -0
- package/components/ColorPicker/usePointerDrag.js +34 -0
- package/components/Combobox/Combobox.d.ts +1 -1
- package/components/Combobox/Combobox.js +2 -2
- package/components/Combobox/types.d.ts +13 -0
- package/components/IconButton/types.d.ts +2 -2
- package/components/MultiCombobox/MultiCombobox.d.ts +33 -0
- package/components/MultiCombobox/MultiCombobox.js +595 -0
- package/components/MultiCombobox/MultiComboboxContext.d.ts +8 -0
- package/components/MultiCombobox/MultiComboboxContext.js +36 -0
- package/components/MultiCombobox/index.d.ts +3 -0
- package/components/MultiCombobox/index.js +2 -0
- package/components/MultiCombobox/types.d.ts +244 -0
- package/components/MultiCombobox/types.js +7 -0
- package/components/MultiSelect/MultiSelect.js +22 -2
- package/components/Popover/index.d.ts +1 -1
- package/components/Select/Select.js +14 -0
- package/components/Slider/Slider.d.ts +2 -0
- package/components/Slider/Slider.js +29 -0
- package/components/Slider/index.d.ts +2 -0
- package/components/Slider/index.js +1 -0
- package/components/Slider/types.d.ts +39 -0
- package/components/Slider/types.js +1 -0
- package/components/index.d.ts +6 -0
- package/components/index.js +3 -0
- package/icons/icons.svg +1 -0
- package/icons/manifest.json +8 -0
- package/icons/registry.d.ts +2 -0
- package/icons/registry.js +1 -0
- package/icons/system/index.d.ts +2 -0
- package/icons/system/index.js +11 -0
- package/package.json +13 -1
- package/styles/all.css +1 -1
- package/styles/all.expanded.css +1063 -133
- package/styles/all.expanded.unlayered.css +1063 -133
- package/styles/all.unlayered.css +1 -1
- package/styles/components/_bundle.scss +6 -0
- package/styles/components/button.scss +45 -35
- package/styles/components/chip.scss +57 -0
- package/styles/components/color-picker.scss +378 -0
- package/styles/components/combobox.scss +16 -2
- package/styles/components/icon-button.scss +32 -26
- package/styles/components/input/index.scss +1 -2
- package/styles/components/multi-combobox.scss +457 -0
- package/styles/components/multi-select.scss +34 -18
- package/styles/components/pager.scss +4 -2
- package/styles/components/progress.scss +1 -1
- package/styles/components/segmented-control.scss +44 -18
- package/styles/components/select.scss +19 -3
- package/styles/components/slider.scss +184 -0
- package/styles/components/switch.scss +1 -1
- package/styles/core.css +1 -1
- package/styles/core.unlayered.css +1 -1
- package/styles/system/_tokens.scss +13 -0
- package/tui-manifest.json +307 -8
- package/utils/color/color.d.ts +61 -0
- package/utils/color/color.js +293 -0
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import type { FloatingContext, ReferenceType } from '@floating-ui/react';
|
|
2
|
+
import type { RefObject, CSSProperties, MutableRefObject } from 'react';
|
|
3
|
+
import type { SizeStandard } from '../../types/sizes';
|
|
4
|
+
import type { OptionValue } from '../../utils/value-key';
|
|
5
|
+
export type MultiComboboxLabels = {
|
|
6
|
+
/** Label for the clear-all button. */
|
|
7
|
+
clear?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Accessible label for a chip's remove button.
|
|
10
|
+
* @default (label) => `Remove ${label}`
|
|
11
|
+
*/
|
|
12
|
+
remove?: (label: string) => string;
|
|
13
|
+
/**
|
|
14
|
+
* Screen reader status announcement, fired on every selection change.
|
|
15
|
+
* When `max` is defined and `count >= max`, include a "maximum reached" note.
|
|
16
|
+
* @default (count, max) => count === 0 ? '0 items selected' : `${count} item${count === 1 ? '' : 's'} selected${max !== undefined && count >= max ? `. Maximum of ${max} reached` : ''}`
|
|
17
|
+
*/
|
|
18
|
+
status?: (count: number, max?: number) => string;
|
|
19
|
+
};
|
|
20
|
+
export declare const defaultMultiComboboxLabels: Required<MultiComboboxLabels>;
|
|
21
|
+
/**
|
|
22
|
+
* Controls when filtering should be active.
|
|
23
|
+
* - 'always': Consumer filters whenever inputValue changes (default)
|
|
24
|
+
* - 'when-searching': Query becomes empty when not actively searching,
|
|
25
|
+
* allowing consumers to show all options when browsing selections
|
|
26
|
+
*/
|
|
27
|
+
export type FilterMode = 'always' | 'when-searching';
|
|
28
|
+
/**
|
|
29
|
+
* Value type for MultiCombobox — arrays of strings or numbers.
|
|
30
|
+
*/
|
|
31
|
+
export type MultiComboboxValue = Array<string | number>;
|
|
32
|
+
export type MultiComboboxProps = {
|
|
33
|
+
/**
|
|
34
|
+
* Control size.
|
|
35
|
+
* @default 'md'
|
|
36
|
+
*/
|
|
37
|
+
size?: SizeStandard;
|
|
38
|
+
/**
|
|
39
|
+
* How selected chips behave when they exceed the control width.
|
|
40
|
+
* - 'trim' (default): the control stays a single line (fixed height); chips
|
|
41
|
+
* flow horizontally and clip toward the inline-start, keeping the typing
|
|
42
|
+
* area in view. Preserves row alignment in multi-column form layouts.
|
|
43
|
+
* - 'wrap': chips wrap onto new lines and the control grows vertically.
|
|
44
|
+
* Opt in for standalone or spacious placements.
|
|
45
|
+
* @default 'trim'
|
|
46
|
+
*/
|
|
47
|
+
overflow?: 'wrap' | 'trim';
|
|
48
|
+
/**
|
|
49
|
+
* Controlled selected values.
|
|
50
|
+
*/
|
|
51
|
+
value?: MultiComboboxValue;
|
|
52
|
+
/**
|
|
53
|
+
* Default values for uncontrolled usage.
|
|
54
|
+
*/
|
|
55
|
+
defaultValue?: MultiComboboxValue;
|
|
56
|
+
/**
|
|
57
|
+
* Callback when selection changes.
|
|
58
|
+
*/
|
|
59
|
+
onValueChange?: (value: MultiComboboxValue) => void;
|
|
60
|
+
/**
|
|
61
|
+
* Controlled input value for search/filter.
|
|
62
|
+
*/
|
|
63
|
+
inputValue?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Callback when input value changes (typing, clear).
|
|
66
|
+
*/
|
|
67
|
+
onInputChange?: (value: string) => void;
|
|
68
|
+
/**
|
|
69
|
+
* Controls filtering behavior.
|
|
70
|
+
* @default 'always'
|
|
71
|
+
*/
|
|
72
|
+
filterMode?: FilterMode;
|
|
73
|
+
/**
|
|
74
|
+
* Callback when the effective query changes.
|
|
75
|
+
*/
|
|
76
|
+
onQueryChange?: (query: string) => void;
|
|
77
|
+
/**
|
|
78
|
+
* Controlled open state.
|
|
79
|
+
*/
|
|
80
|
+
open?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Default open state for uncontrolled usage.
|
|
83
|
+
* @default false
|
|
84
|
+
*/
|
|
85
|
+
defaultOpen?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Callback when open state changes.
|
|
88
|
+
*/
|
|
89
|
+
onOpenChange?: (open: boolean) => void;
|
|
90
|
+
/**
|
|
91
|
+
* Whether the combobox is disabled.
|
|
92
|
+
* @default false
|
|
93
|
+
*/
|
|
94
|
+
disabled?: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Placeholder text for the input. Shown only when no values are selected.
|
|
97
|
+
*/
|
|
98
|
+
placeholder?: string;
|
|
99
|
+
/**
|
|
100
|
+
* Whether to open the listbox when the input receives focus.
|
|
101
|
+
* @default true
|
|
102
|
+
*/
|
|
103
|
+
openOnFocus?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Maximum number of selections allowed.
|
|
106
|
+
* When reached, unselected options become disabled.
|
|
107
|
+
*/
|
|
108
|
+
max?: number;
|
|
109
|
+
/**
|
|
110
|
+
* Callback when max selections is reached.
|
|
111
|
+
*/
|
|
112
|
+
onMaxReached?: () => void;
|
|
113
|
+
/**
|
|
114
|
+
* Accessible name for the combobox.
|
|
115
|
+
*/
|
|
116
|
+
'aria-label'?: string;
|
|
117
|
+
/**
|
|
118
|
+
* ID of element that labels this combobox.
|
|
119
|
+
*/
|
|
120
|
+
'aria-labelledby'?: string;
|
|
121
|
+
/**
|
|
122
|
+
* ID(s) of element(s) that describe this combobox (helper text, error).
|
|
123
|
+
* Forwarded to the input — Field.Control injects this.
|
|
124
|
+
*/
|
|
125
|
+
'aria-describedby'?: string;
|
|
126
|
+
/**
|
|
127
|
+
* Invalid state, forwarded to the input. Field.Control injects this.
|
|
128
|
+
*/
|
|
129
|
+
'aria-invalid'?: boolean | 'true' | 'false';
|
|
130
|
+
/**
|
|
131
|
+
* Required state, forwarded to the input. Field.Control injects this.
|
|
132
|
+
*/
|
|
133
|
+
'aria-required'?: boolean | 'true' | 'false';
|
|
134
|
+
/**
|
|
135
|
+
* Whether to show the clear-all button when values are present.
|
|
136
|
+
* @default true
|
|
137
|
+
*/
|
|
138
|
+
clearable?: boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Class name applied directly to the `<input>` element.
|
|
141
|
+
* Use for utilities like `tui-input-reset` that must target the input itself.
|
|
142
|
+
*/
|
|
143
|
+
inputClassName?: string;
|
|
144
|
+
/**
|
|
145
|
+
* Override default English strings for i18n.
|
|
146
|
+
*/
|
|
147
|
+
labels?: MultiComboboxLabels;
|
|
148
|
+
children: React.ReactNode;
|
|
149
|
+
};
|
|
150
|
+
export type MultiComboboxContentProps = {
|
|
151
|
+
className?: string;
|
|
152
|
+
children: React.ReactNode;
|
|
153
|
+
};
|
|
154
|
+
export type MultiComboboxOptionProps = {
|
|
155
|
+
/**
|
|
156
|
+
* The value for this option. Required and must be unique.
|
|
157
|
+
* Can be string or number.
|
|
158
|
+
*/
|
|
159
|
+
value: OptionValue;
|
|
160
|
+
/**
|
|
161
|
+
* Whether this option is disabled.
|
|
162
|
+
* @default false
|
|
163
|
+
*/
|
|
164
|
+
disabled?: boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Text value used for the chip label when selected.
|
|
167
|
+
* Required when children is not a string.
|
|
168
|
+
* If children is a string, defaults to that.
|
|
169
|
+
*/
|
|
170
|
+
textValue?: string;
|
|
171
|
+
className?: string;
|
|
172
|
+
children: React.ReactNode;
|
|
173
|
+
};
|
|
174
|
+
export type MultiComboboxGroupProps = {
|
|
175
|
+
className?: string;
|
|
176
|
+
children: React.ReactNode;
|
|
177
|
+
};
|
|
178
|
+
export type MultiComboboxLabelProps = {
|
|
179
|
+
className?: string;
|
|
180
|
+
children: React.ReactNode;
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* Registration record for an option.
|
|
184
|
+
*/
|
|
185
|
+
export type RegisteredOption = {
|
|
186
|
+
value: OptionValue;
|
|
187
|
+
ref: RefObject<HTMLElement | null>;
|
|
188
|
+
disabled: boolean;
|
|
189
|
+
textValue: string;
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* Stable context: config, IDs, refs, and stable callbacks.
|
|
193
|
+
*/
|
|
194
|
+
export type MultiComboboxActionsContextValue = {
|
|
195
|
+
disabled: boolean;
|
|
196
|
+
placeholder: string;
|
|
197
|
+
openOnFocus: boolean;
|
|
198
|
+
max: number | undefined;
|
|
199
|
+
inputId: string;
|
|
200
|
+
listboxId: string;
|
|
201
|
+
ariaLabel?: string;
|
|
202
|
+
ariaLabelledBy?: string;
|
|
203
|
+
setOpen: (open: boolean) => void;
|
|
204
|
+
setInputValue: (value: string) => void;
|
|
205
|
+
toggleOption: (value: OptionValue, textValue: string) => void;
|
|
206
|
+
registerOption: (option: RegisteredOption) => void;
|
|
207
|
+
unregisterOption: (value: OptionValue) => void;
|
|
208
|
+
refs: {
|
|
209
|
+
reference: React.RefObject<ReferenceType | null>;
|
|
210
|
+
floating: React.RefObject<HTMLElement | null>;
|
|
211
|
+
setReference: (node: ReferenceType | null) => void;
|
|
212
|
+
setFloating: (node: HTMLElement | null) => void;
|
|
213
|
+
};
|
|
214
|
+
inputRef: RefObject<HTMLInputElement | null>;
|
|
215
|
+
listRef: MutableRefObject<(HTMLElement | null)[]>;
|
|
216
|
+
getReferenceProps: (userProps?: React.HTMLProps<Element>) => Record<string, unknown>;
|
|
217
|
+
getFloatingProps: (userProps?: React.HTMLProps<HTMLElement>) => Record<string, unknown>;
|
|
218
|
+
getItemProps: (userProps?: React.HTMLProps<HTMLElement>) => Record<string, unknown>;
|
|
219
|
+
};
|
|
220
|
+
/**
|
|
221
|
+
* State context: values that change during interaction.
|
|
222
|
+
*/
|
|
223
|
+
export type MultiComboboxStateContextValue = {
|
|
224
|
+
open: boolean;
|
|
225
|
+
value: MultiComboboxValue;
|
|
226
|
+
inputValue: string;
|
|
227
|
+
maxReached: boolean;
|
|
228
|
+
isSelected: (value: OptionValue) => boolean;
|
|
229
|
+
query: string;
|
|
230
|
+
activeIndex: number;
|
|
231
|
+
activeOptionId: string | undefined;
|
|
232
|
+
orderedOptions: RegisteredOption[];
|
|
233
|
+
floatingStyles: CSSProperties;
|
|
234
|
+
floatingContext: FloatingContext;
|
|
235
|
+
};
|
|
236
|
+
/**
|
|
237
|
+
* Combined context value.
|
|
238
|
+
*/
|
|
239
|
+
export type MultiComboboxContextValue = MultiComboboxActionsContextValue & MultiComboboxStateContextValue;
|
|
240
|
+
export type MultiComboboxContentContextValue = {
|
|
241
|
+
listRef: MutableRefObject<(HTMLElement | null)[]>;
|
|
242
|
+
activeIndex: number;
|
|
243
|
+
orderedOptions: RegisteredOption[];
|
|
244
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const defaultMultiComboboxLabels = {
|
|
2
|
+
clear: 'Clear all',
|
|
3
|
+
remove: (label) => `Remove ${label}`,
|
|
4
|
+
status: (count, max) => count === 0
|
|
5
|
+
? '0 items selected'
|
|
6
|
+
: `${count} item${count === 1 ? '' : 's'} selected${max !== undefined && count >= max ? `. Maximum of ${max} reached` : ''}`,
|
|
7
|
+
};
|
|
@@ -5,6 +5,7 @@ import { useFloating, offset, flip, shift, size as sizeMiddleware, autoUpdate, F
|
|
|
5
5
|
import { cx } from '../../utils/cx.js';
|
|
6
6
|
import { getPortalRootFor } from '../../utils/portal.js';
|
|
7
7
|
import { Icon } from '../Icon/index.js';
|
|
8
|
+
import { Chip } from '../Chip/index.js';
|
|
8
9
|
import { MultiSelectActionsContext, MultiSelectStateContext, MultiSelectContentContext, useMultiSelectContext, useMultiSelectContentContext, } from './MultiSelectContext.js';
|
|
9
10
|
import { toKey, defaultMultiSelectLabels, } from './types.js';
|
|
10
11
|
// =============================================================================
|
|
@@ -431,11 +432,25 @@ function MultiSelectTriggerComponent({ asChild = false, className, children, })
|
|
|
431
432
|
return;
|
|
432
433
|
clearAll();
|
|
433
434
|
}, [disabled, clearAll]);
|
|
435
|
+
// Safari doesn't focus buttons on mousedown — focus jumps to <body>, firing
|
|
436
|
+
// a blur that handleBlur reads as focus-loss and closes the menu, so a click
|
|
437
|
+
// on the open trigger closes-then-reopens and never visibly toggles. Focus
|
|
438
|
+
// the trigger ourselves and cancel the browser's focus juggling. Mouse/pen
|
|
439
|
+
// only: cancelling pointerdown on touch swallows the compatibility click.
|
|
440
|
+
const handleTriggerPointerDown = useCallback((e) => {
|
|
441
|
+
if (e.pointerType !== 'mouse' && e.pointerType !== 'pen')
|
|
442
|
+
return;
|
|
443
|
+
if (e.button !== 0)
|
|
444
|
+
return;
|
|
445
|
+
e.preventDefault();
|
|
446
|
+
e.currentTarget.focus();
|
|
447
|
+
}, []);
|
|
434
448
|
// Get Floating UI's reference props
|
|
435
449
|
const floatingProps = getReferenceProps({
|
|
436
450
|
'aria-activedescendant': activeIndex !== null ? `${listboxId}-option-${activeIndex}` : undefined,
|
|
437
451
|
onKeyDown: handleKeyDown,
|
|
438
452
|
onBlur: handleBlur,
|
|
453
|
+
onPointerDown: handleTriggerPointerDown,
|
|
439
454
|
});
|
|
440
455
|
// Render trigger content based on display mode
|
|
441
456
|
const renderTriggerContent = () => {
|
|
@@ -445,10 +460,15 @@ function MultiSelectTriggerComponent({ asChild = false, className, children, })
|
|
|
445
460
|
if (display === 'count') {
|
|
446
461
|
return (_jsx("span", { className: "tui-multiselect__count", children: labels.selected(selectedOptions.length) }));
|
|
447
462
|
}
|
|
448
|
-
// chips mode
|
|
463
|
+
// chips mode — display-only Chips (the shared component, so they read the
|
|
464
|
+
// same as MultiCombobox's token chips). No remove button: MultiSelect
|
|
465
|
+
// manages selection through the dropdown, and a truncated summary (maxChips
|
|
466
|
+
// + "+N more") can't offer a per-chip × for the collapsed items anyway.
|
|
449
467
|
const visibleChips = selectedOptions.slice(0, maxChips);
|
|
450
468
|
const overflow = selectedOptions.length - maxChips;
|
|
451
|
-
|
|
469
|
+
// Chips track the control size, matching MultiCombobox.
|
|
470
|
+
const chipSize = size === 'lg' ? 'md' : size === 'sm' ? 'xs' : 'sm';
|
|
471
|
+
return (_jsxs("span", { className: "tui-multiselect__chips", children: [visibleChips.map((opt) => (_jsx(Chip, { size: chipSize, className: "tui-multiselect__chip", children: opt.textValue }, toKey(opt.value)))), overflow > 0 && (_jsx("span", { className: "tui-multiselect__more", children: labels.more(overflow) }))] }));
|
|
452
472
|
};
|
|
453
473
|
// Default trigger content (when not using asChild or custom children)
|
|
454
474
|
const defaultTriggerContent = (_jsxs(_Fragment, { children: [_jsx("span", { className: "tui-multiselect__value", children: renderTriggerContent() }), hasSelection && (_jsx("span", { className: "tui-multiselect__clear", onClick: handleClearClick, "aria-hidden": "true", children: _jsx(Icon, { name: "system/close" }) })), _jsx(Icon, { name: "system/chevron-down", className: "tui-multiselect__icon", "aria-hidden": "true" })] }));
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { Popover, PopoverTrigger, PopoverContent, usePopover } from './Popover';
|
|
2
|
-
export type { PopoverProps, PopoverTriggerProps, PopoverContentProps, } from './types';
|
|
2
|
+
export type { PopoverProps, PopoverTriggerProps, PopoverContentProps, Side, Align, } from './types';
|
|
@@ -364,11 +364,25 @@ function SelectTriggerComponent({ asChild = false, className, children, }) {
|
|
|
364
364
|
// Return focus to trigger after clearing
|
|
365
365
|
refs.reference.current?.focus();
|
|
366
366
|
}, [disabled, setValue, refs.reference]);
|
|
367
|
+
// Safari doesn't focus buttons on mousedown — focus jumps to <body>, firing
|
|
368
|
+
// a blur that handleBlur reads as focus-loss and closes the menu, so a click
|
|
369
|
+
// on the open trigger closes-then-reopens and never visibly toggles. Focus
|
|
370
|
+
// the trigger ourselves and cancel the browser's focus juggling. Mouse/pen
|
|
371
|
+
// only: cancelling pointerdown on touch swallows the compatibility click.
|
|
372
|
+
const handleTriggerPointerDown = useCallback((e) => {
|
|
373
|
+
if (e.pointerType !== 'mouse' && e.pointerType !== 'pen')
|
|
374
|
+
return;
|
|
375
|
+
if (e.button !== 0)
|
|
376
|
+
return;
|
|
377
|
+
e.preventDefault();
|
|
378
|
+
e.currentTarget.focus();
|
|
379
|
+
}, []);
|
|
367
380
|
// Get Floating UI's reference props - pass our handlers so they get composed
|
|
368
381
|
const floatingProps = getReferenceProps({
|
|
369
382
|
'aria-activedescendant': activeIndex !== null ? `${listboxId}-option-${activeIndex}` : undefined,
|
|
370
383
|
onKeyDown: handleKeyDown,
|
|
371
384
|
onBlur: handleBlur,
|
|
385
|
+
onPointerDown: handleTriggerPointerDown,
|
|
372
386
|
});
|
|
373
387
|
const triggerProps = {
|
|
374
388
|
id: triggerId,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { cx } from '../../utils/cx.js';
|
|
4
|
+
import { useControllableState } from '../../utils/use-controllable-state.js';
|
|
5
|
+
// =============================================================================
|
|
6
|
+
// Slider Component
|
|
7
|
+
// =============================================================================
|
|
8
|
+
//
|
|
9
|
+
// A native <input type="range"> carries all interaction and a11y (keyboard,
|
|
10
|
+
// pointer, form participation, role=slider announcements); the visible track
|
|
11
|
+
// is custom-drawn behind it so it can do what native tracks can't — the
|
|
12
|
+
// segmented pill rhythm and a fill that follows the design system's tokens.
|
|
13
|
+
//
|
|
14
|
+
// The fill layer duplicates the segment row and clips itself to the value's
|
|
15
|
+
// percentage, so fill and rest segments stay perfectly aligned at any width.
|
|
16
|
+
export const Slider = forwardRef(function Slider({ value: controlledValue, defaultValue, min = 0, max = 100, step, onValueChange, segments = 1, startLabel, endLabel, getValueText, disabled = false, id, className, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, }, ref) {
|
|
17
|
+
const [rawValue, setValue] = useControllableState({
|
|
18
|
+
value: controlledValue,
|
|
19
|
+
defaultValue: defaultValue ?? min,
|
|
20
|
+
onChange: onValueChange,
|
|
21
|
+
});
|
|
22
|
+
const value = rawValue ?? min;
|
|
23
|
+
// Segments snap: a segmented track quantises to its boundaries unless an
|
|
24
|
+
// explicit step overrides it.
|
|
25
|
+
const effectiveStep = step ?? (segments > 1 ? (max - min) / segments : 1);
|
|
26
|
+
const fill = max > min ? ((value - min) / (max - min)) * 100 : 0;
|
|
27
|
+
const segmentRow = Array.from({ length: Math.max(1, segments) }, (_, i) => (_jsx("span", { className: "tui-slider__segment" }, i)));
|
|
28
|
+
return (_jsxs("div", { className: cx('tui-slider', disabled && 'is-disabled', className), children: [_jsxs("div", { className: "tui-slider__control", children: [_jsxs("div", { className: "tui-slider__track", "aria-hidden": "true", children: [segmentRow, _jsx("div", { className: "tui-slider__fill", style: { clipPath: `inset(0 ${100 - fill}% 0 0)` }, children: segmentRow })] }), _jsx("input", { ref: ref, type: "range", className: "tui-slider__input", id: id, min: min, max: max, step: effectiveStep, value: value, disabled: disabled, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, "aria-valuetext": getValueText ? getValueText(value) : undefined, onChange: (e) => setValue(Number(e.target.value)) })] }), (startLabel || endLabel) && (_jsxs("div", { className: "tui-slider__labels", children: [_jsx("span", { className: "tui-slider__label", children: startLabel }), _jsx("span", { className: "tui-slider__label", children: endLabel })] }))] }));
|
|
29
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Slider } from './Slider.js';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface SliderProps {
|
|
3
|
+
/** Controlled value. */
|
|
4
|
+
value?: number;
|
|
5
|
+
/** Uncontrolled initial value. Defaults to `min`. */
|
|
6
|
+
defaultValue?: number;
|
|
7
|
+
/** Minimum value. Defaults to 0. */
|
|
8
|
+
min?: number;
|
|
9
|
+
/** Maximum value. Defaults to 100. */
|
|
10
|
+
max?: number;
|
|
11
|
+
/**
|
|
12
|
+
* Step increment. Defaults to 1 — except on a segmented track, where it
|
|
13
|
+
* defaults to the segment span so the value snaps to segment boundaries.
|
|
14
|
+
* Pass an explicit step to override either default.
|
|
15
|
+
*/
|
|
16
|
+
step?: number;
|
|
17
|
+
/** Called with the new value on every change. */
|
|
18
|
+
onValueChange?: (value: number) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Track segmentation: renders the track as this many pill segments with
|
|
21
|
+
* gaps between them, and (unless `step` says otherwise) snaps the value
|
|
22
|
+
* to the segment boundaries. `1` (default) is a continuous track.
|
|
23
|
+
*/
|
|
24
|
+
segments?: number;
|
|
25
|
+
/** Label rendered under the track's start edge (e.g. "Less rounded"). */
|
|
26
|
+
startLabel?: ReactNode;
|
|
27
|
+
/** Label rendered under the track's end edge (e.g. "More rounded"). */
|
|
28
|
+
endLabel?: ReactNode;
|
|
29
|
+
/**
|
|
30
|
+
* Human-readable value for assistive tech (`aria-valuetext`), e.g.
|
|
31
|
+
* `(v) => `${v} pixels``. Without it screen readers announce the number.
|
|
32
|
+
*/
|
|
33
|
+
getValueText?: (value: number) => string;
|
|
34
|
+
disabled?: boolean;
|
|
35
|
+
id?: string;
|
|
36
|
+
className?: string;
|
|
37
|
+
'aria-label'?: string;
|
|
38
|
+
'aria-labelledby'?: string;
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/components/index.d.ts
CHANGED
|
@@ -9,9 +9,11 @@ export { Checkbox } from './Checkbox';
|
|
|
9
9
|
export { Chip } from './Chip';
|
|
10
10
|
export { ChipGroup } from './ChipGroup';
|
|
11
11
|
export { Chips } from './Chips';
|
|
12
|
+
export { ColorPicker, ColorField, ColorArea, ColorSlider, defaultColorPickerLabels } from './ColorPicker';
|
|
12
13
|
export { ContentIndicator } from './ContentIndicator';
|
|
13
14
|
export { Calendar, DatePicker, DateRangePicker, defaultDateRangePresets, defaultCalendarLabels, defaultDatePickerLabels, defaultDateRangePickerLabels, } from './DatePicker';
|
|
14
15
|
export { Combobox, ComboboxContent, ComboboxOption, ComboboxGroup, ComboboxLabel, useCombobox } from './Combobox';
|
|
16
|
+
export { MultiCombobox, MultiComboboxContent, MultiComboboxOption, MultiComboboxGroup, MultiComboboxLabel, useMultiCombobox } from './MultiCombobox';
|
|
15
17
|
export { Dropdown, DropdownTrigger, DropdownContent, DropdownItem, DropdownSeparator, DropdownHeader, useDropdown } from './Dropdown';
|
|
16
18
|
export { Field } from './Field';
|
|
17
19
|
export { MultiSelect, MultiSelectTrigger, MultiSelectContent, MultiSelectOption, MultiSelectGroup, MultiSelectLabel, useMultiSelect } from './MultiSelect';
|
|
@@ -28,6 +30,7 @@ export { Progress } from './Progress';
|
|
|
28
30
|
export { RadioGroup, Radio } from './Radio';
|
|
29
31
|
export { Rating } from './Rating';
|
|
30
32
|
export { SegmentedControl } from './SegmentedControl';
|
|
33
|
+
export { Slider } from './Slider';
|
|
31
34
|
export { Sidebar } from './Sidebar';
|
|
32
35
|
export { StepIndicator } from './StepIndicator';
|
|
33
36
|
export { StepList } from './StepList';
|
|
@@ -46,9 +49,12 @@ export type { CheckboxProps } from './Checkbox';
|
|
|
46
49
|
export type { ChipProps } from './Chip';
|
|
47
50
|
export type { ChipGroupProps, ChipGroupSingleProps, ChipGroupMultipleProps } from './ChipGroup';
|
|
48
51
|
export type { ChipsProps, ChipOption } from './Chips';
|
|
52
|
+
export type { ColorPickerProps, ColorPickerLabels, ColorFieldProps, ColorFieldLabels, ColorAreaProps, ColorSliderProps } from './ColorPicker';
|
|
53
|
+
export type { ColorFormat, Hsva as ColorHsva } from './ColorPicker';
|
|
49
54
|
export type { ContentIndicatorProps } from './ContentIndicator';
|
|
50
55
|
export type { DropdownProps, DropdownTriggerProps, DropdownContentProps, DropdownItemProps, DropdownSeparatorProps, DropdownHeaderProps, } from './Dropdown';
|
|
51
56
|
export type { ComboboxProps, ComboboxContentProps, ComboboxOptionProps, ComboboxGroupProps, ComboboxLabelProps, ComboboxRegisteredOption, } from './Combobox';
|
|
57
|
+
export type { MultiComboboxProps, MultiComboboxContentProps, MultiComboboxOptionProps, MultiComboboxGroupProps, MultiComboboxLabelProps, MultiComboboxLabels, MultiComboboxValue, MultiComboboxFilterMode, MultiComboboxRegisteredOption, } from './MultiCombobox';
|
|
52
58
|
export type { FieldProps } from './Field';
|
|
53
59
|
export type { MultiSelectProps, MultiSelectTriggerProps, MultiSelectContentProps, MultiSelectOptionProps, MultiSelectGroupProps, MultiSelectLabelProps, MultiSelectValue, OptionValue as MultiSelectOptionValue, DisplayMode as MultiSelectDisplayMode, MultiSelectRegisteredOption, } from './MultiSelect';
|
|
54
60
|
export type { SelectProps, SelectTriggerProps, SelectContentProps, SelectOptionProps, SelectGroupProps, SelectLabelProps, } from './Select';
|
package/components/index.js
CHANGED
|
@@ -7,9 +7,11 @@ export { Checkbox } from './Checkbox/index.js';
|
|
|
7
7
|
export { Chip } from './Chip/index.js';
|
|
8
8
|
export { ChipGroup } from './ChipGroup/index.js';
|
|
9
9
|
export { Chips } from './Chips/index.js';
|
|
10
|
+
export { ColorPicker, ColorField, ColorArea, ColorSlider, defaultColorPickerLabels } from './ColorPicker/index.js';
|
|
10
11
|
export { ContentIndicator } from './ContentIndicator/index.js';
|
|
11
12
|
export { Calendar, DatePicker, DateRangePicker, defaultDateRangePresets, defaultCalendarLabels, defaultDatePickerLabels, defaultDateRangePickerLabels, } from './DatePicker/index.js';
|
|
12
13
|
export { Combobox, ComboboxContent, ComboboxOption, ComboboxGroup, ComboboxLabel, useCombobox } from './Combobox/index.js';
|
|
14
|
+
export { MultiCombobox, MultiComboboxContent, MultiComboboxOption, MultiComboboxGroup, MultiComboboxLabel, useMultiCombobox } from './MultiCombobox/index.js';
|
|
13
15
|
export { Dropdown, DropdownTrigger, DropdownContent, DropdownItem, DropdownSeparator, DropdownHeader, useDropdown } from './Dropdown/index.js';
|
|
14
16
|
export { Field } from './Field/index.js';
|
|
15
17
|
export { MultiSelect, MultiSelectTrigger, MultiSelectContent, MultiSelectOption, MultiSelectGroup, MultiSelectLabel, useMultiSelect } from './MultiSelect/index.js';
|
|
@@ -26,6 +28,7 @@ export { Progress } from './Progress/index.js';
|
|
|
26
28
|
export { RadioGroup, Radio } from './Radio/index.js';
|
|
27
29
|
export { Rating } from './Rating/index.js';
|
|
28
30
|
export { SegmentedControl } from './SegmentedControl/index.js';
|
|
31
|
+
export { Slider } from './Slider/index.js';
|
|
29
32
|
export { Sidebar } from './Sidebar/index.js';
|
|
30
33
|
export { StepIndicator } from './StepIndicator/index.js';
|
|
31
34
|
export { StepList } from './StepList/index.js';
|
package/icons/icons.svg
CHANGED
|
@@ -175,6 +175,7 @@
|
|
|
175
175
|
<symbol id="tui-system-download" viewBox="0 0 24 24"><path d="M5.5 9a.5.5 0 0 1 .5-.5h3V7H6a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8.75A1.75 1.75 0 0 0 18.25 7H15v1.5h3.25a.25.25 0 0 1 .25.25V18a.5.5 0 0 1-.5.5H6a.5.5 0 0 1-.5-.5z"/><path d="M12 17.004 7.002 12.56l.996-1.122 3.252 2.89V4h1.5v10.33l3.252-2.89.996 1.12z"/></symbol>
|
|
176
176
|
<symbol id="tui-system-drag" viewBox="0 0 24 24"><path d="M10 5H8v2h2zm0 6H8v2h2zm-2 6h2v2H8zm8-12h-2v2h2zm-2 6h2v2h-2zm2 6h-2v2h2z"/></symbol>
|
|
177
177
|
<symbol id="tui-system-duplicate" viewBox="0 0 24 24"><path d="M14.25 12.75H17v1.5h-2.75V17h-1.5v-2.75H10v-1.5h2.75V10h1.5z"/><path fill-rule="evenodd" d="M17 7h1a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2v-1H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2zm-2-1.5H6a.5.5 0 0 0-.5.5v9a.5.5 0 0 0 .5.5h1V9a2 2 0 0 1 2-2h6.5V6a.5.5 0 0 0-.5-.5m-6 3h9a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5H9a.5.5 0 0 1-.5-.5V9a.5.5 0 0 1 .5-.5" clip-rule="evenodd"/></symbol>
|
|
178
|
+
<symbol id="tui-system-edit-small" viewBox="0 0 24 24"><path fill-rule="evenodd" d="M18.168 9.14 14.924 6l-7.621 7.726L6 18.136l4.527-1.251z" clip-rule="evenodd"/></symbol>
|
|
178
179
|
<symbol id="tui-system-edit" viewBox="0 0 24 24"><path d="M19.864 4.304a2 2 0 0 0-2.733.732l-.635 1.1 3.464 2 .636-1.1a2 2 0 0 0-.732-2.732m-.746 5.292-3.464-2-4.903 8.49.062 3.893 3.402-1.892zM4 5.25h9v1.5H4zm7 4H4v1.5h7zm-7 4h5v1.5H4zm5 4H4v1.5h5z"/></symbol>
|
|
179
180
|
<symbol id="tui-system-ellipsis-h" viewBox="0 0 24 24"><path fill-rule="evenodd" d="M5 11h2v2H5zm6 0h2v2h-2zm6 0h2v2h-2z" clip-rule="evenodd"/></symbol>
|
|
180
181
|
<symbol id="tui-system-ellipsis-v" viewBox="0 0 24 24"><path fill-rule="evenodd" d="M11 19v-2h2v2zm0-6v-2h2v2zm0-6V5h2v2z" clip-rule="evenodd"/></symbol>
|
package/icons/manifest.json
CHANGED
|
@@ -1407,6 +1407,14 @@
|
|
|
1407
1407
|
"viewBox": "0 0 24 24",
|
|
1408
1408
|
"sprite": true
|
|
1409
1409
|
},
|
|
1410
|
+
"system/edit-small": {
|
|
1411
|
+
"id": "tui-system-edit-small",
|
|
1412
|
+
"set": "system",
|
|
1413
|
+
"name": "edit-small",
|
|
1414
|
+
"file": "system/edit-small.svg",
|
|
1415
|
+
"viewBox": "0 0 24 24",
|
|
1416
|
+
"sprite": true
|
|
1417
|
+
},
|
|
1410
1418
|
"system/edit": {
|
|
1411
1419
|
"id": "tui-system-edit",
|
|
1412
1420
|
"set": "system",
|
package/icons/registry.d.ts
CHANGED
|
@@ -179,6 +179,7 @@ export type IconName =
|
|
|
179
179
|
| 'system/download'
|
|
180
180
|
| 'system/drag'
|
|
181
181
|
| 'system/duplicate'
|
|
182
|
+
| 'system/edit-small'
|
|
182
183
|
| 'system/edit'
|
|
183
184
|
| 'system/ellipsis-h'
|
|
184
185
|
| 'system/ellipsis-v'
|
|
@@ -407,6 +408,7 @@ export declare const iconRegistry: {
|
|
|
407
408
|
'system/download': IconComponent;
|
|
408
409
|
'system/drag': IconComponent;
|
|
409
410
|
'system/duplicate': IconComponent;
|
|
411
|
+
'system/edit-small': IconComponent;
|
|
410
412
|
'system/edit': IconComponent;
|
|
411
413
|
'system/ellipsis-h': IconComponent;
|
|
412
414
|
'system/ellipsis-v': IconComponent;
|
package/icons/registry.js
CHANGED
|
@@ -182,6 +182,7 @@ export const iconRegistry = {
|
|
|
182
182
|
'system/download': systemIcons['download'],
|
|
183
183
|
'system/drag': systemIcons['drag'],
|
|
184
184
|
'system/duplicate': systemIcons['duplicate'],
|
|
185
|
+
'system/edit-small': systemIcons['edit-small'],
|
|
185
186
|
'system/edit': systemIcons['edit'],
|
|
186
187
|
'system/ellipsis-h': systemIcons['ellipsis-h'],
|
|
187
188
|
'system/ellipsis-v': systemIcons['ellipsis-v'],
|
package/icons/system/index.d.ts
CHANGED
|
@@ -46,6 +46,7 @@ export declare const CustomFunction: IconComponent;
|
|
|
46
46
|
export declare const Download: IconComponent;
|
|
47
47
|
export declare const Drag: IconComponent;
|
|
48
48
|
export declare const Duplicate: IconComponent;
|
|
49
|
+
export declare const EditSmall: IconComponent;
|
|
49
50
|
export declare const Edit: IconComponent;
|
|
50
51
|
export declare const EllipsisH: IconComponent;
|
|
51
52
|
export declare const EllipsisV: IconComponent;
|
|
@@ -142,6 +143,7 @@ export declare const systemIcons: {
|
|
|
142
143
|
'download': IconComponent;
|
|
143
144
|
'drag': IconComponent;
|
|
144
145
|
'duplicate': IconComponent;
|
|
146
|
+
'edit-small': IconComponent;
|
|
145
147
|
'edit': IconComponent;
|
|
146
148
|
'ellipsis-h': IconComponent;
|
|
147
149
|
'ellipsis-v': IconComponent;
|
package/icons/system/index.js
CHANGED
|
@@ -440,6 +440,16 @@ export function Duplicate(props) {
|
|
|
440
440
|
}, props), [_c("path", {d:"M14.25 12.75H17v1.5h-2.75V17h-1.5v-2.75H10v-1.5h2.75V10h1.5z"}), _c("path", {fillRule:"evenodd",d:"M17 7h1a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2v-1H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2zm-2-1.5H6a.5.5 0 0 0-.5.5v9a.5.5 0 0 0 .5.5h1V9a2 2 0 0 1 2-2h6.5V6a.5.5 0 0 0-.5-.5m-6 3h9a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5H9a.5.5 0 0 1-.5-.5V9a.5.5 0 0 1 .5-.5",clipRule:"evenodd"})]);
|
|
441
441
|
}
|
|
442
442
|
|
|
443
|
+
export function EditSmall(props) {
|
|
444
|
+
return _c("svg", Object.assign({
|
|
445
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
446
|
+
viewBox: "0 0 24 24",
|
|
447
|
+
width: "1em",
|
|
448
|
+
height: "1em",
|
|
449
|
+
fill: "currentColor"
|
|
450
|
+
}, props), _c("path", {fillRule:"evenodd",d:"M18.168 9.14 14.924 6l-7.621 7.726L6 18.136l4.527-1.251z",clipRule:"evenodd"}));
|
|
451
|
+
}
|
|
452
|
+
|
|
443
453
|
export function Edit(props) {
|
|
444
454
|
return _c("svg", Object.assign({
|
|
445
455
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -985,6 +995,7 @@ export const systemIcons = {
|
|
|
985
995
|
'download': Download,
|
|
986
996
|
'drag': Drag,
|
|
987
997
|
'duplicate': Duplicate,
|
|
998
|
+
'edit-small': EditSmall,
|
|
988
999
|
'edit': Edit,
|
|
989
1000
|
'ellipsis-h': EllipsisH,
|
|
990
1001
|
'ellipsis-v': EllipsisV,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangible/ui",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Tangible Design System",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./components/index.js",
|
|
@@ -80,6 +80,10 @@
|
|
|
80
80
|
"import": "./components/Chips/index.js",
|
|
81
81
|
"types": "./components/Chips/index.d.ts"
|
|
82
82
|
},
|
|
83
|
+
"./components/ColorPicker": {
|
|
84
|
+
"import": "./components/ColorPicker/index.js",
|
|
85
|
+
"types": "./components/ColorPicker/index.d.ts"
|
|
86
|
+
},
|
|
83
87
|
"./components/Combobox": {
|
|
84
88
|
"import": "./components/Combobox/index.js",
|
|
85
89
|
"types": "./components/Combobox/index.d.ts"
|
|
@@ -116,6 +120,10 @@
|
|
|
116
120
|
"import": "./components/MoveHandle/index.js",
|
|
117
121
|
"types": "./components/MoveHandle/index.d.ts"
|
|
118
122
|
},
|
|
123
|
+
"./components/MultiCombobox": {
|
|
124
|
+
"import": "./components/MultiCombobox/index.js",
|
|
125
|
+
"types": "./components/MultiCombobox/index.d.ts"
|
|
126
|
+
},
|
|
119
127
|
"./components/MultiSelect": {
|
|
120
128
|
"import": "./components/MultiSelect/index.js",
|
|
121
129
|
"types": "./components/MultiSelect/index.d.ts"
|
|
@@ -160,6 +168,10 @@
|
|
|
160
168
|
"import": "./components/Sidebar/index.js",
|
|
161
169
|
"types": "./components/Sidebar/index.d.ts"
|
|
162
170
|
},
|
|
171
|
+
"./components/Slider": {
|
|
172
|
+
"import": "./components/Slider/index.js",
|
|
173
|
+
"types": "./components/Slider/index.d.ts"
|
|
174
|
+
},
|
|
163
175
|
"./components/StepIndicator": {
|
|
164
176
|
"import": "./components/StepIndicator/index.js",
|
|
165
177
|
"types": "./components/StepIndicator/index.d.ts"
|