@tangible/ui 0.2.3 → 0.2.5

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.
Files changed (52) hide show
  1. package/components/ColorPicker/ColorField.d.ts +31 -2
  2. package/components/ColorPicker/ColorField.js +100 -8
  3. package/components/Combobox/Combobox.d.ts +1 -1
  4. package/components/Combobox/Combobox.js +2 -2
  5. package/components/Combobox/types.d.ts +5 -0
  6. package/components/Field/Field.d.ts +13 -1
  7. package/components/Field/Field.js +5 -3
  8. package/components/GradientPicker/AngleDial.d.ts +14 -0
  9. package/components/GradientPicker/AngleDial.js +24 -0
  10. package/components/GradientPicker/GradientBar.d.ts +38 -0
  11. package/components/GradientPicker/GradientBar.js +130 -0
  12. package/components/GradientPicker/GradientPicker.d.ts +32 -0
  13. package/components/GradientPicker/GradientPicker.js +191 -0
  14. package/components/GradientPicker/index.d.ts +8 -0
  15. package/components/GradientPicker/index.js +8 -0
  16. package/components/GradientPicker/labels.d.ts +42 -0
  17. package/components/GradientPicker/labels.js +31 -0
  18. package/components/MultiCombobox/MultiCombobox.d.ts +1 -1
  19. package/components/MultiCombobox/MultiCombobox.js +2 -2
  20. package/components/MultiCombobox/types.d.ts +5 -0
  21. package/components/Pager/Pager.d.ts +8 -1
  22. package/components/Pager/Pager.js +10 -6
  23. package/components/SearchInput/SearchInput.d.ts +11 -0
  24. package/components/SearchInput/SearchInput.js +76 -0
  25. package/components/SearchInput/index.d.ts +2 -0
  26. package/components/SearchInput/index.js +1 -0
  27. package/components/SearchInput/types.d.ts +69 -0
  28. package/components/SearchInput/types.js +1 -0
  29. package/components/index.d.ts +4 -0
  30. package/components/index.js +2 -0
  31. package/icons/icons.svg +16 -16
  32. package/icons/lms/index.js +13 -13
  33. package/icons/system/index.js +3 -3
  34. package/package.json +9 -1
  35. package/styles/all.css +1 -1
  36. package/styles/all.expanded.css +332 -19
  37. package/styles/all.expanded.unlayered.css +332 -19
  38. package/styles/all.unlayered.css +1 -1
  39. package/styles/components/_bundle.scss +11 -1
  40. package/styles/components/button.scss +4 -3
  41. package/styles/components/card.scss +21 -0
  42. package/styles/components/color-picker.scss +18 -2
  43. package/styles/components/dropdown.scss +1 -0
  44. package/styles/components/gradient-picker.scss +296 -0
  45. package/styles/components/icon-button.scss +15 -8
  46. package/styles/components/pager.scss +11 -5
  47. package/styles/components/search-input.scss +104 -0
  48. package/styles/system/_checkerboard.scss +24 -0
  49. package/styles/system/index.scss +2 -1
  50. package/tui-manifest.json +199 -5
  51. package/utils/color/gradient.d.ts +42 -0
  52. package/utils/color/gradient.js +408 -0
