@charcoal-ui/react 4.0.0-beta.7 → 4.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_lib/compat.d.ts +0 -12
- package/dist/_lib/compat.d.ts.map +1 -1
- package/dist/_lib/createDivComponent.d.ts +2 -2
- package/dist/_lib/createDivComponent.d.ts.map +1 -1
- package/dist/components/Button/index.d.ts +2 -6
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Clickable/index.d.ts +4 -7
- package/dist/components/Clickable/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/Divider/index.d.ts +3 -0
- package/dist/components/DropdownSelector/Divider/index.d.ts.map +1 -0
- package/dist/components/DropdownSelector/DropdownMenuItem/index.d.ts +8 -0
- package/dist/components/DropdownSelector/DropdownMenuItem/index.d.ts.map +1 -0
- package/dist/components/DropdownSelector/DropdownPopover.d.ts.map +1 -1
- package/dist/components/DropdownSelector/ListItem/index.d.ts +5 -13
- package/dist/components/DropdownSelector/ListItem/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/MenuItem/index.d.ts +10 -3
- package/dist/components/DropdownSelector/MenuItem/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.d.ts +1 -1
- package/dist/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.d.ts.map +1 -1
- package/dist/components/DropdownSelector/MenuItemGroup/index.d.ts +1 -3
- package/dist/components/DropdownSelector/MenuItemGroup/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/MenuList/index.d.ts +1 -4
- package/dist/components/DropdownSelector/MenuList/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/Popover/index.d.ts +1 -0
- package/dist/components/DropdownSelector/Popover/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/index.d.ts +3 -1
- package/dist/components/DropdownSelector/index.d.ts.map +1 -1
- package/dist/components/IconButton/index.d.ts +1 -2
- package/dist/components/IconButton/index.d.ts.map +1 -1
- package/dist/components/Modal/Dialog/index.d.ts +1 -1
- package/dist/components/Modal/Dialog/index.d.ts.map +1 -1
- package/dist/components/Modal/ModalPlumbing.d.ts +6 -6
- package/dist/components/Modal/ModalPlumbing.d.ts.map +1 -1
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Modal/useCustomModalOverlay.d.ts +1 -0
- package/dist/components/Modal/useCustomModalOverlay.d.ts.map +1 -1
- package/dist/components/Radio/RadioGroup/index.d.ts +20 -0
- package/dist/components/Radio/RadioGroup/index.d.ts.map +1 -0
- package/dist/components/Radio/RadioGroupContext.d.ts +11 -0
- package/dist/components/Radio/RadioGroupContext.d.ts.map +1 -0
- package/dist/components/Radio/RadioInput/index.d.ts +10 -0
- package/dist/components/Radio/RadioInput/index.d.ts.map +1 -0
- package/dist/components/Radio/index.d.ts +1 -12
- package/dist/components/Radio/index.d.ts.map +1 -1
- package/dist/components/TagItem/index.d.ts +2 -6
- package/dist/components/TagItem/index.d.ts.map +1 -1
- package/dist/components/TextArea/index.d.ts +1 -1
- package/dist/components/TextArea/index.d.ts.map +1 -1
- package/dist/components/TextField/AssistiveText/index.d.ts +2 -2
- package/dist/components/TextField/AssistiveText/index.d.ts.map +1 -1
- package/dist/components/TextField/index.d.ts +3 -3
- package/dist/components/TextField/index.d.ts.map +1 -1
- package/dist/core/CharcoalProvider.d.ts +4 -11
- package/dist/core/CharcoalProvider.d.ts.map +1 -1
- package/dist/index.cjs.js +356 -399
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.css +176 -27
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +322 -363
- package/dist/index.esm.js.map +1 -1
- package/dist/layered.css +1214 -0
- package/dist/layered.css.map +1 -0
- package/package.json +17 -13
- package/src/README.mdx +68 -0
- package/src/SSR.mdx +67 -0
- package/src/_lib/compat.ts +0 -11
- package/src/_lib/index.ts +1 -1
- package/src/components/Button/__snapshots__/index.story.storyshot +9 -9
- package/src/components/Button/index.tsx +4 -10
- package/src/components/Checkbox/CheckboxInput/__snapshots__/index.story.storyshot +5 -5
- package/src/components/Checkbox/CheckboxInput/index.css +4 -5
- package/src/components/Checkbox/__snapshots__/index.story.storyshot +6 -6
- package/src/components/Clickable/__snapshots__/index.story.storyshot +2 -2
- package/src/components/Clickable/index.story.tsx +1 -1
- package/src/components/Clickable/index.tsx +7 -12
- package/src/components/DropdownSelector/Divider/index.css +11 -0
- package/src/components/DropdownSelector/Divider/index.tsx +5 -0
- package/src/components/DropdownSelector/DropdownMenuItem/index.css +20 -0
- package/src/components/DropdownSelector/DropdownMenuItem/index.tsx +34 -0
- package/src/components/DropdownSelector/DropdownPopover.tsx +16 -9
- package/src/components/DropdownSelector/ListItem/__snapshots__/index.story.storyshot +41 -99
- package/src/components/DropdownSelector/ListItem/index.css +24 -0
- package/src/components/DropdownSelector/ListItem/index.story.tsx +11 -5
- package/src/components/DropdownSelector/ListItem/index.tsx +14 -53
- package/src/components/DropdownSelector/MenuItem/index.tsx +17 -12
- package/src/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.tsx +2 -2
- package/src/components/DropdownSelector/MenuItemGroup/index.css +19 -0
- package/src/components/DropdownSelector/MenuItemGroup/index.tsx +6 -28
- package/src/components/DropdownSelector/MenuList/__snapshots__/index.story.storyshot +162 -416
- package/src/components/DropdownSelector/MenuList/index.css +4 -0
- package/src/components/DropdownSelector/MenuList/index.tsx +4 -12
- package/src/components/DropdownSelector/Popover/__snapshots__/index.story.storyshot +1 -1
- package/src/components/DropdownSelector/Popover/index.css +11 -0
- package/src/components/DropdownSelector/Popover/index.tsx +6 -15
- package/src/components/DropdownSelector/__snapshots__/index.story.storyshot +403 -1181
- package/src/components/DropdownSelector/index.css +84 -0
- package/src/components/DropdownSelector/index.story.tsx +0 -4
- package/src/components/DropdownSelector/index.tsx +40 -102
- package/src/components/Icon/__snapshots__/index.story.storyshot +1 -1
- package/src/components/IconButton/__snapshots__/index.story.storyshot +3 -3
- package/src/components/IconButton/index.tsx +3 -6
- package/src/components/LoadingSpinner/__snapshots__/index.story.storyshot +4 -4
- package/src/components/Modal/Dialog/index.tsx +2 -1
- package/src/components/Modal/__snapshots__/index.story.storyshot +118 -437
- package/src/components/Modal/index.story.tsx +26 -11
- package/src/components/Modal/index.tsx +5 -6
- package/src/components/Modal/useCustomModalOverlay.tsx +20 -0
- package/src/components/Radio/RadioGroup/index.css +5 -0
- package/src/components/Radio/RadioGroup/index.tsx +80 -0
- package/src/components/Radio/RadioGroupContext.ts +23 -0
- package/src/components/Radio/RadioInput/index.css +82 -0
- package/src/components/Radio/RadioInput/index.tsx +41 -0
- package/src/components/Radio/__snapshots__/index.story.storyshot +76 -95
- package/src/components/Radio/index.css +2 -81
- package/src/components/Radio/index.story.tsx +30 -13
- package/src/components/Radio/index.test.tsx +22 -28
- package/src/components/Radio/index.tsx +7 -89
- package/src/components/SegmentedControl/__snapshots__/index.story.storyshot +2 -2
- package/src/components/Switch/__snapshots__/index.story.storyshot +4 -4
- package/src/components/TagItem/__snapshots__/index.story.storyshot +8 -8
- package/src/components/TagItem/index.tsx +4 -8
- package/src/components/TextArea/__snapshots__/TextArea.story.storyshot +11 -11
- package/src/components/TextField/TextField.story.tsx +8 -9
- package/src/components/TextField/__snapshots__/TextField.story.storyshot +20 -26
- package/src/components/TextField/index.tsx +2 -2
- package/src/core/CharcoalProvider.tsx +5 -29
- package/src/index.ts +2 -11
- package/src/type.d.ts +2 -13
- package/dist/components/DropdownSelector/Divider.d.ts +0 -7
- package/dist/components/DropdownSelector/Divider.d.ts.map +0 -1
- package/dist/components/DropdownSelector/DropdownMenuItem.d.ts +0 -7
- package/dist/components/DropdownSelector/DropdownMenuItem.d.ts.map +0 -1
- package/dist/components/Modal/__stories__/InternalScrollStory.d.ts +0 -4
- package/dist/components/Modal/__stories__/InternalScrollStory.d.ts.map +0 -1
- package/dist/core/ComponentAbstraction.d.ts +0 -24
- package/dist/core/ComponentAbstraction.d.ts.map +0 -1
- package/dist/styled.d.ts +0 -95
- package/dist/styled.d.ts.map +0 -1
- package/src/components/Button/__snapshots__/index.test.tsx.snap +0 -11
- package/src/components/Button/index.test.tsx +0 -32
- package/src/components/DropdownSelector/Divider.tsx +0 -16
- package/src/components/DropdownSelector/DropdownMenuItem.tsx +0 -43
- package/src/components/Modal/__stories__/InternalScrollStory.tsx +0 -75
- package/src/components/a11y.test.tsx +0 -99
- package/src/core/ComponentAbstraction.tsx +0 -48
- package/src/styled.ts +0 -3
package/dist/index.esm.js
CHANGED
|
@@ -1,31 +1,3 @@
|
|
|
1
|
-
// src/core/ComponentAbstraction.tsx
|
|
2
|
-
import { useContext } from "react";
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
var DefaultLink = React.forwardRef(function DefaultLink2({
|
|
6
|
-
to,
|
|
7
|
-
children,
|
|
8
|
-
...rest
|
|
9
|
-
}, ref) {
|
|
10
|
-
return /* @__PURE__ */ jsx("a", { href: to, ref, ...rest, children });
|
|
11
|
-
});
|
|
12
|
-
var DefaultValue = {
|
|
13
|
-
Link: DefaultLink
|
|
14
|
-
};
|
|
15
|
-
var ComponentAbstractionContext = React.createContext(DefaultValue);
|
|
16
|
-
function ComponentAbstraction({
|
|
17
|
-
children,
|
|
18
|
-
components
|
|
19
|
-
}) {
|
|
20
|
-
return /* @__PURE__ */ jsx(ComponentAbstractionContext.Provider, { value: {
|
|
21
|
-
...DefaultValue,
|
|
22
|
-
...components
|
|
23
|
-
}, children });
|
|
24
|
-
}
|
|
25
|
-
function useComponentAbstraction() {
|
|
26
|
-
return useContext(ComponentAbstractionContext);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
1
|
// src/core/SSRProvider.tsx
|
|
30
2
|
import { SSRProvider as OriginSSRProvider } from "@react-aria/ssr";
|
|
31
3
|
import { version, Fragment } from "react";
|
|
@@ -39,25 +11,15 @@ var SSRProvider = isReactVersionOver(18) ? Fragment : OriginSSRProvider;
|
|
|
39
11
|
import { OverlayProvider } from "@react-aria/overlays";
|
|
40
12
|
|
|
41
13
|
// src/core/CharcoalProvider.tsx
|
|
42
|
-
import {
|
|
43
|
-
import { TokenInjector } from "@charcoal-ui/styled";
|
|
44
|
-
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { jsx } from "react/jsx-runtime";
|
|
45
15
|
function CharcoalProvider({
|
|
46
|
-
|
|
47
|
-
defaultTheme = themeMap[":root"],
|
|
48
|
-
components = {},
|
|
49
|
-
injectTokens = true,
|
|
50
|
-
children,
|
|
51
|
-
background
|
|
16
|
+
children
|
|
52
17
|
}) {
|
|
53
|
-
return /* @__PURE__ */
|
|
54
|
-
injectTokens && /* @__PURE__ */ jsx2(TokenInjector, { theme: themeMap, background }),
|
|
55
|
-
/* @__PURE__ */ jsx2(ComponentAbstraction, { components, children: /* @__PURE__ */ jsx2(OverlayProvider, { children }) })
|
|
56
|
-
] }) });
|
|
18
|
+
return /* @__PURE__ */ jsx(SSRProvider, { children: /* @__PURE__ */ jsx(OverlayProvider, { children }) });
|
|
57
19
|
}
|
|
58
20
|
|
|
59
21
|
// src/components/Button/index.tsx
|
|
60
|
-
import { forwardRef
|
|
22
|
+
import { forwardRef, useMemo as useMemo2 } from "react";
|
|
61
23
|
|
|
62
24
|
// src/_lib/useClassNames.ts
|
|
63
25
|
import { useMemo } from "react";
|
|
@@ -66,53 +28,50 @@ function useClassNames(...classNames) {
|
|
|
66
28
|
}
|
|
67
29
|
|
|
68
30
|
// src/components/Button/index.tsx
|
|
69
|
-
import { jsx as
|
|
70
|
-
var Button =
|
|
31
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
32
|
+
var Button = forwardRef(function Button2({
|
|
71
33
|
variant,
|
|
72
34
|
fullWidth,
|
|
73
35
|
size,
|
|
74
36
|
className,
|
|
75
|
-
|
|
37
|
+
component,
|
|
76
38
|
isActive,
|
|
77
|
-
componentAs,
|
|
78
39
|
...props
|
|
79
40
|
}, ref) {
|
|
80
|
-
const Component = useMemo2(() =>
|
|
41
|
+
const Component = useMemo2(() => component ?? "button", [component]);
|
|
81
42
|
const classNames = useClassNames("charcoal-button", className);
|
|
82
|
-
return /* @__PURE__ */
|
|
43
|
+
return /* @__PURE__ */ jsx2(Component, { ...props, className: classNames, "data-variant": variant, "data-size": size, "data-full-width": fullWidth, "data-active": isActive, ref });
|
|
83
44
|
});
|
|
84
45
|
var Button_default = Button;
|
|
85
46
|
|
|
86
47
|
// src/components/Clickable/index.tsx
|
|
87
|
-
import { useMemo as useMemo3, forwardRef as
|
|
88
|
-
import { jsx as
|
|
89
|
-
var Clickable =
|
|
90
|
-
|
|
91
|
-
as,
|
|
48
|
+
import { useMemo as useMemo3, forwardRef as forwardRef2 } from "react";
|
|
49
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
50
|
+
var Clickable = forwardRef2(function Clickable2({
|
|
51
|
+
component,
|
|
92
52
|
...props
|
|
93
53
|
}, ref) {
|
|
94
54
|
const className = useClassNames("charcoal-clickable", props.className);
|
|
95
|
-
const Component = useMemo3(() =>
|
|
96
|
-
return /* @__PURE__ */
|
|
55
|
+
const Component = useMemo3(() => component ?? "button", [component]);
|
|
56
|
+
return /* @__PURE__ */ jsx3(Component, { ...props, ref, className });
|
|
97
57
|
});
|
|
98
58
|
var Clickable_default = Clickable;
|
|
99
59
|
|
|
100
60
|
// src/components/IconButton/index.tsx
|
|
101
|
-
import { forwardRef as
|
|
102
|
-
import { jsx as
|
|
103
|
-
var IconButton =
|
|
61
|
+
import { forwardRef as forwardRef3, useMemo as useMemo4 } from "react";
|
|
62
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
63
|
+
var IconButton = forwardRef3(function IconButtonInner({
|
|
104
64
|
variant = "Default",
|
|
105
65
|
size = "M",
|
|
106
66
|
icon,
|
|
107
67
|
isActive = false,
|
|
108
|
-
|
|
109
|
-
as,
|
|
68
|
+
component,
|
|
110
69
|
...rest
|
|
111
70
|
}, ref) {
|
|
112
71
|
validateIconSize(size, icon);
|
|
113
|
-
const Component = useMemo4(() =>
|
|
72
|
+
const Component = useMemo4(() => component ?? "button", [component]);
|
|
114
73
|
const classNames = useClassNames("charcoal-icon-button", rest.className);
|
|
115
|
-
return /* @__PURE__ */
|
|
74
|
+
return /* @__PURE__ */ jsx4(Component, { ...rest, ref, className: classNames, "data-size": size, "data-active": isActive, "data-variant": variant, children: /* @__PURE__ */ jsx4("pixiv-icon", { name: icon }) });
|
|
116
75
|
});
|
|
117
76
|
var IconButton_default = IconButton;
|
|
118
77
|
function validateIconSize(size, icon) {
|
|
@@ -137,10 +96,42 @@ function validateIconSize(size, icon) {
|
|
|
137
96
|
}
|
|
138
97
|
|
|
139
98
|
// src/components/Radio/index.tsx
|
|
140
|
-
import { memo, forwardRef as forwardRef5,
|
|
141
|
-
import * as React5 from "react";
|
|
99
|
+
import { memo as memo2, forwardRef as forwardRef5, useContext } from "react";
|
|
142
100
|
import warning from "warning";
|
|
143
|
-
|
|
101
|
+
|
|
102
|
+
// src/components/Radio/RadioGroupContext.ts
|
|
103
|
+
import * as React4 from "react";
|
|
104
|
+
var RadioGroupContext = React4.createContext({
|
|
105
|
+
name: void 0,
|
|
106
|
+
selected: void 0,
|
|
107
|
+
disabled: false,
|
|
108
|
+
readonly: false,
|
|
109
|
+
invalid: false,
|
|
110
|
+
onChange() {
|
|
111
|
+
throw new Error("Cannot find onChange() handler. Perhaps you forgot to wrap with <RadioGroup> ?");
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
// src/components/Radio/RadioInput/index.tsx
|
|
116
|
+
import { forwardRef as forwardRef4, memo, useCallback } from "react";
|
|
117
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
118
|
+
var RadioInput = forwardRef4(function RadioInput2({
|
|
119
|
+
onChange,
|
|
120
|
+
invalid,
|
|
121
|
+
className,
|
|
122
|
+
...props
|
|
123
|
+
}, ref) {
|
|
124
|
+
const handleChange = useCallback((e) => {
|
|
125
|
+
const el = e.currentTarget;
|
|
126
|
+
onChange?.(el.value);
|
|
127
|
+
}, [onChange]);
|
|
128
|
+
const classNames = useClassNames("charcoal-radio-input", className);
|
|
129
|
+
return /* @__PURE__ */ jsx5("input", { className: classNames, ref, type: "radio", onChange: handleChange, "aria-invalid": invalid, ...props });
|
|
130
|
+
});
|
|
131
|
+
var RadioInput_default = memo(RadioInput);
|
|
132
|
+
|
|
133
|
+
// src/components/Radio/index.tsx
|
|
134
|
+
import { jsx as jsx6, jsxs } from "react/jsx-runtime";
|
|
144
135
|
var Radio = forwardRef5(function RadioInner({
|
|
145
136
|
value,
|
|
146
137
|
disabled = false,
|
|
@@ -154,7 +145,7 @@ var Radio = forwardRef5(function RadioInner({
|
|
|
154
145
|
readonly,
|
|
155
146
|
invalid,
|
|
156
147
|
onChange
|
|
157
|
-
} =
|
|
148
|
+
} = useContext(RadioGroupContext);
|
|
158
149
|
const classNames = useClassNames("charcoal-radio__label", props.className);
|
|
159
150
|
warning(
|
|
160
151
|
name !== void 0,
|
|
@@ -163,37 +154,30 @@ var Radio = forwardRef5(function RadioInner({
|
|
|
163
154
|
const isSelected = value === selected;
|
|
164
155
|
const isDisabled = disabled || isParentDisabled;
|
|
165
156
|
const isReadonly = readonly && !isSelected;
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}, [onChange]);
|
|
169
|
-
return /* @__PURE__ */ jsxs2("label", { "aria-disabled": isDisabled || isReadonly, className: classNames, children: [
|
|
170
|
-
/* @__PURE__ */ jsx6("input", { type: "radio", className: "charcoal-radio__input", name, value, checked: isSelected, "aria-invalid": invalid, onChange: handleChange, disabled: isDisabled || isReadonly, ref }),
|
|
157
|
+
return /* @__PURE__ */ jsxs("label", { "aria-disabled": isDisabled || isReadonly, className: classNames, children: [
|
|
158
|
+
/* @__PURE__ */ jsx6(RadioInput_default, { name, value, checked: isSelected, "aria-invalid": invalid, onChange, disabled: isDisabled || isReadonly, ref }),
|
|
171
159
|
children != null && /* @__PURE__ */ jsx6("div", { className: "charcoal-radio__label_div", children })
|
|
172
160
|
] });
|
|
173
161
|
});
|
|
174
|
-
var Radio_default =
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
invalid: false,
|
|
181
|
-
onChange() {
|
|
182
|
-
throw new Error("Cannot find onChange() handler. Perhaps you forgot to wrap with <RadioGroup> ?");
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
var RadioGroup = forwardRef5(function RadioGroupInner({
|
|
162
|
+
var Radio_default = memo2(Radio);
|
|
163
|
+
|
|
164
|
+
// src/components/Radio/RadioGroup/index.tsx
|
|
165
|
+
import { forwardRef as forwardRef6, useCallback as useCallback2, useMemo as useMemo5 } from "react";
|
|
166
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
167
|
+
var RadioGroup = forwardRef6(function RadioGroupInner({
|
|
186
168
|
value,
|
|
169
|
+
label,
|
|
187
170
|
name,
|
|
188
171
|
onChange,
|
|
189
172
|
disabled,
|
|
190
173
|
readonly,
|
|
191
174
|
invalid,
|
|
192
175
|
children,
|
|
176
|
+
"aria-orientation": ariaOrientation = "vertical",
|
|
193
177
|
...props
|
|
194
178
|
}, ref) {
|
|
195
179
|
const classNames = useClassNames("charcoal-radio-group", props.className);
|
|
196
|
-
const handleChange =
|
|
180
|
+
const handleChange = useCallback2((next) => {
|
|
197
181
|
onChange(next);
|
|
198
182
|
}, [onChange]);
|
|
199
183
|
const contextValue = useMemo5(() => ({
|
|
@@ -204,35 +188,35 @@ var RadioGroup = forwardRef5(function RadioGroupInner({
|
|
|
204
188
|
invalid: invalid ?? false,
|
|
205
189
|
onChange: handleChange
|
|
206
190
|
}), [disabled, handleChange, invalid, name, readonly, value]);
|
|
207
|
-
return /* @__PURE__ */
|
|
191
|
+
return /* @__PURE__ */ jsx7(RadioGroupContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx7("div", { role: "radiogroup", "aria-disabled": disabled, "aria-invalid": invalid, "aria-label": label, "aria-labelledby": props["aria-labelledby"], "aria-orientation": ariaOrientation, className: classNames, ref, children }) });
|
|
208
192
|
});
|
|
209
193
|
|
|
210
194
|
// src/components/Switch/index.tsx
|
|
211
|
-
import { memo as
|
|
195
|
+
import { memo as memo4, forwardRef as forwardRef8 } from "react";
|
|
212
196
|
import { useId } from "@react-aria/utils";
|
|
213
197
|
|
|
214
198
|
// src/components/Switch/SwitchInput/index.tsx
|
|
215
|
-
import { forwardRef as
|
|
216
|
-
import { jsx as
|
|
217
|
-
var SwitchInput =
|
|
199
|
+
import { forwardRef as forwardRef7, useCallback as useCallback3 } from "react";
|
|
200
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
201
|
+
var SwitchInput = forwardRef7(function SwitchInput2({
|
|
218
202
|
onChange,
|
|
219
203
|
className,
|
|
220
204
|
...props
|
|
221
205
|
}, ref) {
|
|
222
|
-
const handleChange =
|
|
206
|
+
const handleChange = useCallback3((e) => {
|
|
223
207
|
const el = e.currentTarget;
|
|
224
208
|
onChange?.(el.checked);
|
|
225
209
|
}, [onChange]);
|
|
226
210
|
props.children;
|
|
227
211
|
const classNames = useClassNames("charcoal-switch-input", className);
|
|
228
|
-
return /* @__PURE__ */
|
|
212
|
+
return /* @__PURE__ */ jsx8("input", { ref, className: classNames, type: "checkbox", onChange: handleChange, ...props });
|
|
229
213
|
});
|
|
230
214
|
var SwitchInput_default = SwitchInput;
|
|
231
215
|
|
|
232
216
|
// src/components/Switch/SwitchWithLabel.tsx
|
|
233
|
-
import * as
|
|
234
|
-
import { jsx as
|
|
235
|
-
var SwitchWithLabel =
|
|
217
|
+
import * as React5 from "react";
|
|
218
|
+
import { jsx as jsx9, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
219
|
+
var SwitchWithLabel = React5.memo(function SwitchWithLabel2({
|
|
236
220
|
children,
|
|
237
221
|
className,
|
|
238
222
|
disabled,
|
|
@@ -240,15 +224,15 @@ var SwitchWithLabel = React6.memo(function SwitchWithLabel2({
|
|
|
240
224
|
input
|
|
241
225
|
}) {
|
|
242
226
|
const classNames = useClassNames("charcoal-switch__label", className);
|
|
243
|
-
return /* @__PURE__ */
|
|
227
|
+
return /* @__PURE__ */ jsxs2("label", { htmlFor: id, className: classNames, "aria-disabled": disabled, children: [
|
|
244
228
|
input,
|
|
245
|
-
/* @__PURE__ */
|
|
229
|
+
/* @__PURE__ */ jsx9("div", { className: "charcoal-switch__label_div", children })
|
|
246
230
|
] });
|
|
247
231
|
});
|
|
248
232
|
|
|
249
233
|
// src/components/Switch/index.tsx
|
|
250
|
-
import { jsx as
|
|
251
|
-
var Switch =
|
|
234
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
235
|
+
var Switch = forwardRef8(function Switch2({
|
|
252
236
|
children,
|
|
253
237
|
onChange,
|
|
254
238
|
disabled,
|
|
@@ -258,23 +242,23 @@ var Switch = forwardRef7(function Switch2({
|
|
|
258
242
|
}, ref) {
|
|
259
243
|
const htmlId = useId(id);
|
|
260
244
|
const noChildren = children === void 0;
|
|
261
|
-
const input = /* @__PURE__ */
|
|
245
|
+
const input = /* @__PURE__ */ jsx10(SwitchInput_default, { ...props, disabled, className: noChildren ? className : void 0, id: htmlId, onChange, ref, role: "switch", type: "checkbox" });
|
|
262
246
|
if (noChildren) {
|
|
263
247
|
return input;
|
|
264
248
|
}
|
|
265
|
-
return /* @__PURE__ */
|
|
249
|
+
return /* @__PURE__ */ jsx10(SwitchWithLabel, { className, disabled, id: htmlId, input, children });
|
|
266
250
|
});
|
|
267
|
-
var Switch_default =
|
|
251
|
+
var Switch_default = memo4(Switch);
|
|
268
252
|
|
|
269
253
|
// src/components/TextField/index.tsx
|
|
270
254
|
import { useVisuallyHidden } from "@react-aria/visually-hidden";
|
|
271
|
-
import { useCallback as
|
|
272
|
-
import * as
|
|
255
|
+
import { useCallback as useCallback4, useEffect as useEffect2, useRef, useState } from "react";
|
|
256
|
+
import * as React7 from "react";
|
|
273
257
|
|
|
274
258
|
// src/components/FieldLabel/index.tsx
|
|
275
|
-
import * as
|
|
276
|
-
import { jsx as
|
|
277
|
-
var FieldLabel =
|
|
259
|
+
import * as React6 from "react";
|
|
260
|
+
import { jsx as jsx11, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
261
|
+
var FieldLabel = React6.forwardRef(function FieldLabel2({
|
|
278
262
|
style,
|
|
279
263
|
className,
|
|
280
264
|
label,
|
|
@@ -284,10 +268,10 @@ var FieldLabel = React7.forwardRef(function FieldLabel2({
|
|
|
284
268
|
...labelProps
|
|
285
269
|
}, ref) {
|
|
286
270
|
const classNames = useClassNames("charcoal-field-label-root", className);
|
|
287
|
-
return /* @__PURE__ */
|
|
288
|
-
/* @__PURE__ */
|
|
289
|
-
required && /* @__PURE__ */
|
|
290
|
-
/* @__PURE__ */
|
|
271
|
+
return /* @__PURE__ */ jsxs3("div", { style, className: classNames, children: [
|
|
272
|
+
/* @__PURE__ */ jsx11("label", { ref, className: "charcoal-field-label", ...labelProps, children: label }),
|
|
273
|
+
required && /* @__PURE__ */ jsx11("div", { className: "charcoal-field-label-required-text", children: requiredText }),
|
|
274
|
+
/* @__PURE__ */ jsx11("div", { className: "charcoal-field-label-sub-label", children: /* @__PURE__ */ jsx11("span", { children: subLabel }) })
|
|
291
275
|
] });
|
|
292
276
|
});
|
|
293
277
|
var FieldLabel_default = FieldLabel;
|
|
@@ -332,15 +316,15 @@ function useFocusWithClick(containerRef, inputRef) {
|
|
|
332
316
|
import { mergeRefs as mergeRefs2, useId as useId2 } from "@react-aria/utils";
|
|
333
317
|
|
|
334
318
|
// src/_lib/createDivComponent.tsx
|
|
335
|
-
import { forwardRef as
|
|
336
|
-
import { jsx as
|
|
319
|
+
import { forwardRef as forwardRef10 } from "react";
|
|
320
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
337
321
|
function createDivComponent(mainClassName) {
|
|
338
|
-
return
|
|
322
|
+
return forwardRef10(function DivComponent({
|
|
339
323
|
className,
|
|
340
324
|
...props
|
|
341
325
|
}, ref) {
|
|
342
326
|
const classNames = useClassNames(mainClassName, className);
|
|
343
|
-
return /* @__PURE__ */
|
|
327
|
+
return /* @__PURE__ */ jsx12("div", { className: classNames, ref, ...props });
|
|
344
328
|
});
|
|
345
329
|
}
|
|
346
330
|
|
|
@@ -348,8 +332,8 @@ function createDivComponent(mainClassName) {
|
|
|
348
332
|
var AssistiveText = createDivComponent("charcoal-text-field-assistive-text");
|
|
349
333
|
|
|
350
334
|
// src/components/TextField/index.tsx
|
|
351
|
-
import { jsx as
|
|
352
|
-
var TextField =
|
|
335
|
+
import { jsx as jsx13, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
336
|
+
var TextField = React7.forwardRef(function SingleLineTextFieldInner({
|
|
353
337
|
assistiveText,
|
|
354
338
|
className,
|
|
355
339
|
disabled = false,
|
|
@@ -368,13 +352,13 @@ var TextField = React8.forwardRef(function SingleLineTextFieldInner({
|
|
|
368
352
|
value,
|
|
369
353
|
getCount = countCodePointsInString,
|
|
370
354
|
...props
|
|
371
|
-
},
|
|
355
|
+
}, forwardRef23) {
|
|
372
356
|
const inputRef = useRef(null);
|
|
373
357
|
const {
|
|
374
358
|
visuallyHiddenProps
|
|
375
359
|
} = useVisuallyHidden();
|
|
376
360
|
const [count, setCount] = useState(getCount(value ?? ""));
|
|
377
|
-
const handleChange =
|
|
361
|
+
const handleChange = useCallback4((e) => {
|
|
378
362
|
const value2 = e.target.value;
|
|
379
363
|
const count2 = getCount(value2);
|
|
380
364
|
if (maxLength !== void 0 && count2 > maxLength) {
|
|
@@ -392,28 +376,28 @@ var TextField = React8.forwardRef(function SingleLineTextFieldInner({
|
|
|
392
376
|
const describedbyId = useId2();
|
|
393
377
|
const labelledbyId = useId2();
|
|
394
378
|
const showAssistiveText = assistiveText != null && assistiveText.length !== 0;
|
|
395
|
-
const classNames = useClassNames("charcoal-text-field-root");
|
|
396
|
-
return /* @__PURE__ */
|
|
397
|
-
/* @__PURE__ */
|
|
398
|
-
/* @__PURE__ */
|
|
399
|
-
prefix && /* @__PURE__ */
|
|
400
|
-
/* @__PURE__ */
|
|
401
|
-
(suffix || showCount) && /* @__PURE__ */
|
|
379
|
+
const classNames = useClassNames("charcoal-text-field-root", className);
|
|
380
|
+
return /* @__PURE__ */ jsxs4("div", { className: classNames, "aria-disabled": disabled, children: [
|
|
381
|
+
/* @__PURE__ */ jsx13(FieldLabel_default, { htmlFor: inputId, id: labelledbyId, label, required, requiredText, subLabel, ...!showLabel ? visuallyHiddenProps : {} }),
|
|
382
|
+
/* @__PURE__ */ jsxs4("div", { className: "charcoal-text-field-container", "aria-disabled": disabled === true ? true : void 0, "data-invalid": invalid === true, ref: containerRef, children: [
|
|
383
|
+
prefix && /* @__PURE__ */ jsx13("div", { className: "charcoal-text-field-prefix", children: prefix }),
|
|
384
|
+
/* @__PURE__ */ jsx13("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: mergeRefs2(forwardRef23, inputRef), type, value, ...props }),
|
|
385
|
+
(suffix || showCount) && /* @__PURE__ */ jsxs4("div", { className: "charcoal-text-field-suffix", children: [
|
|
402
386
|
suffix,
|
|
403
|
-
showCount && /* @__PURE__ */
|
|
387
|
+
showCount && /* @__PURE__ */ jsx13("span", { className: "charcoal-text-field-line-counter", children: maxLength !== void 0 ? `${count}/${maxLength}` : count })
|
|
404
388
|
] })
|
|
405
389
|
] }),
|
|
406
|
-
showAssistiveText && /* @__PURE__ */
|
|
390
|
+
showAssistiveText && /* @__PURE__ */ jsx13(AssistiveText, { "data-invalid": invalid === true, id: describedbyId, children: assistiveText })
|
|
407
391
|
] });
|
|
408
392
|
});
|
|
409
393
|
var TextField_default = TextField;
|
|
410
394
|
|
|
411
395
|
// src/components/TextArea/index.tsx
|
|
412
396
|
import { useVisuallyHidden as useVisuallyHidden2 } from "@react-aria/visually-hidden";
|
|
413
|
-
import { forwardRef as
|
|
397
|
+
import { forwardRef as forwardRef12, useCallback as useCallback5, useEffect as useEffect3, useRef as useRef2, useState as useState2 } from "react";
|
|
414
398
|
import { useId as useId3 } from "@react-aria/utils";
|
|
415
|
-
import { jsx as
|
|
416
|
-
var TextArea =
|
|
399
|
+
import { jsx as jsx14, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
400
|
+
var TextArea = forwardRef12(function TextAreaInner({
|
|
417
401
|
onChange,
|
|
418
402
|
className,
|
|
419
403
|
value,
|
|
@@ -431,20 +415,20 @@ var TextArea = forwardRef11(function TextAreaInner({
|
|
|
431
415
|
invalid,
|
|
432
416
|
getCount = countCodePointsInString,
|
|
433
417
|
...props
|
|
434
|
-
},
|
|
418
|
+
}, forwardRef23) {
|
|
435
419
|
const {
|
|
436
420
|
visuallyHiddenProps
|
|
437
421
|
} = useVisuallyHidden2();
|
|
438
422
|
const textareaRef = useRef2(null);
|
|
439
423
|
const [count, setCount] = useState2(getCount(value ?? ""));
|
|
440
424
|
const [rows, setRows] = useState2(initialRows);
|
|
441
|
-
const syncHeight =
|
|
425
|
+
const syncHeight = useCallback5((textarea) => {
|
|
442
426
|
const rows2 = (`${textarea.value}
|
|
443
427
|
`.match(/\n/gu)?.length ?? 0) || 1;
|
|
444
428
|
setRows(initialRows <= rows2 ? rows2 : initialRows);
|
|
445
429
|
}, [initialRows]);
|
|
446
430
|
const nonControlled = value === void 0;
|
|
447
|
-
const handleChange =
|
|
431
|
+
const handleChange = useCallback5((e) => {
|
|
448
432
|
const value2 = e.target.value;
|
|
449
433
|
const count2 = getCount(value2);
|
|
450
434
|
if (maxLength !== void 0 && count2 > maxLength) {
|
|
@@ -473,53 +457,50 @@ var TextArea = forwardRef11(function TextAreaInner({
|
|
|
473
457
|
const labelledbyId = useId3();
|
|
474
458
|
const classNames = useClassNames("charcoal-text-area-root", className);
|
|
475
459
|
const showAssistiveText = assistiveText != null && assistiveText.length !== 0;
|
|
476
|
-
return /* @__PURE__ */
|
|
477
|
-
/* @__PURE__ */
|
|
478
|
-
/* @__PURE__ */
|
|
460
|
+
return /* @__PURE__ */ jsxs5("div", { className: classNames, "aria-disabled": disabled, children: [
|
|
461
|
+
/* @__PURE__ */ jsx14(FieldLabel_default, { htmlFor: textAreaId, id: labelledbyId, label, required, requiredText, subLabel, ...!showLabel ? visuallyHiddenProps : {} }),
|
|
462
|
+
/* @__PURE__ */ jsxs5("div", { className: "charcoal-text-area-container", "aria-disabled": disabled === true ? "true" : void 0, "aria-invalid": invalid === true, ref: containerRef, style: {
|
|
479
463
|
"--charcoal-text-area-rows": `${showCount ? rows + 1 : rows}`
|
|
480
464
|
}, children: [
|
|
481
|
-
/* @__PURE__ */
|
|
482
|
-
showCount && /* @__PURE__ */
|
|
465
|
+
/* @__PURE__ */ jsx14("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 }),
|
|
466
|
+
showCount && /* @__PURE__ */ jsx14("span", { className: "charcoal-text-area-counter", children: maxLength !== void 0 ? `${count}/${maxLength}` : count })
|
|
483
467
|
] }),
|
|
484
|
-
showAssistiveText && /* @__PURE__ */
|
|
468
|
+
showAssistiveText && /* @__PURE__ */ jsx14(AssistiveText, { "data-invalid": invalid === true, id: describedbyId, children: assistiveText })
|
|
485
469
|
] });
|
|
486
470
|
});
|
|
487
471
|
var TextArea_default = TextArea;
|
|
488
472
|
|
|
489
473
|
// src/components/Icon/index.tsx
|
|
490
|
-
import * as
|
|
474
|
+
import * as React8 from "react";
|
|
491
475
|
import "@charcoal-ui/icons";
|
|
492
|
-
import { jsx as
|
|
493
|
-
var Icon =
|
|
476
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
477
|
+
var Icon = React8.forwardRef(function IconInner({
|
|
494
478
|
name,
|
|
495
479
|
scale,
|
|
496
480
|
unsafeNonGuidelineScale,
|
|
497
481
|
className,
|
|
498
482
|
...rest
|
|
499
483
|
}, ref) {
|
|
500
|
-
return /* @__PURE__ */
|
|
484
|
+
return /* @__PURE__ */ jsx15("pixiv-icon", { ref, name, scale, "unsafe-non-guideline-scale": unsafeNonGuidelineScale, class: className, ...rest });
|
|
501
485
|
});
|
|
502
486
|
var Icon_default = Icon;
|
|
503
487
|
|
|
504
488
|
// src/components/Modal/index.tsx
|
|
505
|
-
import { useContext as
|
|
506
|
-
import * as
|
|
489
|
+
import { useContext as useContext2, forwardRef as forwardRef15, memo as memo5 } from "react";
|
|
490
|
+
import * as React12 from "react";
|
|
507
491
|
import { Overlay } from "@react-aria/overlays";
|
|
508
|
-
import { useTheme } from "styled-components";
|
|
509
|
-
import { maxWidth } from "@charcoal-ui/utils";
|
|
510
|
-
import { useMedia } from "@charcoal-ui/styled";
|
|
511
492
|
import { animated, useTransition, easings } from "react-spring";
|
|
512
493
|
import { useObjectRef } from "@react-aria/utils";
|
|
513
494
|
|
|
514
495
|
// src/components/Modal/Dialog/index.tsx
|
|
515
|
-
import { forwardRef as
|
|
496
|
+
import { forwardRef as forwardRef14 } from "react";
|
|
516
497
|
import { useDialog } from "@react-aria/dialog";
|
|
517
498
|
|
|
518
499
|
// src/_lib/useForwardedRef.tsx
|
|
519
|
-
import * as
|
|
500
|
+
import * as React9 from "react";
|
|
520
501
|
function useForwardedRef(ref) {
|
|
521
|
-
const innerRef =
|
|
522
|
-
|
|
502
|
+
const innerRef = React9.useRef(null);
|
|
503
|
+
React9.useEffect(() => {
|
|
523
504
|
if (!ref)
|
|
524
505
|
return;
|
|
525
506
|
if (typeof ref === "function") {
|
|
@@ -532,30 +513,29 @@ function useForwardedRef(ref) {
|
|
|
532
513
|
}
|
|
533
514
|
|
|
534
515
|
// src/components/Modal/Dialog/index.tsx
|
|
535
|
-
import { jsx as
|
|
536
|
-
var Dialog =
|
|
516
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
517
|
+
var Dialog = forwardRef14(function Dialog2({
|
|
537
518
|
size,
|
|
538
519
|
bottomSheet,
|
|
539
|
-
css: css2,
|
|
540
520
|
className,
|
|
541
521
|
...props
|
|
542
|
-
},
|
|
543
|
-
const ref = useForwardedRef(
|
|
522
|
+
}, forwardRef23) {
|
|
523
|
+
const ref = useForwardedRef(forwardRef23);
|
|
544
524
|
const {
|
|
545
525
|
dialogProps
|
|
546
526
|
} = useDialog({
|
|
547
527
|
role: "dialog"
|
|
548
528
|
}, ref);
|
|
549
529
|
const classNames = useClassNames("charcoal-modal-dialog", className);
|
|
550
|
-
return /* @__PURE__ */
|
|
530
|
+
return /* @__PURE__ */ jsx16("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 });
|
|
551
531
|
});
|
|
552
532
|
|
|
553
533
|
// src/components/Modal/ModalBackgroundContext.tsx
|
|
554
|
-
import * as
|
|
555
|
-
var ModalBackgroundContext =
|
|
534
|
+
import * as React10 from "react";
|
|
535
|
+
var ModalBackgroundContext = React10.createContext(null);
|
|
556
536
|
|
|
557
537
|
// src/components/Modal/useCustomModalOverlay.tsx
|
|
558
|
-
import * as
|
|
538
|
+
import * as React11 from "react";
|
|
559
539
|
import { ariaHideOutside, useOverlay, useOverlayFocusContain } from "@react-aria/overlays";
|
|
560
540
|
|
|
561
541
|
// src/components/DropdownSelector/Popover/usePreventScroll.tsx
|
|
@@ -588,7 +568,7 @@ function useCharcoalModalOverlay(props, state, ref) {
|
|
|
588
568
|
}, ref);
|
|
589
569
|
usePreventScroll(typeof document !== "undefined" ? document.body : null, state.isOpen);
|
|
590
570
|
useOverlayFocusContain();
|
|
591
|
-
|
|
571
|
+
React11.useEffect(() => {
|
|
592
572
|
if (state.isOpen && ref.current) {
|
|
593
573
|
return ariaHideOutside([ref.current]);
|
|
594
574
|
}
|
|
@@ -598,11 +578,27 @@ function useCharcoalModalOverlay(props, state, ref) {
|
|
|
598
578
|
underlayProps
|
|
599
579
|
};
|
|
600
580
|
}
|
|
581
|
+
function isWindowDefined() {
|
|
582
|
+
return typeof window !== "undefined";
|
|
583
|
+
}
|
|
584
|
+
function useWindowWidth() {
|
|
585
|
+
const [width, setWidth] = React11.useState(isWindowDefined() ? window.innerWidth : null);
|
|
586
|
+
React11.useEffect(() => {
|
|
587
|
+
const handleResize = () => {
|
|
588
|
+
setWidth(window.innerWidth);
|
|
589
|
+
};
|
|
590
|
+
window.addEventListener("resize", handleResize);
|
|
591
|
+
return () => {
|
|
592
|
+
window.removeEventListener("resize", handleResize);
|
|
593
|
+
};
|
|
594
|
+
});
|
|
595
|
+
return width;
|
|
596
|
+
}
|
|
601
597
|
|
|
602
598
|
// src/components/Modal/index.tsx
|
|
603
|
-
import { jsx as
|
|
599
|
+
import { jsx as jsx17, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
604
600
|
var DEFAULT_Z_INDEX = 10;
|
|
605
|
-
var Modal =
|
|
601
|
+
var Modal = forwardRef15(function ModalInner({
|
|
606
602
|
children,
|
|
607
603
|
zIndex = DEFAULT_Z_INDEX,
|
|
608
604
|
portalContainer,
|
|
@@ -629,8 +625,7 @@ var Modal = forwardRef14(function ModalInner({
|
|
|
629
625
|
onClose,
|
|
630
626
|
isOpen
|
|
631
627
|
}, ref);
|
|
632
|
-
const
|
|
633
|
-
const isMobile = useMedia(maxWidth(theme.breakpoint.screen1)) ?? false;
|
|
628
|
+
const isMobile = (useWindowWidth() ?? Infinity) < 744;
|
|
634
629
|
const transitionEnabled = isMobile && bottomSheet !== false;
|
|
635
630
|
const showDismiss = !isMobile || bottomSheet !== true;
|
|
636
631
|
const transition = useTransition(isOpen, {
|
|
@@ -658,8 +653,8 @@ var Modal = forwardRef14(function ModalInner({
|
|
|
658
653
|
duration: 0
|
|
659
654
|
}
|
|
660
655
|
});
|
|
661
|
-
const bgRef =
|
|
662
|
-
const handleClick =
|
|
656
|
+
const bgRef = React12.useRef(null);
|
|
657
|
+
const handleClick = React12.useCallback((e) => {
|
|
663
658
|
if (e.currentTarget === e.target) {
|
|
664
659
|
onClose();
|
|
665
660
|
}
|
|
@@ -668,15 +663,15 @@ var Modal = forwardRef14(function ModalInner({
|
|
|
668
663
|
backgroundColor,
|
|
669
664
|
overflow,
|
|
670
665
|
transform
|
|
671
|
-
}, item) => item && /* @__PURE__ */
|
|
666
|
+
}, item) => item && /* @__PURE__ */ jsx17(Overlay, { portalContainer, children: /* @__PURE__ */ jsx17(animated.div, { className: "charcoal-modal-background", ref: bgRef, ...underlayProps, style: transitionEnabled ? {
|
|
672
667
|
backgroundColor,
|
|
673
668
|
overflow,
|
|
674
669
|
zIndex
|
|
675
670
|
} : {
|
|
676
671
|
zIndex
|
|
677
|
-
}, "data-bottom-sheet": bottomSheet, onClick: handleClick, children: /* @__PURE__ */
|
|
672
|
+
}, "data-bottom-sheet": bottomSheet, onClick: handleClick, children: /* @__PURE__ */ jsx17(ModalBackgroundContext.Provider, { value: bgRef.current, children: /* @__PURE__ */ jsx17(AnimatedDialog, { ref, ...modalProps, style: transitionEnabled ? {
|
|
678
673
|
transform
|
|
679
|
-
} : {}, size, bottomSheet, className, children: /* @__PURE__ */
|
|
674
|
+
} : {}, size, bottomSheet, className, children: /* @__PURE__ */ jsxs6(ModalContext.Provider, { value: {
|
|
680
675
|
titleProps: {},
|
|
681
676
|
title,
|
|
682
677
|
close: onClose,
|
|
@@ -684,12 +679,12 @@ var Modal = forwardRef14(function ModalInner({
|
|
|
684
679
|
bottomSheet
|
|
685
680
|
}, children: [
|
|
686
681
|
children,
|
|
687
|
-
isDismissable === true && /* @__PURE__ */
|
|
682
|
+
isDismissable === true && /* @__PURE__ */ jsx17(ModalCloseButton, { "aria-label": closeButtonAriaLabel, onClick: onClose })
|
|
688
683
|
] }) }) }) }) }));
|
|
689
684
|
});
|
|
690
685
|
var AnimatedDialog = animated(Dialog);
|
|
691
|
-
var Modal_default =
|
|
692
|
-
var ModalContext =
|
|
686
|
+
var Modal_default = memo5(Modal);
|
|
687
|
+
var ModalContext = React12.createContext({
|
|
693
688
|
titleProps: {},
|
|
694
689
|
title: "",
|
|
695
690
|
close: void 0,
|
|
@@ -697,37 +692,37 @@ var ModalContext = React13.createContext({
|
|
|
697
692
|
bottomSheet: false
|
|
698
693
|
});
|
|
699
694
|
function ModalCloseButton(props) {
|
|
700
|
-
return /* @__PURE__ */
|
|
695
|
+
return /* @__PURE__ */ jsx17(IconButton_default, { className: "charcoal-modal-close-button", size: "S", icon: "24/Close", type: "button", ...props });
|
|
701
696
|
}
|
|
702
697
|
|
|
703
698
|
// src/components/Modal/ModalPlumbing.tsx
|
|
704
|
-
import { useContext as
|
|
705
|
-
import { jsx as
|
|
699
|
+
import { useContext as useContext3 } from "react";
|
|
700
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
706
701
|
function ModalHeader() {
|
|
707
|
-
const modalCtx =
|
|
708
|
-
return /* @__PURE__ */
|
|
702
|
+
const modalCtx = useContext3(ModalContext);
|
|
703
|
+
return /* @__PURE__ */ jsx18("div", { className: "charcoal-modal-header-root", "data-bottom-sheet": modalCtx.bottomSheet, children: /* @__PURE__ */ jsx18("div", { className: "charcoal-modal-header-title", children: modalCtx.title }) });
|
|
709
704
|
}
|
|
710
705
|
var ModalAlign = createDivComponent("charcoal-modal-align");
|
|
711
706
|
var ModalBody = createDivComponent("charcoal-modal-body");
|
|
712
707
|
var ModalButtons = createDivComponent("charcoal-modal-buttons");
|
|
713
708
|
|
|
714
709
|
// src/components/LoadingSpinner/index.tsx
|
|
715
|
-
import { forwardRef as
|
|
716
|
-
import { jsx as
|
|
717
|
-
var LoadingSpinner =
|
|
710
|
+
import { forwardRef as forwardRef16, useImperativeHandle, useRef as useRef5, memo as memo6 } from "react";
|
|
711
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
712
|
+
var LoadingSpinner = forwardRef16(function LoadingSpinnerInner({
|
|
718
713
|
size = 48,
|
|
719
714
|
padding = 16,
|
|
720
715
|
transparent = false,
|
|
721
716
|
...props
|
|
722
717
|
}, ref) {
|
|
723
718
|
const classNames = useClassNames("charcoal-loading-spinner", props.className);
|
|
724
|
-
return /* @__PURE__ */
|
|
719
|
+
return /* @__PURE__ */ jsx19("div", { role: "progressbar", style: {
|
|
725
720
|
"--charcoal-loading-spinner-size": `${size}px`,
|
|
726
721
|
"--charcoal-loading-spinner-padding": `${padding}px`
|
|
727
|
-
}, "data-transparent": transparent, className: classNames, ref, children: /* @__PURE__ */
|
|
722
|
+
}, "data-transparent": transparent, className: classNames, ref, children: /* @__PURE__ */ jsx19(LoadingSpinnerIcon, {}) });
|
|
728
723
|
});
|
|
729
|
-
var LoadingSpinner_default =
|
|
730
|
-
var LoadingSpinnerIcon =
|
|
724
|
+
var LoadingSpinner_default = memo6(LoadingSpinner);
|
|
725
|
+
var LoadingSpinnerIcon = forwardRef16(function LoadingSpinnerIcon2({
|
|
731
726
|
once = false
|
|
732
727
|
}, ref) {
|
|
733
728
|
const iconRef = useRef5(null);
|
|
@@ -741,22 +736,19 @@ var LoadingSpinnerIcon = forwardRef15(function LoadingSpinnerIcon2({
|
|
|
741
736
|
delete iconRef.current.dataset.resetAnimation;
|
|
742
737
|
}
|
|
743
738
|
}));
|
|
744
|
-
return /* @__PURE__ */
|
|
739
|
+
return /* @__PURE__ */ jsx19("div", { role: "presentation", ref: iconRef, "data-once": once, className: "charcoal-loading-spinner-icon" });
|
|
745
740
|
});
|
|
746
741
|
|
|
747
742
|
// src/components/DropdownSelector/index.tsx
|
|
748
|
-
import { useState as
|
|
749
|
-
import styled3, { css } from "styled-components";
|
|
750
|
-
import { disabledSelector } from "@charcoal-ui/utils";
|
|
743
|
+
import { useState as useState4, useRef as useRef9, useMemo as useMemo7, useCallback as useCallback7 } from "react";
|
|
751
744
|
|
|
752
745
|
// src/components/DropdownSelector/DropdownPopover.tsx
|
|
753
746
|
import { useEffect as useEffect7, useRef as useRef7 } from "react";
|
|
754
747
|
|
|
755
748
|
// src/components/DropdownSelector/Popover/index.tsx
|
|
756
|
-
import { useContext as
|
|
749
|
+
import { useContext as useContext4, useRef as useRef6 } from "react";
|
|
757
750
|
import { DismissButton, Overlay as Overlay2, usePopover } from "@react-aria/overlays";
|
|
758
|
-
import
|
|
759
|
-
import { jsx as jsx19, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
751
|
+
import { jsx as jsx20, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
760
752
|
var _empty = () => null;
|
|
761
753
|
function Popover(props) {
|
|
762
754
|
const defaultPopoverRef = useRef6(null);
|
|
@@ -775,29 +767,28 @@ function Popover(props) {
|
|
|
775
767
|
setOpen: _empty,
|
|
776
768
|
toggle: _empty
|
|
777
769
|
});
|
|
778
|
-
const modalBackground =
|
|
770
|
+
const modalBackground = useContext4(ModalBackgroundContext);
|
|
779
771
|
usePreventScroll(modalBackground, props.isOpen);
|
|
780
772
|
if (!props.isOpen)
|
|
781
773
|
return null;
|
|
782
|
-
return /* @__PURE__ */
|
|
783
|
-
/* @__PURE__ */
|
|
774
|
+
return /* @__PURE__ */ jsxs7(Overlay2, { portalContainer: document.body, children: [
|
|
775
|
+
/* @__PURE__ */ jsx20("div", { ...underlayProps, style: {
|
|
784
776
|
position: "fixed",
|
|
785
777
|
zIndex: typeof popoverProps.style?.zIndex === "number" ? popoverProps.style.zIndex - 1 : 99999,
|
|
786
778
|
inset: 0
|
|
787
779
|
} }),
|
|
788
|
-
/* @__PURE__ */
|
|
789
|
-
/* @__PURE__ */
|
|
780
|
+
/* @__PURE__ */ jsxs7("div", { ...popoverProps, ref: finalPopoverRef, className: "charcoal-popover", children: [
|
|
781
|
+
/* @__PURE__ */ jsx20(DismissButton, { onDismiss: () => props.onClose() }),
|
|
782
|
+
/* @__PURE__ */ jsx20("div", { tabIndex: 0, onFocus: props.onClose }),
|
|
790
783
|
props.children,
|
|
791
|
-
/* @__PURE__ */
|
|
784
|
+
/* @__PURE__ */ jsx20("div", { tabIndex: 0, onFocus: props.onClose }),
|
|
785
|
+
/* @__PURE__ */ jsx20(DismissButton, { onDismiss: () => props.onClose() })
|
|
792
786
|
] })
|
|
793
787
|
] });
|
|
794
788
|
}
|
|
795
|
-
var DropdownPopoverDiv = styled.div.withConfig({
|
|
796
|
-
componentId: "ccl__sc-jwnoy6-0"
|
|
797
|
-
})(["margin:4px 0;list-style:none;overflow:auto;max-height:inherit;background-color:var(--charcoal-background1);border:solid 1px var(--charcoal-border-default);border-radius:8px;padding-top:8px;padding-bottom:8px;"]);
|
|
798
789
|
|
|
799
790
|
// src/components/DropdownSelector/DropdownPopover.tsx
|
|
800
|
-
import { jsx as
|
|
791
|
+
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
801
792
|
function DropdownPopover({
|
|
802
793
|
children,
|
|
803
794
|
...props
|
|
@@ -809,24 +800,31 @@ function DropdownPopover({
|
|
|
809
800
|
}
|
|
810
801
|
}, [props.triggerRef, props.isOpen]);
|
|
811
802
|
useEffect7(() => {
|
|
812
|
-
if (props.isOpen
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
803
|
+
if (props.isOpen) {
|
|
804
|
+
if (props.value !== void 0 && props.value !== "") {
|
|
805
|
+
const windowScrollY = window.scrollY;
|
|
806
|
+
const windowScrollX = window.scrollX;
|
|
807
|
+
const selectedElement = document.querySelector(`[data-key="${props.value.toString()}"]`);
|
|
808
|
+
selectedElement?.focus();
|
|
809
|
+
window.scrollTo(windowScrollX, windowScrollY);
|
|
810
|
+
} else {
|
|
811
|
+
const el = ref.current?.querySelector("[role='option']");
|
|
812
|
+
if (el instanceof HTMLElement) {
|
|
813
|
+
el.focus();
|
|
814
|
+
}
|
|
815
|
+
}
|
|
818
816
|
}
|
|
819
817
|
}, [props.value, props.isOpen]);
|
|
820
|
-
return /* @__PURE__ */
|
|
818
|
+
return /* @__PURE__ */ jsx21(Popover, { isOpen: props.isOpen, onClose: props.onClose, popoverRef: ref, triggerRef: props.triggerRef, children });
|
|
821
819
|
}
|
|
822
820
|
|
|
823
821
|
// src/components/DropdownSelector/utils/findPreviewRecursive.tsx
|
|
824
|
-
import * as
|
|
822
|
+
import * as React13 from "react";
|
|
825
823
|
function findPreviewRecursive(children, value) {
|
|
826
|
-
const childArray =
|
|
824
|
+
const childArray = React13.Children.toArray(children);
|
|
827
825
|
for (let i = 0; i < childArray.length; i++) {
|
|
828
826
|
const child = childArray[i];
|
|
829
|
-
if (
|
|
827
|
+
if (React13.isValidElement(child)) {
|
|
830
828
|
if ("value" in child.props) {
|
|
831
829
|
const childValue = child.props.value;
|
|
832
830
|
if (childValue === value && "children" in child.props) {
|
|
@@ -846,11 +844,10 @@ function findPreviewRecursive(children, value) {
|
|
|
846
844
|
|
|
847
845
|
// src/components/DropdownSelector/MenuList/index.tsx
|
|
848
846
|
import { useMemo as useMemo6, useRef as useRef8 } from "react";
|
|
849
|
-
import styled2 from "styled-components";
|
|
850
847
|
|
|
851
848
|
// src/components/DropdownSelector/MenuList/MenuListContext.ts
|
|
852
|
-
import { createContext as
|
|
853
|
-
var MenuListContext =
|
|
849
|
+
import { createContext as createContext4 } from "react";
|
|
850
|
+
var MenuListContext = createContext4({
|
|
854
851
|
root: void 0,
|
|
855
852
|
value: "",
|
|
856
853
|
propsArray: [],
|
|
@@ -859,13 +856,13 @@ var MenuListContext = createContext5({
|
|
|
859
856
|
});
|
|
860
857
|
|
|
861
858
|
// src/components/DropdownSelector/MenuList/internals/getValuesRecursive.tsx
|
|
862
|
-
import * as
|
|
859
|
+
import * as React14 from "react";
|
|
863
860
|
function getValuesRecursive(children) {
|
|
864
|
-
const childArray =
|
|
861
|
+
const childArray = React14.Children.toArray(children);
|
|
865
862
|
const propsArray = [];
|
|
866
863
|
for (let i = 0; i < childArray.length; i++) {
|
|
867
864
|
const child = childArray[i];
|
|
868
|
-
if (
|
|
865
|
+
if (React14.isValidElement(child)) {
|
|
869
866
|
const props = child.props;
|
|
870
867
|
if ("value" in props && typeof props.value === "string") {
|
|
871
868
|
propsArray.push({
|
|
@@ -882,11 +879,11 @@ function getValuesRecursive(children) {
|
|
|
882
879
|
}
|
|
883
880
|
|
|
884
881
|
// src/components/DropdownSelector/MenuList/index.tsx
|
|
885
|
-
import { jsx as
|
|
882
|
+
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
886
883
|
function MenuList(props) {
|
|
887
884
|
const root = useRef8(null);
|
|
888
885
|
const propsArray = useMemo6(() => getValuesRecursive(props.children), [props.children]);
|
|
889
|
-
return /* @__PURE__ */
|
|
886
|
+
return /* @__PURE__ */ jsx22("ul", { className: "charcoal-menu-list", ref: root, children: /* @__PURE__ */ jsx22(MenuListContext.Provider, { value: {
|
|
890
887
|
value: props.value ?? "",
|
|
891
888
|
root,
|
|
892
889
|
propsArray,
|
|
@@ -895,89 +892,70 @@ function MenuList(props) {
|
|
|
895
892
|
}
|
|
896
893
|
}, children: props.children }) });
|
|
897
894
|
}
|
|
898
|
-
var StyledUl = styled2.ul.withConfig({
|
|
899
|
-
componentId: "ccl__sc-1y72v02-0"
|
|
900
|
-
})(["padding:0;margin:0;"]);
|
|
901
895
|
|
|
902
896
|
// src/components/DropdownSelector/index.tsx
|
|
903
|
-
import { focusVisibleFocusRingCss } from "@charcoal-ui/styled";
|
|
904
897
|
import { useVisuallyHidden as useVisuallyHidden3 } from "@react-aria/visually-hidden";
|
|
905
|
-
import {
|
|
906
|
-
|
|
898
|
+
import { useId as useId4 } from "@react-aria/utils";
|
|
899
|
+
import { jsx as jsx23, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
907
900
|
function DropdownSelector({
|
|
908
901
|
onChange,
|
|
902
|
+
showLabel = false,
|
|
909
903
|
...props
|
|
910
904
|
}) {
|
|
911
905
|
const triggerRef = useRef9(null);
|
|
912
|
-
const [isOpen, setIsOpen] =
|
|
906
|
+
const [isOpen, setIsOpen] = useState4(false);
|
|
913
907
|
const preview = findPreviewRecursive(props.children, props.value);
|
|
914
908
|
const isPlaceholder = useMemo7(() => props.placeholder !== void 0 && preview === void 0, [preview, props.placeholder]);
|
|
915
909
|
const propsArray = getValuesRecursive(props.children);
|
|
916
910
|
const {
|
|
917
911
|
visuallyHiddenProps
|
|
918
912
|
} = useVisuallyHidden3();
|
|
919
|
-
const handleChange =
|
|
913
|
+
const handleChange = useCallback7((e) => {
|
|
920
914
|
onChange(e.target.value);
|
|
921
915
|
}, [onChange]);
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
916
|
+
const labelId = useId4();
|
|
917
|
+
const describedbyId = useId4();
|
|
918
|
+
const classNames = useClassNames("charcoal-dropdown-selector-root", props.className);
|
|
919
|
+
return /* @__PURE__ */ jsxs8("div", { className: classNames, "aria-disabled": props.disabled, children: [
|
|
920
|
+
/* @__PURE__ */ jsx23(FieldLabel_default, { id: labelId, label: props.label, required: props.required, requiredText: props.requiredText, subLabel: props.subLabel, ...!showLabel ? visuallyHiddenProps : {} }),
|
|
921
|
+
/* @__PURE__ */ jsx23("div", { ...visuallyHiddenProps, "aria-hidden": "true", children: /* @__PURE__ */ jsx23("select", { name: props.name, value: props.value, onChange: handleChange, tabIndex: -1, children: propsArray.map((itemProps) => {
|
|
922
|
+
return /* @__PURE__ */ jsx23("option", { value: itemProps.value, disabled: itemProps.disabled, children: itemProps.value }, itemProps.value);
|
|
926
923
|
}) }) }),
|
|
927
|
-
/* @__PURE__ */
|
|
924
|
+
/* @__PURE__ */ jsxs8("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: () => {
|
|
928
925
|
if (props.disabled === true)
|
|
929
926
|
return;
|
|
930
927
|
setIsOpen(true);
|
|
931
|
-
}, ref: triggerRef, type: "button",
|
|
932
|
-
/* @__PURE__ */
|
|
933
|
-
/* @__PURE__ */
|
|
928
|
+
}, ref: triggerRef, type: "button", "data-active": isOpen, children: [
|
|
929
|
+
/* @__PURE__ */ jsx23("span", { className: "charcoal-ui-dropdown-selector-text", "data-placeholder": isPlaceholder, children: isPlaceholder ? props.placeholder : preview }),
|
|
930
|
+
/* @__PURE__ */ jsx23(Icon_default, { className: "charcoal-ui-dropdown-selector-icon", name: "16/Menu" })
|
|
934
931
|
] }),
|
|
935
|
-
isOpen && /* @__PURE__ */
|
|
932
|
+
isOpen && /* @__PURE__ */ jsx23(DropdownPopover, { isOpen, onClose: () => setIsOpen(false), triggerRef, value: props.value, children: /* @__PURE__ */ jsx23(MenuList, { value: props.value, onChange: (v) => {
|
|
936
933
|
onChange(v);
|
|
937
934
|
setIsOpen(false);
|
|
938
935
|
}, children: props.children }) }),
|
|
939
|
-
props.assistiveText !== void 0 && /* @__PURE__ */
|
|
936
|
+
props.assistiveText !== void 0 && /* @__PURE__ */ jsx23(AssistiveText, { "data-invalid": props.invalid === true, id: describedbyId, children: props.assistiveText })
|
|
940
937
|
] });
|
|
941
938
|
}
|
|
942
|
-
var DropdownSelectorRoot = styled3.div.withConfig({
|
|
943
|
-
componentId: "ccl__sc-1vnxmc8-0"
|
|
944
|
-
})(["display:grid;grid-template-columns:1fr;grid-gap:4px;width:100%;", "{cursor:default;opacity:0.32;}"], disabledSelector);
|
|
945
|
-
var DropdownButton = styled3.button.withConfig({
|
|
946
|
-
componentId: "ccl__sc-1vnxmc8-1"
|
|
947
|
-
})(["display:grid;grid-template-columns:1fr auto;justify-content:space-between;align-items:center;height:40px;width:100%;box-sizing:border-box;border:none;cursor:pointer;gap:4px;", "{cursor:default;}padding-right:8px;padding-left:8px;background-color:var(--charcoal-surface3);border-radius:4px;transition:0.2s box-shadow,0.2s background-color;&:not(:disabled):not([aria-disabled]),&[aria-disabled='false']{", " ", "}", ""], disabledSelector, focusVisibleFocusRingCss, ({
|
|
948
|
-
$active
|
|
949
|
-
}) => $active === true ? css(["background-color:var(--charcoal-surface3-press);"]) : css(["&:hover{background-color:var(--charcoal-surface3-hover);}&:active{background-color:var(--charcoal-surface3-press);}"]), ({
|
|
950
|
-
invalid
|
|
951
|
-
}) => invalid === true && css(["&:not(:disabled):not([aria-disabled]),&[aria-disabled='false']{box-shadow:0 0 0 4px rgba(255,43,0,0.32);}"]));
|
|
952
|
-
var DropdownButtonText = styled3.span.withConfig({
|
|
953
|
-
componentId: "ccl__sc-1vnxmc8-2"
|
|
954
|
-
})(["text-align:left;font-size:14px;line-height:22px;display:flow-root;color:var(--charcoal-", ");overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"], (p) => p.$isText3 ? "text3" : "text2");
|
|
955
|
-
var DropdownButtonIcon = styled3(Icon_default).withConfig({
|
|
956
|
-
componentId: "ccl__sc-1vnxmc8-3"
|
|
957
|
-
})(["color:var(--charcoal-text2);"]);
|
|
958
939
|
|
|
959
|
-
// src/components/DropdownSelector/
|
|
960
|
-
import
|
|
940
|
+
// src/components/DropdownSelector/MenuItem/index.tsx
|
|
941
|
+
import { forwardRef as forwardRef18 } from "react";
|
|
961
942
|
|
|
962
943
|
// src/components/DropdownSelector/ListItem/index.tsx
|
|
963
|
-
import
|
|
964
|
-
import { jsx as
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
var ItemDiv = styled4.div.withConfig({
|
|
976
|
-
componentId: "ccl__sc-p1vs75-1"
|
|
977
|
-
})(["display:flex;align-items:center;min-height:40px;cursor:pointer;outline:none;padding-right:16px;padding-left:16px;transition:background-color 0.2s;&:disabled,&[aria-disabled]:not([aria-disabled='false']){opacity:0.32;cursor:default;}:hover,:focus,:focus-within{&:not(disabled):not([aria-disabled='true']){background-color:var(--charcoal-surface3);}}"]);
|
|
944
|
+
import { forwardRef as forwardRef17, useMemo as useMemo8 } from "react";
|
|
945
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
946
|
+
var ListItem = forwardRef17(function ListItem2({
|
|
947
|
+
as,
|
|
948
|
+
className,
|
|
949
|
+
...props
|
|
950
|
+
}, ref) {
|
|
951
|
+
const Component = useMemo8(() => as ?? "li", [as]);
|
|
952
|
+
const classNames = useClassNames("charcoal-list-item", className);
|
|
953
|
+
return /* @__PURE__ */ jsx24(Component, { className: classNames, ref, ...props });
|
|
954
|
+
});
|
|
955
|
+
var ListItem_default = ListItem;
|
|
978
956
|
|
|
979
957
|
// src/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.tsx
|
|
980
|
-
import { useCallback as
|
|
958
|
+
import { useCallback as useCallback8, useContext as useContext5 } from "react";
|
|
981
959
|
|
|
982
960
|
// src/components/DropdownSelector/MenuItem/internals/handleFocusByKeyBoard.tsx
|
|
983
961
|
function handleFocusByKeyBoard(element, parent) {
|
|
@@ -1014,12 +992,12 @@ function useMenuItemHandleKeyDown(value) {
|
|
|
1014
992
|
setValue,
|
|
1015
993
|
root,
|
|
1016
994
|
propsArray
|
|
1017
|
-
} =
|
|
1018
|
-
const setContextValue =
|
|
995
|
+
} = useContext5(MenuListContext);
|
|
996
|
+
const setContextValue = useCallback8(() => {
|
|
1019
997
|
if (value !== void 0)
|
|
1020
998
|
setValue(value);
|
|
1021
999
|
}, [value, setValue]);
|
|
1022
|
-
const handleKeyDown =
|
|
1000
|
+
const handleKeyDown = useCallback8((e) => {
|
|
1023
1001
|
if (e.key === "Enter") {
|
|
1024
1002
|
setContextValue();
|
|
1025
1003
|
} else if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
|
@@ -1054,89 +1032,72 @@ function useMenuItemHandleKeyDown(value) {
|
|
|
1054
1032
|
}
|
|
1055
1033
|
|
|
1056
1034
|
// src/components/DropdownSelector/MenuItem/index.tsx
|
|
1057
|
-
import { jsx as
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
const [handleKeyDown, setContextValue] = useMenuItemHandleKeyDown(
|
|
1065
|
-
return /* @__PURE__ */
|
|
1066
|
-
}
|
|
1035
|
+
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
1036
|
+
var MenuItem = forwardRef18(function MenuItem2({
|
|
1037
|
+
className,
|
|
1038
|
+
value,
|
|
1039
|
+
disabled,
|
|
1040
|
+
...props
|
|
1041
|
+
}, ref) {
|
|
1042
|
+
const [handleKeyDown, setContextValue] = useMenuItemHandleKeyDown(value);
|
|
1043
|
+
return /* @__PURE__ */ jsx25(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 });
|
|
1044
|
+
});
|
|
1045
|
+
var MenuItem_default = MenuItem;
|
|
1067
1046
|
|
|
1068
|
-
// src/components/DropdownSelector/DropdownMenuItem.tsx
|
|
1069
|
-
import { useContext as
|
|
1070
|
-
import { jsx as
|
|
1047
|
+
// src/components/DropdownSelector/DropdownMenuItem/index.tsx
|
|
1048
|
+
import { useContext as useContext6 } from "react";
|
|
1049
|
+
import { jsx as jsx26, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1071
1050
|
function DropdownMenuItem(props) {
|
|
1072
1051
|
const {
|
|
1073
1052
|
value: ctxValue
|
|
1074
|
-
} =
|
|
1053
|
+
} = useContext6(MenuListContext);
|
|
1075
1054
|
const isSelected = props.value === ctxValue;
|
|
1076
1055
|
const {
|
|
1077
1056
|
children,
|
|
1078
1057
|
...rest
|
|
1079
1058
|
} = props;
|
|
1080
|
-
return /* @__PURE__ */
|
|
1081
|
-
isSelected && /* @__PURE__ */
|
|
1082
|
-
/* @__PURE__ */
|
|
1059
|
+
return /* @__PURE__ */ jsxs9(MenuItem_default, { ...rest, "aria-selected": isSelected, children: [
|
|
1060
|
+
isSelected && /* @__PURE__ */ jsx26(Icon_default, { className: "charcoal-dropdown-selector-menu-item-icon", name: "16/Check" }),
|
|
1061
|
+
/* @__PURE__ */ jsx26("span", { className: "charcoal-dropdown-selector-menu-item", "data-selected": isSelected, children: props.children })
|
|
1083
1062
|
] });
|
|
1084
1063
|
}
|
|
1085
|
-
var StyledSpan = styled5.span.withConfig({
|
|
1086
|
-
componentId: "ccl__sc-108wg2j-0"
|
|
1087
|
-
})(["font-size:14px;line-height:22px;color:var(--charcoal-text2);padding:9px 0;display:flex;align-items:center;width:100%;margin-left:", "px;"], ({
|
|
1088
|
-
isSelected
|
|
1089
|
-
}) => isSelected === true ? 0 : 20);
|
|
1090
|
-
var Text2ColorIcon = styled5(Icon_default).withConfig({
|
|
1091
|
-
componentId: "ccl__sc-108wg2j-1"
|
|
1092
|
-
})(["color:var(--charcoal-text2);padding-right:4px;"]);
|
|
1093
1064
|
|
|
1094
1065
|
// src/components/DropdownSelector/MenuItemGroup/index.tsx
|
|
1095
|
-
import
|
|
1096
|
-
import { jsx as jsx26, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1066
|
+
import { jsx as jsx27, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1097
1067
|
function MenuItemGroup(props) {
|
|
1098
|
-
return /* @__PURE__ */
|
|
1099
|
-
/* @__PURE__ */
|
|
1100
|
-
/* @__PURE__ */
|
|
1068
|
+
return /* @__PURE__ */ jsxs10("li", { className: "charcoal-menu-item-group", role: "presentation", children: [
|
|
1069
|
+
/* @__PURE__ */ jsx27("span", { children: props.text }),
|
|
1070
|
+
/* @__PURE__ */ jsx27("ul", { role: "group", children: props.children })
|
|
1101
1071
|
] });
|
|
1102
1072
|
}
|
|
1103
|
-
var TextSpan = styled6.span.withConfig({
|
|
1104
|
-
componentId: "ccl__sc-1ubjfz7-0"
|
|
1105
|
-
})(["display:block;color:var(--charcoal-text3);font-size:12px;font-weight:bold;padding:12px 0 8px 16px;"]);
|
|
1106
|
-
var StyledUl2 = styled6.ul.withConfig({
|
|
1107
|
-
componentId: "ccl__sc-1ubjfz7-1"
|
|
1108
|
-
})(["padding-left:0;margin:0;box-sizing:border-box;list-style:none;overflow:hidden;"]);
|
|
1109
|
-
var StyledLi2 = styled6.li.withConfig({
|
|
1110
|
-
componentId: "ccl__sc-1ubjfz7-2"
|
|
1111
|
-
})(["display:block;"]);
|
|
1112
1073
|
|
|
1113
1074
|
// src/components/SegmentedControl/index.tsx
|
|
1114
|
-
import { forwardRef as
|
|
1075
|
+
import { forwardRef as forwardRef19, memo as memo7, useMemo as useMemo9, useRef as useRef10 } from "react";
|
|
1115
1076
|
import { useRadioGroupState } from "@react-stately/radio";
|
|
1116
1077
|
import { useRadio, useRadioGroup } from "@react-aria/radio";
|
|
1117
1078
|
|
|
1118
1079
|
// src/components/SegmentedControl/RadioGroupContext.tsx
|
|
1119
|
-
import { createContext as
|
|
1120
|
-
import { jsx as
|
|
1121
|
-
var RadioContext =
|
|
1080
|
+
import { createContext as createContext5, useContext as useContext7 } from "react";
|
|
1081
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
1082
|
+
var RadioContext = createContext5(null);
|
|
1122
1083
|
var RadioProvider = ({
|
|
1123
1084
|
value,
|
|
1124
1085
|
children
|
|
1125
1086
|
}) => {
|
|
1126
|
-
return /* @__PURE__ */
|
|
1087
|
+
return /* @__PURE__ */ jsx28(RadioContext.Provider, { value, children });
|
|
1127
1088
|
};
|
|
1128
1089
|
var useRadioContext = () => {
|
|
1129
|
-
const state =
|
|
1090
|
+
const state = useContext7(RadioContext);
|
|
1130
1091
|
if (state === null)
|
|
1131
1092
|
throw new Error("`<RadioProvider>` is not likely mounted.");
|
|
1132
1093
|
return state;
|
|
1133
1094
|
};
|
|
1134
1095
|
|
|
1135
1096
|
// src/components/SegmentedControl/index.tsx
|
|
1136
|
-
import { jsx as
|
|
1137
|
-
var SegmentedControl =
|
|
1097
|
+
import { jsx as jsx29, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1098
|
+
var SegmentedControl = forwardRef19(function SegmentedControlInner(props, ref) {
|
|
1138
1099
|
const className = useClassNames("charcoal-segmented-control", props.className);
|
|
1139
|
-
const ariaRadioGroupProps =
|
|
1100
|
+
const ariaRadioGroupProps = useMemo9(() => ({
|
|
1140
1101
|
...props,
|
|
1141
1102
|
isDisabled: props.disabled,
|
|
1142
1103
|
isReadOnly: props.readonly,
|
|
@@ -1147,19 +1108,19 @@ var SegmentedControl = forwardRef16(function SegmentedControlInner(props, ref) {
|
|
|
1147
1108
|
const {
|
|
1148
1109
|
radioGroupProps
|
|
1149
1110
|
} = useRadioGroup(ariaRadioGroupProps, state);
|
|
1150
|
-
const segmentedControlItems =
|
|
1111
|
+
const segmentedControlItems = useMemo9(() => {
|
|
1151
1112
|
return props.data.map((d) => typeof d === "string" ? {
|
|
1152
1113
|
value: d,
|
|
1153
1114
|
label: d
|
|
1154
1115
|
} : d);
|
|
1155
1116
|
}, [props.data]);
|
|
1156
|
-
return /* @__PURE__ */
|
|
1117
|
+
return /* @__PURE__ */ jsx29("div", { ref, ...radioGroupProps, className, children: /* @__PURE__ */ jsx29(RadioProvider, { value: state, children: segmentedControlItems.map((item) => /* @__PURE__ */ jsx29(Segmented, { value: item.value, disabled: item.disabled, children: item.label }, item.value)) }) });
|
|
1157
1118
|
});
|
|
1158
|
-
var SegmentedControl_default =
|
|
1119
|
+
var SegmentedControl_default = memo7(SegmentedControl);
|
|
1159
1120
|
var Segmented = (props) => {
|
|
1160
1121
|
const state = useRadioContext();
|
|
1161
1122
|
const ref = useRef10(null);
|
|
1162
|
-
const ariaRadioProps =
|
|
1123
|
+
const ariaRadioProps = useMemo9(() => ({
|
|
1163
1124
|
value: props.value,
|
|
1164
1125
|
isDisabled: props.disabled,
|
|
1165
1126
|
children: props.children
|
|
@@ -1169,20 +1130,20 @@ var Segmented = (props) => {
|
|
|
1169
1130
|
isDisabled,
|
|
1170
1131
|
isSelected
|
|
1171
1132
|
} = useRadio(ariaRadioProps, state, ref);
|
|
1172
|
-
return /* @__PURE__ */
|
|
1173
|
-
/* @__PURE__ */
|
|
1133
|
+
return /* @__PURE__ */ jsxs11("label", { className: "charcoal-segmented-control-radio__label", "aria-disabled": isDisabled || state.isReadOnly, "data-checked": isSelected, children: [
|
|
1134
|
+
/* @__PURE__ */ jsx29("input", { className: "charcoal-segmented-control-radio__input", ...inputProps, ref }),
|
|
1174
1135
|
props.children
|
|
1175
1136
|
] });
|
|
1176
1137
|
};
|
|
1177
1138
|
|
|
1178
1139
|
// src/components/Checkbox/index.tsx
|
|
1179
|
-
import { forwardRef as
|
|
1180
|
-
import { useId as
|
|
1140
|
+
import { forwardRef as forwardRef21, memo as memo9 } from "react";
|
|
1141
|
+
import { useId as useId5 } from "@react-aria/utils";
|
|
1181
1142
|
|
|
1182
1143
|
// src/components/Checkbox/CheckboxInput/index.tsx
|
|
1183
|
-
import { forwardRef as
|
|
1184
|
-
import { jsx as
|
|
1185
|
-
var CheckboxInput =
|
|
1144
|
+
import { forwardRef as forwardRef20, memo as memo8, useCallback as useCallback9 } from "react";
|
|
1145
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
1146
|
+
var CheckboxInput = forwardRef20(function CheckboxInput2({
|
|
1186
1147
|
onChange,
|
|
1187
1148
|
checked,
|
|
1188
1149
|
invalid,
|
|
@@ -1190,19 +1151,19 @@ var CheckboxInput = forwardRef17(function CheckboxInput2({
|
|
|
1190
1151
|
rounded,
|
|
1191
1152
|
...props
|
|
1192
1153
|
}, ref) {
|
|
1193
|
-
const handleChange =
|
|
1154
|
+
const handleChange = useCallback9((e) => {
|
|
1194
1155
|
const el = e.currentTarget;
|
|
1195
1156
|
onChange?.(el.checked);
|
|
1196
1157
|
}, [onChange]);
|
|
1197
1158
|
const classNames = useClassNames("charcoal-checkbox-input", className);
|
|
1198
|
-
return /* @__PURE__ */
|
|
1159
|
+
return /* @__PURE__ */ jsx30("input", { className: classNames, ref, type: "checkbox", onChange: handleChange, "aria-invalid": invalid, checked, "data-rounded": rounded, ...props });
|
|
1199
1160
|
});
|
|
1200
|
-
var CheckboxInput_default =
|
|
1161
|
+
var CheckboxInput_default = memo8(CheckboxInput);
|
|
1201
1162
|
|
|
1202
1163
|
// src/components/Checkbox/CheckboxWithLabel.tsx
|
|
1203
|
-
import
|
|
1204
|
-
import { jsx as
|
|
1205
|
-
var CheckboxWithLabel =
|
|
1164
|
+
import React16 from "react";
|
|
1165
|
+
import { jsx as jsx31, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1166
|
+
var CheckboxWithLabel = React16.memo(function CheckboxWithLabel2({
|
|
1206
1167
|
className,
|
|
1207
1168
|
children,
|
|
1208
1169
|
input,
|
|
@@ -1210,37 +1171,37 @@ var CheckboxWithLabel = React17.memo(function CheckboxWithLabel2({
|
|
|
1210
1171
|
disabled
|
|
1211
1172
|
}) {
|
|
1212
1173
|
const classNames = useClassNames("charcoal-checkbox__label", className);
|
|
1213
|
-
return /* @__PURE__ */
|
|
1174
|
+
return /* @__PURE__ */ jsxs12("label", { htmlFor: id, "aria-disabled": disabled, className: classNames, children: [
|
|
1214
1175
|
input,
|
|
1215
|
-
/* @__PURE__ */
|
|
1176
|
+
/* @__PURE__ */ jsx31("div", { className: "charcoal-checkbox__label_div", children })
|
|
1216
1177
|
] });
|
|
1217
1178
|
});
|
|
1218
1179
|
|
|
1219
1180
|
// src/components/Checkbox/index.tsx
|
|
1220
|
-
import { jsx as
|
|
1221
|
-
var Checkbox =
|
|
1181
|
+
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
1182
|
+
var Checkbox = forwardRef21(function Checkbox2({
|
|
1222
1183
|
disabled,
|
|
1223
1184
|
className,
|
|
1224
1185
|
id,
|
|
1225
1186
|
children,
|
|
1226
1187
|
...props
|
|
1227
1188
|
}, ref) {
|
|
1228
|
-
const htmlId =
|
|
1189
|
+
const htmlId = useId5(id);
|
|
1229
1190
|
const noChildren = children === void 0;
|
|
1230
|
-
const input = /* @__PURE__ */
|
|
1191
|
+
const input = /* @__PURE__ */ jsx32(CheckboxInput_default, { ...props, className: noChildren ? className : void 0, disabled, id: htmlId, ref });
|
|
1231
1192
|
if (noChildren) {
|
|
1232
1193
|
return input;
|
|
1233
1194
|
}
|
|
1234
|
-
return /* @__PURE__ */
|
|
1195
|
+
return /* @__PURE__ */ jsx32(CheckboxWithLabel, { className, disabled, id: htmlId, input, children });
|
|
1235
1196
|
});
|
|
1236
|
-
var Checkbox_default =
|
|
1197
|
+
var Checkbox_default = memo9(Checkbox);
|
|
1237
1198
|
|
|
1238
1199
|
// src/components/TagItem/index.tsx
|
|
1239
|
-
import { forwardRef as
|
|
1200
|
+
import { forwardRef as forwardRef22, memo as memo10, useMemo as useMemo10 } from "react";
|
|
1240
1201
|
import { useObjectRef as useObjectRef2 } from "@react-aria/utils";
|
|
1241
|
-
import { jsx as
|
|
1242
|
-
var TagItem =
|
|
1243
|
-
|
|
1202
|
+
import { jsx as jsx33, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1203
|
+
var TagItem = forwardRef22(function TagItemInner({
|
|
1204
|
+
component,
|
|
1244
1205
|
label,
|
|
1245
1206
|
translatedLabel,
|
|
1246
1207
|
bgColor = "#7ACCB1",
|
|
@@ -1254,24 +1215,23 @@ var TagItem = forwardRef19(function TagItemInner({
|
|
|
1254
1215
|
const className = useClassNames("charcoal-tag-item", "charcoal-tag-item__bg", props.className);
|
|
1255
1216
|
const bgVariant = bgImage !== void 0 && bgImage.length > 0 ? "image" : "color";
|
|
1256
1217
|
const bg = bgVariant === "color" ? bgColor : `url(${bgImage ?? ""})`;
|
|
1257
|
-
const Component =
|
|
1258
|
-
return /* @__PURE__ */
|
|
1218
|
+
const Component = useMemo10(() => component ?? "button", [component]);
|
|
1219
|
+
return /* @__PURE__ */ jsxs13(Component, { ...props, ref, className, "data-state": status, "data-bg-variant": bgVariant, "data-size": hasTranslatedLabel ? "M" : size, style: {
|
|
1259
1220
|
"--charcoal-tag-item-bg": bg
|
|
1260
1221
|
}, children: [
|
|
1261
|
-
/* @__PURE__ */
|
|
1262
|
-
hasTranslatedLabel && /* @__PURE__ */
|
|
1263
|
-
/* @__PURE__ */
|
|
1222
|
+
/* @__PURE__ */ jsxs13("div", { className: "charcoal-tag-item__label", "data-has-translate": hasTranslatedLabel, children: [
|
|
1223
|
+
hasTranslatedLabel && /* @__PURE__ */ jsx33("span", { className: "charcoal-tag-item__label__translated", children: translatedLabel }),
|
|
1224
|
+
/* @__PURE__ */ jsx33("span", { className: "charcoal-tag-item__label__text", "data-has-translate": hasTranslatedLabel, children: label })
|
|
1264
1225
|
] }),
|
|
1265
|
-
status === "active" && /* @__PURE__ */
|
|
1226
|
+
status === "active" && /* @__PURE__ */ jsx33(Icon_default, { name: "16/Remove" })
|
|
1266
1227
|
] });
|
|
1267
1228
|
});
|
|
1268
|
-
var TagItem_default =
|
|
1229
|
+
var TagItem_default = memo10(TagItem);
|
|
1269
1230
|
export {
|
|
1270
1231
|
Button_default as Button,
|
|
1271
1232
|
CharcoalProvider,
|
|
1272
1233
|
Checkbox_default as Checkbox,
|
|
1273
1234
|
Clickable_default as Clickable,
|
|
1274
|
-
ComponentAbstraction,
|
|
1275
1235
|
DropdownMenuItem,
|
|
1276
1236
|
DropdownSelector,
|
|
1277
1237
|
Icon_default as Icon,
|
|
@@ -1293,7 +1253,6 @@ export {
|
|
|
1293
1253
|
Switch_default as Switch,
|
|
1294
1254
|
TagItem_default as TagItem,
|
|
1295
1255
|
TextArea_default as TextArea,
|
|
1296
|
-
TextField_default as TextField
|
|
1297
|
-
useComponentAbstraction
|
|
1256
|
+
TextField_default as TextField
|
|
1298
1257
|
};
|
|
1299
1258
|
//# sourceMappingURL=index.esm.js.map
|