rift-ds 1.24.0 → 1.26.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 (117) hide show
  1. package/README.md +5 -4
  2. package/chat/ChatThreads.d.ts +3 -1
  3. package/chat/ChatThreads.js +3 -1
  4. package/chat/ChatWidget.css +166 -15
  5. package/chat/ChatWidget.d.ts +6 -2
  6. package/chat/ChatWidget.js +17 -3
  7. package/components/ActionCard/ActionCard.d.ts +1 -1
  8. package/components/Attachment/Attachment.css +8 -0
  9. package/components/Attachment/AttachmentViewer.js +26 -5
  10. package/components/Attachment/fileTypes.d.ts +4 -0
  11. package/components/ContextMenu/ContextMenu.css +11 -0
  12. package/components/ContextMenu/ContextMenu.d.ts +1 -1
  13. package/components/ContextMenu/ContextMenu.js +3 -1
  14. package/components/CurrencyInput/CurrencyInput.css +12 -0
  15. package/components/CurrencyInput/CurrencyInput.d.ts +51 -0
  16. package/components/CurrencyInput/CurrencyInput.js +158 -0
  17. package/components/DataTable/columnTypes.js +4 -16
  18. package/components/DatePicker/DatePicker.d.ts +2 -0
  19. package/components/DatePicker/DatePicker.js +44 -131
  20. package/components/DatePicker/MonthGrid.d.ts +56 -0
  21. package/components/DatePicker/MonthGrid.js +65 -0
  22. package/components/DatePicker/calendar.d.ts +42 -0
  23. package/components/DatePicker/calendar.js +108 -0
  24. package/components/DateRangePicker/DateRangePicker.css +92 -0
  25. package/components/DateRangePicker/DateRangePicker.d.ts +86 -0
  26. package/components/DateRangePicker/DateRangePicker.js +294 -0
  27. package/components/Deadline/Deadline.css +82 -0
  28. package/components/Deadline/Deadline.d.ts +44 -0
  29. package/components/Deadline/Deadline.js +94 -0
  30. package/components/Deadline/deadlineStatus.d.ts +15 -0
  31. package/components/Deadline/deadlineStatus.js +13 -0
  32. package/components/DescriptionList/DescriptionList.css +184 -0
  33. package/components/DescriptionList/DescriptionList.d.ts +64 -0
  34. package/components/DescriptionList/DescriptionList.js +100 -0
  35. package/components/DescriptionList/DescriptionListCopy.d.ts +18 -0
  36. package/components/DescriptionList/DescriptionListCopy.js +45 -0
  37. package/components/DocumentViewer/DocumentViewer.css +188 -0
  38. package/components/DocumentViewer/DocumentViewer.d.ts +59 -0
  39. package/components/DocumentViewer/DocumentViewer.js +185 -0
  40. package/components/DropdownMenu/DropdownMenu.css +38 -0
  41. package/components/DropdownMenu/DropdownMenu.d.ts +4 -0
  42. package/components/DropdownMenu/DropdownMenu.js +11 -5
  43. package/components/DropdownMenu/ShortcutHint.d.ts +9 -0
  44. package/components/DropdownMenu/ShortcutHint.js +6 -0
  45. package/components/ErrorSummary/ErrorSummary.css +94 -0
  46. package/components/ErrorSummary/ErrorSummary.d.ts +34 -0
  47. package/components/ErrorSummary/ErrorSummary.js +70 -0
  48. package/components/ErrorSummary/fieldErrors.d.ts +36 -0
  49. package/components/ErrorSummary/fieldErrors.js +19 -0
  50. package/components/Field/Field.css +12 -0
  51. package/components/Field/Field.d.ts +10 -2
  52. package/components/Field/Field.js +12 -5
  53. package/components/Heading/Heading.css +129 -0
  54. package/components/Heading/Heading.d.ts +31 -0
  55. package/components/Heading/Heading.js +39 -0
  56. package/components/Input/Input.css +120 -0
  57. package/components/Input/Input.d.ts +20 -1
  58. package/components/Input/Input.js +70 -5
  59. package/components/InterruptCard/InterruptCard.d.ts +1 -1
  60. package/components/Link/Link.css +84 -0
  61. package/components/Link/Link.d.ts +43 -0
  62. package/components/Link/Link.js +74 -0
  63. package/components/List/List.css +173 -0
  64. package/components/List/List.d.ts +44 -0
  65. package/components/List/List.js +60 -0
  66. package/components/MaskedInput/MaskedInput.css +16 -0
  67. package/components/MaskedInput/MaskedInput.d.ts +57 -0
  68. package/components/MaskedInput/MaskedInput.js +142 -0
  69. package/components/MaskedInput/mask.d.ts +58 -0
  70. package/components/MaskedInput/mask.js +106 -0
  71. package/components/MessageCard/MessageCard.css +17 -6
  72. package/components/MessageCard/MessageCard.d.ts +1 -1
  73. package/components/ShaderScene/ShaderScene.css +19 -0
  74. package/components/ShaderScene/ShaderScene.d.ts +82 -0
  75. package/components/ShaderScene/ShaderScene.js +167 -0
  76. package/components/ShaderScene/assemble.d.ts +5 -0
  77. package/components/ShaderScene/assemble.js +76 -0
  78. package/components/ShaderScene/common.glsl.d.ts +6 -0
  79. package/components/ShaderScene/common.glsl.js +49 -0
  80. package/components/ShaderScene/passes.d.ts +2 -0
  81. package/components/ShaderScene/passes.js +93 -0
  82. package/components/ShaderScene/renderer.d.ts +39 -0
  83. package/components/ShaderScene/renderer.js +170 -0
  84. package/components/ShaderScene/scenes.d.ts +76 -0
  85. package/components/ShaderScene/scenes.js +752 -0
  86. package/components/ShaderScene/types.d.ts +83 -0
  87. package/components/ShaderScene/types.js +8 -0
  88. package/components/SignaturePad/SignaturePad.css +141 -0
  89. package/components/SignaturePad/SignaturePad.d.ts +68 -0
  90. package/components/SignaturePad/SignaturePad.js +287 -0
  91. package/components/SignaturePad/signature.d.ts +32 -0
  92. package/components/SignaturePad/signature.js +46 -0
  93. package/components/Text/Text.css +129 -0
  94. package/components/Text/Text.d.ts +36 -0
  95. package/components/Text/Text.js +36 -0
  96. package/components/ThreadPanel/ThreadPanel.css +29 -0
  97. package/components/ThreadPanel/ThreadPanel.d.ts +2 -0
  98. package/components/ThreadPanel/ThreadPanel.js +13 -2
  99. package/components/Widget/Widget.css +111 -0
  100. package/components/Widget/Widget.d.ts +15 -1
  101. package/components/Widget/Widget.js +63 -11
  102. package/components/Widget/WidgetDisclosure.d.ts +30 -0
  103. package/components/Widget/WidgetDisclosure.js +52 -0
  104. package/components/registry.json +111 -2
  105. package/components/registry.json.d.ts +111 -2
  106. package/components/registry.json.js +2 -2
  107. package/format/index.d.ts +15 -0
  108. package/format/index.js +17 -0
  109. package/format/money.d.ts +89 -0
  110. package/format/money.js +187 -0
  111. package/format/relative.d.ts +49 -0
  112. package/format/relative.js +50 -0
  113. package/index.d.ts +13 -0
  114. package/index.js +48 -1
  115. package/package.json +9 -2
  116. package/tokens/motion.d.ts +4 -0
  117. package/tokens/motion.js +4 -0
