@charcoal-ui/react 5.0.0-beta.1 → 5.0.0-beta.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/dist/_lib/createDivComponent.d.ts +1 -1
- package/dist/_lib/useForwardedRef.d.ts.map +1 -1
- package/dist/components/Button/index.d.ts +1 -12
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Checkbox/CheckboxWithLabel.d.ts +3 -3
- package/dist/components/Checkbox/CheckboxWithLabel.d.ts.map +1 -1
- package/dist/components/Checkbox/index.d.ts +6 -6
- package/dist/components/Clickable/index.d.ts +1 -1
- package/dist/components/Clickable/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/ListItem/index.d.ts +1 -1
- package/dist/components/DropdownSelector/ListItem/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/MenuItem/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/Popover/usePreventScroll.d.ts.map +1 -1
- package/dist/components/DropdownSelector/index.d.ts.map +1 -1
- package/dist/components/IconButton/index.d.ts +1 -1
- package/dist/components/IconButton/index.d.ts.map +1 -1
- package/dist/components/Modal/ModalPlumbing.d.ts +3 -3
- package/dist/components/Modal/index.d.ts +8 -8
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/MultiSelect/index.d.ts +6 -6
- package/dist/components/MultiSelect/index.d.ts.map +1 -1
- package/dist/components/Radio/RadioGroup/index.d.ts.map +1 -1
- package/dist/components/Radio/RadioInput/index.d.ts.map +1 -1
- package/dist/components/Radio/index.d.ts +3 -3
- package/dist/components/Radio/index.d.ts.map +1 -1
- package/dist/components/Switch/SwitchWithLabel.d.ts +3 -3
- package/dist/components/Switch/SwitchWithLabel.d.ts.map +1 -1
- package/dist/components/TagItem/index.d.ts +5 -5
- package/dist/components/TagItem/index.d.ts.map +1 -1
- package/dist/components/TextArea/index.d.ts +11 -11
- package/dist/components/TextArea/index.d.ts.map +1 -1
- package/dist/components/TextField/AssistiveText/index.d.ts +1 -1
- package/dist/components/TextField/index.d.ts +11 -11
- package/dist/components/TextField/index.d.ts.map +1 -1
- package/dist/core/SSRProvider.d.ts +1 -1
- package/dist/core/themeHelper.d.ts.map +1 -1
- package/dist/index.cjs +11 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +432 -220
- package/dist/index.css.map +1 -1
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/layered.css +433 -221
- package/dist/layered.css.map +1 -1
- package/package.json +15 -22
- package/src/_lib/useForwardedRef.tsx +1 -0
- package/src/components/Button/index.story.tsx +4 -4
- package/src/components/DropdownSelector/DropdownMenuItem/index.tsx +1 -1
- package/src/components/DropdownSelector/ListItem/index.tsx +1 -1
- package/src/components/DropdownSelector/MenuItem/index.tsx +2 -1
- package/src/components/DropdownSelector/Popover/usePreventScroll.tsx +1 -0
- package/src/components/DropdownSelector/index.tsx +1 -0
- package/src/components/Modal/index.story.tsx +4 -12
- package/src/components/MultiSelect/index.test.tsx +4 -4
- package/src/components/MultiSelect/index.tsx +1 -1
- package/src/components/Radio/RadioInput/index.tsx +1 -0
- package/src/components/TagItem/index.tsx +4 -4
- package/dist/index.cjs.js +0 -1624
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.esm.js +0 -1550
- package/dist/index.esm.js.map +0 -1
package/dist/index.cjs.js
DELETED
|
@@ -1,1624 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all)
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from))
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
|
|
31
|
-
// src/index.ts
|
|
32
|
-
var src_exports = {};
|
|
33
|
-
__export(src_exports, {
|
|
34
|
-
Button: () => Button_default,
|
|
35
|
-
CharcoalProvider: () => CharcoalProvider,
|
|
36
|
-
Checkbox: () => Checkbox_default,
|
|
37
|
-
Clickable: () => Clickable_default,
|
|
38
|
-
DropdownMenuItem: () => DropdownMenuItem,
|
|
39
|
-
DropdownSelector: () => DropdownSelector,
|
|
40
|
-
HintText: () => HintText,
|
|
41
|
-
Icon: () => Icon_default,
|
|
42
|
-
IconButton: () => IconButton_default,
|
|
43
|
-
LoadingSpinner: () => LoadingSpinner_default,
|
|
44
|
-
LoadingSpinnerIcon: () => LoadingSpinnerIcon,
|
|
45
|
-
MenuItemGroup: () => MenuItemGroup,
|
|
46
|
-
Modal: () => Modal_default,
|
|
47
|
-
ModalAlign: () => ModalAlign,
|
|
48
|
-
ModalBody: () => ModalBody,
|
|
49
|
-
ModalButtons: () => ModalButtons,
|
|
50
|
-
ModalCloseButton: () => ModalCloseButton,
|
|
51
|
-
ModalHeader: () => ModalHeader,
|
|
52
|
-
MultiSelect: () => MultiSelect_default,
|
|
53
|
-
MultiSelectGroup: () => MultiSelectGroup,
|
|
54
|
-
OverlayProvider: () => import_overlays.OverlayProvider,
|
|
55
|
-
Radio: () => Radio_default,
|
|
56
|
-
RadioGroup: () => RadioGroup,
|
|
57
|
-
SSRProvider: () => SSRProvider,
|
|
58
|
-
SegmentedControl: () => SegmentedControl_default,
|
|
59
|
-
SetThemeScript: () => SetThemeScript,
|
|
60
|
-
Switch: () => Switch_default,
|
|
61
|
-
TagItem: () => TagItem_default,
|
|
62
|
-
TextArea: () => TextArea_default,
|
|
63
|
-
TextField: () => TextField_default,
|
|
64
|
-
getThemeSync: () => getThemeSync,
|
|
65
|
-
makeSetThemeScriptCode: () => makeSetThemeScriptCode,
|
|
66
|
-
prefersColorScheme: () => prefersColorScheme,
|
|
67
|
-
themeSelector: () => themeSelector,
|
|
68
|
-
themeSetter: () => themeSetter,
|
|
69
|
-
useLocalStorage: () => useLocalStorage,
|
|
70
|
-
useMedia: () => useMedia,
|
|
71
|
-
useTheme: () => useTheme,
|
|
72
|
-
useThemeSetter: () => useThemeSetter
|
|
73
|
-
});
|
|
74
|
-
module.exports = __toCommonJS(src_exports);
|
|
75
|
-
|
|
76
|
-
// src/core/SSRProvider.tsx
|
|
77
|
-
var import_ssr = require("@react-aria/ssr");
|
|
78
|
-
var import_react = require("react");
|
|
79
|
-
function isReactVersionOver(minVersion) {
|
|
80
|
-
const reactMajorVersion = parseInt(import_react.version.split(".")[0], 10);
|
|
81
|
-
return Number.isFinite(reactMajorVersion) ? reactMajorVersion >= minVersion : false;
|
|
82
|
-
}
|
|
83
|
-
var SSRProvider = isReactVersionOver(18) ? import_react.Fragment : import_ssr.SSRProvider;
|
|
84
|
-
|
|
85
|
-
// src/core/OverlayProvider.tsx
|
|
86
|
-
var import_overlays = require("@react-aria/overlays");
|
|
87
|
-
|
|
88
|
-
// src/core/CharcoalProvider.tsx
|
|
89
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
90
|
-
function CharcoalProvider({
|
|
91
|
-
children
|
|
92
|
-
}) {
|
|
93
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SSRProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_overlays.OverlayProvider, { children }) });
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// src/core/themeHelper.ts
|
|
97
|
-
var import_react2 = require("react");
|
|
98
|
-
var LOCAL_STORAGE_KEY = "charcoal-theme";
|
|
99
|
-
var DEFAULT_ROOT_ATTRIBUTE = "theme";
|
|
100
|
-
var keyStringRegExp = new RegExp(/^(\w|-)+$/);
|
|
101
|
-
function assertKeyString(key) {
|
|
102
|
-
if (!keyStringRegExp.test(key)) {
|
|
103
|
-
throw new Error(`Unexpected key :${key}, expect: /^(\\w|-)+$/`);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
var themeSetter = (attr = DEFAULT_ROOT_ATTRIBUTE) => (theme) => {
|
|
107
|
-
assertKeyString(attr);
|
|
108
|
-
if (theme !== void 0) {
|
|
109
|
-
document.documentElement.dataset[attr] = theme;
|
|
110
|
-
} else {
|
|
111
|
-
delete document.documentElement.dataset[attr];
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
function themeSelector(theme, attr) {
|
|
115
|
-
return `:root[data-${attr ?? DEFAULT_ROOT_ATTRIBUTE}='${theme}']`;
|
|
116
|
-
}
|
|
117
|
-
function prefersColorScheme(theme) {
|
|
118
|
-
return `@media (prefers-color-scheme: ${theme})`;
|
|
119
|
-
}
|
|
120
|
-
function useThemeSetter({
|
|
121
|
-
key = LOCAL_STORAGE_KEY,
|
|
122
|
-
setter = themeSetter()
|
|
123
|
-
} = {}) {
|
|
124
|
-
const [theme, , system] = useTheme(key);
|
|
125
|
-
(0, import_react2.useEffect)(() => {
|
|
126
|
-
if (theme === void 0) {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
setter(system ? void 0 : theme);
|
|
130
|
-
}, [setter, system, theme]);
|
|
131
|
-
}
|
|
132
|
-
function getThemeSync(key = LOCAL_STORAGE_KEY) {
|
|
133
|
-
const theme = localStorage.getItem(key);
|
|
134
|
-
return theme;
|
|
135
|
-
}
|
|
136
|
-
var useTheme = (localStorageKey = LOCAL_STORAGE_KEY) => {
|
|
137
|
-
assertKeyString(localStorageKey);
|
|
138
|
-
const isDark = useMedia("(prefers-color-scheme: dark)");
|
|
139
|
-
const media = isDark !== void 0 ? isDark ? "dark" : "light" : void 0;
|
|
140
|
-
const [local, setTheme, ready] = useLocalStorage(localStorageKey);
|
|
141
|
-
const theme = !ready || media === void 0 ? void 0 : local ?? media;
|
|
142
|
-
const system = local === void 0;
|
|
143
|
-
return [theme, setTheme, system];
|
|
144
|
-
};
|
|
145
|
-
function useLocalStorage(key, defaultValue) {
|
|
146
|
-
const [ready, setReady] = (0, import_react2.useState)(false);
|
|
147
|
-
const [state, setState] = (0, import_react2.useState)();
|
|
148
|
-
const defaultValueMemo = (0, import_react2.useMemo)(() => defaultValue?.(), [defaultValue]);
|
|
149
|
-
(0, import_react2.useEffect)(() => {
|
|
150
|
-
fetch();
|
|
151
|
-
window.addEventListener("storage", handleStorage);
|
|
152
|
-
return () => {
|
|
153
|
-
window.removeEventListener("storage", handleStorage);
|
|
154
|
-
};
|
|
155
|
-
});
|
|
156
|
-
const handleStorage = (e) => {
|
|
157
|
-
if (e.storageArea !== localStorage) {
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
if (e.key !== key) {
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
fetch();
|
|
164
|
-
};
|
|
165
|
-
const fetch = () => {
|
|
166
|
-
const raw = localStorage.getItem(key);
|
|
167
|
-
setState((raw !== null ? deserialize(raw) : null) ?? defaultValueMemo);
|
|
168
|
-
setReady(true);
|
|
169
|
-
};
|
|
170
|
-
const set = (value) => {
|
|
171
|
-
if (value === void 0) {
|
|
172
|
-
localStorage.removeItem(key);
|
|
173
|
-
} else {
|
|
174
|
-
const raw = serialize(value);
|
|
175
|
-
localStorage.setItem(key, raw);
|
|
176
|
-
}
|
|
177
|
-
const event = new StorageEvent("storage", {
|
|
178
|
-
bubbles: true,
|
|
179
|
-
cancelable: false,
|
|
180
|
-
key,
|
|
181
|
-
url: location.href,
|
|
182
|
-
storageArea: localStorage
|
|
183
|
-
});
|
|
184
|
-
dispatchEvent(event);
|
|
185
|
-
};
|
|
186
|
-
return [state ?? defaultValueMemo, set, ready];
|
|
187
|
-
}
|
|
188
|
-
function deserialize(raw) {
|
|
189
|
-
try {
|
|
190
|
-
return JSON.parse(raw);
|
|
191
|
-
} catch {
|
|
192
|
-
return raw;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
function serialize(value) {
|
|
196
|
-
if (typeof value === "string") {
|
|
197
|
-
return value;
|
|
198
|
-
} else {
|
|
199
|
-
return JSON.stringify(value);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
function useMedia(query) {
|
|
203
|
-
const [match, setState] = (0, import_react2.useState)();
|
|
204
|
-
(0, import_react2.useEffect)(() => {
|
|
205
|
-
const matcher = window.matchMedia(query);
|
|
206
|
-
const onChange = () => {
|
|
207
|
-
setState(matcher.matches);
|
|
208
|
-
};
|
|
209
|
-
matcher.addEventListener("change", onChange);
|
|
210
|
-
setState(matcher.matches);
|
|
211
|
-
return () => {
|
|
212
|
-
matcher.removeEventListener("change", onChange);
|
|
213
|
-
};
|
|
214
|
-
}, [query]);
|
|
215
|
-
return match;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// src/core/SetThemeScript.tsx
|
|
219
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
220
|
-
function makeSetThemeScriptCode({
|
|
221
|
-
localStorageKey = defaultProps.localStorageKey,
|
|
222
|
-
rootAttribute = defaultProps.rootAttribute
|
|
223
|
-
} = defaultProps) {
|
|
224
|
-
assertKeyString(localStorageKey);
|
|
225
|
-
assertKeyString(rootAttribute);
|
|
226
|
-
return `'use strict';
|
|
227
|
-
(function () {
|
|
228
|
-
var localStorageKey = '${localStorageKey}'
|
|
229
|
-
var rootAttribute = '${rootAttribute}'
|
|
230
|
-
var currentTheme = localStorage.getItem(localStorageKey);
|
|
231
|
-
if (currentTheme) {
|
|
232
|
-
document.documentElement.dataset[rootAttribute] = currentTheme;
|
|
233
|
-
}
|
|
234
|
-
})();
|
|
235
|
-
`;
|
|
236
|
-
}
|
|
237
|
-
function SetThemeScript({
|
|
238
|
-
localStorageKey = defaultProps.localStorageKey,
|
|
239
|
-
rootAttribute = defaultProps.rootAttribute
|
|
240
|
-
}) {
|
|
241
|
-
const src = makeSetThemeScriptCode({
|
|
242
|
-
localStorageKey,
|
|
243
|
-
rootAttribute
|
|
244
|
-
});
|
|
245
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("script", { dangerouslySetInnerHTML: {
|
|
246
|
-
__html: src
|
|
247
|
-
} });
|
|
248
|
-
}
|
|
249
|
-
var defaultProps = {
|
|
250
|
-
localStorageKey: LOCAL_STORAGE_KEY,
|
|
251
|
-
rootAttribute: DEFAULT_ROOT_ATTRIBUTE
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
// src/components/Button/index.tsx
|
|
255
|
-
var import_react4 = require("react");
|
|
256
|
-
|
|
257
|
-
// src/_lib/useClassNames.ts
|
|
258
|
-
var import_react3 = require("react");
|
|
259
|
-
function useClassNames(...classNames) {
|
|
260
|
-
return (0, import_react3.useMemo)(() => classNames.filter((v) => v).join(" "), [classNames]);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// src/components/Button/index.tsx
|
|
264
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
265
|
-
var Button = (0, import_react4.forwardRef)(function Button2({
|
|
266
|
-
variant,
|
|
267
|
-
fullWidth,
|
|
268
|
-
size,
|
|
269
|
-
className,
|
|
270
|
-
component,
|
|
271
|
-
isActive,
|
|
272
|
-
...props
|
|
273
|
-
}, ref) {
|
|
274
|
-
const Component = (0, import_react4.useMemo)(() => component ?? "button", [component]);
|
|
275
|
-
const classNames = useClassNames("charcoal-button", className);
|
|
276
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Component, { ...props, className: classNames, "data-variant": variant, "data-size": size, "data-full-width": fullWidth, "data-active": isActive, ref });
|
|
277
|
-
});
|
|
278
|
-
var Button_default = Button;
|
|
279
|
-
|
|
280
|
-
// src/components/Clickable/index.tsx
|
|
281
|
-
var import_react5 = require("react");
|
|
282
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
283
|
-
var Clickable = (0, import_react5.forwardRef)(function Clickable2({
|
|
284
|
-
component,
|
|
285
|
-
...props
|
|
286
|
-
}, ref) {
|
|
287
|
-
const className = useClassNames("charcoal-clickable", props.className);
|
|
288
|
-
const Component = (0, import_react5.useMemo)(() => component ?? "button", [component]);
|
|
289
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Component, { ...props, ref, className });
|
|
290
|
-
});
|
|
291
|
-
var Clickable_default = Clickable;
|
|
292
|
-
|
|
293
|
-
// src/components/IconButton/index.tsx
|
|
294
|
-
var import_react6 = require("react");
|
|
295
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
296
|
-
var IconButton = (0, import_react6.forwardRef)(function IconButtonInner({
|
|
297
|
-
variant = "Default",
|
|
298
|
-
size = "M",
|
|
299
|
-
icon,
|
|
300
|
-
isActive = false,
|
|
301
|
-
component,
|
|
302
|
-
...rest
|
|
303
|
-
}, ref) {
|
|
304
|
-
validateIconSize(size, icon);
|
|
305
|
-
const Component = (0, import_react6.useMemo)(() => component ?? "button", [component]);
|
|
306
|
-
const classNames = useClassNames("charcoal-icon-button", rest.className);
|
|
307
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Component, { ...rest, ref, className: classNames, "data-size": size, "data-active": isActive, "data-variant": variant, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("pixiv-icon", { name: icon }) });
|
|
308
|
-
});
|
|
309
|
-
var IconButton_default = IconButton;
|
|
310
|
-
function validateIconSize(size, icon) {
|
|
311
|
-
let requiredIconSize;
|
|
312
|
-
switch (size) {
|
|
313
|
-
case "XS":
|
|
314
|
-
requiredIconSize = "16";
|
|
315
|
-
break;
|
|
316
|
-
case "S":
|
|
317
|
-
case "M":
|
|
318
|
-
requiredIconSize = "24";
|
|
319
|
-
break;
|
|
320
|
-
}
|
|
321
|
-
const result = /^\d*/u.exec(icon);
|
|
322
|
-
if (result == null) {
|
|
323
|
-
throw new Error("Invalid icon name");
|
|
324
|
-
}
|
|
325
|
-
const [iconSize] = result;
|
|
326
|
-
if (iconSize !== requiredIconSize) {
|
|
327
|
-
console.warn(`IconButton with size "${size}" expect icon size "${requiredIconSize}, but got "${iconSize}"`);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
// src/components/Radio/index.tsx
|
|
332
|
-
var import_react8 = require("react");
|
|
333
|
-
var import_warning = __toESM(require("warning"));
|
|
334
|
-
|
|
335
|
-
// src/components/Radio/RadioGroupContext.ts
|
|
336
|
-
var React4 = __toESM(require("react"));
|
|
337
|
-
var RadioGroupContext = React4.createContext({
|
|
338
|
-
name: void 0,
|
|
339
|
-
selected: void 0,
|
|
340
|
-
disabled: false,
|
|
341
|
-
readonly: false,
|
|
342
|
-
invalid: false,
|
|
343
|
-
onChange() {
|
|
344
|
-
throw new Error("Cannot find onChange() handler. Perhaps you forgot to wrap with <RadioGroup> ?");
|
|
345
|
-
}
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
// src/components/Radio/RadioInput/index.tsx
|
|
349
|
-
var import_react7 = require("react");
|
|
350
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
351
|
-
var RadioInput = (0, import_react7.forwardRef)(function RadioInput2({
|
|
352
|
-
onChange,
|
|
353
|
-
invalid,
|
|
354
|
-
className,
|
|
355
|
-
...props
|
|
356
|
-
}, ref) {
|
|
357
|
-
const handleChange = (0, import_react7.useCallback)((e) => {
|
|
358
|
-
const el = e.currentTarget;
|
|
359
|
-
onChange?.(el.value);
|
|
360
|
-
}, [onChange]);
|
|
361
|
-
const classNames = useClassNames("charcoal-radio-input", className);
|
|
362
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { className: classNames, ref, type: "radio", onChange: handleChange, "aria-invalid": invalid, ...props });
|
|
363
|
-
});
|
|
364
|
-
var RadioInput_default = (0, import_react7.memo)(RadioInput);
|
|
365
|
-
|
|
366
|
-
// src/components/Radio/index.tsx
|
|
367
|
-
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
368
|
-
var Radio = (0, import_react8.forwardRef)(function RadioInner({
|
|
369
|
-
value,
|
|
370
|
-
disabled = false,
|
|
371
|
-
children,
|
|
372
|
-
...props
|
|
373
|
-
}, ref) {
|
|
374
|
-
const {
|
|
375
|
-
name,
|
|
376
|
-
selected,
|
|
377
|
-
disabled: isParentDisabled,
|
|
378
|
-
readonly,
|
|
379
|
-
invalid,
|
|
380
|
-
onChange
|
|
381
|
-
} = (0, import_react8.useContext)(RadioGroupContext);
|
|
382
|
-
const classNames = useClassNames("charcoal-radio__label", props.className);
|
|
383
|
-
(0, import_warning.default)(
|
|
384
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
385
|
-
name !== void 0,
|
|
386
|
-
`"name" is not Provided for <Radio>. Perhaps you forgot to wrap with <RadioGroup> ?`
|
|
387
|
-
);
|
|
388
|
-
const isSelected = value === selected;
|
|
389
|
-
const isDisabled = disabled || isParentDisabled;
|
|
390
|
-
const isReadonly = readonly && !isSelected;
|
|
391
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("label", { "aria-disabled": isDisabled || isReadonly, className: classNames, children: [
|
|
392
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(RadioInput_default, { name, value, checked: isSelected, "aria-invalid": invalid, onChange, disabled: isDisabled || isReadonly, ref }),
|
|
393
|
-
children != null && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "charcoal-radio__label_div", children })
|
|
394
|
-
] });
|
|
395
|
-
});
|
|
396
|
-
var Radio_default = (0, import_react8.memo)(Radio);
|
|
397
|
-
|
|
398
|
-
// src/components/Radio/RadioGroup/index.tsx
|
|
399
|
-
var import_react9 = require("react");
|
|
400
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
401
|
-
var RadioGroup = (0, import_react9.forwardRef)(function RadioGroupInner({
|
|
402
|
-
value,
|
|
403
|
-
label,
|
|
404
|
-
name,
|
|
405
|
-
onChange,
|
|
406
|
-
disabled,
|
|
407
|
-
readonly,
|
|
408
|
-
invalid,
|
|
409
|
-
children,
|
|
410
|
-
"aria-orientation": ariaOrientation = "vertical",
|
|
411
|
-
...props
|
|
412
|
-
}, ref) {
|
|
413
|
-
const classNames = useClassNames("charcoal-radio-group", props.className);
|
|
414
|
-
const handleChange = (0, import_react9.useCallback)((next) => {
|
|
415
|
-
onChange(next);
|
|
416
|
-
}, [onChange]);
|
|
417
|
-
const contextValue = (0, import_react9.useMemo)(() => ({
|
|
418
|
-
name,
|
|
419
|
-
selected: value,
|
|
420
|
-
disabled: disabled ?? false,
|
|
421
|
-
readonly: readonly ?? false,
|
|
422
|
-
invalid: invalid ?? false,
|
|
423
|
-
onChange: handleChange
|
|
424
|
-
}), [disabled, handleChange, invalid, name, readonly, value]);
|
|
425
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(RadioGroupContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { role: "radiogroup", "aria-disabled": disabled, "aria-invalid": invalid, "aria-label": label, "aria-labelledby": props["aria-labelledby"], "aria-orientation": ariaOrientation, className: classNames, ref, children }) });
|
|
426
|
-
});
|
|
427
|
-
|
|
428
|
-
// src/components/MultiSelect/index.tsx
|
|
429
|
-
var import_react11 = require("react");
|
|
430
|
-
var import_warning2 = __toESM(require("warning"));
|
|
431
|
-
|
|
432
|
-
// src/components/MultiSelect/context.ts
|
|
433
|
-
var import_react10 = require("react");
|
|
434
|
-
var MultiSelectGroupContext = (0, import_react10.createContext)({
|
|
435
|
-
name: void 0,
|
|
436
|
-
selected: [],
|
|
437
|
-
disabled: false,
|
|
438
|
-
readonly: false,
|
|
439
|
-
invalid: false,
|
|
440
|
-
onChange() {
|
|
441
|
-
throw new Error("Cannot find `onChange()` handler. Perhaps you forgot to wrap it with `<MultiSelectGroup />` ?");
|
|
442
|
-
}
|
|
443
|
-
});
|
|
444
|
-
|
|
445
|
-
// src/components/Icon/index.tsx
|
|
446
|
-
var React5 = __toESM(require("react"));
|
|
447
|
-
var import_icons = require("@charcoal-ui/icons");
|
|
448
|
-
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
449
|
-
var Icon = React5.forwardRef(function IconInner({
|
|
450
|
-
name,
|
|
451
|
-
scale,
|
|
452
|
-
unsafeNonGuidelineScale,
|
|
453
|
-
className,
|
|
454
|
-
...rest
|
|
455
|
-
}, ref) {
|
|
456
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("pixiv-icon", { ref, name, scale, "unsafe-non-guideline-scale": unsafeNonGuidelineScale, class: className, ...rest });
|
|
457
|
-
});
|
|
458
|
-
var Icon_default = Icon;
|
|
459
|
-
|
|
460
|
-
// src/components/MultiSelect/index.tsx
|
|
461
|
-
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
462
|
-
var MultiSelect = (0, import_react11.forwardRef)(function MultiSelectInner({
|
|
463
|
-
value,
|
|
464
|
-
disabled = false,
|
|
465
|
-
onChange,
|
|
466
|
-
variant = "default",
|
|
467
|
-
className,
|
|
468
|
-
children
|
|
469
|
-
}, ref) {
|
|
470
|
-
const {
|
|
471
|
-
name,
|
|
472
|
-
selected,
|
|
473
|
-
disabled: parentDisabled,
|
|
474
|
-
readonly,
|
|
475
|
-
invalid,
|
|
476
|
-
onChange: parentOnChange
|
|
477
|
-
} = (0, import_react11.useContext)(MultiSelectGroupContext);
|
|
478
|
-
(0, import_warning2.default)(
|
|
479
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
480
|
-
name !== void 0,
|
|
481
|
-
`"name" is not Provided for <MultiSelect>. Perhaps you forgot to wrap with <MultiSelectGroup> ?`
|
|
482
|
-
);
|
|
483
|
-
const isSelected = selected.includes(value);
|
|
484
|
-
const isDisabled = disabled || parentDisabled || readonly;
|
|
485
|
-
const handleChange = (0, import_react11.useCallback)((event) => {
|
|
486
|
-
if (!(event.currentTarget instanceof HTMLInputElement)) {
|
|
487
|
-
return;
|
|
488
|
-
}
|
|
489
|
-
if (onChange)
|
|
490
|
-
onChange({
|
|
491
|
-
value,
|
|
492
|
-
selected: event.currentTarget.checked
|
|
493
|
-
});
|
|
494
|
-
parentOnChange({
|
|
495
|
-
value,
|
|
496
|
-
selected: event.currentTarget.checked
|
|
497
|
-
});
|
|
498
|
-
}, [onChange, parentOnChange, value]);
|
|
499
|
-
const classNames = useClassNames("charcoal-multi-select", className);
|
|
500
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("label", { "aria-disabled": isDisabled, className: classNames, children: [
|
|
501
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("input", { className: "charcoal-multi-select-input", name, value, type: "checkbox", checked: isSelected, disabled: isDisabled, onChange: handleChange, "data-overlay": variant === "overlay", "aria-invalid": invalid, ref }),
|
|
502
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "charcoal-multi-select-overlay", "data-overlay": variant === "overlay", "aria-invalid": invalid, "aria-hidden": true, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Icon_default, { name: "24/Check", "unsafe-non-guideline-scale": 16 / 24 }) }),
|
|
503
|
-
Boolean(children) && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "charcoal-multi-select-label", children })
|
|
504
|
-
] });
|
|
505
|
-
});
|
|
506
|
-
var MultiSelect_default = (0, import_react11.memo)(MultiSelect);
|
|
507
|
-
function MultiSelectGroup({
|
|
508
|
-
className,
|
|
509
|
-
style,
|
|
510
|
-
name,
|
|
511
|
-
label,
|
|
512
|
-
selected,
|
|
513
|
-
onChange,
|
|
514
|
-
disabled = false,
|
|
515
|
-
readonly = false,
|
|
516
|
-
invalid = false,
|
|
517
|
-
children
|
|
518
|
-
}) {
|
|
519
|
-
const handleChange = (0, import_react11.useCallback)((payload) => {
|
|
520
|
-
const index = selected.indexOf(payload.value);
|
|
521
|
-
if (payload.selected) {
|
|
522
|
-
if (index < 0) {
|
|
523
|
-
onChange([...selected, payload.value]);
|
|
524
|
-
}
|
|
525
|
-
} else {
|
|
526
|
-
if (index >= 0) {
|
|
527
|
-
onChange([...selected.slice(0, index), ...selected.slice(index + 1)]);
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
}, [onChange, selected]);
|
|
531
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(MultiSelectGroupContext.Provider, { value: {
|
|
532
|
-
name,
|
|
533
|
-
selected: Array.from(new Set(selected)),
|
|
534
|
-
disabled,
|
|
535
|
-
readonly,
|
|
536
|
-
invalid,
|
|
537
|
-
onChange: handleChange
|
|
538
|
-
}, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className, style, "aria-label": label, "data-testid": "SelectGroup", children }) });
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
// src/components/Switch/index.tsx
|
|
542
|
-
var import_react13 = require("react");
|
|
543
|
-
var import_utils = require("@react-aria/utils");
|
|
544
|
-
|
|
545
|
-
// src/components/Switch/SwitchInput/index.tsx
|
|
546
|
-
var import_react12 = require("react");
|
|
547
|
-
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
548
|
-
var SwitchInput = (0, import_react12.forwardRef)(function SwitchInput2({
|
|
549
|
-
onChange,
|
|
550
|
-
className,
|
|
551
|
-
...props
|
|
552
|
-
}, ref) {
|
|
553
|
-
const handleChange = (0, import_react12.useCallback)((e) => {
|
|
554
|
-
const el = e.currentTarget;
|
|
555
|
-
onChange?.(el.checked);
|
|
556
|
-
}, [onChange]);
|
|
557
|
-
const classNames = useClassNames("charcoal-switch-input", className);
|
|
558
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", { ref, className: classNames, type: "checkbox", onChange: handleChange, ...props });
|
|
559
|
-
});
|
|
560
|
-
var SwitchInput_default = SwitchInput;
|
|
561
|
-
|
|
562
|
-
// src/components/Switch/SwitchWithLabel.tsx
|
|
563
|
-
var React6 = __toESM(require("react"));
|
|
564
|
-
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
565
|
-
var SwitchWithLabel = React6.memo(function SwitchWithLabel2({
|
|
566
|
-
children,
|
|
567
|
-
className,
|
|
568
|
-
disabled,
|
|
569
|
-
id,
|
|
570
|
-
input
|
|
571
|
-
}) {
|
|
572
|
-
const classNames = useClassNames("charcoal-switch__label", className);
|
|
573
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { htmlFor: id, className: classNames, "aria-disabled": disabled, children: [
|
|
574
|
-
input,
|
|
575
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "charcoal-switch__label_div", children })
|
|
576
|
-
] });
|
|
577
|
-
});
|
|
578
|
-
|
|
579
|
-
// src/components/Switch/index.tsx
|
|
580
|
-
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
581
|
-
var Switch = (0, import_react13.forwardRef)(function Switch2({
|
|
582
|
-
children,
|
|
583
|
-
onChange,
|
|
584
|
-
disabled,
|
|
585
|
-
className,
|
|
586
|
-
id,
|
|
587
|
-
...props
|
|
588
|
-
}, ref) {
|
|
589
|
-
const htmlId = (0, import_utils.useId)(id);
|
|
590
|
-
const noChildren = children === void 0;
|
|
591
|
-
const input = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(SwitchInput_default, { ...props, disabled, className: noChildren ? className : void 0, id: htmlId, onChange, ref, role: "switch", type: "checkbox" });
|
|
592
|
-
if (noChildren) {
|
|
593
|
-
return input;
|
|
594
|
-
}
|
|
595
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(SwitchWithLabel, { className, disabled, id: htmlId, input, children });
|
|
596
|
-
});
|
|
597
|
-
var Switch_default = (0, import_react13.memo)(Switch);
|
|
598
|
-
|
|
599
|
-
// src/components/TextField/index.tsx
|
|
600
|
-
var import_visually_hidden = require("@react-aria/visually-hidden");
|
|
601
|
-
var import_react16 = require("react");
|
|
602
|
-
var React8 = __toESM(require("react"));
|
|
603
|
-
|
|
604
|
-
// src/components/FieldLabel/index.tsx
|
|
605
|
-
var React7 = __toESM(require("react"));
|
|
606
|
-
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
607
|
-
var FieldLabel = React7.forwardRef(function FieldLabel2({
|
|
608
|
-
style,
|
|
609
|
-
className,
|
|
610
|
-
label,
|
|
611
|
-
required = false,
|
|
612
|
-
requiredText,
|
|
613
|
-
subLabel,
|
|
614
|
-
...labelProps
|
|
615
|
-
}, ref) {
|
|
616
|
-
const classNames = useClassNames("charcoal-field-label-root", className);
|
|
617
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { style, className: classNames, children: [
|
|
618
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("label", { ref, className: "charcoal-field-label", ...labelProps, children: label }),
|
|
619
|
-
required && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "charcoal-field-label-required-text", children: requiredText }),
|
|
620
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "charcoal-field-label-sub-label", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: subLabel }) })
|
|
621
|
-
] });
|
|
622
|
-
});
|
|
623
|
-
var FieldLabel_default = FieldLabel;
|
|
624
|
-
|
|
625
|
-
// src/_lib/index.ts
|
|
626
|
-
function mergeRefs(...refs) {
|
|
627
|
-
return (value) => {
|
|
628
|
-
for (const ref of refs) {
|
|
629
|
-
if (typeof ref === "function") {
|
|
630
|
-
ref(value);
|
|
631
|
-
} else if (ref !== null) {
|
|
632
|
-
;
|
|
633
|
-
ref.current = value;
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
};
|
|
637
|
-
}
|
|
638
|
-
function countCodePointsInString(string) {
|
|
639
|
-
return Array.from(string).length;
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
// src/components/TextField/useFocusWithClick.tsx
|
|
643
|
-
var import_react14 = require("react");
|
|
644
|
-
function useFocusWithClick(containerRef, inputRef) {
|
|
645
|
-
(0, import_react14.useEffect)(() => {
|
|
646
|
-
const el = containerRef.current;
|
|
647
|
-
if (el) {
|
|
648
|
-
const handleDown = (e) => {
|
|
649
|
-
if (e.target !== inputRef.current) {
|
|
650
|
-
inputRef.current?.focus();
|
|
651
|
-
}
|
|
652
|
-
};
|
|
653
|
-
el.addEventListener("click", handleDown);
|
|
654
|
-
return () => {
|
|
655
|
-
el.removeEventListener("click", handleDown);
|
|
656
|
-
};
|
|
657
|
-
}
|
|
658
|
-
});
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
// src/components/TextField/index.tsx
|
|
662
|
-
var import_utils2 = require("@react-aria/utils");
|
|
663
|
-
|
|
664
|
-
// src/_lib/createDivComponent.tsx
|
|
665
|
-
var import_react15 = require("react");
|
|
666
|
-
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
667
|
-
function createDivComponent(mainClassName) {
|
|
668
|
-
return (0, import_react15.forwardRef)(function DivComponent({
|
|
669
|
-
className,
|
|
670
|
-
...props
|
|
671
|
-
}, ref) {
|
|
672
|
-
const classNames = useClassNames(mainClassName, className);
|
|
673
|
-
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: classNames, ref, ...props });
|
|
674
|
-
});
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
// src/components/TextField/AssistiveText/index.tsx
|
|
678
|
-
var AssistiveText = createDivComponent("charcoal-text-field-assistive-text");
|
|
679
|
-
|
|
680
|
-
// src/components/TextField/index.tsx
|
|
681
|
-
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
682
|
-
var TextField = React8.forwardRef(function SingleLineTextFieldInner({
|
|
683
|
-
assistiveText,
|
|
684
|
-
className,
|
|
685
|
-
disabled = false,
|
|
686
|
-
label = "",
|
|
687
|
-
maxLength,
|
|
688
|
-
onChange,
|
|
689
|
-
prefix = null,
|
|
690
|
-
required,
|
|
691
|
-
requiredText,
|
|
692
|
-
showCount = false,
|
|
693
|
-
showLabel = false,
|
|
694
|
-
subLabel,
|
|
695
|
-
suffix = null,
|
|
696
|
-
type = "text",
|
|
697
|
-
invalid,
|
|
698
|
-
value,
|
|
699
|
-
getCount = countCodePointsInString,
|
|
700
|
-
...props
|
|
701
|
-
}, forwardRef24) {
|
|
702
|
-
const inputRef = (0, import_react16.useRef)(null);
|
|
703
|
-
const {
|
|
704
|
-
visuallyHiddenProps
|
|
705
|
-
} = (0, import_visually_hidden.useVisuallyHidden)();
|
|
706
|
-
const [count, setCount] = (0, import_react16.useState)(getCount(value ?? ""));
|
|
707
|
-
const handleChange = (0, import_react16.useCallback)((e) => {
|
|
708
|
-
const value2 = e.target.value;
|
|
709
|
-
const count2 = getCount(value2);
|
|
710
|
-
if (maxLength !== void 0 && count2 > maxLength) {
|
|
711
|
-
return;
|
|
712
|
-
}
|
|
713
|
-
setCount(count2);
|
|
714
|
-
onChange?.(value2);
|
|
715
|
-
}, [getCount, maxLength, onChange]);
|
|
716
|
-
(0, import_react16.useEffect)(() => {
|
|
717
|
-
setCount(getCount(value ?? ""));
|
|
718
|
-
}, [getCount, value]);
|
|
719
|
-
const containerRef = (0, import_react16.useRef)(null);
|
|
720
|
-
useFocusWithClick(containerRef, inputRef);
|
|
721
|
-
const inputId = (0, import_utils2.useId)(props.id);
|
|
722
|
-
const describedbyId = (0, import_utils2.useId)();
|
|
723
|
-
const labelledbyId = (0, import_utils2.useId)();
|
|
724
|
-
const showAssistiveText = assistiveText != null && assistiveText.length !== 0;
|
|
725
|
-
const classNames = useClassNames("charcoal-text-field-root", className);
|
|
726
|
-
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: classNames, "aria-disabled": disabled, children: [
|
|
727
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(FieldLabel_default, { htmlFor: inputId, id: labelledbyId, label, required, requiredText, subLabel, ...!showLabel ? visuallyHiddenProps : {} }),
|
|
728
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "charcoal-text-field-container", "aria-disabled": disabled === true ? true : void 0, "data-invalid": invalid === true, ref: containerRef, children: [
|
|
729
|
-
prefix && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "charcoal-text-field-prefix", children: prefix }),
|
|
730
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("input", { className: "charcoal-text-field-input", "aria-describedby": showAssistiveText ? describedbyId : void 0, "aria-invalid": invalid, "aria-labelledby": labelledbyId, id: inputId, "data-invalid": invalid === true, maxLength, onChange: handleChange, disabled, ref: (0, import_utils2.mergeRefs)(forwardRef24, inputRef), type, value, ...props }),
|
|
731
|
-
(suffix || showCount) && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "charcoal-text-field-suffix", children: [
|
|
732
|
-
suffix,
|
|
733
|
-
showCount && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "charcoal-text-field-line-counter", children: maxLength !== void 0 ? `${count}/${maxLength}` : count })
|
|
734
|
-
] })
|
|
735
|
-
] }),
|
|
736
|
-
showAssistiveText && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(AssistiveText, { "data-invalid": invalid === true, id: describedbyId, children: assistiveText })
|
|
737
|
-
] });
|
|
738
|
-
});
|
|
739
|
-
var TextField_default = TextField;
|
|
740
|
-
|
|
741
|
-
// src/components/TextArea/index.tsx
|
|
742
|
-
var import_visually_hidden2 = require("@react-aria/visually-hidden");
|
|
743
|
-
var import_react17 = require("react");
|
|
744
|
-
var import_utils3 = require("@react-aria/utils");
|
|
745
|
-
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
746
|
-
var TextArea = (0, import_react17.forwardRef)(function TextAreaInner({
|
|
747
|
-
onChange,
|
|
748
|
-
className,
|
|
749
|
-
value,
|
|
750
|
-
showCount = false,
|
|
751
|
-
showLabel = false,
|
|
752
|
-
label = "",
|
|
753
|
-
requiredText,
|
|
754
|
-
subLabel,
|
|
755
|
-
disabled = false,
|
|
756
|
-
required,
|
|
757
|
-
assistiveText,
|
|
758
|
-
maxLength,
|
|
759
|
-
autoHeight = false,
|
|
760
|
-
rows: initialRows = 4,
|
|
761
|
-
invalid,
|
|
762
|
-
getCount = countCodePointsInString,
|
|
763
|
-
...props
|
|
764
|
-
}, forwardRef24) {
|
|
765
|
-
const {
|
|
766
|
-
visuallyHiddenProps
|
|
767
|
-
} = (0, import_visually_hidden2.useVisuallyHidden)();
|
|
768
|
-
const textareaRef = (0, import_react17.useRef)(null);
|
|
769
|
-
const [count, setCount] = (0, import_react17.useState)(getCount(value ?? ""));
|
|
770
|
-
const [rows, setRows] = (0, import_react17.useState)(initialRows);
|
|
771
|
-
const syncHeight = (0, import_react17.useCallback)((textarea) => {
|
|
772
|
-
const rows2 = (`${textarea.value}
|
|
773
|
-
`.match(/\n/gu)?.length ?? 0) || 1;
|
|
774
|
-
setRows(initialRows <= rows2 ? rows2 : initialRows);
|
|
775
|
-
}, [initialRows]);
|
|
776
|
-
const nonControlled = value === void 0;
|
|
777
|
-
const handleChange = (0, import_react17.useCallback)((e) => {
|
|
778
|
-
const value2 = e.target.value;
|
|
779
|
-
const count2 = getCount(value2);
|
|
780
|
-
if (maxLength !== void 0 && count2 > maxLength) {
|
|
781
|
-
return;
|
|
782
|
-
}
|
|
783
|
-
if (nonControlled) {
|
|
784
|
-
setCount(count2);
|
|
785
|
-
}
|
|
786
|
-
if (autoHeight && textareaRef.current !== null) {
|
|
787
|
-
syncHeight(textareaRef.current);
|
|
788
|
-
}
|
|
789
|
-
onChange?.(value2);
|
|
790
|
-
}, [autoHeight, getCount, maxLength, nonControlled, onChange, syncHeight]);
|
|
791
|
-
(0, import_react17.useEffect)(() => {
|
|
792
|
-
setCount(getCount(value ?? ""));
|
|
793
|
-
}, [getCount, value]);
|
|
794
|
-
(0, import_react17.useEffect)(() => {
|
|
795
|
-
if (autoHeight && textareaRef.current !== null) {
|
|
796
|
-
syncHeight(textareaRef.current);
|
|
797
|
-
}
|
|
798
|
-
}, [autoHeight, syncHeight]);
|
|
799
|
-
const containerRef = (0, import_react17.useRef)(null);
|
|
800
|
-
useFocusWithClick(containerRef, textareaRef);
|
|
801
|
-
const textAreaId = (0, import_utils3.useId)(props.id);
|
|
802
|
-
const describedbyId = (0, import_utils3.useId)();
|
|
803
|
-
const labelledbyId = (0, import_utils3.useId)();
|
|
804
|
-
const classNames = useClassNames("charcoal-text-area-root", className);
|
|
805
|
-
const showAssistiveText = assistiveText != null && assistiveText.length !== 0;
|
|
806
|
-
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: classNames, "aria-disabled": disabled, children: [
|
|
807
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(FieldLabel_default, { htmlFor: textAreaId, id: labelledbyId, label, required, requiredText, subLabel, ...!showLabel ? visuallyHiddenProps : {} }),
|
|
808
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "charcoal-text-area-container", "aria-disabled": disabled === true ? "true" : void 0, "aria-invalid": invalid === true, ref: containerRef, style: {
|
|
809
|
-
"--charcoal-text-area-rows": `${showCount ? rows + 1 : rows}`
|
|
810
|
-
}, children: [
|
|
811
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("textarea", { className: "charcoal-text-area-textarea", "aria-describedby": showAssistiveText ? describedbyId : void 0, "aria-invalid": invalid, "aria-labelledby": labelledbyId, id: textAreaId, maxLength, "data-no-bottom-padding": showCount, onChange: handleChange, ref: mergeRefs(forwardRef24, textareaRef), rows, value, disabled, ...props }),
|
|
812
|
-
showCount && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "charcoal-text-area-counter", children: maxLength !== void 0 ? `${count}/${maxLength}` : count })
|
|
813
|
-
] }),
|
|
814
|
-
showAssistiveText && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(AssistiveText, { "data-invalid": invalid === true, id: describedbyId, children: assistiveText })
|
|
815
|
-
] });
|
|
816
|
-
});
|
|
817
|
-
var TextArea_default = TextArea;
|
|
818
|
-
|
|
819
|
-
// src/components/Modal/index.tsx
|
|
820
|
-
var import_react20 = require("react");
|
|
821
|
-
var React12 = __toESM(require("react"));
|
|
822
|
-
var import_overlays3 = require("@react-aria/overlays");
|
|
823
|
-
var import_react_spring = require("react-spring");
|
|
824
|
-
var import_utils4 = require("@react-aria/utils");
|
|
825
|
-
|
|
826
|
-
// src/components/Modal/Dialog/index.tsx
|
|
827
|
-
var import_react18 = require("react");
|
|
828
|
-
var import_dialog = require("@react-aria/dialog");
|
|
829
|
-
|
|
830
|
-
// src/_lib/useForwardedRef.tsx
|
|
831
|
-
var React9 = __toESM(require("react"));
|
|
832
|
-
function useForwardedRef(ref) {
|
|
833
|
-
const innerRef = React9.useRef(null);
|
|
834
|
-
React9.useEffect(() => {
|
|
835
|
-
if (!ref)
|
|
836
|
-
return;
|
|
837
|
-
if (typeof ref === "function") {
|
|
838
|
-
ref(innerRef.current);
|
|
839
|
-
} else {
|
|
840
|
-
ref.current = innerRef.current;
|
|
841
|
-
}
|
|
842
|
-
});
|
|
843
|
-
return innerRef;
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
// src/components/Modal/Dialog/index.tsx
|
|
847
|
-
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
848
|
-
var Dialog = (0, import_react18.forwardRef)(function Dialog2({
|
|
849
|
-
size,
|
|
850
|
-
bottomSheet,
|
|
851
|
-
className,
|
|
852
|
-
...props
|
|
853
|
-
}, forwardRef24) {
|
|
854
|
-
const ref = useForwardedRef(forwardRef24);
|
|
855
|
-
const {
|
|
856
|
-
dialogProps
|
|
857
|
-
} = (0, import_dialog.useDialog)({
|
|
858
|
-
role: "dialog"
|
|
859
|
-
}, ref);
|
|
860
|
-
const classNames = useClassNames("charcoal-modal-dialog", className);
|
|
861
|
-
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: classNames, role: dialogProps.role, "data-bottom-sheet": bottomSheet, tabIndex: dialogProps.tabIndex, "aria-labelledby": dialogProps["aria-labelledby"], onBlur: dialogProps.onBlur, "data-size": size, ref, ...props });
|
|
862
|
-
});
|
|
863
|
-
|
|
864
|
-
// src/components/Modal/ModalBackgroundContext.tsx
|
|
865
|
-
var React10 = __toESM(require("react"));
|
|
866
|
-
var ModalBackgroundContext = React10.createContext(null);
|
|
867
|
-
|
|
868
|
-
// src/components/Modal/useCustomModalOverlay.tsx
|
|
869
|
-
var React11 = __toESM(require("react"));
|
|
870
|
-
var import_overlays2 = require("@react-aria/overlays");
|
|
871
|
-
|
|
872
|
-
// src/components/DropdownSelector/Popover/usePreventScroll.tsx
|
|
873
|
-
var import_react19 = require("react");
|
|
874
|
-
function usePreventScroll(element, isOpen, useClip = false) {
|
|
875
|
-
(0, import_react19.useEffect)(() => {
|
|
876
|
-
if (isOpen && element) {
|
|
877
|
-
const defaultPaddingRight = element.style.paddingRight;
|
|
878
|
-
const defaultOverflow = element.style.overflow;
|
|
879
|
-
element.style.paddingRight = `${window.innerWidth - element.clientWidth}px`;
|
|
880
|
-
element.style.overflow = useClip ? "clip" : "hidden";
|
|
881
|
-
return () => {
|
|
882
|
-
element.style.paddingRight = defaultPaddingRight;
|
|
883
|
-
element.style.overflow = defaultOverflow;
|
|
884
|
-
};
|
|
885
|
-
}
|
|
886
|
-
}, [element, isOpen, useClip]);
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
// src/components/Modal/useCustomModalOverlay.tsx
|
|
890
|
-
function useCharcoalModalOverlay(props, state, ref) {
|
|
891
|
-
const {
|
|
892
|
-
overlayProps,
|
|
893
|
-
underlayProps
|
|
894
|
-
} = (0, import_overlays2.useOverlay)({
|
|
895
|
-
...props,
|
|
896
|
-
isOpen: state.isOpen,
|
|
897
|
-
onClose: state.onClose,
|
|
898
|
-
shouldCloseOnInteractOutside: () => false
|
|
899
|
-
}, ref);
|
|
900
|
-
usePreventScroll(typeof document !== "undefined" ? document.body : null, state.isOpen, props.overflowClip);
|
|
901
|
-
(0, import_overlays2.useOverlayFocusContain)();
|
|
902
|
-
React11.useEffect(() => {
|
|
903
|
-
if (state.isOpen && ref.current) {
|
|
904
|
-
return (0, import_overlays2.ariaHideOutside)([ref.current]);
|
|
905
|
-
}
|
|
906
|
-
}, [state.isOpen, ref]);
|
|
907
|
-
return {
|
|
908
|
-
modalProps: overlayProps,
|
|
909
|
-
underlayProps
|
|
910
|
-
};
|
|
911
|
-
}
|
|
912
|
-
function isWindowDefined() {
|
|
913
|
-
return typeof window !== "undefined";
|
|
914
|
-
}
|
|
915
|
-
function useWindowWidth() {
|
|
916
|
-
const [width, setWidth] = React11.useState(isWindowDefined() ? window.innerWidth : null);
|
|
917
|
-
React11.useEffect(() => {
|
|
918
|
-
const handleResize = () => {
|
|
919
|
-
setWidth(window.innerWidth);
|
|
920
|
-
};
|
|
921
|
-
window.addEventListener("resize", handleResize);
|
|
922
|
-
return () => {
|
|
923
|
-
window.removeEventListener("resize", handleResize);
|
|
924
|
-
};
|
|
925
|
-
});
|
|
926
|
-
return width;
|
|
927
|
-
}
|
|
928
|
-
|
|
929
|
-
// src/components/Modal/index.tsx
|
|
930
|
-
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
931
|
-
var DEFAULT_Z_INDEX = 10;
|
|
932
|
-
var Modal = (0, import_react20.forwardRef)(function ModalInner({
|
|
933
|
-
children,
|
|
934
|
-
zIndex = DEFAULT_Z_INDEX,
|
|
935
|
-
portalContainer,
|
|
936
|
-
...props
|
|
937
|
-
}, external) {
|
|
938
|
-
const {
|
|
939
|
-
title,
|
|
940
|
-
size = "M",
|
|
941
|
-
bottomSheet = false,
|
|
942
|
-
isDismissable,
|
|
943
|
-
onClose,
|
|
944
|
-
className,
|
|
945
|
-
isOpen = false,
|
|
946
|
-
closeButtonAriaLabel = "Close"
|
|
947
|
-
} = props;
|
|
948
|
-
const ref = (0, import_utils4.useObjectRef)(external);
|
|
949
|
-
const {
|
|
950
|
-
modalProps,
|
|
951
|
-
underlayProps
|
|
952
|
-
} = useCharcoalModalOverlay({
|
|
953
|
-
...props,
|
|
954
|
-
isKeyboardDismissDisabled: isDismissable === void 0 || isDismissable === false
|
|
955
|
-
}, {
|
|
956
|
-
onClose,
|
|
957
|
-
isOpen
|
|
958
|
-
}, ref);
|
|
959
|
-
const isMobile = (useWindowWidth() ?? Infinity) < 744;
|
|
960
|
-
const transitionEnabled = isMobile && bottomSheet !== false;
|
|
961
|
-
const showDismiss = !isMobile || bottomSheet !== true;
|
|
962
|
-
const transition = (0, import_react_spring.useTransition)(isOpen, {
|
|
963
|
-
from: {
|
|
964
|
-
transform: "translateY(100%)",
|
|
965
|
-
backgroundColor: "rgba(0, 0, 0, 0)",
|
|
966
|
-
overflow: "hidden"
|
|
967
|
-
},
|
|
968
|
-
enter: {
|
|
969
|
-
transform: "translateY(0%)",
|
|
970
|
-
backgroundColor: "rgba(0, 0, 0, 0.4)"
|
|
971
|
-
},
|
|
972
|
-
update: {
|
|
973
|
-
overflow: "auto"
|
|
974
|
-
},
|
|
975
|
-
leave: {
|
|
976
|
-
transform: "translateY(100%)",
|
|
977
|
-
backgroundColor: "rgba(0, 0, 0, 0)",
|
|
978
|
-
overflow: "hidden"
|
|
979
|
-
},
|
|
980
|
-
config: transitionEnabled ? {
|
|
981
|
-
duration: 400,
|
|
982
|
-
easing: import_react_spring.easings.easeOutQuart
|
|
983
|
-
} : {
|
|
984
|
-
duration: 0
|
|
985
|
-
}
|
|
986
|
-
});
|
|
987
|
-
const bgRef = React12.useRef(null);
|
|
988
|
-
const handleClick = React12.useCallback((e) => {
|
|
989
|
-
if (e.currentTarget === e.target) {
|
|
990
|
-
onClose();
|
|
991
|
-
}
|
|
992
|
-
}, [onClose]);
|
|
993
|
-
return transition(({
|
|
994
|
-
backgroundColor,
|
|
995
|
-
overflow,
|
|
996
|
-
transform
|
|
997
|
-
}, item) => item && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_overlays3.Overlay, { portalContainer, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_spring.animated.div, { className: "charcoal-modal-background", ref: bgRef, ...underlayProps, style: transitionEnabled ? {
|
|
998
|
-
backgroundColor,
|
|
999
|
-
overflow,
|
|
1000
|
-
zIndex
|
|
1001
|
-
} : {
|
|
1002
|
-
zIndex
|
|
1003
|
-
}, "data-bottom-sheet": bottomSheet, onClick: handleClick, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ModalBackgroundContext.Provider, { value: bgRef.current, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AnimatedDialog, { ref, ...modalProps, style: transitionEnabled ? {
|
|
1004
|
-
transform
|
|
1005
|
-
} : {}, size, bottomSheet, className, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(ModalContext.Provider, { value: {
|
|
1006
|
-
titleProps: {},
|
|
1007
|
-
title,
|
|
1008
|
-
close: onClose,
|
|
1009
|
-
showDismiss,
|
|
1010
|
-
bottomSheet
|
|
1011
|
-
}, children: [
|
|
1012
|
-
children,
|
|
1013
|
-
isDismissable === true && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ModalCloseButton, { "aria-label": closeButtonAriaLabel, onClick: onClose })
|
|
1014
|
-
] }) }) }) }) }));
|
|
1015
|
-
});
|
|
1016
|
-
var AnimatedDialog = (0, import_react_spring.animated)(Dialog);
|
|
1017
|
-
var Modal_default = (0, import_react20.memo)(Modal);
|
|
1018
|
-
var ModalContext = React12.createContext({
|
|
1019
|
-
titleProps: {},
|
|
1020
|
-
title: "",
|
|
1021
|
-
close: void 0,
|
|
1022
|
-
showDismiss: true,
|
|
1023
|
-
bottomSheet: false
|
|
1024
|
-
});
|
|
1025
|
-
function ModalCloseButton(props) {
|
|
1026
|
-
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(IconButton_default, { className: "charcoal-modal-close-button", size: "S", icon: "24/Close", type: "button", ...props });
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
|
-
// src/components/Modal/ModalPlumbing.tsx
|
|
1030
|
-
var import_react21 = require("react");
|
|
1031
|
-
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1032
|
-
function ModalHeader() {
|
|
1033
|
-
const modalCtx = (0, import_react21.useContext)(ModalContext);
|
|
1034
|
-
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "charcoal-modal-header-root", "data-bottom-sheet": modalCtx.bottomSheet, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "charcoal-modal-header-title", children: modalCtx.title }) });
|
|
1035
|
-
}
|
|
1036
|
-
var ModalAlign = createDivComponent("charcoal-modal-align");
|
|
1037
|
-
var ModalBody = createDivComponent("charcoal-modal-body");
|
|
1038
|
-
var ModalButtons = createDivComponent("charcoal-modal-buttons");
|
|
1039
|
-
|
|
1040
|
-
// src/components/LoadingSpinner/index.tsx
|
|
1041
|
-
var import_react22 = require("react");
|
|
1042
|
-
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
1043
|
-
var LoadingSpinner = (0, import_react22.forwardRef)(function LoadingSpinnerInner({
|
|
1044
|
-
size = 48,
|
|
1045
|
-
padding = 16,
|
|
1046
|
-
transparent = false,
|
|
1047
|
-
...props
|
|
1048
|
-
}, ref) {
|
|
1049
|
-
const classNames = useClassNames("charcoal-loading-spinner", props.className);
|
|
1050
|
-
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { role: "progressbar", style: {
|
|
1051
|
-
"--charcoal-loading-spinner-size": `${size}px`,
|
|
1052
|
-
"--charcoal-loading-spinner-padding": `${padding}px`
|
|
1053
|
-
}, "data-transparent": transparent, className: classNames, ref, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(LoadingSpinnerIcon, {}) });
|
|
1054
|
-
});
|
|
1055
|
-
var LoadingSpinner_default = (0, import_react22.memo)(LoadingSpinner);
|
|
1056
|
-
var LoadingSpinnerIcon = (0, import_react22.forwardRef)(function LoadingSpinnerIcon2({
|
|
1057
|
-
once = false
|
|
1058
|
-
}, ref) {
|
|
1059
|
-
const iconRef = (0, import_react22.useRef)(null);
|
|
1060
|
-
(0, import_react22.useImperativeHandle)(ref, () => ({
|
|
1061
|
-
restart: () => {
|
|
1062
|
-
if (!iconRef.current) {
|
|
1063
|
-
return;
|
|
1064
|
-
}
|
|
1065
|
-
iconRef.current.dataset.resetAnimation = "true";
|
|
1066
|
-
void iconRef.current.offsetWidth;
|
|
1067
|
-
delete iconRef.current.dataset.resetAnimation;
|
|
1068
|
-
}
|
|
1069
|
-
}));
|
|
1070
|
-
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { role: "presentation", ref: iconRef, "data-once": once, className: "charcoal-loading-spinner-icon" });
|
|
1071
|
-
});
|
|
1072
|
-
|
|
1073
|
-
// src/components/DropdownSelector/index.tsx
|
|
1074
|
-
var import_react27 = require("react");
|
|
1075
|
-
|
|
1076
|
-
// src/components/DropdownSelector/DropdownPopover.tsx
|
|
1077
|
-
var import_react24 = require("react");
|
|
1078
|
-
|
|
1079
|
-
// src/components/DropdownSelector/Popover/index.tsx
|
|
1080
|
-
var import_react23 = require("react");
|
|
1081
|
-
var import_overlays4 = require("@react-aria/overlays");
|
|
1082
|
-
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
1083
|
-
var _empty = () => null;
|
|
1084
|
-
function Popover(props) {
|
|
1085
|
-
const defaultPopoverRef = (0, import_react23.useRef)(null);
|
|
1086
|
-
const finalPopoverRef = props.popoverRef === void 0 ? defaultPopoverRef : props.popoverRef;
|
|
1087
|
-
const {
|
|
1088
|
-
popoverProps,
|
|
1089
|
-
underlayProps
|
|
1090
|
-
} = (0, import_overlays4.usePopover)({
|
|
1091
|
-
triggerRef: props.triggerRef,
|
|
1092
|
-
popoverRef: finalPopoverRef,
|
|
1093
|
-
containerPadding: 16
|
|
1094
|
-
}, {
|
|
1095
|
-
close: props.onClose,
|
|
1096
|
-
isOpen: props.isOpen,
|
|
1097
|
-
// never used
|
|
1098
|
-
open: _empty,
|
|
1099
|
-
setOpen: _empty,
|
|
1100
|
-
toggle: _empty
|
|
1101
|
-
});
|
|
1102
|
-
const modalBackground = (0, import_react23.useContext)(ModalBackgroundContext);
|
|
1103
|
-
usePreventScroll(modalBackground, props.isOpen);
|
|
1104
|
-
if (!props.isOpen)
|
|
1105
|
-
return null;
|
|
1106
|
-
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_overlays4.Overlay, { portalContainer: document.body, children: [
|
|
1107
|
-
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { ...underlayProps, style: {
|
|
1108
|
-
position: "fixed",
|
|
1109
|
-
zIndex: typeof popoverProps.style?.zIndex === "number" ? popoverProps.style.zIndex - 1 : 99999,
|
|
1110
|
-
inset: 0
|
|
1111
|
-
} }),
|
|
1112
|
-
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { ...popoverProps, ref: finalPopoverRef, className: "charcoal-popover", children: [
|
|
1113
|
-
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_overlays4.DismissButton, { onDismiss: () => props.onClose() }),
|
|
1114
|
-
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { tabIndex: 0, onFocus: props.onClose }),
|
|
1115
|
-
props.children,
|
|
1116
|
-
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { tabIndex: 0, onFocus: props.onClose }),
|
|
1117
|
-
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_overlays4.DismissButton, { onDismiss: () => props.onClose() })
|
|
1118
|
-
] })
|
|
1119
|
-
] });
|
|
1120
|
-
}
|
|
1121
|
-
|
|
1122
|
-
// src/components/DropdownSelector/DropdownPopover.tsx
|
|
1123
|
-
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
1124
|
-
function DropdownPopover({
|
|
1125
|
-
children,
|
|
1126
|
-
...props
|
|
1127
|
-
}) {
|
|
1128
|
-
const ref = (0, import_react24.useRef)(null);
|
|
1129
|
-
(0, import_react24.useEffect)(() => {
|
|
1130
|
-
if (props.isOpen && ref.current && props.triggerRef.current) {
|
|
1131
|
-
ref.current.style.width = `${props.triggerRef.current.clientWidth}px`;
|
|
1132
|
-
}
|
|
1133
|
-
}, [props.triggerRef, props.isOpen]);
|
|
1134
|
-
(0, import_react24.useEffect)(() => {
|
|
1135
|
-
if (props.isOpen) {
|
|
1136
|
-
if (props.value !== void 0 && props.value !== "") {
|
|
1137
|
-
const windowScrollY = window.scrollY;
|
|
1138
|
-
const windowScrollX = window.scrollX;
|
|
1139
|
-
const selectedElement = document.querySelector(`[data-key="${props.value.toString()}"]`);
|
|
1140
|
-
selectedElement?.focus();
|
|
1141
|
-
window.scrollTo(windowScrollX, windowScrollY);
|
|
1142
|
-
} else {
|
|
1143
|
-
const el = ref.current?.querySelector("[role='option']");
|
|
1144
|
-
if (el instanceof HTMLElement) {
|
|
1145
|
-
el.focus();
|
|
1146
|
-
}
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
}, [props.value, props.isOpen]);
|
|
1150
|
-
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Popover, { isOpen: props.isOpen, onClose: props.onClose, popoverRef: ref, triggerRef: props.triggerRef, children });
|
|
1151
|
-
}
|
|
1152
|
-
|
|
1153
|
-
// src/components/DropdownSelector/utils/findPreviewRecursive.tsx
|
|
1154
|
-
var React13 = __toESM(require("react"));
|
|
1155
|
-
function findPreviewRecursive(children, value) {
|
|
1156
|
-
const childArray = React13.Children.toArray(children);
|
|
1157
|
-
for (let i = 0; i < childArray.length; i++) {
|
|
1158
|
-
const child = childArray[i];
|
|
1159
|
-
if (React13.isValidElement(child)) {
|
|
1160
|
-
if ("value" in child.props) {
|
|
1161
|
-
const childValue = child.props.value;
|
|
1162
|
-
if (childValue === value && "children" in child.props) {
|
|
1163
|
-
const children2 = child.props.children;
|
|
1164
|
-
return children2;
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1167
|
-
if ("children" in child.props) {
|
|
1168
|
-
const children2 = findPreviewRecursive(child.props.children, value);
|
|
1169
|
-
if (children2 !== void 0) {
|
|
1170
|
-
return children2;
|
|
1171
|
-
}
|
|
1172
|
-
}
|
|
1173
|
-
}
|
|
1174
|
-
}
|
|
1175
|
-
}
|
|
1176
|
-
|
|
1177
|
-
// src/components/DropdownSelector/MenuList/index.tsx
|
|
1178
|
-
var import_react26 = require("react");
|
|
1179
|
-
|
|
1180
|
-
// src/components/DropdownSelector/MenuList/MenuListContext.ts
|
|
1181
|
-
var import_react25 = require("react");
|
|
1182
|
-
var MenuListContext = (0, import_react25.createContext)({
|
|
1183
|
-
root: void 0,
|
|
1184
|
-
value: "",
|
|
1185
|
-
propsArray: [],
|
|
1186
|
-
setValue: (_v) => {
|
|
1187
|
-
}
|
|
1188
|
-
});
|
|
1189
|
-
|
|
1190
|
-
// src/components/DropdownSelector/MenuList/internals/getValuesRecursive.tsx
|
|
1191
|
-
var React14 = __toESM(require("react"));
|
|
1192
|
-
function getValuesRecursive(children) {
|
|
1193
|
-
const childArray = React14.Children.toArray(children);
|
|
1194
|
-
const propsArray = [];
|
|
1195
|
-
for (let i = 0; i < childArray.length; i++) {
|
|
1196
|
-
const child = childArray[i];
|
|
1197
|
-
if (React14.isValidElement(child)) {
|
|
1198
|
-
const props = child.props;
|
|
1199
|
-
if ("value" in props && typeof props.value === "string") {
|
|
1200
|
-
propsArray.push({
|
|
1201
|
-
disabled: props.disabled,
|
|
1202
|
-
value: props.value
|
|
1203
|
-
});
|
|
1204
|
-
}
|
|
1205
|
-
if ("children" in props && props.children) {
|
|
1206
|
-
propsArray.push(...getValuesRecursive(props.children));
|
|
1207
|
-
}
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
return propsArray;
|
|
1211
|
-
}
|
|
1212
|
-
|
|
1213
|
-
// src/components/DropdownSelector/MenuList/index.tsx
|
|
1214
|
-
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
1215
|
-
function MenuList(props) {
|
|
1216
|
-
const root = (0, import_react26.useRef)(null);
|
|
1217
|
-
const propsArray = (0, import_react26.useMemo)(() => getValuesRecursive(props.children), [props.children]);
|
|
1218
|
-
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("ul", { className: "charcoal-menu-list", ref: root, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(MenuListContext.Provider, { value: {
|
|
1219
|
-
value: props.value ?? "",
|
|
1220
|
-
root,
|
|
1221
|
-
propsArray,
|
|
1222
|
-
setValue: (v) => {
|
|
1223
|
-
props.onChange?.(v);
|
|
1224
|
-
}
|
|
1225
|
-
}, children: props.children }) });
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
|
-
// src/components/DropdownSelector/index.tsx
|
|
1229
|
-
var import_visually_hidden3 = require("@react-aria/visually-hidden");
|
|
1230
|
-
var import_utils5 = require("@react-aria/utils");
|
|
1231
|
-
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
1232
|
-
function DropdownSelector({
|
|
1233
|
-
onChange,
|
|
1234
|
-
showLabel = false,
|
|
1235
|
-
...props
|
|
1236
|
-
}) {
|
|
1237
|
-
const triggerRef = (0, import_react27.useRef)(null);
|
|
1238
|
-
const [isOpen, setIsOpen] = (0, import_react27.useState)(false);
|
|
1239
|
-
const preview = findPreviewRecursive(props.children, props.value);
|
|
1240
|
-
const isPlaceholder = (0, import_react27.useMemo)(() => props.placeholder !== void 0 && preview === void 0, [preview, props.placeholder]);
|
|
1241
|
-
const propsArray = getValuesRecursive(props.children);
|
|
1242
|
-
const {
|
|
1243
|
-
visuallyHiddenProps
|
|
1244
|
-
} = (0, import_visually_hidden3.useVisuallyHidden)();
|
|
1245
|
-
const handleChange = (0, import_react27.useCallback)((e) => {
|
|
1246
|
-
onChange(e.target.value);
|
|
1247
|
-
}, [onChange]);
|
|
1248
|
-
const labelId = (0, import_utils5.useId)();
|
|
1249
|
-
const describedbyId = (0, import_utils5.useId)();
|
|
1250
|
-
const classNames = useClassNames("charcoal-dropdown-selector-root", props.className);
|
|
1251
|
-
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: classNames, "aria-disabled": props.disabled, children: [
|
|
1252
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(FieldLabel_default, { id: labelId, label: props.label, required: props.required, requiredText: props.requiredText, subLabel: props.subLabel, ...!showLabel ? visuallyHiddenProps : {} }),
|
|
1253
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { ...visuallyHiddenProps, "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("select", { name: props.name, value: props.value, onChange: handleChange, tabIndex: -1, children: propsArray.map((itemProps) => {
|
|
1254
|
-
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("option", { value: itemProps.value, disabled: itemProps.disabled, children: itemProps.value }, itemProps.value);
|
|
1255
|
-
}) }) }),
|
|
1256
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("button", { className: "charcoal-dropdown-selector-button", "aria-labelledby": labelId, "aria-invalid": props.invalid, "aria-describedby": props.assistiveText !== void 0 ? describedbyId : void 0, disabled: props.disabled, onClick: () => {
|
|
1257
|
-
if (props.disabled === true)
|
|
1258
|
-
return;
|
|
1259
|
-
setIsOpen(true);
|
|
1260
|
-
}, ref: triggerRef, type: "button", "data-active": isOpen, children: [
|
|
1261
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "charcoal-ui-dropdown-selector-text", "data-placeholder": isPlaceholder, children: isPlaceholder ? props.placeholder : preview }),
|
|
1262
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Icon_default, { className: "charcoal-ui-dropdown-selector-icon", name: "16/Menu" })
|
|
1263
|
-
] }),
|
|
1264
|
-
isOpen && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropdownPopover, { isOpen, onClose: () => setIsOpen(false), triggerRef, value: props.value, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(MenuList, { value: props.value, onChange: (v) => {
|
|
1265
|
-
onChange(v);
|
|
1266
|
-
setIsOpen(false);
|
|
1267
|
-
}, children: props.children }) }),
|
|
1268
|
-
props.assistiveText !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(AssistiveText, { "data-invalid": props.invalid === true, id: describedbyId, children: props.assistiveText })
|
|
1269
|
-
] });
|
|
1270
|
-
}
|
|
1271
|
-
|
|
1272
|
-
// src/components/DropdownSelector/MenuItem/index.tsx
|
|
1273
|
-
var import_react30 = require("react");
|
|
1274
|
-
|
|
1275
|
-
// src/components/DropdownSelector/ListItem/index.tsx
|
|
1276
|
-
var import_react28 = require("react");
|
|
1277
|
-
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
1278
|
-
var ListItem = (0, import_react28.forwardRef)(function ListItem2({
|
|
1279
|
-
as,
|
|
1280
|
-
className,
|
|
1281
|
-
...props
|
|
1282
|
-
}, ref) {
|
|
1283
|
-
const Component = (0, import_react28.useMemo)(() => as ?? "li", [as]);
|
|
1284
|
-
const classNames = useClassNames("charcoal-list-item", className);
|
|
1285
|
-
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Component, { className: classNames, ref, ...props });
|
|
1286
|
-
});
|
|
1287
|
-
var ListItem_default = ListItem;
|
|
1288
|
-
|
|
1289
|
-
// src/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.tsx
|
|
1290
|
-
var import_react29 = require("react");
|
|
1291
|
-
|
|
1292
|
-
// src/components/DropdownSelector/MenuItem/internals/handleFocusByKeyBoard.tsx
|
|
1293
|
-
function handleFocusByKeyBoard(element, parent) {
|
|
1294
|
-
const isScrollable = parent.scrollHeight > parent.clientHeight;
|
|
1295
|
-
if (isScrollable) {
|
|
1296
|
-
const rect = element.getBoundingClientRect();
|
|
1297
|
-
const parentRect = parent.getBoundingClientRect();
|
|
1298
|
-
if (rect.bottom > parentRect.bottom) {
|
|
1299
|
-
parent.scrollTo({
|
|
1300
|
-
top: parent.scrollTop + rect.bottom - parentRect.bottom
|
|
1301
|
-
});
|
|
1302
|
-
} else if (rect.top < parentRect.top) {
|
|
1303
|
-
parent.scrollTo({
|
|
1304
|
-
top: parent.scrollTop - (parentRect.top - rect.top)
|
|
1305
|
-
});
|
|
1306
|
-
}
|
|
1307
|
-
} else {
|
|
1308
|
-
scrollIfNeeded(element);
|
|
1309
|
-
}
|
|
1310
|
-
}
|
|
1311
|
-
function scrollIfNeeded(element) {
|
|
1312
|
-
const elementRect = element.getBoundingClientRect();
|
|
1313
|
-
const isVisible = elementRect.top >= 0 && elementRect.bottom <= (window.innerHeight || document.documentElement.clientHeight);
|
|
1314
|
-
if (!isVisible) {
|
|
1315
|
-
element.scrollIntoView({
|
|
1316
|
-
block: "nearest"
|
|
1317
|
-
});
|
|
1318
|
-
}
|
|
1319
|
-
}
|
|
1320
|
-
|
|
1321
|
-
// src/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.tsx
|
|
1322
|
-
function useMenuItemHandleKeyDown(value) {
|
|
1323
|
-
const {
|
|
1324
|
-
setValue,
|
|
1325
|
-
root,
|
|
1326
|
-
propsArray
|
|
1327
|
-
} = (0, import_react29.useContext)(MenuListContext);
|
|
1328
|
-
const setContextValue = (0, import_react29.useCallback)(() => {
|
|
1329
|
-
if (value !== void 0)
|
|
1330
|
-
setValue(value);
|
|
1331
|
-
}, [value, setValue]);
|
|
1332
|
-
const handleKeyDown = (0, import_react29.useCallback)((e) => {
|
|
1333
|
-
if (e.key === "Enter") {
|
|
1334
|
-
setContextValue();
|
|
1335
|
-
} else if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
|
1336
|
-
const isForward = e.key === "ArrowDown";
|
|
1337
|
-
e.preventDefault();
|
|
1338
|
-
if (!propsArray || value === void 0)
|
|
1339
|
-
return;
|
|
1340
|
-
const values = propsArray.map((props) => props.value).filter((v) => v);
|
|
1341
|
-
let index = values.indexOf(value);
|
|
1342
|
-
if (index === -1)
|
|
1343
|
-
return;
|
|
1344
|
-
for (let n = 0; n < values.length; n++) {
|
|
1345
|
-
const focusValue = isForward ? (
|
|
1346
|
-
// prev or last
|
|
1347
|
-
index + 1 >= values.length ? values[0] : values[index + 1]
|
|
1348
|
-
) : (
|
|
1349
|
-
// next or first
|
|
1350
|
-
index - 1 < 0 ? values[values.length - 1] : values[index - 1]
|
|
1351
|
-
);
|
|
1352
|
-
const next = root?.current?.querySelector(`[data-key='${focusValue}']`);
|
|
1353
|
-
if (next instanceof HTMLElement) {
|
|
1354
|
-
if (next.ariaDisabled === "true") {
|
|
1355
|
-
index += isForward ? 1 : -1;
|
|
1356
|
-
continue;
|
|
1357
|
-
}
|
|
1358
|
-
next.focus({
|
|
1359
|
-
preventScroll: true
|
|
1360
|
-
});
|
|
1361
|
-
if (root?.current?.parentElement) {
|
|
1362
|
-
handleFocusByKeyBoard(next, root.current.parentElement);
|
|
1363
|
-
}
|
|
1364
|
-
break;
|
|
1365
|
-
}
|
|
1366
|
-
}
|
|
1367
|
-
}
|
|
1368
|
-
}, [setContextValue, propsArray, value, root]);
|
|
1369
|
-
return [handleKeyDown, setContextValue];
|
|
1370
|
-
}
|
|
1371
|
-
|
|
1372
|
-
// src/components/DropdownSelector/MenuItem/index.tsx
|
|
1373
|
-
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
1374
|
-
var MenuItem = (0, import_react30.forwardRef)(function MenuItem2({
|
|
1375
|
-
className,
|
|
1376
|
-
value,
|
|
1377
|
-
disabled,
|
|
1378
|
-
...props
|
|
1379
|
-
}, ref) {
|
|
1380
|
-
const [handleKeyDown, setContextValue] = useMenuItemHandleKeyDown(value);
|
|
1381
|
-
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ListItem_default, { ...props, ref, "data-key": value, onKeyDown: handleKeyDown, onClick: disabled === true ? void 0 : setContextValue, tabIndex: -1, "aria-disabled": disabled, role: "option", children: props.children });
|
|
1382
|
-
});
|
|
1383
|
-
var MenuItem_default = MenuItem;
|
|
1384
|
-
|
|
1385
|
-
// src/components/DropdownSelector/DropdownMenuItem/index.tsx
|
|
1386
|
-
var import_react31 = require("react");
|
|
1387
|
-
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
1388
|
-
function DropdownMenuItem(props) {
|
|
1389
|
-
const {
|
|
1390
|
-
value: ctxValue
|
|
1391
|
-
} = (0, import_react31.useContext)(MenuListContext);
|
|
1392
|
-
const isSelected = props.value === ctxValue;
|
|
1393
|
-
const {
|
|
1394
|
-
children,
|
|
1395
|
-
...rest
|
|
1396
|
-
} = props;
|
|
1397
|
-
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(MenuItem_default, { ...rest, "aria-selected": isSelected, children: [
|
|
1398
|
-
isSelected && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Icon_default, { className: "charcoal-dropdown-selector-menu-item-icon", name: "16/Check" }),
|
|
1399
|
-
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "charcoal-dropdown-selector-menu-item", "data-selected": isSelected, children: props.children })
|
|
1400
|
-
] });
|
|
1401
|
-
}
|
|
1402
|
-
|
|
1403
|
-
// src/components/DropdownSelector/MenuItemGroup/index.tsx
|
|
1404
|
-
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
1405
|
-
function MenuItemGroup(props) {
|
|
1406
|
-
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("li", { className: "charcoal-menu-item-group", role: "presentation", children: [
|
|
1407
|
-
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { children: props.text }),
|
|
1408
|
-
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("ul", { role: "group", children: props.children })
|
|
1409
|
-
] });
|
|
1410
|
-
}
|
|
1411
|
-
|
|
1412
|
-
// src/components/SegmentedControl/index.tsx
|
|
1413
|
-
var import_react33 = require("react");
|
|
1414
|
-
var import_radio = require("@react-stately/radio");
|
|
1415
|
-
var import_radio2 = require("@react-aria/radio");
|
|
1416
|
-
|
|
1417
|
-
// src/components/SegmentedControl/RadioGroupContext.tsx
|
|
1418
|
-
var import_react32 = require("react");
|
|
1419
|
-
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
1420
|
-
var RadioContext = (0, import_react32.createContext)(null);
|
|
1421
|
-
var RadioProvider = ({
|
|
1422
|
-
value,
|
|
1423
|
-
children
|
|
1424
|
-
}) => {
|
|
1425
|
-
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(RadioContext.Provider, { value, children });
|
|
1426
|
-
};
|
|
1427
|
-
var useRadioContext = () => {
|
|
1428
|
-
const state = (0, import_react32.useContext)(RadioContext);
|
|
1429
|
-
if (state === null)
|
|
1430
|
-
throw new Error("`<RadioProvider>` is not likely mounted.");
|
|
1431
|
-
return state;
|
|
1432
|
-
};
|
|
1433
|
-
|
|
1434
|
-
// src/components/SegmentedControl/index.tsx
|
|
1435
|
-
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
1436
|
-
var SegmentedControl = (0, import_react33.forwardRef)(function SegmentedControlInner(props, ref) {
|
|
1437
|
-
const className = useClassNames("charcoal-segmented-control", props.className);
|
|
1438
|
-
const ariaRadioGroupProps = (0, import_react33.useMemo)(() => ({
|
|
1439
|
-
...props,
|
|
1440
|
-
isDisabled: props.disabled,
|
|
1441
|
-
isReadOnly: props.readonly,
|
|
1442
|
-
isRequired: props.required,
|
|
1443
|
-
"aria-label": props.name
|
|
1444
|
-
}), [props]);
|
|
1445
|
-
const state = (0, import_radio.useRadioGroupState)(ariaRadioGroupProps);
|
|
1446
|
-
const {
|
|
1447
|
-
radioGroupProps
|
|
1448
|
-
} = (0, import_radio2.useRadioGroup)(ariaRadioGroupProps, state);
|
|
1449
|
-
const segmentedControlItems = (0, import_react33.useMemo)(() => {
|
|
1450
|
-
return props.data.map((d) => typeof d === "string" ? {
|
|
1451
|
-
value: d,
|
|
1452
|
-
label: d
|
|
1453
|
-
} : d);
|
|
1454
|
-
}, [props.data]);
|
|
1455
|
-
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { ref, ...radioGroupProps, className, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(RadioProvider, { value: state, children: segmentedControlItems.map((item) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Segmented, { value: item.value, disabled: item.disabled, children: item.label }, item.value)) }) });
|
|
1456
|
-
});
|
|
1457
|
-
var SegmentedControl_default = (0, import_react33.memo)(SegmentedControl);
|
|
1458
|
-
var Segmented = (props) => {
|
|
1459
|
-
const state = useRadioContext();
|
|
1460
|
-
const ref = (0, import_react33.useRef)(null);
|
|
1461
|
-
const ariaRadioProps = (0, import_react33.useMemo)(() => ({
|
|
1462
|
-
value: props.value,
|
|
1463
|
-
isDisabled: props.disabled,
|
|
1464
|
-
children: props.children
|
|
1465
|
-
}), [props]);
|
|
1466
|
-
const {
|
|
1467
|
-
inputProps,
|
|
1468
|
-
isDisabled,
|
|
1469
|
-
isSelected
|
|
1470
|
-
} = (0, import_radio2.useRadio)(ariaRadioProps, state, ref);
|
|
1471
|
-
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("label", { className: "charcoal-segmented-control-radio__label", "aria-disabled": isDisabled || state.isReadOnly, "data-checked": isSelected, children: [
|
|
1472
|
-
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("input", { className: "charcoal-segmented-control-radio__input", ...inputProps, ref }),
|
|
1473
|
-
props.children
|
|
1474
|
-
] });
|
|
1475
|
-
};
|
|
1476
|
-
|
|
1477
|
-
// src/components/Checkbox/index.tsx
|
|
1478
|
-
var import_react36 = require("react");
|
|
1479
|
-
var import_utils6 = require("@react-aria/utils");
|
|
1480
|
-
|
|
1481
|
-
// src/components/Checkbox/CheckboxInput/index.tsx
|
|
1482
|
-
var import_react34 = require("react");
|
|
1483
|
-
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
1484
|
-
var CheckboxInput = (0, import_react34.forwardRef)(function CheckboxInput2({
|
|
1485
|
-
onChange,
|
|
1486
|
-
checked,
|
|
1487
|
-
invalid,
|
|
1488
|
-
className,
|
|
1489
|
-
rounded,
|
|
1490
|
-
...props
|
|
1491
|
-
}, ref) {
|
|
1492
|
-
const handleChange = (0, import_react34.useCallback)((e) => {
|
|
1493
|
-
const el = e.currentTarget;
|
|
1494
|
-
onChange?.(el.checked);
|
|
1495
|
-
}, [onChange]);
|
|
1496
|
-
const classNames = useClassNames("charcoal-checkbox-input", className);
|
|
1497
|
-
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("input", { className: classNames, ref, type: "checkbox", onChange: handleChange, "aria-invalid": invalid, checked, "data-rounded": rounded, ...props });
|
|
1498
|
-
});
|
|
1499
|
-
var CheckboxInput_default = (0, import_react34.memo)(CheckboxInput);
|
|
1500
|
-
|
|
1501
|
-
// src/components/Checkbox/CheckboxWithLabel.tsx
|
|
1502
|
-
var import_react35 = __toESM(require("react"));
|
|
1503
|
-
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
1504
|
-
var CheckboxWithLabel = import_react35.default.memo(function CheckboxWithLabel2({
|
|
1505
|
-
className,
|
|
1506
|
-
children,
|
|
1507
|
-
input,
|
|
1508
|
-
id,
|
|
1509
|
-
disabled
|
|
1510
|
-
}) {
|
|
1511
|
-
const classNames = useClassNames("charcoal-checkbox__label", className);
|
|
1512
|
-
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("label", { htmlFor: id, "aria-disabled": disabled, className: classNames, children: [
|
|
1513
|
-
input,
|
|
1514
|
-
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "charcoal-checkbox__label_div", children })
|
|
1515
|
-
] });
|
|
1516
|
-
});
|
|
1517
|
-
|
|
1518
|
-
// src/components/Checkbox/index.tsx
|
|
1519
|
-
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
1520
|
-
var Checkbox = (0, import_react36.forwardRef)(function Checkbox2({
|
|
1521
|
-
disabled,
|
|
1522
|
-
className,
|
|
1523
|
-
id,
|
|
1524
|
-
children,
|
|
1525
|
-
...props
|
|
1526
|
-
}, ref) {
|
|
1527
|
-
const htmlId = (0, import_utils6.useId)(id);
|
|
1528
|
-
const noChildren = children === void 0;
|
|
1529
|
-
const input = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(CheckboxInput_default, { ...props, className: noChildren ? className : void 0, disabled, id: htmlId, ref });
|
|
1530
|
-
if (noChildren) {
|
|
1531
|
-
return input;
|
|
1532
|
-
}
|
|
1533
|
-
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(CheckboxWithLabel, { className, disabled, id: htmlId, input, children });
|
|
1534
|
-
});
|
|
1535
|
-
var Checkbox_default = (0, import_react36.memo)(Checkbox);
|
|
1536
|
-
|
|
1537
|
-
// src/components/TagItem/index.tsx
|
|
1538
|
-
var import_react37 = require("react");
|
|
1539
|
-
var import_utils7 = require("@react-aria/utils");
|
|
1540
|
-
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
1541
|
-
var TagItem = (0, import_react37.forwardRef)(function TagItemInner({
|
|
1542
|
-
component,
|
|
1543
|
-
label,
|
|
1544
|
-
translatedLabel,
|
|
1545
|
-
bgColor = "#7ACCB1",
|
|
1546
|
-
bgImage,
|
|
1547
|
-
size = "M",
|
|
1548
|
-
status = "default",
|
|
1549
|
-
...props
|
|
1550
|
-
}, _ref) {
|
|
1551
|
-
const ref = (0, import_utils7.useObjectRef)(_ref);
|
|
1552
|
-
const hasTranslatedLabel = translatedLabel !== void 0 && translatedLabel.length > 0;
|
|
1553
|
-
const className = useClassNames("charcoal-tag-item", "charcoal-tag-item__bg", props.className);
|
|
1554
|
-
const bgVariant = bgImage !== void 0 && bgImage.length > 0 ? "image" : "color";
|
|
1555
|
-
const bg = bgVariant === "color" ? bgColor : `url(${bgImage ?? ""})`;
|
|
1556
|
-
const Component = (0, import_react37.useMemo)(() => component ?? "button", [component]);
|
|
1557
|
-
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(Component, { ...props, ref, className, "data-state": status, "data-bg-variant": bgVariant, "data-size": hasTranslatedLabel ? "M" : size, style: {
|
|
1558
|
-
"--charcoal-tag-item-bg": bg
|
|
1559
|
-
}, children: [
|
|
1560
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "charcoal-tag-item__label", "data-has-translate": hasTranslatedLabel, children: [
|
|
1561
|
-
hasTranslatedLabel && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: "charcoal-tag-item__label__translated", children: translatedLabel }),
|
|
1562
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: "charcoal-tag-item__label__text", "data-has-translate": hasTranslatedLabel, children: label })
|
|
1563
|
-
] }),
|
|
1564
|
-
status === "active" && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Icon_default, { name: "16/Remove" })
|
|
1565
|
-
] });
|
|
1566
|
-
});
|
|
1567
|
-
var TagItem_default = (0, import_react37.memo)(TagItem);
|
|
1568
|
-
|
|
1569
|
-
// src/components/HintText/index.tsx
|
|
1570
|
-
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
1571
|
-
function HintText({
|
|
1572
|
-
children,
|
|
1573
|
-
context = "section",
|
|
1574
|
-
className
|
|
1575
|
-
}) {
|
|
1576
|
-
const classNames = useClassNames("charcoal-hint-text", className);
|
|
1577
|
-
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: classNames, "data-context": context, children: [
|
|
1578
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "charcoal-hint-text-icon", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Icon_default, { name: "16/Info" }) }),
|
|
1579
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("p", { className: "charcoal-hint-text-message", children })
|
|
1580
|
-
] });
|
|
1581
|
-
}
|
|
1582
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
1583
|
-
0 && (module.exports = {
|
|
1584
|
-
Button,
|
|
1585
|
-
CharcoalProvider,
|
|
1586
|
-
Checkbox,
|
|
1587
|
-
Clickable,
|
|
1588
|
-
DropdownMenuItem,
|
|
1589
|
-
DropdownSelector,
|
|
1590
|
-
HintText,
|
|
1591
|
-
Icon,
|
|
1592
|
-
IconButton,
|
|
1593
|
-
LoadingSpinner,
|
|
1594
|
-
LoadingSpinnerIcon,
|
|
1595
|
-
MenuItemGroup,
|
|
1596
|
-
Modal,
|
|
1597
|
-
ModalAlign,
|
|
1598
|
-
ModalBody,
|
|
1599
|
-
ModalButtons,
|
|
1600
|
-
ModalCloseButton,
|
|
1601
|
-
ModalHeader,
|
|
1602
|
-
MultiSelect,
|
|
1603
|
-
MultiSelectGroup,
|
|
1604
|
-
OverlayProvider,
|
|
1605
|
-
Radio,
|
|
1606
|
-
RadioGroup,
|
|
1607
|
-
SSRProvider,
|
|
1608
|
-
SegmentedControl,
|
|
1609
|
-
SetThemeScript,
|
|
1610
|
-
Switch,
|
|
1611
|
-
TagItem,
|
|
1612
|
-
TextArea,
|
|
1613
|
-
TextField,
|
|
1614
|
-
getThemeSync,
|
|
1615
|
-
makeSetThemeScriptCode,
|
|
1616
|
-
prefersColorScheme,
|
|
1617
|
-
themeSelector,
|
|
1618
|
-
themeSetter,
|
|
1619
|
-
useLocalStorage,
|
|
1620
|
-
useMedia,
|
|
1621
|
-
useTheme,
|
|
1622
|
-
useThemeSetter
|
|
1623
|
-
});
|
|
1624
|
-
//# sourceMappingURL=index.cjs.js.map
|