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