@@ -0,0 +1,94 @@
1
+ /* ============================================
2
+ ERROR SUMMARY
3
+ The Alert's error surface (status fill, status
4
+ border, its radius and inset), holding a
5
+ heading and a list of links, one per error.
6
+ ============================================ */
7
+
8
+ /* Base */
9
+ .ds-error-summary {
10
+ display: flex;
11
+ align-items: flex-start;
12
+ gap: var(--gap-200);
13
+ box-sizing: border-box;
14
+ width: 100%;
15
+ padding: var(--padding-400);
16
+ border: var(--border-025) solid var(--color-status-error-border);
17
+ border-radius: var(--radius-200);
18
+ background-color: var(--color-status-error-bg);
19
+ color: var(--color-status-error-text);
20
+ }
21
+
22
+ .ds-error-summary:focus {
23
+ outline: none;
24
+ }
25
+
26
+ .ds-error-summary:focus-visible {
27
+ outline: var(--border-050) solid var(--color-action-primary-bg);
28
+ outline-offset: var(--border-050);
29
+ }
30
+
31
+ .ds-error-summary__icon {
32
+ flex-shrink: 0;
33
+ --icon-size: var(--icon-size-600);
34
+ line-height: 1;
35
+ color: var(--color-status-error-border);
36
+ }
37
+
38
+ .ds-error-summary__content {
39
+ display: flex;
40
+ flex: 1;
41
+ flex-direction: column;
42
+ gap: var(--gap-100);
43
+ min-width: 0;
44
+ }
45
+
46
+ .ds-error-summary__title {
47
+ margin: 0;
48
+ font-family: var(--font-paragraph-emphasis-family);
49
+ font-size: var(--font-paragraph-emphasis-size);
50
+ font-weight: var(--font-paragraph-emphasis-weight);
51
+ line-height: var(--font-paragraph-emphasis-line-height);
52
+ letter-spacing: var(--font-paragraph-emphasis-letter-spacing);
53
+ }
54
+
55
+ .ds-error-summary__description {
56
+ margin: 0;
57
+ font-family: var(--font-paragraph-family);
58
+ font-size: var(--font-paragraph-size);
59
+ font-weight: var(--font-paragraph-weight);
60
+ line-height: var(--font-paragraph-line-height);
61
+ letter-spacing: var(--font-paragraph-letter-spacing);
62
+ }
63
+
64
+ /* List */
65
+ .ds-error-summary__list {
66
+ display: flex;
67
+ flex-direction: column;
68
+ gap: var(--gap-100);
69
+ margin: 0;
70
+ padding: 0;
71
+ list-style: none;
72
+ }
73
+
74
+ .ds-error-summary__link {
75
+ border-radius: var(--radius-050);
76
+ font-family: var(--font-paragraph-family);
77
+ font-size: var(--font-paragraph-size);
78
+ font-weight: var(--font-paragraph-weight);
79
+ line-height: var(--font-paragraph-line-height);
80
+ letter-spacing: var(--font-paragraph-letter-spacing);
81
+ color: inherit;
82
+ text-decoration-line: underline;
83
+ text-decoration-thickness: from-font;
84
+ text-underline-offset: 0.2em;
85
+ }
86
+
87
+ .ds-error-summary__link:hover {
88
+ text-decoration-thickness: var(--border-050);
89
+ }
90
+
91
+ .ds-error-summary__link:focus-visible {
92
+ outline: var(--border-050) solid var(--color-action-primary-bg);
93
+ outline-offset: var(--border-050);
94
+ }
@@ -0,0 +1,34 @@
1
+ import { default as React } from 'react';
2
+ import { ErrorSummaryError } from './fieldErrors';
3
+ /** Props owned by ErrorSummary itself; everything else falls through to the root `<section>`. */
4
+ type ErrorSummaryOwnProps = {
5
+ /** The errors, in the form's order: each the id of the control it belongs to and what is wrong. The summary renders nothing while the list is empty. */
6
+ errors: ErrorSummaryError<React.ReactNode>[];
7
+ /** The heading, in place of the one `titleLabel` writes. Note: this replaces the native `title` attribute, which ErrorSummary does not expose. */
8
+ title?: React.ReactNode;
9
+ /** The heading for a given number of errors: the count as a number (for a plural rule) and as written in the locale (for display). Defaults to "There is a problem" for one and "There are <count> problems" for more. */
10
+ titleLabel?: (count: number, formatted: string) => string;
11
+ /** A line under the heading, before the list. */
12
+ description?: React.ReactNode;
13
+ /** Move focus to the summary when the list goes from empty to holding errors (on a submit), so a screen reader reads it and a keyboard user starts from it. Defaults to true. */
14
+ focusOnMount?: boolean;
15
+ /** The heading's level, so the summary takes its place in the page's outline. Defaults to 2. */
16
+ headingLevel?: 2 | 3 | 4;
17
+ /** Called with a control's id after its link moves focus to it. */
18
+ onErrorClick?: (id: string) => void;
19
+ /** The BCP 47 locale the count is written in. Defaults to the nearest LocaleProvider's, else `en-US`. */
20
+ locale?: string;
21
+ /** Additional CSS classes. */
22
+ className?: string;
23
+ };
24
+ export interface ErrorSummaryProps extends ErrorSummaryOwnProps, Omit<React.ComponentPropsWithRef<'section'>, keyof ErrorSummaryOwnProps | 'children'> {
25
+ }
26
+ /**
27
+ * Every error on a form in one place, at the top of it: a heading that says
28
+ * how many, and a link per error that moves focus to the control and scrolls
29
+ * it into view. Takes the focus when errors first appear, so the reader
30
+ * starts from what needs fixing.
31
+ */
32
+ export declare function ErrorSummary({ errors, title, titleLabel, description, focusOnMount, headingLevel, onErrorClick, locale: localeProp, className, ref, ...rest }: ErrorSummaryProps): React.JSX.Element | null;
33
+ export { fieldErrorsFrom } from './fieldErrors';
34
+ export type { ErrorSummaryError, FieldErrors, FieldErrorsFromOptions } from './fieldErrors';
@@ -0,0 +1,70 @@
1
+ "use client";
2
+ import { jsxs, jsx } from "react/jsx-runtime";
3
+ import { useId, useRef, useEffect } from "react";
4
+ import { useLocale } from "../../behaviors/LocaleProvider.js";
5
+ import { formatNumber } from "../../behaviors/locale.js";
6
+ import "../../fonts/material-symbols.css";
7
+ import "./ErrorSummary.css";
8
+ const DEFAULT_TITLE_LABEL = (count, formatted) => count === 1 ? "There is a problem" : `There are ${formatted} problems`;
9
+ function ErrorSummary({
10
+ errors,
11
+ title,
12
+ titleLabel = DEFAULT_TITLE_LABEL,
13
+ description,
14
+ focusOnMount = true,
15
+ headingLevel = 2,
16
+ onErrorClick,
17
+ locale: localeProp,
18
+ className = "",
19
+ ref,
20
+ ...rest
21
+ }) {
22
+ const locale = useLocale(localeProp);
23
+ const headingId = useId();
24
+ const rootRef = useRef(null);
25
+ const hadErrors = useRef(false);
26
+ const count = errors.length;
27
+ useEffect(() => {
28
+ const has = count > 0;
29
+ if (has && !hadErrors.current && focusOnMount) rootRef.current?.focus();
30
+ hadErrors.current = has;
31
+ }, [count, focusOnMount]);
32
+ if (count === 0) return null;
33
+ const setRef = (node) => {
34
+ rootRef.current = node;
35
+ if (typeof ref === "function") ref(node);
36
+ else if (ref) ref.current = node;
37
+ };
38
+ const goTo = (event, id) => {
39
+ const target = document.getElementById(id);
40
+ if (!target) return;
41
+ event.preventDefault();
42
+ const frame = target.closest(".ds-field") ?? target;
43
+ frame.scrollIntoView({ block: "center" });
44
+ target.focus({ preventScroll: true });
45
+ onErrorClick?.(id);
46
+ };
47
+ const Heading = `h${headingLevel}`;
48
+ const heading = title ?? titleLabel(count, formatNumber(count, locale));
49
+ return /* @__PURE__ */ jsxs(
50
+ "section",
51
+ {
52
+ ...rest,
53
+ ref: setRef,
54
+ tabIndex: -1,
55
+ "aria-labelledby": headingId,
56
+ className: ["ds-error-summary", className].filter(Boolean).join(" "),
57
+ children: [
58
+ /* @__PURE__ */ jsx("span", { className: "ds-error-summary__icon material-symbols-rounded", "aria-hidden": "true", children: "error" }),
59
+ /* @__PURE__ */ jsxs("div", { className: "ds-error-summary__content", children: [
60
+ /* @__PURE__ */ jsx(Heading, { className: "ds-error-summary__title", id: headingId, children: heading }),
61
+ description != null && description !== false && /* @__PURE__ */ jsx("p", { className: "ds-error-summary__description", children: description }),
62
+ /* @__PURE__ */ jsx("ul", { className: "ds-error-summary__list", children: errors.map((error, index) => /* @__PURE__ */ jsx("li", { className: "ds-error-summary__item", children: /* @__PURE__ */ jsx("a", { className: "ds-error-summary__link", href: `#${error.id}`, onClick: (event) => goTo(event, error.id), children: error.message }) }, `${error.id}-${index}`)) })
63
+ ] })
64
+ ]
65
+ }
66
+ );
67
+ }
68
+ export {
69
+ ErrorSummary
70
+ };
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Server field errors into the shapes ErrorSummary and Field take. No React,
3
+ * so a route handler or a form action can call it too.
4
+ */
5
+ /** One error ErrorSummary lists: the id of the control it belongs to, and what is wrong. */
6
+ export type ErrorSummaryError<Message = string> = {
7
+ /** The id of the control the error belongs to; the summary's link focuses it. */
8
+ id: string;
9
+ /** What is wrong, in words that say how to fix it. */
10
+ message: Message;
11
+ };
12
+ /** Options for {@link fieldErrorsFrom}. */
13
+ export type FieldErrorsFromOptions = {
14
+ /** The control id for a field name, when the two differ (`email` named, `signup-email` its id). Defaults to the name itself. */
15
+ idFor?: (name: string) => string;
16
+ /** The order the summary lists fields in, usually the form's own order. Fields not named come after, in the record's order. */
17
+ order?: readonly string[];
18
+ };
19
+ /** What {@link fieldErrorsFrom} returns: the summary's list, and one message per field for its `errorText`. */
20
+ export type FieldErrors = {
21
+ /** Every message, one entry each, for ErrorSummary's `errors`. */
22
+ errors: ErrorSummaryError[];
23
+ /** One message per field name (several joined by a space), for each Field's or Input's `errorText`. */
24
+ errorText: Record<string, string>;
25
+ };
26
+ /**
27
+ * Turn the common server shape, `{ fieldName: message | message[] }`, into
28
+ * ErrorSummary's `errors` and a per-field `errorText` map. Empty messages
29
+ * and empty lists are dropped, so a record with nothing wrong gives empty
30
+ * results.
31
+ *
32
+ * ```ts
33
+ * const { errors, errorText } = fieldErrorsFrom(response.fieldErrors, { order: ['name', 'email'] });
34
+ * ```
35
+ */
36
+ export declare function fieldErrorsFrom(record: Readonly<Record<string, string | readonly string[] | null | undefined>> | null | undefined, options?: FieldErrorsFromOptions): FieldErrors;
@@ -0,0 +1,19 @@
1
+ function fieldErrorsFrom(record, options = {}) {
2
+ const { idFor = (name) => name, order = [] } = options;
3
+ const names = Object.keys(record ?? {});
4
+ const ranked = [...order.filter((name) => names.includes(name)), ...names.filter((name) => !order.includes(name))];
5
+ const errors = [];
6
+ const errorText = {};
7
+ for (const name of ranked) {
8
+ const raw = record?.[name];
9
+ const messages = (Array.isArray(raw) ? raw : [raw]).filter((m) => typeof m === "string" && m.trim() !== "");
10
+ if (messages.length === 0) continue;
11
+ const id = idFor(name);
12
+ for (const message of messages) errors.push({ id, message });
13
+ errorText[name] = messages.join(" ");
14
+ }
15
+ return { errors, errorText };
16
+ }
17
+ export {
18
+ fieldErrorsFrom
19
+ };
@@ -62,6 +62,18 @@
62
62
  color: var(--color-status-error-border);
