@tangible/ui 0.1.0 → 0.2.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/components/Button/types.d.ts +5 -2
- package/components/Chip/Chip.d.ts +28 -0
- package/components/Chip/Chip.js +19 -3
- 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/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 +3 -0
- package/components/index.js +2 -0
- package/package.json +9 -1
- package/styles/all.css +1 -1
- package/styles/all.expanded.css +707 -50
- package/styles/all.expanded.unlayered.css +707 -50
- package/styles/all.unlayered.css +1 -1
- package/styles/components/_bundle.scss +4 -0
- package/styles/components/button.scss +45 -35
- package/styles/components/chip.scss +57 -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 +215 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IconName } from '../../icons/registry';
|
|
2
|
-
import type { Size, ThemeIntent } from '../../types';
|
|
2
|
+
import type { Size, ThemeIntent, ThemeStatus } from '../../types';
|
|
3
3
|
export type { Size };
|
|
4
4
|
/**
|
|
5
5
|
* Semantic color themes.
|
|
@@ -9,8 +9,11 @@ export type { Size };
|
|
|
9
9
|
* - `'destructive'`: Alias for `'danger'` — mapped internally before
|
|
10
10
|
* class generation. Provided for readability in consumer code where
|
|
11
11
|
* "destructive" better describes the intent (e.g. `theme="destructive"`).
|
|
12
|
+
* - `'success'` / `'warning'` / `'info'`: Status-coloured actions for
|
|
13
|
+
* surfaces where the action carries the status semantics (approve,
|
|
14
|
+
* proceed-with-caution, learn-more).
|
|
12
15
|
*/
|
|
13
|
-
export type Theme = ThemeIntent | 'destructive';
|
|
16
|
+
export type Theme = ThemeIntent | ThemeStatus | 'destructive';
|
|
14
17
|
/**
|
|
15
18
|
* Visual style variants.
|
|
16
19
|
* - `'solid'`: Filled background (default)
|
|
@@ -29,6 +29,20 @@ export type ChipProps = {
|
|
|
29
29
|
leftIcon?: React.ReactNode;
|
|
30
30
|
rightIcon?: React.ReactNode;
|
|
31
31
|
onClick?: React.MouseEventHandler<HTMLElement>;
|
|
32
|
+
/**
|
|
33
|
+
* When provided, renders a trailing remove (×) button after the content.
|
|
34
|
+
* The button is a real `<button>` — the only focusable target in the chip —
|
|
35
|
+
* so the chip body stays non-interactive. Intended for token/tag patterns
|
|
36
|
+
* (MultiSelect, MultiCombobox). Combining `onRemove` with an interactive
|
|
37
|
+
* chip (`onClick` or ChipGroup) nests interactive elements and warns in dev.
|
|
38
|
+
*/
|
|
39
|
+
onRemove?: React.MouseEventHandler<HTMLButtonElement>;
|
|
40
|
+
/**
|
|
41
|
+
* Accessible label for the remove button. Pass a specific label like
|
|
42
|
+
* `Remove Alice` for context.
|
|
43
|
+
* @default 'Remove'
|
|
44
|
+
*/
|
|
45
|
+
removeLabel?: string;
|
|
32
46
|
/** When inside ChipGroup, identifies this chip for selection tracking */
|
|
33
47
|
value?: OptionValue;
|
|
34
48
|
} & Omit<React.HTMLAttributes<HTMLSpanElement>, 'onClick'>;
|
|
@@ -57,6 +71,20 @@ export declare const Chip: React.ForwardRefExoticComponent<{
|
|
|
57
71
|
leftIcon?: React.ReactNode;
|
|
58
72
|
rightIcon?: React.ReactNode;
|
|
59
73
|
onClick?: React.MouseEventHandler<HTMLElement>;
|
|
74
|
+
/**
|
|
75
|
+
* When provided, renders a trailing remove (×) button after the content.
|
|
76
|
+
* The button is a real `<button>` — the only focusable target in the chip —
|
|
77
|
+
* so the chip body stays non-interactive. Intended for token/tag patterns
|
|
78
|
+
* (MultiSelect, MultiCombobox). Combining `onRemove` with an interactive
|
|
79
|
+
* chip (`onClick` or ChipGroup) nests interactive elements and warns in dev.
|
|
80
|
+
*/
|
|
81
|
+
onRemove?: React.MouseEventHandler<HTMLButtonElement>;
|
|
82
|
+
/**
|
|
83
|
+
* Accessible label for the remove button. Pass a specific label like
|
|
84
|
+
* `Remove Alice` for context.
|
|
85
|
+
* @default 'Remove'
|
|
86
|
+
*/
|
|
87
|
+
removeLabel?: string;
|
|
60
88
|
/** When inside ChipGroup, identifies this chip for selection tracking */
|
|
61
89
|
value?: OptionValue;
|
|
62
90
|
} & Omit<React.HTMLAttributes<HTMLSpanElement>, "onClick"> & React.RefAttributes<HTMLElement>>;
|
package/components/Chip/Chip.js
CHANGED
|
@@ -5,7 +5,8 @@ import { cx } from '../../utils/cx.js';
|
|
|
5
5
|
import { toKey } from '../../utils/value-key.js';
|
|
6
6
|
import { isDev } from '../../utils/is-dev.js';
|
|
7
7
|
import { useChipGroupContext } from '../ChipGroup/ChipGroupContext.js';
|
|
8
|
-
|
|
8
|
+
import { Icon } from '../Icon/index.js';
|
|
9
|
+
export const Chip = forwardRef(function Chip({ as = 'span', href, target, rel, children, size = 'md', theme = 'secondary', variant = 'default', selected: selectedProp, disabled: disabledProp, interactive, className, leftIcon, rightIcon, onClick: onClickProp, onRemove, removeLabel = 'Remove', value, ...rest }, ref) {
|
|
9
10
|
const groupContext = useChipGroupContext();
|
|
10
11
|
// Dev warning: inside ChipGroup without value
|
|
11
12
|
useEffect(() => {
|
|
@@ -13,6 +14,13 @@ export const Chip = forwardRef(function Chip({ as = 'span', href, target, rel, c
|
|
|
13
14
|
console.warn('Chip: Inside a ChipGroup but missing `value` prop. This chip will not be managed by the group.');
|
|
14
15
|
}
|
|
15
16
|
}, [groupContext, value]);
|
|
17
|
+
// Dev warning: onRemove nests a <button> — the chip body must not also be
|
|
18
|
+
// interactive, or we produce nested interactive elements (invalid a11y).
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (isDev() && onRemove && (onClickProp || groupContext)) {
|
|
21
|
+
console.warn('Chip: `onRemove` renders a nested <button>; do not combine it with an interactive chip (`onClick` or ChipGroup). Use a display-only chip with `onRemove` for token/tag patterns.');
|
|
22
|
+
}
|
|
23
|
+
}, [onRemove, onClickProp, groupContext]);
|
|
16
24
|
// Derive from group context when applicable
|
|
17
25
|
const isManaged = groupContext !== null && value !== undefined;
|
|
18
26
|
const selected = isManaged ? groupContext.selectedValues.has(toKey(value)) : selectedProp;
|
|
@@ -35,7 +43,7 @@ export const Chip = forwardRef(function Chip({ as = 'span', href, target, rel, c
|
|
|
35
43
|
onClick(e);
|
|
36
44
|
}
|
|
37
45
|
}, [isClickable, onClick]);
|
|
38
|
-
const classes = cx('tui-chip', size && `is-size-${size}`, theme && `is-theme-${theme}`, variant !== 'default' && `is-style-${variant}`, selected && 'is-selected', (interactive || isManaged) && 'is-interactive', className);
|
|
46
|
+
const classes = cx('tui-chip', size && `is-size-${size}`, theme && `is-theme-${theme}`, variant !== 'default' && `is-style-${variant}`, selected && 'is-selected', (interactive || isManaged) && 'is-interactive', onRemove && 'has-remove', className);
|
|
39
47
|
const anchorProps = as === 'a'
|
|
40
48
|
? {
|
|
41
49
|
href: disabled || isManaged ? undefined : href ?? '#',
|
|
@@ -60,5 +68,13 @@ export const Chip = forwardRef(function Chip({ as = 'span', href, target, rel, c
|
|
|
60
68
|
'aria-disabled': disabled || undefined,
|
|
61
69
|
}
|
|
62
70
|
: {};
|
|
63
|
-
return (_jsxs(Tag, { ref: ref, className: classes, ...anchorProps, ...buttonProps, onClick: disabled ? undefined : onClick, ...rest, children: [leftIcon && leftIcon, children != null && children !== '' && (_jsx("span", { className: "tui-chip__text", children: children })), rightIcon && rightIcon
|
|
71
|
+
return (_jsxs(Tag, { ref: ref, className: classes, ...anchorProps, ...buttonProps, onClick: disabled ? undefined : onClick, ...rest, children: [leftIcon && leftIcon, children != null && children !== '' && (_jsx("span", { className: "tui-chip__text", children: children })), rightIcon && rightIcon, onRemove && (_jsx("button", { type: "button", className: "tui-chip__remove", "aria-label": removeLabel, disabled: disabled, tabIndex: disabled ? -1 : undefined,
|
|
72
|
+
// Stop propagation so removing doesn't trigger any ancestor click
|
|
73
|
+
// (e.g. a token-field wrapper that focuses the input).
|
|
74
|
+
onClick: (e) => {
|
|
75
|
+
e.stopPropagation();
|
|
76
|
+
onRemove(e);
|
|
77
|
+
},
|
|
78
|
+
// Keep pointerdown from stealing focus/opening a parent listbox.
|
|
79
|
+
onPointerDown: (e) => e.stopPropagation(), children: _jsx(Icon, { name: "system/close", "aria-hidden": "true" }) }))] }));
|
|
64
80
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComboboxProps, ComboboxContentProps, ComboboxOptionProps, ComboboxGroupProps, ComboboxLabelProps } from './types';
|
|
2
|
-
declare function ComboboxRoot({ value: controlledValue, defaultValue, onValueChange, inputValue: controlledInputValue, onInputChange, open: controlledOpen, defaultOpen, onOpenChange, disabled, placeholder, size, openOnFocus, filterMode, onQueryChange, clearable, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, inputClassName, labels: labelsProp, children, }: ComboboxProps): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
declare function ComboboxRoot({ value: controlledValue, defaultValue, onValueChange, inputValue: controlledInputValue, onInputChange, open: controlledOpen, defaultOpen, onOpenChange, disabled, placeholder, size, openOnFocus, filterMode, onQueryChange, clearable, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, 'aria-describedby': ariaDescribedBy, 'aria-invalid': ariaInvalid, 'aria-required': ariaRequired, inputClassName, labels: labelsProp, children, }: ComboboxProps): import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
declare namespace ComboboxRoot {
|
|
4
4
|
var displayName: string;
|
|
5
5
|
}
|
|
@@ -13,7 +13,7 @@ import { defaultComboboxLabels } from './types.js';
|
|
|
13
13
|
// =============================================================================
|
|
14
14
|
// Combobox Root
|
|
15
15
|
// =============================================================================
|
|
16
|
-
function ComboboxRoot({ value: controlledValue, defaultValue, onValueChange, inputValue: controlledInputValue, onInputChange, open: controlledOpen, defaultOpen, onOpenChange, disabled = false, placeholder = '', size = 'md', openOnFocus = true, filterMode = 'always', onQueryChange, clearable = true, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, inputClassName, labels: labelsProp, children, }) {
|
|
16
|
+
function ComboboxRoot({ value: controlledValue, defaultValue, onValueChange, inputValue: controlledInputValue, onInputChange, open: controlledOpen, defaultOpen, onOpenChange, disabled = false, placeholder = '', size = 'md', openOnFocus = true, filterMode = 'always', onQueryChange, clearable = true, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, 'aria-describedby': ariaDescribedBy, 'aria-invalid': ariaInvalid, 'aria-required': ariaRequired, inputClassName, labels: labelsProp, children, }) {
|
|
17
17
|
const labels = { ...defaultComboboxLabels, ...labelsProp };
|
|
18
18
|
// Controlled/uncontrolled value (initialize from defaultValue)
|
|
19
19
|
const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue);
|
|
@@ -386,7 +386,7 @@ function ComboboxRoot({ value: controlledValue, defaultValue, onValueChange, inp
|
|
|
386
386
|
return (_jsx(ComboboxActionsContext.Provider, { value: actionsValue, children: _jsx(ComboboxStateContext.Provider, { value: stateValue, children: _jsxs("div", { className: "tui-combobox", children: [_jsxs("div", { className: "tui-combobox__input-wrapper", children: [_jsx("input", { ref: (node) => {
|
|
387
387
|
inputRef.current = node;
|
|
388
388
|
refs.setReference(node);
|
|
389
|
-
}, type: "text", id: inputId, className: cx('tui-combobox__input', size !== 'md' && `is-size-${size}`, inputClassName), role: "combobox", "aria-expanded": open, "aria-controls": open ? listboxId : undefined, "aria-autocomplete": "list", "aria-activedescendant": activeOptionId, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, disabled: disabled, placeholder: placeholder, value: inputValue, autoComplete: "off", ...referenceProps, onChange: handleInputChange }), clearable && inputValue && !disabled && (_jsx("button", { type: "button", className: "tui-combobox__clear", onClick: handleClear, onMouseDown: (e) => e.preventDefault(), "aria-label": labels.clear, tabIndex: -1, children: _jsx(Icon, { name: "system/close" }) })), _jsx("span", { className: "tui-combobox__icon", "aria-hidden": "true", children: _jsx(Icon, { name: "system/chevron-down" }) })] }), children] }) }) }));
|
|
389
|
+
}, type: "text", id: inputId, className: cx('tui-combobox__input', size !== 'md' && `is-size-${size}`, inputClassName), role: "combobox", "aria-expanded": open, "aria-controls": open ? listboxId : undefined, "aria-autocomplete": "list", "aria-activedescendant": activeOptionId, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, "aria-required": ariaRequired, disabled: disabled, placeholder: placeholder, value: inputValue, autoComplete: "off", ...referenceProps, onChange: handleInputChange }), clearable && inputValue && !disabled && (_jsx("button", { type: "button", className: "tui-combobox__clear", onClick: handleClear, onMouseDown: (e) => e.preventDefault(), "aria-label": labels.clear, tabIndex: -1, children: _jsx(Icon, { name: "system/close" }) })), _jsx("span", { className: "tui-combobox__icon", "aria-hidden": "true", children: _jsx(Icon, { name: "system/chevron-down" }) })] }), children] }) }) }));
|
|
390
390
|
}
|
|
391
391
|
ComboboxRoot.displayName = 'Combobox';
|
|
392
392
|
// =============================================================================
|
|
@@ -91,6 +91,19 @@ export type ComboboxProps = {
|
|
|
91
91
|
* ID of element that labels this combobox.
|
|
92
92
|
*/
|
|
93
93
|
'aria-labelledby'?: string;
|
|
94
|
+
/**
|
|
95
|
+
* ID(s) of element(s) that describe this combobox (helper text, error).
|
|
96
|
+
* Forwarded to the input — Field.Control injects this.
|
|
97
|
+
*/
|
|
98
|
+
'aria-describedby'?: string;
|
|
99
|
+
/**
|
|
100
|
+
* Invalid state, forwarded to the input. Field.Control injects this.
|
|
101
|
+
*/
|
|
102
|
+
'aria-invalid'?: boolean | 'true' | 'false';
|
|
103
|
+
/**
|
|
104
|
+
* Required state, forwarded to the input. Field.Control injects this.
|
|
105
|
+
*/
|
|
106
|
+
'aria-required'?: boolean | 'true' | 'false';
|
|
94
107
|
/**
|
|
95
108
|
* Whether to show the clear button when a value is present.
|
|
96
109
|
* @default true
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IconName } from '../../icons/registry';
|
|
2
|
-
import type { Size, ThemeIntent } from '../../types';
|
|
2
|
+
import type { Size, ThemeIntent, ThemeStatus } from '../../types';
|
|
3
3
|
export type { Size };
|
|
4
|
-
export type Theme = ThemeIntent;
|
|
4
|
+
export type Theme = ThemeIntent | ThemeStatus;
|
|
5
5
|
export type Variant = 'solid' | 'outline' | 'ghost';
|
|
6
6
|
export type Shape = 'square' | 'circle';
|
|
7
7
|
type IconButtonBaseProps = {
|
|
@@ -0,0 +1,33 @@
|
|
|
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;
|
|
3
|
+
declare namespace MultiComboboxRoot {
|
|
4
|
+
var displayName: string;
|
|
5
|
+
}
|
|
6
|
+
declare function MultiComboboxContentComponent({ className, children }: MultiComboboxContentProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
declare namespace MultiComboboxContentComponent {
|
|
8
|
+
var displayName: string;
|
|
9
|
+
}
|
|
10
|
+
declare function MultiComboboxOptionComponent({ value: optionValue, disabled, textValue: explicitTextValue, className, children, }: MultiComboboxOptionProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
declare namespace MultiComboboxOptionComponent {
|
|
12
|
+
var displayName: string;
|
|
13
|
+
}
|
|
14
|
+
declare function MultiComboboxGroupComponent({ className, children }: MultiComboboxGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
declare namespace MultiComboboxGroupComponent {
|
|
16
|
+
var displayName: string;
|
|
17
|
+
}
|
|
18
|
+
declare function MultiComboboxLabelComponent({ className, children }: MultiComboboxLabelProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
declare namespace MultiComboboxLabelComponent {
|
|
20
|
+
var displayName: string;
|
|
21
|
+
}
|
|
22
|
+
type MultiComboboxCompound = typeof MultiComboboxRoot & {
|
|
23
|
+
Content: typeof MultiComboboxContentComponent;
|
|
24
|
+
Option: typeof MultiComboboxOptionComponent;
|
|
25
|
+
Group: typeof MultiComboboxGroupComponent;
|
|
26
|
+
Label: typeof MultiComboboxLabelComponent;
|
|
27
|
+
};
|
|
28
|
+
export declare const MultiCombobox: MultiComboboxCompound;
|
|
29
|
+
export declare const MultiComboboxContent: typeof MultiComboboxContentComponent;
|
|
30
|
+
export declare const MultiComboboxOption: typeof MultiComboboxOptionComponent;
|
|
31
|
+
export declare const MultiComboboxGroup: typeof MultiComboboxGroupComponent;
|
|
32
|
+
export declare const MultiComboboxLabel: typeof MultiComboboxLabelComponent;
|
|
33
|
+
export { useMultiComboboxContext as useMultiCombobox } from './MultiComboboxContext';
|