@tangible/ui 0.2.13 → 0.2.15

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 (35) hide show
  1. package/components/DatePicker/DatePicker.d.ts +19 -1
  2. package/components/DatePicker/DatePicker.js +73 -16
  3. package/components/DatePicker/DateRangePicker.d.ts +19 -1
  4. package/components/DatePicker/DateRangePicker.js +77 -23
  5. package/components/DatePicker/PickerTrigger.d.ts +38 -0
  6. package/components/DatePicker/PickerTrigger.js +57 -0
  7. package/components/DatePicker/index.d.ts +3 -3
  8. package/components/DatePicker/index.js +2 -2
  9. package/components/DatePicker/types.d.ts +65 -2
  10. package/components/Modal/Modal.d.ts +1 -1
  11. package/components/Modal/Modal.js +49 -9
  12. package/components/Popover/Popover.js +13 -0
  13. package/components/SecretInput/SecretInput.d.ts +9 -0
  14. package/components/SecretInput/SecretInput.js +146 -0
  15. package/components/SecretInput/index.d.ts +3 -0
  16. package/components/SecretInput/index.js +2 -0
  17. package/components/SecretInput/types.d.ts +138 -0
  18. package/components/SecretInput/types.js +11 -0
  19. package/components/index.d.ts +3 -1
  20. package/components/index.js +2 -1
  21. package/figma-tokens.json +1 -1
  22. package/package.json +5 -1
  23. package/skills/building-with-tui/SKILL.md +66 -2
  24. package/styles/all.css +1 -1
  25. package/styles/all.expanded.css +92 -0
  26. package/styles/all.expanded.unlayered.css +92 -0
  27. package/styles/all.unlayered.css +1 -1
  28. package/styles/components/_bundle.scss +3 -1
  29. package/styles/components/search-input.scss +1 -1
  30. package/styles/components/secret-input.scss +156 -0
  31. package/styles/components/text-input.scss +32 -0
  32. package/styles/core.css +1 -1
  33. package/styles/core.unlayered.css +1 -1
  34. package/styles/utilities/_index.scss +8 -0
  35. package/tui-manifest.json +111 -2
@@ -10,6 +10,7 @@ import { IconButton } from '../IconButton/index.js';
10
10
  const isBrowser = typeof document !== 'undefined';
11
11
  function ModalRoot({ open, onClose, size = 'md', stickyHead, stickyFoot, 'aria-labelledby': labelledBy, 'aria-describedby': describedBy, initialFocusSelector, container, showCloseButton, closeLabel = 'Close', closeOnBackdropClick = true, closeOnEscape = true, preventScrollOnRestore = false, className, children, ...rest }) {
12
12
  const dialogRef = useRef(null);
13
+ const anchorRef = useRef(null);
13
14
  const restoreRef = useRef(null);
14
15
  const warnedRef = useRef(false);
15
16
  const warnedAriaLabelRef = useRef(false);
@@ -32,24 +33,58 @@ function ModalRoot({ open, onClose, size = 'md', stickyHead, stickyFoot, 'aria-l
32
33
  'to provide an accessible name (WCAG 4.1.2).');
33
34
  }
34
35
  }, [open, labelledBy]);
35
- // Capture trigger element and compute portal mount point when modal opens.
36
+ // Compute portal mount point and capture the focus-restore target on open.
36
37
  // Uses useLayoutEffect to run before paint — both renders complete before
37
38
  // the browser shows anything, so no visible delay.
38
39
  //
39
- // NOTE: This assumes document.activeElement is the trigger at open time.
40
- // True for click/keyboard handlers. For programmatic opens (timers, effects),
41
- // the captured element may not be meaningful — focus restore still works,
42
- // portal scoping may fall back to global interface.
40
+ // Portal scoping resolves from `anchorRef` — a throwaway span rendered at the
41
+ // Modal's own position in the tree (see the first-render branch below) — NOT
42
+ // from document.activeElement. activeElement is not a reliable stand-in for
43
+ // the trigger: Safari/WebKit does not focus a <button> on click, so focus can
44
+ // still be sitting in a hidden, inert tab panel that a click moved away from.
45
+ // Scoping off it portalled the dialog into that hidden subtree, where the
46
+ // focus trap and scroll lock engaged around an invisible modal.
47
+ //
48
+ // Focus restore still reads activeElement (it wants "whatever had focus", and
49
+ // Modal has no reference to the trigger), so on WebKit it can restore to the
50
+ // pre-click element rather than the trigger. Cosmetic by comparison, and it
51
+ // cannot strand the user.
43
52
  useLayoutEffect(() => {
44
53
  if (!open || !isBrowser) {
45
54
  return;
46
55
  }
47
56
  if (mount)
48
57
  return; // Already captured for this open cycle
49
- const trigger = document.activeElement;
50
- restoreRef.current = trigger;
51
- setMount(container ?? getPortalRootFor(trigger));
58
+ restoreRef.current = document.activeElement;
59
+ setMount(container ?? getPortalRootFor(anchorRef.current));
52
60
  }, [open, container, mount]);
