rift-ds 1.24.0 → 1.25.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.
Files changed (99) hide show
  1. package/README.md +4 -4
  2. package/chat/ChatWidget.d.ts +5 -1
  3. package/chat/ChatWidget.js +12 -1
  4. package/components/Attachment/Attachment.css +8 -0
  5. package/components/Attachment/AttachmentViewer.js +26 -5
  6. package/components/Attachment/fileTypes.d.ts +4 -0
  7. package/components/CurrencyInput/CurrencyInput.css +12 -0
  8. package/components/CurrencyInput/CurrencyInput.d.ts +51 -0
  9. package/components/CurrencyInput/CurrencyInput.js +158 -0
  10. package/components/DataTable/columnTypes.js +4 -16
  11. package/components/DatePicker/DatePicker.d.ts +2 -0
  12. package/components/DatePicker/DatePicker.js +44 -131
  13. package/components/DatePicker/MonthGrid.d.ts +56 -0
  14. package/components/DatePicker/MonthGrid.js +65 -0
  15. package/components/DatePicker/calendar.d.ts +42 -0
  16. package/components/DatePicker/calendar.js +108 -0
  17. package/components/DateRangePicker/DateRangePicker.css +92 -0
  18. package/components/DateRangePicker/DateRangePicker.d.ts +86 -0
  19. package/components/DateRangePicker/DateRangePicker.js +294 -0
  20. package/components/Deadline/Deadline.css +82 -0
  21. package/components/Deadline/Deadline.d.ts +44 -0
  22. package/components/Deadline/Deadline.js +94 -0
  23. package/components/Deadline/deadlineStatus.d.ts +15 -0
  24. package/components/Deadline/deadlineStatus.js +13 -0
  25. package/components/DescriptionList/DescriptionList.css +184 -0
  26. package/components/DescriptionList/DescriptionList.d.ts +64 -0
  27. package/components/DescriptionList/DescriptionList.js +100 -0
  28. package/components/DescriptionList/DescriptionListCopy.d.ts +18 -0
  29. package/components/DescriptionList/DescriptionListCopy.js +45 -0
  30. package/components/DocumentViewer/DocumentViewer.css +188 -0
  31. package/components/DocumentViewer/DocumentViewer.d.ts +59 -0
  32. package/components/DocumentViewer/DocumentViewer.js +185 -0
  33. package/components/ErrorSummary/ErrorSummary.css +94 -0
  34. package/components/ErrorSummary/ErrorSummary.d.ts +34 -0
  35. package/components/ErrorSummary/ErrorSummary.js +70 -0
  36. package/components/ErrorSummary/fieldErrors.d.ts +36 -0
  37. package/components/ErrorSummary/fieldErrors.js +19 -0
  38. package/components/Field/Field.css +12 -0
  39. package/components/Field/Field.d.ts +10 -2
  40. package/components/Field/Field.js +12 -5
  41. package/components/Heading/Heading.css +129 -0
  42. package/components/Heading/Heading.d.ts +31 -0
  43. package/components/Heading/Heading.js +39 -0
  44. package/components/Input/Input.css +120 -0
  45. package/components/Input/Input.d.ts +20 -1
  46. package/components/Input/Input.js +70 -5
  47. package/components/Link/Link.css +84 -0
  48. package/components/Link/Link.d.ts +43 -0
  49. package/components/Link/Link.js +74 -0
  50. package/components/List/List.css +173 -0
  51. package/components/List/List.d.ts +44 -0
  52. package/components/List/List.js +60 -0
  53. package/components/MaskedInput/MaskedInput.css +16 -0
  54. package/components/MaskedInput/MaskedInput.d.ts +57 -0
  55. package/components/MaskedInput/MaskedInput.js +142 -0
  56. package/components/MaskedInput/mask.d.ts +58 -0
  57. package/components/MaskedInput/mask.js +106 -0
  58. package/components/ShaderScene/ShaderScene.css +19 -0
  59. package/components/ShaderScene/ShaderScene.d.ts +82 -0
  60. package/components/ShaderScene/ShaderScene.js +144 -0
  61. package/components/ShaderScene/assemble.d.ts +5 -0
  62. package/components/ShaderScene/assemble.js +74 -0
  63. package/components/ShaderScene/common.glsl.d.ts +6 -0
  64. package/components/ShaderScene/common.glsl.js +49 -0
  65. package/components/ShaderScene/passes.d.ts +2 -0
  66. package/components/ShaderScene/passes.js +93 -0
  67. package/components/ShaderScene/renderer.d.ts +35 -0
  68. package/components/ShaderScene/renderer.js +125 -0
  69. package/components/ShaderScene/scenes.d.ts +20 -0
  70. package/components/ShaderScene/scenes.js +184 -0
  71. package/components/ShaderScene/types.d.ts +70 -0
  72. package/components/ShaderScene/types.js +8 -0
  73. package/components/SignaturePad/SignaturePad.css +141 -0
  74. package/components/SignaturePad/SignaturePad.d.ts +68 -0
  75. package/components/SignaturePad/SignaturePad.js +287 -0
  76. package/components/SignaturePad/signature.d.ts +32 -0
  77. package/components/SignaturePad/signature.js +46 -0
  78. package/components/Text/Text.css +129 -0
  79. package/components/Text/Text.d.ts +36 -0
  80. package/components/Text/Text.js +36 -0
  81. package/components/Widget/Widget.css +111 -0
  82. package/components/Widget/Widget.d.ts +15 -1
  83. package/components/Widget/Widget.js +63 -11
  84. package/components/Widget/WidgetDisclosure.d.ts +30 -0
  85. package/components/Widget/WidgetDisclosure.js +52 -0
  86. package/components/registry.json +111 -2
  87. package/components/registry.json.d.ts +111 -2
  88. package/components/registry.json.js +2 -2
  89. package/format/index.d.ts +15 -0
  90. package/format/index.js +17 -0
  91. package/format/money.d.ts +89 -0
  92. package/format/money.js +187 -0
  93. package/format/relative.d.ts +49 -0
  94. package/format/relative.js +50 -0
  95. package/index.d.ts +13 -0
  96. package/index.js +46 -0
  97. package/package.json +9 -2
  98. package/tokens/motion.d.ts +4 -0
  99. package/tokens/motion.js +4 -0