@@ -0,0 +1,191 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useId, useRef, useState } from 'react';
3
+ import { cx } from '../../utils/cx.js';
4
+ import { Button } from '../Button/index.js';
5
+ import { IconButton } from '../IconButton/index.js';
6
+ import { Popover } from '../Popover/index.js';
7
+ import { Select } from '../Select/index.js';
8
+ import { TextInput } from '../TextInput/index.js';
9
+ import { Tooltip } from '../Tooltip/index.js';
10
+ import { ColorPicker } from '../ColorPicker/index.js';
11
+ import { parseGradient, formatGradient, reverseStops, colorAtPosition, DEFAULT_GRADIENT, GRADIENT_TYPES, } from '../../utils/color/gradient.js';
12
+ import { GradientBar } from './GradientBar.js';
13
+ import { AngleDial } from './AngleDial.js';
14
+ import { resolveGradientLabels } from './labels.js';
15
+ const round1 = (n) => Math.round(n * 10) / 10;
16
+ const clampN = (n, min, max) => Math.min(max, Math.max(min, n));
17
+ // -----------------------------------------------------------------------------
18
+ // NumberField — a compact labelled numeric input (spinbutton semantics), used
19
+ // for stop positions and the gradient geometry (angle / size / position).
20
+ // -----------------------------------------------------------------------------
21
+ function NumberField({ label, hideLabel, value, min, max, suffix, disabled, onCommit, className, }) {
22
+ const id = useId();
23
+ // A local draft only while typing, so the round-trip through the gradient
24
+ // string doesn't clobber partial input. Cleared on blur → canonical value.
25
+ const [draft, setDraft] = useState(null);
26
+ const display = draft ?? String(round1(value));
27
+ const commit = (raw) => onCommit(clampN(raw, min, max));
28
+ // Live-commit ONLY values already inside [min, max]. Clamping intermediate
29
+ // keystrokes would be destructive with dynamic bounds: typing "6" on the way
30
+ // to "65" between neighbours at 50 and 70 would collapse the stop onto 50.
31
+ // Out-of-range drafts stay drafts until blur, which clamp-commits.
32
+ const commitLive = (raw) => {
33
+ if (raw >= min && raw <= max)
34
+ onCommit(raw);
35
+ };
36
+ return (_jsxs("span", { className: cx('tui-gradient-picker__field', className), children: [!hideLabel && (_jsx("label", { className: "tui-gradient-picker__label", htmlFor: id, children: label })), _jsx(TextInput, { id: id, size: "sm", inputMode: "decimal", autoComplete: "off", spellCheck: false, value: display, suffix: suffix, disabled: disabled, role: "spinbutton", "aria-label": hideLabel ? label : undefined, "aria-valuenow": round1(value), "aria-valuetext": `${round1(value)}${suffix ?? ''}`, "aria-valuemin": min, "aria-valuemax": max, onChange: (e) => {
37
+ const text = e.target.value;
38
+ setDraft(text);
39
+ const num = parseFloat(text);
40
+ if (!Number.isNaN(num))
41
+ commitLive(num);
42
+ }, onBlur: () => {
43
+ if (draft != null) {
44
+ const num = parseFloat(draft);
45
+ if (!Number.isNaN(num))
46
+ commit(num);
47
+ }
48
+ setDraft(null);
49
+ }, onKeyDown: (e) => {
50
+ if (e.key !== 'ArrowUp' && e.key !== 'ArrowDown')
51
+ return;
52
+ e.preventDefault();
53
+ const delta = (e.shiftKey ? 10 : 1) * (e.key === 'ArrowUp' ? 1 : -1);
54
+ const base = parseFloat(draft ?? String(value));
55
+ const num = clampN((Number.isNaN(base) ? 0 : base) + delta, min, max);
56
+ setDraft(String(round1(num)));
57
+ commit(num);
58
+ } })] }));
59
+ }
60
+ /**
61
+ * Gradient picker: a stop strip with draggable thumbs, an editable CSS value
62
+ * field, a fully accessible colour-stop list (each stop opens a {@link
63
+ * ColorPicker} in a popover), and per-type geometry controls (linear angle +
64
+ * dial, radial size/position, conic position).
65
+ *
66
+ * The value contract is a CSS gradient string — `linear-gradient(…)`,
67
+ * `radial-gradient(…)` or `conic-gradient(…)` — accepted (pasted or typed)
68
+ * and emitted. Stops keep whatever colour strings the ColorPicker accepts,
69
+ * including `var(--x)` references. An unparseable value falls back to a
70
+ * default gradient in the controls; committing any edit replaces it.
71
+ */
72
+ export function GradientPicker({ value: controlledValue, defaultValue = formatGradient(DEFAULT_GRADIENT), onValueChange, alpha = true, formats, disabled, labels, 'aria-label': ariaLabel, className, ...rest }) {
73
+ const L = resolveGradientLabels(labels);
74
+ const isControlled = useRef(controlledValue !== undefined).current;
75
+ const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue);
76
+ const value = isControlled ? controlledValue ?? '' : uncontrolledValue;
77
+ const parsed = parseGradient(value);
78
+ const gradient = parsed.kind === 'gradient' ? parsed.gradient : DEFAULT_GRADIENT;
79
+ const { stops } = gradient;
80
+ // Which stop's colour editor popover is open (also the bar's highlight).
81
+ const [openStop, setOpenStop] = useState(null);
82
+ // Focus recovery for row removals: the focused remove button unmounts, so
83
+ // focus the surviving neighbour's remove button (or the add button when the
84
+ // remaining rows can't be removed).
85
+ // HTMLElement because Button/IconButton forward a button/anchor union ref.
86
+ const removeRefs = useRef([]);
87
+ const addRef = useRef(null);
88
+ const pendingRowFocus = useRef(null);
89
+ const prevStopCount = useRef(stops.length);
90
+ useEffect(() => {
91
+ // Consume only on an actual decrease — a controlled parent may drop the
92
+ // update, and a stale ref must not steal focus on a later stop-add.
93
+ const decreased = stops.length < prevStopCount.current;
94
+ prevStopCount.current = stops.length;
95
+ const target = pendingRowFocus.current;
96
+ pendingRowFocus.current = null;
97
+ if (!decreased || target == null)
98
+ return;
99
+ const index = Math.min(target, stops.length - 1);
100
+ const button = removeRefs.current[index];
101
+ if (button instanceof HTMLButtonElement && !button.disabled)
102
+ button.focus();
103
+ else
104
+ addRef.current?.focus();
105
+ }, [stops.length]);
106
+ const commit = useCallback((next) => {
107
+ const nextValue = formatGradient(next);
108
+ if (!isControlled)
109
+ setUncontrolledValue(nextValue);
110
+ onValueChange?.(nextValue);
111
+ }, [isControlled, onValueChange]);
112
+ const patch = (partial) => commit({ ...gradient, ...partial });
113
+ // Stops stay sorted by position at all times (indices are stable for the
114
+ // bar, the list, and assistive tech). Dragging clamps at the neighbours
115
+ // instead of crossing them.
116
+ const clampStopPosition = (index, position) => clampN(position, stops[index - 1]?.position ?? 0, stops[index + 1]?.position ?? 100);
117
+ const updateStop = (index, partial) => patch({ stops: stops.map((s, i) => (i === index ? { ...s, ...partial } : s)) });
118
+ const moveStop = (index, position) => updateStop(index, { position: round1(clampStopPosition(index, position)) });
119
+ /** Insert a stop at `position` (default: the middle of the largest gap). */
120
+ const addStop = (position) => {
121
+ let at = position;
122
+ if (at == null) {
123
+ let gapStart = 0;
124
+ let gapSize = -1;
125
+ for (let i = 0; i <= stops.length; i++) {
126
+ const from = i === 0 ? 0 : stops[i - 1].position;
127
+ const to = i === stops.length ? 100 : stops[i].position;
128
+ if (to - from > gapSize) {
129
+ gapSize = to - from;
130
+ gapStart = from;
131
+ }
132
+ }
133
+ at = gapStart + gapSize / 2;
134
+ }
135
+ at = round1(clampN(at, 0, 100));
136
+ const stop = { color: colorAtPosition(stops, at), position: at };
137
+ const index = stops.findIndex((s) => s.position > at);
138
+ const insertAt = index === -1 ? stops.length : index;
139
+ patch({ stops: [...stops.slice(0, insertAt), stop, ...stops.slice(insertAt)] });
140
+ setOpenStop(null);
141
+ };
142
+ const removeStop = (index, recoverFocus = false) => {
143
+ if (stops.length <= 2)
144
+ return;
145
+ if (recoverFocus)
146
+ pendingRowFocus.current = index > 0 ? index - 1 : 0;
147
+ if (openStop != null && openStop >= index)
148
+ setOpenStop(null);
149
+ patch({ stops: stops.filter((_, i) => i !== index) });
150
+ };
151
+ // Editable value field: local draft, parsed on commit, reverted if invalid.
152
+ const [draft, setDraft] = useState(null);
153
+ const emitted = formatGradient(gradient);
154
+ const fieldText = draft ?? emitted;
155
+ const commitText = () => {
156
+ if (draft == null)
157
+ return;
158
+ const p = parseGradient(draft.trim());
159
+ if (p.kind === 'gradient')
160
+ commit(p.gradient);
161
+ // invalid → revert (drop the draft)
162
+ setDraft(null);
163
+ };
164
+ // Transient "Copied" confirmation (tooltip label + SR live announcement).
165
+ const [copied, setCopied] = useState(false);
166
+ const copyTimer = useRef(null);
167
+ useEffect(() => () => void (copyTimer.current && clearTimeout(copyTimer.current)), []);
168
+ const handleCopy = () => {
169
+ navigator.clipboard?.writeText(emitted);
170
+ setCopied(true);
171
+ if (copyTimer.current)
172
+ clearTimeout(copyTimer.current);
173
+ copyTimer.current = setTimeout(() => setCopied(false), 1200);
174
+ };
175
+ const typeLabelId = useId();
176
+ return (_jsxs("div", { className: cx('tui-gradient-picker', disabled && 'is-disabled', className), role: "group", "aria-label": ariaLabel ?? L.group, ...rest, children: [_jsx(GradientBar, { stops: stops, activeIndex: openStop, onStopPositionChange: moveStop, onStopAdd: (position) => addStop(position), onStopRemove: (index) => removeStop(index), onStopActivate: (index) => setOpenStop(index), labels: { stop: L.stop, stopValueText: L.stopValueText }, disabled: disabled, "aria-label": L.bar }), _jsxs("div", { className: "tui-gradient-picker__value", children: [_jsx("input", { className: "tui-gradient-picker__value-input", type: "text", autoComplete: "off", spellCheck: false, value: fieldText, onChange: (e) => setDraft(e.target.value), onBlur: commitText, onKeyDown: (e) => {
177
+ if (e.key === 'Enter')
178
+ commitText();
179
+ }, "aria-label": L.value, disabled: disabled }), _jsxs(Tooltip, { children: [_jsx(Tooltip.Trigger, { asChild: true, children: _jsx(IconButton, { icon: "system/reverse", label: L.reverse, variant: "ghost", size: "sm", disabled: disabled, onClick: () => {
180
+ // An open editor's index would silently point at the mirrored
181
+ // stop after the reorder — close it instead.
182
+ setOpenStop(null);
183
+ patch({ stops: reverseStops(stops) });
184
+ } }) }), _jsx(Tooltip.Content, { children: L.reverse })] }), _jsxs(Tooltip, { children: [_jsx(Tooltip.Trigger, { asChild: true, children: _jsx(IconButton, { icon: "system/copy", label: L.copy, variant: "ghost", size: "sm", disabled: disabled, onClick: handleCopy }) }), _jsx(Tooltip.Content, { children: copied ? L.copied : L.copy })] })] }), _jsxs("div", { className: "tui-gradient-picker__stops", children: [_jsx("span", { className: "tui-gradient-picker__label", children: L.stopsHeading }), stops.map((stop, i) => (_jsxs("div", { className: "tui-gradient-picker__stop", children: [_jsxs(Popover, { open: openStop === i, onOpenChange: (open) => setOpenStop(open ? i : null), children: [_jsx(Popover.Trigger, { asChild: true, children: _jsx("button", { type: "button", className: "tui-gradient-picker__swatch", "aria-label": L.editStop(i + 1), disabled: disabled, children: _jsx("span", { className: "tui-gradient-picker__swatch-fill", "aria-hidden": "true", style: { '--_swatch': stop.color } }) }) }), _jsx(Popover.Content, { side: "bottom", align: "start", modal: true, "aria-label": L.editStop(i + 1), className: "tui-gradient-picker__stop-popover", children: _jsx(ColorPicker, { value: stop.color, onValueChange: (color) => updateStop(i, { color }), alpha: alpha, formats: formats }) })] }), _jsx(NumberField, { label: L.stopPosition(i + 1), hideLabel: true, value: stop.position, min: stops[i - 1]?.position ?? 0, max: stops[i + 1]?.position ?? 100, suffix: "%", disabled: disabled, onCommit: (position) => updateStop(i, { position: round1(position) }), className: "tui-gradient-picker__stop-position" }), _jsx(IconButton, { ref: (el) => {
185
+ removeRefs.current[i] = el;
186
+ }, icon: "system/trash", label: L.removeStop(i + 1), variant: "ghost", theme: "danger", size: "sm", disabled: disabled || stops.length <= 2, onClick: () => removeStop(i, true) })] }, i))), _jsx(Button, { ref: (el) => {
187
+ addRef.current = el;
188
+ }, variant: "outline", size: "sm", disabled: disabled, onClick: () => addStop(), className: "tui-gradient-picker__add", children: L.addStop })] }), _jsxs("div", { className: cx('tui-gradient-picker__geometry', gradient.type === 'linear' && 'is-linear'), children: [_jsxs("span", { className: "tui-gradient-picker__field tui-gradient-picker__type-field", children: [_jsx("span", { className: "tui-gradient-picker__label", id: typeLabelId, children: L.type }), _jsxs(Select, { value: gradient.type, onValueChange: (t) => patch({ type: t }), disabled: disabled, size: "sm", "aria-labelledby": typeLabelId, children: [_jsx(Select.Trigger, { className: "tui-gradient-picker__type" }), _jsx(Select.Content, { children: GRADIENT_TYPES.map((t) => (_jsx(Select.Option, { value: t, children: L.types[t] }, t))) })] })] }), gradient.type === 'linear' && (_jsxs("span", { className: "tui-gradient-picker__angle", children: [_jsx(NumberField, { label: L.angle, value: gradient.angle, min: 0, max: 360, suffix: "\u00B0", disabled: disabled,
189
+ // mod 360 so a committed 360 doesn't flip to 0 on blur.
190
+ onCommit: (angle) => patch({ angle: round1(angle) % 360 }) }), _jsx(AngleDial, { angle: gradient.angle, onAngleChange: (angle) => patch({ angle }), disabled: disabled })] })), gradient.type === 'radial' && (_jsxs(_Fragment, { children: [_jsx(NumberField, { label: L.sizeX, value: gradient.sizeX, min: 0, max: 1000, suffix: "%", disabled: disabled, onCommit: (sizeX) => patch({ sizeX: round1(sizeX) }) }), _jsx(NumberField, { label: L.sizeY, value: gradient.sizeY, min: 0, max: 1000, suffix: "%", disabled: disabled, onCommit: (sizeY) => patch({ sizeY: round1(sizeY) }) })] })), (gradient.type === 'radial' || gradient.type === 'conic') && (_jsxs(_Fragment, { children: [_jsx(NumberField, { label: L.posX, value: gradient.posX, min: 0, max: 100, suffix: "%", disabled: disabled, onCommit: (posX) => patch({ posX: round1(posX) }) }), _jsx(NumberField, { label: L.posY, value: gradient.posY, min: 0, max: 100, suffix: "%", disabled: disabled, onCommit: (posY) => patch({ posY: round1(posY) }) })] }))] }), _jsx("span", { className: "tui-visually-hidden", role: "status", "aria-live": "polite", children: copied ? L.copied : '' })] }));
191
+ }
@@ -0,0 +1,8 @@
1
+ export { GradientPicker } from './GradientPicker';
2
+ export type { GradientPickerProps } from './GradientPicker';
3
+ export { GradientBar } from './GradientBar';
4
+ export type { GradientBarProps, GradientBarLabels } from './GradientBar';
5
+ export { defaultGradientPickerLabels } from './labels';
6
+ export type { GradientPickerLabels } from './labels';
7
+ export { parseGradient, formatGradient, formatStops, reverseStops, colorAtPosition, DEFAULT_GRADIENT, GRADIENT_TYPES, } from '../../utils/color/gradient';
8
+ export type { Gradient, GradientType, GradientStop, ParsedGradient, } from '../../utils/color/gradient';
@@ -0,0 +1,8 @@
1
+ export { GradientPicker } from './GradientPicker.js';
2
+ export { GradientBar } from './GradientBar.js';
3
+ // AngleDial is deliberately NOT exported: it is aria-hidden and pointer-only
4
+ // by design — usable only beside an accessible input editing the same value,
5
+ // which GradientPicker provides. Standalone use would ship an inaccessible
6
+ // control.
7
+ export { defaultGradientPickerLabels } from './labels.js';
8
+ export { parseGradient, formatGradient, formatStops, reverseStops, colorAtPosition, DEFAULT_GRADIENT, GRADIENT_TYPES, } from '../../utils/color/gradient.js';
@@ -0,0 +1,42 @@
1
+ import type { GradientType } from '../../utils/color/gradient';
2
+ export type GradientPickerLabels = {
3
+ /** Accessible name for the whole picker group. */
4
+ group?: string;
5
+ /** Accessible name for the stop strip. */
6
+ bar?: string;
7
+ /** Accessible name for a stop thumb on the strip. */
8
+ stop?: (index: number, total: number, color: string) => string;
9
+ /** Value text for a stop thumb's position. */
10
+ stopValueText?: (percent: number) => string;
11
+ /** Accessible name for the gradient value text field. */
12
+ value?: string;
13
+ /** Copy button label + idle tooltip. */
14
+ copy?: string;
15
+ /** Tooltip + SR announcement shown briefly after a successful copy. */
16
+ copied?: string;
17
+ /** Reverse button label + tooltip. */
18
+ reverse?: string;
19
+ /** Visible heading of the stop list. */
20
+ stopsHeading?: string;
21
+ /** The add-stop button's text. */
22
+ addStop?: string;
23
+ /** Accessible name for a stop row's swatch (opens the colour editor). */
24
+ editStop?: (index: number) => string;
25
+ /** Accessible name for a stop row's position input. */
26
+ stopPosition?: (index: number) => string;
27
+ /** Accessible name for a stop row's remove button. */
28
+ removeStop?: (index: number) => string;
29
+ /** Visible label of the gradient type selector. */
30
+ type?: string;
31
+ /** Display names per gradient type. */
32
+ types?: Partial<Record<GradientType, string>>;
33
+ /** Visible labels of the geometry fields. */
34
+ angle?: string;
35
+ sizeX?: string;
36
+ sizeY?: string;
37
+ posX?: string;
38
+ posY?: string;
39
+ };
40
+ export declare const defaultGradientPickerLabels: Required<GradientPickerLabels>;
41
+ /** Merge consumer overrides over the defaults (shallow, plus the nested map). */
42
+ export declare function resolveGradientLabels(labels?: GradientPickerLabels): Required<GradientPickerLabels>;
@@ -0,0 +1,31 @@
1
+ export const defaultGradientPickerLabels = {
2
+ group: 'Gradient picker',
3
+ bar: 'Gradient stops',
4
+ stop: (index, total, color) => `Color stop ${index + 1} of ${total}: ${color}`,
5
+ stopValueText: (percent) => `${percent}%`,
6
+ value: 'Gradient value',
7
+ copy: 'Copy gradient value',
8
+ copied: 'Copied',
9
+ reverse: 'Reverse gradient',
10
+ stopsHeading: 'Color stops',
11
+ addStop: 'Add color stop',
12
+ editStop: (index) => `Edit color stop ${index}`,
13
+ stopPosition: (index) => `Position of color stop ${index}`,
14
+ removeStop: (index) => `Remove color stop ${index}`,
15
+ type: 'Type',
16
+ types: { linear: 'Linear', radial: 'Radial', conic: 'Conic' },
17
+ angle: 'Angle',
18
+ sizeX: 'Shape size X',
19
+ sizeY: 'Shape size Y',
20
+ posX: 'Shape position X',
21
+ posY: 'Shape position Y',
22
+ };
23
+ /** Merge consumer overrides over the defaults (shallow, plus the nested map). */
24
+ export function resolveGradientLabels(labels) {
25
+ const d = defaultGradientPickerLabels;
26
+ return {
27
+ ...d,
28
+ ...labels,
29
+ types: { ...d.types, ...labels?.types },
30
+ };
31
+ }
@@ -1,5 +1,5 @@
1
1
  import type { MultiComboboxProps, MultiComboboxContentProps, MultiComboboxOptionProps, MultiComboboxGroupProps, MultiComboboxLabelProps } from './types';
