@gtivr4/a1-design-system-react 0.1.0 → 0.2.3
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/package.json +1 -1
- package/src/color-scheme.css +586 -24
- package/src/components/accordion/Accordion.jsx +80 -0
- package/src/components/accordion/accordion.css +118 -0
- package/src/components/banner/Banner.jsx +66 -0
- package/src/components/banner/banner.css +205 -0
- package/src/components/bleed/Bleed.jsx +27 -0
- package/src/components/bleed/bleed.css +5 -0
- package/src/components/blockquote/Blockquote.jsx +40 -0
- package/src/components/blockquote/blockquote.css +166 -0
- package/src/components/breadcrumb/Breadcrumb.jsx +82 -0
- package/src/components/breadcrumb/breadcrumb.css +133 -0
- package/src/components/button/button.css +42 -12
- package/src/components/button-container/ButtonContainer.jsx +20 -1
- package/src/components/button-container/button-container.css +19 -1
- package/src/components/calendar/Calendar.jsx +383 -0
- package/src/components/calendar/calendar.css +225 -0
- package/src/components/card/Card.jsx +50 -12
- package/src/components/card/card.css +178 -14
- package/src/components/checkbox-group/CheckboxGroup.jsx +120 -0
- package/src/components/checkbox-group/checkbox-group.css +304 -0
- package/src/components/cluster/Cluster.jsx +52 -0
- package/src/components/cluster/cluster.css +9 -0
- package/src/components/code/Code.jsx +135 -0
- package/src/components/code/code.css +60 -0
- package/src/components/data-table/DataTable.jsx +721 -0
- package/src/components/data-table/DataTableFilters.jsx +339 -0
- package/src/components/data-table/data-table-filters.css +259 -0
- package/src/components/data-table/data-table.css +425 -0
- package/src/components/dialog/Dialog.jsx +45 -2
- package/src/components/dialog/dialog.css +13 -4
- package/src/components/divider/Divider.jsx +64 -0
- package/src/components/divider/divider.css +170 -0
- package/src/components/field/CreditCardField.jsx +131 -0
- package/src/components/field/DateField.jsx +11 -0
- package/src/components/field/NumberField.jsx +11 -0
- package/src/components/field/PhoneField.jsx +107 -0
- package/src/components/field/SelectField.jsx +86 -0
- package/src/components/field/TextField.jsx +83 -0
- package/src/components/field/TextareaField.jsx +147 -0
- package/src/components/field/TimeField.jsx +11 -0
- package/src/components/field/ZipField.jsx +114 -0
- package/src/components/field/credit-card.css +30 -0
- package/src/components/field/field.css +380 -0
- package/src/components/field/textarea-field.css +185 -0
- package/src/components/field-row/FieldRow.jsx +23 -0
- package/src/components/field-row/field-row.css +51 -0
- package/src/components/fieldset/Fieldset.jsx +49 -0
- package/src/components/fieldset/fieldset.css +75 -0
- package/src/components/figure/Figure.jsx +63 -0
- package/src/components/figure/figure.css +97 -0
- package/src/components/grid/Grid.jsx +36 -2
- package/src/components/grid/grid.css +129 -4
- package/src/components/heading/Heading.jsx +41 -1
- package/src/components/heading/heading.css +65 -4
- package/src/components/icon/icon.css +1 -0
- package/src/components/icon-button/icon-button.css +1 -0
- package/src/components/inline/inline.css +51 -0
- package/src/components/inline-editable/InlineEditable.jsx +77 -0
- package/src/components/inline-editable/inline-editable.css +47 -0
- package/src/components/inset/Inset.jsx +27 -0
- package/src/components/inset/inset.css +6 -0
- package/src/components/labels/Labels.jsx +5 -5
- package/src/components/link/Link.jsx +2 -3
- package/src/components/link/link.css +30 -1
- package/src/components/list/List.jsx +92 -0
- package/src/components/list/list.css +178 -0
- package/src/components/menu/Menu.jsx +243 -10
- package/src/components/menu/menu.css +157 -17
- package/src/components/message/Message.jsx +25 -50
- package/src/components/message/message.css +50 -33
- package/src/components/notification/Notification.jsx +1 -1
- package/src/components/page-layout/PageLayout.jsx +16 -1
- package/src/components/page-layout/page-layout.css +97 -4
- package/src/components/page-nav/PageNav.jsx +110 -0
- package/src/components/page-nav/page-nav.css +167 -0
- package/src/components/paragraph/Paragraph.jsx +35 -2
- package/src/components/paragraph/paragraph.css +38 -1
- package/src/components/radio-group/RadioGroup.jsx +121 -0
- package/src/components/radio-group/radio-group.css +268 -0
- package/src/components/section/Section.jsx +108 -0
- package/src/components/section/section.css +280 -0
- package/src/components/segmented-control/SegmentedControl.jsx +4 -0
- package/src/components/segmented-control/segmented.css +13 -0
- package/src/components/side-nav/SideNav.jsx +29 -9
- package/src/components/side-nav/scrim.css +1 -1
- package/src/components/side-nav/side-nav.css +70 -32
- package/src/components/snackbar/Snackbar.jsx +56 -0
- package/src/components/snackbar/snackbar.css +113 -0
- package/src/components/spacer/Spacer.jsx +36 -0
- package/src/components/spacer/spacer.css +44 -0
- package/src/components/stack/Stack.jsx +100 -0
- package/src/components/stack/stack.css +37 -0
- package/src/components/switch/Switch.jsx +114 -0
- package/src/components/switch/switch.css +276 -0
- package/src/components/system-banner/SystemBanner.jsx +57 -0
- package/src/components/system-banner/system-banner.css +118 -0
- package/src/components/tabs/Tabs.jsx +96 -28
- package/src/components/tabs/tabs.css +352 -15
- package/src/components/token-select/TokenSelect.jsx +159 -0
- package/src/components/token-select/token-select.css +110 -0
- package/src/components/top-header/TopHeader.jsx +641 -0
- package/src/components/top-header/top-header.css +337 -0
- package/src/illustrations/ComponentThumbnails.jsx +227 -0
- package/src/index.js +41 -5
- package/src/themes.css +256 -5
- package/src/utilities/spacing.css +8 -0
- package/src/utilities/sr-only.css +16 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
.a1-cluster {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-wrap: wrap;
|
|
4
|
+
align-items: var(--a1-cluster-align, center);
|
|
5
|
+
justify-content: var(--a1-cluster-justify, flex-start);
|
|
6
|
+
row-gap: var(--a1-cluster-row-gap, var(--base-spacing-8));
|
|
7
|
+
column-gap: var(--a1-cluster-column-gap, var(--base-spacing-8));
|
|
8
|
+
min-width: 0;
|
|
9
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { Children, isValidElement, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { Button } from "../button/Button.jsx";
|
|
3
|
+
import { useLabel } from "../labels/Labels.jsx";
|
|
4
|
+
import "./code.css";
|
|
5
|
+
|
|
6
|
+
const variants = ["inline", "block"];
|
|
7
|
+
|
|
8
|
+
function textFromChildren(children) {
|
|
9
|
+
if (children == null || typeof children === "boolean") return "";
|
|
10
|
+
if (typeof children === "string" || typeof children === "number") return String(children);
|
|
11
|
+
if (Array.isArray(children)) return children.map(textFromChildren).join("");
|
|
12
|
+
if (isValidElement(children)) return textFromChildren(children.props.children);
|
|
13
|
+
return "";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function writeClipboard(text) {
|
|
17
|
+
if (typeof navigator !== "undefined" && navigator.clipboard?.writeText) {
|
|
18
|
+
return navigator.clipboard.writeText(text).catch(() => writeClipboardFallback(text));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return writeClipboardFallback(text);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function writeClipboardFallback(text) {
|
|
25
|
+
if (typeof document === "undefined") return Promise.reject(new Error("Clipboard unavailable"));
|
|
26
|
+
|
|
27
|
+
const textarea = document.createElement("textarea");
|
|
28
|
+
textarea.value = text;
|
|
29
|
+
textarea.setAttribute("readonly", "");
|
|
30
|
+
textarea.style.position = "fixed";
|
|
31
|
+
textarea.style.insetBlockStart = "0";
|
|
32
|
+
textarea.style.insetInlineStart = "0";
|
|
33
|
+
textarea.style.inlineSize = "1px";
|
|
34
|
+
textarea.style.blockSize = "1px";
|
|
35
|
+
textarea.style.opacity = "0";
|
|
36
|
+
document.body.appendChild(textarea);
|
|
37
|
+
textarea.focus();
|
|
38
|
+
textarea.select();
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
textarea.setSelectionRange(0, textarea.value.length);
|
|
42
|
+
const copied = document.execCommand("copy");
|
|
43
|
+
if (!copied) throw new Error("Copy command failed");
|
|
44
|
+
return Promise.resolve();
|
|
45
|
+
} catch (error) {
|
|
46
|
+
return Promise.reject(error);
|
|
47
|
+
} finally {
|
|
48
|
+
document.body.removeChild(textarea);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function Code({
|
|
53
|
+
variant = "inline",
|
|
54
|
+
wrapping = false,
|
|
55
|
+
copyCode = false,
|
|
56
|
+
copyText,
|
|
57
|
+
className = "",
|
|
58
|
+
children,
|
|
59
|
+
...props
|
|
60
|
+
}) {
|
|
61
|
+
const resolvedVariant = variants.includes(variant) ? variant : "inline";
|
|
62
|
+
const [copied, setCopied] = useState(false);
|
|
63
|
+
const resetTimer = useRef(null);
|
|
64
|
+
const copyLabel = useLabel("code.copyCode", "Copy code");
|
|
65
|
+
const copiedLabel = useLabel("code.copied", "Copied");
|
|
66
|
+
const textToCopy = useMemo(
|
|
67
|
+
() => copyText || textFromChildren(Children.toArray(children)),
|
|
68
|
+
[children, copyText],
|
|
69
|
+
);
|
|
70
|
+
const shouldRenderBlock = resolvedVariant === "block" || copyCode;
|
|
71
|
+
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
return () => {
|
|
74
|
+
if (resetTimer.current) window.clearTimeout(resetTimer.current);
|
|
75
|
+
};
|
|
76
|
+
}, []);
|
|
77
|
+
|
|
78
|
+
async function handleCopy() {
|
|
79
|
+
await writeClipboard(textToCopy);
|
|
80
|
+
setCopied(true);
|
|
81
|
+
|
|
82
|
+
if (resetTimer.current) window.clearTimeout(resetTimer.current);
|
|
83
|
+
resetTimer.current = window.setTimeout(() => {
|
|
84
|
+
setCopied(false);
|
|
85
|
+
resetTimer.current = null;
|
|
86
|
+
}, 2000);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const codeClasses = [
|
|
90
|
+
"a1-code",
|
|
91
|
+
`a1-code--${resolvedVariant}`,
|
|
92
|
+
wrapping && "a1-code--wrapping",
|
|
93
|
+
!shouldRenderBlock && className,
|
|
94
|
+
]
|
|
95
|
+
.filter(Boolean)
|
|
96
|
+
.join(" ");
|
|
97
|
+
|
|
98
|
+
if (!shouldRenderBlock) {
|
|
99
|
+
return (
|
|
100
|
+
<code className={codeClasses} {...props}>
|
|
101
|
+
{children}
|
|
102
|
+
</code>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return (
|
|
107
|
+
<div
|
|
108
|
+
className={[
|
|
109
|
+
"a1-code-block",
|
|
110
|
+
copyCode && "a1-code-block--copyable",
|
|
111
|
+
className,
|
|
112
|
+
]
|
|
113
|
+
.filter(Boolean)
|
|
114
|
+
.join(" ")}
|
|
115
|
+
>
|
|
116
|
+
<pre className="a1-code-block__pre">
|
|
117
|
+
<code className={codeClasses} {...props}>
|
|
118
|
+
{children}
|
|
119
|
+
</code>
|
|
120
|
+
</pre>
|
|
121
|
+
{copyCode && (
|
|
122
|
+
<Button
|
|
123
|
+
className="a1-code-block__copy"
|
|
124
|
+
icon="content_copy"
|
|
125
|
+
size="sm"
|
|
126
|
+
variant="tertiary"
|
|
127
|
+
onClick={handleCopy}
|
|
128
|
+
type="button"
|
|
129
|
+
>
|
|
130
|
+
{copied ? copiedLabel : copyLabel}
|
|
131
|
+
</Button>
|
|
132
|
+
)}
|
|
133
|
+
</div>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
.a1-code {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
max-inline-size: 100%;
|
|
4
|
+
font-family: var(--component-inline-font-family-mono);
|
|
5
|
+
font-size: var(--component-inline-code-font-size);
|
|
6
|
+
line-height: 1.6;
|
|
7
|
+
color: var(--semantic-color-text-default);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.a1-code--inline {
|
|
11
|
+
display: inline;
|
|
12
|
+
padding: var(--component-inline-padding-block) var(--component-inline-padding-inline);
|
|
13
|
+
border-radius: var(--component-inline-border-radius);
|
|
14
|
+
background: var(--semantic-color-surface-raised);
|
|
15
|
+
white-space: nowrap;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.a1-code--inline.a1-code--wrapping {
|
|
19
|
+
white-space: normal;
|
|
20
|
+
overflow-wrap: anywhere;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.a1-code-block {
|
|
24
|
+
box-sizing: border-box;
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-direction: column;
|
|
27
|
+
align-items: flex-start;
|
|
28
|
+
gap: var(--base-spacing-8);
|
|
29
|
+
max-inline-size: 100%;
|
|
30
|
+
color: var(--semantic-color-text-default);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.a1-code-block__pre {
|
|
34
|
+
box-sizing: border-box;
|
|
35
|
+
max-inline-size: 100%;
|
|
36
|
+
inline-size: 100%;
|
|
37
|
+
margin: 0;
|
|
38
|
+
overflow-x: auto;
|
|
39
|
+
padding: var(--base-spacing-16);
|
|
40
|
+
border: var(--component-card-border-width) solid var(--semantic-color-border-subtle);
|
|
41
|
+
border-radius: var(--base-radius-md);
|
|
42
|
+
background: var(--semantic-color-surface-panel);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.a1-code--block {
|
|
46
|
+
display: block;
|
|
47
|
+
padding: 0;
|
|
48
|
+
border-radius: 0;
|
|
49
|
+
background: transparent;
|
|
50
|
+
white-space: pre;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.a1-code--block.a1-code--wrapping {
|
|
54
|
+
white-space: pre-wrap;
|
|
55
|
+
overflow-wrap: anywhere;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.a1-code-block__copy {
|
|
59
|
+
margin: 0;
|
|
60
|
+
}
|