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,184 @@
|
|
|
1
|
+
/* ============================================
|
|
2
|
+
DESCRIPTION LIST
|
|
3
|
+
Terms in the secondary text colour, values in
|
|
4
|
+
the primary, the facts recipe the chat cards
|
|
5
|
+
use made general. The frame is the size
|
|
6
|
+
container, so the inline layout stacks and the
|
|
7
|
+
grid drops columns by the room the list has,
|
|
8
|
+
never by the viewport.
|
|
9
|
+
============================================ */
|
|
10
|
+
|
|
11
|
+
/* Frame */
|
|
12
|
+
.ds-description-list__frame {
|
|
13
|
+
container-type: inline-size;
|
|
14
|
+
min-width: 0;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/* Base */
|
|
18
|
+
.ds-description-list {
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
gap: var(--gap-300);
|
|
22
|
+
margin: 0;
|
|
23
|
+
min-width: 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.ds-description-list__item {
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
gap: var(--gap-050);
|
|
30
|
+
min-width: 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.ds-description-list__term {
|
|
34
|
+
color: var(--color-text-secondary);
|
|
35
|
+
overflow-wrap: break-word;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.ds-description-list__details {
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
gap: var(--gap-200);
|
|
42
|
+
min-width: 0;
|
|
43
|
+
margin: 0;
|
|
44
|
+
color: var(--color-text-primary);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.ds-description-list__value {
|
|
48
|
+
flex: 1 1 auto;
|
|
49
|
+
min-width: 0;
|
|
50
|
+
overflow-wrap: anywhere;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* Stacked and grid entries keep a copy button or action beside the value;
|
|
54
|
+
the inline layout's value column runs to the far edge, so its actions
|
|
55
|
+
line up down the list there. */
|
|
56
|
+
.ds-description-list--stacked .ds-description-list__value,
|
|
57
|
+
.ds-description-list--grid .ds-description-list__value {
|
|
58
|
+
flex: 0 1 auto;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.ds-description-list__value--empty {
|
|
62
|
+
color: var(--color-text-tertiary);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.ds-description-list__actions {
|
|
66
|
+
display: inline-flex;
|
|
67
|
+
flex-shrink: 0;
|
|
68
|
+
align-items: center;
|
|
69
|
+
gap: var(--gap-100);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/* The copy button sits on the value's line without making the row taller. */
|
|
73
|
+
.ds-description-list__copy {
|
|
74
|
+
margin-block: calc(-1 * var(--padding-100));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/* Sizes */
|
|
78
|
+
.ds-description-list--default .ds-description-list__term,
|
|
79
|
+
.ds-description-list--default .ds-description-list__details {
|
|
80
|
+
font-family: var(--font-paragraph-family);
|
|
81
|
+
font-size: var(--font-paragraph-size);
|
|
82
|
+
font-weight: var(--font-paragraph-weight);
|
|
83
|
+
line-height: var(--font-paragraph-line-height);
|
|
84
|
+
letter-spacing: var(--font-paragraph-letter-spacing);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.ds-description-list--compact {
|
|
88
|
+
gap: var(--gap-200);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.ds-description-list--compact .ds-description-list__term,
|
|
92
|
+
.ds-description-list--compact .ds-description-list__details {
|
|
93
|
+
font-family: var(--font-paragraph-sm-family);
|
|
94
|
+
font-size: var(--font-paragraph-sm-size);
|
|
95
|
+
font-weight: var(--font-paragraph-sm-weight);
|
|
96
|
+
line-height: var(--font-paragraph-sm-line-height);
|
|
97
|
+
letter-spacing: var(--font-paragraph-sm-letter-spacing);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/* Inline: term and value in two columns, the term a quarter, a third or a half */
|
|
101
|
+
.ds-description-list--inline .ds-description-list__item {
|
|
102
|
+
display: grid;
|
|
103
|
+
align-items: baseline;
|
|
104
|
+
column-gap: var(--gap-400);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.ds-description-list--inline.ds-description-list--term-narrow .ds-description-list__item {
|
|
108
|
+
grid-template-columns: minmax(0, 1fr) minmax(0, 3fr);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.ds-description-list--inline.ds-description-list--term-default .ds-description-list__item {
|
|
112
|
+
grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.ds-description-list--inline.ds-description-list--term-wide .ds-description-list__item {
|
|
116
|
+
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/* Grid: stacked entries in columns */
|
|
120
|
+
.ds-description-list--grid {
|
|
121
|
+
display: grid;
|
|
122
|
+
grid-template-columns: repeat(var(--ds-description-list-columns, 2), minmax(0, 1fr));
|
|
123
|
+
gap: var(--gap-400) var(--gap-500);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/* Alignment: values against the far edge */
|
|
127
|
+
.ds-description-list--align-end .ds-description-list__value {
|
|
128
|
+
text-align: end;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.ds-description-list--align-end .ds-description-list__details {
|
|
132
|
+
justify-content: flex-end;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/* Dividers */
|
|
136
|
+
.ds-description-list--dividers {
|
|
137
|
+
gap: 0;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.ds-description-list--dividers .ds-description-list__item {
|
|
141
|
+
padding-block: var(--padding-300);
|
|
142
|
+
border-block-end: var(--border-025) solid var(--color-divider);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.ds-description-list--dividers .ds-description-list__item:last-child {
|
|
146
|
+
border-block-end: none;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.ds-description-list--grid.ds-description-list--dividers {
|
|
150
|
+
column-gap: var(--gap-500);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/* Narrow room: the inline layout stacks once two columns cannot hold a
|
|
154
|
+
short term and value side by side; the grid drops to fewer columns. */
|
|
155
|
+
@container (max-width: 360px) {
|
|
156
|
+
.ds-description-list--inline .ds-description-list__item,
|
|
157
|
+
.ds-description-list--inline.ds-description-list--term-narrow .ds-description-list__item,
|
|
158
|
+
.ds-description-list--inline.ds-description-list--term-default .ds-description-list__item,
|
|
159
|
+
.ds-description-list--inline.ds-description-list--term-wide .ds-description-list__item {
|
|
160
|
+
display: flex;
|
|
161
|
+
flex-direction: column;
|
|
162
|
+
gap: var(--gap-050);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.ds-description-list--inline.ds-description-list--align-end .ds-description-list__value {
|
|
166
|
+
text-align: start;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.ds-description-list--inline.ds-description-list--align-end .ds-description-list__details {
|
|
170
|
+
justify-content: flex-start;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
@container (max-width: 480px) {
|
|
175
|
+
.ds-description-list--grid {
|
|
176
|
+
grid-template-columns: minmax(0, 1fr);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
@container (min-width: 481px) and (max-width: 720px) {
|
|
181
|
+
.ds-description-list--grid {
|
|
182
|
+
grid-template-columns: repeat(min(var(--ds-description-list-columns, 2), 2), minmax(0, 1fr));
|
|
183
|
+
}
|
|
184
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/** One term and its value, as `items` takes them. */
|
|
3
|
+
export type DescriptionListEntry = {
|
|
4
|
+
/** The term: what the value is ("Account number", "Due date"). */
|
|
5
|
+
term: React.ReactNode;
|
|
6
|
+
/** The value. Empty (null, undefined or an empty string) shows the list's `emptyValue`. */
|
|
7
|
+
details?: React.ReactNode;
|
|
8
|
+
/** A stable key for the entry; also its element id. */
|
|
9
|
+
id?: string;
|
|
10
|
+
/** A trailing control for this value: an Edit button, a link. */
|
|
11
|
+
action?: React.ReactNode;
|
|
12
|
+
/** Offer a copy button: `true` copies the value when it is text, a string copies that string (the unformatted account number behind a formatted one). */
|
|
13
|
+
copyable?: boolean | string;
|
|
14
|
+
};
|
|
15
|
+
/** Props owned by DescriptionList itself; everything else falls through to the `<dl>`. */
|
|
16
|
+
type DescriptionListOwnProps = {
|
|
17
|
+
/** The entries, in order. Or compose `DescriptionListItem` children instead. */
|
|
18
|
+
items?: DescriptionListEntry[];
|
|
19
|
+
/** `DescriptionListItem` children, for a list written out by hand. */
|
|
20
|
+
children?: React.ReactNode;
|
|
21
|
+
/** `stacked` puts each term above its value; `inline` sets term and value in two columns and stacks them when the list is narrow; `grid` lays stacked entries out in `columns`. */
|
|
22
|
+
layout?: 'stacked' | 'inline' | 'grid';
|
|
23
|
+
/** How many columns the `grid` layout uses at full width, 1 to 4. Fewer show as the list narrows. */
|
|
24
|
+
columns?: 1 | 2 | 3 | 4;
|
|
25
|
+
/** Draw a divider between entries. */
|
|
26
|
+
dividers?: boolean;
|
|
27
|
+
/** The type size: `default` the paragraph face, `compact` the small paragraph face for dense panels. */
|
|
28
|
+
size?: 'default' | 'compact';
|
|
29
|
+
/** How much of the row the term column takes in the `inline` layout: a quarter, a third or a half. */
|
|
30
|
+
termWidth?: 'narrow' | 'default' | 'wide';
|
|
31
|
+
/** Where values sit: `end` lines amounts up against the far edge. */
|
|
32
|
+
align?: 'start' | 'end';
|
|
33
|
+
/** What an empty value shows. Defaults to "Not set". */
|
|
34
|
+
emptyValue?: React.ReactNode;
|
|
35
|
+
/** The copy button's accessible name, given the entry's term when it is text and an empty string when it is not. Defaults to "Copy <term>", or "Copy". */
|
|
36
|
+
copyLabel?: (term: string) => string;
|
|
37
|
+
/** The copy button's accessible name for a moment after a copy. Defaults to "Copied". */
|
|
38
|
+
copiedLabel?: string;
|
|
39
|
+
/** Called after a value is put on the clipboard, so a host can confirm it or count it. Only reaches a list rendered from a client component. */
|
|
40
|
+
onValueCopy?: (value: string) => void;
|
|
41
|
+
/** Additional CSS classes. */
|
|
42
|
+
className?: string;
|
|
43
|
+
};
|
|
44
|
+
export interface DescriptionListProps extends DescriptionListOwnProps, Omit<React.ComponentPropsWithRef<'dl'>, keyof DescriptionListOwnProps> {
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Terms and their values: a review screen before submit, a receipt, account
|
|
48
|
+
* details, a record inspector. Stacked, in two columns that stack when
|
|
49
|
+
* narrow, or in a grid; values can be copied or carry a trailing action, and
|
|
50
|
+
* an empty value says so in words. Server-renderable.
|
|
51
|
+
*/
|
|
52
|
+
export declare function DescriptionList({ items, children, layout, columns, dividers, size, termWidth, align, emptyValue, copyLabel, copiedLabel, onValueCopy, className, style, ref, ...rest }: DescriptionListProps): React.JSX.Element;
|
|
53
|
+
/** Props owned by DescriptionListItem itself; everything else falls through to the entry's wrapper `<div>`. */
|
|
54
|
+
type DescriptionListItemOwnProps = Omit<DescriptionListEntry, 'id'> & {
|
|
55
|
+
/** The value, as children. `details` wins when both are set. */
|
|
56
|
+
children?: React.ReactNode;
|
|
57
|
+
/** Additional CSS classes. */
|
|
58
|
+
className?: string;
|
|
59
|
+
};
|
|
60
|
+
export interface DescriptionListItemProps extends DescriptionListItemOwnProps, Omit<React.ComponentPropsWithRef<'div'>, keyof DescriptionListItemOwnProps> {
|
|
61
|
+
}
|
|
62
|
+
/** One term and its value inside a DescriptionList, for a list written out by hand. Server-renderable. */
|
|
63
|
+
export declare function DescriptionListItem({ term, details, children, action, copyable, className, ref, ...rest }: DescriptionListItemProps): React.JSX.Element;
|
|
64
|
+
export {};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { DescriptionListCopy } from "./DescriptionListCopy.js";
|
|
4
|
+
import "../../behaviors/visually-hidden.css";
|
|
5
|
+
import "./DescriptionList.css";
|
|
6
|
+
const isEmpty = (value) => value == null || value === false || value === "";
|
|
7
|
+
const textOf = (value) => typeof value === "string" || typeof value === "number" ? String(value) : null;
|
|
8
|
+
function renderEntry({ term, details, id, action, copyable }, settings, className = "", rest = {}, ref) {
|
|
9
|
+
const empty = isEmpty(details);
|
|
10
|
+
const copyText = empty ? null : typeof copyable === "string" ? copyable : copyable ? textOf(details) : null;
|
|
11
|
+
const termText = textOf(term);
|
|
12
|
+
const classes = ["ds-description-list__item", className].filter(Boolean).join(" ");
|
|
13
|
+
return /* @__PURE__ */ jsxs("div", { ...rest, ref, id: id ?? rest.id, className: classes, children: [
|
|
14
|
+
/* @__PURE__ */ jsx("dt", { className: "ds-description-list__term", children: term }),
|
|
15
|
+
/* @__PURE__ */ jsxs("dd", { className: "ds-description-list__details", children: [
|
|
16
|
+
/* @__PURE__ */ jsx("span", { className: `ds-description-list__value${empty ? " ds-description-list__value--empty" : ""}`, children: empty ? settings.emptyValue : details }),
|
|
17
|
+
(copyText || action) && /* @__PURE__ */ jsxs("span", { className: "ds-description-list__actions", children: [
|
|
18
|
+
copyText && /* @__PURE__ */ jsx(
|
|
19
|
+
DescriptionListCopy,
|
|
20
|
+
{
|
|
21
|
+
value: copyText,
|
|
22
|
+
label: settings.copyLabel(termText ?? ""),
|
|
23
|
+
copiedLabel: settings.copiedLabel,
|
|
24
|
+
onCopied: settings.onValueCopy
|
|
25
|
+
}
|
|
26
|
+
),
|
|
27
|
+
action
|
|
28
|
+
] })
|
|
29
|
+
] })
|
|
30
|
+
] });
|
|
31
|
+
}
|
|
32
|
+
const DEFAULT_COPY_LABEL = (term) => term ? `Copy ${term}` : "Copy";
|
|
33
|
+
const SETTINGS_PROP = "__dsDescriptionListSettings";
|
|
34
|
+
function DescriptionList({
|
|
35
|
+
items,
|
|
36
|
+
children,
|
|
37
|
+
layout = "stacked",
|
|
38
|
+
columns = 2,
|
|
39
|
+
dividers = false,
|
|
40
|
+
size = "default",
|
|
41
|
+
termWidth = "default",
|
|
42
|
+
align = "start",
|
|
43
|
+
emptyValue = "Not set",
|
|
44
|
+
copyLabel = DEFAULT_COPY_LABEL,
|
|
45
|
+
copiedLabel = "Copied",
|
|
46
|
+
onValueCopy,
|
|
47
|
+
className = "",
|
|
48
|
+
style,
|
|
49
|
+
ref,
|
|
50
|
+
...rest
|
|
51
|
+
}) {
|
|
52
|
+
const settings = { emptyValue, copyLabel, copiedLabel, onValueCopy };
|
|
53
|
+
const classes = [
|
|
54
|
+
"ds-description-list",
|
|
55
|
+
`ds-description-list--${layout}`,
|
|
56
|
+
`ds-description-list--${size}`,
|
|
57
|
+
layout === "inline" && `ds-description-list--term-${termWidth}`,
|
|
58
|
+
dividers && "ds-description-list--dividers",
|
|
59
|
+
align === "end" && "ds-description-list--align-end",
|
|
60
|
+
className
|
|
61
|
+
].filter(Boolean).join(" ");
|
|
62
|
+
const resolvedStyle = layout === "grid" ? { ...style, "--ds-description-list-columns": columns } : style;
|
|
63
|
+
const composed = React.Children.map(
|
|
64
|
+
children,
|
|
65
|
+
(child) => React.isValidElement(child) && child.type === DescriptionListItem ? React.cloneElement(child, { [SETTINGS_PROP]: settings }) : child
|
|
66
|
+
);
|
|
67
|
+
return /* @__PURE__ */ jsx("div", { className: "ds-description-list__frame", children: /* @__PURE__ */ jsxs("dl", { ...rest, ref, className: classes, style: resolvedStyle, children: [
|
|
68
|
+
items?.map((entry, index) => /* @__PURE__ */ jsx(React.Fragment, { children: renderEntry(entry, settings) }, entry.id ?? index)),
|
|
69
|
+
composed
|
|
70
|
+
] }) });
|
|
71
|
+
}
|
|
72
|
+
function DescriptionListItem({
|
|
73
|
+
term,
|
|
74
|
+
details,
|
|
75
|
+
children,
|
|
76
|
+
action,
|
|
77
|
+
copyable,
|
|
78
|
+
className = "",
|
|
79
|
+
ref,
|
|
80
|
+
...rest
|
|
81
|
+
}) {
|
|
82
|
+
const { [SETTINGS_PROP]: passed, ...divRest } = rest;
|
|
83
|
+
const settings = {
|
|
84
|
+
emptyValue: passed?.emptyValue ?? "Not set",
|
|
85
|
+
copyLabel: passed?.copyLabel ?? DEFAULT_COPY_LABEL,
|
|
86
|
+
copiedLabel: passed?.copiedLabel ?? "Copied",
|
|
87
|
+
onValueCopy: passed?.onValueCopy
|
|
88
|
+
};
|
|
89
|
+
return renderEntry(
|
|
90
|
+
{ term, details: details ?? children, action, copyable },
|
|
91
|
+
settings,
|
|
92
|
+
className,
|
|
93
|
+
divRest,
|
|
94
|
+
ref
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
export {
|
|
98
|
+
DescriptionList,
|
|
99
|
+
DescriptionListItem
|
|
100
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Props owned by DescriptionListCopy. */
|
|
2
|
+
export interface DescriptionListCopyProps {
|
|
3
|
+
/** The text put on the clipboard. */
|
|
4
|
+
value: string;
|
|
5
|
+
/** The button's accessible name before a copy. */
|
|
6
|
+
label: string;
|
|
7
|
+
/** The button's accessible name for a moment after a copy. */
|
|
8
|
+
copiedLabel: string;
|
|
9
|
+
/** Called after the value is put on the clipboard. */
|
|
10
|
+
onCopied?: (value: string) => void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The copy button beside a description list value. Internal: DescriptionList
|
|
14
|
+
* renders it for a `copyable` item, so the list itself stays
|
|
15
|
+
* server-renderable. A compact tertiary CircularButton whose glyph and name
|
|
16
|
+
* turn to "Copied" for a moment after a press.
|
|
17
|
+
*/
|
|
18
|
+
export declare function DescriptionListCopy({ value, label, copiedLabel, onCopied }: DescriptionListCopyProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useState, useRef, useEffect } from "react";
|
|
4
|
+
import { CircularButton } from "../CircularButton/CircularButton.js";
|
|
5
|
+
import { MOTION_FEEDBACK_RESET_MS } from "../../tokens/motion.js";
|
|
6
|
+
function writeClipboard(text) {
|
|
7
|
+
const fallback = () => {
|
|
8
|
+
const textarea = document.createElement("textarea");
|
|
9
|
+
textarea.value = text;
|
|
10
|
+
textarea.setAttribute("readonly", "");
|
|
11
|
+
textarea.className = "ds-visually-hidden";
|
|
12
|
+
document.body.appendChild(textarea);
|
|
13
|
+
textarea.select();
|
|
14
|
+
document.execCommand("copy");
|
|
15
|
+
document.body.removeChild(textarea);
|
|
16
|
+
};
|
|
17
|
+
if (navigator.clipboard?.writeText) navigator.clipboard.writeText(text).catch(fallback);
|
|
18
|
+
else fallback();
|
|
19
|
+
}
|
|
20
|
+
function DescriptionListCopy({ value, label, copiedLabel, onCopied }) {
|
|
21
|
+
const [copied, setCopied] = useState(false);
|
|
22
|
+
const timer = useRef(void 0);
|
|
23
|
+
useEffect(() => () => window.clearTimeout(timer.current), []);
|
|
24
|
+
const copy = () => {
|
|
25
|
+
writeClipboard(value);
|
|
26
|
+
onCopied?.(value);
|
|
27
|
+
setCopied(true);
|
|
28
|
+
window.clearTimeout(timer.current);
|
|
29
|
+
timer.current = window.setTimeout(() => setCopied(false), MOTION_FEEDBACK_RESET_MS);
|
|
30
|
+
};
|
|
31
|
+
return /* @__PURE__ */ jsx(
|
|
32
|
+
CircularButton,
|
|
33
|
+
{
|
|
34
|
+
className: "ds-description-list__copy",
|
|
35
|
+
icon: copied ? "check" : "content_copy",
|
|
36
|
+
variant: "tertiary",
|
|
37
|
+
size: "compact",
|
|
38
|
+
ariaLabel: copied ? copiedLabel : label,
|
|
39
|
+
onClick: copy
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
DescriptionListCopy
|
|
45
|
+
};
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/* ============================================
|
|
2
|
+
DOCUMENT VIEWER
|
|
3
|
+
A bordered frame on the secondary container,
|
|
4
|
+
a toolbar row behind a divider, then the file:
|
|
5
|
+
the browser's own PDF viewer, an image that
|
|
6
|
+
zooms inside a scroller, or text set in the
|
|
7
|
+
code face. The frame's height is a step of the
|
|
8
|
+
control-height scale, or its container's.
|
|
9
|
+
============================================ */
|
|
10
|
+
|
|
11
|
+
/* Base */
|
|
12
|
+
.ds-document-viewer {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
box-sizing: border-box;
|
|
16
|
+
min-width: 0;
|
|
17
|
+
border: var(--border-025) solid var(--color-bg-container-border);
|
|
18
|
+
border-radius: var(--radius-300);
|
|
19
|
+
background-color: var(--color-bg-container-secondary);
|
|
20
|
+
overflow: hidden;
|
|
21
|
+
container-type: inline-size;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.ds-document-viewer--height-fill {
|
|
25
|
+
block-size: 100%;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/* Bare: no frame and no toolbar, the host's own surface and header around it */
|
|
29
|
+
.ds-document-viewer--bare {
|
|
30
|
+
border: none;
|
|
31
|
+
border-radius: 0;
|
|
32
|
+
background-color: transparent;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* Toolbar */
|
|
36
|
+
.ds-document-viewer__toolbar {
|
|
37
|
+
display: flex;
|
|
38
|
+
align-items: center;
|
|
39
|
+
gap: var(--gap-200);
|
|
40
|
+
min-width: 0;
|
|
41
|
+
padding: var(--padding-150) var(--padding-200) var(--padding-150) var(--padding-400);
|
|
42
|
+
border-block-end: var(--border-025) solid var(--color-divider);
|
|
43
|
+
background-color: var(--color-bg-page-primary);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.ds-document-viewer__title {
|
|
47
|
+
flex: 1 1 auto;
|
|
48
|
+
min-width: 0;
|
|
49
|
+
overflow: hidden;
|
|
50
|
+
white-space: nowrap;
|
|
51
|
+
text-overflow: ellipsis;
|
|
52
|
+
font-family: var(--font-paragraph-sm-emphasis-family);
|
|
53
|
+
font-size: var(--font-paragraph-sm-emphasis-size);
|
|
54
|
+
font-weight: var(--font-paragraph-sm-emphasis-weight);
|
|
55
|
+
line-height: var(--font-paragraph-sm-emphasis-line-height);
|
|
56
|
+
letter-spacing: var(--font-paragraph-sm-emphasis-letter-spacing);
|
|
57
|
+
color: var(--color-text-primary);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.ds-document-viewer__actions {
|
|
61
|
+
display: flex;
|
|
62
|
+
flex-shrink: 0;
|
|
63
|
+
align-items: center;
|
|
64
|
+
gap: var(--gap-050);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* The zoom reading doubles as the fit-to-width button. */
|
|
68
|
+
.ds-document-viewer__zoom {
|
|
69
|
+
box-sizing: border-box;
|
|
70
|
+
min-inline-size: var(--control-height-default);
|
|
71
|
+
height: var(--control-height-compact);
|
|
72
|
+
padding: 0 var(--padding-150);
|
|
73
|
+
border: none;
|
|
74
|
+
border-radius: var(--radius-pill);
|
|
75
|
+
background: none;
|
|
76
|
+
font-family: var(--font-paragraph-sm-family);
|
|
77
|
+
font-size: var(--font-paragraph-sm-size);
|
|
78
|
+
line-height: var(--font-paragraph-sm-line-height);
|
|
79
|
+
font-variant-numeric: tabular-nums;
|
|
80
|
+
color: var(--color-text-secondary);
|
|
81
|
+
cursor: pointer;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.ds-document-viewer__zoom:hover {
|
|
85
|
+
background-color: var(--color-action-passive-bg-hover);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.ds-document-viewer__zoom:focus-visible {
|
|
89
|
+
outline: var(--border-050) solid var(--color-action-primary-bg);
|
|
90
|
+
outline-offset: var(--border-050);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* A narrow frame gives the title a row of its own above the controls,
|
|
94
|
+
so a phone reads the whole name rather than its first word. */
|
|
95
|
+
@container (max-width: 400px) {
|
|
96
|
+
.ds-document-viewer__toolbar {
|
|
97
|
+
flex-wrap: wrap;
|
|
98
|
+
row-gap: var(--gap-050);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.ds-document-viewer__title {
|
|
102
|
+
flex-basis: 100%;
|
|
103
|
+
white-space: normal;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.ds-document-viewer__actions {
|
|
107
|
+
margin-inline-start: auto;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/* Body */
|
|
112
|
+
.ds-document-viewer__body {
|
|
113
|
+
display: flex;
|
|
114
|
+
flex-direction: column;
|
|
115
|
+
block-size: calc(var(--control-height-default) * 12);
|
|
116
|
+
min-height: 0;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.ds-document-viewer--height-tall .ds-document-viewer__body {
|
|
120
|
+
block-size: calc(var(--control-height-default) * 18);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.ds-document-viewer--height-fill .ds-document-viewer__body {
|
|
124
|
+
flex: 1 1 auto;
|
|
125
|
+
block-size: auto;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.ds-document-viewer__frame {
|
|
129
|
+
flex: 1 1 auto;
|
|
130
|
+
inline-size: 100%;
|
|
131
|
+
block-size: 100%;
|
|
132
|
+
border: none;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.ds-document-viewer__scroll {
|
|
136
|
+
flex: 1 1 auto;
|
|
137
|
+
min-height: 0;
|
|
138
|
+
overflow: auto;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.ds-document-viewer__scroll:focus-visible {
|
|
142
|
+
outline: var(--border-050) solid var(--color-action-primary-bg);
|
|
143
|
+
outline-offset: calc(-1 * var(--border-050));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.ds-document-viewer__image {
|
|
147
|
+
display: block;
|
|
148
|
+
max-inline-size: none;
|
|
149
|
+
block-size: auto;
|
|
150
|
+
margin-inline: auto;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.ds-document-viewer__text {
|
|
154
|
+
margin: 0;
|
|
155
|
+
padding: var(--padding-400);
|
|
156
|
+
font-family: var(--font-family-code);
|
|
157
|
+
font-size: var(--font-paragraph-sm-size);
|
|
158
|
+
line-height: var(--font-paragraph-sm-line-height);
|
|
159
|
+
color: var(--color-text-primary);
|
|
160
|
+
white-space: pre-wrap;
|
|
161
|
+
overflow-wrap: anywhere;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/* Loading and fallback */
|
|
165
|
+
.ds-document-viewer__loading,
|
|
166
|
+
.ds-document-viewer__fallback {
|
|
167
|
+
display: flex;
|
|
168
|
+
flex: 1 1 auto;
|
|
169
|
+
flex-direction: column;
|
|
170
|
+
align-items: center;
|
|
171
|
+
justify-content: center;
|
|
172
|
+
gap: var(--gap-300);
|
|
173
|
+
padding: var(--padding-500);
|
|
174
|
+
text-align: center;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.ds-document-viewer__fallback-icon {
|
|
178
|
+
--icon-size: var(--icon-size-800);
|
|
179
|
+
color: var(--color-icon-primary);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.ds-document-viewer__fallback-text {
|
|
183
|
+
margin: 0;
|
|
184
|
+
font-family: var(--font-paragraph-family);
|
|
185
|
+
font-size: var(--font-paragraph-size);
|
|
186
|
+
line-height: var(--font-paragraph-line-height);
|
|
187
|
+
color: var(--color-text-secondary);
|
|
188
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/** What the viewer shows a file as. */
|
|
3
|
+
export type DocumentViewerKind = 'pdf' | 'image' | 'text';
|
|
4
|
+
/** Props owned by DocumentViewer itself; everything else falls through to the root `<section>`. */
|
|
5
|
+
type DocumentViewerOwnProps = {
|
|
6
|
+
/** The file's address. */
|
|
7
|
+
src: string;
|
|
8
|
+
/** The document's name, shown in the toolbar and naming the frame for a screen reader. Note: this replaces the native `title` tooltip attribute, which DocumentViewer does not expose. */
|
|
9
|
+
title: string;
|
|
10
|
+
/** How to show it, or `auto` to read it from `fileName`, `src` and `mimeType`. A kind the viewer cannot show renders the fallback. Defaults to `auto`. */
|
|
11
|
+
kind?: DocumentViewerKind | 'auto';
|
|
12
|
+
/** The file's name, extension included, for `auto` and for the downloaded file. Defaults to the last part of `src`. */
|
|
13
|
+
fileName?: string;
|
|
14
|
+
/** The file's mime type, when `auto` cannot tell from the name. */
|
|
15
|
+
mimeType?: string;
|
|
16
|
+
/** The viewer's height: `default`, `tall`, or `fill` to take the height of its container. */
|
|
17
|
+
height?: 'default' | 'tall' | 'fill';
|
|
18
|
+
/** Drop the frame and the toolbar and fill the host, for a host that brings its own header with the name and the actions, such as AttachmentViewer. */
|
|
19
|
+
bare?: boolean;
|
|
20
|
+
/** Show the download button. A string names the downloaded file. Defaults to true. */
|
|
21
|
+
download?: boolean | string;
|
|
22
|
+
/** Called when the download button is pressed, in place of the browser's own download: for a file the host must fetch with credentials. */
|
|
23
|
+
onDownload?: () => void;
|
|
24
|
+
/** Show the button that opens the file in a new tab. Defaults to true. */
|
|
25
|
+
openInNewTab?: boolean;
|
|
26
|
+
/** More controls for the toolbar, before the built-in ones: a share button, a page count. */
|
|
27
|
+
toolbar?: React.ReactNode;
|
|
28
|
+
/** What shows when the file cannot be shown here: an unknown kind, a text file that would not load, or a browser that will not embed a PDF. Defaults to a line saying so and a download button. */
|
|
29
|
+
fallback?: React.ReactNode;
|
|
30
|
+
/** Accessible name and text of the download button. Defaults to "Download". */
|
|
31
|
+
downloadLabel?: string;
|
|
32
|
+
/** Accessible name of the open button. Defaults to "Open in new tab". */
|
|
33
|
+
openLabel?: string;
|
|
34
|
+
/** Accessible name of the zoom-in button. Defaults to "Zoom in". */
|
|
35
|
+
zoomInLabel?: string;
|
|
36
|
+
/** Accessible name of the zoom-out button. Defaults to "Zoom out". */
|
|
37
|
+
zoomOutLabel?: string;
|
|
38
|
+
/** Accessible name of the button that fits an image to the width again, given the zoom in percent. Defaults to "Fit to width, now <zoom>%". */
|
|
39
|
+
resetZoomLabel?: (percent: string) => string;
|
|
40
|
+
/** Announced while a text file loads. Defaults to "Loading document". */
|
|
41
|
+
loadingLabel?: string;
|
|
42
|
+
/** The default fallback's line. Defaults to "This file can’t be shown here." */
|
|
43
|
+
fallbackLabel?: string;
|
|
44
|
+
/** The BCP 47 locale the zoom is written in. Defaults to the nearest LocaleProvider's, else `en-US`. */
|
|
45
|
+
locale?: string;
|
|
46
|
+
/** Additional CSS classes */
|
|
47
|
+
className?: string;
|
|
48
|
+
};
|
|
49
|
+
export interface DocumentViewerProps extends DocumentViewerOwnProps, Omit<React.ComponentPropsWithRef<'section'>, keyof DocumentViewerOwnProps | 'children'> {
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* A document on the page: a statement, a contract, an invoice, an uploaded
|
|
53
|
+
* receipt. A PDF shows in the browser's own viewer, an image with zoom, a
|
|
54
|
+
* text file in a scrolling frame; the toolbar downloads it or opens it in a
|
|
55
|
+
* new tab. Where the browser will not embed the file, the fallback shows in
|
|
56
|
+
* its place. The library carries no document renderer.
|
|
57
|
+
*/
|
|
58
|
+
export declare function DocumentViewer({ src, title, kind, fileName, mimeType, height, bare, download, onDownload, openInNewTab, toolbar, fallback, downloadLabel, openLabel, zoomInLabel, zoomOutLabel, resetZoomLabel, loadingLabel, fallbackLabel, locale: localeProp, className, ref, ...rest }: DocumentViewerProps): React.JSX.Element;
|
|
59
|
+
export {};
|