2
- declare function MultiComboboxRoot({ value: controlledValue, defaultValue, onValueChange, inputValue: controlledInputValue, onInputChange, open: controlledOpen, defaultOpen, onOpenChange, disabled, placeholder, size, overflow, openOnFocus, filterMode, onQueryChange, max, onMaxReached, clearable, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, 'aria-describedby': ariaDescribedBy, 'aria-invalid': ariaInvalid, 'aria-required': ariaRequired, inputClassName, labels: labelsProp, children, }: MultiComboboxProps): import("react/jsx-runtime").JSX.Element;
2
+ declare function MultiComboboxRoot({ value: controlledValue, defaultValue, onValueChange, inputValue: controlledInputValue, onInputChange, open: controlledOpen, defaultOpen, onOpenChange, disabled, placeholder, size, overflow, openOnFocus, filterMode, onQueryChange, max, onMaxReached, clearable, 'aria-label': ariaLabel, id: inputIdProp, 'aria-labelledby': ariaLabelledBy, 'aria-describedby': ariaDescribedBy, 'aria-invalid': ariaInvalid, 'aria-required': ariaRequired, inputClassName, labels: labelsProp, children, }: MultiComboboxProps): import("react/jsx-runtime").JSX.Element;
3
3
  declare namespace MultiComboboxRoot {
4
4
  var displayName: string;
5
5
  }