63
63
  }
64
64
 
65
+ /* The newer form: the error is a message of its own under the control,
66
+ and the helper text keeps its colour beside it. */
67
+ .ds-field__error {
68
+ margin: 0;
69
+ font-family: var(--font-paragraph-sm-family);
70
+ font-size: var(--font-paragraph-sm-size);
71
+ font-weight: var(--font-paragraph-sm-weight);
72
+ line-height: var(--font-paragraph-sm-line-height);
73
+ letter-spacing: var(--font-paragraph-sm-letter-spacing);
74
+ color: var(--color-status-error-text);
75
+ }
76
+
65
77
  /* ============================================
66
78
  DISABLED STATE
67
79
  ============================================ */
@@ -5,15 +5,23 @@ type FieldOwnProps = {
5
5
  label?: string;
6
6
  /** The form control this field labels */
7
7
  children?: React.ReactNode;
8
- /** Helper or error message rendered below the control */
8
+ /** Helper text rendered below the control. With `errorText` it stays as it is while an error shows; with the older `error` flag it is recoloured as the error message. */
9
9
  helperText?: string;
10
+ /**
11
+ * The error message, shown under the control in the error colour while the
12
+ * helper text keeps its place, and announced politely when it changes.
13
+ * Setting it marks the field invalid, so `error` is not needed alongside
14
+ * it. The older form, `error` with the message in `helperText`, still
15
+ * works.
16
+ */
17
+ errorText?: React.ReactNode;
10
18
  /**
11
19
  * Optional content rendered opposite the helper text — a character counter,
12
20
  * a unit, a "0/280". Present only when supplied; without it the helper sits
13
21
  * directly in the field's column and no extra wrapper is introduced.
14
22
  */
15
23
  aside?: React.ReactNode;
16
- /** Error state — recolours the helper text and marks the control invalid */
24
+ /** Error state: marks the control invalid and, in the older form without `errorText`, recolours the helper text as the error message. */
17
25
  error?: boolean;
18
26
  /** Marks the field required and renders the required marker */
19
27
  required?: boolean;
@@ -8,6 +8,7 @@ const Field = React.forwardRef(
8
8
  label,
9
9
  children,
10
10
  helperText,
11
+ errorText,
11
12
  aside,
12
13
  error = false,
13
14
  required = false,
@@ -21,12 +22,17 @@ const Field = React.forwardRef(
21
22
  const baseClass = "ds-field";
22
23
  const generatedId = useId();
23
24
  const controlId = id || generatedId;
24
- const describedBy = helperText ? `${controlId}-helper` : void 0;
25
+ const hasErrorText = errorText != null && errorText !== false && errorText !== "";
26
+ const helperId = helperText ? `${controlId}-helper` : void 0;
27
+ const errorId = hasErrorText ? `${controlId}-error` : void 0;
28
+ const describedBy = [errorId, helperId].filter(Boolean).join(" ") || void 0;
29
+ const invalid = error || hasErrorText;
25
30
  const labelId = label ? `${controlId}-label` : void 0;
26
31
  const classes = [
27
32
  baseClass,
28
33
  size === "compact" ? `${baseClass}--compact` : "",
29
- error ? `${baseClass}--error` : "",
34
+ error && !hasErrorText ? `${baseClass}--error` : "",
35
+ hasErrorText ? `${baseClass}--invalid` : "",
30
36
  disabled ? `${baseClass}--disabled` : "",
31
37
  className
32
38
  ].filter(Boolean).join(" ");
@@ -34,7 +40,7 @@ const Field = React.forwardRef(
34
40
  controlId,
35
41
  labelId,
36
42
  describedBy,
37
- invalid: error,
43
+ invalid,
38
44
  required,
39
45
  disabled
40
46
  };
@@ -57,10 +63,11 @@ const Field = React.forwardRef(
57
63
  ] })
58
64
  ] })),