61
+ // Dev warning: a mount buried in a hidden/inert subtree renders an invisible
62
+ // modal with a live focus trap — the exact failure the anchor fix removes,
63
+ // now only reachable by rendering <Modal> inside a hidden panel yourself.
64
+ useEffect(() => {
65
+ if (!isDev() || !open || !mount)
66
+ return;
67
+ let node = mount;
68
+ let buried = null;
69
+ while (node && node !== document.body) {
70
+ const el = node;
71
+ if (el.hasAttribute('hidden') || el.hasAttribute('inert')) {
72
+ buried = el;
73
+ break;
74
+ }
75
+ if (isBrowser && getComputedStyle(el).display === 'none') {
76
+ buried = el;
77
+ break;
78
+ }
79
+ node = el.parentElement;
80
+ }
81
+ if (buried) {
82
+ console.warn('[TUI Modal] Portal target is inside a hidden or inert subtree, so the dialog ' +
83
+ 'will not be visible while its focus trap and scroll lock are active. The mount ' +
84
+ 'point is resolved from where <Modal> sits in the tree — move it out of the ' +
85
+ 'hidden container, or pass an explicit `container`.', buried);
86
+ }
87
+ }, [open, mount]);
53
88
  // Reset state when modal closes, restore focus to trigger.
54
89
  useEffect(() => {
55
90
  if (open)
@@ -139,8 +174,13 @@ function ModalRoot({ open, onClose, size = 'md', stickyHead, stickyFoot, 'aria-l
139
174
  }, [open, mount, initialFocusSelector, labelledBy]);
140
175
  // Memoize context value to prevent unnecessary re-renders
141
176
  const contextValue = useMemo(() => ({ onClose }), [onClose]);
142
- if (!open || !mount)
177
+ if (!open)
143
178
  return null;
179
+ // First render of an open cycle: nothing but an in-tree anchor, so the layout
180
+ // effect above can resolve the portal root from the Modal's own DOM position.
181
+ // Unmounts on the very next render (pre-paint), so it never lays anything out.
182
+ if (!mount)
183
+ return _jsx("span", { ref: anchorRef, hidden: true });
144
184
  return createPortal(_jsx(ModalContext.Provider, { value: contextValue, children: _jsxs("div", { className: "tui-modal", "data-state": "open", style: { pointerEvents: 'auto' }, children: [_jsx("div", { className: "tui-modal__backdrop", "aria-hidden": "true", onClick: closeOnBackdropClick ? onClose : undefined }), _jsxs("div", { ref: dialogRef, role: "dialog", "aria-modal": "true", "aria-labelledby": labelledBy, "aria-describedby": describedBy, className: cx('tui-modal__dialog', `is-size-${size}`, stickyHead && 'is-sticky-head', stickyFoot && 'is-sticky-foot', className), tabIndex: -1, ...rest, children: [showCloseButton && (_jsx(IconButton, { icon: "system/close", label: closeLabel, variant: "ghost", size: "sm", onClick: onClose, className: "tui-modal__close", showTooltip: true })), children] })] }) }), mount);
145
185
  }
146
186
  function ModalClose({ label = 'Close', className }) {
@@ -87,8 +87,21 @@ function PopoverTriggerComponent({ asChild = false, children }) {
87
87
  'data-popover-open': open || undefined,
88
88
  };
89
89
  if (asChild && isValidElement(children)) {
90
+ // Compose, don't clobber: an asChild trigger that brings its own onClick
91
+ // (an IconButton with an analytics call, a picker's own handler) used to
92
+ // lose it silently to the spread below. The child runs first, and opts out
93
+ // of toggling the popover by calling preventDefault — same contract as
94
+ // Select.Trigger's composed handlers.
95
+ const childOnClick = children.props.onClick;
90
96
  return cloneElement(children, {
91
97
  ...triggerProps,
98
+ onClick: childOnClick
99
+ ? (e) => {
100
+ childOnClick(e);
101
+ if (!e.defaultPrevented)
102
+ handleClick();
103
+ }
104
+ : handleClick,
92
105
  ref: setRefs,
93
106
  });
94
107
  }
@@ -0,0 +1,9 @@
1
+ export declare const SecretInput: import("react").ForwardRefExoticComponent<Omit<import("..").TextInputProps, "type" | "prefix" | "suffix"> & {
2
+ isSet?: boolean;
3
+ defaultRevealed?: boolean;
4
+ revealed?: boolean;
5
+ onRevealChange?: (revealed: boolean) => void;
6
+ locked?: boolean;
7
+ lockedMessage?: string;
8
+ labels?: import("./types").SecretInputLabels;
9
+ } & import("react").RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,146 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useCallback, useEffect, useId, useRef, useState } from 'react';
3
+ import { cx } from '../../utils/cx.js';
4
+ import { composeRefs } from '../../utils/compose-refs.js';
5
+ import { isDev } from '../../utils/is-dev.js';
6
+ import { Icon } from '../Icon/index.js';
7
+ import { TextInput } from '../TextInput/index.js';
8
+ import { defaultSecretInputLabels } from './types.js';
9
+ // =============================================================================
10
+ // SecretInput Component
11
+ // =============================================================================
12
+ //
13
+ // TextInput variant for stored secrets — API keys, tokens. See types.ts for the
14
+ // server-side contract the prop surface is shaped around; the short version is
15
+ // that a stored secret must never reach the client, so this component only ever
16
+ // holds a value the user typed in this session and `isSet` is a boolean.
17
+ //
18
+ // Three states, and the reveal toggle exists in only one of them:
19
+ // - editable masked <input type="password"> + reveal toggle
20
+ // - set same, plus the "•••••••• Saved" placeholder treatment
21
+ // - locked readOnly + lock icon, no toggle (nothing client-side to reveal)
22
+ //
23
+ // Styling lives in styles.scss. The field chrome is the shared input group.
24
+ //
25
+ // =============================================================================
26
+ export const SecretInput = forwardRef(function SecretInput({ isSet = false, revealed: revealedProp, defaultRevealed = false, onRevealChange, locked = false, lockedMessage, labels, value, defaultValue, onChange, placeholder, className, inputClassName, disabled, 'aria-describedby': ariaDescribedBy, ...rest }, forwardedRef) {
27
+ // Every rendered string comes from here — see SecretInputLabels for why
28
+ // none of them is assembled from fragments.
29
+ const text = { ...defaultSecretInputLabels, ...labels };
30
+ const inputRef = useRef(null);
31
+ const [revealedState, setRevealedState] = useState(defaultRevealed);
32
+ // Locked in at mount, like the rest of the family: a component that flips
33
+ // between controlled and uncontrolled mid-life pollutes its own state.
34
+ const [isRevealControlled] = useState(revealedProp !== undefined);
35
+ const revealed = isRevealControlled ? !!revealedProp : revealedState;
36
+ const [isValueControlled] = useState(value !== undefined);
37
+ // Emptiness decides the set-state, which drives an ARIA description as well
38
+ // as the placeholder — so a wrong answer here tells a screen-reader user
39
+ // their secret is safely stored when the field is about to overwrite it.
40
+ // That rules out tracking it from React change events alone: `form.reset()`
41
+ // and a post-mount `defaultValue` both change the input's value WITHOUT
42
+ // firing one. The DOM node is the only honest source for the uncontrolled
43
+ // case, so we read it and re-read it on those two events.
44
+ // The seed is deliberately redundant with the effect below, which would
45
+ // reach the same answer one tick later. It exists for the FIRST render: the
46
+ // set-state feeds an ARIA description, and a frame in which the description
47
+ // says "a value is saved and hidden" over a field that already holds a
48
+ // value is a frame of the component asserting the opposite of the truth.
49
+ // Consequence worth knowing: deleting it leaves the suite green, because
50
+ // every assertion runs after effects have flushed.
51
+ const [domHasValue, setDomHasValue] = useState(() => defaultValue !== undefined && String(defaultValue).length > 0);
52
+ const syncFromDom = useCallback(() => {
53
+ setDomHasValue((inputRef.current?.value.length ?? 0) > 0);
54
+ }, []);
55
+ // A later `defaultValue` reaches an un-dirtied input without an event.
56
+ useEffect(() => {
57
+ if (!isValueControlled)
58
+ syncFromDom();
59
+ }, [defaultValue, isValueControlled, syncFromDom]);
60
+ // form.reset() (and React 19's form-action auto-reset) clears the field
61
+ // silently. Read after the reset has actually been applied.
62
+ useEffect(() => {
63
+ const form = inputRef.current?.form;
64
+ if (!form || isValueControlled)
65
+ return;
66
+ const onReset = () => queueMicrotask(syncFromDom);
67
+ form.addEventListener('reset', onReset);
68
+ return () => form.removeEventListener('reset', onReset);
69
+ }, [isValueControlled, syncFromDom]);
70
+ const isEmpty = isValueControlled ? (value ?? '') === '' : !domHasValue;
71
+ // The contract is that the server sends a boolean, never the secret. A
72
+ // prefilled `isSet` field means someone echoed the stored value back into
73
+ // the page — the exact leak this component exists to prevent, and invisible
74
+ // because it renders perfectly.
75
+ if (isDev() && isSet && (value || defaultValue)) {
76
+ console.warn('[SecretInput] `isSet` means "a value exists server-side" and the field ' +
77
+ 'must start empty. Passing `value`/`defaultValue` alongside it sends the ' +
78
+ 'stored secret to the client, which is what `isSet` exists to avoid.');
79
+ }
80
+ const handleChange = (e) => {
81
+ setDomHasValue(e.target.value.length > 0);
82
+ onChange?.(e);
83
+ };
84
+ // Announced state, for the screen-reader-plus-mouse case: pointerdown is
85
+ // prevented so focus stays in the field, which means the toggle is never
86
+ // focused on a mouse click and neither its name nor its state is ever read.
87
+ // Without this, a user flips their key into the clear in total silence.
88
+ // Empty until the first toggle so nothing is announced on mount.
89
+ const [announcement, setAnnouncement] = useState('');
90
+ const toggleReveal = () => {
91
+ const next = !revealed;
92
+ if (!isRevealControlled)
93
+ setRevealedState(next);
94
+ setAnnouncement(next ? text.shown : text.hidden);
95
+ onRevealChange?.(next);
96
+ };
97
+ const handleToggleClick = () => {
98
+ toggleReveal();
99
+ // Pointer activation leaves focus wherever it was — including on <body>
100
+ // if nothing was focused, which strands the user at the top of the
101
+ // document. Recover only in that case: on keyboard activation focus is
102
+ // already on the button, and stealing it would break the toggle.
103
+ const input = inputRef.current;
104
+ const active = input?.ownerDocument.activeElement;
105
+ if (input && !active?.closest('.tui-secret-input'))
106
+ input.focus();
107
+ };
108
+ // The set-state treatment only makes sense while there is nothing typed —
109
+ // once there is, the field shows what the user is entering.
110
+ const showSetState = isSet && isEmpty;
111
+ // ...and the description only makes sense where typing is possible. On a
112
+ // locked field "Typing replaces it" is a straight contradiction, so the
113
+ // locked description supersedes rather than joins it.
114
+ const describeSetState = showSetState && !locked;
115
+ const setDescId = useId();
116
+ const lockedDescId = useId();
117
+ // Composed, never replaced: Field.Control injects aria-describedby pointing
118
+ // at the field's error and helper text, and clobbering it would silence
119
+ // both. Same reason the ids are appended rather than assigned.
120
+ const describedBy = [ariaDescribedBy, describeSetState && setDescId, locked && lockedDescId]
121
+ .filter(Boolean)
122
+ .join(' ') || undefined;
123
+ return (_jsx(TextInput, { ...rest, ref: composeRefs(forwardedRef, inputRef),
124
+ // Masked unless the user asked to see what they typed. A locked field
125
+ // holds nothing to reveal, so it stays masked regardless.
126
+ type: revealed && !locked ? 'text' : 'password', value: value, defaultValue: defaultValue, onChange: handleChange, readOnly: locked || rest.readOnly, disabled: disabled, "aria-describedby": describedBy,
127
+ // The bullets are a placeholder, never a value — a real value would
128
+ // submit and overwrite the stored secret with eight bullet characters.
129
+ // A consumer-supplied placeholder wins; the description still carries
130
+ // the set-state to AT either way.
131
+ placeholder: placeholder ?? (showSetState ? text.valueSet : undefined), className: cx('tui-secret-input', showSetState && 'is-set', locked && 'is-locked', className),
132
+ // `off` is the one value browsers deliberately ignore on a password
133
+ // field; `new-password` is what actually stops Chrome/Safari/Firefox
134
+ // offering a saved credential. That matters beyond annoyance: an
135
+ // autofilled value fires an input event, so the field looks legitimately
136
+ // typed and the save handler would overwrite the stored secret with a
137
+ // credential the user never chose. The two vendor attributes below cover
138
+ // the 1Password/LastPass extensions, which ignore autocomplete.
139
+ autoComplete: rest.autoComplete ?? 'new-password', spellCheck: rest.spellCheck ?? false, "data-1p-ignore": "", "data-lpignore": "true",
140
+ // tui-input-reset strips native in-field chrome — here Edge's own
141
+ // ::-ms-reveal eye, which would sit beside our toggle AND unmask the
142
+ // field without changing `type`, so the toggle's state would be wrong.
143
+ inputClassName: cx('tui-input-reset', 'tui-secret-input__input', inputClassName), suffix: _jsxs(_Fragment, { children: [describeSetState && (_jsx("span", { id: setDescId, className: "tui-visually-hidden", children: text.valueSetDescription })), locked ? (_jsxs(_Fragment, { children: [_jsx("span", { id: lockedDescId, className: "tui-visually-hidden", children: lockedMessage ?? text.locked }), _jsx(Icon, { name: "system/lock-small", className: "tui-secret-input__lock" })] })) : (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "tui-secret-input__reveal", "aria-label": revealed ? text.hide : text.reveal, "data-revealed": revealed ? 'true' : undefined, disabled: disabled, onClick: handleToggleClick,
144
+ // Keep pointerdown from stealing focus before the click fires.
145
+ onPointerDown: (e) => e.preventDefault(), children: _jsx(Icon, { name: revealed ? 'system/view-off' : 'system/view' }) }), _jsx("span", { role: "status", "aria-live": "polite", className: "tui-visually-hidden", children: announcement })] }))] }) }));
146
+ });
@@ -0,0 +1,3 @@
1
+ export { SecretInput } from './SecretInput';
2
+ export { defaultSecretInputLabels } from './types';
3
+ export type { SecretInputProps, SecretInputLabels } from './types';
@@ -0,0 +1,2 @@
1
+ export { SecretInput } from './SecretInput.js';
2
+ export { defaultSecretInputLabels } from './types.js';
@@ -0,0 +1,138 @@
1
+ import type { TextInputProps } from '../TextInput/types';
2
+ /**
3
+ * Overridable label strings for i18n.
4
+ *
5
+ * Every string the component renders or exposes to AT is here — nothing is
6
+ * assembled from fragments at runtime, so a translator controls whole sentences
7
+ * including word order, punctuation and the bullet run.
8
+ */
9
+ export type SecretInputLabels = {
10
+ /**
11
+ * Accessible name for the reveal toggle while the value is masked.
12
+ * @default "Show value"
13
+ */
14
+ reveal?: string;
15
+ /**
16
+ * Accessible name for the reveal toggle while the value is showing.
17
+ *
18
+ * @remarks The name flips rather than staying constant with `aria-pressed`:
19
+ * for "is my API key on screen right now" a name is announced reliably by
20
+ * every AT where `aria-pressed` is not, and stays unambiguous on AT that
21
+ * ignores the state entirely.
22
+ * @default "Hide value"
23
+ */
24
+ hide?: string;
25
+ /**
26
+ * Announced when the value becomes visible. A live region carries this
27
+ * because pointer activation deliberately leaves focus in the field, so the
28
+ * toggle itself is never read on a mouse click.
29
+ * @default "Value shown."
30
+ */
31
+ shown?: string;
32
+ /**
33
+ * Announced when the value is masked again.
34
+ * @default "Value hidden."
35
+ */
36
+ hidden?: string;
37
+ /**
38
+ * The whole placeholder shown while `isSet` — bullets included, deliberately.
39
+ * A translator owns the bullet count, the separator and the word order (some
40
+ * locales want the label first; RTL wants it last), none of which survives
41
+ * being concatenated in code.
42
+ *
43
+ * @remarks Placeholder text only. It is never a value, so nothing submits
44
+ * unless the user types. A `placeholder` prop overrides it.
45
+ * @default "•••••••• Saved"
46
+ */
47
+ valueSet?: string;
48
+ /**
49
+ * Accessible description announced while `isSet`, explaining what an empty
50
+ * field means. Sighted users get the placeholder above; this is its
51
+ * equivalent for AT, and it says more because a placeholder cannot.
52
+ * @default "A value is saved and hidden. Typing replaces it."
53
+ */
54
+ valueSetDescription?: string;
55
+ /**
56
+ * Accessible description when `locked` and no `lockedMessage` is given.
57
+ * @default "This value is managed outside this screen and cannot be edited here."
58
+ */
59
+ locked?: string;
60
+ };
61
+ export declare const defaultSecretInputLabels: Required<SecretInputLabels>;
62
+ /**
63
+ * SecretInput is a TextInput variant for API keys, tokens and other stored
64
+ * secrets. It is shaped around a server-side contract, and only makes sense
65
+ * with it:
66
+ *
67
+ * 1. **A stored secret is never sent to the client** — not as a `value`, not in
68
+ * a config blob. The server sends a boolean (`isSet`) saying a value exists.
69
+ * 2. **"Unchanged" round-trips as absence.** An untouched field submits empty
70
+ * and the save handler treats empty as "keep the stored value". Replacing
71
+ * means typing a new value; clearing is a separate, explicit action.
72
+ * 3. **A config-defined secret wins and locks the field** — `locked` renders it
73
+ * as externally managed: readable, never editable, never revealable.
74
+ *
75
+ * So the component never displays a stored secret. The only value it ever holds
76
+ * is one the user typed in this session, which is why there is an `isSet` flag
77
+ * rather than a masked-value prop — and why the reveal toggle can never leak
78
+ * anything the user did not just type.
79
+ *
80
+ * @remarks Unlike SearchInput, this is a thin native wrapper rather than a value
81
+ * component: `value`/`defaultValue`/`onChange` stay native so the field works
82
+ * inside a plain `<form>` with nothing but a `name`, which is how the PHP-driven
83
+ * consumers submit it. Emptiness is tracked internally for presentation only.
84
+ */
85
+ export type SecretInputProps = Omit<TextInputProps, 'type' | 'prefix' | 'suffix'> & {
86
+ /**
87
+ * A value exists server-side that is deliberately not shown. Renders the
88
+ * set-state treatment while the input is empty.
89
+ *
90
+ * The stored value must never be passed to this component — see the contract
91
+ * above; a dev-only warning fires if it is alongside `isSet`. Nothing is submitted unless the user types, so an empty submit means
92
+ * "unchanged" and the set-state is an accurate description of what the server
93
+ * still holds (including after the user types and deletes back to empty).
94
+ * @default false
95
+ */
96
+ isSet?: boolean;
97
+ /**
98
+ * Initial reveal state (uncontrolled).
99
+ * @default false
100
+ */
101
+ defaultRevealed?: boolean;
102
+ /**
103
+ * Reveal state (controlled) — for policies like re-masking on blur.
104
+ */
105
+ revealed?: boolean;
106
+ /**
107
+ * Called when the reveal toggle is activated, with the new state.
108
+ */
109
+ onRevealChange?: (revealed: boolean) => void;
110
+ /**
111
+ * The value is managed outside this UI (a `wp-config.php` constant, an env
112
+ * var, a policy). Renders read-only with a lock icon and no reveal toggle —
113
+ * there is nothing client-side to reveal.
114
+ *
115
+ * @remarks Deliberately `readOnly`, not `disabled`: a native `disabled` input
116
+ * leaves the tab order and the accessible name goes with it, so AT users lose
117
+ * the information that the field exists and is managed elsewhere. Same
118
+ * reasoning as MoveHandle's locked state.
119
+ * @default false
120
+ */
121
+ locked?: boolean;
122
+ /**
123
+ * Why the field is locked, e.g. "Defined in wp-config.php." Replaces the
124
+ * generic `labels.locked` sentence as the field's accessible description.
125
+ *
126
+ * @remarks Visually hidden, and composed onto any `aria-describedby` the field
127
+ * already has rather than replacing it. Render the visible copy in
128
+ * `Field.HelperText` — and when you do, prefer putting the sentence *only*
129
+ * there (leave this unset) so it is not announced twice.
130
+ */
131
+ lockedMessage?: string;
132
+ /**
133
+ * Overridable label strings for i18n. All keys are optional — defaults are
134
+ * English, and are exported as {@link defaultSecretInputLabels} so a consumer
135
+ * can override one key without restating the rest.
136
+ */
137
+ labels?: SecretInputLabels;
138
+ };
@@ -0,0 +1,11 @@
1
+ export const defaultSecretInputLabels = {
2
+ reveal: 'Show value',
3
+ hide: 'Hide value',
4
+ shown: 'Value shown.',
5
+ hidden: 'Value hidden.',
6
+ // Eight bullets is a deliberate fiction — it must not hint at the real
7
+ // length of the stored secret, which the client does not know anyway.
8
+ valueSet: '•••••••• Saved',
9
+ valueSetDescription: 'A value is saved and hidden. Typing replaces it.',
10
+ locked: 'This value is managed outside this screen and cannot be edited here.',
11
+ };
@@ -12,7 +12,7 @@ export { Chips } from './Chips';
12
12
  export { ColorPicker, ColorField, ColorArea, ColorSlider, defaultColorPickerLabels } from './ColorPicker';
