rift-ds 1.23.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.
- package/README.md +4 -4
- package/behaviors/shell.css +119 -0
- package/bin/templates/blocks/components/blocks/AppShell.module.css +69 -15
- package/bin/templates/blocks/components/blocks/AppShell.tsx +45 -30
- package/bin/templates/blocks/registry.json +1 -1
- package/chat/ChatAgentPane.css +6 -6
- package/chat/ChatLauncher.d.ts +3 -3
- package/chat/ChatWidget.css +260 -8
- package/chat/ChatWidget.d.ts +41 -6
- package/chat/ChatWidget.js +49 -2
- package/chat/index.d.ts +1 -1
- package/chat/registry.json.d.ts +1 -1
- package/chat/registry.json.js +1 -1
- package/components/AppLayout/AppLayout.css +17 -4
- package/components/AppLayout/AppLayout.d.ts +8 -5
- package/components/AppLayout/AppLayout.js +2 -0
- package/components/AppSidebar/AppSidebar.css +108 -23
- package/components/AppSidebar/AppSidebar.d.ts +8 -5
- package/components/AppSidebar/AppSidebar.js +6 -3
- package/components/Attachment/Attachment.css +8 -0
- package/components/Attachment/AttachmentViewer.js +26 -5
- package/components/Attachment/fileTypes.d.ts +4 -0
- package/components/CurrencyInput/CurrencyInput.css +12 -0
- package/components/CurrencyInput/CurrencyInput.d.ts +51 -0
- package/components/CurrencyInput/CurrencyInput.js +158 -0
- package/components/DataTable/columnTypes.js +4 -16
- package/components/DatePicker/DatePicker.d.ts +2 -0
- package/components/DatePicker/DatePicker.js +44 -131
- package/components/DatePicker/MonthGrid.d.ts +56 -0
- package/components/DatePicker/MonthGrid.js +65 -0
- package/components/DatePicker/calendar.d.ts +42 -0
- package/components/DatePicker/calendar.js +108 -0
- package/components/DateRangePicker/DateRangePicker.css +92 -0
- package/components/DateRangePicker/DateRangePicker.d.ts +86 -0
- package/components/DateRangePicker/DateRangePicker.js +294 -0
- package/components/Deadline/Deadline.css +82 -0
- package/components/Deadline/Deadline.d.ts +44 -0
- package/components/Deadline/Deadline.js +94 -0
- package/components/Deadline/deadlineStatus.d.ts +15 -0
- package/components/Deadline/deadlineStatus.js +13 -0
- package/components/DescriptionList/DescriptionList.css +184 -0
- package/components/DescriptionList/DescriptionList.d.ts +64 -0
- package/components/DescriptionList/DescriptionList.js +100 -0
- package/components/DescriptionList/DescriptionListCopy.d.ts +18 -0
- package/components/DescriptionList/DescriptionListCopy.js +45 -0
- package/components/DocumentViewer/DocumentViewer.css +188 -0
- package/components/DocumentViewer/DocumentViewer.d.ts +59 -0
- package/components/DocumentViewer/DocumentViewer.js +185 -0
- package/components/ErrorSummary/ErrorSummary.css +94 -0
- package/components/ErrorSummary/ErrorSummary.d.ts +34 -0
- package/components/ErrorSummary/ErrorSummary.js +70 -0
- package/components/ErrorSummary/fieldErrors.d.ts +36 -0
- package/components/ErrorSummary/fieldErrors.js +19 -0
- package/components/Field/Field.css +12 -0
- package/components/Field/Field.d.ts +10 -2
- package/components/Field/Field.js +12 -5
- package/components/Heading/Heading.css +129 -0
- package/components/Heading/Heading.d.ts +31 -0
- package/components/Heading/Heading.js +39 -0
- package/components/Input/Input.css +120 -0
- package/components/Input/Input.d.ts +20 -1
- package/components/Input/Input.js +70 -5
- package/components/Link/Link.css +84 -0
- package/components/Link/Link.d.ts +43 -0
- package/components/Link/Link.js +74 -0
- package/components/List/List.css +173 -0
- package/components/List/List.d.ts +44 -0
- package/components/List/List.js +60 -0
- package/components/MaskedInput/MaskedInput.css +16 -0
- package/components/MaskedInput/MaskedInput.d.ts +57 -0
- package/components/MaskedInput/MaskedInput.js +142 -0
- package/components/MaskedInput/mask.d.ts +58 -0
- package/components/MaskedInput/mask.js +106 -0
- package/components/ShaderScene/ShaderScene.css +19 -0
- package/components/ShaderScene/ShaderScene.d.ts +82 -0
- package/components/ShaderScene/ShaderScene.js +144 -0
- package/components/ShaderScene/assemble.d.ts +5 -0
- package/components/ShaderScene/assemble.js +74 -0
- package/components/ShaderScene/common.glsl.d.ts +6 -0
- package/components/ShaderScene/common.glsl.js +49 -0
- package/components/ShaderScene/passes.d.ts +2 -0
- package/components/ShaderScene/passes.js +93 -0
- package/components/ShaderScene/renderer.d.ts +35 -0
- package/components/ShaderScene/renderer.js +125 -0
- package/components/ShaderScene/scenes.d.ts +20 -0
- package/components/ShaderScene/scenes.js +184 -0
- package/components/ShaderScene/types.d.ts +70 -0
- package/components/ShaderScene/types.js +8 -0
- package/components/SignaturePad/SignaturePad.css +141 -0
- package/components/SignaturePad/SignaturePad.d.ts +68 -0
- package/components/SignaturePad/SignaturePad.js +287 -0
- package/components/SignaturePad/signature.d.ts +32 -0
- package/components/SignaturePad/signature.js +46 -0
- package/components/Text/Text.css +129 -0
- package/components/Text/Text.d.ts +36 -0
- package/components/Text/Text.js +36 -0
- package/components/ThemePicker/ThemePicker.css +6 -0
- package/components/ThemePicker/ThemePicker.js +20 -11
- package/components/ThreadPanel/ThreadPanel.css +65 -36
- package/components/ThreadPanel/ThreadPanel.d.ts +5 -5
- package/components/ThreadPanel/ThreadPanel.js +1 -1
- package/components/Widget/Widget.css +111 -0
- package/components/Widget/Widget.d.ts +15 -1
- package/components/Widget/Widget.js +63 -11
- package/components/Widget/WidgetDisclosure.d.ts +30 -0
- package/components/Widget/WidgetDisclosure.js +52 -0
- package/components/registry.json +112 -3
- package/components/registry.json.d.ts +112 -3
- package/components/registry.json.js +2 -2
- package/format/index.d.ts +15 -0
- package/format/index.js +17 -0
- package/format/money.d.ts +89 -0
- package/format/money.js +187 -0
- package/format/relative.d.ts +49 -0
- package/format/relative.js +50 -0
- package/index.d.ts +13 -0
- package/index.js +46 -0
- package/package.json +9 -2
- package/tokens/motion.d.ts +4 -0
- package/tokens/motion.js +4 -0
- package/tokens/presets/plum.css +234 -240
- package/tokens/tokens-dark.css +2 -2
- package/tokens/tokens-light.css +2 -2
- package/tokens/values.json.js +1 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/** A heading type style, named as the type scale names it, from the largest. */
|
|
3
|
+
export type HeadingTier = 'mega-1' | 'mega-2' | 'display-1' | 'display-2' | 'sub-display' | 'heading-1' | 'heading-2' | 'heading-3' | 'title-body';
|
|
4
|
+
/** Props owned by Heading itself; everything else falls through to the heading element. */
|
|
5
|
+
type HeadingOwnProps = {
|
|
6
|
+
/** The heading's place in the document outline, which sets the element (`h1` to `h6`). Choose it for the outline, never for the size. */
|
|
7
|
+
level?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
8
|
+
/** The type style it wears, apart from `level`, so a card's `h3` can look like a small title and a page's `h1` like a display line. Defaults to the level's own: heading-1 to heading-3 for levels 1 to 3, title-body below. */
|
|
9
|
+
tier?: HeadingTier;
|
|
10
|
+
/** The colour role: `default` takes the tier's own (the display or heading text colour a theme can tone), `neutral` the secondary text colour for a quieter title. */
|
|
11
|
+
tone?: 'default' | 'neutral';
|
|
12
|
+
/** Keep the heading on one line, ending in an ellipsis where it runs out of room. The full text stays in the accessible name. */
|
|
13
|
+
truncate?: boolean;
|
|
14
|
+
/** Balance the lines of a heading that wraps, so the last line is never a lone word. */
|
|
15
|
+
balance?: boolean;
|
|
16
|
+
/** Where the text sits on the line, along the reading direction. */
|
|
17
|
+
align?: 'start' | 'center' | 'end';
|
|
18
|
+
/** The heading's text. */
|
|
19
|
+
children?: React.ReactNode;
|
|
20
|
+
/** Additional CSS classes. */
|
|
21
|
+
className?: string;
|
|
22
|
+
};
|
|
23
|
+
export interface HeadingProps extends HeadingOwnProps, Omit<React.ComponentPropsWithRef<'h2'>, keyof HeadingOwnProps> {
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A heading in the type scale. `level` sets the element and `tier` the
|
|
27
|
+
* look, chosen apart, so the outline stays correct whatever size a design
|
|
28
|
+
* calls for. Server-renderable.
|
|
29
|
+
*/
|
|
30
|
+
export declare function Heading({ level, tier, tone, truncate, balance, align, className, children, ref, ...rest }: HeadingProps): React.JSX.Element;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import "./Heading.css";
|
|
4
|
+
const LEVEL_TIER = {
|
|
5
|
+
1: "heading-1",
|
|
6
|
+
2: "heading-2",
|
|
7
|
+
3: "heading-3",
|
|
8
|
+
4: "title-body",
|
|
9
|
+
5: "title-body",
|
|
10
|
+
6: "title-body"
|
|
11
|
+
};
|
|
12
|
+
function Heading({
|
|
13
|
+
level = 2,
|
|
14
|
+
tier,
|
|
15
|
+
tone = "default",
|
|
16
|
+
truncate = false,
|
|
17
|
+
balance = false,
|
|
18
|
+
align,
|
|
19
|
+
className = "",
|
|
20
|
+
children,
|
|
21
|
+
ref,
|
|
22
|
+
...rest
|
|
23
|
+
}) {
|
|
24
|
+
const Tag = `h${level}`;
|
|
25
|
+
const resolvedTier = tier ?? LEVEL_TIER[level];
|
|
26
|
+
const classes = [
|
|
27
|
+
"ds-heading",
|
|
28
|
+
`ds-heading--${resolvedTier}`,
|
|
29
|
+
tone !== "default" && `ds-heading--tone-${tone}`,
|
|
30
|
+
truncate && "ds-heading--truncate",
|
|
31
|
+
balance && "ds-heading--balance",
|
|
32
|
+
align && `ds-heading--align-${align}`,
|
|
33
|
+
className
|
|
34
|
+
].filter(Boolean).join(" ");
|
|
35
|
+
return /* @__PURE__ */ jsx(Tag, { ...rest, ref, className: classes, children });
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
Heading
|
|
39
|
+
};
|
|
@@ -154,3 +154,123 @@
|
|
|
154
154
|
padding-inline-end: calc(var(--padding-300) + 20px + var(--gap-200)); /* 12px + 20px icon + 8px gap */
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
+
|
|
158
|
+
/* ============================================
|
|
159
|
+
AFFIXED: a prefix, a suffix or a clear button
|
|
160
|
+
The wrapper becomes the field's box (border,
|
|
161
|
+
fill, hover, focus, error, disabled), and the
|
|
162
|
+
native input inside it a bare, growing text
|
|
163
|
+
run, so an affix of any width sits on the
|
|
164
|
+
field's line with no padding to guess. Only
|
|
165
|
+
in this mode: an input without affixes keeps
|
|
166
|
+
its border on the <input> exactly as before.
|
|
167
|
+
============================================ */
|
|
168
|
+
|
|
169
|
+
.ds-input--affixed .ds-input__field-wrapper {
|
|
170
|
+
gap: var(--gap-200);
|
|
171
|
+
box-sizing: border-box;
|
|
172
|
+
height: var(--control-height-default);
|
|
173
|
+
padding-inline: var(--padding-400);
|
|
174
|
+
border: var(--border-025) solid var(--color-input-border-primary);
|
|
175
|
+
border-radius: var(--radius-300);
|
|
176
|
+
background-color: var(--color-input-bg-primary);
|
|
177
|
+
transition: border-color var(--motion-duration-base) var(--motion-ease-standard), background-color var(--motion-duration-base) var(--motion-ease-standard);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.ds-input--affixed .ds-input__field-wrapper:hover:not(:focus-within) {
|
|
181
|
+
border-color: var(--color-input-border-hover);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.ds-input--affixed .ds-input__field-wrapper:focus-within {
|
|
185
|
+
border-color: var(--color-input-border-selected);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.ds-input--affixed .ds-input__field,
|
|
189
|
+
.ds-input--affixed .ds-input__field:hover,
|
|
190
|
+
.ds-input--affixed .ds-input__field:focus {
|
|
191
|
+
flex: 1 1 auto;
|
|
192
|
+
min-width: 0;
|
|
193
|
+
height: 100%;
|
|
194
|
+
padding: 0;
|
|
195
|
+
border: none;
|
|
196
|
+
border-radius: 0;
|
|
197
|
+
background-color: transparent;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.ds-input--affixed .ds-input__icon {
|
|
201
|
+
position: static;
|
|
202
|
+
transform: none;
|
|
203
|
+
flex-shrink: 0;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.ds-input--affixed.ds-input--has-icon-left .ds-input__field,
|
|
207
|
+
.ds-input--affixed.ds-input--has-icon-right .ds-input__field {
|
|
208
|
+
padding-inline: 0;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.ds-input__affix {
|
|
212
|
+
flex-shrink: 0;
|
|
213
|
+
font-family: var(--font-paragraph-family);
|
|
214
|
+
font-size: var(--font-paragraph-size);
|
|
215
|
+
font-weight: var(--font-paragraph-weight);
|
|
216
|
+
line-height: var(--font-paragraph-line-height);
|
|
217
|
+
letter-spacing: var(--font-paragraph-letter-spacing);
|
|
218
|
+
color: var(--color-text-secondary);
|
|
219
|
+
white-space: nowrap;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/* The clear button and an action sit a step in from the edge, their circles centred in the row. */
|
|
223
|
+
.ds-input__action {
|
|
224
|
+
display: inline-flex;
|
|
225
|
+
flex-shrink: 0;
|
|
226
|
+
align-items: center;
|
|
227
|
+
margin-inline-end: calc(-1 * var(--padding-200));
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.ds-input--affixed.ds-input--compact .ds-input__action {
|
|
231
|
+
margin-inline-end: calc(-1 * var(--padding-300));
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.ds-input__action + .ds-input__clear {
|
|
235
|
+
margin-inline-start: calc(-1 * var(--gap-200));
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.ds-input__clear {
|
|
239
|
+
flex-shrink: 0;
|
|
240
|
+
margin-inline-end: calc(-1 * var(--padding-200));
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.ds-input--affixed.ds-input--error .ds-input__field-wrapper,
|
|
244
|
+
.ds-input--affixed.ds-input--error .ds-input__field-wrapper:focus-within {
|
|
245
|
+
border-color: var(--color-status-error-border);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.ds-input--affixed.ds-input--disabled .ds-input__field-wrapper {
|
|
249
|
+
background-color: var(--color-input-bg-disabled);
|
|
250
|
+
border-color: var(--color-input-border-disabled);
|
|
251
|
+
cursor: not-allowed;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
.ds-input--affixed.ds-input--disabled .ds-input__field {
|
|
255
|
+
background-color: transparent;
|
|
256
|
+
border: none;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.ds-input--affixed.ds-input--disabled .ds-input__affix {
|
|
260
|
+
color: var(--color-input-text-disabled);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.ds-input--affixed.ds-input--compact .ds-input__field-wrapper {
|
|
264
|
+
height: var(--control-height-compact);
|
|
265
|
+
padding-inline: var(--padding-300);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.ds-input--affixed.ds-input--compact .ds-input__affix {
|
|
269
|
+
font-size: var(--font-paragraph-sm-size);
|
|
270
|
+
line-height: var(--font-paragraph-sm-line-height);
|
|
271
|
+
letter-spacing: var(--font-paragraph-sm-letter-spacing);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.ds-input--affixed.ds-input--compact .ds-input__clear {
|
|
275
|
+
margin-inline-end: calc(-1 * var(--padding-300));
|
|
276
|
+
}
|
|
@@ -11,8 +11,27 @@ type InputOwnProps = {
|
|
|
11
11
|
size?: 'default' | 'compact';
|
|
12
12
|
/** Error state — shows error styling and message */
|
|
13
13
|
error?: boolean;
|
|
14
|
-
/** Helper
|
|
14
|
+
/** Helper text displayed below the input. With the older `error` flag and no `errorText`, it doubles as the error message. */
|
|
15
15
|
helperText?: string;
|
|
16
|
+
/** The error message, shown under the input while the helper text keeps its place. Setting it marks the input invalid; Field's spec owns the wiring. */
|
|
17
|
+
errorText?: React.ReactNode;
|
|
18
|
+
/**
|
|
19
|
+
* Text or a node inside the field before the value, read by a screen reader
|
|
20
|
+
* as part of the field (a currency symbol, `https://`, a country code). Not
|
|
21
|
+
* the decorative `iconLeft`. Note: this shadows the native `prefix`
|
|
22
|
+
* attribute (an RDFa vocabulary), which Input does not expose.
|
|
23
|
+
*/
|
|
24
|
+
prefix?: React.ReactNode;
|
|
25
|
+
/** Text or a node inside the field after the value, read by a screen reader as part of the field (a unit, `.com`, `%`). Not the decorative `iconRight`. */
|
|
26
|
+
suffix?: React.ReactNode;
|
|
27
|
+
/** A control inside the field at its end, after the suffix: a show/hide button, a copy button. Unlike `suffix` it is not read as part of the field; it is a control of its own. */
|
|
28
|
+
action?: React.ReactNode;
|
|
29
|
+
/** Show a clear button while the field holds a value. It empties the field, fires `onChange` and `onValueChange` with an empty value, then `onClear`, and returns focus to the field. */
|
|
30
|
+
clearable?: boolean;
|
|
31
|
+
/** Accessible name of the clear button. Defaults to "Clear". */
|
|
32
|
+
clearLabel?: string;
|
|
33
|
+
/** Called after the clear button empties the field. */
|
|
34
|
+
onClear?: () => void;
|
|
16
35
|
/** Leading icon — Material Symbol name (string) or custom element (ReactNode) */
|
|
17
36
|
iconLeft?: string | React.ReactNode;
|
|
18
37
|
/** Trailing icon — Material Symbol name (string) or custom element (ReactNode) */
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import React from "react";
|
|
3
|
+
import React, { useRef, useState, useId } from "react";
|
|
4
4
|
import { Field } from "../Field/Field.js";
|
|
5
|
+
import { CircularButton } from "../CircularButton/CircularButton.js";
|
|
5
6
|
import "./Input.css";
|
|
6
7
|
import "../../fonts/material-symbols.css";
|
|
7
8
|
import { mirrorClass } from "../../behaviors/direction.js";
|
|
@@ -16,6 +17,13 @@ const Input = React.forwardRef(
|
|
|
16
17
|
required = false,
|
|
17
18
|
error = false,
|
|
18
19
|
helperText,
|
|
20
|
+
errorText,
|
|
21
|
+
prefix,
|
|
22
|
+
suffix,
|
|
23
|
+
action,
|
|
24
|
+
clearable = false,
|
|
25
|
+
clearLabel = "Clear",
|
|
26
|
+
onClear,
|
|
19
27
|
iconLeft,
|
|
20
28
|
iconRight,
|
|
21
29
|
onChange,
|
|
@@ -24,30 +32,71 @@ const Input = React.forwardRef(
|
|
|
24
32
|
ariaLabel,
|
|
25
33
|
name,
|
|
26
34
|
id,
|
|
35
|
+
defaultValue,
|
|
36
|
+
readOnly,
|
|
27
37
|
...rest
|
|
28
38
|
}, ref) => {
|
|
29
39
|
const baseClass = "ds-input";
|
|
40
|
+
const innerRef = useRef(null);
|
|
41
|
+
const setRef = (node) => {
|
|
42
|
+
innerRef.current = node;
|
|
43
|
+
if (typeof ref === "function") ref(node);
|
|
44
|
+
else if (ref) ref.current = node;
|
|
45
|
+
};
|
|
46
|
+
const [uncontrolledFilled, setUncontrolledFilled] = useState(
|
|
47
|
+
defaultValue != null && String(defaultValue) !== ""
|
|
48
|
+
);
|
|
49
|
+
const filled = value !== void 0 ? value !== "" && value != null : uncontrolledFilled;
|
|
50
|
+
const hasErrorText = errorText != null && errorText !== false && errorText !== "";
|
|
51
|
+
const invalid = error || hasErrorText;
|
|
52
|
+
const hasPrefix = prefix != null && prefix !== false && prefix !== "";
|
|
53
|
+
const hasSuffix = suffix != null && suffix !== false && suffix !== "";
|
|
54
|
+
const hasAction = action != null && action !== false;
|
|
55
|
+
const affixed = hasPrefix || hasSuffix || clearable || hasAction;
|
|
56
|
+
const showClear = clearable && filled && !disabled && !readOnly;
|
|
30
57
|
const classes = [
|
|
31
58
|
baseClass,
|
|
32
59
|
size === "compact" ? `${baseClass}--compact` : "",
|
|
33
|
-
|
|
60
|
+
invalid ? `${baseClass}--error` : "",
|
|
61
|
+
affixed ? `${baseClass}--affixed` : "",
|
|
34
62
|
disabled ? `${baseClass}--disabled` : "",
|
|
35
63
|
iconLeft ? `${baseClass}--has-icon-left` : "",
|
|
36
64
|
iconRight ? `${baseClass}--has-icon-right` : "",
|
|
37
65
|
className
|
|
38
66
|
].filter(Boolean).join(" ");
|
|
39
67
|
const handleChange = (e) => {
|
|
68
|
+
if (value === void 0) setUncontrolledFilled(e.target.value !== "");
|
|
40
69
|
onChange?.(e);
|
|
41
70
|
onValueChange?.(e.target.value);
|
|
42
71
|
};
|
|
72
|
+
const handleClear = () => {
|
|
73
|
+
const input = innerRef.current;
|
|
74
|
+
if (!input) return;
|
|
75
|
+
const setter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")?.set;
|
|
76
|
+
setter?.call(input, "");
|
|
77
|
+
input.dispatchEvent(new Event("input", { bubbles: true }));
|
|
78
|
+
onClear?.();
|
|
79
|
+
input.focus();
|
|
80
|
+
};
|
|
81
|
+
const fallbackId = useId();
|
|
43
82
|
const inputId = id || name || label?.toLowerCase().replace(/\s+/g, "-");
|
|
44
|
-
const
|
|
83
|
+
const affixBase = inputId || fallbackId;
|
|
84
|
+
const prefixId = hasPrefix ? `${affixBase}-prefix` : void 0;
|
|
85
|
+
const suffixId = hasSuffix ? `${affixBase}-suffix` : void 0;
|
|
86
|
+
const describedBy = [
|
|
87
|
+
rest["aria-describedby"],
|
|
88
|
+
prefixId,
|
|
89
|
+
suffixId,
|
|
90
|
+
hasErrorText ? `${inputId}-error` : void 0,
|
|
91
|
+
helperText ? `${inputId}-helper` : void 0
|
|
92
|
+
].filter(Boolean).join(" ") || void 0;
|
|
45
93
|
return /* @__PURE__ */ jsx(
|
|
46
94
|
Field,
|
|
47
95
|
{
|
|
48
96
|
className: classes,
|
|
49
97
|
label,
|
|
50
98
|
helperText,
|
|
99
|
+
errorText,
|
|
51
100
|
error,
|
|
52
101
|
required,
|
|
53
102
|
disabled,
|
|
@@ -62,25 +111,41 @@ const Input = React.forwardRef(
|
|
|
62
111
|
children: iconLeft
|
|
63
112
|
}
|
|
64
113
|
),
|
|
114
|
+
hasPrefix && /* @__PURE__ */ jsx("span", { className: `${baseClass}__affix ${baseClass}__affix--prefix`, id: prefixId, dir: "auto", children: prefix }),
|
|
65
115
|
/* @__PURE__ */ jsx(
|
|
66
116
|
"input",
|
|
67
117
|
{
|
|
68
118
|
...rest,
|
|
69
|
-
ref,
|
|
119
|
+
ref: setRef,
|
|
70
120
|
className: `${baseClass}__field`,
|
|
71
121
|
type,
|
|
72
122
|
id: inputId,
|
|
73
123
|
name,
|
|
74
124
|
value,
|
|
125
|
+
defaultValue,
|
|
126
|
+
readOnly,
|
|
75
127
|
placeholder,
|
|
76
128
|
disabled,
|
|
77
129
|
required,
|
|
78
130
|
"aria-label": rest["aria-label"] ?? ariaLabel ?? label,
|
|
79
|
-
"aria-invalid":
|
|
131
|
+
"aria-invalid": invalid,
|
|
80
132
|
"aria-describedby": describedBy,
|
|
81
133
|
onChange: handleChange
|
|
82
134
|
}
|
|
83
135
|
),
|
|
136
|
+
hasSuffix && /* @__PURE__ */ jsx("span", { className: `${baseClass}__affix ${baseClass}__affix--suffix`, id: suffixId, dir: "auto", children: suffix }),
|
|
137
|
+
hasAction && /* @__PURE__ */ jsx("span", { className: `${baseClass}__action`, children: action }),
|
|
138
|
+
showClear && /* @__PURE__ */ jsx(
|
|
139
|
+
CircularButton,
|
|
140
|
+
{
|
|
141
|
+
className: `${baseClass}__clear`,
|
|
142
|
+
icon: "close",
|
|
143
|
+
variant: "tertiary",
|
|
144
|
+
size: "compact",
|
|
145
|
+
ariaLabel: clearLabel,
|
|
146
|
+
onClick: handleClear
|
|
147
|
+
}
|
|
148
|
+
),
|
|
84
149
|
iconRight && /* @__PURE__ */ jsx(
|
|
85
150
|
"span",
|
|
86
151
|
{
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/* ============================================
|
|
2
|
+
LINK
|
|
3
|
+
Inline: the sentence's own face and colour,
|
|
4
|
+
underlined, so a link in prose reads as part
|
|
5
|
+
of the prose. Standalone: the tertiary action
|
|
6
|
+
text colour a tertiary Button wears, in its
|
|
7
|
+
own paragraph face. Both are underlined. Neither
|
|
8
|
+
takes the action fill, which stays reserved
|
|
9
|
+
for primary actions.
|
|
10
|
+
============================================ */
|
|
11
|
+
|
|
12
|
+
/* Base */
|
|
13
|
+
.ds-link {
|
|
14
|
+
display: inline;
|
|
15
|
+
color: inherit;
|
|
16
|
+
text-decoration-line: underline;
|
|
17
|
+
text-decoration-thickness: from-font;
|
|
18
|
+
text-underline-offset: 0.2em;
|
|
19
|
+
text-decoration-color: currentColor;
|
|
20
|
+
border-radius: var(--radius-050);
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.ds-link:focus-visible {
|
|
25
|
+
outline: var(--border-050) solid var(--color-action-primary-bg);
|
|
26
|
+
outline-offset: var(--border-050);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* Both variants keep the underline at rest, so a link always reads as one
|
|
30
|
+
whatever colour a theme gives its text, and thicken it on hover. */
|
|
31
|
+
.ds-link:hover {
|
|
32
|
+
text-decoration-thickness: var(--border-050);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* Standalone */
|
|
36
|
+
.ds-link--standalone {
|
|
37
|
+
color: var(--color-action-primary-text-tertiary);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.ds-link--standalone.ds-link--default {
|
|
41
|
+
font-family: var(--font-paragraph-emphasis-family);
|
|
42
|
+
font-size: var(--font-paragraph-emphasis-size);
|
|
43
|
+
font-weight: var(--font-paragraph-emphasis-weight);
|
|
44
|
+
line-height: var(--font-paragraph-emphasis-line-height);
|
|
45
|
+
letter-spacing: var(--font-paragraph-emphasis-letter-spacing);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.ds-link--standalone.ds-link--compact {
|
|
49
|
+
font-family: var(--font-paragraph-sm-emphasis-family);
|
|
50
|
+
font-size: var(--font-paragraph-sm-emphasis-size);
|
|
51
|
+
font-weight: var(--font-paragraph-sm-emphasis-weight);
|
|
52
|
+
line-height: var(--font-paragraph-sm-emphasis-line-height);
|
|
53
|
+
letter-spacing: var(--font-paragraph-sm-emphasis-letter-spacing);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/* Icons: sized to the text, sitting on its line. An inline link takes the
|
|
57
|
+
size of whatever sentence it is in, so its glyph follows the text rather
|
|
58
|
+
than a step of the icon scale. */
|
|
59
|
+
.ds-link__icon {
|
|
60
|
+
display: inline-block;
|
|
61
|
+
/* ds-allow(icon-size): an inline link's glyph is the height of the text it sits in, which can be any tier */
|
|
62
|
+
--icon-size: 1em;
|
|
63
|
+
line-height: 1;
|
|
64
|
+
vertical-align: -0.125em;
|
|
65
|
+
text-decoration: none;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.ds-link__icon--start {
|
|
69
|
+
margin-inline-end: var(--gap-050);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.ds-link__icon--end {
|
|
73
|
+
margin-inline-start: var(--gap-050);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/* States */
|
|
77
|
+
.ds-link--disabled {
|
|
78
|
+
opacity: 0.4;
|
|
79
|
+
cursor: not-allowed;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.ds-link--disabled:hover {
|
|
83
|
+
text-decoration-thickness: from-font;
|
|
84
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { LinkComponent } from '../../behaviors/LinkProvider';
|
|
3
|
+
/** Props owned by Link itself; everything else falls through to the anchor. */
|
|
4
|
+
type LinkOwnProps = {
|
|
5
|
+
/** Where the link goes. */
|
|
6
|
+
href: string;
|
|
7
|
+
/** The link text. */
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
/** `inline` sits inside a sentence, underlined and in the sentence's colour; `standalone` stands on its own line or beside a control, in the tertiary action text colour and its own type face. Both are underlined. */
|
|
10
|
+
variant?: 'inline' | 'standalone';
|
|
11
|
+
/** The standalone link's type size: `default` the paragraph face, `compact` the small paragraph face. An inline link always takes the size of the text around it. Distinct from no native attribute of an anchor. */
|
|
12
|
+
size?: 'default' | 'compact';
|
|
13
|
+
/** The link leaves the app: it opens in a new tab with `rel="noopener noreferrer"`, carries an outward mark, and tells a screen reader it opens a new tab. */
|
|
14
|
+
external?: boolean;
|
|
15
|
+
/** Read after an external link's text, hidden from the eye. Defaults to "(opens in a new tab)". */
|
|
16
|
+
externalLabel?: string;
|
|
17
|
+
/** Hold the link inert: it renders as text with `aria-disabled`, at the library's disabled treatment, and goes nowhere. */
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
/** A Material Symbol name or a node before the text. A directional glyph mirrors in a right-to-left context. */
|
|
20
|
+
iconLeft?: string | React.ReactNode;
|
|
21
|
+
/** A Material Symbol name or a node after the text. A directional glyph mirrors in a right-to-left context. */
|
|
22
|
+
iconRight?: string | React.ReactNode;
|
|
23
|
+
/**
|
|
24
|
+
* The component the link renders with, such as Next.js's `Link`, so it
|
|
25
|
+
* navigates through the app's router; a plain `<a>` when unset. This
|
|
26
|
+
* component can render on the server, so it never reads a LinkProvider:
|
|
27
|
+
* pass the prop even under one. An external link always renders a plain
|
|
28
|
+
* `<a>`.
|
|
29
|
+
*/
|
|
30
|
+
linkComponent?: LinkComponent;
|
|
31
|
+
/** Additional CSS classes. */
|
|
32
|
+
className?: string;
|
|
33
|
+
};
|
|
34
|
+
export interface LinkProps extends LinkOwnProps, Omit<React.ComponentPropsWithRef<'a'>, keyof LinkOwnProps> {
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A text link, inside a sentence or on its own. Renders through
|
|
38
|
+
* `linkComponent` so it navigates through the app's router, opens an
|
|
39
|
+
* external address in a new tab and says so, and holds still with
|
|
40
|
+
* `disabled`. Server-renderable.
|
|
41
|
+
*/
|
|
42
|
+
export declare function Link({ href, children, variant, size, external, externalLabel, disabled, iconLeft, iconRight, linkComponent, className, ref, ...rest }: LinkProps): React.JSX.Element;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { mirrorClass } from "../../behaviors/direction.js";
|
|
4
|
+
import "../../behaviors/visually-hidden.css";
|
|
5
|
+
import "../../fonts/material-symbols.css";
|
|
6
|
+
import "./Link.css";
|
|
7
|
+
const renderIcon = (icon, side) => {
|
|
8
|
+
if (icon == null || icon === false) return null;
|
|
9
|
+
if (typeof icon === "string")
|
|
10
|
+
return /* @__PURE__ */ jsx("span", { className: `ds-link__icon ds-link__icon--${side} material-symbols-rounded ${mirrorClass(icon)}`, "aria-hidden": "true", children: icon });
|
|
11
|
+
return /* @__PURE__ */ jsx("span", { className: `ds-link__icon ds-link__icon--${side}`, "aria-hidden": "true", children: icon });
|
|
12
|
+
};
|
|
13
|
+
function Link({
|
|
14
|
+
href,
|
|
15
|
+
children,
|
|
16
|
+
variant = "inline",
|
|
17
|
+
size = "default",
|
|
18
|
+
external = false,
|
|
19
|
+
externalLabel = "(opens in a new tab)",
|
|
20
|
+
disabled = false,
|
|
21
|
+
iconLeft,
|
|
22
|
+
iconRight,
|
|
23
|
+
linkComponent,
|
|
24
|
+
className = "",
|
|
25
|
+
ref,
|
|
26
|
+
...rest
|
|
27
|
+
}) {
|
|
28
|
+
const Anchor = external ? "a" : linkComponent ?? "a";
|
|
29
|
+
const classes = [
|
|
30
|
+
"ds-link",
|
|
31
|
+
`ds-link--${variant}`,
|
|
32
|
+
variant === "standalone" && `ds-link--${size}`,
|
|
33
|
+
disabled && "ds-link--disabled",
|
|
34
|
+
className
|
|
35
|
+
].filter(Boolean).join(" ");
|
|
36
|
+
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
37
|
+
renderIcon(iconLeft, "start"),
|
|
38
|
+
/* @__PURE__ */ jsx("span", { className: "ds-link__text", children }),
|
|
39
|
+
external && /* @__PURE__ */ jsx("span", { className: "ds-link__icon ds-link__icon--end ds-link__external material-symbols-rounded", "aria-hidden": "true", children: "arrow_outward" }),
|
|
40
|
+
renderIcon(iconRight, "end"),
|
|
41
|
+
external && /* @__PURE__ */ jsxs("span", { className: "ds-visually-hidden", children: [
|
|
42
|
+
" ",
|
|
43
|
+
externalLabel
|
|
44
|
+
] })
|
|
45
|
+
] });
|
|
46
|
+
if (disabled) {
|
|
47
|
+
const { target: _target, rel: _rel, download: _download, ...spanRest } = rest;
|
|
48
|
+
return /* @__PURE__ */ jsx(
|
|
49
|
+
"span",
|
|
50
|
+
{
|
|
51
|
+
...spanRest,
|
|
52
|
+
ref,
|
|
53
|
+
role: "link",
|
|
54
|
+
"aria-disabled": "true",
|
|
55
|
+
className: classes,
|
|
56
|
+
children: content
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
return /* @__PURE__ */ jsx(
|
|
61
|
+
Anchor,
|
|
62
|
+
{
|
|
63
|
+
...rest,
|
|
64
|
+
ref,
|
|
65
|
+
href,
|
|
66
|
+
className: classes,
|
|
67
|
+
...external ? { target: "_blank", rel: "noopener noreferrer" } : {},
|
|
68
|
+
children: content
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
export {
|
|
73
|
+
Link
|
|
74
|
+
};
|