59
65
  children,
66
+ hasErrorText && /* @__PURE__ */ jsx("p", { className: `${baseClass}__error`, id: errorId, "aria-live": "polite", children: errorText }),
60
67
  aside ? /* @__PURE__ */ jsxs("div", { className: `${baseClass}__footer`, children: [
61
- helperText ? /* @__PURE__ */ jsx("p", { className: `${baseClass}__helper`, id: describedBy, children: helperText }) : /* @__PURE__ */ jsx("span", {}),
68
+ helperText ? /* @__PURE__ */ jsx("p", { className: `${baseClass}__helper`, id: helperId, children: helperText }) : /* @__PURE__ */ jsx("span", {}),
62
69
  aside
63
- ] }) : helperText && /* @__PURE__ */ jsx("p", { className: `${baseClass}__helper`, id: describedBy, children: helperText })
70
+ ] }) : helperText && /* @__PURE__ */ jsx("p", { className: `${baseClass}__helper`, id: helperId, children: helperText })
64
71
  ] }) });
65
72
  }
66
73
  );
@@ -0,0 +1,129 @@
1
+ /* ============================================
2
+ HEADING
3
+ One element per outline level, one class per
4
+ type tier. Each tier reads its five tokens
5
+ from tokens-typography.css; the display tiers
6
+ take the display text role and the heading
7
+ tiers the heading role, so a theme that tones
8
+ either tier tones every Heading with it.
9
+ ============================================ */
10
+
11
+ /* Base */
12
+ .ds-heading {
13
+ margin: 0;
14
+ color: var(--color-text-heading);
15
+ overflow-wrap: break-word;
16
+ }
17
+
18
+ /* Tiers: display */
19
+ .ds-heading--mega-1 {
20
+ font-family: var(--font-mega-1-family);
21
+ font-size: var(--font-mega-1-size);
22
+ font-weight: var(--font-mega-1-weight);
23
+ line-height: var(--font-mega-1-line-height);
24
+ letter-spacing: var(--font-mega-1-letter-spacing);
25
+ color: var(--color-text-display);
26
+ }
27
+
28
+ .ds-heading--mega-2 {
29
+ font-family: var(--font-mega-2-family);
30
+ font-size: var(--font-mega-2-size);
31
+ font-weight: var(--font-mega-2-weight);
32
+ line-height: var(--font-mega-2-line-height);
33
+ letter-spacing: var(--font-mega-2-letter-spacing);
34
+ color: var(--color-text-display);
35
+ }
36
+
37
+ .ds-heading--display-1 {
38
+ font-family: var(--font-display-1-family);
39
+ font-size: var(--font-display-1-size);
40
+ font-weight: var(--font-display-1-weight);
41
+ line-height: var(--font-display-1-line-height);
42
+ letter-spacing: var(--font-display-1-letter-spacing);
43
+ color: var(--color-text-display);
44
+ }
45
+
46
+ .ds-heading--display-2 {
47
+ font-family: var(--font-display-2-family);
48
+ font-size: var(--font-display-2-size);
49
+ font-weight: var(--font-display-2-weight);
50
+ line-height: var(--font-display-2-line-height);
51
+ letter-spacing: var(--font-display-2-letter-spacing);
52
+ color: var(--color-text-display);
53
+ }
54
+
55
+ .ds-heading--sub-display {
56
+ font-family: var(--font-sub-display-family);
57
+ font-size: var(--font-sub-display-size);
58
+ font-weight: var(--font-sub-display-weight);
59
+ line-height: var(--font-sub-display-line-height);
60
+ letter-spacing: var(--font-sub-display-letter-spacing);
61
+ color: var(--color-text-display);
62
+ }
63
+
64
+ /* Tiers: heading */
65
+ .ds-heading--heading-1 {
66
+ font-family: var(--font-heading-1-family);
67
+ font-size: var(--font-heading-1-size);
68
+ font-weight: var(--font-heading-1-weight);
69
+ line-height: var(--font-heading-1-line-height);
70
+ letter-spacing: var(--font-heading-1-letter-spacing);
71
+ color: var(--color-text-heading);
72
+ }
73
+
74
+ .ds-heading--heading-2 {
75
+ font-family: var(--font-heading-2-family);
76
+ font-size: var(--font-heading-2-size);
77
+ font-weight: var(--font-heading-2-weight);
78
+ line-height: var(--font-heading-2-line-height);
79
+ letter-spacing: var(--font-heading-2-letter-spacing);
80
+ color: var(--color-text-heading);
81
+ }
82
+
83
+ .ds-heading--heading-3 {
84
+ font-family: var(--font-heading-3-family);
85
+ font-size: var(--font-heading-3-size);
86
+ font-weight: var(--font-heading-3-weight);
87
+ line-height: var(--font-heading-3-line-height);
88
+ letter-spacing: var(--font-heading-3-letter-spacing);
89
+ color: var(--color-text-heading);
90
+ }
91
+
92
+ /* Tiers: title in the body face */
93
+ .ds-heading--title-body {
94
+ font-family: var(--font-title-body-family);
95
+ font-size: var(--font-title-body-size);
96
+ font-weight: var(--font-title-body-weight);
97
+ line-height: var(--font-title-body-line-height);
98
+ letter-spacing: var(--font-title-body-letter-spacing);
99
+ color: var(--color-text-heading);
100
+ }
101
+
102
+ /* Tone */
103
+ .ds-heading.ds-heading--tone-neutral {
104
+ color: var(--color-text-secondary);
105
+ }
106
+
107
+ /* Wrapping */
108
+ .ds-heading--truncate {
109
+ overflow: hidden;
110
+ white-space: nowrap;
111
+ text-overflow: ellipsis;
112
+ }
113
+
114
+ .ds-heading--balance {
115
+ text-wrap: balance;
116
+ }
117
+
118
+ /* Alignment */
119
+ .ds-heading--align-start {
120
+ text-align: start;
121
+ }
122
+
123
+ .ds-heading--align-center {
124
+ text-align: center;
125
+ }
126
+
127
+ .ds-heading--align-end {
128
+ text-align: end;
129
+ }
@@ -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
+ }