13
13
  export { GradientPicker, GradientBar, defaultGradientPickerLabels } from './GradientPicker';
14
14
  export { ContentIndicator } from './ContentIndicator';
15
- export { Calendar, DatePicker, DateRangePicker, defaultDateRangePresets, defaultCalendarLabels, defaultDatePickerLabels, defaultDateRangePickerLabels, } from './DatePicker';
15
+ export { Calendar, DatePicker, DatePickerTrigger, DateRangePicker, DateRangePickerTrigger, defaultDateRangePresets, defaultCalendarLabels, defaultDatePickerLabels, defaultDateRangePickerLabels, } from './DatePicker';
16
16
  export { Combobox, ComboboxContent, ComboboxOption, ComboboxGroup, ComboboxLabel, useCombobox } from './Combobox';
17
17
  export { MultiCombobox, MultiComboboxContent, MultiComboboxOption, MultiComboboxGroup, MultiComboboxLabel, useMultiCombobox } from './MultiCombobox';
18
18
  export { Dropdown, DropdownTrigger, DropdownContent, DropdownItem, DropdownSeparator, DropdownHeader, useDropdown } from './Dropdown';
@@ -37,6 +37,7 @@ export { StepIndicator } from './StepIndicator';
37
37
  export { StepList } from './StepList';
