@solexllc/usx-react 0.10.0 → 0.12.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 +16 -0
- package/dist/Popover-BzDCTuQM.cjs +984 -0
- package/dist/Popover-LToVWsWc.js +985 -0
- package/dist/chat.cjs +1391 -0
- package/dist/chat.js +1391 -0
- package/dist/index.cjs +4426 -5231
- package/dist/index.js +168 -970
- package/package.json +9 -5
- package/src/chat.js +15 -0
- package/src/components/avatar/Avatar.tsx +54 -16
- package/src/components/avatar/avatar.django-snapshot.html +112 -0
- package/src/components/avatar/avatar.django.html +2 -2
- package/src/components/avatar/avatar.html +25 -0
- package/src/components/avatar/avatar.react-snapshot.html +104 -0
- package/src/components/avatar/config.json +13 -15
- package/src/components/avatar-group/AvatarGroup.tsx +17 -15
- package/src/components/avatar-group/avatar-group.django-snapshot.html +22 -0
- package/src/components/avatar-group/avatar-group.django.html +1 -1
- package/src/components/avatar-group/avatar-group.react-snapshot.html +20 -0
- package/src/components/avatar-group/config.json +2 -2
- package/src/components/back-to-top/BackToTop.tsx +21 -57
- package/src/components/back-to-top/back-to-top.django-snapshot.html +101 -202
- package/src/components/back-to-top/back-to-top.django.html +11 -38
- package/src/components/back-to-top/back-to-top.html +22 -106
- package/src/components/back-to-top/back-to-top.react-snapshot.html +94 -148
- package/src/components/back-to-top/config.json +41 -10
- package/src/components/button/Button.tsx +12 -3
- package/src/components/button/button.django-snapshot.html +18 -0
- package/src/components/button/button.django.html +3 -2
- package/src/components/button/button.react-snapshot.html +16 -0
- package/src/components/button/config.json +11 -2
- package/src/components/callout/callout.django.html +1 -1
- package/src/components/callout/config.json +7 -16
- package/src/components/character-count/CharacterCount.tsx +2 -0
- package/src/components/character-count/character-count.react-snapshot.html +7 -0
- package/src/components/chat/Chat.tsx +575 -0
- package/src/components/chat/README.md +174 -0
- package/src/components/chat/avatarProps.ts +32 -0
- package/src/components/chat/chat.django-snapshot.html +23515 -0
- package/src/components/chat/chat.django.html +75 -0
- package/src/components/chat/chat.html +116 -0
- package/src/components/chat/chat.react-snapshot.html +16895 -0
- package/src/components/chat/config.json +1241 -0
- package/src/components/chat-attachment/ChatAttachment.tsx +39 -0
- package/src/components/chat-attachment/chat-attachment.django.html +24 -0
- package/src/components/chat-attachment/chat-attachment.html +10 -0
- package/src/components/chat-attachment/config.json +27 -0
- package/src/components/chat-attachments/ChatAttachments.tsx +17 -0
- package/src/components/chat-attachments/chat-attachments.django-snapshot.html +58 -0
- package/src/components/chat-attachments/chat-attachments.django.html +10 -0
- package/src/components/chat-attachments/chat-attachments.html +14 -0
- package/src/components/chat-attachments/chat-attachments.react-snapshot.html +46 -0
- package/src/components/chat-attachments/config.json +25 -0
- package/src/components/chat-bubble/ChatBubble.tsx +39 -0
- package/src/components/chat-bubble/ChatFormattedText.tsx +138 -0
- package/src/components/chat-bubble/chat-bubble.django-snapshot.html +128 -0
- package/src/components/chat-bubble/chat-bubble.django.html +19 -0
- package/src/components/chat-bubble/chat-bubble.html +1 -0
- package/src/components/chat-bubble/chat-bubble.react-snapshot.html +118 -0
- package/src/components/chat-bubble/config.json +70 -0
- package/src/components/chat-composer/ChatComposer.tsx +210 -0
- package/src/components/chat-composer/README.md +15 -0
- package/src/components/chat-composer/chat-composer.django-snapshot.html +575 -0
- package/src/components/chat-composer/chat-composer.django.html +77 -0
- package/src/components/chat-composer/chat-composer.html +44 -0
- package/src/components/chat-composer/chat-composer.react-snapshot.html +519 -0
- package/src/components/chat-composer/chat-formatting.django.html +59 -0
- package/src/components/chat-composer/config.json +137 -0
- package/src/components/chat-context/ChatContext.tsx +46 -0
- package/src/components/chat-context/chat-context.django-snapshot.html +35 -0
- package/src/components/chat-context/chat-context.django.html +20 -0
- package/src/components/chat-context/chat-context.html +9 -0
- package/src/components/chat-context/chat-context.react-snapshot.html +30 -0
- package/src/components/chat-context/config.json +36 -0
- package/src/components/chat-controls/ChatControls.tsx +67 -0
- package/src/components/chat-controls/chat-controls.django-snapshot.html +114 -0
- package/src/components/chat-controls/chat-controls.django.html +36 -0
- package/src/components/chat-controls/chat-controls.html +11 -0
- package/src/components/chat-controls/chat-controls.react-snapshot.html +107 -0
- package/src/components/chat-controls/config.json +67 -0
- package/src/components/chat-directory/ChatDirectory.tsx +168 -0
- package/src/components/chat-directory/chat-directory.django-snapshot.html +546 -0
- package/src/components/chat-directory/chat-directory.django.html +14 -0
- package/src/components/chat-directory/chat-directory.html +4 -0
- package/src/components/chat-directory/chat-directory.react-snapshot.html +471 -0
- package/src/components/chat-directory/config.json +242 -0
- package/src/components/chat-directory-item/ChatDirectoryItem.tsx +150 -0
- package/src/components/chat-directory-item/chat-directory-item.django-snapshot.html +281 -0
- package/src/components/chat-directory-item/chat-directory-item.django.html +38 -0
- package/src/components/chat-directory-item/chat-directory-item.html +9 -0
- package/src/components/chat-directory-item/chat-directory-item.react-snapshot.html +249 -0
- package/src/components/chat-directory-item/config.json +103 -0
- package/src/components/chat-history/ChatHistory.tsx +30 -0
- package/src/components/chat-history/chat-history.django-snapshot.html +113 -0
- package/src/components/chat-history/chat-history.django.html +20 -0
- package/src/components/chat-history/chat-history.html +9 -0
- package/src/components/chat-history/chat-history.react-snapshot.html +111 -0
- package/src/components/chat-history/config.json +24 -0
- package/src/components/chat-message/ChatMessage.tsx +148 -0
- package/src/components/chat-message/chat-message.django-snapshot.html +758 -0
- package/src/components/chat-message/chat-message.django.html +56 -0
- package/src/components/chat-message/chat-message.html +12 -0
- package/src/components/chat-message/chat-message.react-snapshot.html +627 -0
- package/src/components/chat-message/config.json +278 -0
- package/src/components/chat-message-actions/ChatMessageActions.tsx +133 -0
- package/src/components/chat-message-actions/chat-message-actions.django-snapshot.html +345 -0
- package/src/components/chat-message-actions/chat-message-actions.django.html +29 -0
- package/src/components/chat-message-actions/chat-message-actions.html +53 -0
- package/src/components/chat-message-actions/chat-message-actions.react-snapshot.html +295 -0
- package/src/components/chat-message-actions/config.json +121 -0
- package/src/components/chat-window/ChatWindow.tsx +133 -0
- package/src/components/chat-window/chat-window.django-snapshot.html +448 -0
- package/src/components/chat-window/chat-window.django.html +39 -0
- package/src/components/chat-window/chat-window.html +26 -0
- package/src/components/chat-window/chat-window.react-snapshot.html +286 -0
- package/src/components/chat-window/config.json +123 -0
- package/src/components/clickable/Clickable.tsx +19 -5
- package/src/components/clickable/clickable.django-snapshot.html +11 -2
- package/src/components/clickable/clickable.django.html +2 -0
- package/src/components/clickable/clickable.react-snapshot.html +10 -2
- package/src/components/clickable/config.json +4 -0
- package/src/components/code/code.django-snapshot.html +27 -22
- package/src/components/code/code.html +2 -2
- package/src/components/code/code.react-snapshot.html +43 -8
- package/src/components/copy-to-clipboard/CopyToClipboard.tsx +2 -7
- package/src/components/copy-to-clipboard/copy-to-clipboard.django-snapshot.html +6 -4
- package/src/components/copy-to-clipboard/copy-to-clipboard.django.html +3 -2
- package/src/components/copy-to-clipboard/copy-to-clipboard.react-snapshot.html +14 -2
- package/src/components/file-list/FileList.tsx +3 -2
- package/src/components/file-list/config.json +5 -0
- package/src/components/file-list/file-list.django-snapshot.html +63 -0
- package/src/components/file-list/file-list.django.html +1 -1
- package/src/components/file-list/file-list.react-snapshot.html +53 -0
- package/src/components/footer/footer.django-snapshot.html +0 -3
- package/src/components/header/header.django-snapshot.html +5 -167
- package/src/components/header/header.django.html +2 -2
- package/src/components/header/header.html +1 -11
- package/src/components/header/header.react-snapshot.html +3 -6
- package/src/components/hero/hero.django-snapshot.html +0 -20
- package/src/components/hero/hero.django.html +3 -3
- package/src/components/icon-list/IconList.tsx +10 -2
- package/src/components/icon-list/config.json +5 -1
- package/src/components/icon-list/icon-list.django-snapshot.html +39 -0
- package/src/components/icon-list/icon-list.django.html +2 -0
- package/src/components/icon-list/icon-list.react-snapshot.html +31 -0
- package/src/components/image/image.django.html +4 -4
- package/src/components/input/Input.tsx +1 -1
- package/src/components/input/config.json +2 -3
- package/src/components/input/input.django-snapshot.html +4 -21
- package/src/components/input/input.django.html +2 -2
- package/src/components/link/Link.tsx +7 -4
- package/src/components/link/config.json +2 -3
- package/src/components/link/link.django-snapshot.html +8 -0
- package/src/components/link/link.django.html +2 -2
- package/src/components/link/link.html +4 -1
- package/src/components/link/link.react-snapshot.html +8 -0
- package/src/components/list/List.tsx +10 -2
- package/src/components/list/config.json +5 -1
- package/src/components/list/list.django-snapshot.html +26 -0
- package/src/components/list/list.django.html +2 -0
- package/src/components/list/list.html +20 -0
- package/src/components/list/list.react-snapshot.html +20 -0
- package/src/components/memorable-date/memorable-date.django-snapshot.html +0 -8
- package/src/components/memorable-date/memorable-date.django.html +2 -2
- package/src/components/misc-banner/misc-banner.django-snapshot.html +12 -12
- package/src/components/misc-banner/misc-banner.django.html +4 -2
- package/src/components/page/Page.tsx +16 -0
- package/src/components/page/config.json +18 -1
- package/src/components/page/page.django-snapshot.html +74 -0
- package/src/components/page/page.django.html +8 -0
- package/src/components/page/page.html +60 -0
- package/src/components/page/page.react-snapshot.html +60 -0
- package/src/components/popover/Popover.tsx +60 -9
- package/src/components/popover/PopoverMenu.tsx +33 -15
- package/src/components/popover/config.json +88 -14
- package/src/components/popover/popover-menu.django.html +13 -2
- package/src/components/popover/popover.django-snapshot.html +229 -7
- package/src/components/popover/popover.django.html +3 -2
- package/src/components/popover/popover.react-snapshot.html +127 -4
- package/src/components/process-list/config.json +41 -3
- package/src/components/quote/Quote.tsx +9 -2
- package/src/components/search/Search.tsx +1 -1
- package/src/components/search/config.json +3 -4
- package/src/components/search/search.django-snapshot.html +262 -1684
- package/src/components/search/search.django.html +1 -20
- package/src/components/select/select.django-snapshot.html +7 -7
- package/src/components/select/select.react-snapshot.html +7 -7
- package/src/components/summary/Summary.tsx +4 -2
- package/src/components/summary/config.json +4 -0
- package/src/components/summary/summary.django.html +4 -4
- package/src/components/table/Table.tsx +58 -25
- package/src/components/table/config.json +61 -13
- package/src/components/tag/Tag.tsx +40 -7
- package/src/components/tag/config.json +18 -2
- package/src/components/tag/tag.django-snapshot.html +16 -1
- package/src/components/tag/tag.django.html +12 -6
- package/src/components/tag/tag.html +4 -0
- package/src/components/tag/tag.react-snapshot.html +16 -1
- package/src/components/tag-group/TagGroup.tsx +6 -9
- package/src/components/tag-group/config.json +4 -0
- package/src/components/tag-group/tag-group.django.html +1 -1
- package/src/components/theme-picker/ThemePicker.tsx +95 -52
- package/src/components/theme-picker/config.json +7 -4
- package/src/components/theme-picker/theme-picker-select.django.html +7 -0
- package/src/components/theme-picker/theme-picker.django-snapshot.html +101 -21
- package/src/components/theme-picker/theme-picker.django.html +22 -24
- package/src/components/theme-picker/theme-picker.html +86 -56
- package/src/components/theme-picker/theme-picker.react-snapshot.html +74 -18
|
@@ -0,0 +1,984 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
+
const React = require("react");
|
|
4
|
+
function getDefaultExportFromCjs(x) {
|
|
5
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
6
|
+
}
|
|
7
|
+
var classnames = { exports: {} };
|
|
8
|
+
/*!
|
|
9
|
+
Copyright (c) 2018 Jed Watson.
|
|
10
|
+
Licensed under the MIT License (MIT), see
|
|
11
|
+
http://jedwatson.github.io/classnames
|
|
12
|
+
*/
|
|
13
|
+
var hasRequiredClassnames;
|
|
14
|
+
function requireClassnames() {
|
|
15
|
+
if (hasRequiredClassnames) return classnames.exports;
|
|
16
|
+
hasRequiredClassnames = 1;
|
|
17
|
+
(function(module2) {
|
|
18
|
+
(function() {
|
|
19
|
+
var hasOwn = {}.hasOwnProperty;
|
|
20
|
+
function classNames() {
|
|
21
|
+
var classes = "";
|
|
22
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
23
|
+
var arg = arguments[i];
|
|
24
|
+
if (arg) {
|
|
25
|
+
classes = appendClass(classes, parseValue(arg));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return classes;
|
|
29
|
+
}
|
|
30
|
+
function parseValue(arg) {
|
|
31
|
+
if (typeof arg === "string" || typeof arg === "number") {
|
|
32
|
+
return arg;
|
|
33
|
+
}
|
|
34
|
+
if (typeof arg !== "object") {
|
|
35
|
+
return "";
|
|
36
|
+
}
|
|
37
|
+
if (Array.isArray(arg)) {
|
|
38
|
+
return classNames.apply(null, arg);
|
|
39
|
+
}
|
|
40
|
+
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
|
|
41
|
+
return arg.toString();
|
|
42
|
+
}
|
|
43
|
+
var classes = "";
|
|
44
|
+
for (var key in arg) {
|
|
45
|
+
if (hasOwn.call(arg, key) && arg[key]) {
|
|
46
|
+
classes = appendClass(classes, key);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return classes;
|
|
50
|
+
}
|
|
51
|
+
function appendClass(value, newClass) {
|
|
52
|
+
if (!newClass) {
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
if (value) {
|
|
56
|
+
return value + " " + newClass;
|
|
57
|
+
}
|
|
58
|
+
return value + newClass;
|
|
59
|
+
}
|
|
60
|
+
if (module2.exports) {
|
|
61
|
+
classNames.default = classNames;
|
|
62
|
+
module2.exports = classNames;
|
|
63
|
+
} else {
|
|
64
|
+
window.classNames = classNames;
|
|
65
|
+
}
|
|
66
|
+
})();
|
|
67
|
+
})(classnames);
|
|
68
|
+
return classnames.exports;
|
|
69
|
+
}
|
|
70
|
+
var classnamesExports = requireClassnames();
|
|
71
|
+
const ClassNames = /* @__PURE__ */ getDefaultExportFromCjs(classnamesExports);
|
|
72
|
+
function getAssetUrl(assetPath, staticBaseUrl) {
|
|
73
|
+
if (/^[a-z][a-z\d+.-]*:/i.test(assetPath)) return assetPath;
|
|
74
|
+
const base = staticBaseUrl || typeof window !== "undefined" && window.usxBaseUrl || "/";
|
|
75
|
+
return `${base.replace(/\/+$/, "")}/${assetPath.replace(/^\/+/, "")}`;
|
|
76
|
+
}
|
|
77
|
+
function getAssetSrcSet(srcSet, staticBaseUrl) {
|
|
78
|
+
return srcSet.replace(/(^\s*|,\s*)(\S*[^,\s])(?=,?(?:\s|$))/g, (_match, separator, url) => `${separator}${getAssetUrl(url, staticBaseUrl)}`);
|
|
79
|
+
}
|
|
80
|
+
function Icon({
|
|
81
|
+
name,
|
|
82
|
+
source = "uswds",
|
|
83
|
+
size,
|
|
84
|
+
color,
|
|
85
|
+
alt,
|
|
86
|
+
staticBaseUrl,
|
|
87
|
+
staticUrlPrefix,
|
|
88
|
+
className = "",
|
|
89
|
+
...props
|
|
90
|
+
}) {
|
|
91
|
+
const spritePrefix = staticUrlPrefix ?? getAssetUrl(`img/${source === "usx" ? "usx-sprite.svg" : "sprite.svg"}#`, staticBaseUrl);
|
|
92
|
+
const classes = ClassNames(
|
|
93
|
+
"usa-icon",
|
|
94
|
+
"usx-icon",
|
|
95
|
+
size ? size === 1 ? "usx-icon--size-1" : "usa-icon--size-" + size : "",
|
|
96
|
+
color ? "text-" + color : "",
|
|
97
|
+
className
|
|
98
|
+
);
|
|
99
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
100
|
+
"svg",
|
|
101
|
+
{
|
|
102
|
+
className: classes,
|
|
103
|
+
"aria-hidden": alt ? void 0 : "true",
|
|
104
|
+
"aria-label": alt || void 0,
|
|
105
|
+
focusable: "false",
|
|
106
|
+
role: "img",
|
|
107
|
+
...props,
|
|
108
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("use", { href: spritePrefix + name })
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
function Alert({
|
|
113
|
+
heading,
|
|
114
|
+
text,
|
|
115
|
+
variant,
|
|
116
|
+
slim = false,
|
|
117
|
+
noIcon = false,
|
|
118
|
+
className = "",
|
|
119
|
+
role,
|
|
120
|
+
ariaLabel,
|
|
121
|
+
ariaLabelledby,
|
|
122
|
+
onDismiss = void 0,
|
|
123
|
+
staticBaseUrl,
|
|
124
|
+
children = null,
|
|
125
|
+
...props
|
|
126
|
+
}) {
|
|
127
|
+
const normalizedVariant = variant && ["info", "warning", "success", "error", "emergency"].includes(variant) ? variant : null;
|
|
128
|
+
const classes = ClassNames(
|
|
129
|
+
"usa-alert",
|
|
130
|
+
"usx-alert",
|
|
131
|
+
normalizedVariant ? `usa-alert--${normalizedVariant}` : "",
|
|
132
|
+
slim ? "usa-alert--slim" : "",
|
|
133
|
+
noIcon ? "usa-alert--no-icon" : "",
|
|
134
|
+
className
|
|
135
|
+
);
|
|
136
|
+
const resolvedRole = role || (normalizedVariant === "error" || normalizedVariant === "emergency" ? "alert" : normalizedVariant === "success" ? "status" : "region");
|
|
137
|
+
const accessibilityProps = {
|
|
138
|
+
role: resolvedRole
|
|
139
|
+
};
|
|
140
|
+
if (ariaLabelledby) {
|
|
141
|
+
accessibilityProps["aria-labelledby"] = ariaLabelledby;
|
|
142
|
+
} else if (ariaLabel) {
|
|
143
|
+
accessibilityProps["aria-label"] = ariaLabel;
|
|
144
|
+
} else if (resolvedRole === "region") {
|
|
145
|
+
const label = heading || (normalizedVariant ? `${normalizedVariant} alert` : void 0);
|
|
146
|
+
if (label) accessibilityProps["aria-label"] = label;
|
|
147
|
+
}
|
|
148
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes, ...accessibilityProps, ...props, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "usa-alert__body", children: [
|
|
149
|
+
!slim && heading ? /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "usa-alert__heading", children: heading }) : null,
|
|
150
|
+
children ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "usa-alert__text", children }) : text ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "usa-alert__text", children: text }) : null,
|
|
151
|
+
onDismiss && /* @__PURE__ */ jsxRuntime.jsx("button", { className: "usx-alert__dismiss", "aria-label": "Dismiss alert", onClick: onDismiss, children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "close", size: 3, staticBaseUrl }) })
|
|
152
|
+
] }) });
|
|
153
|
+
}
|
|
154
|
+
const Tooltip = ({
|
|
155
|
+
label,
|
|
156
|
+
position = "right",
|
|
157
|
+
children,
|
|
158
|
+
className = "",
|
|
159
|
+
bodyClassName = "",
|
|
160
|
+
...props
|
|
161
|
+
}) => {
|
|
162
|
+
const validPositions = ["top", "bottom", "left", "right"];
|
|
163
|
+
const normalizedPosition = validPositions.includes(position) ? position : "right";
|
|
164
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: ClassNames("usx-tooltip", className), ...props, children: [
|
|
165
|
+
children,
|
|
166
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
167
|
+
"span",
|
|
168
|
+
{
|
|
169
|
+
className: ClassNames("usa-tooltip__body", `usa-tooltip__body--${normalizedPosition}`, bodyClassName),
|
|
170
|
+
role: "tooltip",
|
|
171
|
+
children: label
|
|
172
|
+
}
|
|
173
|
+
)
|
|
174
|
+
] });
|
|
175
|
+
};
|
|
176
|
+
const shapeClassMap = {
|
|
177
|
+
circle: "usx-circle",
|
|
178
|
+
"rounded-sm": "usx-rounded-sm",
|
|
179
|
+
"rounded-md": "usx-rounded-md",
|
|
180
|
+
"rounded-lg": "usx-rounded-lg",
|
|
181
|
+
"rounded-xl": "usx-rounded-xl"
|
|
182
|
+
};
|
|
183
|
+
function Avatar({
|
|
184
|
+
href,
|
|
185
|
+
src = null,
|
|
186
|
+
alt = null,
|
|
187
|
+
variant = "image",
|
|
188
|
+
value = null,
|
|
189
|
+
shape = null,
|
|
190
|
+
statusRingColor = null,
|
|
191
|
+
statusLabel = null,
|
|
192
|
+
tooltipProps = null,
|
|
193
|
+
className = "",
|
|
194
|
+
imageClassName = "",
|
|
195
|
+
contentClassName = "",
|
|
196
|
+
...props
|
|
197
|
+
}) {
|
|
198
|
+
const isInitialsVariant = variant === "initials";
|
|
199
|
+
const isIconVariant = variant === "icon";
|
|
200
|
+
const ringColor = statusRingColor == null ? void 0 : statusRingColor.trim();
|
|
201
|
+
const label = statusLabel == null ? void 0 : statusLabel.trim();
|
|
202
|
+
const accessibleLabel = label ? [alt, label].filter(Boolean).join(", ") : alt || void 0;
|
|
203
|
+
const wrapperClasses = ClassNames(
|
|
204
|
+
"usx-avatar",
|
|
205
|
+
ringColor && "border-05",
|
|
206
|
+
ringColor && `border-${ringColor}`,
|
|
207
|
+
ringColor && (shape ? shapeClassMap[shape] : isInitialsVariant || isIconVariant ? "usx-circle" : null),
|
|
208
|
+
className
|
|
209
|
+
);
|
|
210
|
+
const imgClasses = ClassNames(
|
|
211
|
+
"usx-avatar__img",
|
|
212
|
+
shape ? shapeClassMap[shape] : null,
|
|
213
|
+
imageClassName
|
|
214
|
+
);
|
|
215
|
+
const contentClasses = ClassNames(
|
|
216
|
+
"usx-avatar__content",
|
|
217
|
+
shape ? shapeClassMap[shape] : "usx-circle",
|
|
218
|
+
contentClassName
|
|
219
|
+
);
|
|
220
|
+
const avatarContent = isInitialsVariant ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: contentClasses, children: value }) : isIconVariant ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: contentClasses, children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: value, alt: alt ? void 0 : `${value} icon` }) }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
221
|
+
"img",
|
|
222
|
+
{
|
|
223
|
+
className: imgClasses,
|
|
224
|
+
src: src || void 0,
|
|
225
|
+
alt: alt || void 0,
|
|
226
|
+
role: "img",
|
|
227
|
+
...props
|
|
228
|
+
}
|
|
229
|
+
);
|
|
230
|
+
const avatar = href ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
231
|
+
"a",
|
|
232
|
+
{
|
|
233
|
+
href,
|
|
234
|
+
className: wrapperClasses,
|
|
235
|
+
"aria-label": label ? accessibleLabel : isInitialsVariant || isIconVariant ? alt || void 0 : void 0,
|
|
236
|
+
children: avatarContent
|
|
237
|
+
}
|
|
238
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
239
|
+
"span",
|
|
240
|
+
{
|
|
241
|
+
className: wrapperClasses,
|
|
242
|
+
role: label ? "img" : void 0,
|
|
243
|
+
"aria-label": label ? accessibleLabel : isInitialsVariant || isIconVariant ? alt || void 0 : void 0,
|
|
244
|
+
children: avatarContent
|
|
245
|
+
}
|
|
246
|
+
);
|
|
247
|
+
return tooltipProps ? /* @__PURE__ */ jsxRuntime.jsx(Tooltip, { ...tooltipProps, children: avatar }) : avatar;
|
|
248
|
+
}
|
|
249
|
+
function AvatarGroup({
|
|
250
|
+
avatarProps = [],
|
|
251
|
+
overlap = false,
|
|
252
|
+
stacked = false,
|
|
253
|
+
className = "",
|
|
254
|
+
...props
|
|
255
|
+
}) {
|
|
256
|
+
const classes = ClassNames(
|
|
257
|
+
"usx-avatar-group",
|
|
258
|
+
overlap && "usx-avatar-group--overlap",
|
|
259
|
+
stacked && "usx-avatar-group--stacked",
|
|
260
|
+
className
|
|
261
|
+
);
|
|
262
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes, ...props, children: avatarProps.map(({ initials, initialsClassName, ...avatar }, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
263
|
+
Avatar,
|
|
264
|
+
{
|
|
265
|
+
...avatar,
|
|
266
|
+
variant: avatar.variant ?? (avatar.src ? "image" : "initials"),
|
|
267
|
+
value: avatar.value ?? initials,
|
|
268
|
+
contentClassName: avatar.contentClassName ?? initialsClassName
|
|
269
|
+
},
|
|
270
|
+
`${avatar.src || avatar.value || initials || "avatar"}-${index}`
|
|
271
|
+
)) });
|
|
272
|
+
}
|
|
273
|
+
const Required = ({
|
|
274
|
+
title = "Required",
|
|
275
|
+
children = null,
|
|
276
|
+
className = "",
|
|
277
|
+
...props
|
|
278
|
+
}) => {
|
|
279
|
+
const classes = ClassNames("usx-required", className);
|
|
280
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
281
|
+
/* @__PURE__ */ jsxRuntime.jsx("abbr", { title, className: classes, ...props, children: "*" }),
|
|
282
|
+
" ",
|
|
283
|
+
children ? children : ""
|
|
284
|
+
] });
|
|
285
|
+
};
|
|
286
|
+
function Label({
|
|
287
|
+
id,
|
|
288
|
+
htmlFor,
|
|
289
|
+
required = false,
|
|
290
|
+
error = false,
|
|
291
|
+
children = null,
|
|
292
|
+
screenReaderOnly = false,
|
|
293
|
+
className = "",
|
|
294
|
+
classOverride = false,
|
|
295
|
+
...props
|
|
296
|
+
}) {
|
|
297
|
+
const classes = ClassNames(
|
|
298
|
+
"usa-label",
|
|
299
|
+
"usx-label",
|
|
300
|
+
{ "usa-sr-only": screenReaderOnly, "usa-label--error": !!error },
|
|
301
|
+
className
|
|
302
|
+
);
|
|
303
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
304
|
+
"label",
|
|
305
|
+
{
|
|
306
|
+
id: id || void 0,
|
|
307
|
+
className: classOverride ? className : classes,
|
|
308
|
+
htmlFor: htmlFor || void 0,
|
|
309
|
+
...props,
|
|
310
|
+
children: [
|
|
311
|
+
required && /* @__PURE__ */ jsxRuntime.jsx(Required, {}),
|
|
312
|
+
children
|
|
313
|
+
]
|
|
314
|
+
}
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
const Spinner = ({
|
|
318
|
+
size = 3,
|
|
319
|
+
color,
|
|
320
|
+
label = null,
|
|
321
|
+
screenReaderLabel = null,
|
|
322
|
+
staticUrlPrefix,
|
|
323
|
+
staticBaseUrl,
|
|
324
|
+
className = "",
|
|
325
|
+
...props
|
|
326
|
+
}) => {
|
|
327
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { role: "status", "aria-live": "polite", className: `usx-spinner ${className}`, ...props, children: [
|
|
328
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
329
|
+
Icon,
|
|
330
|
+
{
|
|
331
|
+
name: "spinner",
|
|
332
|
+
source: "usx",
|
|
333
|
+
size,
|
|
334
|
+
color,
|
|
335
|
+
staticBaseUrl,
|
|
336
|
+
staticUrlPrefix
|
|
337
|
+
}
|
|
338
|
+
),
|
|
339
|
+
screenReaderLabel && /* @__PURE__ */ jsxRuntime.jsx(Label, { screenReaderOnly: true, children: screenReaderLabel }),
|
|
340
|
+
label && /* @__PURE__ */ jsxRuntime.jsx(Label, { children: label })
|
|
341
|
+
] });
|
|
342
|
+
};
|
|
343
|
+
function Button({
|
|
344
|
+
label,
|
|
345
|
+
variant,
|
|
346
|
+
type = "button",
|
|
347
|
+
disabled = false,
|
|
348
|
+
onClick,
|
|
349
|
+
href,
|
|
350
|
+
isExternal = false,
|
|
351
|
+
big = false,
|
|
352
|
+
inverse = false,
|
|
353
|
+
ghost = false,
|
|
354
|
+
loading = false,
|
|
355
|
+
iconProps = [],
|
|
356
|
+
className = "",
|
|
357
|
+
children = "",
|
|
358
|
+
extraAttributes = {},
|
|
359
|
+
...props
|
|
360
|
+
}) {
|
|
361
|
+
const leftIcons = iconProps.filter((icon) => (icon.position ?? "left") === "left");
|
|
362
|
+
const rightIcons = iconProps.filter((icon) => icon.position === "right");
|
|
363
|
+
const renderIcon = (icon, index) => {
|
|
364
|
+
const { position, ...iconRest } = icon;
|
|
365
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Icon, { ...iconRest }, index);
|
|
366
|
+
};
|
|
367
|
+
const spinner = loading && /* @__PURE__ */ jsxRuntime.jsx(Spinner, { size: 2 });
|
|
368
|
+
const variantClasses = {
|
|
369
|
+
primary: "usa-button--primary",
|
|
370
|
+
secondary: "usa-button--secondary",
|
|
371
|
+
"accent-cool": "usa-button--accent-cool",
|
|
372
|
+
"accent-warm": "usa-button--accent-warm",
|
|
373
|
+
base: "usa-button--base",
|
|
374
|
+
outline: "usa-button--outline",
|
|
375
|
+
unstyled: "usa-button--unstyled"
|
|
376
|
+
};
|
|
377
|
+
const classes = ClassNames(
|
|
378
|
+
"usa-button",
|
|
379
|
+
"usx-button",
|
|
380
|
+
variant && variantClasses[variant],
|
|
381
|
+
big && "usa-button--big",
|
|
382
|
+
inverse && "usa-button--inverse",
|
|
383
|
+
ghost && "usx-button--ghost",
|
|
384
|
+
className
|
|
385
|
+
);
|
|
386
|
+
if (href) {
|
|
387
|
+
const {
|
|
388
|
+
// Remove unused variables
|
|
389
|
+
...anchorProps
|
|
390
|
+
} = props;
|
|
391
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
392
|
+
"a",
|
|
393
|
+
{
|
|
394
|
+
className: classes,
|
|
395
|
+
href,
|
|
396
|
+
...isExternal ? { target: "_blank", rel: "noopener noreferrer" } : {},
|
|
397
|
+
...anchorProps,
|
|
398
|
+
...extraAttributes,
|
|
399
|
+
children: [
|
|
400
|
+
spinner,
|
|
401
|
+
leftIcons.map(renderIcon),
|
|
402
|
+
children || label,
|
|
403
|
+
rightIcons.map(renderIcon)
|
|
404
|
+
]
|
|
405
|
+
}
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
const {
|
|
409
|
+
// Remove unused variables
|
|
410
|
+
...buttonProps
|
|
411
|
+
} = props;
|
|
412
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
413
|
+
"button",
|
|
414
|
+
{
|
|
415
|
+
type,
|
|
416
|
+
className: classes,
|
|
417
|
+
disabled,
|
|
418
|
+
"aria-disabled": disabled ? "true" : void 0,
|
|
419
|
+
...onClick ? { onClick } : {},
|
|
420
|
+
...buttonProps,
|
|
421
|
+
...extraAttributes,
|
|
422
|
+
children: [
|
|
423
|
+
spinner,
|
|
424
|
+
leftIcons.map(renderIcon),
|
|
425
|
+
children || label,
|
|
426
|
+
rightIcons.map(renderIcon)
|
|
427
|
+
]
|
|
428
|
+
}
|
|
429
|
+
);
|
|
430
|
+
}
|
|
431
|
+
function ButtonGroup({
|
|
432
|
+
buttonProps = [],
|
|
433
|
+
segmented = false,
|
|
434
|
+
className = "",
|
|
435
|
+
...props
|
|
436
|
+
}) {
|
|
437
|
+
const classes = ClassNames(
|
|
438
|
+
"usa-button-group usx-button-group",
|
|
439
|
+
segmented && "usa-button-group--segmented",
|
|
440
|
+
className
|
|
441
|
+
);
|
|
442
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ul", { className: classes, ...props, children: buttonProps.map(({ itemClassName, ...item }, index) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: ClassNames("usa-button-group__item", itemClassName), children: /* @__PURE__ */ jsxRuntime.jsx(Button, { ...item, children: item.children }) }, index)) });
|
|
443
|
+
}
|
|
444
|
+
function Callout({
|
|
445
|
+
className,
|
|
446
|
+
strokeColor,
|
|
447
|
+
indent,
|
|
448
|
+
dedent,
|
|
449
|
+
big,
|
|
450
|
+
orientation = "horizontal",
|
|
451
|
+
children,
|
|
452
|
+
content,
|
|
453
|
+
backgroundColor,
|
|
454
|
+
textColor,
|
|
455
|
+
as: Element = "div",
|
|
456
|
+
...props
|
|
457
|
+
}) {
|
|
458
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
459
|
+
Element,
|
|
460
|
+
{
|
|
461
|
+
className: ClassNames(
|
|
462
|
+
"usx-callout",
|
|
463
|
+
orientation === "vertical" && "usx-callout--vertical",
|
|
464
|
+
strokeColor && `border-${strokeColor}`,
|
|
465
|
+
indent && `usx-callout--indent-${indent}`,
|
|
466
|
+
dedent && "usx-callout--dedent",
|
|
467
|
+
(big ?? orientation === "horizontal") && "usx-callout--big",
|
|
468
|
+
backgroundColor && `bg-${backgroundColor}`,
|
|
469
|
+
textColor && `text-${textColor}`,
|
|
470
|
+
className
|
|
471
|
+
),
|
|
472
|
+
...props,
|
|
473
|
+
children: children ?? content
|
|
474
|
+
}
|
|
475
|
+
);
|
|
476
|
+
}
|
|
477
|
+
const Tag = ({
|
|
478
|
+
id,
|
|
479
|
+
big = false,
|
|
480
|
+
value,
|
|
481
|
+
color = null,
|
|
482
|
+
outline = false,
|
|
483
|
+
icon = null,
|
|
484
|
+
dismissible = false,
|
|
485
|
+
isDismissed = false,
|
|
486
|
+
onDismiss = () => {
|
|
487
|
+
},
|
|
488
|
+
className = "",
|
|
489
|
+
children,
|
|
490
|
+
href,
|
|
491
|
+
target,
|
|
492
|
+
rel,
|
|
493
|
+
extraAttributes = {},
|
|
494
|
+
...props
|
|
495
|
+
}) => {
|
|
496
|
+
const [isVisible, setIsVisible] = React.useState(!isDismissed);
|
|
497
|
+
const interactive = Boolean(href);
|
|
498
|
+
const classes = ClassNames(
|
|
499
|
+
"usa-tag",
|
|
500
|
+
"usx-tag",
|
|
501
|
+
{ "usa-tag--big": big },
|
|
502
|
+
{ [`bg-${color}`]: color && !outline && !interactive },
|
|
503
|
+
{ [`text-${color}`]: color && outline && !interactive },
|
|
504
|
+
{ "usx-tag--outline": outline || interactive },
|
|
505
|
+
{ "usa-link usx-link usx-no-visited usx-tag--interactive": interactive },
|
|
506
|
+
className
|
|
507
|
+
);
|
|
508
|
+
const handleDismiss = (e) => {
|
|
509
|
+
e.preventDefault();
|
|
510
|
+
if (onDismiss) {
|
|
511
|
+
onDismiss(e);
|
|
512
|
+
}
|
|
513
|
+
setIsVisible(false);
|
|
514
|
+
};
|
|
515
|
+
if (!isVisible) {
|
|
516
|
+
return null;
|
|
517
|
+
}
|
|
518
|
+
const content = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
519
|
+
icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: icon, size: big ? 3 : 2 }),
|
|
520
|
+
" ",
|
|
521
|
+
children || value,
|
|
522
|
+
dismissible && !interactive && /* @__PURE__ */ jsxRuntime.jsx(
|
|
523
|
+
"button",
|
|
524
|
+
{
|
|
525
|
+
type: "button",
|
|
526
|
+
className: "usx-tag__dismiss",
|
|
527
|
+
"aria-label": "Dismiss tag",
|
|
528
|
+
onClick: handleDismiss,
|
|
529
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "close", size: 2 })
|
|
530
|
+
}
|
|
531
|
+
)
|
|
532
|
+
] });
|
|
533
|
+
if (href) {
|
|
534
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
535
|
+
"a",
|
|
536
|
+
{
|
|
537
|
+
id,
|
|
538
|
+
href,
|
|
539
|
+
target,
|
|
540
|
+
rel,
|
|
541
|
+
className: classes,
|
|
542
|
+
...props,
|
|
543
|
+
...extraAttributes,
|
|
544
|
+
children: content
|
|
545
|
+
}
|
|
546
|
+
);
|
|
547
|
+
}
|
|
548
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { id, className: classes, ...props, ...extraAttributes, children: content });
|
|
549
|
+
};
|
|
550
|
+
function Image({
|
|
551
|
+
src,
|
|
552
|
+
alt,
|
|
553
|
+
href,
|
|
554
|
+
rounded = false,
|
|
555
|
+
circular = false,
|
|
556
|
+
caption,
|
|
557
|
+
hideCaption = false,
|
|
558
|
+
objectFit = "",
|
|
559
|
+
maxWidth,
|
|
560
|
+
maxHeight,
|
|
561
|
+
staticBaseUrl,
|
|
562
|
+
srcSet,
|
|
563
|
+
className = "",
|
|
564
|
+
...props
|
|
565
|
+
}) {
|
|
566
|
+
const classes = ClassNames(
|
|
567
|
+
"usx-image",
|
|
568
|
+
{
|
|
569
|
+
"usx-image--rounded": rounded,
|
|
570
|
+
"usx-image--circular": circular,
|
|
571
|
+
[`usx-object-fit-${objectFit}`]: objectFit
|
|
572
|
+
},
|
|
573
|
+
className
|
|
574
|
+
);
|
|
575
|
+
const style = {};
|
|
576
|
+
if (maxWidth) style.maxWidth = maxWidth;
|
|
577
|
+
if (maxHeight) style.maxHeight = maxHeight;
|
|
578
|
+
if (maxHeight && !maxWidth) style.width = "auto";
|
|
579
|
+
if (maxWidth && !maxHeight) style.height = "auto";
|
|
580
|
+
const captionClasses = ClassNames(
|
|
581
|
+
"usx-image--caption",
|
|
582
|
+
{ "usa-sr-only": hideCaption }
|
|
583
|
+
);
|
|
584
|
+
const isResponsive = src && typeof src === "object";
|
|
585
|
+
const imgElement = !src ? "Image" : isResponsive ? /* @__PURE__ */ jsxRuntime.jsxs("picture", { children: [
|
|
586
|
+
src.sources.map((source, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
587
|
+
"source",
|
|
588
|
+
{
|
|
589
|
+
...source.media ? { media: source.media } : {},
|
|
590
|
+
srcSet: getAssetSrcSet(source.srcSet, staticBaseUrl),
|
|
591
|
+
...source.type ? { type: source.type } : {},
|
|
592
|
+
...source.sizes ? { sizes: source.sizes } : {}
|
|
593
|
+
},
|
|
594
|
+
i
|
|
595
|
+
)),
|
|
596
|
+
/* @__PURE__ */ jsxRuntime.jsx("img", { src: getAssetUrl(src.fallback, staticBaseUrl), srcSet: srcSet ? getAssetSrcSet(srcSet, staticBaseUrl) : void 0, alt, style, ...props })
|
|
597
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("img", { src: getAssetUrl(src, staticBaseUrl), srcSet: srcSet ? getAssetSrcSet(srcSet, staticBaseUrl) : void 0, alt, style, ...props });
|
|
598
|
+
if (caption) {
|
|
599
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("figure", { className: classes, style, children: [
|
|
600
|
+
href ? /* @__PURE__ */ jsxRuntime.jsx("a", { href, children: imgElement }) : imgElement,
|
|
601
|
+
/* @__PURE__ */ jsxRuntime.jsx("figcaption", { className: captionClasses, children: caption })
|
|
602
|
+
] });
|
|
603
|
+
}
|
|
604
|
+
const Element = href ? "a" : "div";
|
|
605
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
606
|
+
Element,
|
|
607
|
+
{
|
|
608
|
+
...href ? { href } : {},
|
|
609
|
+
className: classes,
|
|
610
|
+
style,
|
|
611
|
+
children: imgElement
|
|
612
|
+
}
|
|
613
|
+
);
|
|
614
|
+
}
|
|
615
|
+
function Hint({
|
|
616
|
+
id,
|
|
617
|
+
children = null,
|
|
618
|
+
className = "",
|
|
619
|
+
...props
|
|
620
|
+
}) {
|
|
621
|
+
const classes = ClassNames("usa-hint", "usx-hint", className);
|
|
622
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: classes, ...id ? { id } : {}, ...props, children });
|
|
623
|
+
}
|
|
624
|
+
function ErrorMessage({
|
|
625
|
+
id,
|
|
626
|
+
children = null,
|
|
627
|
+
className = "",
|
|
628
|
+
...props
|
|
629
|
+
}) {
|
|
630
|
+
const classes = ClassNames("usa-error-message", "usx-error-message", className);
|
|
631
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: classes, role: "alert", ...id ? { id } : {}, ...props, children });
|
|
632
|
+
}
|
|
633
|
+
function FormGroup({ children = null, className = "", error = false, ...props }) {
|
|
634
|
+
const classes = ClassNames(
|
|
635
|
+
"usa-form-group",
|
|
636
|
+
"usx-form-group",
|
|
637
|
+
{
|
|
638
|
+
"usa-form-group--error": error
|
|
639
|
+
},
|
|
640
|
+
className
|
|
641
|
+
);
|
|
642
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes, ...props, children });
|
|
643
|
+
}
|
|
644
|
+
const TextArea = ({
|
|
645
|
+
label = null,
|
|
646
|
+
id,
|
|
647
|
+
placeholder = "",
|
|
648
|
+
disabled = false,
|
|
649
|
+
required = false,
|
|
650
|
+
defaultValue = "",
|
|
651
|
+
value,
|
|
652
|
+
hint = null,
|
|
653
|
+
screenReaderOnlyLabel = false,
|
|
654
|
+
error = null,
|
|
655
|
+
success = null,
|
|
656
|
+
formGroup = true,
|
|
657
|
+
className = "",
|
|
658
|
+
...props
|
|
659
|
+
}) => {
|
|
660
|
+
const textAreaId = id || `textarea-${Math.random().toString(36).substr(2, 9)}`;
|
|
661
|
+
const hasError = !!error;
|
|
662
|
+
const hasSuccess = !!success;
|
|
663
|
+
const classes = ClassNames(
|
|
664
|
+
"usa-textarea",
|
|
665
|
+
"usx-textarea",
|
|
666
|
+
hasError ? "usa-input--error" : hasSuccess ? "usa-input--success" : null,
|
|
667
|
+
className
|
|
668
|
+
);
|
|
669
|
+
const hintId = hint ? `${textAreaId}-hint` : void 0;
|
|
670
|
+
const describedByParts = [];
|
|
671
|
+
if (hintId) describedByParts.push(hintId);
|
|
672
|
+
if (hasError && typeof error === "string") describedByParts.push(`${textAreaId}-error`);
|
|
673
|
+
const content = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
674
|
+
label && /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: textAreaId, required, screenReaderOnly: screenReaderOnlyLabel, error: hasError, children: label }),
|
|
675
|
+
hint && /* @__PURE__ */ jsxRuntime.jsx(Hint, { id: hintId, children: hint }),
|
|
676
|
+
hasError && typeof error === "string" && /* @__PURE__ */ jsxRuntime.jsx(ErrorMessage, { id: `${textAreaId}-error`, children: error }),
|
|
677
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
678
|
+
"textarea",
|
|
679
|
+
{
|
|
680
|
+
id: textAreaId,
|
|
681
|
+
className: classes,
|
|
682
|
+
placeholder,
|
|
683
|
+
disabled,
|
|
684
|
+
...value !== void 0 ? { value } : { defaultValue },
|
|
685
|
+
...required ? { required: true } : {},
|
|
686
|
+
"aria-describedby": describedByParts.length ? describedByParts.join(" ") : void 0,
|
|
687
|
+
"aria-invalid": hasError ? "true" : void 0,
|
|
688
|
+
...props
|
|
689
|
+
}
|
|
690
|
+
)
|
|
691
|
+
] });
|
|
692
|
+
return formGroup ? /* @__PURE__ */ jsxRuntime.jsx(FormGroup, { error: hasError, children: content }) : content;
|
|
693
|
+
};
|
|
694
|
+
function ClickableLink({
|
|
695
|
+
children,
|
|
696
|
+
className,
|
|
697
|
+
as: Tag2 = "span",
|
|
698
|
+
colorChange = false,
|
|
699
|
+
bgColorChange = false,
|
|
700
|
+
...rest
|
|
701
|
+
}) {
|
|
702
|
+
const classes = ClassNames(
|
|
703
|
+
"usx-clickable__link",
|
|
704
|
+
colorChange && "usx-clickable__color-on-hover",
|
|
705
|
+
bgColorChange && "usx-clickable__bg-color-on-hover",
|
|
706
|
+
className
|
|
707
|
+
);
|
|
708
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Tag2, { className: classes, ...rest, children });
|
|
709
|
+
}
|
|
710
|
+
function ClickableColorChange({ children, className, as: Tag2 = "span", ...rest }) {
|
|
711
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Tag2, { className: ClassNames("usx-clickable__color-on-hover", className), ...rest, children });
|
|
712
|
+
}
|
|
713
|
+
function ClickableBgColorChange({ children, className, as: Tag2 = "span", ...rest }) {
|
|
714
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Tag2, { className: ClassNames("usx-clickable__bg-color-on-hover", className), ...rest, children });
|
|
715
|
+
}
|
|
716
|
+
function Clickable({ className, children, extraAttributes = {}, ...rest }) {
|
|
717
|
+
const classes = ClassNames("usx-clickable", className);
|
|
718
|
+
if ("href" in rest && rest.href !== void 0) {
|
|
719
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
720
|
+
"a",
|
|
721
|
+
{
|
|
722
|
+
className: classes,
|
|
723
|
+
...rest,
|
|
724
|
+
...extraAttributes,
|
|
725
|
+
children
|
|
726
|
+
}
|
|
727
|
+
);
|
|
728
|
+
}
|
|
729
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
730
|
+
"button",
|
|
731
|
+
{
|
|
732
|
+
type: "button",
|
|
733
|
+
className: classes,
|
|
734
|
+
...rest,
|
|
735
|
+
...extraAttributes,
|
|
736
|
+
children
|
|
737
|
+
}
|
|
738
|
+
);
|
|
739
|
+
}
|
|
740
|
+
Clickable.Link = ClickableLink;
|
|
741
|
+
Clickable.ColorChange = ClickableColorChange;
|
|
742
|
+
Clickable.BgColorChange = ClickableBgColorChange;
|
|
743
|
+
function Summary({
|
|
744
|
+
label = "Details",
|
|
745
|
+
children,
|
|
746
|
+
ariaLabel,
|
|
747
|
+
title,
|
|
748
|
+
className = "",
|
|
749
|
+
textClassName = "",
|
|
750
|
+
markerColor = void 0,
|
|
751
|
+
underlineColor = void 0,
|
|
752
|
+
noUnderline = false,
|
|
753
|
+
noMarker = false,
|
|
754
|
+
unstyled = false
|
|
755
|
+
}) {
|
|
756
|
+
if (unstyled) {
|
|
757
|
+
return /* @__PURE__ */ jsxRuntime.jsx("summary", { className: className || void 0, "aria-label": ariaLabel, title, children: children ?? label });
|
|
758
|
+
}
|
|
759
|
+
const summaryClassNames = ClassNames(
|
|
760
|
+
"usx-summary",
|
|
761
|
+
{ [`marker-${markerColor}`]: markerColor && !noMarker },
|
|
762
|
+
{ "usx-summary--no-marker": noMarker },
|
|
763
|
+
{ "usx-summary--no-underline": noUnderline },
|
|
764
|
+
className
|
|
765
|
+
);
|
|
766
|
+
const summaryTextClassNames = ClassNames(
|
|
767
|
+
"usx-summary-text",
|
|
768
|
+
{ [`underline-${underlineColor}`]: !noUnderline && underlineColor },
|
|
769
|
+
textClassName
|
|
770
|
+
);
|
|
771
|
+
return /* @__PURE__ */ jsxRuntime.jsx("summary", { className: summaryClassNames, "aria-label": ariaLabel, title, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: summaryTextClassNames, children: children ?? (label || "Details") }) });
|
|
772
|
+
}
|
|
773
|
+
function Link({
|
|
774
|
+
href,
|
|
775
|
+
text,
|
|
776
|
+
children,
|
|
777
|
+
visited = false,
|
|
778
|
+
external = false,
|
|
779
|
+
alt = false,
|
|
780
|
+
newTab = false,
|
|
781
|
+
className = "",
|
|
782
|
+
...props
|
|
783
|
+
}) {
|
|
784
|
+
const classes = ClassNames(
|
|
785
|
+
"usa-link",
|
|
786
|
+
"usx-link",
|
|
787
|
+
visited && "usx-link--visited",
|
|
788
|
+
external && "usa-link--external",
|
|
789
|
+
alt && "usa-link--alt",
|
|
790
|
+
className
|
|
791
|
+
);
|
|
792
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
793
|
+
"a",
|
|
794
|
+
{
|
|
795
|
+
href,
|
|
796
|
+
className: classes,
|
|
797
|
+
target: newTab || external ? "_blank" : void 0,
|
|
798
|
+
rel: newTab || external ? "noreferrer noopener" : void 0,
|
|
799
|
+
...props,
|
|
800
|
+
children: children ?? text
|
|
801
|
+
}
|
|
802
|
+
);
|
|
803
|
+
}
|
|
804
|
+
const TagGroup = ({
|
|
805
|
+
tagProps = null,
|
|
806
|
+
children = null,
|
|
807
|
+
className = "",
|
|
808
|
+
extraAttributes = {},
|
|
809
|
+
...props
|
|
810
|
+
}) => {
|
|
811
|
+
const classes = ClassNames("usx-tag-group", className);
|
|
812
|
+
const content = children ? children : Array.isArray(tagProps) ? tagProps.map((t, i) => /* @__PURE__ */ jsxRuntime.jsx(Tag, { ...t }, t.id || t.value || i)) : null;
|
|
813
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ...props, ...extraAttributes, className: classes, children: content });
|
|
814
|
+
};
|
|
815
|
+
function PopoverMenu({
|
|
816
|
+
items,
|
|
817
|
+
prefix,
|
|
818
|
+
panelShape,
|
|
819
|
+
className,
|
|
820
|
+
...props
|
|
821
|
+
}) {
|
|
822
|
+
const generatedPrefix = React.useId();
|
|
823
|
+
const base = prefix ?? generatedPrefix;
|
|
824
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ul", { ...props, className: ClassNames("usx-popover__menu", className), children: items.map((item, index) => {
|
|
825
|
+
const id = item.id ?? `${base}-${index}`;
|
|
826
|
+
return /* @__PURE__ */ jsxRuntime.jsx("li", { children: item.type === "details" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
827
|
+
Popover,
|
|
828
|
+
{
|
|
829
|
+
id,
|
|
830
|
+
summaryProps: {
|
|
831
|
+
...item.summaryProps,
|
|
832
|
+
className: ClassNames(item.summaryProps.className, "usx-popover__menu-item")
|
|
833
|
+
},
|
|
834
|
+
name: base,
|
|
835
|
+
side: "right",
|
|
836
|
+
panelShape,
|
|
837
|
+
menuItems: item.items
|
|
838
|
+
}
|
|
839
|
+
) : item.type === "button" || item.onClick ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
840
|
+
"button",
|
|
841
|
+
{
|
|
842
|
+
...item.extraAttributes,
|
|
843
|
+
type: "button",
|
|
844
|
+
className: "usx-popover__menu-item",
|
|
845
|
+
onClick: item.onClick,
|
|
846
|
+
disabled: item.disabled,
|
|
847
|
+
children: [
|
|
848
|
+
item.icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, { ...item.icon }),
|
|
849
|
+
item.text
|
|
850
|
+
]
|
|
851
|
+
}
|
|
852
|
+
) : item.href ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
853
|
+
Link,
|
|
854
|
+
{
|
|
855
|
+
href: item.href,
|
|
856
|
+
text: item.text,
|
|
857
|
+
className: "usx-no-visited usx-popover__menu-item"
|
|
858
|
+
}
|
|
859
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "usx-popover__menu-item", children: item.text }) }, id);
|
|
860
|
+
}) });
|
|
861
|
+
}
|
|
862
|
+
function Popover({
|
|
863
|
+
id,
|
|
864
|
+
side = "bottom",
|
|
865
|
+
align = "start",
|
|
866
|
+
panelShape = "rounded",
|
|
867
|
+
defaultOpen = false,
|
|
868
|
+
dismissOnOutside = true,
|
|
869
|
+
menuItems,
|
|
870
|
+
showClose = false,
|
|
871
|
+
closeLabel = "Close",
|
|
872
|
+
headerLeftActions,
|
|
873
|
+
headerRightActions,
|
|
874
|
+
showCloseIcon = false,
|
|
875
|
+
closeIconLabel = "Close",
|
|
876
|
+
headerClassName,
|
|
877
|
+
panelHeading,
|
|
878
|
+
panelHeadingId,
|
|
879
|
+
headingAs = "h2",
|
|
880
|
+
scrollable = false,
|
|
881
|
+
className,
|
|
882
|
+
summaryProps,
|
|
883
|
+
panelClassName,
|
|
884
|
+
contentClassName,
|
|
885
|
+
extraAttributes,
|
|
886
|
+
children,
|
|
887
|
+
...props
|
|
888
|
+
}) {
|
|
889
|
+
const composedSummaryProps = { ...summaryProps, label: (summaryProps == null ? void 0 : summaryProps.label) ?? "Open panel" };
|
|
890
|
+
const Heading = headingAs;
|
|
891
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
892
|
+
"details",
|
|
893
|
+
{
|
|
894
|
+
...props,
|
|
895
|
+
className: ClassNames("usx-popover", className),
|
|
896
|
+
open: defaultOpen || void 0,
|
|
897
|
+
"data-side": side,
|
|
898
|
+
"data-align": align,
|
|
899
|
+
"data-usx-popover-dismiss-on-outside": dismissOnOutside ? void 0 : "false",
|
|
900
|
+
...extraAttributes,
|
|
901
|
+
children: [
|
|
902
|
+
/* @__PURE__ */ jsxRuntime.jsx(Summary, { unstyled: true, ...composedSummaryProps }),
|
|
903
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
904
|
+
"div",
|
|
905
|
+
{
|
|
906
|
+
id,
|
|
907
|
+
className: ClassNames(
|
|
908
|
+
"usx-popover__panel",
|
|
909
|
+
{
|
|
910
|
+
"usx-popover__panel--square": panelShape === "square"
|
|
911
|
+
},
|
|
912
|
+
panelClassName
|
|
913
|
+
),
|
|
914
|
+
children: [
|
|
915
|
+
(headerLeftActions || panelHeading || headerRightActions || showCloseIcon) && /* @__PURE__ */ jsxRuntime.jsxs("header", { className: ClassNames("usx-popover__header", headerClassName), children: [
|
|
916
|
+
headerLeftActions && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "usx-popover__header-left-actions", children: headerLeftActions }),
|
|
917
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "usx-popover__header-content", children: panelHeading && /* @__PURE__ */ jsxRuntime.jsx(Heading, { id: panelHeadingId, className: "usx-popover__panel-heading", tabIndex: -1, children: panelHeading }) }),
|
|
918
|
+
(headerRightActions || showCloseIcon) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "usx-popover__header-right-actions", children: [
|
|
919
|
+
headerRightActions,
|
|
920
|
+
showCloseIcon && /* @__PURE__ */ jsxRuntime.jsx(
|
|
921
|
+
Button,
|
|
922
|
+
{
|
|
923
|
+
variant: "unstyled",
|
|
924
|
+
className: "usx-popover__header-action usx-popover__header-close",
|
|
925
|
+
"aria-label": closeIconLabel,
|
|
926
|
+
iconProps: [{ name: "close" }],
|
|
927
|
+
extraAttributes: { "data-usx-popover-close": id }
|
|
928
|
+
}
|
|
929
|
+
)
|
|
930
|
+
] })
|
|
931
|
+
] }),
|
|
932
|
+
menuItems && menuItems.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(PopoverMenu, { items: menuItems, prefix: id, panelShape }),
|
|
933
|
+
Boolean(children) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
934
|
+
"div",
|
|
935
|
+
{
|
|
936
|
+
className: ClassNames(
|
|
937
|
+
"usx-popover__panel-content",
|
|
938
|
+
{ "usx-popover__scroll": scrollable },
|
|
939
|
+
contentClassName
|
|
940
|
+
),
|
|
941
|
+
children
|
|
942
|
+
}
|
|
943
|
+
),
|
|
944
|
+
showClose && /* @__PURE__ */ jsxRuntime.jsx(
|
|
945
|
+
Button,
|
|
946
|
+
{
|
|
947
|
+
variant: "unstyled",
|
|
948
|
+
className: "usx-popover__panel-close",
|
|
949
|
+
"data-usx-popover-close": id,
|
|
950
|
+
children: closeLabel
|
|
951
|
+
}
|
|
952
|
+
)
|
|
953
|
+
]
|
|
954
|
+
}
|
|
955
|
+
)
|
|
956
|
+
]
|
|
957
|
+
}
|
|
958
|
+
);
|
|
959
|
+
}
|
|
960
|
+
exports.Alert = Alert;
|
|
961
|
+
exports.Avatar = Avatar;
|
|
962
|
+
exports.AvatarGroup = AvatarGroup;
|
|
963
|
+
exports.Button = Button;
|
|
964
|
+
exports.ButtonGroup = ButtonGroup;
|
|
965
|
+
exports.Callout = Callout;
|
|
966
|
+
exports.ClassNames = ClassNames;
|
|
967
|
+
exports.Clickable = Clickable;
|
|
968
|
+
exports.ErrorMessage = ErrorMessage;
|
|
969
|
+
exports.FormGroup = FormGroup;
|
|
970
|
+
exports.Hint = Hint;
|
|
971
|
+
exports.Icon = Icon;
|
|
972
|
+
exports.Image = Image;
|
|
973
|
+
exports.Label = Label;
|
|
974
|
+
exports.Link = Link;
|
|
975
|
+
exports.Popover = Popover;
|
|
976
|
+
exports.Required = Required;
|
|
977
|
+
exports.Spinner = Spinner;
|
|
978
|
+
exports.Summary = Summary;
|
|
979
|
+
exports.Tag = Tag;
|
|
980
|
+
exports.TagGroup = TagGroup;
|
|
981
|
+
exports.TextArea = TextArea;
|
|
982
|
+
exports.Tooltip = Tooltip;
|
|
983
|
+
exports.getAssetUrl = getAssetUrl;
|
|
984
|
+
exports.getDefaultExportFromCjs = getDefaultExportFromCjs;
|