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.
- package/README.md +5 -4
- package/chat/ChatThreads.d.ts +3 -1
- package/chat/ChatThreads.js +3 -1
- package/chat/ChatWidget.css +166 -15
- package/chat/ChatWidget.d.ts +6 -2
- package/chat/ChatWidget.js +17 -3
- package/components/ActionCard/ActionCard.d.ts +1 -1
- package/components/Attachment/Attachment.css +8 -0
- package/components/Attachment/AttachmentViewer.js +26 -5
- package/components/Attachment/fileTypes.d.ts +4 -0
- package/components/ContextMenu/ContextMenu.css +11 -0
- package/components/ContextMenu/ContextMenu.d.ts +1 -1
- package/components/ContextMenu/ContextMenu.js +3 -1
- 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/DropdownMenu/DropdownMenu.css +38 -0
- package/components/DropdownMenu/DropdownMenu.d.ts +4 -0
- package/components/DropdownMenu/DropdownMenu.js +11 -5
- package/components/DropdownMenu/ShortcutHint.d.ts +9 -0
- package/components/DropdownMenu/ShortcutHint.js +6 -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/InterruptCard/InterruptCard.d.ts +1 -1
- 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/MessageCard/MessageCard.css +17 -6
- package/components/MessageCard/MessageCard.d.ts +1 -1
- package/components/ShaderScene/ShaderScene.css +19 -0
- package/components/ShaderScene/ShaderScene.d.ts +82 -0
- package/components/ShaderScene/ShaderScene.js +167 -0
- package/components/ShaderScene/assemble.d.ts +5 -0
- package/components/ShaderScene/assemble.js +76 -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 +39 -0
- package/components/ShaderScene/renderer.js +170 -0
- package/components/ShaderScene/scenes.d.ts +76 -0
- package/components/ShaderScene/scenes.js +752 -0
- package/components/ShaderScene/types.d.ts +83 -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/ThreadPanel/ThreadPanel.css +29 -0
- package/components/ThreadPanel/ThreadPanel.d.ts +2 -0
- package/components/ThreadPanel/ThreadPanel.js +13 -2
- 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 +111 -2
- package/components/registry.json.d.ts +111 -2
- 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 +48 -1
- package/package.json +9 -2
- package/tokens/motion.d.ts +4 -0
- package/tokens/motion.js +4 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/* ============================================
|
|
2
|
+
TEXT
|
|
3
|
+
Running text in one of the scale's body
|
|
4
|
+
tiers. Each tier reads its tokens from
|
|
5
|
+
tokens-typography.css; `--emphasis` swaps in
|
|
6
|
+
the tier's emphasis weight, which the
|
|
7
|
+
paragraph tiers carry as their own style and
|
|
8
|
+
the small tiers borrow from paragraph-sm.
|
|
9
|
+
============================================ */
|
|
10
|
+
|
|
11
|
+
/* Base */
|
|
12
|
+
.ds-text {
|
|
13
|
+
margin: 0;
|
|
14
|
+
color: var(--color-text-primary);
|
|
15
|
+
overflow-wrap: break-word;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* Tiers */
|
|
19
|
+
.ds-text--paragraph {
|
|
20
|
+
font-family: var(--font-paragraph-family);
|
|
21
|
+
font-size: var(--font-paragraph-size);
|
|
22
|
+
font-weight: var(--font-paragraph-weight);
|
|
23
|
+
line-height: var(--font-paragraph-line-height);
|
|
24
|
+
letter-spacing: var(--font-paragraph-letter-spacing);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.ds-text--paragraph.ds-text--emphasis {
|
|
28
|
+
font-family: var(--font-paragraph-emphasis-family);
|
|
29
|
+
font-weight: var(--font-paragraph-emphasis-weight);
|
|
30
|
+
letter-spacing: var(--font-paragraph-emphasis-letter-spacing);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.ds-text--paragraph-sm {
|
|
34
|
+
font-family: var(--font-paragraph-sm-family);
|
|
35
|
+
font-size: var(--font-paragraph-sm-size);
|
|
36
|
+
font-weight: var(--font-paragraph-sm-weight);
|
|
37
|
+
line-height: var(--font-paragraph-sm-line-height);
|
|
38
|
+
letter-spacing: var(--font-paragraph-sm-letter-spacing);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.ds-text--paragraph-sm.ds-text--emphasis {
|
|
42
|
+
font-family: var(--font-paragraph-sm-emphasis-family);
|
|
43
|
+
font-weight: var(--font-paragraph-sm-emphasis-weight);
|
|
44
|
+
letter-spacing: var(--font-paragraph-sm-emphasis-letter-spacing);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.ds-text--caption {
|
|
48
|
+
font-family: var(--font-caption-family);
|
|
49
|
+
font-size: var(--font-caption-size);
|
|
50
|
+
font-weight: var(--font-caption-weight);
|
|
51
|
+
line-height: var(--font-caption-line-height);
|
|
52
|
+
letter-spacing: var(--font-caption-letter-spacing);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.ds-text--overline {
|
|
56
|
+
font-family: var(--font-overline-family);
|
|
57
|
+
font-size: var(--font-overline-size);
|
|
58
|
+
font-weight: var(--font-overline-weight);
|
|
59
|
+
line-height: var(--font-overline-line-height);
|
|
60
|
+
letter-spacing: var(--font-overline-letter-spacing);
|
|
61
|
+
text-transform: uppercase;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.ds-text--code {
|
|
65
|
+
font-family: var(--font-family-code);
|
|
66
|
+
font-size: var(--font-paragraph-sm-size);
|
|
67
|
+
font-weight: var(--font-paragraph-sm-weight);
|
|
68
|
+
line-height: var(--font-paragraph-sm-line-height);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.ds-text--caption.ds-text--emphasis,
|
|
72
|
+
.ds-text--overline.ds-text--emphasis,
|
|
73
|
+
.ds-text--code.ds-text--emphasis {
|
|
74
|
+
font-weight: var(--font-paragraph-sm-emphasis-weight);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/* Tone */
|
|
78
|
+
.ds-text--tone-neutral {
|
|
79
|
+
color: var(--color-text-secondary);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.ds-text--tone-positive {
|
|
83
|
+
color: var(--color-status-positive-text);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.ds-text--tone-warning {
|
|
87
|
+
color: var(--color-status-warning-text);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.ds-text--tone-error {
|
|
91
|
+
color: var(--color-status-error-text);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.ds-text--tone-inherit {
|
|
95
|
+
color: inherit;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/* Wrapping */
|
|
99
|
+
.ds-text--truncate {
|
|
100
|
+
overflow: hidden;
|
|
101
|
+
white-space: nowrap;
|
|
102
|
+
text-overflow: ellipsis;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.ds-text--clamp {
|
|
106
|
+
display: -webkit-box;
|
|
107
|
+
-webkit-box-orient: vertical;
|
|
108
|
+
-webkit-line-clamp: var(--ds-text-lines);
|
|
109
|
+
line-clamp: var(--ds-text-lines);
|
|
110
|
+
overflow: hidden;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/* Figures */
|
|
114
|
+
.ds-text--numeric {
|
|
115
|
+
font-variant-numeric: tabular-nums;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/* Alignment */
|
|
119
|
+
.ds-text--align-start {
|
|
120
|
+
text-align: start;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.ds-text--align-center {
|
|
124
|
+
text-align: center;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.ds-text--align-end {
|
|
128
|
+
text-align: end;
|
|
129
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/** A running-text type style, named as the type scale names it. */
|
|
3
|
+
export type TextTier = 'paragraph' | 'paragraph-sm' | 'caption' | 'overline' | 'code';
|
|
4
|
+
/** Props owned by Text itself; everything else falls through to the rendered element. */
|
|
5
|
+
type TextOwnProps = {
|
|
6
|
+
/** The type style: `paragraph` for body copy, `paragraph-sm` for helper copy and table cells, `caption` for the smallest notes, `overline` for an eyebrow above a title, `code` for an inline identifier in the code face. */
|
|
7
|
+
tier?: TextTier;
|
|
8
|
+
/** The element it renders as. Defaults to `p`; `span` sits inside a line, `label` names a control (pass `htmlFor`). */
|
|
9
|
+
as?: 'p' | 'span' | 'div' | 'label' | 'strong' | 'em';
|
|
10
|
+
/** The colour role: `default` the primary text, `neutral` the secondary for quieter copy, a status role for a message of that kind, `inherit` the surrounding colour. */
|
|
11
|
+
tone?: 'default' | 'neutral' | 'positive' | 'warning' | 'error' | 'inherit';
|
|
12
|
+
/** `emphasis` sets the tier's emphasis weight, the one heavier weight the type scale gives running text. */
|
|
13
|
+
weight?: 'default' | 'emphasis';
|
|
14
|
+
/** Keep the text on one line, ending in an ellipsis where it runs out of room. */
|
|
15
|
+
truncate?: boolean;
|
|
16
|
+
/** Clamp the text to this many lines, ending in an ellipsis. Overrides `truncate`. */
|
|
17
|
+
lines?: number;
|
|
18
|
+
/** Tabular figures, so digits line up in a column of amounts or times. */
|
|
19
|
+
numeric?: boolean;
|
|
20
|
+
/** Where the text sits on the line, along the reading direction. `end` lines up a column of amounts. */
|
|
21
|
+
align?: 'start' | 'center' | 'end';
|
|
22
|
+
/** The control this text names, when `as` is `label`. */
|
|
23
|
+
htmlFor?: string;
|
|
24
|
+
/** The text. */
|
|
25
|
+
children?: React.ReactNode;
|
|
26
|
+
/** Additional CSS classes. */
|
|
27
|
+
className?: string;
|
|
28
|
+
};
|
|
29
|
+
export interface TextProps extends TextOwnProps, Omit<React.ComponentPropsWithRef<'p'>, keyof TextOwnProps> {
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Running text in the type scale: body copy, helper copy, a caption, an
|
|
33
|
+
* amount in a column. Server-renderable.
|
|
34
|
+
*/
|
|
35
|
+
export declare function Text({ tier, as, tone, weight, truncate, lines, numeric, align, className, style, children, ref, ...rest }: TextProps): React.JSX.Element;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import "./Text.css";
|
|
4
|
+
function Text({
|
|
5
|
+
tier = "paragraph",
|
|
6
|
+
as = "p",
|
|
7
|
+
tone = "default",
|
|
8
|
+
weight = "default",
|
|
9
|
+
truncate = false,
|
|
10
|
+
lines,
|
|
11
|
+
numeric = false,
|
|
12
|
+
align,
|
|
13
|
+
className = "",
|
|
14
|
+
style,
|
|
15
|
+
children,
|
|
16
|
+
ref,
|
|
17
|
+
...rest
|
|
18
|
+
}) {
|
|
19
|
+
const Tag = as;
|
|
20
|
+
const clamped = lines !== void 0 && lines > 0;
|
|
21
|
+
const classes = [
|
|
22
|
+
"ds-text",
|
|
23
|
+
`ds-text--${tier}`,
|
|
24
|
+
tone !== "default" && `ds-text--tone-${tone}`,
|
|
25
|
+
weight === "emphasis" && "ds-text--emphasis",
|
|
26
|
+
clamped ? "ds-text--clamp" : truncate && "ds-text--truncate",
|
|
27
|
+
numeric && "ds-text--numeric",
|
|
28
|
+
align && `ds-text--align-${align}`,
|
|
29
|
+
className
|
|
30
|
+
].filter(Boolean).join(" ");
|
|
31
|
+
const resolvedStyle = clamped ? { ...style, "--ds-text-lines": lines } : style;
|
|
32
|
+
return /* @__PURE__ */ jsx(Tag, { ...rest, ref, className: classes, style: resolvedStyle, children });
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
Text
|
|
36
|
+
};
|
|
@@ -864,6 +864,35 @@
|
|
|
864
864
|
padding-inline-start: var(--padding-200);
|
|
865
865
|
}
|
|
866
866
|
|
|
867
|
+
/* The footer's two forms share one cell, AppSidebar's: the slot keeps one
|
|
868
|
+
height in both states, so the rail never snaps, and the expanded form
|
|
869
|
+
fades out as the collapsed form fades in. The collapsed form stacks its
|
|
870
|
+
controls (the same ones at their smallest) on the rail's axis. */
|
|
871
|
+
.ds-thread-panel__footer-slots {
|
|
872
|
+
display: grid;
|
|
873
|
+
min-width: 0;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
.ds-thread-panel__footer-slots > .ds-thread-panel__footer-slot {
|
|
877
|
+
grid-area: 1 / 1;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
.ds-thread-panel__footer-slot--collapsed {
|
|
881
|
+
display: flex;
|
|
882
|
+
flex-direction: column;
|
|
883
|
+
align-items: center;
|
|
884
|
+
justify-content: flex-end;
|
|
885
|
+
gap: var(--gap-200);
|
|
886
|
+
padding-inline-start: 0;
|
|
887
|
+
opacity: 1;
|
|
888
|
+
pointer-events: auto;
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
.ds-thread-panel--expanded .ds-thread-panel__footer-slot--collapsed {
|
|
892
|
+
opacity: 0;
|
|
893
|
+
pointer-events: none;
|
|
894
|
+
}
|
|
895
|
+
|
|
867
896
|
/* The rails' one profile block, AppSidebar's: a 40px avatar, the name over
|
|
868
897
|
the meta line in paragraph type, AppSidebar's avatar-to-name gap.
|
|
869
898
|
Collapsed, the avatar sits on the rail's axis (12 + 40 + 12 = 64);
|
|
@@ -164,6 +164,8 @@ type ThreadPanelOwnProps = {
|
|
|
164
164
|
profile?: ThreadPanelProfile;
|
|
165
165
|
/** Rendered in the footer above the profile row — a theme toggle, a storage meter. Fades out while collapsed, AppSidebar's contract. */
|
|
166
166
|
footerSlot?: React.ReactNode;
|
|
167
|
+
/** Rendered above the profile row while the panel is collapsed, in `footerSlot`'s place: the same controls at their smallest, such as a SegmentedControl's or ThemeToggle's `cycle` circle, stacked and centred on the rail's axis. AppSidebar's contract: the two forms share one cell and crossfade with the panel, and whichever is hidden is inert. */
|
|
168
|
+
collapsedFooterSlot?: React.ReactNode;
|
|
167
169
|
/** Additional CSS classes */
|
|
168
170
|
className?: string;
|
|
169
171
|
/**
|
|
@@ -150,6 +150,7 @@ const ThreadPanel = React.forwardRef(
|
|
|
150
150
|
expandLabel = "Expand the panel",
|
|
151
151
|
profile,
|
|
152
152
|
footerSlot,
|
|
153
|
+
collapsedFooterSlot,
|
|
153
154
|
className = "",
|
|
154
155
|
linkComponent,
|
|
155
156
|
...rest
|
|
@@ -171,7 +172,7 @@ const ThreadPanel = React.forwardRef(
|
|
|
171
172
|
);
|
|
172
173
|
const showHeader = Boolean(logo || logoText || onExpandedChange);
|
|
173
174
|
const showNew = Boolean(newThreadLabel || onNewThread || newThreadHref);
|
|
174
|
-
const showFooter = Boolean(footerSlot || profile);
|
|
175
|
+
const showFooter = Boolean(footerSlot || collapsedFooterSlot || profile);
|
|
175
176
|
const logoExpands = Boolean(logo && !expanded && onExpandedChange);
|
|
176
177
|
const toggleLabel = expanded ? collapseLabel : expandLabel;
|
|
177
178
|
const toggle = onExpandedChange && /* @__PURE__ */ jsx(
|
|
@@ -508,7 +509,17 @@ const ThreadPanel = React.forwardRef(
|
|
|
508
509
|
)
|
|
509
510
|
] }),
|
|
510
511
|
showFooter && /* @__PURE__ */ jsxs("div", { className: `${baseClass}__footer`, children: [
|
|
511
|
-
footerSlot && /* @__PURE__ */
|
|
512
|
+
(footerSlot || collapsedFooterSlot) && /* @__PURE__ */ jsxs("div", { className: `${baseClass}__footer-slots`, children: [
|
|
513
|
+
footerSlot && /* @__PURE__ */ jsx("div", { className: `${baseClass}__footer-slot`, inert: !expanded, children: footerSlot }),
|
|
514
|
+
collapsedFooterSlot && /* @__PURE__ */ jsx(
|
|
515
|
+
"div",
|
|
516
|
+
{
|
|
517
|
+
className: `${baseClass}__footer-slot ${baseClass}__footer-slot--collapsed`,
|
|
518
|
+
inert: expanded,
|
|
519
|
+
children: collapsedFooterSlot
|
|
520
|
+
}
|
|
521
|
+
)
|
|
522
|
+
] }),
|
|
512
523
|
profile && /* @__PURE__ */ jsxs(
|
|
513
524
|
"div",
|
|
514
525
|
{
|
|
@@ -66,6 +66,117 @@
|
|
|
66
66
|
min-width: 0;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
/* Heading block: the title and the description under it */
|
|
70
|
+
|
|
71
|
+
.ds-widget__heading {
|
|
72
|
+
display: flex;
|
|
73
|
+
flex-direction: column;
|
|
74
|
+
gap: var(--gap-050);
|
|
75
|
+
min-width: 0;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.ds-widget__description {
|
|
79
|
+
margin: 0;
|
|
80
|
+
font-family: var(--font-paragraph-sm-family);
|
|
81
|
+
font-size: var(--font-paragraph-sm-size);
|
|
82
|
+
font-weight: var(--font-paragraph-sm-weight);
|
|
83
|
+
line-height: var(--font-paragraph-sm-line-height);
|
|
84
|
+
letter-spacing: var(--font-paragraph-sm-letter-spacing);
|
|
85
|
+
color: var(--color-text-secondary);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/* Footer — behind the family's divider, a step below the body */
|
|
89
|
+
|
|
90
|
+
.ds-widget__footer {
|
|
91
|
+
display: flex;
|
|
92
|
+
flex-wrap: wrap;
|
|
93
|
+
align-items: center;
|
|
94
|
+
justify-content: flex-end;
|
|
95
|
+
gap: var(--gap-200);
|
|
96
|
+
min-width: 0;
|
|
97
|
+
padding-block-start: var(--padding-300);
|
|
98
|
+
border-block-start: var(--border-025) solid var(--color-divider);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/* Padding */
|
|
102
|
+
|
|
103
|
+
.ds-widget--padding-compact {
|
|
104
|
+
gap: var(--gap-200);
|
|
105
|
+
padding: var(--padding-300);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.ds-widget--padding-none {
|
|
109
|
+
gap: 0;
|
|
110
|
+
padding: 0;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.ds-widget--padding-none .ds-widget__header {
|
|
114
|
+
padding: var(--padding-500);
|
|
115
|
+
padding-block-end: var(--padding-300);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.ds-widget--padding-none .ds-widget__footer {
|
|
119
|
+
padding: var(--padding-300) var(--padding-500);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/* Collapsible — the title is the disclosure button */
|
|
123
|
+
|
|
124
|
+
.ds-widget__region {
|
|
125
|
+
display: flex;
|
|
126
|
+
flex-direction: column;
|
|
127
|
+
gap: var(--gap-300);
|
|
128
|
+
min-width: 0;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.ds-widget__region[hidden] {
|
|
132
|
+
display: none;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.ds-widget--padding-none .ds-widget__region {
|
|
136
|
+
gap: 0;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.ds-widget__toggle {
|
|
140
|
+
display: inline-flex;
|
|
141
|
+
align-items: baseline;
|
|
142
|
+
gap: var(--gap-200);
|
|
143
|
+
min-width: 0;
|
|
144
|
+
margin: 0;
|
|
145
|
+
padding: 0;
|
|
146
|
+
border: none;
|
|
147
|
+
border-radius: var(--radius-100);
|
|
148
|
+
background: none;
|
|
149
|
+
font: inherit;
|
|
150
|
+
letter-spacing: inherit;
|
|
151
|
+
color: inherit;
|
|
152
|
+
text-align: start;
|
|
153
|
+
cursor: pointer;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.ds-widget__toggle:focus-visible {
|
|
157
|
+
outline: var(--border-050) solid var(--color-action-primary-bg);
|
|
158
|
+
outline-offset: var(--border-050);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.ds-widget__chevron {
|
|
162
|
+
--icon-size: var(--icon-size-500);
|
|
163
|
+
align-self: center;
|
|
164
|
+
color: var(--color-icon-primary);
|
|
165
|
+
transition: transform var(--motion-duration-base) var(--motion-ease-standard);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.ds-widget__toggle[aria-expanded='false'] .ds-widget__chevron {
|
|
169
|
+
transform: rotate(-90deg);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.ds-widget__toggle[aria-expanded='false'] .ds-widget__chevron:dir(rtl) {
|
|
173
|
+
transform: rotate(90deg);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.ds-widget--collapsible:has(.ds-widget__region[hidden]) {
|
|
177
|
+
gap: 0;
|
|
178
|
+
}
|
|
179
|
+
|
|
69
180
|
/* Group — a labelled run of rows */
|
|
70
181
|
|
|
71
182
|
.ds-widget-group {
|
|
@@ -10,7 +10,21 @@ type WidgetOwnProps = {
|
|
|
10
10
|
action?: React.ReactNode;
|
|
11
11
|
/** Heading element for the title, so the tile takes its place in the page's outline. */
|
|
12
12
|
titleAs?: 'h2' | 'h3' | 'h4';
|
|
13
|
-
/**
|
|
13
|
+
/** A line of quieter text under the title, saying what the section holds. It also describes the section to a screen reader. */
|
|
14
|
+
description?: React.ReactNode;
|
|
15
|
+
/** A slot under the body, behind a divider: the section's actions (Save, Cancel), a total, a link to everything. */
|
|
16
|
+
footer?: React.ReactNode;
|
|
17
|
+
/** The inset: `default` the tile's own, `compact` a step tighter for dense settings, `none` for a body that runs edge to edge (a table, a map) while the header and footer keep the default inset. */
|
|
18
|
+
padding?: 'default' | 'compact' | 'none';
|
|
19
|
+
/** Let the reader fold the section away: the title becomes a button that shows and hides the body and footer, which leave the tab order and the accessibility tree while hidden. */
|
|
20
|
+
collapsible?: boolean;
|
|
21
|
+
/** Whether a collapsible section is open (controlled). Pair with `onOpenChange`. */
|
|
22
|
+
open?: boolean;
|
|
23
|
+
/** Whether a collapsible section starts open (uncontrolled). Defaults to true. */
|
|
24
|
+
defaultOpen?: boolean;
|
|
25
|
+
/** Called with the new open state when the reader folds or unfolds a collapsible section. */
|
|
26
|
+
onOpenChange?: (open: boolean) => void;
|
|
27
|
+
/** The tile's body: WidgetRows, WidgetGroups, a chart, a figure, a form, anything. */
|
|
14
28
|
children?: React.ReactNode;
|
|
15
29
|
/** The BCP 47 locale the count is written in, such as `ar-EG`. Defaults to `en-US`. This component can render from a Server Component, so it takes the prop alone and reads no LocaleProvider. */
|
|
16
30
|
locale?: string;
|
|
@@ -1,27 +1,79 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import React from "react";
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import React, { useId } from "react";
|
|
3
3
|
import "./Widget.css";
|
|
4
4
|
import { formatNumber, DEFAULT_LOCALE } from "../../behaviors/locale.js";
|
|
5
|
+
import { WidgetDisclosure } from "./WidgetDisclosure.js";
|
|
5
6
|
const Widget = React.forwardRef(
|
|
6
|
-
({
|
|
7
|
+
({
|
|
8
|
+
title,
|
|
9
|
+
count,
|
|
10
|
+
action,
|
|
11
|
+
titleAs: Title = "h3",
|
|
12
|
+
description,
|
|
13
|
+
footer,
|
|
14
|
+
padding = "default",
|
|
15
|
+
collapsible = false,
|
|
16
|
+
open,
|
|
17
|
+
defaultOpen = true,
|
|
18
|
+
onOpenChange,
|
|
19
|
+
children,
|
|
20
|
+
locale = DEFAULT_LOCALE,
|
|
21
|
+
className = "",
|
|
22
|
+
...rest
|
|
23
|
+
}, ref) => {
|
|
7
24
|
const baseClass = "ds-widget";
|
|
8
|
-
|
|
25
|
+
const hasDescription = description != null && description !== false && description !== "";
|
|
26
|
+
const hasFooter = footer != null && footer !== false;
|
|
27
|
+
const idBase = useId();
|
|
28
|
+
const descriptionId = hasDescription ? `${idBase}-description` : void 0;
|
|
29
|
+
const countText = count !== void 0 ? formatNumber(count, locale) : void 0;
|
|
30
|
+
const classes = [
|
|
31
|
+
baseClass,
|
|
32
|
+
padding !== "default" && `${baseClass}--padding-${padding}`,
|
|
33
|
+
collapsible && `${baseClass}--collapsible`,
|
|
34
|
+
className
|
|
35
|
+
].filter(Boolean).join(" ");
|
|
36
|
+
const descriptionNode = hasDescription ? /* @__PURE__ */ jsx("p", { className: `${baseClass}__description`, id: descriptionId, children: description }) : null;
|
|
37
|
+
const footerNode = hasFooter ? /* @__PURE__ */ jsx("footer", { className: `${baseClass}__footer`, children: footer }) : null;
|
|
38
|
+
return /* @__PURE__ */ jsx(
|
|
9
39
|
"section",
|
|
10
40
|
{
|
|
11
41
|
"aria-label": title,
|
|
42
|
+
"aria-describedby": descriptionId,
|
|
12
43
|
...rest,
|
|
13
44
|
ref,
|
|
14
|
-
className:
|
|
15
|
-
children:
|
|
45
|
+
className: classes,
|
|
46
|
+
children: collapsible ? /* @__PURE__ */ jsxs(
|
|
47
|
+
WidgetDisclosure,
|
|
48
|
+
{
|
|
49
|
+
idBase,
|
|
50
|
+
title,
|
|
51
|
+
titleAs: Title,
|
|
52
|
+
count: countText,
|
|
53
|
+
action,
|
|
54
|
+
description: descriptionNode,
|
|
55
|
+
open,
|
|
56
|
+
defaultOpen,
|
|
57
|
+
onOpenChange,
|
|
58
|
+
children: [
|
|
59
|
+
/* @__PURE__ */ jsx("div", { className: `${baseClass}__body`, children }),
|
|
60
|
+
footerNode
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
16
64
|
/* @__PURE__ */ jsxs("header", { className: `${baseClass}__header`, children: [
|
|
17
|
-
/* @__PURE__ */ jsxs(
|
|
18
|
-
|
|
19
|
-
|
|
65
|
+
/* @__PURE__ */ jsxs("div", { className: `${baseClass}__heading`, children: [
|
|
66
|
+
/* @__PURE__ */ jsxs(Title, { className: `${baseClass}__title`, children: [
|
|
67
|
+
title,
|
|
68
|
+
countText !== void 0 && /* @__PURE__ */ jsx("span", { className: `${baseClass}__count`, children: countText })
|
|
69
|
+
] }),
|
|
70
|
+
descriptionNode
|
|
20
71
|
] }),
|
|
21
72
|
action && /* @__PURE__ */ jsx("span", { className: `${baseClass}__action`, children: action })
|
|
22
73
|
] }),
|
|
23
|
-
/* @__PURE__ */ jsx("div", { className: `${baseClass}__body`, children })
|
|
24
|
-
|
|
74
|
+
/* @__PURE__ */ jsx("div", { className: `${baseClass}__body`, children }),
|
|
75
|
+
footerNode
|
|
76
|
+
] })
|
|
25
77
|
}
|
|
26
78
|
);
|
|
27
79
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/** Props owned by WidgetDisclosure itself. */
|
|
3
|
+
export interface WidgetDisclosureProps {
|
|
4
|
+
/** The id the header button's region is named from. */
|
|
5
|
+
idBase: string;
|
|
6
|
+
/** The tile's heading, which becomes the button's text. */
|
|
7
|
+
title: string;
|
|
8
|
+
/** The heading element the button sits in. */
|
|
9
|
+
titleAs: 'h2' | 'h3' | 'h4';
|
|
10
|
+
/** The count already written in the tile's locale. */
|
|
11
|
+
count?: string;
|
|
12
|
+
/** The header's trailing slot, kept outside the button. */
|
|
13
|
+
action?: React.ReactNode;
|
|
14
|
+
/** The description paragraph, kept under the heading and outside the button. */
|
|
15
|
+
description?: React.ReactNode;
|
|
16
|
+
/** Whether the section is open (controlled). */
|
|
17
|
+
open?: boolean;
|
|
18
|
+
/** Whether the section starts open (uncontrolled). */
|
|
19
|
+
defaultOpen: boolean;
|
|
20
|
+
/** Called with the new open state. */
|
|
21
|
+
onOpenChange?: (open: boolean) => void;
|
|
22
|
+
/** The body and footer the button shows and hides. */
|
|
23
|
+
children: React.ReactNode;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The collapsible half of Widget: the header whose title is a disclosure
|
|
27
|
+
* button, and the region it shows and hides. Internal: Widget renders it
|
|
28
|
+
* when `collapsible` is set, so the tile itself stays server-renderable.
|
|
29
|
+
*/
|
|
30
|
+
export declare function WidgetDisclosure({ idBase, title, titleAs: Title, count, action, description, open: openProp, defaultOpen, onOpenChange, children, }: WidgetDisclosureProps): React.JSX.Element;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import "../../fonts/material-symbols.css";
|
|
5
|
+
function WidgetDisclosure({
|
|
6
|
+
idBase,
|
|
7
|
+
title,
|
|
8
|
+
titleAs: Title,
|
|
9
|
+
count,
|
|
10
|
+
action,
|
|
11
|
+
description,
|
|
12
|
+
open: openProp,
|
|
13
|
+
defaultOpen,
|
|
14
|
+
onOpenChange,
|
|
15
|
+
children
|
|
16
|
+
}) {
|
|
17
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);
|
|
18
|
+
const open = openProp ?? uncontrolledOpen;
|
|
19
|
+
const regionId = `${idBase}-region`;
|
|
20
|
+
const toggle = () => {
|
|
21
|
+
const next = !open;
|
|
22
|
+
if (openProp === void 0) setUncontrolledOpen(next);
|
|
23
|
+
onOpenChange?.(next);
|
|
24
|
+
};
|
|
25
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
26
|
+
/* @__PURE__ */ jsxs("header", { className: "ds-widget__header", children: [
|
|
27
|
+
/* @__PURE__ */ jsxs("div", { className: "ds-widget__heading", children: [
|
|
28
|
+
/* @__PURE__ */ jsx(Title, { className: "ds-widget__title", children: /* @__PURE__ */ jsxs(
|
|
29
|
+
"button",
|
|
30
|
+
{
|
|
31
|
+
type: "button",
|
|
32
|
+
className: "ds-widget__toggle",
|
|
33
|
+
"aria-expanded": open,
|
|
34
|
+
"aria-controls": regionId,
|
|
35
|
+
onClick: toggle,
|
|
36
|
+
children: [
|
|
37
|
+
/* @__PURE__ */ jsx("span", { className: "ds-widget__toggle-text", children: title }),
|
|
38
|
+
count !== void 0 && /* @__PURE__ */ jsx("span", { className: "ds-widget__count", children: count }),
|
|
39
|
+
/* @__PURE__ */ jsx("span", { className: "ds-widget__chevron material-symbols-rounded", "aria-hidden": "true", children: "expand_more" })
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
) }),
|
|
43
|
+
description
|
|
44
|
+
] }),
|
|
45
|
+
action && /* @__PURE__ */ jsx("span", { className: "ds-widget__action", children: action })
|
|
46
|
+
] }),
|
|
47
|
+
/* @__PURE__ */ jsx("div", { className: "ds-widget__region", id: regionId, hidden: !open, children })
|
|
48
|
+
] });
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
WidgetDisclosure
|
|
52
|
+
};
|