38
38
  export { DataTable } from './Table';
39
39
  export { SearchInput } from './SearchInput';
40
+ export { SecretInput, defaultSecretInputLabels } from './SecretInput';
40
41
  export { SearchSelect, SearchSelectTrigger, SearchSelectContent, SearchSelectOption, SearchSelectGroup, SearchSelectLabel, useSearchSelect, } from './SearchSelect';
41
42
  export { Switch } from './Switch';
42
43
  export { Tabs } from './Tabs';
@@ -80,6 +81,7 @@ export type { StepListProps, StepListItemProps } from './StepList';
80
81
  export type { DataTableProps } from './Table';
81
82
  export type { TabsProps, TabsListProps, TabProps, TabPanelProps, TabsVariant, TabsActivationMode, TabsOrientation, } from './Tabs';
82
83
  export type { SearchInputProps } from './SearchInput';
84
+ export type { SecretInputProps, SecretInputLabels } from './SecretInput';
83
85
  export type { SearchSelectProps, SearchSelectTriggerProps, SearchSelectContentProps, SearchSelectOptionProps, SearchSelectGroupProps, SearchSelectLabelProps, SearchSelectLabels, } from './SearchSelect';
84
86
  export type { SwitchProps } from './Switch';
85
87
  export type { TextareaProps, TextareaResize } from './Textarea';