@@ -17,7 +17,7 @@ const EMPTY_VALUE = [];
17
17
  // =============================================================================
18
18
  // MultiCombobox Root
19
19
  // =============================================================================
20
- function MultiComboboxRoot({ value: controlledValue, defaultValue, onValueChange, inputValue: controlledInputValue, onInputChange, open: controlledOpen, defaultOpen, onOpenChange, disabled = false, placeholder = '', size = 'md', overflow = 'trim', openOnFocus = true, filterMode = 'always', onQueryChange, max, onMaxReached, clearable = true, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, 'aria-describedby': ariaDescribedBy, 'aria-invalid': ariaInvalid, 'aria-required': ariaRequired, inputClassName, labels: labelsProp, children, }) {
20
+ function MultiComboboxRoot({ value: controlledValue, defaultValue, onValueChange, inputValue: controlledInputValue, onInputChange, open: controlledOpen, defaultOpen, onOpenChange, disabled = false, placeholder = '', size = 'md', overflow = 'trim', openOnFocus = true, filterMode = 'always', onQueryChange, max, onMaxReached, clearable = true, 'aria-label': ariaLabel, id: inputIdProp, 'aria-labelledby': ariaLabelledBy, 'aria-describedby': ariaDescribedBy, 'aria-invalid': ariaInvalid, 'aria-required': ariaRequired, inputClassName, labels: labelsProp, children, }) {
21
21
  const labels = { ...defaultMultiComboboxLabels, ...labelsProp };
22
22
  // Controlled/uncontrolled value (initialize from defaultValue)
23
23
  const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue ?? []);
@@ -58,7 +58,7 @@ function MultiComboboxRoot({ value: controlledValue, defaultValue, onValueChange
58
58
  openRef.current = open;
59
59
  // IDs
60
60
  const baseId = useId();
61
- const inputId = `${baseId}-input`;
61
+ const inputId = inputIdProp ?? `${baseId}-input`;
62
62
  const listboxId = `${baseId}-listbox`;
63
63
  // Refs
64
64
  const inputRef = useRef(null);
@@ -110,6 +110,11 @@ export type MultiComboboxProps = {
110
110
  * Callback when max selections is reached.
111
111
  */
112
112
  onMaxReached?: () => void;
113
+ /**
114
+ * Optional input ID override, applied to the inner `<input>`.
115
+ * Useful for Field integration via htmlFor — Field.Control injects this.
116
+ */
117
+ id?: string;
113
118
  /**
114
119
  * Accessible name for the combobox.
115
120
  */
@@ -1,3 +1,4 @@
1
+ import type { SizeStandard } from '../../types/sizes';
1
2
  import { type PagerLabels } from './types';
2
3
  export type PagerMode = 'simple' | 'ends' | 'full' | 'smart';
3
4
  export type PagerProps = {
@@ -13,6 +14,12 @@ export type PagerProps = {
13
14
  pageSizeOptions?: number[];
14
15
  /** Called when user changes page size */
15
16
  onPageSizeChange?: (size: number) => void;
17
+ /**
18
+ * Control size — joins the shared control-height ladder (sm/md/lg) that
19
+ * Button, IconButton, and the form controls use.
20
+ * @default 'sm'
21
+ */
22
+ size?: SizeStandard;
16
23
  /** Pagination mode: 'simple' (prev/next only), 'ends', 'full', 'smart' */
17
24
  mode?: PagerMode;
18
25
  /** Max page number buttons in smart mode */
@@ -29,4 +36,4 @@ export type PagerProps = {
29
36
  */
30
37
  labels?: PagerLabels;
31
38
  };
32
- export declare function Pager({ currentPage, totalPages, onPageChange, pageSize, pageSizeOptions, onPageSizeChange, mode, maxNumbers, navStyle, hidden, className, labels: labelsProp, }: PagerProps): import("react/jsx-runtime").JSX.Element | null;
39
+ export declare function Pager({ currentPage, totalPages, onPageChange, pageSize, pageSizeOptions, onPageSizeChange, size, mode, maxNumbers, navStyle, hidden, className, labels: labelsProp, }: PagerProps): import("react/jsx-runtime").JSX.Element | null;
@@ -122,7 +122,11 @@ function buildItems(total, current, mode, maxNumbers) {
122
122
  // -----------------------------------------------------------------------------
123
123
  // Component
124
124
  // -----------------------------------------------------------------------------
125
- export function Pager({ currentPage, totalPages, onPageChange, pageSize, pageSizeOptions, onPageSizeChange, mode = 'smart', maxNumbers = DEFAULT_MAX_SLOTS, navStyle = 'text', hidden = false, className, labels: labelsProp, }) {
125
+ export function Pager({ currentPage, totalPages, onPageChange, pageSize, pageSizeOptions, onPageSizeChange, size = 'sm', mode = 'smart', maxNumbers = DEFAULT_MAX_SLOTS, navStyle = 'text', hidden = false, className, labels: labelsProp, }) {
126
+ // Size class follows the shared convention: default emits nothing, sm/lg
127
+ // emit `is-size-*`. (Pager's own default is sm, so a stock Pager still gets
128
+ // the class.)
129
+ const sizeClass = size !== 'md' ? `is-size-${size}` : undefined;
126
130
  const labels = React.useMemo(() => ({ ...defaultPagerLabels, ...labelsProp }), [labelsProp]);
127
131
  // Normalise inputs
128
132
  const total = Math.max(1, totalPages);
@@ -140,20 +144,20 @@ export function Pager({ currentPage, totalPages, onPageChange, pageSize, pageSiz
140
144
  const showPageSizeSelector = pageSizeOptions && pageSizeOptions.length > 0 && onPageSizeChange;
141
145
  return (_jsxs("div", { className: cx('tui-pager', className), children: [_jsx("span", { role: "status", "aria-atomic": "true", className: "tui-visually-hidden", children: announcement }), _jsx("nav", { className: "tui-pager__nav", "aria-label": labels.navigation, children: items.map((it, i) => {
142
146
  if (it.kind === 'ellipsis') {
143
- return (_jsx("span", { className: "tui-pager__ellipsis", "aria-hidden": true, children: "..." }, `e${i}`));
147
+ return (_jsx("span", { className: cx('tui-pager__ellipsis', sizeClass), "aria-hidden": true, children: "..." }, `e${i}`));
144
148
  }
145
149
  if (it.kind === 'prev' || it.kind === 'next') {
146
150
  const isPrev = it.kind === 'prev';
147
151
  const label = isPrev ? labels.previous : labels.next;
148
152
  if (navStyle === 'icon') {
149
- return (_jsx(IconButton, { icon: isPrev ? 'system/chevron-left' : 'system/chevron-right', label: label, showTooltip: true, size: "sm", theme: "secondary", variant: "outline", disabled: it.disabled, onClick: () => go(it.page), className: "tui-pager__item" }, it.kind));
153
+ return (_jsx(IconButton, { icon: isPrev ? 'system/chevron-left' : 'system/chevron-right', label: label, showTooltip: true, size: size, theme: "secondary", variant: "outline", disabled: it.disabled, onClick: () => go(it.page), className: "tui-pager__item" }, it.kind));
150
154
  }
151
- return (_jsx(Button, { size: "sm", theme: "secondary", variant: "outline", disabled: it.disabled, onClick: () => go(it.page), "aria-label": label, className: "tui-pager__item", children: isPrev ? labels.previousText : labels.nextText }, it.kind));
155
+ return (_jsx(Button, { size: size, theme: "secondary", variant: "outline", disabled: it.disabled, onClick: () => go(it.page), "aria-label": label, className: "tui-pager__item", children: isPrev ? labels.previousText : labels.nextText }, it.kind));
152
156
  }
153
157
  // Page number
154
158
  if (it.kind === 'page') {
155
- return (_jsx(Button, { size: "sm", theme: it.current ? 'primary' : 'secondary', variant: it.current ? 'solid' : 'outline', "aria-current": it.current ? 'page' : undefined, "aria-label": labels.page(it.page), onClick: () => go(it.page), className: "tui-pager__item", children: it.page }, it.page));
159
+ return (_jsx(Button, { size: size, theme: it.current ? 'primary' : 'secondary', variant: it.current ? 'solid' : 'outline', "aria-current": it.current ? 'page' : undefined, "aria-label": labels.page(it.page), onClick: () => go(it.page), className: "tui-pager__item", children: it.page }, it.page));
156
160
  }
157
161
  return null;
158
- }) }), _jsxs("div", { className: "tui-pager__info", children: [_jsx("span", { children: labels.pageStatus(current, total) }), showPageSizeSelector && (_jsxs("label", { className: "tui-pager__page-size-label", children: [_jsx("span", { className: "tui-visually-hidden", children: labels.itemsPerPage }), _jsx("select", { className: "tui-input", value: pageSize, onChange: (e) => onPageSizeChange(Number(e.target.value)), children: pageSizeOptions.map((s) => (_jsx("option", { value: s, children: labels.perPage(s) }, s))) })] }))] })] }));
162
+ }) }), _jsxs("div", { className: "tui-pager__info", children: [_jsx("span", { children: labels.pageStatus(current, total) }), showPageSizeSelector && (_jsxs("label", { className: "tui-pager__page-size-label", children: [_jsx("span", { className: "tui-visually-hidden", children: labels.itemsPerPage }), _jsx("select", { className: cx('tui-input', sizeClass), value: pageSize, onChange: (e) => onPageSizeChange(Number(e.target.value)), children: pageSizeOptions.map((s) => (_jsx("option", { value: s, children: labels.perPage(s) }, s))) })] }))] })] }));
159
163
  }
@@ -0,0 +1,11 @@
1
+ export declare const SearchInput: import("react").ForwardRefExoticComponent<Omit<import("..").TextInputProps, "value" | "type" | "defaultValue" | "onChange" | "prefix" | "suffix"> & {
2
+ value?: string;
3
+ defaultValue?: string;
4
+ onValueChange?: (value: string) => void;
5
+ onClear?: () => void;
6
+ onSearch?: (value: string) => void;
7
+ searchLabel?: string;
8
+ clearLabel?: string;
9
+ hideClear?: boolean;
10
+ searchIcon?: import("react").ReactNode;
11
+ } & import("react").RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,76 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef, useRef } from 'react';
3
+ import { cx } from '../../utils/cx.js';
4
+ import { composeRefs } from '../../utils/compose-refs.js';
5
+ import { useControllableState } from '../../utils/use-controllable-state.js';
6
+ import { Icon } from '../Icon/index.js';
7
+ import { TextInput } from '../TextInput/index.js';
8
+ // =============================================================================
9
+ // SearchInput Component
10
+ // =============================================================================
11
+ //
12
+ // Thin variant over TextInput: `type="search"` for the searchbox semantics,
13
+ // a leading search icon, and an owned clear (×) button. See types.ts for why
14
+ // the native clear affordance is suppressed in favour of our own.
15
+ //
16
+ // When `onSearch` is provided the leading icon becomes a submit button — it
17
+ // lives in the prefix slot, so it sits *inside* the field (no external width)
18
+ // and Enter in the field submits too.
19
+ //
20
+ // Styling lives in styles.scss (the `tui-search-input__clear` / `__submit`
21
+ // buttons); the field chrome is inherited from the shared input core.
22
+ //
23
+ // =============================================================================
24
+ export const SearchInput = forwardRef(function SearchInput({ value: valueProp, defaultValue, onValueChange, onClear, onSearch, searchLabel = 'Search', clearLabel = 'Clear search', hideClear = false, searchIcon, inputClassName, onKeyDown, disabled, ...rest }, forwardedRef) {
25
+ const innerRef = useRef(null);
26
+ const [value = '', setValue] = useControllableState({
27
+ value: valueProp,
28
+ defaultValue: defaultValue ?? '',
29
+ onChange: onValueChange,
30
+ });
31
+ const handleChange = (e) => {
32
+ setValue(e.target.value);
33
+ };
34
+ const clear = () => {
35
+ setValue('');
36
+ onClear?.();
37
+ // Refocus the field so the user can keep typing — clearing hides the
38
+ // button, and without this focus would fall to <body>.
39
+ innerRef.current?.focus();
40
+ };
41
+ const submit = () => onSearch?.(value);
42
+ const handleKeyDown = (e) => {
43
+ onKeyDown?.(e);
44
+ // onSearch owns submit: preventDefault so it doesn't also trigger a native
45
+ // form submit when the field happens to sit inside a <form>.
46
+ if (onSearch && !e.defaultPrevented && e.key === 'Enter') {
47
+ e.preventDefault();
48
+ submit();
49
+ }
50
+ };
51
+ // Whether a clear affordance is possible at all (independent of value).
52
+ const clearable = !hideClear && !disabled;
53
+ // Whether the button is currently shown (there's something to clear).
54
+ const showClear = clearable && value.length > 0;
55
+ const icon = searchIcon ?? _jsx(Icon, { name: "system/search" });
56
+ // With onSearch the leading icon is the submit control; otherwise it stays a
57
+ // decorative glyph (Icon renders decorative-by-default with no `label`).
58
+ const prefix = onSearch && !disabled ? (_jsx("button", { type: "button", className: "tui-search-input__submit", "aria-label": searchLabel, onClick: submit,
59
+ // Keep pointerdown from stealing focus before the click fires.
60
+ onPointerDown: (e) => e.preventDefault(), children: icon })) : (icon);
61
+ return (_jsx(TextInput
62
+ // rest is spread first so SearchInput's own wiring below (value, the
63
+ // change handler, type) always wins — a stray value/onChange from a
64
+ // consumer can't clobber the controlled-value plumbing.
65
+ , { ...rest, ref: composeRefs(forwardedRef, innerRef), type: "search", value: value, onChange: handleChange, onKeyDown: handleKeyDown, disabled: disabled,
66
+ // tui-input-reset strips the native search decoration (WebKit cancel
67
+ // button, etc.); we render our own clear affordance.
68
+ inputClassName: cx('tui-input-reset', inputClassName), prefix: prefix, suffix: clearable ? (_jsx("button", { type: "button", className: "tui-search-input__clear", "aria-label": clearLabel, onClick: clear,
69
+ // Keep pointerdown from stealing focus before the click fires.
70
+ onPointerDown: (e) => e.preventDefault(),
71
+ // Rendered even while empty so the suffix slot reserves its width —
72
+ // the input never reflows as the button appears/disappears.
73
+ // `visibility: hidden` (vs. unmounting) also drops the empty-state
74
+ // button from the tab order and the a11y tree.
75
+ style: showClear ? undefined : { visibility: 'hidden' }, children: _jsx(Icon, { name: "system/close-small" }) })) : undefined }));
76
+ });
@@ -0,0 +1,2 @@
1
+ export { SearchInput } from './SearchInput';
2
+ export type { SearchInputProps } from './types';
@@ -0,0 +1 @@
1
+ export { SearchInput } from './SearchInput.js';
@@ -0,0 +1,69 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { TextInputProps } from '../TextInput/types';
3
+ /**
4
+ * SearchInput is a TextInput variant tuned for search: it renders as a native
5
+ * `<input type="search">` (implicit `role="searchbox"`, so AT announces it as a
6
+ * search field), a leading search icon, and a trailing clear (×) button.
7
+ *
8
+ * The native WebKit/Blink clear affordance (`::-webkit-search-cancel-button`) is
9
+ * suppressed via `tui-input-reset` — it never renders in Firefox and can't be
10
+ * styled or reliably reached by keyboard. SearchInput draws its own clear button
11
+ * instead, so the affordance is consistent, styleable, focusable, and i18n-able
12
+ * across every browser.
13
+ */
14
+ export type SearchInputProps = Omit<TextInputProps, 'type' | 'prefix' | 'suffix' | 'value' | 'defaultValue' | 'onChange'> & {
15
+ /**
16
+ * Current value (controlled).
17
+ */
18
+ value?: string;
19
+ /**
20
+ * Initial value (uncontrolled).
21
+ */
22
+ defaultValue?: string;
23
+ /**
24
+ * Called with the current string value on every change — typing and the clear
25
+ * button alike (clearing fires it with `''`).
26
+ *
27
+ * @remarks SearchInput is a value component (like Combobox/Select), not a thin
28
+ * native wrapper: it owns controlled/uncontrolled state and the clear button,
29
+ * so it exposes `onValueChange` rather than a native `onChange` event. Reach
30
+ * for {@link TextInput} directly if you need the raw change event.
31
+ */
32
+ onValueChange?: (value: string) => void;
33
+ /**
34
+ * Called when the clear button is pressed, after the value is reset.
35
+ */
36
+ onClear?: () => void;
37
+ /**
38
+ * Called with the current value when the search is submitted — pressing Enter
39
+ * in the field or activating the submit button.
40
+ *
41
+ * @remarks Providing this turns the leading search icon into a submit button.
42
+ * It lives in the field's prefix slot, so it sits *inside* the field (no extra
43
+ * external width) rather than as an attached button beside it. `onSearch` owns
44
+ * submit: Enter is intercepted (and its default prevented), so the field never
45
+ * double-fires a native form submission.
46
+ */
47
+ onSearch?: (value: string) => void;
48
+ /**
49
+ * Accessible label for the submit button (only rendered when `onSearch` is
50
+ * set).
51
+ * @default 'Search'
52
+ */
53
+ searchLabel?: string;
54
+ /**
55
+ * Accessible label for the clear button.
56
+ * @default 'Clear search'
57
+ */
58
+ clearLabel?: string;
59
+ /**
60
+ * Hide the clear button entirely (e.g. when search runs live and clearing
61
+ * has no meaning).
62
+ * @default false
63
+ */
64
+ hideClear?: boolean;
65
+ /**
66
+ * Override the leading icon. Defaults to the `system/search` glyph.
67
+ */
68
+ searchIcon?: ReactNode;
69
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -10,6 +10,7 @@ export { Chip } from './Chip';
10
10
  export { ChipGroup } from './ChipGroup';
11
11
  export { Chips } from './Chips';
12
12
  export { ColorPicker, ColorField, ColorArea, ColorSlider, defaultColorPickerLabels } from './ColorPicker';
13
+ export { GradientPicker, GradientBar, defaultGradientPickerLabels } from './GradientPicker';
13
14
  export { ContentIndicator } from './ContentIndicator';
14
15
  export { Calendar, DatePicker, DateRangePicker, defaultDateRangePresets, defaultCalendarLabels, defaultDatePickerLabels, defaultDateRangePickerLabels, } from './DatePicker';
15
16
  export { Combobox, ComboboxContent, ComboboxOption, ComboboxGroup, ComboboxLabel, useCombobox } from './Combobox';
@@ -35,6 +36,7 @@ export { Sidebar } from './Sidebar';
35
36
  export { StepIndicator } from './StepIndicator';
36
37
  export { StepList } from './StepList';
37
38
  export { DataTable } from './Table';
39
+ export { SearchInput } from './SearchInput';
38
40
  export { Switch } from './Switch';
39
41
  export { Tabs } from './Tabs';
40
42
  export { Textarea } from './Textarea';
@@ -51,6 +53,7 @@ export type { ChipGroupProps, ChipGroupSingleProps, ChipGroupMultipleProps } fro
51
53
  export type { ChipsProps, ChipOption } from './Chips';
52
54
  export type { ColorPickerProps, ColorPickerLabels, ColorFieldProps, ColorFieldLabels, ColorAreaProps, ColorSliderProps } from './ColorPicker';
53
55
  export type { ColorFormat, Hsva as ColorHsva } from './ColorPicker';
56
+ export type { GradientPickerProps, GradientPickerLabels, GradientBarProps, GradientBarLabels, Gradient, GradientType, GradientStop, } from './GradientPicker';
54
57
  export type { ContentIndicatorProps } from './ContentIndicator';
55
58
  export type { DropdownProps, DropdownTriggerProps, DropdownContentProps, DropdownItemProps, DropdownSeparatorProps, DropdownHeaderProps, } from './Dropdown';
56
59
  export type { ComboboxProps, ComboboxContentProps, ComboboxOptionProps, ComboboxGroupProps, ComboboxLabelProps, ComboboxRegisteredOption, } from './Combobox';
@@ -75,6 +78,7 @@ export type { StepIndicatorProps, StepStatus } from './StepIndicator';
75
78
  export type { StepListProps, StepListItemProps } from './StepList';
76
79
  export type { DataTableProps } from './Table';
77
80
  export type { TabsProps, TabsListProps, TabProps, TabPanelProps, TabsVariant, TabsActivationMode, TabsOrientation, } from './Tabs';
81
+ export type { SearchInputProps } from './SearchInput';
78
82
  export type { SwitchProps } from './Switch';
79
83
  export type { TextareaProps, TextareaResize } from './Textarea';
80
84
  export type { TextInputProps, TextInputType } from './TextInput';
@@ -8,6 +8,7 @@ export { Chip } from './Chip/index.js';
8
8
  export { ChipGroup } from './ChipGroup/index.js';
9
9
  export { Chips } from './Chips/index.js';
10
10
  export { ColorPicker, ColorField, ColorArea, ColorSlider, defaultColorPickerLabels } from './ColorPicker/index.js';
11
+ export { GradientPicker, GradientBar, defaultGradientPickerLabels } from './GradientPicker/index.js';
11
12
  export { ContentIndicator } from './ContentIndicator/index.js';
12
13
  export { Calendar, DatePicker, DateRangePicker, defaultDateRangePresets, defaultCalendarLabels, defaultDatePickerLabels, defaultDateRangePickerLabels, } from './DatePicker/index.js';
13
14
  export { Combobox, ComboboxContent, ComboboxOption, ComboboxGroup, ComboboxLabel, useCombobox } from './Combobox/index.js';
@@ -33,6 +34,7 @@ export { Sidebar } from './Sidebar/index.js';
33
34
  export { StepIndicator } from './StepIndicator/index.js';
34
35
  export { StepList } from './StepList/index.js';
35
36
  export { DataTable } from './Table/index.js';
37
+ export { SearchInput } from './SearchInput/index.js';
36
38
  export { Switch } from './Switch/index.js';
37
39
  export { Tabs } from './Tabs/index.js';
38
40
  export { Textarea } from './Textarea/index.js';