@tangible/ui 0.2.29 → 0.2.31
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/Accordion/Accordion.js +2 -1
- package/components/Avatar/Avatar.js +6 -2
- package/components/Button/types.d.ts +5 -5
- package/components/Chip/Chip.js +2 -1
- package/components/ChipGroup/ChipGroup.js +1 -1
- package/components/ChipGroup/types.d.ts +2 -1
- package/components/Chips/Chips.d.ts +2 -0
- package/components/Chips/Chips.js +2 -16
- package/components/ColorPicker/ColorField.d.ts +3 -3
- package/components/ColorPicker/ColorField.js +2 -1
- package/components/ColorPicker/ColorPicker.js +2 -1
- package/components/ColorPicker/usePointerDrag.d.ts +7 -0
- package/components/ColorPicker/usePointerDrag.js +15 -1
- package/components/Combobox/Combobox.js +3 -2
- package/components/ContentIndicator/types.d.ts +3 -3
- package/components/DatePicker/Calendar.js +4 -3
- package/components/DatePicker/DatePicker.js +3 -2
- package/components/DatePicker/PickerTrigger.js +2 -1
- package/components/DatePicker/types.d.ts +1 -1
- package/components/GradientPicker/GradientBar.js +3 -1
- package/components/GradientPicker/GradientPicker.js +4 -3
- package/components/Icon/Icon.d.ts +9 -2
- package/components/Icon/Icon.js +4 -3
- package/components/Icon/index.d.ts +1 -1
- package/components/IconButton/IconButton.js +13 -45
- package/components/IconButton/IconButtonCore.d.ts +9 -0
- package/components/IconButton/IconButtonCore.js +76 -0
- package/components/IconButton/types.d.ts +4 -3
- package/components/Modal/Modal.js +3 -2
- package/components/MoveHandle/MoveHandle.js +3 -2
- package/components/MultiCombobox/MultiCombobox.js +3 -2
- package/components/MultiSelect/MultiSelect.js +3 -2
- package/components/NavMenu/NavMenu.js +2 -1
- package/components/NavMenu/types.d.ts +3 -3
- package/components/Notice/Notice.d.ts +7 -0
- package/components/Notice/Notice.js +6 -5
- package/components/Pager/Pager.js +5 -4
- package/components/Rating/Rating.js +2 -1
- package/components/SearchInput/SearchInput.js +3 -2
- package/components/SearchSelect/SearchSelect.js +3 -2
- package/components/SecretInput/SecretInput.js +3 -2
- package/components/Select/Select.js +3 -2
- package/components/Sidebar/Sidebar.js +18 -4
- package/components/StepIndicator/StepIndicator.js +4 -2
- package/components/StepIndicator/types.d.ts +2 -2
- package/components/StepList/types.d.ts +2 -2
- package/components/Tabs/types.d.ts +3 -3
- package/components/Toast/Toast.d.ts +5 -1
- package/components/Toast/Toast.js +3 -3
- package/components/Tooltip/Tooltip.d.ts +1 -1
- package/components/Tooltip/Tooltip.js +28 -6
- package/components/Tooltip/index.d.ts +1 -1
- package/components/Tooltip/types.d.ts +18 -0
- package/components/index.d.ts +2 -2
- package/figma-tokens.json +6 -4
- package/icons/cred/index.js +1 -0
- package/icons/icons.svg +7 -3
- package/icons/lms/index.d.ts +0 -3
- package/icons/lms/index.js +6 -33
- package/icons/manifest.json +71 -9
- package/icons/membersync/index.js +1 -0
- package/icons/player/index.js +1 -0
- package/icons/reaction/index.js +1 -0
- package/icons/registry.d.ts +14 -0
- package/icons/registry.js +7 -0
- package/icons/system/index.d.ts +11 -0
- package/icons/system/index.js +48 -0
- package/package.json +2 -1
- package/skills/building-with-tui/SKILL.md +201 -4
- package/styles/all.css +1 -1
- package/styles/all.expanded.css +90 -13
- package/styles/all.expanded.unlayered.css +90 -13
- package/styles/all.unlayered.css +1 -1
- package/styles/app.css +41 -0
- package/styles/components/_bundle.scss +2 -0
- package/styles/components/button.scss +6 -1
- package/styles/components/card.scss +17 -1
- package/styles/components/chip-group.scss +45 -28
- package/styles/components/chips.scss +21 -0
- package/styles/components/color-picker.scss +15 -1
- package/styles/components/gradient-picker.scss +2 -2
- package/styles/components/tooltip.scss +8 -1
- package/styles/core.css +1 -1
- package/styles/core.unlayered.css +1 -1
- package/styles/system/_text-styles.scss +4 -0
- package/styles/system/_tokens.scss +7 -2
- package/styles/utilities/_index.scss +3 -0
- package/tui-manifest.json +40 -18
- package/vanilla/styles.css +1 -1
- package/vanilla/styles.unlayered.css +1 -1
|
@@ -5,6 +5,7 @@ import { composeRefs, getElementRef } from '../../utils/compose-refs.js';
|
|
|
5
5
|
import { mergeProps } from '../../utils/merge-props.js';
|
|
6
6
|
import { Icon } from '../Icon/index.js';
|
|
7
7
|
import { AccordionContext, AccordionItemContext, useAccordionContext, useAccordionItemContext } from './AccordionContext.js';
|
|
8
|
+
import { ChevronDown as ChevronDownIcon } from '../../icons/system/index.js';
|
|
8
9
|
function AccordionRoot(props) {
|
|
9
10
|
const { type, variant = 'card', children, className } = props;
|
|
10
11
|
// Track trigger refs for keyboard navigation
|
|
@@ -261,7 +262,7 @@ function AccordionTrigger({ asChild = false, unstyled = false, 'aria-label': ari
|
|
|
261
262
|
return element;
|
|
262
263
|
}
|
|
263
264
|
// Default: render as button with built-in chevron indicator
|
|
264
|
-
const button = (_jsxs("button", { ref: triggerRef, type: "button", id: triggerId, className: cx('tui-accordion__trigger', className), "aria-expanded": isOpen, "aria-controls": panelId, "aria-label": ariaLabel, disabled: disabled, "data-state": state, "data-disabled": disabled || undefined, "data-tui-accordion-trigger": "", onClick: handleClick, onKeyDown: handleKeyDown, children: [children && _jsx("span", { className: "tui-accordion__trigger-content", children: children }), _jsx(Icon, { name:
|
|
265
|
+
const button = (_jsxs("button", { ref: triggerRef, type: "button", id: triggerId, className: cx('tui-accordion__trigger', className), "aria-expanded": isOpen, "aria-controls": panelId, "aria-label": ariaLabel, disabled: disabled, "data-state": state, "data-disabled": disabled || undefined, "data-tui-accordion-trigger": "", onClick: handleClick, onKeyDown: handleKeyDown, children: [children && _jsx("span", { className: "tui-accordion__trigger-content", children: children }), _jsx(Icon, { name: ChevronDownIcon, className: "tui-accordion__indicator", "aria-hidden": "true" })] }));
|
|
265
266
|
// Wrap in heading if headingLevel is specified
|
|
266
267
|
if (headingLevel) {
|
|
267
268
|
const Heading = `h${headingLevel}`;
|
|
@@ -5,6 +5,7 @@ import { stringToGenerativeColor } from '../../utils/generative.js';
|
|
|
5
5
|
import { Icon } from '../Icon/index.js';
|
|
6
6
|
import { Tooltip } from '../Tooltip/index.js';
|
|
7
7
|
import { defaultAvatarLabels } from './types.js';
|
|
8
|
+
import { UserCircleOutline as UserCircleOutlineIcon } from '../../icons/system/index.js';
|
|
8
9
|
/**
|
|
9
10
|
* Generate initials from a name.
|
|
10
11
|
* "Mary Ghen" → "MG", "Bob" → "B", "Jean-Luc Picard" → "JP"
|
|
@@ -49,9 +50,12 @@ export const Avatar = React.memo(React.forwardRef(({ src, name, size = 'md', sha
|
|
|
49
50
|
'aria-label': name && indicatorLabel
|
|
50
51
|
? labels.description(name, indicatorLabel)
|
|
51
52
|
: name || indicatorLabel,
|
|
52
|
-
}), children: [_jsxs("span", { className: "tui-avatar__content", children: [showImage && (_jsx("img", { src: src, alt: "", className: "tui-avatar__image", onError: () => setImgError(true) })), showInitials && (_jsx("span", { className: "tui-avatar__initials", "aria-hidden": "true", children: initials })), showPlaceholder && (_jsx(Icon, { name:
|
|
53
|
+
}), children: [_jsxs("span", { className: "tui-avatar__content", children: [showImage && (_jsx("img", { src: src, alt: "", className: "tui-avatar__image", onError: () => setImgError(true) })), showInitials && (_jsx("span", { className: "tui-avatar__initials", "aria-hidden": "true", children: initials })), showPlaceholder && (_jsx(Icon, { name: UserCircleOutlineIcon, className: "tui-avatar__placeholder" }))] }), indicator && (_jsx("span", { className: cx('tui-avatar__indicator', `is-position-${indicatorPosition}`), "aria-hidden": "true", children: indicator }))] }));
|
|
53
54
|
if (showTooltip) {
|
|
54
|
-
return (
|
|
55
|
+
return (
|
|
56
|
+
// The avatar already has aria-label={name}: the tooltip is its visual
|
|
57
|
+
// label, so it adds no aria-describedby (the name would be read twice).
|
|
58
|
+
_jsxs(Tooltip, { type: "label", children: [_jsx(Tooltip.Trigger, { asChild: true, children: avatarElement }), _jsx(Tooltip.Content, { children: name })] }));
|
|
55
59
|
}
|
|
56
60
|
return avatarElement;
|
|
57
61
|
}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IconSource } from '../Icon/Icon';
|
|
2
2
|
import type { Size, ThemeIntent, ThemeStatus } from '../../types';
|
|
3
3
|
export type { Size };
|
|
4
4
|
/**
|
|
@@ -100,16 +100,16 @@ type CommonProps = {
|
|
|
100
100
|
onClick?: React.MouseEventHandler<HTMLButtonElement | HTMLAnchorElement>;
|
|
101
101
|
/**
|
|
102
102
|
* Icon to display before the label.
|
|
103
|
-
*
|
|
103
|
+
* A registry path like "system/check", or an icon component.
|
|
104
104
|
* @example leftIconName="system/check"
|
|
105
105
|
*/
|
|
106
|
-
leftIconName?:
|
|
106
|
+
leftIconName?: IconSource;
|
|
107
107
|
/**
|
|
108
108
|
* Icon to display after the label.
|
|
109
|
-
*
|
|
109
|
+
* A registry path like "system/chevron-right", or an icon component.
|
|
110
110
|
* @example rightIconName="system/chevron-right"
|
|
111
111
|
*/
|
|
112
|
-
rightIconName?:
|
|
112
|
+
rightIconName?: IconSource;
|
|
113
113
|
/**
|
|
114
114
|
* Custom left icon element. Overrides leftIconName.
|
|
115
115
|
*/
|
package/components/Chip/Chip.js
CHANGED
|
@@ -6,6 +6,7 @@ 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
|
+
import { Close as CloseIcon } from '../../icons/system/index.js';
|
|
9
10
|
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) {
|
|
10
11
|
const groupContext = useChipGroupContext();
|
|
11
12
|
// Dev warning: inside ChipGroup without value
|
|
@@ -76,5 +77,5 @@ export const Chip = forwardRef(function Chip({ as = 'span', href, target, rel, c
|
|
|
76
77
|
onRemove(e);
|
|
77
78
|
},
|
|
78
79
|
// Keep pointerdown from stealing focus/opening a parent listbox.
|
|
79
|
-
onPointerDown: (e) => e.stopPropagation(), children: _jsx(Icon, { name:
|
|
80
|
+
onPointerDown: (e) => e.stopPropagation(), children: _jsx(Icon, { name: CloseIcon, "aria-hidden": "true" }) }))] }));
|
|
80
81
|
});
|
|
@@ -64,6 +64,6 @@ export function ChipGroup(props) {
|
|
|
64
64
|
console.warn('ChipGroup: Missing accessible name. Provide aria-label or aria-labelledby.');
|
|
65
65
|
}
|
|
66
66
|
}, [ariaLabel, ariaLabelledBy]);
|
|
67
|
-
return (_jsx(ChipGroupContext.Provider, { value: contextValue, children: _jsxs("div", { role: "group", "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-disabled": disabled || undefined, "aria-describedby": multiple ? descriptionId : undefined, className: cx('tui-chip-group', `is-density-${density}`, direction === 'stack' && 'is-direction-stack',
|
|
67
|
+
return (_jsx(ChipGroupContext.Provider, { value: contextValue, children: _jsxs("div", { role: "group", "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-disabled": disabled || undefined, "aria-describedby": multiple ? descriptionId : undefined, className: cx('tui-chip-group', `is-density-${density}`, direction === 'stack' && 'is-direction-stack', className), "data-align": alignment, children: [children, multiple && (_jsx("span", { id: descriptionId, className: "tui-visually-hidden", children: multipleLabel }))] }) }));
|
|
68
68
|
}
|
|
69
69
|
ChipGroup.displayName = 'ChipGroup';
|
|
@@ -6,7 +6,8 @@ type ChipGroupBaseProps = {
|
|
|
6
6
|
density?: 'xs' | 'sm' | 'md';
|
|
7
7
|
/** Layout direction. Default 'inline' (row wrap). */
|
|
8
8
|
direction?: 'inline' | 'stack';
|
|
9
|
-
/**
|
|
9
|
+
/** Inline: distribution along the row (justify-content). Stack: cross-axis
|
|
10
|
+
* alignment (align-items). Published as `data-align`. */
|
|
10
11
|
alignment?: 'start' | 'center' | 'end';
|
|
11
12
|
/** Visually hidden label describing multi-select behaviour. For i18n support.
|
|
12
13
|
* @default 'Multiple selections allowed' */
|
|
@@ -25,6 +25,8 @@ export type ChipsProps = {
|
|
|
25
25
|
/** Gap between chips */
|
|
26
26
|
density?: 'xs' | 'sm' | 'md';
|
|
27
27
|
direction?: 'inline' | 'stack';
|
|
28
|
+
/** Inline: distribution along the row. Stack: cross-axis alignment.
|
|
29
|
+
* Published as `data-align`. */
|
|
28
30
|
alignment?: 'start' | 'center' | 'end';
|
|
29
31
|
className?: string;
|
|
30
32
|
role?: React.AriaRole;
|
|
@@ -1,21 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { Chip } from '../Chip/index.js';
|
|
4
|
-
|
|
5
|
-
xs: 'var(--tui-spacing-xs)',
|
|
6
|
-
sm: 'var(--tui-spacing-sm)',
|
|
7
|
-
md: 'var(--tui-spacing-md)',
|
|
8
|
-
};
|
|
4
|
+
import { cx } from '../../utils/cx.js';
|
|
9
5
|
export function Chips({ name, options, density = 'sm', direction = 'inline', alignment, className, role = 'group' }) {
|
|
10
|
-
|
|
11
|
-
const style = {
|
|
12
|
-
display: 'flex',
|
|
13
|
-
flexDirection: isInline ? 'row' : 'column',
|
|
14
|
-
flexWrap: isInline ? 'wrap' : undefined,
|
|
15
|
-
gap: DENSITY_MAP[density],
|
|
16
|
-
justifyContent: isInline && alignment ? alignment : undefined,
|
|
17
|
-
alignItems: !isInline && alignment ? alignment : undefined,
|
|
18
|
-
marginBlockEnd: 'var(--tui-spacing-sm)',
|
|
19
|
-
};
|
|
20
|
-
return (_jsx("div", { role: role, className: className, "data-chips-name": name, style: style, children: options.map((o, index) => (_jsx(Chip, { as: o.as ?? (o.href ? 'a' : 'span'), href: o.href, target: o.target, rel: o.rel, size: o.size, theme: o.theme, variant: o.variant, disabled: o.disabled, className: o.className, leftIcon: o.leftIcon, rightIcon: o.rightIcon, children: o.label }, o.id ?? o.href ?? (typeof o.label === 'string' ? o.label : `chip-${index}`)))) }));
|
|
6
|
+
return (_jsx("div", { role: role, className: cx('tui-chips', `is-density-${density}`, direction === 'stack' && 'is-direction-stack', className), "data-align": alignment, "data-chips-name": name, children: options.map((o, index) => (_jsx(Chip, { as: o.as ?? (o.href ? 'a' : 'span'), href: o.href, target: o.target, rel: o.rel, size: o.size, theme: o.theme, variant: o.variant, disabled: o.disabled, className: o.className, leftIcon: o.leftIcon, rightIcon: o.rightIcon, children: o.label }, o.id ?? o.href ?? (typeof o.label === 'string' ? o.label : `chip-${index}`)))) }));
|
|
21
7
|
}
|
|
@@ -3,7 +3,7 @@ import { type ColorPickerLabels } from './labels';
|
|
|
3
3
|
import { type ColorFormat } from '../../utils/color/color';
|
|
4
4
|
import { type GradientType } from '../../utils/color/gradient';
|
|
5
5
|
import type { SizeStandard } from '../../types';
|
|
6
|
-
import type {
|
|
6
|
+
import type { IconSource } from '../Icon/Icon';
|
|
7
7
|
import type { Side, Align } from '../Popover';
|
|
8
8
|
export type ColorFieldLabels = ColorPickerLabels & {
|
|
9
9
|
/** Base accessible name for the trigger (the label/value is appended). */
|
|
@@ -87,8 +87,8 @@ export type ColorFieldProps = {
|
|
|
87
87
|
* bound to dynamic sources rather than a fixed colour.
|
|
88
88
|
*/
|
|
89
89
|
dynamic?: boolean;
|
|
90
|
-
/** Override the swatch icon. @default 'system/edit-small' ('system/bolt-fill' when `dynamic`) */
|
|
91
|
-
icon?:
|
|
90
|
+
/** Override the swatch icon: a registry path or an icon component. @default 'system/edit-small' ('system/bolt-fill' when `dynamic`) */
|
|
91
|
+
icon?: IconSource;
|
|
92
92
|
size?: SizeStandard;
|
|
93
93
|
/** Popover side relative to the trigger. @default 'bottom' */
|
|
94
94
|
side?: Side;
|
|
@@ -11,6 +11,7 @@ import { resolveLabels } from './labels.js';
|
|
|
11
11
|
import { parseColor, resolveVarColor, formatColor, hsvToRgb, rgbToHex, } from '../../utils/color/color.js';
|
|
12
12
|
import { parseGradient, formatGradient, colorAtPosition, } from '../../utils/color/gradient.js';
|
|
13
13
|
import { getContrastForeground } from '../../utils/color/contrast.js';
|
|
14
|
+
import { BoltFill as BoltFillIcon, EditSmall as EditSmallIcon } from '../../icons/system/index.js';
|
|
14
15
|
/**
|
|
15
16
|
* Resolve any colour string to an Hsva — `var()` opportunistically via the
|
|
16
17
|
* live element; anything unresolvable returns null. The single resolved value
|
|
@@ -118,7 +119,7 @@ export function ColorField({ value: controlledValue, defaultValue = '#000000', o
|
|
|
118
119
|
// Dynamic values get a neutral swatch + bolt; concrete colours get the colour
|
|
119
120
|
// + an edit affordance. Icon colour is contrast-picked so it stays legible.
|
|
120
121
|
const swatchBg = dynamic ? 'var(--tui-color-fg, #111)' : swatchHex;
|
|
121
|
-
const swatchIcon = icon ?? (dynamic ?
|
|
122
|
+
const swatchIcon = icon ?? (dynamic ? BoltFillIcon : EditSmallIcon);
|
|
122
123
|
const iconColor = dynamic
|
|
123
124
|
? '#fff'
|
|
124
125
|
: getContrastForeground(resolvedHsva ? compositeOverWhiteHex(resolvedHsva) : '#000000');
|
|
@@ -9,6 +9,7 @@ import { ColorSlider } from './ColorSlider.js';
|
|
|
9
9
|
import { HUE_TRACK, alphaTrack } from './tracks.js';
|
|
10
10
|
import { parseColor, formatColor, resolveVarColor, COLOR_FORMATS, hsvToRgb, rgbToHsv, rgbToHsl, hslToRgb, rgbToHwb, hwbToRgb, rgbToOklch, oklchToRgb, } from '../../utils/color/color.js';
|
|
11
11
|
import { resolveLabels } from './labels.js';
|
|
12
|
+
import { Copy as CopyIcon } from '../../icons/system/index.js';
|
|
12
13
|
const NEUTRAL = { h: 0, s: 0, v: 0, a: 1 };
|
|
13
14
|
const CHANNEL_DEFS = {
|
|
14
15
|
rgb: [
|
|
@@ -211,5 +212,5 @@ export function ColorPicker({ value: controlledValue, defaultValue = '#000000',
|
|
|
211
212
|
return (_jsxs("div", { ref: rootRef, className: cx('tui-color-picker', disabled && 'is-disabled', className), role: "group", "aria-label": ariaLabel ?? L.group, ...rest, children: [_jsx(ColorArea, { hsva: hsva, onValueChange: ({ s, v }) => patch({ s, v }), disabled: disabled, "aria-label": L.area, valueText: L.areaValueText(Math.round(hsva.s * 100), Math.round(hsva.v * 100)) }), _jsx(ColorSlider, { "aria-label": L.hue, value: hsva.h, min: 0, max: 360, track: HUE_TRACK, valueText: L.hueValueText(Math.round(hsva.h)), onValueChange: (h) => patch({ h }), disabled: disabled }), alpha && (_jsx(ColorSlider, { "aria-label": L.alpha, value: hsva.a * 100, min: 0, max: 100, checkerboard: true, track: alphaTrack(opaqueHex), valueText: L.alphaValueText(Math.round(hsva.a * 100)), onValueChange: (a) => patch({ a: a / 100 }), disabled: disabled })), _jsxs("div", { className: "tui-color-picker__value", children: [offeredFormats.length > 1 && (_jsxs(Select, { value: format, onValueChange: (v) => setFormat(v), disabled: disabled, "aria-label": L.format, children: [_jsx(Select.Trigger, { className: "tui-color-picker__format" }), _jsx(Select.Content, { children: offeredFormats.map((f) => (_jsx(Select.Option, { value: f, children: L.formats[f] }, f))) })] })), _jsx("div", { className: "tui-color-picker__field-group", children: useChannels ? (_jsx(Channels, { format: format, hsva: hsva, alpha: alpha, disabled: disabled, onChange: commitHsva, channelLabels: L.channels, groupLabel: L.channelGroup(L.formats[format] ?? format) })) : (_jsx("input", { className: "tui-color-picker__field-input", type: "text", autoComplete: "off", spellCheck: false, value: fieldText, onChange: (e) => setDraft(e.target.value), onBlur: commitText, onKeyDown: (e) => {
|
|
212
213
|
if (e.key === 'Enter')
|
|
213
214
|
commitText();
|
|
214
|
-
}, "aria-label": L.value, disabled: disabled })) }), _jsxs(Tooltip, { children: [_jsx(Tooltip.Trigger, { asChild: true, children: _jsx(IconButton, { className: "tui-color-picker__copy", icon:
|
|
215
|
+
}, "aria-label": L.value, disabled: disabled })) }), _jsxs(Tooltip, { type: "label", children: [_jsx(Tooltip.Trigger, { asChild: true, children: _jsx(IconButton, { className: "tui-color-picker__copy", icon: CopyIcon, label: L.copy, variant: "ghost", size: "sm", disabled: disabled, onClick: handleCopy }) }), _jsx(Tooltip.Content, { children: copied ? L.copied : L.copy })] })] }), _jsx("span", { className: "tui-visually-hidden", role: "status", "aria-live": "polite", children: copied ? L.copied : '' }), _jsx("p", { className: cx('tui-color-picker__var', !isVar && 'is-empty'), "aria-live": "polite", children: isVar && (_jsxs(_Fragment, { children: [L.variable, " ", _jsx("code", { children: parsed.name })] })) })] }));
|
|
215
216
|
}
|
|
@@ -4,10 +4,17 @@ import type React from 'react';
|
|
|
4
4
|
* onMove(clientX, clientY); subsequent moves fire it too until pointerup. The
|
|
5
5
|
* consumer converts client coords to a value using its own bounding rect.
|
|
6
6
|
* Spread the returned handlers onto the draggable element.
|
|
7
|
+
*
|
|
8
|
+
* pointercancel and lostpointercapture end the drag too. The browser cancels
|
|
9
|
+
* a pointer for system gestures or palm rejection and never sends pointerup,
|
|
10
|
+
* so without them the drag stays live and a later hover (hybrid devices)
|
|
11
|
+
* moves the value with no button pressed.
|
|
7
12
|
*/
|
|
8
13
|
export declare function usePointerDrag(onMove: (clientX: number, clientY: number) => void, disabled?: boolean): {
|
|
9
14
|
onPointerDown: (e: React.PointerEvent) => void;
|
|
10
15
|
onPointerMove: (e: React.PointerEvent) => void;
|
|
11
16
|
onPointerUp: (e: React.PointerEvent) => void;
|
|
17
|
+
onPointerCancel: (e: React.PointerEvent) => void;
|
|
18
|
+
onLostPointerCapture: () => void;
|
|
12
19
|
};
|
|
13
20
|
export declare const clamp01: (n: number) => number;
|
|
@@ -4,6 +4,11 @@ import { useCallback, useRef } from 'react';
|
|
|
4
4
|
* onMove(clientX, clientY); subsequent moves fire it too until pointerup. The
|
|
5
5
|
* consumer converts client coords to a value using its own bounding rect.
|
|
6
6
|
* Spread the returned handlers onto the draggable element.
|
|
7
|
+
*
|
|
8
|
+
* pointercancel and lostpointercapture end the drag too. The browser cancels
|
|
9
|
+
* a pointer for system gestures or palm rejection and never sends pointerup,
|
|
10
|
+
* so without them the drag stays live and a later hover (hybrid devices)
|
|
11
|
+
* moves the value with no button pressed.
|
|
7
12
|
*/
|
|
8
13
|
export function usePointerDrag(onMove, disabled) {
|
|
9
14
|
const active = useRef(false);
|
|
@@ -29,6 +34,15 @@ export function usePointerDrag(onMove, disabled) {
|
|
|
29
34
|
/* pointer already released */
|
|
30
35
|
}
|
|
31
36
|
}, []);
|
|
32
|
-
|
|
37
|
+
const onLostPointerCapture = useCallback(() => {
|
|
38
|
+
active.current = false;
|
|
39
|
+
}, []);
|
|
40
|
+
return {
|
|
41
|
+
onPointerDown,
|
|
42
|
+
onPointerMove,
|
|
43
|
+
onPointerUp,
|
|
44
|
+
onPointerCancel: onPointerUp,
|
|
45
|
+
onLostPointerCapture,
|
|
46
|
+
};
|
|
33
47
|
}
|
|
34
48
|
export const clamp01 = (n) => Math.min(1, Math.max(0, n));
|
|
@@ -9,6 +9,7 @@ import { composeEventHandlers } from '../../utils/compose-events.js';
|
|
|
9
9
|
import { Icon } from '../Icon/index.js';
|
|
10
10
|
import { ComboboxActionsContext, ComboboxStateContext, ComboboxContentContext, useComboboxContext, useComboboxContentContext, } from './ComboboxContext.js';
|
|
11
11
|
import { defaultComboboxLabels } from './types.js';
|
|
12
|
+
import { Check as CheckIcon, ChevronDown as ChevronDownIcon, Close as CloseIcon } from '../../icons/system/index.js';
|
|
12
13
|
// =============================================================================
|
|
13
14
|
// Combobox Root
|
|
14
15
|
// =============================================================================
|
|
@@ -288,7 +289,7 @@ function ComboboxRoot({ value: controlledValue, defaultValue, onValueChange, inp
|
|
|
288
289
|
return (_jsx(ComboboxActionsContext.Provider, { value: actionsValue, children: _jsx(ComboboxStateContext.Provider, { value: stateValue, children: _jsxs("div", { className: "tui-combobox", children: [_jsxs("div", { ref: handleWrapperRef, className: cx('tui-input-group', 'tui-combobox__input-wrapper', size !== 'md' && `is-size-${size}`), onMouseDown: handleWrapperMouseDown, children: [_jsx("input", { ref: (node) => {
|
|
289
290
|
inputRef.current = node;
|
|
290
291
|
refs.setReference(node);
|
|
291
|
-
}, type: "text", id: inputId, className: cx('tui-combobox__input', 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:
|
|
292
|
+
}, type: "text", id: inputId, className: cx('tui-combobox__input', 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: CloseIcon }) })), _jsx("span", { className: "tui-combobox__icon", "aria-hidden": "true", children: _jsx(Icon, { name: ChevronDownIcon }) })] }), children] }) }) }));
|
|
292
293
|
}
|
|
293
294
|
ComboboxRoot.displayName = 'Combobox';
|
|
294
295
|
// =============================================================================
|
|
@@ -363,7 +364,7 @@ function ComboboxOptionComponent({ value: optionValue, disabled = false, textVal
|
|
|
363
364
|
const itemProps = getItemProps({
|
|
364
365
|
onClick: handleClick,
|
|
365
366
|
});
|
|
366
|
-
return (_jsxs("div", { ref: ref, id: optionId, role: "option", className: cx('tui-combobox__option', className), "aria-selected": isSelected, "aria-disabled": disabled || undefined, "data-highlighted": isHighlighted || undefined, "data-disabled": disabled || undefined, ...itemProps, onPointerDown: composeEventHandlers(handlePointerDown, itemProps.onPointerDown), children: [_jsx("span", { className: "tui-combobox__option-content", children: children }), isSelected && (_jsx(Icon, { name:
|
|
367
|
+
return (_jsxs("div", { ref: ref, id: optionId, role: "option", className: cx('tui-combobox__option', className), "aria-selected": isSelected, "aria-disabled": disabled || undefined, "data-highlighted": isHighlighted || undefined, "data-disabled": disabled || undefined, ...itemProps, onPointerDown: composeEventHandlers(handlePointerDown, itemProps.onPointerDown), children: [_jsx("span", { className: "tui-combobox__option-content", children: children }), isSelected && (_jsx(Icon, { name: CheckIcon, className: "tui-combobox__option-check", "aria-hidden": "true" }))] }));
|
|
367
368
|
}
|
|
368
369
|
ComboboxOptionComponent.displayName = 'Combobox.Option';
|
|
369
370
|
// =============================================================================
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IconSource } from '../Icon/Icon';
|
|
2
2
|
import type { Size } from '../../types';
|
|
3
3
|
export type { Size };
|
|
4
4
|
/**
|
|
@@ -19,10 +19,10 @@ export type Variant = 'ring' | 'solid';
|
|
|
19
19
|
export type ContentIndicatorProps = {
|
|
20
20
|
/**
|
|
21
21
|
* Icon to display in the center.
|
|
22
|
-
*
|
|
22
|
+
* A registry path ("category/name") or an icon component.
|
|
23
23
|
* @example "lms/question-mark"
|
|
24
24
|
*/
|
|
25
|
-
icon:
|
|
25
|
+
icon: IconSource;
|
|
26
26
|
/**
|
|
27
27
|
* Size of the indicator.
|
|
28
28
|
* - `'xs'`: 16px circle
|
|
@@ -2,10 +2,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { cx } from '../../utils/cx.js';
|
|
4
4
|
import { useControllableState } from '../../utils/use-controllable-state.js';
|
|
5
|
-
import {
|
|
5
|
+
import { IconButtonCore } from '../IconButton/IconButtonCore.js';
|
|
6
6
|
import { addDays, addMonths, addYears, getMonthGrid, getMonthNames, getWeekdayLabels, isAfterDay, isBeforeDay, isSameDay, isSameMonth, isWithinDays, startOfMonth, } from './date-utils.js';
|
|
7
7
|
import { resolveLocale } from './date-utils.js';
|
|
8
8
|
import { defaultCalendarLabels } from './types.js';
|
|
9
|
+
import { ArrowLeft as ArrowLeftIcon, ArrowRight as ArrowRightIcon } from '../../icons/system/index.js';
|
|
9
10
|
// =============================================================================
|
|
10
11
|
// Calendar
|
|
11
12
|
// =============================================================================
|
|
@@ -105,7 +106,7 @@ export const Calendar = React.forwardRef(function Calendar({ value, onChange, mo
|
|
|
105
106
|
// Month/year drill-down view
|
|
106
107
|
// ---------------------------------------------------------------------------
|
|
107
108
|
if (view === 'months') {
|
|
108
|
-
return (_jsxs("div", { ref: ref, className: cx('tui-calendar', 'is-view-months', className), "aria-label": ariaLabel, children: [_jsxs("div", { className: "tui-calendar__nav", children: [_jsx(
|
|
109
|
+
return (_jsxs("div", { ref: ref, className: cx('tui-calendar', 'is-view-months', className), "aria-label": ariaLabel, children: [_jsxs("div", { className: "tui-calendar__nav", children: [_jsx(IconButtonCore, { className: "tui-calendar__prev", icon: ArrowLeftIcon, label: labels.prevYear, variant: "ghost", size: "sm", onClick: () => setVisibleMonth(addYears(visibleMonth, -1)) }), _jsx("button", { type: "button", className: "tui-calendar__caption", "aria-live": "polite", onClick: () => setView('days'), children: visibleMonth.getFullYear() }), _jsx(IconButtonCore, { className: "tui-calendar__next", icon: ArrowRightIcon, label: labels.nextYear, variant: "ghost", size: "sm", onClick: () => setVisibleMonth(addYears(visibleMonth, 1)) })] }), _jsx("div", { className: "tui-calendar__months", role: "listbox", "aria-label": caption, children: getMonthNames(locale, 'short').map((name, m) => {
|
|
109
110
|
const current = m === visibleMonth.getMonth();
|
|
110
111
|
return (_jsx("button", { type: "button", role: "option", "aria-selected": current, className: cx('tui-calendar__month', current && 'is-selected'), onClick: () => {
|
|
111
112
|
const next = new Date(visibleMonth);
|
|
@@ -122,7 +123,7 @@ export const Calendar = React.forwardRef(function Calendar({ value, onChange, mo
|
|
|
122
123
|
const weeks = getMonthGrid(visibleMonth, weekStartsOn);
|
|
123
124
|
const today = new Date();
|
|
124
125
|
const hasFocusTarget = weeks.some((row) => row.some((d) => isSameDay(d, focusedDay)));
|
|
125
|
-
return (_jsxs("div", { ref: ref, className: cx('tui-calendar', className), "aria-label": ariaLabel, children: [_jsxs("div", { className: "tui-calendar__nav", children: [_jsx(
|
|
126
|
+
return (_jsxs("div", { ref: ref, className: cx('tui-calendar', className), "aria-label": ariaLabel, children: [_jsxs("div", { className: "tui-calendar__nav", children: [_jsx(IconButtonCore, { className: "tui-calendar__prev", icon: ArrowLeftIcon, label: labels.prevMonth, variant: "ghost", size: "sm", onClick: () => setVisibleMonth(addMonths(visibleMonth, -1)) }), _jsxs("button", { type: "button", id: captionId, className: "tui-calendar__caption", "aria-live": "polite", "aria-label": labels.openMonthPicker(caption), onClick: () => setView('months'), children: [_jsx("span", { className: "tui-calendar__caption-month", children: monthNames[visibleMonth.getMonth()] }), ' ', _jsx("span", { className: "tui-calendar__caption-year", children: visibleMonth.getFullYear() })] }), _jsx(IconButtonCore, { className: "tui-calendar__next", icon: ArrowRightIcon, label: labels.nextMonth, variant: "ghost", size: "sm", onClick: () => setVisibleMonth(addMonths(visibleMonth, 1)) })] }), _jsxs("table", { ref: gridRef, role: "grid", className: "tui-calendar__grid", "aria-labelledby": captionId, children: [_jsx("thead", { children: _jsx("tr", { children: weekdays.map((w) => (_jsx("th", { scope: "col", className: "tui-calendar__weekday", "aria-label": w.long, children: w.narrow }, w.long))) }) }), _jsx("tbody", { children: weeks.map((row) => (_jsx("tr", { children: row.map((day) => {
|
|
126
127
|
const outside = !isSameMonth(day, visibleMonth);
|
|
127
128
|
const selected = isSameDay(day, value);
|
|
128
129
|
const isToday = isSameDay(day, today);
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { cx } from '../../utils/cx.js';
|
|
4
4
|
import { useControllableState } from '../../utils/use-controllable-state.js';
|
|
5
5
|
import { Button } from '../Button/index.js';
|
|
6
|
-
import {
|
|
6
|
+
import { IconButtonCore } from '../IconButton/IconButtonCore.js';
|
|
7
7
|
import { Popover, PopoverContent } from '../Popover/index.js';
|
|
8
8
|
import { SegmentedControl } from '../SegmentedControl/index.js';
|
|
9
9
|
import { Select } from '../Select/index.js';
|
|
@@ -11,6 +11,7 @@ import { Calendar } from './Calendar.js';
|
|
|
11
11
|
import { clampDay, daysInMonth, formatDay, formatDayTime, getMonthNames, withDay, resolveLocale, } from './date-utils.js';
|
|
12
12
|
import { PickerTrigger, PickerTriggerProvider } from './PickerTrigger.js';
|
|
13
13
|
import { defaultDatePickerLabels } from './types.js';
|
|
14
|
+
import { Close as CloseIcon } from '../../icons/system/index.js';
|
|
14
15
|
// =============================================================================
|
|
15
16
|
// DatePicker
|
|
16
17
|
// =============================================================================
|
|
@@ -152,7 +153,7 @@ const DatePickerRoot = React.forwardRef(function DatePicker({ value: valueProp,
|
|
|
152
153
|
if (next && disabled)
|
|
153
154
|
return;
|
|
154
155
|
setOpen(next);
|
|
155
|
-
}, children: [children ?? _jsx(PickerTrigger, {}), _jsxs(PopoverContent, { modal: true, side: "bottom", align: "start", className: "tui-date-picker", "aria-label": title, children: [_jsxs("div", { className: "tui-date-picker__head", children: [_jsx("span", { className: "tui-date-picker__title", children: title }), _jsx(Button, { className: "tui-date-picker__now", variant: "ghost", theme: "primary", size: "sm", label: labels.now, onClick: () => commit(clampDay(new Date(), min, max)) }), _jsx(
|
|
156
|
+
}, children: [children ?? _jsx(PickerTrigger, {}), _jsxs(PopoverContent, { modal: true, side: "bottom", align: "start", className: "tui-date-picker", "aria-label": title, children: [_jsxs("div", { className: "tui-date-picker__head", children: [_jsx("span", { className: "tui-date-picker__title", children: title }), _jsx(Button, { className: "tui-date-picker__now", variant: "ghost", theme: "primary", size: "sm", label: labels.now, onClick: () => commit(clampDay(new Date(), min, max)) }), _jsx(IconButtonCore, { className: "tui-date-picker__close", icon: CloseIcon, label: labels.close, variant: "ghost", size: "sm", onClick: () => setOpen(false) })] }), withTime && (_jsx(TimeField, { value: base, onChange: commit, hour12: hour12, zoneLabel: zoneLabel, labels: labels })), _jsxs("div", { className: "tui-date-picker__fields", role: "group", "aria-label": labels.dateSection, children: [_jsx("div", { className: "tui-date-picker__month", children: _jsxs(Select, { value: String(base.getMonth()), onValueChange: (m) => {
|
|
156
157
|
const next = new Date(base);
|
|
157
158
|
next.setDate(Math.min(next.getDate(), daysInMonth(new Date(next.getFullYear(), Number(m), 1))));
|
|
158
159
|
next.setMonth(Number(m));
|
|
@@ -4,6 +4,7 @@ import { cx } from '../../utils/cx.js';
|
|
|
4
4
|
import { composeRefs, getElementRef } from '../../utils/compose-refs.js';
|
|
5
5
|
import { Icon } from '../Icon/index.js';
|
|
6
6
|
import { PopoverTrigger } from '../Popover/index.js';
|
|
7
|
+
import { Calendar as CalendarIcon } from '../../icons/lms/index.js';
|
|
7
8
|
const PickerTriggerContext = React.createContext(null);
|
|
8
9
|
export const PickerTriggerProvider = PickerTriggerContext.Provider;
|
|
9
10
|
export function PickerTrigger({ asChild = false, children, className }) {
|
|
@@ -53,5 +54,5 @@ export function PickerTrigger({ asChild = false, children, className }) {
|
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
56
|
const { formatted } = ctx;
|
|
56
|
-
return (_jsx(PopoverTrigger, { asChild: true, children: _jsxs("button", { ref: composeRefs(ctx.forwardedRef), type: "button", id: ctx.id, disabled: ctx.disabled, className: cx('tui-input-group', `${ctx.blockClass}__trigger`, ctx.disabled && 'is-disabled', ctx.rootClassName, className), "aria-haspopup": "dialog", "aria-expanded": ctx.open, "aria-label": ctx.ariaLabel ?? (formatted ? ctx.labelFor(formatted) : ctx.labelEmpty), "aria-labelledby": ctx.ariaLabelledBy ? `${ctx.ariaLabelledBy} ${ctx.valueId}` : undefined, "aria-describedby": ctx.ariaDescribedBy, "aria-invalid": ctx.ariaInvalid, children: [_jsx("span", { id: ctx.valueId, className: cx(`${ctx.blockClass}__trigger-value`, !formatted && 'is-placeholder'), children: formatted ?? ctx.placeholder }), _jsx("span", { className: "tui-input-group__suffix", children: _jsx(Icon, { name:
|
|
57
|
+
return (_jsx(PopoverTrigger, { asChild: true, children: _jsxs("button", { ref: composeRefs(ctx.forwardedRef), type: "button", id: ctx.id, disabled: ctx.disabled, className: cx('tui-input-group', `${ctx.blockClass}__trigger`, ctx.disabled && 'is-disabled', ctx.rootClassName, className), "aria-haspopup": "dialog", "aria-expanded": ctx.open, "aria-label": ctx.ariaLabel ?? (formatted ? ctx.labelFor(formatted) : ctx.labelEmpty), "aria-labelledby": ctx.ariaLabelledBy ? `${ctx.ariaLabelledBy} ${ctx.valueId}` : undefined, "aria-describedby": ctx.ariaDescribedBy, "aria-invalid": ctx.ariaInvalid, children: [_jsx("span", { id: ctx.valueId, className: cx(`${ctx.blockClass}__trigger-value`, !formatted && 'is-placeholder'), children: formatted ?? ctx.placeholder }), _jsx("span", { className: "tui-input-group__suffix", children: _jsx(Icon, { name: CalendarIcon, size: "sm" }) })] }) }));
|
|
57
58
|
}
|
|
@@ -56,7 +56,7 @@ export type CalendarProps = CalendarBaseProps & {
|
|
|
56
56
|
* *selection* logic lives in DateRangePicker.
|
|
57
57
|
*/
|
|
58
58
|
range?: DateRange | null;
|
|
59
|
-
/**
|
|
59
|
+
/** Override default English strings for i18n. */
|
|
60
60
|
labels?: CalendarLabels;
|
|
61
61
|
'aria-label'?: string;
|
|
62
62
|
className?: string;
|
|
@@ -117,7 +117,9 @@ export function GradientBar({ stops, activeIndex, onActiveIndexChange, onStopPos
|
|
|
117
117
|
style: {
|
|
118
118
|
left: `calc(var(--_thumb, 16px) / 2 + ${stop.position / 100} * (100% - var(--_thumb, 16px)))`,
|
|
119
119
|
'--_stop-color': stop.color,
|
|
120
|
-
}, onPointerDown: handleThumbPointerDown(i), onPointerMove: handleThumbPointerMove, onPointerUp: handleThumbPointerUp,
|
|
120
|
+
}, onPointerDown: handleThumbPointerDown(i), onPointerMove: handleThumbPointerMove, onPointerUp: handleThumbPointerUp, onPointerCancel: handleThumbPointerUp, onLostPointerCapture: () => {
|
|
121
|
+
dragIndex.current = null;
|
|
122
|
+
}, onKeyDown: handleThumbKeyDown(i), onClick: (e) => {
|
|
121
123
|
e.stopPropagation();
|
|
122
124
|
// A completed drag ends in a click too — only a clean press
|
|
123
125
|
// (no movement) opens the stop editor.
|
|
@@ -12,6 +12,7 @@ import { parseGradient, formatGradient, reverseStops, colorAtPosition, DEFAULT_G
|
|
|
12
12
|
import { GradientBar } from './GradientBar.js';
|
|
13
13
|
import { AngleDial } from './AngleDial.js';
|
|
14
14
|
import { resolveGradientLabels } from './labels.js';
|
|
15
|
+
import { Copy as CopyIcon, Reverse as ReverseIcon, Trash as TrashIcon } from '../../icons/system/index.js';
|
|
15
16
|
const round1 = (n) => Math.round(n * 10) / 10;
|
|
16
17
|
const clampN = (n, min, max) => Math.min(max, Math.max(min, n));
|
|
17
18
|
// -----------------------------------------------------------------------------
|
|
@@ -176,14 +177,14 @@ export function GradientPicker({ value: controlledValue, defaultValue = formatGr
|
|
|
176
177
|
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
178
|
if (e.key === 'Enter')
|
|
178
179
|
commitText();
|
|
179
|
-
}, "aria-label": L.value, disabled: disabled }), _jsxs(Tooltip, { children: [_jsx(Tooltip.Trigger, { asChild: true, children: _jsx(IconButton, { icon:
|
|
180
|
+
}, "aria-label": L.value, disabled: disabled }), _jsxs(Tooltip, { type: "label", children: [_jsx(Tooltip.Trigger, { asChild: true, children: _jsx(IconButton, { icon: ReverseIcon, label: L.reverse, variant: "ghost", size: "sm", disabled: disabled, onClick: () => {
|
|
180
181
|
// An open editor's index would silently point at the mirrored
|
|
181
182
|
// stop after the reorder — close it instead.
|
|
182
183
|
setOpenStop(null);
|
|
183
184
|
patch({ stops: reverseStops(stops) });
|
|
184
|
-
} }) }), _jsx(Tooltip.Content, { children: L.reverse })] }), _jsxs(Tooltip, { children: [_jsx(Tooltip.Trigger, { asChild: true, children: _jsx(IconButton, { icon:
|
|
185
|
+
} }) }), _jsx(Tooltip.Content, { children: L.reverse })] }), _jsxs(Tooltip, { type: "label", children: [_jsx(Tooltip.Trigger, { asChild: true, children: _jsx(IconButton, { icon: CopyIcon, 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 tui-text-style-overline", 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
186
|
removeRefs.current[i] = el;
|
|
186
|
-
}, icon:
|
|
187
|
+
}, icon: TrashIcon, 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
188
|
addRef.current = el;
|
|
188
189
|
}, 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 tui-text-style-overline", 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
190
|
// mod 360 so a committed 360 doesn't flip to 0 on blur.
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { IconName } from '../../icons/registry';
|
|
3
3
|
import type { SizeExtended } from '../../types';
|
|
4
|
+
/** An SVG icon component, imported directly: `import { Check } from '@tangible/ui/icons/system/index.js'`. */
|
|
5
|
+
export type IconComponent = React.ComponentType<React.SVGProps<SVGSVGElement>>;
|
|
6
|
+
/**
|
|
7
|
+
* A registry name ("system/check") or an icon component. A component renders
|
|
8
|
+
* without a registry lookup, so it works with a lean registry (see the skill).
|
|
9
|
+
*/
|
|
10
|
+
export type IconSource = IconName | IconComponent;
|
|
4
11
|
export interface IconProps {
|
|
5
|
-
/** Icon name from registry (
|
|
6
|
-
name?:
|
|
12
|
+
/** Icon name from the registry ("system/check"), or an icon component. */
|
|
13
|
+
name?: IconSource;
|
|
7
14
|
/**
|
|
8
15
|
* Emoji or unicode character (alternative to name). The same labelling
|
|
9
16
|
* contract as `name` applies: pass `label` when the emoji conveys meaning
|
package/components/Icon/Icon.js
CHANGED
|
@@ -11,9 +11,10 @@ import { iconRegistry } from '../../icons/registry.js';
|
|
|
11
11
|
* - Informative icons: provide a `label` prop for screen reader announcement
|
|
12
12
|
*/
|
|
13
13
|
export const Icon = React.memo(React.forwardRef(({ name, emoji, label, size, className }, ref) => {
|
|
14
|
-
const
|
|
14
|
+
const byName = typeof name === 'string';
|
|
15
|
+
const SvgIcon = !name ? null : byName ? iconRegistry[name] : name;
|
|
15
16
|
// Dev warning for invalid icon name
|
|
16
|
-
if (isDev() &&
|
|
17
|
+
if (isDev() && byName && !SvgIcon) {
|
|
17
18
|
console.warn(`[Icon] Unknown icon name: "${name}". Check the registry.`);
|
|
18
19
|
}
|
|
19
20
|
// Decorative if no label provided
|
|
@@ -21,7 +22,7 @@ export const Icon = React.memo(React.forwardRef(({ name, emoji, label, size, cla
|
|
|
21
22
|
// A name that misses the registry (typo, or a runtime-dynamic name from
|
|
22
23
|
// config/API data) renders an empty span in production — mark it so the
|
|
23
24
|
// void is findable in DevTools instead of failing silently.
|
|
24
|
-
const isMissing = Boolean(
|
|
25
|
+
const isMissing = Boolean(byName && !SvgIcon && !emoji);
|
|
25
26
|
return (_jsxs("span", { ref: ref, className: cx('tui-icon', size && `is-size-${size}`, className), ...(isMissing ? { 'data-tui-icon-missing': name } : {}), ...(isDecorative
|
|
26
27
|
? { 'aria-hidden': true }
|
|
27
28
|
: { role: 'img', 'aria-label': label }), children: [SvgIcon && _jsx(SvgIcon, { "aria-hidden": "true", focusable: "false" }), !SvgIcon && emoji] }));
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { Icon } from './Icon';
|
|
2
|
-
export type { IconProps } from './Icon';
|
|
2
|
+
export type { IconProps, IconSource, IconComponent } from './Icon';
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
|
-
import { cx } from '../../utils/cx.js';
|
|
4
|
-
import { Icon } from '../Icon/index.js';
|
|
5
3
|
import { Tooltip } from '../Tooltip/index.js';
|
|
6
|
-
import {
|
|
4
|
+
import { IconButtonCore } from './IconButtonCore.js';
|
|
7
5
|
// =============================================================================
|
|
8
6
|
// IconButton Component
|
|
9
7
|
// =============================================================================
|
|
@@ -15,48 +13,18 @@ import { getSafeRel } from '../../utils/polymorphic.js';
|
|
|
15
13
|
// Renders as <button> by default, or <a> when href is provided.
|
|
16
14
|
// Set showTooltip to display the label on hover for sighted users.
|
|
17
15
|
//
|
|
16
|
+
// The button itself is IconButtonCore; this file adds only the tooltip, so
|
|
17
|
+
// TUI components that never show one can import the core and skip Tooltip
|
|
18
|
+
// and @floating-ui entirely (see IconButtonCore.tsx).
|
|
19
|
+
//
|
|
18
20
|
// =============================================================================
|
|
19
21
|
export const IconButton = forwardRef((props, ref) => {
|
|
20
|
-
const {
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const classes = cx('tui-icon-button', `is-size-${size}`, `is-theme-${theme}`, `is-style-${variant}`, isDisabled && 'is-disabled', shape === 'circle' && 'is-shape-circle', className);
|
|
28
|
-
const iconContent = (_jsxs(_Fragment, { children: [_jsx(Icon, { name: icon }), loading && _jsx("span", { className: "tui-icon-button__spinner", "aria-hidden": "true" })] }));
|
|
29
|
-
// Render the base element (button or anchor)
|
|
30
|
-
let element;
|
|
31
|
-
if (isLink) {
|
|
32
|
-
const { href, target, rel, tabIndex, onClick, ...anchorRest } = rest;
|
|
33
|
-
const safeRel = getSafeRel(target, rel);
|
|
34
|
-
const handleClick = (e) => {
|
|
35
|
-
if (isDisabled) {
|
|
36
|
-
e.preventDefault();
|
|
37
|
-
e.stopPropagation();
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
onClick?.(e);
|
|
41
|
-
};
|
|
42
|
-
element = (_jsx("a", { ref: ref, href: disabled ? undefined : href, className: classes, "aria-label": resolvedLabel, "aria-disabled": isDisabled || undefined, "aria-busy": loading || undefined, tabIndex: disabled ? -1 : tabIndex, onClick: handleClick, target: target, rel: safeRel, ...anchorRest, children: iconContent }));
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
const { onClick, ...buttonRest } = rest;
|
|
46
|
-
const handleButtonClick = (e) => {
|
|
47
|
-
if (loadingOnly) {
|
|
48
|
-
e.preventDefault();
|
|
49
|
-
e.stopPropagation();
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
onClick?.(e);
|
|
53
|
-
};
|
|
54
|
-
element = (_jsx("button", { ref: ref, type: buttonRest.type ?? 'button', className: classes, "aria-label": resolvedLabel, disabled: disabled, "aria-disabled": loadingOnly || undefined, "aria-busy": loading || undefined, "aria-pressed": pressed, onClick: handleButtonClick, ...buttonRest, children: iconContent }));
|
|
55
|
-
}
|
|
56
|
-
// Wrap in tooltip if requested
|
|
57
|
-
if (showTooltip) {
|
|
58
|
-
return (_jsxs(Tooltip, { children: [_jsx(Tooltip.Trigger, { asChild: true, children: element }), _jsx(Tooltip.Content, { side: tooltipSide, children: label })] }));
|
|
59
|
-
}
|
|
60
|
-
return element;
|
|
22
|
+
const { showTooltip = false, tooltipSide = 'top', ...rest } = props;
|
|
23
|
+
const element = _jsx(IconButtonCore, { ref: ref, ...rest });
|
|
24
|
+
if (!showTooltip)
|
|
25
|
+
return element;
|
|
26
|
+
return (
|
|
27
|
+
// The tooltip shows the label, which is already the button's name.
|
|
28
|
+
_jsxs(Tooltip, { type: "label", children: [_jsx(Tooltip.Trigger, { asChild: true, children: element }), _jsx(Tooltip.Content, { side: tooltipSide, children: props.label })] }));
|
|
61
29
|
});
|
|
62
30
|
IconButton.displayName = 'IconButton';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IconButtonProps, IconButtonAsAnchor, IconButtonAsButton } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* IconButtonProps without the tooltip props, per variant (button | anchor).
|
|
4
|
+
* The `infer P` is load-bearing: a conditional type distributes only over a
|
|
5
|
+
* naked type parameter, and a plain `Omit<IconButtonProps, …>` would merge the
|
|
6
|
+
* variants and lose `href` as the discriminant.
|
|
7
|
+
*/
|
|
8
|
+
export type IconButtonCoreProps = IconButtonProps extends infer P ? P extends unknown ? Omit<P, 'showTooltip' | 'tooltipSide'> : never : never;
|
|
9
|
+
export declare const IconButtonCore: import("react").ForwardRefExoticComponent<(Omit<IconButtonAsButton, "showTooltip" | "tooltipSide"> | Omit<IconButtonAsAnchor, "showTooltip" | "tooltipSide">) & import("react").RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
|