@@ -10,7 +10,7 @@ export { Chips } from './Chips/index.js';
10
10
  export { ColorPicker, ColorField, ColorArea, ColorSlider, defaultColorPickerLabels } from './ColorPicker/index.js';
11
11
  export { GradientPicker, GradientBar, defaultGradientPickerLabels } from './GradientPicker/index.js';
12
12
  export { ContentIndicator } from './ContentIndicator/index.js';
13
- export { Calendar, DatePicker, DateRangePicker, defaultDateRangePresets, defaultCalendarLabels, defaultDatePickerLabels, defaultDateRangePickerLabels, } from './DatePicker/index.js';
13
+ export { Calendar, DatePicker, DatePickerTrigger, DateRangePicker, DateRangePickerTrigger, defaultDateRangePresets, defaultCalendarLabels, defaultDatePickerLabels, defaultDateRangePickerLabels, } from './DatePicker/index.js';
14
14
  export { Combobox, ComboboxContent, ComboboxOption, ComboboxGroup, ComboboxLabel, useCombobox } from './Combobox/index.js';
15
15
  export { MultiCombobox, MultiComboboxContent, MultiComboboxOption, MultiComboboxGroup, MultiComboboxLabel, useMultiCombobox } from './MultiCombobox/index.js';
16
16
  export { Dropdown, DropdownTrigger, DropdownContent, DropdownItem, DropdownSeparator, DropdownHeader, useDropdown } from './Dropdown/index.js';