@@ -0,0 +1,173 @@
1
+ /* ============================================
2
+ LIST
3
+ Every marker sits in one gutter at the list's
4
+ inline start: the native disc and number, the
5
+ form controls' check, a named icon drawn by
6
+ the icon font in ::before, or an item's own
7
+ icon. The marker box is one line of the item's
8
+ text tall, so it centres on the first line
9
+ however the label wraps.
10
+ ============================================ */
11
+
12
+ /* Base */
13
+ .ds-list {
14
+ --ds-list-gutter: calc(var(--icon-size-500) + var(--gap-200));
15
+ display: flex;
16
+ flex-direction: column;
17
+ gap: var(--ds-list-gap);
18
+ margin: 0;
19
+ padding: 0;
20
+ padding-inline-start: var(--ds-list-gutter);
21
+ color: var(--color-text-primary);
22
+ list-style: none;
23
+ }
24
+
25
+ .ds-list__item {
26
+ position: relative;
27
+ display: flex;
28
+ flex-direction: column;
29
+ gap: var(--gap-050);
30
+ min-inline-size: 0;
31
+ }
32
+
33
+ .ds-list__label {
34
+ overflow-wrap: break-word;
35
+ }
36
+
37
+ .ds-list__description {
38
+ color: var(--color-text-secondary);
39
+ font-family: var(--font-paragraph-sm-family);
40
+ font-size: var(--font-paragraph-sm-size);
41
+ font-weight: var(--font-paragraph-sm-weight);
42
+ line-height: var(--font-paragraph-sm-line-height);
43
+ letter-spacing: var(--font-paragraph-sm-letter-spacing);
44
+ }
45
+
46
+ /* Sizes */
47
+ .ds-list--default {
48
+ font-family: var(--font-paragraph-family);
49
+ font-size: var(--font-paragraph-size);
50
+ font-weight: var(--font-paragraph-weight);
51
+ line-height: var(--font-paragraph-line-height);
52
+ letter-spacing: var(--font-paragraph-letter-spacing);
53
+ }
54
+
55
+ .ds-list--compact {
56
+ font-family: var(--font-paragraph-sm-family);
57
+ font-size: var(--font-paragraph-sm-size);
58
+ font-weight: var(--font-paragraph-sm-weight);
59
+ line-height: var(--font-paragraph-sm-line-height);
60
+ letter-spacing: var(--font-paragraph-sm-letter-spacing);
61
+ }
62
+
63
+ .ds-list--compact .ds-list__description {
64
+ font-size: var(--font-caption-size);
65
+ line-height: var(--font-caption-line-height);
66
+ }
67
+
68
+ /* Spacing */
69
+ .ds-list--spacing-compact {
70
+ --ds-list-gap: var(--gap-050);
71
+ }
72
+
73
+ .ds-list--spacing-default {
74
+ --ds-list-gap: var(--gap-200);
75
+ }
76
+
77
+ .ds-list--spacing-relaxed {
78
+ --ds-list-gap: var(--gap-400);
79
+ }
80
+
81
+ /* Markers: the gutter box every drawn marker sits in */
82
+ .ds-list__marker,
83
+ .ds-list--marker-icon .ds-list__item::before {
84
+ position: absolute;
85
+ inset-block-start: 0;
86
+ inset-inline-start: calc(-1 * var(--ds-list-gutter));
87
+ display: flex;
88
+ align-items: center;
89
+ justify-content: center;
90
+ inline-size: var(--icon-size-500);
91
+ block-size: 1lh;
92
+ --icon-size: var(--icon-size-500);
93
+ color: var(--color-text-secondary);
94
+ }
95
+
96
+ /* Native markers: disc and number */
97
+ .ds-list--marker-disc {
98
+ list-style: disc;
99
+ }
100
+
101
+ .ds-list--marker-number {
102
+ list-style: decimal;
103
+ }
104
+
105
+ .ds-list--marker-disc .ds-list__item,
106
+ .ds-list--marker-number .ds-list__item {
107
+ display: list-item;
108
+ }
109
+
110
+ .ds-list--marker-disc .ds-list__item > * + *,
111
+ .ds-list--marker-number .ds-list__item > * + * {
112
+ margin-block-start: var(--gap-050);
113
+ }
114
+
115
+ .ds-list--marker-disc .ds-list__description,
116
+ .ds-list--marker-number .ds-list__description {
117
+ display: block;
118
+ }
119
+
120
+ .ds-list__item::marker {
121
+ color: var(--color-text-secondary);
122
+ font-variant-numeric: tabular-nums;
123
+ }
124
+
125
+ /* The tick: the form controls' CheckIcon, drawn only in a check list */
126
+ .ds-list__tick {
127
+ display: none;
128
+ }
129
+
130
+ .ds-list--marker-check .ds-list__tick {
131
+ display: flex;
132
+ color: var(--color-status-positive-text);
133
+ }
134
+
135
+ .ds-list__tick-glyph {
136
+ inline-size: var(--icon-size-500);
137
+ block-size: var(--icon-size-500);
138
+ padding: var(--padding-050);
139
+ box-sizing: border-box;
140
+ }
141
+
142
+ /* A named icon, drawn by the icon font from the list's custom property */
143
+ .ds-list--marker-icon .ds-list__item::before {
144
+ content: var(--ds-list-marker);
145
+ font-family: 'Material Symbols Rounded';
146
+ font-size: var(--icon-size);
147
+ line-height: 1;
148
+ font-feature-settings: 'liga';
149
+ -webkit-font-smoothing: antialiased;
150
+ }
151
+
152
+ /* An item's own icon replaces the list's marker */
153
+ .ds-list__item--icon {
154
+ display: flex;
155
+ list-style: none;
156
+ }
157
+
158
+ .ds-list .ds-list__item--icon::before {
159
+ content: none;
160
+ }
161
+
162
+ /* No marker, no gutter */
163
+ .ds-list--marker-none {
164
+ padding-inline-start: 0;
165
+ }
166
+
167
+ .ds-list--marker-none .ds-list__item--icon {
168
+ padding-inline-start: var(--ds-list-gutter);
169
+ }
170
+
171
+ .ds-list--marker-none .ds-list__item--icon .ds-list__marker {
172
+ inset-inline-start: 0;
173
+ }
@@ -0,0 +1,44 @@
1
+ import { default as React } from 'react';
2
+ /** Props owned by List itself; everything else falls through to the list element. */
3
+ type ListOwnProps = {
4
+ /** `unordered` is a `ul`, `ordered` an `ol` whose order means something (steps), `plain` a `ul` with no markers and no indent. */
5
+ variant?: 'unordered' | 'ordered' | 'plain';
6
+ /** The mark before each item: a disc, the item's number, the form controls' check, nothing, or a Material Symbol name (`star`, `bolt`). Defaults to the variant's own: disc, number, none. */
7
+ marker?: 'disc' | 'number' | 'check' | 'none' | (string & {});
8
+ /** The room between items: `compact` for dense lists, `relaxed` for items with descriptions. */
9
+ spacing?: 'compact' | 'default' | 'relaxed';
10
+ /** The items' type size: `default` the paragraph face, `compact` the small paragraph face. */
11
+ size?: 'default' | 'compact';
12
+ /** The number an ordered list counts from. */
13
+ start?: number;
14
+ /** Count an ordered list down instead of up. */
15
+ reversed?: boolean;
16
+ /** The items, each a `ListItem`. */
17
+ children?: React.ReactNode;
18
+ /** Additional CSS classes. */
19
+ className?: string;
20
+ };
21
+ export interface ListProps extends ListOwnProps, Omit<React.ComponentPropsWithRef<'ul'>, keyof ListOwnProps> {
22
+ }
23
+ /**
24
+ * A list of items, ordered or not, marked with a disc, a number, a check or
25
+ * an icon, each item optionally carrying a description under it: features,
26
+ * steps, requirements. Server-renderable.
27
+ */
28
+ export declare function List({ variant, marker, spacing, size, start, reversed, className, style, children, ref, ...rest }: ListProps): React.JSX.Element;
29
+ /** Props owned by ListItem itself; everything else falls through to the `li`. */
30
+ type ListItemOwnProps = {
31
+ /** The item's text. */
32
+ children?: React.ReactNode;
33
+ /** A line of quieter text under the item. */
34
+ description?: React.ReactNode;
35
+ /** A Material Symbol name or a node that replaces this item's marker. A directional glyph mirrors in a right-to-left context. */
36
+ icon?: string | React.ReactNode;
37
+ /** Additional CSS classes. */
38
+ className?: string;
39
+ };
40
+ export interface ListItemProps extends ListItemOwnProps, Omit<React.ComponentPropsWithRef<'li'>, keyof ListItemOwnProps> {
41
+ }
42
+ /** One item of a List, with an optional description and an icon of its own. Server-renderable. */
43
+ export declare function ListItem({ children, description, icon, className, ref, ...rest }: ListItemProps): React.JSX.Element;
44
+ export {};
@@ -0,0 +1,60 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import "react";
3
+ import { CheckIcon } from "../Checkbox/Checkbox.js";
4
+ import { mirrorClass } from "../../behaviors/direction.js";
5
+ import "../../fonts/material-symbols.css";
6
+ import "./List.css";
7
+ const NATIVE_MARKERS = /* @__PURE__ */ new Set(["disc", "number", "check", "none"]);
8
+ function List({
9
+ variant = "unordered",
10
+ marker,
11
+ spacing = "default",
12
+ size = "default",
13
+ start,
14
+ reversed,
15
+ className = "",
16
+ style,
17
+ children,
18
+ ref,
19
+ ...rest
20
+ }) {
21
+ const resolvedMarker = marker ?? (variant === "ordered" ? "number" : variant === "plain" ? "none" : "disc");
22
+ const iconMarker = !NATIVE_MARKERS.has(resolvedMarker);
23
+ const classes = [
24
+ "ds-list",
25
+ `ds-list--${variant}`,
26
+ `ds-list--marker-${iconMarker ? "icon" : resolvedMarker}`,
27
+ `ds-list--spacing-${spacing}`,
28
+ `ds-list--${size}`,
29
+ className
30
+ ].filter(Boolean).join(" ");
31
+ const resolvedStyle = iconMarker ? { ...style, "--ds-list-marker": JSON.stringify(resolvedMarker) } : style;
32
+ if (variant === "ordered") {
33
+ return /* @__PURE__ */ jsx(
34
+ "ol",
35
+ {
36
+ ...rest,
37
+ ref,
38
+ start,
39
+ reversed,
40
+ className: classes,
41
+ style: resolvedStyle,
42
+ children
43
+ }
44
+ );
45
+ }
46
+ return /* @__PURE__ */ jsx("ul", { ...rest, ref, className: classes, style: resolvedStyle, children });
47
+ }
48
+ function ListItem({ children, description, icon, className = "", ref, ...rest }) {
49
+ const hasIcon = icon != null && icon !== false;
50
+ const classes = ["ds-list__item", hasIcon && "ds-list__item--icon", className].filter(Boolean).join(" ");
51
+ return /* @__PURE__ */ jsxs("li", { ...rest, ref, className: classes, children: [
52
+ hasIcon ? typeof icon === "string" ? /* @__PURE__ */ jsx("span", { className: `ds-list__marker material-symbols-rounded ${mirrorClass(icon)}`, "aria-hidden": "true", children: icon }) : /* @__PURE__ */ jsx("span", { className: "ds-list__marker", "aria-hidden": "true", children: icon }) : /* @__PURE__ */ jsx("span", { className: "ds-list__marker ds-list__tick", "aria-hidden": "true", children: /* @__PURE__ */ jsx(CheckIcon, { className: "ds-list__tick-glyph" }) }),
53
+ /* @__PURE__ */ jsx("span", { className: "ds-list__label", children }),
54
+ description != null && description !== false && /* @__PURE__ */ jsx("span", { className: "ds-list__description", children: description })
55
+ ] });
56
+ }
57
+ export {
58
+ List,
59
+ ListItem
60
+ };
@@ -0,0 +1,16 @@
1
+ /* ============================================
2
+ MASKED INPUT
3
+ An Input whose text the mask writes; the field,
4
+ its states and its action slot are Input's.
5
+ Tabular figures keep the separators still as
6
+ digits arrive, and a hidden value's dots are
7
+ spaced so each stands for one character.
8
+ ============================================ */
9
+
10
+ .ds-masked-input .ds-input__field {
11
+ font-variant-numeric: tabular-nums;
12
+ }
13
+
14
+ .ds-masked-input--concealed .ds-input__field {
15
+ letter-spacing: var(--font-overline-letter-spacing);
16
+ }
@@ -0,0 +1,57 @@
1
+ import { default as React } from 'react';
2
+ import { Mask } from './mask';
3
+ /** Props owned by MaskedInput itself; everything else falls through to the visible `<input>`. */
4
+ type MaskedInputOwnProps = {
5
+ /** Label text above the field. */
6
+ label?: string;
7
+ /** The shape of the value: a pattern where `#` takes a digit, `A` a letter and `*` either (`'(###) ###-####'`), or a function from the raw characters to the shown text. `MASK_PRESETS` holds common patterns. */
8
+ mask: Mask;
9
+ /** The raw value, the characters without the mask's separators (`"5550100199"`) (controlled). Pair with `onValueChange`. */
10
+ value?: string;
11
+ /** The raw value the field starts with (uncontrolled). */
12
+ defaultValue?: string;
13
+ /** Called with the raw value and the shown text as the reader types. Fires alongside the native `onChange`. */
14
+ onValueChange?: (value: string, formatted: string) => void;
15
+ /** Hide the value as dots until it is revealed: a tax ID, a card number. Defaults `autoComplete` to `off`. */
16
+ sensitive?: boolean;
17
+ /** Add a show and hide button to a sensitive field. */
18
+ revealable?: boolean;
19
+ /** Whether a sensitive value is shown (controlled). Pair with `onRevealedChange`. */
20
+ revealed?: boolean;
21
+ /** Whether a sensitive value starts shown (uncontrolled). Defaults to false. */
22
+ defaultRevealed?: boolean;
23
+ /** Called with the new state when the reader shows or hides the value, or it hides itself. */
24
+ onRevealedChange?: (revealed: boolean) => void;
25
+ /** How many of the last characters of a hidden value stay readable while the field is not focused, so a reader can tell which card it is. Defaults to 0. */
26
+ visibleTail?: number;
27
+ /** Hide a revealed value again after this many milliseconds, or after the library's reveal timeout with `true`. Off by default. */
28
+ autoHideAfter?: number | boolean;
29
+ /** Accessible name of the reveal button while the value is hidden. Defaults to "Show". */
30
+ showLabel?: string;
31
+ /** Accessible name of the reveal button while the value is shown. Defaults to "Hide". */
32
+ hideLabel?: string;
33
+ /** Component size (not the native character-width `size` attribute). */
34
+ size?: 'default' | 'compact';
35
+ /** Helper text below the field. */
36
+ helperText?: string;
37
+ /** The error message under the field; setting it marks the field invalid. */
38
+ errorText?: React.ReactNode;
39
+ /** Error state without a message of its own. */
40
+ error?: boolean;
41
+ /** The form field name. The form receives the raw value through a hidden input, never the shown text. */
42
+ name?: string;
43
+ /** Additional CSS classes, applied to the wrapper. */
44
+ className?: string;
45
+ };
46
+ export interface MaskedInputProps extends MaskedInputOwnProps, Omit<React.ComponentPropsWithRef<'input'>, keyof MaskedInputOwnProps | 'type' | 'prefix'> {
47
+ }
48
+ /**
49
+ * A field that writes its value into a shape as the reader types: a phone
50
+ * number, a card number, an ID number, a licence key. The value is the raw
51
+ * characters; the separators are the field's, the caret holds its place
52
+ * across them, and a paste is cleaned up. A sensitive value hides as dots
53
+ * until the reader shows it.
54
+ */
55
+ export declare function MaskedInput({ label, mask, value: valueProp, defaultValue, onValueChange, sensitive, revealable, revealed: revealedProp, defaultRevealed, onRevealedChange, visibleTail, autoHideAfter, showLabel, hideLabel, size, helperText, errorText, error, name, disabled, className, onChange, onFocus, onBlur, ref, ...rest }: MaskedInputProps): React.JSX.Element;
56
+ export { MASK_PRESETS, applyMask } from './mask';
57
+ export type { Mask, Masked } from './mask';
@@ -0,0 +1,142 @@
1
+ "use client";
2
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
3
+ import { useState, useMemo, useRef, useLayoutEffect, useEffect } from "react";
4
+ import { Input } from "../Input/Input.js";
5
+ import { CircularButton } from "../CircularButton/CircularButton.js";
6
+ import { MOTION_SENSITIVE_HIDE_MS } from "../../tokens/motion.js";
7
+ import { applyMask, concealMasked, maskIsNumeric, readEdit, maskCapacity, caretFor } from "./mask.js";
8
+ import { MASK_PRESETS } from "./mask.js";
9
+ import "./MaskedInput.css";
10
+ function MaskedInput({
11
+ label,
12
+ mask,
13
+ value: valueProp,
14
+ defaultValue = "",
15
+ onValueChange,
16
+ sensitive = false,
17
+ revealable = false,
18
+ revealed: revealedProp,
19
+ defaultRevealed = false,
20
+ onRevealedChange,
21
+ visibleTail = 0,
22
+ autoHideAfter = false,
23
+ showLabel = "Show",
24
+ hideLabel = "Hide",
25
+ size = "default",
26
+ helperText,
27
+ errorText,
28
+ error,
29
+ name,
30
+ disabled,
31
+ className = "",
32
+ onChange,
33
+ onFocus,
34
+ onBlur,
35
+ ref,
36
+ ...rest
37
+ }) {
38
+ const controlled = valueProp !== void 0;
39
+ const [uncontrolled, setUncontrolled] = useState(() => applyMask(defaultValue, mask).raw);
40
+ const raw = controlled ? applyMask(valueProp, mask).raw : uncontrolled;
41
+ const masked = useMemo(() => applyMask(raw, mask), [raw, mask]);
42
+ const revealControlled = revealedProp !== void 0;
43
+ const [uncontrolledRevealed, setUncontrolledRevealed] = useState(defaultRevealed);
44
+ const revealed = !sensitive || (revealControlled ? revealedProp : uncontrolledRevealed);
45
+ const setRevealed = (next) => {
46
+ if (!revealControlled) setUncontrolledRevealed(next);
47
+ onRevealedChange?.(next);
48
+ };
49
+ const [focused, setFocused] = useState(false);
50
+ const shown = revealed ? masked.text : concealMasked(masked, focused ? 0 : visibleTail);
51
+ const inputRef = useRef(null);
52
+ const setRef = (node) => {
53
+ inputRef.current = node;
54
+ if (typeof ref === "function") ref(node);
55
+ else if (ref) ref.current = node;
56
+ };
57
+ const pendingCaret = useRef(null);
58
+ const lastInputType = useRef(void 0);
59
+ useLayoutEffect(() => {
60
+ const input = inputRef.current;
61
+ if (pendingCaret.current == null || !input || document.activeElement !== input) return;
62
+ input.setSelectionRange(pendingCaret.current, pendingCaret.current);
63
+ pendingCaret.current = null;
64
+ });
65
+ const hideAfter = autoHideAfter === true ? MOTION_SENSITIVE_HIDE_MS : autoHideAfter || 0;
66
+ const revealedNow = sensitive && revealed;
67
+ useEffect(() => {
68
+ if (!revealedNow || hideAfter <= 0) return;
69
+ const timer = window.setTimeout(() => setRevealed(false), hideAfter);
70
+ return () => window.clearTimeout(timer);
71
+ }, [revealedNow, hideAfter]);
72
+ const handleBeforeInput = (event) => {
73
+ lastInputType.current = event.nativeEvent.inputType;
74
+ };
75
+ const handleChange = (event) => {
76
+ const inputType = event.nativeEvent.inputType ?? lastInputType.current;
77
+ const edit = readEdit({ ...masked, text: shown }, event.target.value, inputType);
78
+ const capped = [...edit.raw].slice(0, maskCapacity(mask)).join("");
79
+ const next = applyMask(capped, mask);
80
+ pendingCaret.current = caretFor(next, Math.min(edit.caretRaw, next.slots.filter(Boolean).length));
81
+ onChange?.(event);
82
+ if (next.raw === raw) {
83
+ const input = event.target;
84
+ const caret = pendingCaret.current;
85
+ requestAnimationFrame(() => input.setSelectionRange(caret, caret));
86
+ return;
87
+ }
88
+ if (!controlled) setUncontrolled(next.raw);
89
+ onValueChange?.(next.raw, next.text);
90
+ };
91
+ const revealButton = sensitive && revealable ? /* @__PURE__ */ jsx(
92
+ CircularButton,
93
+ {
94
+ icon: revealed ? "visibility_off" : "visibility",
95
+ variant: "tertiary",
96
+ size: "compact",
97
+ ariaLabel: revealed ? hideLabel : showLabel,
98
+ "aria-pressed": revealed,
99
+ disabled,
100
+ onClick: () => setRevealed(!revealed)
101
+ }
102
+ ) : void 0;
103
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
104
+ /* @__PURE__ */ jsx(
105
+ Input,
106
+ {
107
+ autoComplete: sensitive ? "off" : void 0,
108
+ spellCheck: false,
109
+ ...rest,
110
+ id: rest.id ?? name,
111
+ ref: setRef,
112
+ className: ["ds-masked-input", sensitive && !revealed && "ds-masked-input--concealed", className].filter(Boolean).join(" "),
113
+ label,
114
+ size,
115
+ type: "text",
116
+ inputMode: rest.inputMode ?? (maskIsNumeric(mask) ? "numeric" : void 0),
117
+ value: shown,
118
+ disabled,
119
+ error,
120
+ helperText,
121
+ errorText,
122
+ action: revealButton,
123
+ onBeforeInput: handleBeforeInput,
124
+ onChange: handleChange,
125
+ onFocus: (event) => {
126
+ setFocused(true);
127
+ onFocus?.(event);
128
+ },
129
+ onBlur: (event) => {
130
+ setFocused(false);
131
+ onBlur?.(event);
132
+ }
133
+ }
134
+ ),
135
+ name && /* @__PURE__ */ jsx("input", { type: "hidden", name, value: raw, disabled })
136
+ ] });
137
+ }
138
+ export {
139
+ MASK_PRESETS,
140
+ MaskedInput,
141
+ applyMask
142
+ };
@@ -0,0 +1,58 @@
1
+ /**
2
+ * The mask engine behind MaskedInput: a pattern or a function turns the raw
3
+ * characters a person typed into the text the field shows, and a typed edit
4
+ * of the shown text back into raw characters. No React, so a server can
5
+ * format a stored value the same way.
6
+ *
7
+ * A pattern is a string where `#` takes a digit, `A` a letter, `*` either,
8
+ * and every other character is written as it stands: `(###) ###-####`.
9
+ * Letters keep the case they were typed in; a function mask can change it.
10
+ */
11
+ /** A pattern string, or a function from the raw characters to the shown text. */
12
+ export type Mask = string | ((raw: string) => string);
13
+ /** Ready-made patterns. They are data, not a claim about any locale: pick the one that matches what you collect. */
14
+ export declare const MASK_PRESETS: {
15
+ /** A ten-digit phone number in the US shape: `(555) 010-0199`. */
16
+ readonly phoneUs: "(###) ###-####";
17
+ /** A sixteen-digit card number in four groups: `4242 4242 4242 4242`. */
18
+ readonly card: "#### #### #### ####";
19
+ /** A nine-digit ID number in three groups: `123-45-6789`. */
20
+ readonly idNumber: "###-##-####";
21
+ /** A five-digit postal code with an optional four-digit extension: `94107-1234`. */
22
+ readonly postalCode: "#####-####";
23
+ /** A licence key of four blocks of four letters or digits: `AB12-CD34-EF56-GH78`. */
24
+ readonly licenceKey: "****-****-****-****";
25
+ };
26
+ /** The shown text, and which of its characters stand for a raw character (the rest are the mask's literals). */
27
+ export type Masked = {
28
+ text: string;
29
+ raw: string;
30
+ slots: boolean[];
31
+ };
32
+ /** How many raw characters a pattern holds, or Infinity for a function mask. */
33
+ export declare function maskCapacity(mask: Mask): number;
34
+ /** Whether every slot in a pattern takes a digit, so the field can ask for the numeric keyboard. */
35
+ export declare function maskIsNumeric(mask: Mask): boolean;
36
+ /**
37
+ * Raw characters through the mask. A character that fits no slot is
38
+ * dropped; literals are written only up to the last filled slot, so a
39
+ * half-typed number never ends in a dangling separator.
40
+ */
41
+ export declare function applyMask(raw: string, mask: Mask): Masked;
42
+ /** What an edit of the shown text did to the raw value, and where the caret goes. */
43
+ export type MaskEdit = {
44
+ raw: string;
45
+ caretRaw: number;
46
+ };
47
+ /**
48
+ * Read an edit of the shown text back into raw characters. The two texts
49
+ * are compared from each end; whatever the person removed is taken out of
50
+ * the raw value by slot, whatever they typed or pasted goes in, and
51
+ * removing only a separator (Backspace just after a dash) removes the raw
52
+ * character before it, which is what the person meant.
53
+ */
54
+ export declare function readEdit(previous: Masked, nextText: string, inputType?: string): MaskEdit;
55
+ /** The position in the shown text just after `count` raw characters. */
56
+ export declare function caretFor(masked: Masked, count: number): number;
57
+ /** The shown text with its raw characters hidden as dots, all but the last `visibleTail`. */
58
+ export declare function concealMasked(masked: Masked, visibleTail?: number, dot?: string): string;
@@ -0,0 +1,106 @@
1
+ const MASK_PRESETS = {
2
+ /** A ten-digit phone number in the US shape: `(555) 010-0199`. */
3
+ phoneUs: "(###) ###-####",
4
+ /** A sixteen-digit card number in four groups: `4242 4242 4242 4242`. */
5
+ card: "#### #### #### ####",
6
+ /** A nine-digit ID number in three groups: `123-45-6789`. */
7
+ idNumber: "###-##-####",
8
+ /** A five-digit postal code with an optional four-digit extension: `94107-1234`. */
9
+ postalCode: "#####-####",
10
+ /** A licence key of four blocks of four letters or digits: `AB12-CD34-EF56-GH78`. */
11
+ licenceKey: "****-****-****-****"
12
+ };
13
+ const TOKENS = { "#": new RegExp("\\p{Nd}", "u"), A: new RegExp("\\p{L}", "u"), "*": /[\p{L}\p{Nd}]/u };
14
+ const RAW_CHAR = /[\p{L}\p{Nd}]/u;
15
+ function maskCapacity(mask) {
16
+ return typeof mask === "string" ? [...mask].filter((c) => c in TOKENS).length : Infinity;
17
+ }
18
+ function maskIsNumeric(mask) {
19
+ return typeof mask === "string" && [...mask].every((c) => c === "#" || !(c in TOKENS));
20
+ }
21
+ function applyMask(raw, mask) {
22
+ const chars = [...raw].filter((c) => RAW_CHAR.test(c));
23
+ if (typeof mask === "function") {
24
+ const text2 = mask(chars.join(""));
25
+ const slots2 = [...text2].map((c) => RAW_CHAR.test(c));
26
+ return { text: text2, raw: [...text2].filter((c) => RAW_CHAR.test(c)).join(""), slots: slots2 };
27
+ }
28
+ let text = "";
29
+ let pending = "";
30
+ const slots = [];
31
+ const pendingSlots = [];
32
+ const kept = [];
33
+ let i = 0;
34
+ for (const m of mask) {
35
+ if (i >= chars.length) break;
36
+ const token = TOKENS[m];
37
+ if (!token) {
38
+ pending += m;
39
+ pendingSlots.push(false);
40
+ continue;
41
+ }
42
+ while (i < chars.length && !token.test(chars[i])) i++;
43
+ if (i >= chars.length) break;
44
+ text += pending + chars[i];
45
+ slots.push(...pendingSlots, true);
46
+ pending = "";
47
+ pendingSlots.length = 0;
48
+ kept.push(chars[i]);
49
+ i++;
50
+ }
51
+ return { text, raw: kept.join(""), slots };
52
+ }
53
+ function readEdit(previous, nextText, inputType) {
54
+ const before = [...previous.text];
55
+ const after = [...nextText];
56
+ let start = 0;
57
+ while (start < before.length && start < after.length && before[start] === after[start]) start++;
58
+ let endBefore = before.length;
59
+ let endAfter = after.length;
60
+ while (endBefore > start && endAfter > start && before[endBefore - 1] === after[endAfter - 1]) {
61
+ endBefore--;
62
+ endAfter--;
63
+ }
64
+ const rawIndex = (displayIndex) => previous.slots.slice(0, displayIndex).filter(Boolean).length;
65
+ let rawStart = rawIndex(start);
66
+ const rawEnd = rawIndex(endBefore);
67
+ const inserted = after.slice(start, endAfter).filter((c) => RAW_CHAR.test(c)).join("");
68
+ const rawChars = [...previous.raw];
69
+ if (inserted === "" && rawStart === rawEnd && endBefore > start) {
70
+ if (inputType === "deleteContentForward") rawChars.splice(rawStart, 1);
71
+ else if (rawStart > 0) {
72
+ rawChars.splice(rawStart - 1, 1);
73
+ rawStart -= 1;
74
+ }
75
+ return { raw: rawChars.join(""), caretRaw: rawStart };
76
+ }
77
+ rawChars.splice(rawStart, rawEnd - rawStart, ...inserted);
78
+ return { raw: rawChars.join(""), caretRaw: rawStart + [...inserted].length };
79
+ }
80
+ function caretFor(masked, count) {
81
+ if (count <= 0) return 0;
82
+ let seen = 0;
83
+ for (let i = 0; i < masked.slots.length; i++) {
84
+ if (masked.slots[i]) seen++;
85
+ if (seen === count) return i + 1;
86
+ }
87
+ return masked.text.length;
88
+ }
89
+ function concealMasked(masked, visibleTail = 0, dot = "•") {
90
+ const total = masked.slots.filter(Boolean).length;
91
+ let seen = 0;
92
+ return [...masked.text].map((c, i) => {
93
+ if (!masked.slots[i]) return c;
94
+ seen++;
95
+ return seen > total - visibleTail ? c : dot;
96
+ }).join("");
97
+ }
98
+ export {
99
+ MASK_PRESETS,
100
+ applyMask,
101
+ caretFor,
102
+ concealMasked,
103
+ maskCapacity,
104
+ maskIsNumeric,
105
+ readEdit
106
+ };
@@ -0,0 +1,19 @@
1
+ /* ShaderScene: the canvas, filling its positioned ancestor.
2
+ Placement and clipping belong to that ancestor, as with ShaderField: where
3
+ a scene sits is a layout decision. The ground under the canvas is the
4
+ page's, so a machine that cannot run WebGL2 shows the plain page. */
5
+
6
+ .ds-shader-scene {
7
+ position: absolute;
8
+ inset: 0;
9
+ overflow: hidden;
10
+ /* Scenery, never a target. */
11
+ pointer-events: none;
12
+ background-color: var(--color-bg-page-primary);
13
+ }
14
+
15
+ .ds-shader-scene__canvas {
16
+ display: block;
17
+ width: 100%;
18
+ height: 100%;
19
+ }