@@ -35,6 +35,7 @@ export { StepIndicator } from './StepIndicator/index.js';
35
35
  export { StepList } from './StepList/index.js';
36
36
  export { DataTable } from './Table/index.js';
37
37
  export { SearchInput } from './SearchInput/index.js';
38
+ export { SecretInput, defaultSecretInputLabels } from './SecretInput/index.js';
38
39
  export { SearchSelect, SearchSelectTrigger, SearchSelectContent, SearchSelectOption, SearchSelectGroup, SearchSelectLabel, useSearchSelect, } from './SearchSelect/index.js';
39
40
  export { Switch } from './Switch/index.js';
40
41
  export { Tabs } from './Tabs/index.js';
package/figma-tokens.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.2.13",
2
+ "version": "0.2.15",
3
3
  "source": "publish/styles/all.expanded.css",
4
4
  "prefix": "tui-",
5
5
  "note": "Layer 1 primitives only. Component API tokens (--tui-{component}-*) are never defined in CSS — they exist only as fallback reads — so they have no Figma representation.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangible/ui",
3
- "version": "0.2.13",
3
+ "version": "0.2.15",
4
4
  "description": "Tangible Design System",
5
5
  "type": "module",
6
6
  "main": "./components/index.js",
@@ -170,6 +170,10 @@
170
170
  "import": "./components/SearchSelect/index.js",
171
171
  "types": "./components/SearchSelect/index.d.ts"
172
172
  },
173
+ "./components/SecretInput": {
174
+ "import": "./components/SecretInput/index.js",
175
+ "types": "./components/SecretInput/index.d.ts"
176
+ },
173
177
  "./components/SegmentedControl": {
174
178
  "import": "./components/SegmentedControl/index.js",
175
179
  "types": "./components/SegmentedControl/index.d.ts"
@@ -228,13 +228,77 @@ Useful primitives:
228
228
  `className` is for layout integration (margin, grid placement), not appearance. Beyond the token
229
229
  API the sanctioned escape hatch is to **swizzle** — copy the component source and own the fork.
230
230
 
231
+ ### Replacing a trigger with `asChild`
232
+
233
+ `Select.Trigger`, `Dropdown.Trigger`, `Popover.Trigger`, `Tooltip.Trigger`, `Accordion.Trigger`,
234
+ `MultiSelect.Trigger`, `DatePicker.Trigger` and `DateRangePicker.Trigger` all take `asChild`,
235
+ rendering your element in place of theirs.
236
+
237
+ The two pickers render their trigger automatically when the root has no children, so
238
+ `<DatePicker />` is unchanged. Reach for `DatePicker.Trigger` when you want to place the trigger
239
+ yourself — which is what lets the whole popover (time field, Now, month/day/year, calendar) hang off
240
+ a text field the user can also type into freely:
241
+
242
+ ```tsx
243
+ <DatePicker withTime onChange={(date) => setText(format(date))}>
244
+ <TextInput
245
+ value={text}
246
+ onChange={(e) => setText(e.target.value)}
247
+ suffix={
248
+ <DatePicker.Trigger asChild>
249
+ <IconButton icon="lms/calendar" label="Pick a date" variant="ghost" size="sm" />
250
+ </DatePicker.Trigger>
251
+ }
252
+ />
253
+ </DatePicker>
254
+ ```
255
+
256
+ TUI never writes into the field: `onChange` hands you a `Date` and you decide what string goes in,
257
+ which is why this works with formats TUI knows nothing about ("3pm ET" survives being typed).
258
+ Children with no `Trigger` among them leave the picker unopenable — a dev warning fires.
259
+
260
+ **Size a slot button one tier below the field** (`md` field → `sm` button). Button and IconButton
261
+ anchor to `--tui-control-height-*`, which is the *whole field's* height; TUI cancels the group's
262
+ padding so it no longer inflates the field, but a same-tier button still fills the content box edge
263
+ to edge.
264
+
265
+ Four things change versus a picker's default trigger, all deliberate:
266
+
267
+ - **Your element owns its accessible name**, so name it for the action ("Pick a date"). The default
268
+ trigger appends its value text to the name; `asChild` cannot, because there is no value span —
269
+ and a dangling `aria-labelledby` id would resolve the *entire* name to empty.
270
+ - **No `tui-input-group` chrome** is applied. That is the point (a bare button, not a bordered
271
+ field) and it is where the pickers diverge from `Select.Trigger`, which force-applies the class
272
+ even under `asChild`. It also means `aria-invalid` still lands on your element but paints nothing,
273
+ so an invalid trigger inside a `Field` needs one rule of your own:
274
+
275
+ ```css
276
+ .my-date-trigger[aria-invalid='true'] {
277
+ border-color: var(--tui-theme-danger-base);
278
+ color: var(--tui-theme-danger-base);
279
+ }
280
+ ```
281
+
282
+ Everything else `Field` injects works unchanged — `Field.Label` reaches the accessible name, and
283
+ `Field.Error` is announced via `aria-describedby`.
284
+ - **`disabled` arrives as `aria-disabled` + `data-disabled`**, since your element may not be a
285
+ `<button>`. The popover refuses to open either way, in the open direction only — closing is never
286
+ blocked, so disabling a form mid-submit cannot strand an open popover.
287
+ - **Your element must be natively focusable and keyboard-activatable** — a `<button>` or `<a>`, not
288
+ a styled `<div>`. No key handler is attached under `asChild`; it relies on the child turning
289
+ Enter/Space into a click, which only real interactive elements do.
290
+
291
+ Your child's `onClick` still runs; call `preventDefault()` in it to suppress the toggle.
292
+
231
293
  ## Component names, and what isn't there
232
294
 
233
295
  43 components. If you are hunting for a name: **Alert → `Notice`**, **Menu → `Dropdown`**,
234
296
  **Table → `DataTable`**, **Pagination → `Pager`**, **Drawer → `Sidebar`** (drawer mode),
235
297
  **Badge → `Chip`** or `ContentIndicator`, **Spinner → `Progress`** or `Button loading`.
236
- No Toast/Snackbar, no Breadcrumb, no Skeleton, and no time picker — `DatePicker` and
237
- `DateRangePicker` are dates only.
298
+ No Toast/Snackbar, no Breadcrumb, no Skeleton, and no *standalone* time picker — but
299
+ `DatePicker` / `DateRangePicker` take `withTime` for an hour/minute field (12- or 24-hour via
300
+ `hour12`) plus a display-only `zoneLabel`; the value is a plain `Date` with wall-clock semantics,
301
+ so timezone interpretation stays yours.
238
302
 
239
303
  Two clusters are easy to pick wrong:
240
304