@usefui/components 1.5.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/CHANGELOG.md +233 -0
- package/LICENSE +21 -0
- package/README.md +0 -0
- package/babel.config.js +12 -0
- package/dist/index.d.mts +1299 -0
- package/dist/index.d.ts +1299 -0
- package/dist/index.js +3701 -0
- package/dist/index.mjs +3586 -0
- package/package.json +44 -0
- package/src/__tests__/Accordion.test.tsx +106 -0
- package/src/__tests__/Avatar.test.tsx +89 -0
- package/src/__tests__/Badge.test.tsx +58 -0
- package/src/__tests__/Button.test.tsx +88 -0
- package/src/__tests__/Checkbox.test.tsx +106 -0
- package/src/__tests__/Collapsible.test.tsx +79 -0
- package/src/__tests__/Dialog.test.tsx +109 -0
- package/src/__tests__/Dropdown.test.tsx +159 -0
- package/src/__tests__/Field.test.tsx +100 -0
- package/src/__tests__/OTPField.test.tsx +199 -0
- package/src/__tests__/Overlay.test.tsx +70 -0
- package/src/__tests__/Page.test.tsx +98 -0
- package/src/__tests__/Portal.test.tsx +28 -0
- package/src/__tests__/Sheet.test.tsx +125 -0
- package/src/__tests__/Switch.test.tsx +90 -0
- package/src/__tests__/Tabs.test.tsx +129 -0
- package/src/__tests__/Toggle.test.tsx +67 -0
- package/src/__tests__/Toolbar.test.tsx +147 -0
- package/src/__tests__/Tooltip.test.tsx +88 -0
- package/src/accordion/Accordion.stories.tsx +89 -0
- package/src/accordion/hooks/index.tsx +39 -0
- package/src/accordion/index.tsx +170 -0
- package/src/avatar/Avatar.stories.tsx +62 -0
- package/src/avatar/index.tsx +90 -0
- package/src/avatar/styles/index.ts +79 -0
- package/src/badge/Badge.stories.tsx +60 -0
- package/src/badge/index.tsx +58 -0
- package/src/badge/styles/index.ts +109 -0
- package/src/button/Button.stories.tsx +47 -0
- package/src/button/index.tsx +79 -0
- package/src/button/styles/index.ts +180 -0
- package/src/checkbox/Checkbox.stories.tsx +100 -0
- package/src/checkbox/hooks/index.tsx +40 -0
- package/src/checkbox/index.tsx +147 -0
- package/src/checkbox/styles/index.ts +139 -0
- package/src/collapsible/Collapsible.stories.tsx +95 -0
- package/src/collapsible/hooks/index.tsx +50 -0
- package/src/collapsible/index.tsx +137 -0
- package/src/dialog/Dialog.stories.tsx +73 -0
- package/src/dialog/hooks/index.tsx +35 -0
- package/src/dialog/index.tsx +221 -0
- package/src/dialog/styles/index.ts +72 -0
- package/src/divider/index.ts +10 -0
- package/src/dropdown/Dropdown.stories.tsx +100 -0
- package/src/dropdown/hooks/index.tsx +64 -0
- package/src/dropdown/index.tsx +316 -0
- package/src/dropdown/styles/index.ts +90 -0
- package/src/field/Field.stories.tsx +146 -0
- package/src/field/hooks/index.tsx +28 -0
- package/src/field/index.tsx +183 -0
- package/src/field/styles/index.ts +166 -0
- package/src/index.ts +33 -0
- package/src/otp-field/OTPField.stories.tsx +50 -0
- package/src/otp-field/hooks/index.tsx +13 -0
- package/src/otp-field/index.tsx +234 -0
- package/src/otp-field/styles/index.ts +33 -0
- package/src/otp-field/types/index.ts +23 -0
- package/src/overlay/Overlay.stories.tsx +59 -0
- package/src/overlay/index.tsx +58 -0
- package/src/overlay/styles/index.ts +26 -0
- package/src/page/Page.stories.tsx +85 -0
- package/src/page/index.tsx +265 -0
- package/src/page/styles/index.ts +59 -0
- package/src/portal/Portal.stories.tsx +27 -0
- package/src/portal/index.tsx +36 -0
- package/src/scrollarea/Scrollarea.stories.tsx +99 -0
- package/src/scrollarea/index.tsx +27 -0
- package/src/scrollarea/styles/index.ts +71 -0
- package/src/sheet/Sheet.stories.tsx +86 -0
- package/src/sheet/hooks/index.tsx +47 -0
- package/src/sheet/index.tsx +190 -0
- package/src/sheet/styles/index.ts +69 -0
- package/src/switch/Switch.stories.tsx +96 -0
- package/src/switch/hooks/index.tsx +33 -0
- package/src/switch/index.tsx +122 -0
- package/src/switch/styles/index.ts +118 -0
- package/src/table/index.tsx +138 -0
- package/src/table/styles/index.ts +48 -0
- package/src/tabs/Tabs.stories.tsx +87 -0
- package/src/tabs/hooks/index.tsx +35 -0
- package/src/tabs/index.tsx +161 -0
- package/src/tabs/styles/index.ts +9 -0
- package/src/toggle/Toggle.stories.tsx +118 -0
- package/src/toggle/index.tsx +55 -0
- package/src/toggle/styles/index.ts +0 -0
- package/src/toolbar/Toolbar.stories.tsx +89 -0
- package/src/toolbar/hooks/index.tsx +35 -0
- package/src/toolbar/index.tsx +243 -0
- package/src/toolbar/styles/index.ts +129 -0
- package/src/tooltip/Tooltip.stories.tsx +60 -0
- package/src/tooltip/index.tsx +177 -0
- package/src/tooltip/styles/index.ts +38 -0
- package/src/utils/index.ts +2 -0
- package/tsconfig.json +18 -0
- package/vitest.config.ts +16 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,3586 @@
|
|
|
1
|
+
// src/accordion/index.tsx
|
|
2
|
+
import React3 from "react";
|
|
3
|
+
|
|
4
|
+
// src/accordion/hooks/index.tsx
|
|
5
|
+
import React, { useState, createContext, useContext } from "react";
|
|
6
|
+
var defaultComponentAPI = {
|
|
7
|
+
id: "",
|
|
8
|
+
states: {},
|
|
9
|
+
methods: {}
|
|
10
|
+
};
|
|
11
|
+
var AccordionContext = createContext(defaultComponentAPI);
|
|
12
|
+
var useAccordion = () => useContext(AccordionContext);
|
|
13
|
+
var AccordionProvider = ({
|
|
14
|
+
children
|
|
15
|
+
}) => {
|
|
16
|
+
const context = useAccordionProvider();
|
|
17
|
+
return /* @__PURE__ */ React.createElement(AccordionContext.Provider, { value: context }, children);
|
|
18
|
+
};
|
|
19
|
+
function useAccordionProvider() {
|
|
20
|
+
const [value, setValue] = useState(null);
|
|
21
|
+
const accordionId = React.useId();
|
|
22
|
+
return {
|
|
23
|
+
id: accordionId,
|
|
24
|
+
states: {
|
|
25
|
+
value
|
|
26
|
+
},
|
|
27
|
+
methods: {
|
|
28
|
+
applyValue: (value2) => setValue(value2),
|
|
29
|
+
getAccordionId: ({ value: value2, type }) => `${accordionId}-${type}-${value2}`
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// src/button/index.tsx
|
|
35
|
+
import React2 from "react";
|
|
36
|
+
|
|
37
|
+
// src/button/styles/index.ts
|
|
38
|
+
import styled, { css } from "styled-components";
|
|
39
|
+
var ButtonDefaultStyles = css`
|
|
40
|
+
cursor: pointer;
|
|
41
|
+
position: relative;
|
|
42
|
+
display: flex;
|
|
43
|
+
align-items: center;
|
|
44
|
+
justify-content: center;
|
|
45
|
+
gap: var(--measurement-medium-30);
|
|
46
|
+
font-size: var(--fontsize-medium-20);
|
|
47
|
+
height: fit-content;
|
|
48
|
+
font-weight: 500;
|
|
49
|
+
line-height: 1;
|
|
50
|
+
letter-spacing: calc(
|
|
51
|
+
var(--fontsize-small-10) - ((var(--fontsize-small-10) * 1.066))
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
border: var(--measurement-small-10) solid transparent;
|
|
55
|
+
backdrop-filter: blur(var(--measurement-small-10));
|
|
56
|
+
|
|
57
|
+
width: fit-content;
|
|
58
|
+
transition: all ease-in-out 0.2s;
|
|
59
|
+
|
|
60
|
+
span,
|
|
61
|
+
img {
|
|
62
|
+
opacity: 0.6;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
&:hover,
|
|
66
|
+
&:focus,
|
|
67
|
+
&:active {
|
|
68
|
+
span,
|
|
69
|
+
img {
|
|
70
|
+
opacity: 1;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
&:disabled {
|
|
75
|
+
cursor: not-allowed;
|
|
76
|
+
opacity: 0.6;
|
|
77
|
+
}
|
|
78
|
+
`;
|
|
79
|
+
var ButtonIconStyles = css`
|
|
80
|
+
svg {
|
|
81
|
+
width: var(--fontsize-medium-20);
|
|
82
|
+
height: var(--fontsize-medium-20);
|
|
83
|
+
fill: currentColor;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
svg {
|
|
87
|
+
opacity: 0.6;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
&:hover,
|
|
91
|
+
&:focus,
|
|
92
|
+
&:active {
|
|
93
|
+
svg {
|
|
94
|
+
opacity: 1;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
&[data-variant="primary"] {
|
|
99
|
+
svg {
|
|
100
|
+
fill: var(--body-color);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
`;
|
|
104
|
+
var ButtonVariantsStyles = css`
|
|
105
|
+
&[data-variant="primary"] {
|
|
106
|
+
color: var(--body-color) !important;
|
|
107
|
+
background-color: var(--font-color);
|
|
108
|
+
|
|
109
|
+
&:hover,
|
|
110
|
+
&:focus,
|
|
111
|
+
&:active {
|
|
112
|
+
color: var(--body-color);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
&[data-variant="secondary"] {
|
|
116
|
+
color: var(--font-color-alpha-60);
|
|
117
|
+
background-color: var(--body-color);
|
|
118
|
+
border-color: var(--font-color-alpha-10);
|
|
119
|
+
|
|
120
|
+
&:hover,
|
|
121
|
+
&:focus,
|
|
122
|
+
&:active {
|
|
123
|
+
color: var(--font-color);
|
|
124
|
+
border-color: var(--font-color-alpha-30);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
&[data-variant="tertiary"] {
|
|
128
|
+
color: var(--font-color-alpha-60);
|
|
129
|
+
border-color: var(--font-color-alpha-10);
|
|
130
|
+
background-color: transparent;
|
|
131
|
+
|
|
132
|
+
&:hover,
|
|
133
|
+
&:focus,
|
|
134
|
+
&:active {
|
|
135
|
+
color: var(--font-color);
|
|
136
|
+
background-color: var(--font-color-alpha-10);
|
|
137
|
+
border-color: transparent;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
&[data-variant="border"] {
|
|
141
|
+
color: var(--font-color-alpha-60);
|
|
142
|
+
background-color: transparent;
|
|
143
|
+
border-color: var(--font-color-alpha-10);
|
|
144
|
+
|
|
145
|
+
&:hover,
|
|
146
|
+
&:focus,
|
|
147
|
+
&:active {
|
|
148
|
+
color: var(--font-color);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
&[data-variant="mono"] {
|
|
152
|
+
color: var(--font-color-alpha-80);
|
|
153
|
+
background-color: var(--font-color-alpha-10);
|
|
154
|
+
|
|
155
|
+
&:hover,
|
|
156
|
+
&:focus,
|
|
157
|
+
&:active {
|
|
158
|
+
color: var(--font-color);
|
|
159
|
+
border-color: var(--font-color-alpha-10);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
&[data-variant="ghost"] {
|
|
163
|
+
border: none;
|
|
164
|
+
padding: 0;
|
|
165
|
+
background-color: transparent;
|
|
166
|
+
min-width: fit-content;
|
|
167
|
+
min-height: var(--measurement-medium-60);
|
|
168
|
+
color: var(--font-color-alpha-60);
|
|
169
|
+
|
|
170
|
+
&:hover,
|
|
171
|
+
&:focus,
|
|
172
|
+
&:active {
|
|
173
|
+
color: var(--font-color);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
`;
|
|
177
|
+
var ButtonSizeStyles = css`
|
|
178
|
+
&[data-size="small"] {
|
|
179
|
+
border-radius: var(--measurement-medium-20);
|
|
180
|
+
font-size: var(--fontsize-medium-10);
|
|
181
|
+
|
|
182
|
+
gap: var(--measurement-medium-10);
|
|
183
|
+
padding: var(--measurement-medium-10) var(--measurement-medium-30);
|
|
184
|
+
min-width: var(--measurement-medium-60);
|
|
185
|
+
min-height: var(--measurement-medium-60);
|
|
186
|
+
|
|
187
|
+
svg {
|
|
188
|
+
width: var(--fontsize-medium-10);
|
|
189
|
+
height: var(--fontsize-medium-10);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
&[data-size="medium"] {
|
|
193
|
+
border-radius: var(--measurement-medium-30);
|
|
194
|
+
padding: var(--measurement-medium-10) var(--measurement-medium-60);
|
|
195
|
+
min-width: var(--measurement-medium-90);
|
|
196
|
+
min-height: var(--measurement-medium-80);
|
|
197
|
+
}
|
|
198
|
+
&[data-size="large"] {
|
|
199
|
+
border-radius: var(--measurement-medium-30);
|
|
200
|
+
padding: var(--measurement-medium-10) var(--measurement-medium-60);
|
|
201
|
+
min-width: var(--measurement-medium-90);
|
|
202
|
+
min-height: var(--measurement-medium-90);
|
|
203
|
+
}
|
|
204
|
+
`;
|
|
205
|
+
var ButtonWrapper = styled.button`
|
|
206
|
+
&[data-raw="false"] {
|
|
207
|
+
${ButtonDefaultStyles}
|
|
208
|
+
${ButtonSizeStyles}
|
|
209
|
+
${ButtonVariantsStyles}
|
|
210
|
+
|
|
211
|
+
&[data-rawIcon="false"] {
|
|
212
|
+
${ButtonIconStyles}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
`;
|
|
216
|
+
|
|
217
|
+
// src/button/index.tsx
|
|
218
|
+
var Button = React2.forwardRef(
|
|
219
|
+
(props, forwardedRef) => {
|
|
220
|
+
const {
|
|
221
|
+
name,
|
|
222
|
+
variant = "mono" /* Mono */,
|
|
223
|
+
sizing = "medium" /* Medium */,
|
|
224
|
+
raw,
|
|
225
|
+
rawicon,
|
|
226
|
+
children,
|
|
227
|
+
...restProps
|
|
228
|
+
} = props;
|
|
229
|
+
const defaultName = "button";
|
|
230
|
+
const ariaLabel = `${name ?? defaultName}-action`;
|
|
231
|
+
const disabledState = props.disabled ?? false;
|
|
232
|
+
const buttonType = props.type ?? "button";
|
|
233
|
+
const buttonDescription = `${ariaLabel}:${buttonType}`;
|
|
234
|
+
const buttonStateDescription = `disabled:${disabledState}`;
|
|
235
|
+
const ButtonFullDesc = `${buttonDescription}/${buttonStateDescription}`;
|
|
236
|
+
return /* @__PURE__ */ React2.createElement(
|
|
237
|
+
ButtonWrapper,
|
|
238
|
+
{
|
|
239
|
+
ref: forwardedRef,
|
|
240
|
+
role: "button",
|
|
241
|
+
type: buttonType,
|
|
242
|
+
name: name ?? defaultName,
|
|
243
|
+
"aria-label": ariaLabel,
|
|
244
|
+
"aria-description": ButtonFullDesc,
|
|
245
|
+
"aria-disabled": disabledState,
|
|
246
|
+
"data-variant": variant,
|
|
247
|
+
"data-size": sizing,
|
|
248
|
+
"data-raw": Boolean(raw),
|
|
249
|
+
"data-rawicon": Boolean(rawicon),
|
|
250
|
+
tabIndex: 0,
|
|
251
|
+
...restProps
|
|
252
|
+
},
|
|
253
|
+
children
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
);
|
|
257
|
+
Button.displayName = "Button";
|
|
258
|
+
|
|
259
|
+
// src/accordion/index.tsx
|
|
260
|
+
var Accordion = (props) => {
|
|
261
|
+
const { children, ...restProps } = props;
|
|
262
|
+
const { id } = useAccordion();
|
|
263
|
+
return /* @__PURE__ */ React3.createElement("div", { id, ...restProps }, children);
|
|
264
|
+
};
|
|
265
|
+
Accordion.displayName = "Accordion";
|
|
266
|
+
var AccordionRoot = ({ children }) => {
|
|
267
|
+
return /* @__PURE__ */ React3.createElement(AccordionProvider, null, children);
|
|
268
|
+
};
|
|
269
|
+
AccordionRoot.displayName = "Accordion.Root";
|
|
270
|
+
var AccordionTrigger = (props) => {
|
|
271
|
+
const { value, disabled, onClick, children, ...restProps } = props;
|
|
272
|
+
const { states, methods } = useAccordion();
|
|
273
|
+
const { getAccordionId, applyValue } = methods;
|
|
274
|
+
const hasSameValueAsContext = value === states.value;
|
|
275
|
+
const IdHandler = {
|
|
276
|
+
trigger: getAccordionId && getAccordionId({ value, type: "trigger" }),
|
|
277
|
+
content: getAccordionId && getAccordionId({ value, type: "content" })
|
|
278
|
+
};
|
|
279
|
+
const handleClick = (event) => {
|
|
280
|
+
if (!disabled) {
|
|
281
|
+
onClick && onClick(event);
|
|
282
|
+
if (applyValue) {
|
|
283
|
+
const unchangedValue = hasSameValueAsContext && states.value !== null;
|
|
284
|
+
if (unchangedValue) applyValue(null);
|
|
285
|
+
else applyValue(value);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
return /* @__PURE__ */ React3.createElement(
|
|
290
|
+
Button,
|
|
291
|
+
{
|
|
292
|
+
id: String(IdHandler.trigger),
|
|
293
|
+
value,
|
|
294
|
+
disabled: disabled ?? false,
|
|
295
|
+
onClick: handleClick,
|
|
296
|
+
"aria-expanded": hasSameValueAsContext,
|
|
297
|
+
"aria-controls": String(IdHandler.content),
|
|
298
|
+
"data-state": hasSameValueAsContext ? "expanded" : "collapsed",
|
|
299
|
+
variant: props.variant ?? "ghost" /* Ghost */,
|
|
300
|
+
...restProps
|
|
301
|
+
},
|
|
302
|
+
children
|
|
303
|
+
);
|
|
304
|
+
};
|
|
305
|
+
AccordionTrigger.displayName = "Accordion.Trigger";
|
|
306
|
+
var AccordionContent = (props) => {
|
|
307
|
+
const { defaultOpen = false, value, children, ...restProps } = props;
|
|
308
|
+
const { states, methods } = useAccordion();
|
|
309
|
+
const { getAccordionId, applyValue } = methods;
|
|
310
|
+
const hasSameValueAsContext = value === states.value;
|
|
311
|
+
const IdHandler = {
|
|
312
|
+
trigger: getAccordionId && getAccordionId({ value, type: "trigger" }),
|
|
313
|
+
content: getAccordionId && getAccordionId({ value, type: "content" })
|
|
314
|
+
};
|
|
315
|
+
React3.useEffect(() => {
|
|
316
|
+
if (defaultOpen && !hasSameValueAsContext && applyValue) applyValue(value);
|
|
317
|
+
}, []);
|
|
318
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, hasSameValueAsContext && /* @__PURE__ */ React3.createElement(
|
|
319
|
+
"div",
|
|
320
|
+
{
|
|
321
|
+
role: "article",
|
|
322
|
+
id: String(IdHandler.content),
|
|
323
|
+
"aria-labelledby": String(IdHandler.trigger),
|
|
324
|
+
"aria-expanded": hasSameValueAsContext,
|
|
325
|
+
"data-value": value,
|
|
326
|
+
...restProps
|
|
327
|
+
},
|
|
328
|
+
children
|
|
329
|
+
));
|
|
330
|
+
};
|
|
331
|
+
AccordionContent.displayName = "Accordion.Content";
|
|
332
|
+
Accordion.Root = AccordionRoot;
|
|
333
|
+
Accordion.Trigger = AccordionTrigger;
|
|
334
|
+
Accordion.Content = AccordionContent;
|
|
335
|
+
|
|
336
|
+
// src/avatar/index.tsx
|
|
337
|
+
import React4 from "react";
|
|
338
|
+
|
|
339
|
+
// src/avatar/styles/index.ts
|
|
340
|
+
import styled2, { css as css2 } from "styled-components";
|
|
341
|
+
var AvatarSizesStyles = css2`
|
|
342
|
+
&[data-size="small"] {
|
|
343
|
+
width: var(--measurement-large-10);
|
|
344
|
+
height: var(--measurement-large-10);
|
|
345
|
+
min-width: var(--measurement-large-10);
|
|
346
|
+
min-height: var(--measurement-large-10);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
&[data-size="medium"] {
|
|
350
|
+
width: var(--measurement-medium-90);
|
|
351
|
+
height: var(--measurement-medium-90);
|
|
352
|
+
min-width: var(--measurement-medium-90);
|
|
353
|
+
min-height: var(--measurement-medium-90);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
&[data-size="large"] {
|
|
357
|
+
width: var(--measurement-large-20);
|
|
358
|
+
height: var(--measurement-large-20);
|
|
359
|
+
min-width: var(--measurement-large-20);
|
|
360
|
+
min-height: var(--measurement-large-20);
|
|
361
|
+
}
|
|
362
|
+
`;
|
|
363
|
+
var AvatarStatusesStyles = css2`
|
|
364
|
+
&[data-status="online"] {
|
|
365
|
+
fill: var(--shade-green-10);
|
|
366
|
+
stroke: var(--shade-green-20);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
&[data-status="away"] {
|
|
370
|
+
fill: var(--color-yellow);
|
|
371
|
+
stroke: var(--shade-yellow-10);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
&[data-status="busy"] {
|
|
375
|
+
fill: var(--color-red);
|
|
376
|
+
stroke: var(--shade-red-10);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
&[data-status="offline"] {
|
|
380
|
+
fill: var(--body-color);
|
|
381
|
+
stroke: var(--font-color-alpha-10);
|
|
382
|
+
}
|
|
383
|
+
`;
|
|
384
|
+
var AvatarWrapper = styled2.div`
|
|
385
|
+
&[data-raw="false"] {
|
|
386
|
+
position: relative;
|
|
387
|
+
display: flex;
|
|
388
|
+
align-items: center;
|
|
389
|
+
justify-content: center;
|
|
390
|
+
|
|
391
|
+
background-color: var(--body-color);
|
|
392
|
+
border-radius: 100%;
|
|
393
|
+
|
|
394
|
+
img {
|
|
395
|
+
width: inherit;
|
|
396
|
+
height: inherit;
|
|
397
|
+
min-width: inherit;
|
|
398
|
+
min-height: inherit;
|
|
399
|
+
border-radius: 100%;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
${AvatarSizesStyles}
|
|
403
|
+
}
|
|
404
|
+
`;
|
|
405
|
+
var StatusWrapper = styled2.svg`
|
|
406
|
+
--status-position: calc(
|
|
407
|
+
var(--measurement-medium-10) - (var(--measurement-medium-10) * 2)
|
|
408
|
+
);
|
|
409
|
+
|
|
410
|
+
position: absolute;
|
|
411
|
+
stroke-width: var(--measurement-small-30);
|
|
412
|
+
bottom: var(--status-position);
|
|
413
|
+
right: var(--status-position);
|
|
414
|
+
|
|
415
|
+
${AvatarStatusesStyles}
|
|
416
|
+
`;
|
|
417
|
+
|
|
418
|
+
// src/avatar/index.tsx
|
|
419
|
+
var AvataStatusEnum = /* @__PURE__ */ ((AvataStatusEnum2) => {
|
|
420
|
+
AvataStatusEnum2["Online"] = "online";
|
|
421
|
+
AvataStatusEnum2["Away"] = "away";
|
|
422
|
+
AvataStatusEnum2["Busy"] = "busy";
|
|
423
|
+
AvataStatusEnum2["Offline"] = "offline";
|
|
424
|
+
return AvataStatusEnum2;
|
|
425
|
+
})(AvataStatusEnum || {});
|
|
426
|
+
var Avatar = (props) => {
|
|
427
|
+
const {
|
|
428
|
+
raw,
|
|
429
|
+
sizing = "medium" /* Medium */,
|
|
430
|
+
status,
|
|
431
|
+
src,
|
|
432
|
+
alt,
|
|
433
|
+
children,
|
|
434
|
+
...restProps
|
|
435
|
+
} = props;
|
|
436
|
+
const sizeLabel = sizing ?? "medium" /* Medium */;
|
|
437
|
+
return /* @__PURE__ */ React4.createElement(
|
|
438
|
+
AvatarWrapper,
|
|
439
|
+
{
|
|
440
|
+
"data-raw": Boolean(raw),
|
|
441
|
+
"data-size": sizing,
|
|
442
|
+
"data-status": status,
|
|
443
|
+
"aria-label": props["aria-label"] ?? `${sizeLabel}-user-avatar`,
|
|
444
|
+
...restProps
|
|
445
|
+
},
|
|
446
|
+
!children && src && /* @__PURE__ */ React4.createElement(
|
|
447
|
+
"img",
|
|
448
|
+
{
|
|
449
|
+
"aria-label": `${sizeLabel}-user-avatar-image`,
|
|
450
|
+
alt: alt ?? `${sizeLabel}-user-avatar-image`,
|
|
451
|
+
src
|
|
452
|
+
}
|
|
453
|
+
),
|
|
454
|
+
children,
|
|
455
|
+
status && /* @__PURE__ */ React4.createElement(
|
|
456
|
+
StatusWrapper,
|
|
457
|
+
{
|
|
458
|
+
role: "img",
|
|
459
|
+
"aria-label": `${sizing}-user-avatar-status`,
|
|
460
|
+
"aria-labelledby": "title desc",
|
|
461
|
+
"data-status": status,
|
|
462
|
+
height: "16",
|
|
463
|
+
width: "16"
|
|
464
|
+
},
|
|
465
|
+
/* @__PURE__ */ React4.createElement("title", null, "Activity status"),
|
|
466
|
+
/* @__PURE__ */ React4.createElement("desc", null, status),
|
|
467
|
+
/* @__PURE__ */ React4.createElement("circle", { role: "presentation", cx: "8", cy: "8", r: "6" })
|
|
468
|
+
)
|
|
469
|
+
);
|
|
470
|
+
};
|
|
471
|
+
Avatar.displayName = "Avatar";
|
|
472
|
+
|
|
473
|
+
// src/badge/index.tsx
|
|
474
|
+
import React5 from "react";
|
|
475
|
+
|
|
476
|
+
// src/badge/styles/index.ts
|
|
477
|
+
import styled3, { css as css3 } from "styled-components";
|
|
478
|
+
var BadgeBaseStyles = css3`
|
|
479
|
+
display: inline-flex;
|
|
480
|
+
align-items: center;
|
|
481
|
+
justify-content: center;
|
|
482
|
+
gap: var(--measurement-medium-10);
|
|
483
|
+
min-width: var(--measurement-medium-60);
|
|
484
|
+
min-height: var(--measurement-medium-60);
|
|
485
|
+
width: fit-content;
|
|
486
|
+
|
|
487
|
+
border: var(--measurement-small-10) solid transparent;
|
|
488
|
+
|
|
489
|
+
font-size: var(--fontsize-small-60);
|
|
490
|
+
padding: var(--measurement-medium-10) var(--measurement-medium-30);
|
|
491
|
+
font-weight: 500;
|
|
492
|
+
transition: all ease-in-out 0.2s;
|
|
493
|
+
`;
|
|
494
|
+
var BadgeVariantStyles = css3`
|
|
495
|
+
border: var(--measurement-small-10) solid transparent;
|
|
496
|
+
|
|
497
|
+
&[data-variant="primary"] {
|
|
498
|
+
background-color: var(--font-color);
|
|
499
|
+
color: var(--body-color);
|
|
500
|
+
|
|
501
|
+
&:hover,
|
|
502
|
+
&:focus {
|
|
503
|
+
border-color: var(--font-color-alpha-10);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
&[data-variant="secondary"] {
|
|
507
|
+
background-color: var(--font-color-alpha-10);
|
|
508
|
+
color: var(--font-color-alpha-60);
|
|
509
|
+
|
|
510
|
+
&:hover,
|
|
511
|
+
&:focus {
|
|
512
|
+
color: var(--font-color);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
&[data-variant="border"] {
|
|
516
|
+
background-color: transparent;
|
|
517
|
+
border-color: var(--font-color-alpha-10);
|
|
518
|
+
color: var(--font-color-alpha-60);
|
|
519
|
+
|
|
520
|
+
&:hover,
|
|
521
|
+
&:focus {
|
|
522
|
+
color: var(--font-color);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
&[data-variant="error"] {
|
|
526
|
+
background-color: var(--alpha-red-10);
|
|
527
|
+
color: var(--alpha-red-80);
|
|
528
|
+
|
|
529
|
+
&:hover,
|
|
530
|
+
&:focus {
|
|
531
|
+
background-color: var(--alpha-red-10);
|
|
532
|
+
color: var(--color-red);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
&[data-variant="warning"] {
|
|
536
|
+
background-color: var(--alpha-orange-10);
|
|
537
|
+
color: var(--alpha-orange-80);
|
|
538
|
+
|
|
539
|
+
&:hover,
|
|
540
|
+
&:focus {
|
|
541
|
+
background-color: var(--alpha-orange-10);
|
|
542
|
+
color: var(--color-orange);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
&[data-variant="success"] {
|
|
546
|
+
background-color: var(--alpha-green-10);
|
|
547
|
+
color: var(--alpha-green-80);
|
|
548
|
+
|
|
549
|
+
&:hover,
|
|
550
|
+
&:focus {
|
|
551
|
+
background-color: var(--alpha-green-10);
|
|
552
|
+
color: var(--color-green);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
&[data-variant="meta"] {
|
|
556
|
+
background-color: var(--alpha-blue-10);
|
|
557
|
+
color: var(--alpha-blue-80);
|
|
558
|
+
|
|
559
|
+
&:hover,
|
|
560
|
+
&:focus {
|
|
561
|
+
background-color: var(--alpha-blue-10);
|
|
562
|
+
color: var(--color-blue);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
`;
|
|
566
|
+
var BadgeShapeStyles = css3`
|
|
567
|
+
&[data-shape="square"] {
|
|
568
|
+
border-radius: 0;
|
|
569
|
+
}
|
|
570
|
+
&[data-shape="smooth"] {
|
|
571
|
+
border-radius: var(--measurement-medium-20);
|
|
572
|
+
}
|
|
573
|
+
&[data-shape="round"] {
|
|
574
|
+
border-radius: var(--measurement-large-90);
|
|
575
|
+
}
|
|
576
|
+
`;
|
|
577
|
+
var BadgeWrapper = styled3.div`
|
|
578
|
+
&[data-raw="false"] {
|
|
579
|
+
${BadgeBaseStyles}
|
|
580
|
+
${BadgeVariantStyles}
|
|
581
|
+
${BadgeShapeStyles}
|
|
582
|
+
}
|
|
583
|
+
`;
|
|
584
|
+
|
|
585
|
+
// src/badge/index.tsx
|
|
586
|
+
var Badge = (props) => {
|
|
587
|
+
const {
|
|
588
|
+
raw = false,
|
|
589
|
+
variant = "primary",
|
|
590
|
+
shape = "smooth",
|
|
591
|
+
children,
|
|
592
|
+
...restProps
|
|
593
|
+
} = props;
|
|
594
|
+
return /* @__PURE__ */ React5.createElement(
|
|
595
|
+
BadgeWrapper,
|
|
596
|
+
{
|
|
597
|
+
"data-raw": raw,
|
|
598
|
+
"data-variant": variant,
|
|
599
|
+
"data-shape": shape,
|
|
600
|
+
...restProps
|
|
601
|
+
},
|
|
602
|
+
children
|
|
603
|
+
);
|
|
604
|
+
};
|
|
605
|
+
Badge.displayName = "Badge";
|
|
606
|
+
|
|
607
|
+
// src/checkbox/index.tsx
|
|
608
|
+
import React7 from "react";
|
|
609
|
+
|
|
610
|
+
// src/checkbox/hooks/index.tsx
|
|
611
|
+
import React6, { useState as useState2, createContext as createContext2, useContext as useContext2 } from "react";
|
|
612
|
+
var defaultComponentAPI2 = {
|
|
613
|
+
id: "",
|
|
614
|
+
states: {},
|
|
615
|
+
methods: {}
|
|
616
|
+
};
|
|
617
|
+
var CheckboxContext = createContext2(defaultComponentAPI2);
|
|
618
|
+
var useCheckbox = () => useContext2(CheckboxContext);
|
|
619
|
+
var CheckboxProvider = ({ children }) => {
|
|
620
|
+
const context = useCheckboxProvider();
|
|
621
|
+
return /* @__PURE__ */ React6.createElement(CheckboxContext.Provider, { value: context }, children);
|
|
622
|
+
};
|
|
623
|
+
function useCheckboxProvider() {
|
|
624
|
+
const [checked, setChecked] = useState2(false);
|
|
625
|
+
const checkboxId = React6.useId();
|
|
626
|
+
return {
|
|
627
|
+
id: checkboxId,
|
|
628
|
+
states: {
|
|
629
|
+
checked
|
|
630
|
+
},
|
|
631
|
+
methods: {
|
|
632
|
+
toggleChecked: () => setChecked(!checked),
|
|
633
|
+
applyChecked: (state) => setChecked(Boolean(state))
|
|
634
|
+
}
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
// src/checkbox/styles/index.ts
|
|
639
|
+
import styled4, { css as css4 } from "styled-components";
|
|
640
|
+
var CheckboxDefaultStyles = css4`
|
|
641
|
+
position: relative;
|
|
642
|
+
display: flex;
|
|
643
|
+
align-items: center;
|
|
644
|
+
justify-content: center;
|
|
645
|
+
backdrop-filter: blur(var(--measurement-small-10));
|
|
646
|
+
transition: all ease-in-out 0.2s;
|
|
647
|
+
`;
|
|
648
|
+
var CheckboxVariantsStyles = css4`
|
|
649
|
+
&[data-variant="primary"] {
|
|
650
|
+
background-color: var(--font-color-alpha-10);
|
|
651
|
+
border: var(--measurement-small-10) solid transparent;
|
|
652
|
+
|
|
653
|
+
&:hover,
|
|
654
|
+
&:focus {
|
|
655
|
+
border-color: var(--font-color-alpha-10);
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
&:active,
|
|
659
|
+
&[data-state="checked"] {
|
|
660
|
+
background-color: var(--font-color);
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
&[data-state="checked"] {
|
|
664
|
+
svg {
|
|
665
|
+
stroke: var(--body-color);
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
&[data-variant="border"] {
|
|
671
|
+
background-color: var(--body-color);
|
|
672
|
+
border: var(--measurement-small-10) solid var(--font-color-alpha-10);
|
|
673
|
+
|
|
674
|
+
&:hover,
|
|
675
|
+
&:focus,
|
|
676
|
+
&:active,
|
|
677
|
+
&[data-state="checked"] {
|
|
678
|
+
background-color: var(--font-color-alpha-10);
|
|
679
|
+
border-color: transparent;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
&[data-state="checked"] {
|
|
683
|
+
svg {
|
|
684
|
+
stroke: var(--font-color);
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
&[data-variant="mono"] {
|
|
689
|
+
background-color: var(--font-color-alpha-10);
|
|
690
|
+
border: var(--measurement-small-10) solid transparent;
|
|
691
|
+
|
|
692
|
+
&:hover,
|
|
693
|
+
&:focus,
|
|
694
|
+
&:active,
|
|
695
|
+
&[data-state="checked"] {
|
|
696
|
+
border-color: var(--font-color-alpha-10);
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
&[data-state="checked"] {
|
|
700
|
+
svg {
|
|
701
|
+
stroke: var(--font-color);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
&[data-variant="ghost"] {
|
|
706
|
+
border: var(--measurement-small-10) solid transparent;
|
|
707
|
+
|
|
708
|
+
&:hover,
|
|
709
|
+
&:focus,
|
|
710
|
+
&:active,
|
|
711
|
+
&[data-state="checked"] {
|
|
712
|
+
border-color: var(--font-color-alpha-10);
|
|
713
|
+
|
|
714
|
+
svg {
|
|
715
|
+
stroke: var(--font-color);
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
`;
|
|
720
|
+
var CheckboxSizeStyles = css4`
|
|
721
|
+
&[data-size="small"] {
|
|
722
|
+
width: var(--measurement-medium-60);
|
|
723
|
+
height: var(--measurement-medium-60);
|
|
724
|
+
border-radius: var(--measurement-small-80);
|
|
725
|
+
}
|
|
726
|
+
&[data-size="medium"] {
|
|
727
|
+
width: var(--measurement-medium-70);
|
|
728
|
+
height: var(--measurement-medium-70);
|
|
729
|
+
border-radius: var(--measurement-medium-10);
|
|
730
|
+
}
|
|
731
|
+
&[data-size="large"] {
|
|
732
|
+
width: var(--measurement-large-10);
|
|
733
|
+
height: var(--measurement-large-10);
|
|
734
|
+
border-radius: var(--measurement-medium-20);
|
|
735
|
+
}
|
|
736
|
+
`;
|
|
737
|
+
var CheckboxWrapper = styled4.div`
|
|
738
|
+
cursor: pointer;
|
|
739
|
+
|
|
740
|
+
&[data-raw="false"] {
|
|
741
|
+
${CheckboxDefaultStyles}
|
|
742
|
+
${CheckboxVariantsStyles}
|
|
743
|
+
${CheckboxSizeStyles}
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
&[data-disabled="true"] {
|
|
747
|
+
cursor: not-allowed;
|
|
748
|
+
opacity: 0.6;
|
|
749
|
+
|
|
750
|
+
svg {
|
|
751
|
+
stroke-opacity: 0.6;
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
`;
|
|
755
|
+
var NativeInput = styled4.input`
|
|
756
|
+
&[data-raw="false"] {
|
|
757
|
+
appearance: none;
|
|
758
|
+
background: none;
|
|
759
|
+
border: none;
|
|
760
|
+
cursor: pointer;
|
|
761
|
+
height: 100%;
|
|
762
|
+
position: absolute;
|
|
763
|
+
left: 0;
|
|
764
|
+
top: 0;
|
|
765
|
+
width: 100%;
|
|
766
|
+
|
|
767
|
+
&:disabled {
|
|
768
|
+
cursor: not-allowed;
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
`;
|
|
772
|
+
var Indicator = styled4.span`
|
|
773
|
+
line-height: 0;
|
|
774
|
+
pointer-events: none;
|
|
775
|
+
`;
|
|
776
|
+
|
|
777
|
+
// src/checkbox/index.tsx
|
|
778
|
+
var Checkbox = (props) => {
|
|
779
|
+
const { states, methods } = useCheckbox();
|
|
780
|
+
const { applyChecked, toggleChecked } = methods;
|
|
781
|
+
const {
|
|
782
|
+
raw,
|
|
783
|
+
sizing = "medium" /* Medium */,
|
|
784
|
+
variant = "mono" /* Mono */,
|
|
785
|
+
name,
|
|
786
|
+
disabled,
|
|
787
|
+
required,
|
|
788
|
+
defaultChecked,
|
|
789
|
+
value,
|
|
790
|
+
onClick,
|
|
791
|
+
children,
|
|
792
|
+
...restProps
|
|
793
|
+
} = props;
|
|
794
|
+
const defaultValue = states.checked ? "checked" : "unchecked";
|
|
795
|
+
const handleClick = (event) => {
|
|
796
|
+
if (toggleChecked) toggleChecked();
|
|
797
|
+
if (onClick) onClick(event);
|
|
798
|
+
};
|
|
799
|
+
React7.useEffect(() => {
|
|
800
|
+
if (defaultChecked && applyChecked) applyChecked(defaultChecked);
|
|
801
|
+
}, []);
|
|
802
|
+
return /* @__PURE__ */ React7.createElement(
|
|
803
|
+
CheckboxWrapper,
|
|
804
|
+
{
|
|
805
|
+
role: "checkbox",
|
|
806
|
+
"aria-hidden": "true",
|
|
807
|
+
"data-state": value ?? defaultValue,
|
|
808
|
+
"data-disabled": disabled,
|
|
809
|
+
"data-raw": Boolean(raw),
|
|
810
|
+
"data-size": sizing,
|
|
811
|
+
"data-variant": variant,
|
|
812
|
+
"aria-label": props["aria-label"] ?? `${name}-checkbox`
|
|
813
|
+
},
|
|
814
|
+
/* @__PURE__ */ React7.createElement(
|
|
815
|
+
NativeInput,
|
|
816
|
+
{
|
|
817
|
+
type: "checkbox",
|
|
818
|
+
tabIndex: 0,
|
|
819
|
+
name,
|
|
820
|
+
value: value ?? defaultValue,
|
|
821
|
+
defaultChecked: Boolean(states.checked),
|
|
822
|
+
required,
|
|
823
|
+
disabled,
|
|
824
|
+
onInput: handleClick,
|
|
825
|
+
"data-state": defaultValue,
|
|
826
|
+
"data-raw": Boolean(raw),
|
|
827
|
+
"aria-disabled": Boolean(disabled),
|
|
828
|
+
"aria-required": Boolean(required),
|
|
829
|
+
"aria-checked": Boolean(states.checked),
|
|
830
|
+
"aria-label": props["aria-label"] ?? `${name}-native-checkbox`,
|
|
831
|
+
...restProps
|
|
832
|
+
}
|
|
833
|
+
),
|
|
834
|
+
children
|
|
835
|
+
);
|
|
836
|
+
};
|
|
837
|
+
Checkbox.displayName = "Checkbox";
|
|
838
|
+
var CheckboxRoot = (props) => {
|
|
839
|
+
const { children, ...restProps } = props;
|
|
840
|
+
return /* @__PURE__ */ React7.createElement(CheckboxProvider, { ...restProps }, children);
|
|
841
|
+
};
|
|
842
|
+
CheckboxRoot.displayName = "Checkbox.Root";
|
|
843
|
+
var CheckboxIndicator = (props) => {
|
|
844
|
+
const { states } = useCheckbox();
|
|
845
|
+
const { children, ...restProps } = props;
|
|
846
|
+
return /* @__PURE__ */ React7.createElement(React7.Fragment, null, states.checked && /* @__PURE__ */ React7.createElement(Indicator, { ...restProps }, children ?? /* @__PURE__ */ React7.createElement(
|
|
847
|
+
"svg",
|
|
848
|
+
{
|
|
849
|
+
tabIndex: -1,
|
|
850
|
+
"aria-hidden": "true",
|
|
851
|
+
"aria-label": "checked-icon",
|
|
852
|
+
focusable: "false",
|
|
853
|
+
width: "10",
|
|
854
|
+
height: "10",
|
|
855
|
+
viewBox: "0 0 10 10",
|
|
856
|
+
fill: "none"
|
|
857
|
+
},
|
|
858
|
+
/* @__PURE__ */ React7.createElement("title", null, "Checked"),
|
|
859
|
+
/* @__PURE__ */ React7.createElement(
|
|
860
|
+
"path",
|
|
861
|
+
{
|
|
862
|
+
d: "M2 5.5L4.12132 7.62132L8.36396 3.37868",
|
|
863
|
+
strokeWidth: "2",
|
|
864
|
+
strokeLinecap: "round",
|
|
865
|
+
strokeLinejoin: "round"
|
|
866
|
+
}
|
|
867
|
+
)
|
|
868
|
+
)));
|
|
869
|
+
};
|
|
870
|
+
CheckboxIndicator.displayName = "Checkbox.Indicator";
|
|
871
|
+
Checkbox.Root = CheckboxRoot;
|
|
872
|
+
Checkbox.Indicator = CheckboxIndicator;
|
|
873
|
+
|
|
874
|
+
// src/collapsible/index.tsx
|
|
875
|
+
import React9 from "react";
|
|
876
|
+
|
|
877
|
+
// src/collapsible/hooks/index.tsx
|
|
878
|
+
import React8, { useState as useState3, createContext as createContext3, useContext as useContext3 } from "react";
|
|
879
|
+
var defaultComponentAPI3 = {
|
|
880
|
+
id: "",
|
|
881
|
+
states: {},
|
|
882
|
+
methods: {}
|
|
883
|
+
};
|
|
884
|
+
var CollapsibleContext = createContext3(defaultComponentAPI3);
|
|
885
|
+
var useCollapsible = () => useContext3(CollapsibleContext);
|
|
886
|
+
var CollapsibleProvider = ({
|
|
887
|
+
children
|
|
888
|
+
}) => {
|
|
889
|
+
const context = useCollapsibleProvider();
|
|
890
|
+
return /* @__PURE__ */ React8.createElement(CollapsibleContext.Provider, { value: context }, children);
|
|
891
|
+
};
|
|
892
|
+
function useCollapsibleProvider() {
|
|
893
|
+
const [expanded, setExpanded] = useState3(false);
|
|
894
|
+
const [defaultOpen, setDefaultOpen] = useState3(false);
|
|
895
|
+
const collapsibleId = React8.useId();
|
|
896
|
+
const toggleCollapsible = () => {
|
|
897
|
+
setExpanded(!expanded);
|
|
898
|
+
setDefaultOpen(false);
|
|
899
|
+
};
|
|
900
|
+
const applyDefaultOpen = () => {
|
|
901
|
+
setExpanded(!expanded);
|
|
902
|
+
setDefaultOpen(true);
|
|
903
|
+
};
|
|
904
|
+
return {
|
|
905
|
+
id: collapsibleId,
|
|
906
|
+
states: {
|
|
907
|
+
expanded,
|
|
908
|
+
defaultOpen
|
|
909
|
+
},
|
|
910
|
+
methods: {
|
|
911
|
+
toggleCollapsible: () => toggleCollapsible(),
|
|
912
|
+
applyDefaultOpen: () => applyDefaultOpen()
|
|
913
|
+
}
|
|
914
|
+
};
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
// src/utils/index.ts
|
|
918
|
+
var applyDataState = (condition) => condition ? "open" : "closed";
|
|
919
|
+
|
|
920
|
+
// src/collapsible/index.tsx
|
|
921
|
+
var Collapsible = (props) => {
|
|
922
|
+
const { children, ...restProps } = props;
|
|
923
|
+
const collapsibleContext = useCollapsible();
|
|
924
|
+
return /* @__PURE__ */ React9.createElement(
|
|
925
|
+
"div",
|
|
926
|
+
{
|
|
927
|
+
"data-state": applyDataState(Boolean(collapsibleContext.states.expanded)),
|
|
928
|
+
...restProps
|
|
929
|
+
},
|
|
930
|
+
children
|
|
931
|
+
);
|
|
932
|
+
};
|
|
933
|
+
Collapsible.displayName = "Collapsible";
|
|
934
|
+
var CollapsibleRoot = ({ children }) => {
|
|
935
|
+
return /* @__PURE__ */ React9.createElement(CollapsibleProvider, null, children);
|
|
936
|
+
};
|
|
937
|
+
CollapsibleRoot.displayName = "Collapsible.Root";
|
|
938
|
+
var CollapsibleTrigger = (props) => {
|
|
939
|
+
const { children, disabled, onClick, ...restProps } = props;
|
|
940
|
+
const { id, states, methods } = useCollapsible();
|
|
941
|
+
const { toggleCollapsible } = methods;
|
|
942
|
+
const handleClick = (event) => {
|
|
943
|
+
if (toggleCollapsible) toggleCollapsible();
|
|
944
|
+
if (onClick) onClick(event);
|
|
945
|
+
};
|
|
946
|
+
return /* @__PURE__ */ React9.createElement(
|
|
947
|
+
Button,
|
|
948
|
+
{
|
|
949
|
+
disabled,
|
|
950
|
+
"aria-controls": id,
|
|
951
|
+
"data-state": applyDataState(Boolean(states.expanded)),
|
|
952
|
+
"data-expanded": states.expanded,
|
|
953
|
+
onClick: handleClick,
|
|
954
|
+
variant: props.variant ?? "ghost" /* Ghost */,
|
|
955
|
+
...restProps
|
|
956
|
+
},
|
|
957
|
+
children
|
|
958
|
+
);
|
|
959
|
+
};
|
|
960
|
+
CollapsibleTrigger.displayName = "Collapsible.Trigger";
|
|
961
|
+
var CollapsibleContent = (props) => {
|
|
962
|
+
const { defaultOpen = false, showFirstChild, children, ...restProps } = props;
|
|
963
|
+
const { id, states, methods } = useCollapsible();
|
|
964
|
+
const { applyDefaultOpen } = methods;
|
|
965
|
+
const childArray = React9.Children.toArray(children);
|
|
966
|
+
const displayChildren = states.expanded ?? states.defaultOpen;
|
|
967
|
+
const displayFirstChild = showFirstChild && childArray.length > 1 && !states.expanded;
|
|
968
|
+
React9.useEffect(() => {
|
|
969
|
+
if (defaultOpen && applyDefaultOpen) applyDefaultOpen();
|
|
970
|
+
}, []);
|
|
971
|
+
return /* @__PURE__ */ React9.createElement(
|
|
972
|
+
"div",
|
|
973
|
+
{
|
|
974
|
+
id,
|
|
975
|
+
"data-state": applyDataState(Boolean(states.expanded)),
|
|
976
|
+
role: "region",
|
|
977
|
+
...restProps
|
|
978
|
+
},
|
|
979
|
+
displayFirstChild && childArray[0],
|
|
980
|
+
displayChildren && children
|
|
981
|
+
);
|
|
982
|
+
};
|
|
983
|
+
CollapsibleContent.displayName = "Collapsible.Content";
|
|
984
|
+
Collapsible.Root = CollapsibleRoot;
|
|
985
|
+
Collapsible.Trigger = CollapsibleTrigger;
|
|
986
|
+
Collapsible.Content = CollapsibleContent;
|
|
987
|
+
|
|
988
|
+
// src/dialog/index.tsx
|
|
989
|
+
import React12 from "react";
|
|
990
|
+
|
|
991
|
+
// src/dialog/hooks/index.tsx
|
|
992
|
+
import React10, { useState as useState4, createContext as createContext4, useContext as useContext4 } from "react";
|
|
993
|
+
var defaultComponentAPI4 = {
|
|
994
|
+
id: "",
|
|
995
|
+
states: {},
|
|
996
|
+
methods: {}
|
|
997
|
+
};
|
|
998
|
+
var DialogContext = createContext4(defaultComponentAPI4);
|
|
999
|
+
var useDialog = () => useContext4(DialogContext);
|
|
1000
|
+
var DialogProvider = ({ children }) => {
|
|
1001
|
+
const context = useDialogProvider();
|
|
1002
|
+
return /* @__PURE__ */ React10.createElement(DialogContext.Provider, { value: context }, children);
|
|
1003
|
+
};
|
|
1004
|
+
function useDialogProvider() {
|
|
1005
|
+
const [open, setOpen] = useState4(false);
|
|
1006
|
+
const dialogId = React10.useId();
|
|
1007
|
+
return {
|
|
1008
|
+
id: dialogId,
|
|
1009
|
+
states: {
|
|
1010
|
+
open
|
|
1011
|
+
},
|
|
1012
|
+
methods: {
|
|
1013
|
+
toggleDialog: () => setOpen(!open),
|
|
1014
|
+
getDialogId: (type) => `${dialogId}-${type}`
|
|
1015
|
+
}
|
|
1016
|
+
};
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
// ../hooks/dist/index.mjs
|
|
1020
|
+
import { useEffect, useRef } from "react";
|
|
1021
|
+
import { useEffect as useEffect2, useState as useState5, useCallback } from "react";
|
|
1022
|
+
import React11 from "react";
|
|
1023
|
+
function useEventListener(eventName, handler, element) {
|
|
1024
|
+
const savedHandler = useRef(handler);
|
|
1025
|
+
useEffect(() => {
|
|
1026
|
+
savedHandler.current = handler;
|
|
1027
|
+
}, [handler]);
|
|
1028
|
+
useEffect(() => {
|
|
1029
|
+
const targetElement = element && element.current || window;
|
|
1030
|
+
if (!(targetElement && targetElement.addEventListener)) return;
|
|
1031
|
+
const eventListener = (event) => savedHandler.current(event);
|
|
1032
|
+
targetElement.addEventListener(eventName, eventListener);
|
|
1033
|
+
return () => targetElement.removeEventListener(eventName, eventListener);
|
|
1034
|
+
}, [eventName, element]);
|
|
1035
|
+
}
|
|
1036
|
+
var useEventListener_default = useEventListener;
|
|
1037
|
+
function useClickOutside(ref, handler, mouseEvent = "mousedown") {
|
|
1038
|
+
useEventListener_default(mouseEvent, (event) => {
|
|
1039
|
+
const element = ref && ref.current;
|
|
1040
|
+
if (!element || element.contains(event.target)) return;
|
|
1041
|
+
handler(event);
|
|
1042
|
+
});
|
|
1043
|
+
}
|
|
1044
|
+
function useKeyPress(targetKey, hotkey, bindKey) {
|
|
1045
|
+
const [keyPressed, setKeyPressed] = useState5(false);
|
|
1046
|
+
const switchStoredKeyPressed = useCallback(
|
|
1047
|
+
(event, state) => {
|
|
1048
|
+
if (!hotkey && event.key === targetKey) {
|
|
1049
|
+
return setKeyPressed(state);
|
|
1050
|
+
}
|
|
1051
|
+
if (hotkey && event[
|
|
1052
|
+
bindKey ?? "metaKey"
|
|
1053
|
+
/* Meta */
|
|
1054
|
+
] && event.key === targetKey) {
|
|
1055
|
+
return setKeyPressed(state);
|
|
1056
|
+
}
|
|
1057
|
+
return;
|
|
1058
|
+
},
|
|
1059
|
+
[bindKey, hotkey, targetKey]
|
|
1060
|
+
);
|
|
1061
|
+
const KeyDownHandler = useCallback(
|
|
1062
|
+
(event) => switchStoredKeyPressed(event, true),
|
|
1063
|
+
[switchStoredKeyPressed]
|
|
1064
|
+
);
|
|
1065
|
+
const KeyUpHandler = useCallback(
|
|
1066
|
+
(event) => switchStoredKeyPressed(event, false),
|
|
1067
|
+
[switchStoredKeyPressed]
|
|
1068
|
+
);
|
|
1069
|
+
useEffect2(() => {
|
|
1070
|
+
window.addEventListener("keydown", KeyDownHandler);
|
|
1071
|
+
window.addEventListener("keyup", KeyUpHandler);
|
|
1072
|
+
return () => {
|
|
1073
|
+
window.removeEventListener("keydown", KeyDownHandler);
|
|
1074
|
+
window.removeEventListener("keyup", KeyUpHandler);
|
|
1075
|
+
};
|
|
1076
|
+
}, [KeyDownHandler, KeyUpHandler]);
|
|
1077
|
+
return keyPressed;
|
|
1078
|
+
}
|
|
1079
|
+
var useDisabledScroll = (state) => {
|
|
1080
|
+
const overflow = state ? "hidden" : "";
|
|
1081
|
+
React11.useEffect(() => {
|
|
1082
|
+
document.body.style.overflowY = overflow;
|
|
1083
|
+
}, [state]);
|
|
1084
|
+
return {
|
|
1085
|
+
overflow,
|
|
1086
|
+
disabled: state
|
|
1087
|
+
};
|
|
1088
|
+
};
|
|
1089
|
+
|
|
1090
|
+
// src/dialog/styles/index.ts
|
|
1091
|
+
import styled5, { css as css5 } from "styled-components";
|
|
1092
|
+
var DialogDefaultStyles = css5`
|
|
1093
|
+
position: fixed;
|
|
1094
|
+
top: 15dvh;
|
|
1095
|
+
padding: var(--measurement-medium-60);
|
|
1096
|
+
width: 100%;
|
|
1097
|
+
|
|
1098
|
+
border: var(--measurement-small-10) solid var(--font-color-alpha-10);
|
|
1099
|
+
background-color: var(--body-color);
|
|
1100
|
+
border-radius: var(--measurement-medium-30);
|
|
1101
|
+
|
|
1102
|
+
transition: all ease-in-out 0.2s;
|
|
1103
|
+
z-index: var(--depth-default-100);
|
|
1104
|
+
`;
|
|
1105
|
+
var DialogSizeStyles = css5`
|
|
1106
|
+
--base-size: var(--measurement-medium-60);
|
|
1107
|
+
--computed-size: calc(100% - (var(--base-size) * 2));
|
|
1108
|
+
--max-height: 75dvh;
|
|
1109
|
+
|
|
1110
|
+
&[data-size="small"] {
|
|
1111
|
+
max-width: calc(var(--measurement-large-90) * 1.33);
|
|
1112
|
+
max-height: var(--max-height);
|
|
1113
|
+
}
|
|
1114
|
+
&[data-size="medium"] {
|
|
1115
|
+
max-width: calc(var(--measurement-large-90) * 2.66);
|
|
1116
|
+
max-height: var(--max-height);
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
&[data-size="large"] {
|
|
1120
|
+
top: var(--base-size);
|
|
1121
|
+
max-width: var(--computed-size);
|
|
1122
|
+
height: var(--computed-size);
|
|
1123
|
+
padding: var(--measurement-medium-80);
|
|
1124
|
+
}
|
|
1125
|
+
`;
|
|
1126
|
+
var Menu = styled5.menu`
|
|
1127
|
+
margin: 0;
|
|
1128
|
+
padding: 0;
|
|
1129
|
+
|
|
1130
|
+
&[data-raw="false"] {
|
|
1131
|
+
display: flex;
|
|
1132
|
+
justify-content: flex-end;
|
|
1133
|
+
gap: var(--measurement-medium-30);
|
|
1134
|
+
}
|
|
1135
|
+
`;
|
|
1136
|
+
var DialogWrapper = styled5.dialog`
|
|
1137
|
+
@keyframes slide-in {
|
|
1138
|
+
0% {
|
|
1139
|
+
opacity: 0;
|
|
1140
|
+
transform: translateY(var(--measurement-medium-30));
|
|
1141
|
+
}
|
|
1142
|
+
100% {
|
|
1143
|
+
opacity: 1;
|
|
1144
|
+
transform: translateY(0);
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
border: none;
|
|
1149
|
+
box-shadow: none;
|
|
1150
|
+
z-index: 100;
|
|
1151
|
+
|
|
1152
|
+
&[data-raw="false"] {
|
|
1153
|
+
${DialogDefaultStyles}
|
|
1154
|
+
${DialogSizeStyles}
|
|
1155
|
+
|
|
1156
|
+
animation-duration: 0.2s;
|
|
1157
|
+
animation-name: slide-in;
|
|
1158
|
+
animation-fill-mode: backwards;
|
|
1159
|
+
}
|
|
1160
|
+
`;
|
|
1161
|
+
|
|
1162
|
+
// src/dialog/index.tsx
|
|
1163
|
+
var Dialog = (props) => {
|
|
1164
|
+
const {
|
|
1165
|
+
raw,
|
|
1166
|
+
sizing = "medium" /* Medium */,
|
|
1167
|
+
open = false,
|
|
1168
|
+
lock = true,
|
|
1169
|
+
children,
|
|
1170
|
+
...restProps
|
|
1171
|
+
} = props;
|
|
1172
|
+
const { states, methods } = useDialog();
|
|
1173
|
+
const { getDialogId, toggleDialog } = methods;
|
|
1174
|
+
const triggerId = getDialogId && getDialogId("trigger");
|
|
1175
|
+
const contentId = getDialogId && getDialogId("content");
|
|
1176
|
+
React12.useEffect(() => {
|
|
1177
|
+
if (open && toggleDialog) toggleDialog();
|
|
1178
|
+
}, []);
|
|
1179
|
+
if (lock) useDisabledScroll(Boolean(states.open));
|
|
1180
|
+
return /* @__PURE__ */ React12.createElement(React12.Fragment, null, states.open && /* @__PURE__ */ React12.createElement(
|
|
1181
|
+
ScrollArea,
|
|
1182
|
+
{
|
|
1183
|
+
as: DialogWrapper,
|
|
1184
|
+
role: "dialog",
|
|
1185
|
+
tabIndex: -1,
|
|
1186
|
+
id: String(contentId),
|
|
1187
|
+
open: Boolean(states.open),
|
|
1188
|
+
"aria-labelledby": String(triggerId),
|
|
1189
|
+
"data-state": applyDataState(Boolean(states.open)),
|
|
1190
|
+
"data-size": sizing,
|
|
1191
|
+
"data-raw": Boolean(raw),
|
|
1192
|
+
...restProps
|
|
1193
|
+
},
|
|
1194
|
+
children
|
|
1195
|
+
));
|
|
1196
|
+
};
|
|
1197
|
+
Dialog.displayName = "Dialog";
|
|
1198
|
+
var DialogRoot = ({ children }) => {
|
|
1199
|
+
return /* @__PURE__ */ React12.createElement(DialogProvider, null, children);
|
|
1200
|
+
};
|
|
1201
|
+
DialogRoot.displayName = "Dialog.Root";
|
|
1202
|
+
var DialogOverlay = (props) => {
|
|
1203
|
+
const { closeOnInteract = false, onClick, ...restProps } = props;
|
|
1204
|
+
const { states, methods } = useDialog();
|
|
1205
|
+
const { toggleDialog } = methods;
|
|
1206
|
+
const handleClick = (event) => {
|
|
1207
|
+
if (closeOnInteract && toggleDialog) toggleDialog();
|
|
1208
|
+
if (onClick) onClick(event);
|
|
1209
|
+
};
|
|
1210
|
+
return /* @__PURE__ */ React12.createElement(
|
|
1211
|
+
Overlay,
|
|
1212
|
+
{
|
|
1213
|
+
visible: Boolean(states.open),
|
|
1214
|
+
closeOnInteract,
|
|
1215
|
+
onClick: handleClick,
|
|
1216
|
+
...restProps
|
|
1217
|
+
}
|
|
1218
|
+
);
|
|
1219
|
+
};
|
|
1220
|
+
DialogOverlay.displayName = "Dialog.Overlay";
|
|
1221
|
+
var DialogTrigger = (props) => {
|
|
1222
|
+
const { onClick, children, ...restProps } = props;
|
|
1223
|
+
const { states, methods } = useDialog();
|
|
1224
|
+
const { getDialogId, toggleDialog } = methods;
|
|
1225
|
+
const triggerId = getDialogId && getDialogId("trigger");
|
|
1226
|
+
const contentId = getDialogId && getDialogId("content");
|
|
1227
|
+
const handleClick = (event) => {
|
|
1228
|
+
if (toggleDialog) toggleDialog();
|
|
1229
|
+
if (onClick) onClick(event);
|
|
1230
|
+
};
|
|
1231
|
+
return /* @__PURE__ */ React12.createElement(
|
|
1232
|
+
Button,
|
|
1233
|
+
{
|
|
1234
|
+
id: String(triggerId),
|
|
1235
|
+
onClick: handleClick,
|
|
1236
|
+
"aria-controls": String(contentId),
|
|
1237
|
+
"aria-expanded": Boolean(states.open),
|
|
1238
|
+
"data-state": applyDataState(Boolean(states.open)),
|
|
1239
|
+
...restProps
|
|
1240
|
+
},
|
|
1241
|
+
children
|
|
1242
|
+
);
|
|
1243
|
+
};
|
|
1244
|
+
DialogTrigger.displayName = "Dialog.Trigger";
|
|
1245
|
+
var DialogMenu = (props) => {
|
|
1246
|
+
const { raw, children, ...restProps } = props;
|
|
1247
|
+
return /* @__PURE__ */ React12.createElement(Menu, { "data-raw": Boolean(raw), ...restProps }, children);
|
|
1248
|
+
};
|
|
1249
|
+
DialogMenu.displayName = "Dialog.Menu";
|
|
1250
|
+
var DialogControl = (props) => {
|
|
1251
|
+
const { onClick, children, ...restProps } = props;
|
|
1252
|
+
const { states, methods } = useDialog();
|
|
1253
|
+
const { getDialogId, toggleDialog } = methods;
|
|
1254
|
+
const innerControlId = getDialogId && getDialogId("inner-control");
|
|
1255
|
+
const contentId = getDialogId && getDialogId("content");
|
|
1256
|
+
const handleClick = (event) => {
|
|
1257
|
+
if (toggleDialog) toggleDialog();
|
|
1258
|
+
if (onClick) onClick(event);
|
|
1259
|
+
};
|
|
1260
|
+
return /* @__PURE__ */ React12.createElement(
|
|
1261
|
+
Button,
|
|
1262
|
+
{
|
|
1263
|
+
id: String(innerControlId),
|
|
1264
|
+
onClick: handleClick,
|
|
1265
|
+
"aria-controls": String(contentId),
|
|
1266
|
+
"aria-expanded": Boolean(states.open),
|
|
1267
|
+
"data-state": applyDataState(Boolean(states.open)),
|
|
1268
|
+
...restProps
|
|
1269
|
+
},
|
|
1270
|
+
children
|
|
1271
|
+
);
|
|
1272
|
+
};
|
|
1273
|
+
DialogControl.displayName = "Dialog.Control";
|
|
1274
|
+
Dialog.Root = DialogRoot;
|
|
1275
|
+
Dialog.Trigger = DialogTrigger;
|
|
1276
|
+
Dialog.Control = DialogControl;
|
|
1277
|
+
Dialog.Menu = DialogMenu;
|
|
1278
|
+
Dialog.Overlay = DialogOverlay;
|
|
1279
|
+
|
|
1280
|
+
// src/divider/index.ts
|
|
1281
|
+
import styled6 from "styled-components";
|
|
1282
|
+
var Divider = styled6.hr`
|
|
1283
|
+
height: var(--measurement-small-10);
|
|
1284
|
+
margin: var(--measurement-medium-30) 0;
|
|
1285
|
+
background: var(--font-color-alpha-10);
|
|
1286
|
+
border: none;
|
|
1287
|
+
`;
|
|
1288
|
+
|
|
1289
|
+
// src/dropdown/index.tsx
|
|
1290
|
+
import React14 from "react";
|
|
1291
|
+
|
|
1292
|
+
// src/dropdown/hooks/index.tsx
|
|
1293
|
+
import React13 from "react";
|
|
1294
|
+
var DEFAULT_API = {
|
|
1295
|
+
id: "",
|
|
1296
|
+
states: {},
|
|
1297
|
+
methods: {}
|
|
1298
|
+
};
|
|
1299
|
+
var DEFAULT_POSITIONS = {
|
|
1300
|
+
top: 0,
|
|
1301
|
+
right: 0,
|
|
1302
|
+
bottom: 0,
|
|
1303
|
+
left: 0
|
|
1304
|
+
};
|
|
1305
|
+
var DEFAULT_DIMENSIONS = {
|
|
1306
|
+
width: 0,
|
|
1307
|
+
height: 0
|
|
1308
|
+
};
|
|
1309
|
+
var DropdownMenuContext = React13.createContext(DEFAULT_API);
|
|
1310
|
+
var useDropdownMenu = () => React13.useContext(DropdownMenuContext);
|
|
1311
|
+
var DropdownMenuProvider = ({
|
|
1312
|
+
children
|
|
1313
|
+
}) => {
|
|
1314
|
+
const context = useDropdownMenuProvider();
|
|
1315
|
+
return /* @__PURE__ */ React13.createElement(DropdownMenuContext.Provider, { value: context }, children);
|
|
1316
|
+
};
|
|
1317
|
+
function useDropdownMenuProvider() {
|
|
1318
|
+
const [open, setOpen] = React13.useState(false);
|
|
1319
|
+
const [contentProps, setContentProps] = React13.useState({
|
|
1320
|
+
...DEFAULT_POSITIONS,
|
|
1321
|
+
...DEFAULT_DIMENSIONS
|
|
1322
|
+
});
|
|
1323
|
+
const [triggerProps, setTriggerProps] = React13.useState({
|
|
1324
|
+
...DEFAULT_POSITIONS,
|
|
1325
|
+
...DEFAULT_DIMENSIONS
|
|
1326
|
+
});
|
|
1327
|
+
const triggerId = React13.useId();
|
|
1328
|
+
const dropdownId = React13.useId();
|
|
1329
|
+
const composedId = `${triggerId}|${dropdownId}`;
|
|
1330
|
+
return {
|
|
1331
|
+
id: composedId,
|
|
1332
|
+
states: {
|
|
1333
|
+
open,
|
|
1334
|
+
contentProps,
|
|
1335
|
+
triggerProps
|
|
1336
|
+
},
|
|
1337
|
+
methods: {
|
|
1338
|
+
toggleOpen: () => setOpen(!open),
|
|
1339
|
+
setContentProps,
|
|
1340
|
+
setTriggerProps
|
|
1341
|
+
}
|
|
1342
|
+
};
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
// src/dropdown/styles/index.ts
|
|
1346
|
+
import styled7, { css as css6, keyframes } from "styled-components";
|
|
1347
|
+
var FadeIn = keyframes`
|
|
1348
|
+
0% {
|
|
1349
|
+
opacity: 0;
|
|
1350
|
+
}
|
|
1351
|
+
100% {
|
|
1352
|
+
opacity: 1;
|
|
1353
|
+
}
|
|
1354
|
+
`;
|
|
1355
|
+
var ContentWrapperSizes = css6`
|
|
1356
|
+
--small: var(--measurement-large-60);
|
|
1357
|
+
--medium: var(--measurement-large-80);
|
|
1358
|
+
--large: var(--measurement-large-90);
|
|
1359
|
+
|
|
1360
|
+
max-height: var(--measurement-large-90);
|
|
1361
|
+
|
|
1362
|
+
&[data-sizing="small"] {
|
|
1363
|
+
width: var(--small);
|
|
1364
|
+
max-width: var(--small);
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
&[data-sizing="medium"] {
|
|
1368
|
+
width: var(--medium);
|
|
1369
|
+
max-width: var(--medium);
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
&[data-sizing="large"] {
|
|
1373
|
+
width: var(--large);
|
|
1374
|
+
max-width: var(--large);
|
|
1375
|
+
}
|
|
1376
|
+
`;
|
|
1377
|
+
var RootWrapper = styled7.div`
|
|
1378
|
+
position: relative;
|
|
1379
|
+
`;
|
|
1380
|
+
var ContentWrapper = styled7.ul`
|
|
1381
|
+
--small: var(--measurement-large-60);
|
|
1382
|
+
--medium: var(--measurement-large-80);
|
|
1383
|
+
--large: var(--measurement-large-90);
|
|
1384
|
+
|
|
1385
|
+
&[data-raw="false"] {
|
|
1386
|
+
position: fixed;
|
|
1387
|
+
margin: 0;
|
|
1388
|
+
|
|
1389
|
+
padding: var(--measurement-medium-30);
|
|
1390
|
+
margin: var(--measurement-medium-10) 0;
|
|
1391
|
+
|
|
1392
|
+
background-color: var(--body-color);
|
|
1393
|
+
border: var(--measurement-small-10) solid var(--font-color-alpha-10);
|
|
1394
|
+
border-radius: var(--measurement-medium-30);
|
|
1395
|
+
|
|
1396
|
+
z-index: var(--depth-default-100);
|
|
1397
|
+
animation-duration: 0.2s;
|
|
1398
|
+
animation-name: ${FadeIn};
|
|
1399
|
+
animation-fill-mode: backwards;
|
|
1400
|
+
|
|
1401
|
+
${ContentWrapperSizes}
|
|
1402
|
+
}
|
|
1403
|
+
`;
|
|
1404
|
+
var ItemWrapper = styled7.li`
|
|
1405
|
+
list-style: none;
|
|
1406
|
+
padding: 0;
|
|
1407
|
+
margin: 0;
|
|
1408
|
+
user-select: none;
|
|
1409
|
+
|
|
1410
|
+
&[data-raw="false"] {
|
|
1411
|
+
font-size: var(--fontsize-small-80);
|
|
1412
|
+
padding: var(--measurement-medium-30);
|
|
1413
|
+
border-radius: var(--measurement-medium-20);
|
|
1414
|
+
text-align: left;
|
|
1415
|
+
color: var(--font-color-alpha-60);
|
|
1416
|
+
outline: none;
|
|
1417
|
+
transition: all ease-in-out 0.2s;
|
|
1418
|
+
cursor: pointer;
|
|
1419
|
+
|
|
1420
|
+
&:hover,
|
|
1421
|
+
&:focus,
|
|
1422
|
+
&:active {
|
|
1423
|
+
color: var(--font-color);
|
|
1424
|
+
background-color: var(--font-color-alpha-10);
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
&[aria-disabled="true"] {
|
|
1429
|
+
cursor: not-allowed;
|
|
1430
|
+
opacity: 0.6;
|
|
1431
|
+
}
|
|
1432
|
+
`;
|
|
1433
|
+
|
|
1434
|
+
// src/dropdown/index.tsx
|
|
1435
|
+
var DropdownMenu = ({ children }) => {
|
|
1436
|
+
const DropdownContentRef = React14.useRef(null);
|
|
1437
|
+
const { states, methods } = useDropdownMenu();
|
|
1438
|
+
const { toggleOpen } = methods;
|
|
1439
|
+
const handleClickOutside = () => {
|
|
1440
|
+
if (states.open && toggleOpen) toggleOpen();
|
|
1441
|
+
};
|
|
1442
|
+
useClickOutside(DropdownContentRef, handleClickOutside);
|
|
1443
|
+
useDisabledScroll(Boolean(states.open));
|
|
1444
|
+
return /* @__PURE__ */ React14.createElement(RootWrapper, { ref: DropdownContentRef }, children);
|
|
1445
|
+
};
|
|
1446
|
+
DropdownMenu.displayName = "DropdownMenu";
|
|
1447
|
+
var DropdownMenuRoot = ({ children }) => {
|
|
1448
|
+
return /* @__PURE__ */ React14.createElement(DropdownMenuProvider, null, children);
|
|
1449
|
+
};
|
|
1450
|
+
DropdownMenuRoot.displayName = "DropdownMenu.Root";
|
|
1451
|
+
var DropdownMenuTrigger = (props) => {
|
|
1452
|
+
const triggerRef = React14.useRef(null);
|
|
1453
|
+
const triggerRect = () => triggerRef.current?.getBoundingClientRect();
|
|
1454
|
+
const { variant = "ghost", onClick, children, ...restProps } = props;
|
|
1455
|
+
const { id, states, methods } = useDropdownMenu();
|
|
1456
|
+
const { toggleOpen, setTriggerProps } = methods;
|
|
1457
|
+
const handleClick = (event) => {
|
|
1458
|
+
if (onClick) onClick(event);
|
|
1459
|
+
if (toggleOpen) toggleOpen();
|
|
1460
|
+
if (setTriggerProps)
|
|
1461
|
+
setTriggerProps({
|
|
1462
|
+
top: Number(triggerRect()?.top),
|
|
1463
|
+
right: Number(triggerRect()?.right),
|
|
1464
|
+
bottom: Number(triggerRect()?.bottom),
|
|
1465
|
+
left: Number(triggerRect()?.left),
|
|
1466
|
+
width: Number(triggerRect()?.width),
|
|
1467
|
+
height: Number(triggerRect()?.height)
|
|
1468
|
+
});
|
|
1469
|
+
};
|
|
1470
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1471
|
+
Button,
|
|
1472
|
+
{
|
|
1473
|
+
ref: triggerRef,
|
|
1474
|
+
id: id.split("|").at(0),
|
|
1475
|
+
onClick: handleClick,
|
|
1476
|
+
"aria-haspopup": "menu",
|
|
1477
|
+
"data-state": applyDataState(Boolean(states.open)),
|
|
1478
|
+
variant,
|
|
1479
|
+
...restProps
|
|
1480
|
+
},
|
|
1481
|
+
children
|
|
1482
|
+
);
|
|
1483
|
+
};
|
|
1484
|
+
DropdownMenuTrigger.displayName = "DropdownMenu.Trigger";
|
|
1485
|
+
var DropdownMenuContent = React14.forwardRef((props, _) => {
|
|
1486
|
+
const { raw, sizing = "medium", defaultOpen, children, ...restProps } = props;
|
|
1487
|
+
const { id, states, methods } = useDropdownMenu();
|
|
1488
|
+
const { toggleOpen, setContentProps } = methods;
|
|
1489
|
+
const mounted = React14.useRef(false);
|
|
1490
|
+
const contentRef = React14.useRef(null);
|
|
1491
|
+
const contentRect = () => contentRef?.current?.getBoundingClientRect();
|
|
1492
|
+
const bodyRect = () => {
|
|
1493
|
+
if (typeof document !== "undefined") {
|
|
1494
|
+
return document?.body?.getBoundingClientRect();
|
|
1495
|
+
}
|
|
1496
|
+
return void 0;
|
|
1497
|
+
};
|
|
1498
|
+
const positions = {
|
|
1499
|
+
btt: `calc((${states?.triggerProps?.top}px - ${states?.contentProps?.height}px) - (var(--measurement-medium-10) * 2))`,
|
|
1500
|
+
ttb: `calc((${states?.triggerProps?.top}px + ${states?.triggerProps?.height}px) + var(--measurement-medium-10))`,
|
|
1501
|
+
ltr: `${states?.triggerProps?.left}px`,
|
|
1502
|
+
rtl: `calc(${states?.triggerProps?.left}px - (${states?.contentProps?.width}px - ${states?.triggerProps?.width}px))`
|
|
1503
|
+
};
|
|
1504
|
+
const dimensions = {
|
|
1505
|
+
body_width: bodyRect()?.width ?? 0,
|
|
1506
|
+
body_height: bodyRect()?.height ?? 0,
|
|
1507
|
+
content_width: states.contentProps.width,
|
|
1508
|
+
content_height: states.contentProps.height,
|
|
1509
|
+
content_left: states.contentProps.left,
|
|
1510
|
+
content_bottom: states.contentProps.bottom
|
|
1511
|
+
};
|
|
1512
|
+
const hasEnoughHorizontalSpace = dimensions.body_width - dimensions.content_left > dimensions.content_width * 1.1;
|
|
1513
|
+
const hasEnoughVerticalSpace = dimensions.body_height - dimensions.content_bottom > dimensions.content_height - dimensions.content_height * 0.9;
|
|
1514
|
+
React14.useEffect(() => {
|
|
1515
|
+
if (defaultOpen && toggleOpen) toggleOpen();
|
|
1516
|
+
}, []);
|
|
1517
|
+
React14.useEffect(() => {
|
|
1518
|
+
mounted.current = true;
|
|
1519
|
+
setContentProps && setContentProps({
|
|
1520
|
+
top: Number(contentRect()?.top),
|
|
1521
|
+
right: Number(contentRect()?.right),
|
|
1522
|
+
bottom: Number(contentRect()?.bottom),
|
|
1523
|
+
left: Number(contentRect()?.left),
|
|
1524
|
+
width: Number(contentRect()?.width),
|
|
1525
|
+
height: Number(contentRect()?.height)
|
|
1526
|
+
});
|
|
1527
|
+
return () => {
|
|
1528
|
+
mounted.current = false;
|
|
1529
|
+
};
|
|
1530
|
+
}, [states.open]);
|
|
1531
|
+
return /* @__PURE__ */ React14.createElement(React14.Fragment, null, states.open && /* @__PURE__ */ React14.createElement(
|
|
1532
|
+
ContentWrapper,
|
|
1533
|
+
{
|
|
1534
|
+
ref: contentRef,
|
|
1535
|
+
id: id.split("|").at(-1),
|
|
1536
|
+
role: "menu",
|
|
1537
|
+
tabIndex: -1,
|
|
1538
|
+
"aria-labelledby": id.split("|").at(0),
|
|
1539
|
+
"data-state": applyDataState(Boolean(states.open)),
|
|
1540
|
+
"data-sizing": sizing,
|
|
1541
|
+
"data-side": hasEnoughHorizontalSpace ? "left" /* Left */ : "right" /* Right */,
|
|
1542
|
+
"data-align": hasEnoughHorizontalSpace ? "left" /* Left */ : "right" /* Right */,
|
|
1543
|
+
"data-raw": Boolean(raw),
|
|
1544
|
+
style: {
|
|
1545
|
+
top: hasEnoughVerticalSpace ? positions.ttb : positions.btt,
|
|
1546
|
+
left: hasEnoughHorizontalSpace ? positions.ltr : positions.rtl
|
|
1547
|
+
},
|
|
1548
|
+
...restProps
|
|
1549
|
+
},
|
|
1550
|
+
children
|
|
1551
|
+
));
|
|
1552
|
+
});
|
|
1553
|
+
DropdownMenuContent.displayName = "DropdownMenu.Content";
|
|
1554
|
+
var DropdownMenuItem = (props) => {
|
|
1555
|
+
const {
|
|
1556
|
+
raw,
|
|
1557
|
+
onClick,
|
|
1558
|
+
radio = false,
|
|
1559
|
+
disabled,
|
|
1560
|
+
children,
|
|
1561
|
+
...restProps
|
|
1562
|
+
} = props;
|
|
1563
|
+
const { methods } = useDropdownMenu();
|
|
1564
|
+
const { toggleOpen } = methods;
|
|
1565
|
+
const EventsHandler = {
|
|
1566
|
+
toggle: () => {
|
|
1567
|
+
if (!radio && toggleOpen) toggleOpen();
|
|
1568
|
+
},
|
|
1569
|
+
click: (event) => {
|
|
1570
|
+
if (onClick) onClick(event);
|
|
1571
|
+
}
|
|
1572
|
+
};
|
|
1573
|
+
const handleClick = (event) => {
|
|
1574
|
+
if (!disabled) {
|
|
1575
|
+
EventsHandler.click(event);
|
|
1576
|
+
EventsHandler.toggle();
|
|
1577
|
+
}
|
|
1578
|
+
};
|
|
1579
|
+
const handleKeydown = (event) => {
|
|
1580
|
+
if (["Space", "Enter"].includes(event.code || event.key) && !disabled) {
|
|
1581
|
+
EventsHandler.click(event);
|
|
1582
|
+
EventsHandler.toggle();
|
|
1583
|
+
}
|
|
1584
|
+
};
|
|
1585
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1586
|
+
ItemWrapper,
|
|
1587
|
+
{
|
|
1588
|
+
role: "menuitem",
|
|
1589
|
+
tabIndex: 0,
|
|
1590
|
+
onClick: handleClick,
|
|
1591
|
+
onKeyDown: handleKeydown,
|
|
1592
|
+
"aria-disabled": disabled,
|
|
1593
|
+
"data-orientation": "vertical",
|
|
1594
|
+
"data-raw": Boolean(raw),
|
|
1595
|
+
...restProps
|
|
1596
|
+
},
|
|
1597
|
+
children
|
|
1598
|
+
);
|
|
1599
|
+
};
|
|
1600
|
+
DropdownMenuItem.displayName = "DropdownMenu.Item";
|
|
1601
|
+
DropdownMenu.Root = DropdownMenuRoot;
|
|
1602
|
+
DropdownMenu.Trigger = DropdownMenuTrigger;
|
|
1603
|
+
DropdownMenu.Content = DropdownMenuContent;
|
|
1604
|
+
DropdownMenu.Item = DropdownMenuItem;
|
|
1605
|
+
|
|
1606
|
+
// src/field/index.tsx
|
|
1607
|
+
import React16 from "react";
|
|
1608
|
+
|
|
1609
|
+
// src/field/hooks/index.tsx
|
|
1610
|
+
import React15, { createContext as createContext5, useContext as useContext5 } from "react";
|
|
1611
|
+
var defaultComponentAPI5 = {
|
|
1612
|
+
id: "",
|
|
1613
|
+
states: {},
|
|
1614
|
+
methods: {}
|
|
1615
|
+
};
|
|
1616
|
+
var FieldContext = createContext5(defaultComponentAPI5);
|
|
1617
|
+
var useField = () => useContext5(FieldContext);
|
|
1618
|
+
var FieldProvider = ({ children }) => {
|
|
1619
|
+
const context = useFieldProvider();
|
|
1620
|
+
return /* @__PURE__ */ React15.createElement(FieldContext.Provider, { value: context }, children);
|
|
1621
|
+
};
|
|
1622
|
+
function useFieldProvider() {
|
|
1623
|
+
const fieldId = React15.useId();
|
|
1624
|
+
return {
|
|
1625
|
+
id: fieldId,
|
|
1626
|
+
states: {},
|
|
1627
|
+
methods: {}
|
|
1628
|
+
};
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
// src/field/styles/index.ts
|
|
1632
|
+
import styled8, { css as css7 } from "styled-components";
|
|
1633
|
+
var FieldDefaultStyles = css7`
|
|
1634
|
+
outline: none;
|
|
1635
|
+
cursor: pointer;
|
|
1636
|
+
display: flex;
|
|
1637
|
+
align-items: center;
|
|
1638
|
+
justify-content: center;
|
|
1639
|
+
|
|
1640
|
+
font-size: var(--fontsize-small-80);
|
|
1641
|
+
font-weight: 500;
|
|
1642
|
+
line-height: 1.1;
|
|
1643
|
+
letter-spacing: calc(
|
|
1644
|
+
var(--fontsize-small-10) - ((var(--fontsize-small-10) * 1.066))
|
|
1645
|
+
);
|
|
1646
|
+
|
|
1647
|
+
border: var(--measurement-small-10) solid transparent;
|
|
1648
|
+
border-radius: var(--measurement-medium-30);
|
|
1649
|
+
backdrop-filter: blur(var(--measurement-small-10));
|
|
1650
|
+
color: var(--font-color-alpha-60);
|
|
1651
|
+
width: fit-content;
|
|
1652
|
+
height: fit-content;
|
|
1653
|
+
|
|
1654
|
+
transition: all ease-in-out 0.2s;
|
|
1655
|
+
|
|
1656
|
+
svg,
|
|
1657
|
+
span,
|
|
1658
|
+
img {
|
|
1659
|
+
opacity: 0.6;
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
&:hover,
|
|
1663
|
+
&:focus,
|
|
1664
|
+
&:active {
|
|
1665
|
+
color: var(--font-color);
|
|
1666
|
+
|
|
1667
|
+
svg,
|
|
1668
|
+
span,
|
|
1669
|
+
img {
|
|
1670
|
+
opacity: 1;
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
&::placeholder {
|
|
1674
|
+
color: var(--font-color-alpha-30);
|
|
1675
|
+
}
|
|
1676
|
+
&:disabled {
|
|
1677
|
+
cursor: not-allowed;
|
|
1678
|
+
opacity: 0.6;
|
|
1679
|
+
}
|
|
1680
|
+
`;
|
|
1681
|
+
var FieldVariantsStyles = css7`
|
|
1682
|
+
&[data-variant="primary"] {
|
|
1683
|
+
background-color: var(--font-color-alpha-10);
|
|
1684
|
+
|
|
1685
|
+
&[data-error="true"] {
|
|
1686
|
+
color: var(--color-red);
|
|
1687
|
+
background-color: var(--alpha-red-10);
|
|
1688
|
+
border-color: var(--alpha-red-10);
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
&[data-variant="secondary"] {
|
|
1693
|
+
background-color: transparent;
|
|
1694
|
+
border-color: var(--font-color-alpha-10);
|
|
1695
|
+
|
|
1696
|
+
&:hover,
|
|
1697
|
+
&:focus,
|
|
1698
|
+
&:active {
|
|
1699
|
+
background-color: var(--font-color-alpha-10);
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1702
|
+
&[data-error="true"] {
|
|
1703
|
+
color: var(--color-red);
|
|
1704
|
+
border-color: var(--alpha-red-10);
|
|
1705
|
+
|
|
1706
|
+
&:hover,
|
|
1707
|
+
&:focus,
|
|
1708
|
+
&:active {
|
|
1709
|
+
background-color: var(--alpha-red-10);
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1714
|
+
&[data-variant="ghost"] {
|
|
1715
|
+
padding: 0;
|
|
1716
|
+
border: none;
|
|
1717
|
+
background-color: transparent;
|
|
1718
|
+
min-width: fit-content;
|
|
1719
|
+
min-height: var(--measurement-medium-60);
|
|
1720
|
+
color: var(--font-color-alpha-60);
|
|
1721
|
+
|
|
1722
|
+
&:hover,
|
|
1723
|
+
&:focus,
|
|
1724
|
+
&:active {
|
|
1725
|
+
color: var(--font-color);
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
&[data-error="true"] {
|
|
1729
|
+
color: var(--color-red);
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
`;
|
|
1733
|
+
var FieldSizeStyles = css7`
|
|
1734
|
+
&[data-size="small"] {
|
|
1735
|
+
gap: var(--measurement-medium-10);
|
|
1736
|
+
padding: 0 var(--measurement-medium-30);
|
|
1737
|
+
min-width: var(--measurement-medium-60);
|
|
1738
|
+
min-height: var(--measurement-medium-80);
|
|
1739
|
+
}
|
|
1740
|
+
&[data-size="medium"] {
|
|
1741
|
+
gap: var(--measurement-medium-30);
|
|
1742
|
+
padding: 0 var(--measurement-medium-30);
|
|
1743
|
+
min-width: var(--measurement-medium-90);
|
|
1744
|
+
min-height: var(--measurement-medium-90);
|
|
1745
|
+
width: fit-content;
|
|
1746
|
+
}
|
|
1747
|
+
&[data-size="large"] {
|
|
1748
|
+
padding: var(--measurement-medium-20) var(--measurement-medium-40);
|
|
1749
|
+
min-width: var(--measurement-medium-90);
|
|
1750
|
+
min-height: var(--measurement-medium-90);
|
|
1751
|
+
}
|
|
1752
|
+
`;
|
|
1753
|
+
var Fieldset = styled8.fieldset`
|
|
1754
|
+
all: unset;
|
|
1755
|
+
display: grid;
|
|
1756
|
+
gap: var(--measurement-medium-10);
|
|
1757
|
+
`;
|
|
1758
|
+
var Sup = styled8.sup`
|
|
1759
|
+
color: var(--color-red);
|
|
1760
|
+
`;
|
|
1761
|
+
var Input = styled8.input`
|
|
1762
|
+
&[data-raw="false"] {
|
|
1763
|
+
${FieldDefaultStyles}
|
|
1764
|
+
${FieldVariantsStyles}
|
|
1765
|
+
${FieldSizeStyles}
|
|
1766
|
+
|
|
1767
|
+
&[data-error="true"] {
|
|
1768
|
+
&::placeholder {
|
|
1769
|
+
color: var(--alpha-red-30);
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
`;
|
|
1774
|
+
var Label = styled8.label`
|
|
1775
|
+
&[data-raw="false"] {
|
|
1776
|
+
font-weight: 500;
|
|
1777
|
+
line-height: 1.1;
|
|
1778
|
+
letter-spacing: calc(
|
|
1779
|
+
var(--fontsize-small-10) - ((var(--fontsize-small-10) * 1.066))
|
|
1780
|
+
);
|
|
1781
|
+
}
|
|
1782
|
+
`;
|
|
1783
|
+
var Def = styled8.dfn`
|
|
1784
|
+
&[data-raw="false"] {
|
|
1785
|
+
font-style: normal;
|
|
1786
|
+
font-size: var(--fontsize-medium-10);
|
|
1787
|
+
|
|
1788
|
+
&[data-variant="hint"] {
|
|
1789
|
+
color: var(--font-color-alpha-30);
|
|
1790
|
+
}
|
|
1791
|
+
&[data-variant="error"] {
|
|
1792
|
+
color: var(--color-red);
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
`;
|
|
1796
|
+
|
|
1797
|
+
// src/field/index.tsx
|
|
1798
|
+
var MetaVariantEnum = /* @__PURE__ */ ((MetaVariantEnum2) => {
|
|
1799
|
+
MetaVariantEnum2["Default"] = "default";
|
|
1800
|
+
MetaVariantEnum2["Hint"] = "hint";
|
|
1801
|
+
MetaVariantEnum2["Emphasis"] = "emphasis";
|
|
1802
|
+
MetaVariantEnum2["Error"] = "error";
|
|
1803
|
+
return MetaVariantEnum2;
|
|
1804
|
+
})(MetaVariantEnum || {});
|
|
1805
|
+
var Field = (props) => {
|
|
1806
|
+
const {
|
|
1807
|
+
raw,
|
|
1808
|
+
sizing = "medium" /* Medium */,
|
|
1809
|
+
variant = "primary" /* Primary */,
|
|
1810
|
+
error,
|
|
1811
|
+
hint,
|
|
1812
|
+
...restProps
|
|
1813
|
+
} = props;
|
|
1814
|
+
const metaId = React16.useId();
|
|
1815
|
+
const { id } = useField();
|
|
1816
|
+
return /* @__PURE__ */ React16.createElement(React16.Fragment, null, /* @__PURE__ */ React16.createElement(
|
|
1817
|
+
Input,
|
|
1818
|
+
{
|
|
1819
|
+
id,
|
|
1820
|
+
"aria-invalid": !!error,
|
|
1821
|
+
"aria-describedby": metaId,
|
|
1822
|
+
"aria-errormessage": error,
|
|
1823
|
+
"data-error": Boolean(error),
|
|
1824
|
+
"data-variant": variant,
|
|
1825
|
+
"data-size": sizing,
|
|
1826
|
+
"data-raw": Boolean(raw),
|
|
1827
|
+
...restProps
|
|
1828
|
+
}
|
|
1829
|
+
), (error ?? hint) && /* @__PURE__ */ React16.createElement(
|
|
1830
|
+
FieldMeta,
|
|
1831
|
+
{
|
|
1832
|
+
raw,
|
|
1833
|
+
"data-variant": error ? "error" /* Error */ : "hint" /* Hint */
|
|
1834
|
+
},
|
|
1835
|
+
error ?? hint
|
|
1836
|
+
));
|
|
1837
|
+
};
|
|
1838
|
+
Field.displayName = "Field";
|
|
1839
|
+
var FieldRoot = ({ children }) => {
|
|
1840
|
+
return /* @__PURE__ */ React16.createElement(FieldProvider, null, children);
|
|
1841
|
+
};
|
|
1842
|
+
FieldRoot.displayName = "Field.Root";
|
|
1843
|
+
var FieldWrapper = ({
|
|
1844
|
+
children,
|
|
1845
|
+
...restProps
|
|
1846
|
+
}) => {
|
|
1847
|
+
return /* @__PURE__ */ React16.createElement(Fieldset, { ...restProps }, children);
|
|
1848
|
+
};
|
|
1849
|
+
FieldWrapper.displayName = "Field.Wrapper";
|
|
1850
|
+
var FieldLabel = (props) => {
|
|
1851
|
+
const { raw, optional = false, children, ...restProps } = props;
|
|
1852
|
+
const { id } = useField();
|
|
1853
|
+
return /* @__PURE__ */ React16.createElement(Label, { htmlFor: id, "data-raw": Boolean(raw), ...restProps }, children, !optional && /* @__PURE__ */ React16.createElement(Sup, null, "*"));
|
|
1854
|
+
};
|
|
1855
|
+
FieldLabel.displayName = "Field.Label";
|
|
1856
|
+
var FieldMeta = (props) => {
|
|
1857
|
+
const {
|
|
1858
|
+
raw,
|
|
1859
|
+
variant = "emphasis" /* Emphasis */,
|
|
1860
|
+
children,
|
|
1861
|
+
...restProps
|
|
1862
|
+
} = props;
|
|
1863
|
+
const metaId = React16.useId();
|
|
1864
|
+
const { id } = useField();
|
|
1865
|
+
return /* @__PURE__ */ React16.createElement(
|
|
1866
|
+
Def,
|
|
1867
|
+
{
|
|
1868
|
+
id: metaId,
|
|
1869
|
+
"aria-details": id,
|
|
1870
|
+
"data-variant": variant,
|
|
1871
|
+
"data-raw": Boolean(raw),
|
|
1872
|
+
...restProps
|
|
1873
|
+
},
|
|
1874
|
+
children
|
|
1875
|
+
);
|
|
1876
|
+
};
|
|
1877
|
+
FieldMeta.displayName = "Field.Meta";
|
|
1878
|
+
Field.Root = FieldRoot;
|
|
1879
|
+
Field.Wrapper = FieldWrapper;
|
|
1880
|
+
Field.Label = FieldLabel;
|
|
1881
|
+
Field.Meta = FieldMeta;
|
|
1882
|
+
|
|
1883
|
+
// src/otp-field/index.tsx
|
|
1884
|
+
import React18 from "react";
|
|
1885
|
+
|
|
1886
|
+
// src/otp-field/hooks/index.tsx
|
|
1887
|
+
import React17 from "react";
|
|
1888
|
+
var OTPFieldContext = React17.createContext(
|
|
1889
|
+
null
|
|
1890
|
+
);
|
|
1891
|
+
var useOTPField = () => {
|
|
1892
|
+
const context = React17.useContext(OTPFieldContext);
|
|
1893
|
+
if (!context) return null;
|
|
1894
|
+
return context;
|
|
1895
|
+
};
|
|
1896
|
+
|
|
1897
|
+
// src/otp-field/styles/index.ts
|
|
1898
|
+
import styled9 from "styled-components";
|
|
1899
|
+
var OTPCell = styled9.input`
|
|
1900
|
+
width: var(--measurement-medium-90);
|
|
1901
|
+
height: var(--measurement-medium-90);
|
|
1902
|
+
border: var(--measurement-small-10) solid var(--font-color-alpha-10);
|
|
1903
|
+
|
|
1904
|
+
border-radius: var(--measurement-medium-30);
|
|
1905
|
+
backdrop-filter: blur(var(--measurement-small-10));
|
|
1906
|
+
|
|
1907
|
+
text-align: center;
|
|
1908
|
+
font-size: var(--fontsize-medium-10);
|
|
1909
|
+
font-weight: 500;
|
|
1910
|
+
|
|
1911
|
+
color: var(--font-color-alpha-10);
|
|
1912
|
+
text-shadow: 0 0 0 var(--font-color);
|
|
1913
|
+
|
|
1914
|
+
background-color: transparent;
|
|
1915
|
+
transition: all 0.2s ease-in-out;
|
|
1916
|
+
outline: none;
|
|
1917
|
+
|
|
1918
|
+
&:focus:not(:active) {
|
|
1919
|
+
background-color: var(--font-color-alpha-10);
|
|
1920
|
+
}
|
|
1921
|
+
|
|
1922
|
+
&:hover:not(:active) {
|
|
1923
|
+
border-color: var(--font-color-alpha-20);
|
|
1924
|
+
}
|
|
1925
|
+
|
|
1926
|
+
&::placeholder {
|
|
1927
|
+
opacity: var(--opacity-default-10);
|
|
1928
|
+
}
|
|
1929
|
+
`;
|
|
1930
|
+
|
|
1931
|
+
// src/otp-field/index.tsx
|
|
1932
|
+
var OTPField = ({ children, length, onComplete }) => {
|
|
1933
|
+
const defaultLength = length ?? 6;
|
|
1934
|
+
const inputRefs = React18.useRef([]);
|
|
1935
|
+
const [otp, setOtp] = React18.useState(
|
|
1936
|
+
Array.from({ length: defaultLength }, () => "")
|
|
1937
|
+
);
|
|
1938
|
+
const [activeIndex, setActiveIndex] = React18.useState(0);
|
|
1939
|
+
const handleChange = (index, value) => {
|
|
1940
|
+
const newOtp = [...otp];
|
|
1941
|
+
newOtp[index] = value.substring(value.length - 1);
|
|
1942
|
+
setOtp(newOtp);
|
|
1943
|
+
if (value && index < defaultLength - 1) {
|
|
1944
|
+
setActiveIndex(index + 1);
|
|
1945
|
+
inputRefs.current[index + 1]?.focus();
|
|
1946
|
+
}
|
|
1947
|
+
};
|
|
1948
|
+
const handleKeyDown = (index, e) => {
|
|
1949
|
+
const enabledBehaviorKeys = ["Backspace", "Delete"];
|
|
1950
|
+
const disabledBehaviorKeys = [
|
|
1951
|
+
"Tab",
|
|
1952
|
+
"ArrowLeft",
|
|
1953
|
+
"ArrowRight",
|
|
1954
|
+
"Home",
|
|
1955
|
+
"End"
|
|
1956
|
+
];
|
|
1957
|
+
if (enabledBehaviorKeys.includes(e.key)) {
|
|
1958
|
+
if (otp[index]) {
|
|
1959
|
+
const newOtp = [...otp];
|
|
1960
|
+
newOtp[index] = "";
|
|
1961
|
+
setOtp(newOtp);
|
|
1962
|
+
return;
|
|
1963
|
+
}
|
|
1964
|
+
if (index > 0) {
|
|
1965
|
+
setActiveIndex(index - 1);
|
|
1966
|
+
inputRefs.current[index - 1]?.focus();
|
|
1967
|
+
}
|
|
1968
|
+
return;
|
|
1969
|
+
}
|
|
1970
|
+
if (disabledBehaviorKeys.includes(e.key) && !otp[index]) {
|
|
1971
|
+
e.preventDefault();
|
|
1972
|
+
}
|
|
1973
|
+
};
|
|
1974
|
+
const handleFocus = (index) => setActiveIndex(index);
|
|
1975
|
+
const handlePaste = (e) => {
|
|
1976
|
+
e.preventDefault();
|
|
1977
|
+
const pasteData = e.clipboardData.getData("text");
|
|
1978
|
+
const pasteArray = pasteData.slice(0, defaultLength).split("");
|
|
1979
|
+
const newOtp = [...otp];
|
|
1980
|
+
pasteArray.forEach((char, index) => {
|
|
1981
|
+
if (index < defaultLength) newOtp[index] = char;
|
|
1982
|
+
});
|
|
1983
|
+
setOtp(newOtp);
|
|
1984
|
+
const nextIndex = Math.min(pasteArray.length, defaultLength - 1);
|
|
1985
|
+
setActiveIndex(nextIndex);
|
|
1986
|
+
inputRefs.current[nextIndex]?.focus();
|
|
1987
|
+
};
|
|
1988
|
+
const handleClick = () => {
|
|
1989
|
+
const firstEmptyIndex = otp.findIndex((digit) => digit === "");
|
|
1990
|
+
const targetIndex = firstEmptyIndex === -1 ? defaultLength - 1 : firstEmptyIndex;
|
|
1991
|
+
setActiveIndex(targetIndex);
|
|
1992
|
+
inputRefs.current[targetIndex]?.focus();
|
|
1993
|
+
const timeout = setTimeout(
|
|
1994
|
+
() => inputRefs.current[targetIndex]?.select(),
|
|
1995
|
+
0
|
|
1996
|
+
);
|
|
1997
|
+
return () => clearTimeout(timeout);
|
|
1998
|
+
};
|
|
1999
|
+
React18.useEffect(() => {
|
|
2000
|
+
const otpString = otp.join("");
|
|
2001
|
+
if (otpString.length === defaultLength && onComplete) {
|
|
2002
|
+
onComplete(otpString);
|
|
2003
|
+
}
|
|
2004
|
+
}, [otp, defaultLength, onComplete]);
|
|
2005
|
+
const contextValue = React18.useMemo(() => {
|
|
2006
|
+
return {
|
|
2007
|
+
otp,
|
|
2008
|
+
activeIndex,
|
|
2009
|
+
inputRefs,
|
|
2010
|
+
length: defaultLength,
|
|
2011
|
+
handleChange,
|
|
2012
|
+
handleKeyDown,
|
|
2013
|
+
handleFocus,
|
|
2014
|
+
handleClick,
|
|
2015
|
+
handlePaste
|
|
2016
|
+
};
|
|
2017
|
+
}, [
|
|
2018
|
+
otp,
|
|
2019
|
+
activeIndex,
|
|
2020
|
+
inputRefs,
|
|
2021
|
+
defaultLength,
|
|
2022
|
+
handleChange,
|
|
2023
|
+
handleKeyDown,
|
|
2024
|
+
handleFocus,
|
|
2025
|
+
handleClick,
|
|
2026
|
+
handlePaste
|
|
2027
|
+
]);
|
|
2028
|
+
return /* @__PURE__ */ React18.createElement(OTPFieldContext.Provider, { value: contextValue }, children);
|
|
2029
|
+
};
|
|
2030
|
+
OTPField.displayName = "OTPField";
|
|
2031
|
+
var OTPFieldGroup = React18.forwardRef(({ ...props }, ref) => {
|
|
2032
|
+
return /* @__PURE__ */ React18.createElement("span", { ref, className: "flex g-medium-10 align-center", ...props });
|
|
2033
|
+
});
|
|
2034
|
+
OTPFieldGroup.displayName = "OTPField.Group";
|
|
2035
|
+
var OTPFieldSlot = ({
|
|
2036
|
+
index,
|
|
2037
|
+
...props
|
|
2038
|
+
}) => {
|
|
2039
|
+
const context = useOTPField();
|
|
2040
|
+
if (!context) return null;
|
|
2041
|
+
const {
|
|
2042
|
+
otp,
|
|
2043
|
+
activeIndex,
|
|
2044
|
+
inputRefs,
|
|
2045
|
+
handleChange,
|
|
2046
|
+
handleKeyDown,
|
|
2047
|
+
handleFocus,
|
|
2048
|
+
handleClick,
|
|
2049
|
+
handlePaste
|
|
2050
|
+
} = context;
|
|
2051
|
+
return /* @__PURE__ */ React18.createElement(
|
|
2052
|
+
OTPCell,
|
|
2053
|
+
{
|
|
2054
|
+
ref: (el) => inputRefs.current[index] = el,
|
|
2055
|
+
type: "text",
|
|
2056
|
+
"data-testid": "otp-field-slot",
|
|
2057
|
+
"data-active": activeIndex === index,
|
|
2058
|
+
autoComplete: "one-time-code",
|
|
2059
|
+
maxLength: 1,
|
|
2060
|
+
value: otp[index] || "",
|
|
2061
|
+
placeholder: props.placeholder || "-",
|
|
2062
|
+
onChange: (e) => handleChange(index, e.target.value),
|
|
2063
|
+
onKeyDown: (e) => handleKeyDown(index, e),
|
|
2064
|
+
onFocus: () => handleFocus(index),
|
|
2065
|
+
onMouseDown: () => handleClick(index),
|
|
2066
|
+
onClick: () => handleClick(index),
|
|
2067
|
+
onPaste: handlePaste,
|
|
2068
|
+
...props
|
|
2069
|
+
}
|
|
2070
|
+
);
|
|
2071
|
+
};
|
|
2072
|
+
OTPFieldSlot.displayName = "OTPField.Slot";
|
|
2073
|
+
OTPField.Group = OTPFieldGroup;
|
|
2074
|
+
OTPField.Slot = OTPFieldSlot;
|
|
2075
|
+
|
|
2076
|
+
// src/overlay/index.tsx
|
|
2077
|
+
import React19 from "react";
|
|
2078
|
+
|
|
2079
|
+
// src/overlay/styles/index.ts
|
|
2080
|
+
import styled10 from "styled-components";
|
|
2081
|
+
var OverlayWrapper = styled10.div`
|
|
2082
|
+
@keyframes animate-fade {
|
|
2083
|
+
0% {
|
|
2084
|
+
opacity: 0;
|
|
2085
|
+
}
|
|
2086
|
+
100% {
|
|
2087
|
+
opacity: 1;
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
|
|
2091
|
+
position: fixed;
|
|
2092
|
+
top: 0;
|
|
2093
|
+
left: 0;
|
|
2094
|
+
width: 100%;
|
|
2095
|
+
height: 100%;
|
|
2096
|
+
z-index: var(--depth-default-90);
|
|
2097
|
+
|
|
2098
|
+
&[data-raw="false"] {
|
|
2099
|
+
background-color: rgba(0, 0, 0, 0.6); // Always forced to black
|
|
2100
|
+
animation-duration: 0.2s;
|
|
2101
|
+
animation-name: animate-fade;
|
|
2102
|
+
animation-fill-mode: backwards;
|
|
2103
|
+
}
|
|
2104
|
+
`;
|
|
2105
|
+
|
|
2106
|
+
// src/overlay/index.tsx
|
|
2107
|
+
var Overlay = (props) => {
|
|
2108
|
+
const { raw, visible, closeOnInteract, onClick, ...restProps } = props;
|
|
2109
|
+
const [mounted, setMounted] = React19.useState(Boolean(visible));
|
|
2110
|
+
const handleClick = (event) => {
|
|
2111
|
+
if (onClick) onClick(event);
|
|
2112
|
+
if (closeOnInteract) setMounted(false);
|
|
2113
|
+
};
|
|
2114
|
+
React19.useEffect(() => {
|
|
2115
|
+
if (visible !== mounted) setMounted(Boolean(visible));
|
|
2116
|
+
}, [visible]);
|
|
2117
|
+
return /* @__PURE__ */ React19.createElement(React19.Fragment, null, mounted && /* @__PURE__ */ React19.createElement(
|
|
2118
|
+
OverlayWrapper,
|
|
2119
|
+
{
|
|
2120
|
+
tabIndex: -1,
|
|
2121
|
+
onClick: handleClick,
|
|
2122
|
+
"aria-hidden": true,
|
|
2123
|
+
"data-raw": Boolean(raw),
|
|
2124
|
+
...restProps
|
|
2125
|
+
}
|
|
2126
|
+
));
|
|
2127
|
+
};
|
|
2128
|
+
Overlay.displayName = "Overlay";
|
|
2129
|
+
|
|
2130
|
+
// src/page/index.tsx
|
|
2131
|
+
import React20 from "react";
|
|
2132
|
+
|
|
2133
|
+
// src/page/styles/index.ts
|
|
2134
|
+
import styled12 from "styled-components";
|
|
2135
|
+
|
|
2136
|
+
// src/scrollarea/styles/index.ts
|
|
2137
|
+
import styled11, { css as css8 } from "styled-components";
|
|
2138
|
+
var HiddenScrollbar = css8`
|
|
2139
|
+
scrollbar-width: none;
|
|
2140
|
+
|
|
2141
|
+
&::-webkit-scrollbar {
|
|
2142
|
+
display: none;
|
|
2143
|
+
width: 0;
|
|
2144
|
+
height: 0;
|
|
2145
|
+
}
|
|
2146
|
+
&::-moz-scrollbar {
|
|
2147
|
+
display: none;
|
|
2148
|
+
}
|
|
2149
|
+
`;
|
|
2150
|
+
var CustomScrollbar = css8`
|
|
2151
|
+
height: ${({ $height }) => $height || "100%"};
|
|
2152
|
+
width: ${({ $width }) => $width || "100%"};
|
|
2153
|
+
overflow-y: auto;
|
|
2154
|
+
overflow-x: hidden;
|
|
2155
|
+
|
|
2156
|
+
&::-webkit-scrollbar {
|
|
2157
|
+
cursor: pointer;
|
|
2158
|
+
|
|
2159
|
+
width: var(--measurement-medium-10);
|
|
2160
|
+
}
|
|
2161
|
+
|
|
2162
|
+
&::-webkit-scrollbar-track {
|
|
2163
|
+
background: ${({ $trackColor }) => $trackColor || "transparent"};
|
|
2164
|
+
border-radius: var(--measurement-medium-30);
|
|
2165
|
+
border: none;
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2168
|
+
&::-webkit-scrollbar-thumb {
|
|
2169
|
+
background: ${({ $thumbColor }) => $thumbColor || "var(--font-color-alpha-10)"};
|
|
2170
|
+
border-radius: var(--measurement-medium-30);
|
|
2171
|
+
transition: background-color 0.2s ease;
|
|
2172
|
+
}
|
|
2173
|
+
|
|
2174
|
+
&::-webkit-scrollbar-thumb:hover {
|
|
2175
|
+
background: ${({ $thumbHoverColor, $thumbColor }) => $thumbHoverColor || $thumbColor || "var(--font-color-alpha-20)"};
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2178
|
+
// Firefox
|
|
2179
|
+
scrollbar-width: thin;
|
|
2180
|
+
scrollbar-color: ${({ $thumbColor, $trackColor }) => `${$thumbColor || "var(--font-color-alpha-10)"} ${$trackColor || "transparent"}`};
|
|
2181
|
+
`;
|
|
2182
|
+
var ScrollAreaWrapper = styled11.div`
|
|
2183
|
+
overflow: scroll;
|
|
2184
|
+
|
|
2185
|
+
&[data-scrollbar="true"] {
|
|
2186
|
+
${CustomScrollbar}
|
|
2187
|
+
}
|
|
2188
|
+
&[data-scrollbar="false"] {
|
|
2189
|
+
${HiddenScrollbar}
|
|
2190
|
+
}
|
|
2191
|
+
`;
|
|
2192
|
+
|
|
2193
|
+
// src/page/styles/index.ts
|
|
2194
|
+
var PageRootWrapper = styled12.div`
|
|
2195
|
+
height: 100dvh;
|
|
2196
|
+
width: 100%;
|
|
2197
|
+
`;
|
|
2198
|
+
var PageNavWrapper = styled12.nav`
|
|
2199
|
+
background-color: var(--body-color);
|
|
2200
|
+
border: var(--measurement-small-10) solid transparent;
|
|
2201
|
+
border-bottom-color: var(--font-color-alpha-10);
|
|
2202
|
+
width: 100%;
|
|
2203
|
+
height: 100%;
|
|
2204
|
+
max-height: var(--measurement-large-20);
|
|
2205
|
+
padding: var(--measurement-medium-30);
|
|
2206
|
+
`;
|
|
2207
|
+
var PageMenuWrapper = styled12.menu`
|
|
2208
|
+
background-color: var(--body-color);
|
|
2209
|
+
border: var(--measurement-small-10) solid transparent;
|
|
2210
|
+
border-bottom-color: var(--font-color-alpha-10);
|
|
2211
|
+
width: 100%;
|
|
2212
|
+
height: 100%;
|
|
2213
|
+
max-height: var(--measurement-large-30);
|
|
2214
|
+
margin: 0;
|
|
2215
|
+
padding: var(--measurement-medium-60) var(--measurement-medium-30);
|
|
2216
|
+
`;
|
|
2217
|
+
var PagePanelWrapper = styled12.aside`
|
|
2218
|
+
position: absolute;
|
|
2219
|
+
bottom: 0;
|
|
2220
|
+
width: 100%;
|
|
2221
|
+
overflow: scroll;
|
|
2222
|
+
${HiddenScrollbar}
|
|
2223
|
+
`;
|
|
2224
|
+
var PageSectionWrapper = styled12.div`
|
|
2225
|
+
background: var(--body-color);
|
|
2226
|
+
width: 100%;
|
|
2227
|
+
height: 100%;
|
|
2228
|
+
`;
|
|
2229
|
+
var PageBodyWrapper = styled12.div`
|
|
2230
|
+
--menus-height: calc(
|
|
2231
|
+
var(--measurement-large-30) *
|
|
2232
|
+
${({ $menus }) => $menus ? Number($menus) : 0}
|
|
2233
|
+
);
|
|
2234
|
+
--navs-height: calc(
|
|
2235
|
+
var(--measurement-large-20) *
|
|
2236
|
+
${({ $navigations }) => $navigations ? Number($navigations) : 0}
|
|
2237
|
+
);
|
|
2238
|
+
--page-height: calc(100dvh - (var(--menus-height) + var(--navs-height)));
|
|
2239
|
+
|
|
2240
|
+
outline: none;
|
|
2241
|
+
display: inline-block;
|
|
2242
|
+
|
|
2243
|
+
height: var(--page-height);
|
|
2244
|
+
max-height: var(--page-height);
|
|
2245
|
+
|
|
2246
|
+
width: 100%;
|
|
2247
|
+
overflow: scroll;
|
|
2248
|
+
${HiddenScrollbar}
|
|
2249
|
+
`;
|
|
2250
|
+
|
|
2251
|
+
// src/page/index.tsx
|
|
2252
|
+
var Page = (props) => {
|
|
2253
|
+
const { children } = props;
|
|
2254
|
+
return /* @__PURE__ */ React20.createElement(PageRootWrapper, { className: "flex", ...props }, children);
|
|
2255
|
+
};
|
|
2256
|
+
Page.displayName = "Page";
|
|
2257
|
+
var PageNavigation = (props) => {
|
|
2258
|
+
const { children } = props;
|
|
2259
|
+
return /* @__PURE__ */ React20.createElement(PageNavWrapper, { ...props }, children);
|
|
2260
|
+
};
|
|
2261
|
+
PageNavigation.displayName = "Page.Navigation";
|
|
2262
|
+
var PageTools = (props) => {
|
|
2263
|
+
const {
|
|
2264
|
+
shortcut,
|
|
2265
|
+
hotkey,
|
|
2266
|
+
bindkey,
|
|
2267
|
+
raw,
|
|
2268
|
+
sizing,
|
|
2269
|
+
side,
|
|
2270
|
+
defaultOpen,
|
|
2271
|
+
fixed,
|
|
2272
|
+
showoncollapse,
|
|
2273
|
+
onClick,
|
|
2274
|
+
trigger,
|
|
2275
|
+
triggerProps,
|
|
2276
|
+
children
|
|
2277
|
+
} = props;
|
|
2278
|
+
const handleClick = (event) => {
|
|
2279
|
+
if (onClick) onClick(event);
|
|
2280
|
+
};
|
|
2281
|
+
return /* @__PURE__ */ React20.createElement(Toolbar.Root, null, /* @__PURE__ */ React20.createElement(
|
|
2282
|
+
Toolbar,
|
|
2283
|
+
{
|
|
2284
|
+
raw,
|
|
2285
|
+
sizing,
|
|
2286
|
+
side,
|
|
2287
|
+
shortcut: !fixed && shortcut,
|
|
2288
|
+
hotkey,
|
|
2289
|
+
bindkey,
|
|
2290
|
+
defaultOpen,
|
|
2291
|
+
...props
|
|
2292
|
+
},
|
|
2293
|
+
/* @__PURE__ */ React20.createElement(Toolbar.Section, { showoncollapse }, children),
|
|
2294
|
+
!fixed && /* @__PURE__ */ React20.createElement(
|
|
2295
|
+
Toolbar.Trigger,
|
|
2296
|
+
{
|
|
2297
|
+
title: shortcut ? `${bindkey ?? "ctrl"} + ${hotkey}` : "toolbar-trigger",
|
|
2298
|
+
onClick: handleClick,
|
|
2299
|
+
...triggerProps
|
|
2300
|
+
},
|
|
2301
|
+
trigger ?? /* @__PURE__ */ React20.createElement("span", null, "\u2194")
|
|
2302
|
+
)
|
|
2303
|
+
));
|
|
2304
|
+
};
|
|
2305
|
+
PageTools.displayName = "Page.Tools";
|
|
2306
|
+
var PageContent = (props) => {
|
|
2307
|
+
const { children } = props;
|
|
2308
|
+
return /* @__PURE__ */ React20.createElement(ScrollArea, { as: PageSectionWrapper, ...props }, children);
|
|
2309
|
+
};
|
|
2310
|
+
PageContent.displayName = "Page.Content";
|
|
2311
|
+
var PageWrapper = (props) => {
|
|
2312
|
+
const { children } = props;
|
|
2313
|
+
return /* @__PURE__ */ React20.createElement(PageBodyWrapper, { ...props }, children);
|
|
2314
|
+
};
|
|
2315
|
+
PageWrapper.displayName = "Page.Wrapper";
|
|
2316
|
+
var PagePanel = (props) => {
|
|
2317
|
+
const {
|
|
2318
|
+
shortcut,
|
|
2319
|
+
hotkey,
|
|
2320
|
+
bindkey,
|
|
2321
|
+
raw,
|
|
2322
|
+
sizing,
|
|
2323
|
+
height = "auto",
|
|
2324
|
+
side,
|
|
2325
|
+
defaultOpen,
|
|
2326
|
+
fixed,
|
|
2327
|
+
showoncollapse,
|
|
2328
|
+
onClick,
|
|
2329
|
+
trigger,
|
|
2330
|
+
triggerProps,
|
|
2331
|
+
children
|
|
2332
|
+
} = props;
|
|
2333
|
+
const handleClick = (event) => {
|
|
2334
|
+
if (onClick) onClick(event);
|
|
2335
|
+
};
|
|
2336
|
+
return /* @__PURE__ */ React20.createElement(Toolbar.Root, null, /* @__PURE__ */ React20.createElement(
|
|
2337
|
+
PagePanelWrapper,
|
|
2338
|
+
{
|
|
2339
|
+
as: Toolbar,
|
|
2340
|
+
raw,
|
|
2341
|
+
sizing,
|
|
2342
|
+
height,
|
|
2343
|
+
side,
|
|
2344
|
+
shortcut: !fixed && shortcut,
|
|
2345
|
+
hotkey,
|
|
2346
|
+
bindkey,
|
|
2347
|
+
defaultOpen,
|
|
2348
|
+
"aria-label": props["aria-label"]
|
|
2349
|
+
},
|
|
2350
|
+
!fixed && /* @__PURE__ */ React20.createElement(
|
|
2351
|
+
Toolbar.Trigger,
|
|
2352
|
+
{
|
|
2353
|
+
title: shortcut ? `${bindkey ?? "ctrl"} + ${hotkey}` : "toolbar-trigger",
|
|
2354
|
+
onClick: handleClick,
|
|
2355
|
+
...triggerProps
|
|
2356
|
+
},
|
|
2357
|
+
trigger ?? /* @__PURE__ */ React20.createElement("span", { style: { transform: "rotate(90deg)" } }, "\u2194")
|
|
2358
|
+
),
|
|
2359
|
+
/* @__PURE__ */ React20.createElement(Toolbar.Section, { showoncollapse }, children)
|
|
2360
|
+
));
|
|
2361
|
+
};
|
|
2362
|
+
PagePanel.displayName = "Page.Panel";
|
|
2363
|
+
var PageMenu = (props) => {
|
|
2364
|
+
const { children } = props;
|
|
2365
|
+
return /* @__PURE__ */ React20.createElement(PageMenuWrapper, { ...props }, children);
|
|
2366
|
+
};
|
|
2367
|
+
PageMenu.displayName = "Page.Menu";
|
|
2368
|
+
Page.Navigation = PageNavigation;
|
|
2369
|
+
Page.Tools = PageTools;
|
|
2370
|
+
Page.Wrapper = PageWrapper;
|
|
2371
|
+
Page.Content = PageContent;
|
|
2372
|
+
Page.Panel = PagePanel;
|
|
2373
|
+
Page.Menu = PageMenu;
|
|
2374
|
+
|
|
2375
|
+
// src/portal/index.tsx
|
|
2376
|
+
import React21 from "react";
|
|
2377
|
+
import { createPortal } from "react-dom";
|
|
2378
|
+
var Portal = (props) => {
|
|
2379
|
+
if (typeof document === "undefined") return null;
|
|
2380
|
+
const { container, children } = props;
|
|
2381
|
+
const [hasMounted, setHasMounted] = React21.useState(false);
|
|
2382
|
+
const [portalRoot, setPortalRoot] = React21.useState(null);
|
|
2383
|
+
React21.useEffect(() => {
|
|
2384
|
+
setHasMounted(true);
|
|
2385
|
+
setPortalRoot(document.querySelector(`#${container}`));
|
|
2386
|
+
}, [container]);
|
|
2387
|
+
if (!hasMounted || !portalRoot) return null;
|
|
2388
|
+
return createPortal(children, portalRoot);
|
|
2389
|
+
};
|
|
2390
|
+
Portal.displayName = "Portal";
|
|
2391
|
+
|
|
2392
|
+
// src/sheet/index.tsx
|
|
2393
|
+
import React23 from "react";
|
|
2394
|
+
|
|
2395
|
+
// src/sheet/hooks/index.tsx
|
|
2396
|
+
import React22 from "react";
|
|
2397
|
+
var SheetContext = React22.createContext({
|
|
2398
|
+
id: {},
|
|
2399
|
+
states: {},
|
|
2400
|
+
methods: {}
|
|
2401
|
+
});
|
|
2402
|
+
var useSheet = () => React22.useContext(SheetContext);
|
|
2403
|
+
var SheetProvider = ({ children }) => {
|
|
2404
|
+
const context = useSheetProvider();
|
|
2405
|
+
return /* @__PURE__ */ React22.createElement(SheetContext.Provider, { value: context }, children);
|
|
2406
|
+
};
|
|
2407
|
+
function useSheetProvider() {
|
|
2408
|
+
const containerId = React22.useId();
|
|
2409
|
+
const triggerId = React22.useId();
|
|
2410
|
+
const controlId = React22.useId();
|
|
2411
|
+
const [open, setOpen] = React22.useState(false);
|
|
2412
|
+
return {
|
|
2413
|
+
id: {
|
|
2414
|
+
containerId,
|
|
2415
|
+
triggerId,
|
|
2416
|
+
controlId
|
|
2417
|
+
},
|
|
2418
|
+
states: {
|
|
2419
|
+
open
|
|
2420
|
+
},
|
|
2421
|
+
methods: {
|
|
2422
|
+
setOpen,
|
|
2423
|
+
toggle: () => setOpen(!open)
|
|
2424
|
+
}
|
|
2425
|
+
};
|
|
2426
|
+
}
|
|
2427
|
+
|
|
2428
|
+
// src/sheet/styles/index.ts
|
|
2429
|
+
import styled13, { css as css9 } from "styled-components";
|
|
2430
|
+
var SheetStyles = css9`
|
|
2431
|
+
all: unset;
|
|
2432
|
+
position: fixed;
|
|
2433
|
+
background-color: var(--body-color);
|
|
2434
|
+
border: var(--measurement-small-10) solid transparent;
|
|
2435
|
+
padding: var(--measurement-medium-60);
|
|
2436
|
+
height: 100%;
|
|
2437
|
+
z-index: var(--depth-default-100);
|
|
2438
|
+
|
|
2439
|
+
@keyframes slide-right {
|
|
2440
|
+
0% {
|
|
2441
|
+
transform: translateX(calc(var(--measurement-large-90) * 2));
|
|
2442
|
+
}
|
|
2443
|
+
100% {
|
|
2444
|
+
transform: translateX(0);
|
|
2445
|
+
}
|
|
2446
|
+
}
|
|
2447
|
+
@keyframes slide-left {
|
|
2448
|
+
0% {
|
|
2449
|
+
transform: translateX(calc(var(--measurement-large-90) * -2));
|
|
2450
|
+
}
|
|
2451
|
+
100% {
|
|
2452
|
+
transform: translateX(0);
|
|
2453
|
+
}
|
|
2454
|
+
}
|
|
2455
|
+
|
|
2456
|
+
animation-delay: 0.2s;
|
|
2457
|
+
animation-duration: 0.2s;
|
|
2458
|
+
animation-timing-function: cubic-bezier(0.19, 1, 0.22, 1);
|
|
2459
|
+
animation-fill-mode: backwards;
|
|
2460
|
+
`;
|
|
2461
|
+
var SheetSizeStyles = css9`
|
|
2462
|
+
&[data-size="small"] {
|
|
2463
|
+
width: var(--measurement-large-80);
|
|
2464
|
+
}
|
|
2465
|
+
|
|
2466
|
+
&[data-size="medium"] {
|
|
2467
|
+
width: var(--measurement-large-90);
|
|
2468
|
+
}
|
|
2469
|
+
|
|
2470
|
+
&[data-size="large"] {
|
|
2471
|
+
width: calc(var(--measurement-large-90) * 1.5);
|
|
2472
|
+
}
|
|
2473
|
+
`;
|
|
2474
|
+
var SheetSideStyles = css9`
|
|
2475
|
+
top: 0;
|
|
2476
|
+
|
|
2477
|
+
&[data-side="right"] {
|
|
2478
|
+
right: 0;
|
|
2479
|
+
border-left-color: var(--font-color-alpha-10);
|
|
2480
|
+
animation-name: slide-right;
|
|
2481
|
+
}
|
|
2482
|
+
|
|
2483
|
+
&[data-side="left"] {
|
|
2484
|
+
left: 0;
|
|
2485
|
+
border-right-color: var(--font-color-alpha-10);
|
|
2486
|
+
animation-name: slide-left;
|
|
2487
|
+
}
|
|
2488
|
+
`;
|
|
2489
|
+
var SheetWrapper = styled13.dialog`
|
|
2490
|
+
&[data-raw="false"] {
|
|
2491
|
+
${SheetStyles}
|
|
2492
|
+
${SheetSideStyles}
|
|
2493
|
+
${SheetSizeStyles}
|
|
2494
|
+
}
|
|
2495
|
+
`;
|
|
2496
|
+
|
|
2497
|
+
// src/sheet/index.tsx
|
|
2498
|
+
var SheetRoot = ({ children }) => {
|
|
2499
|
+
return /* @__PURE__ */ React23.createElement(SheetProvider, null, children);
|
|
2500
|
+
};
|
|
2501
|
+
SheetRoot.displayName = "Sheet.Root";
|
|
2502
|
+
var Sheet = (props) => {
|
|
2503
|
+
const {
|
|
2504
|
+
raw,
|
|
2505
|
+
sizing = "medium" /* Medium */,
|
|
2506
|
+
side = "right" /* Right */,
|
|
2507
|
+
lock = true,
|
|
2508
|
+
overlay = true,
|
|
2509
|
+
closeOnInteract = true,
|
|
2510
|
+
open,
|
|
2511
|
+
shortcut,
|
|
2512
|
+
bindkey = "ctrlKey" /* Ctrl */,
|
|
2513
|
+
hotkey,
|
|
2514
|
+
children,
|
|
2515
|
+
...restProps
|
|
2516
|
+
} = props;
|
|
2517
|
+
const { id, states, methods } = useSheet();
|
|
2518
|
+
const { toggle } = methods;
|
|
2519
|
+
const shortcutControls = useKeyPress(String(hotkey), true, bindkey);
|
|
2520
|
+
React23.useEffect(() => {
|
|
2521
|
+
if (open && toggle) return toggle();
|
|
2522
|
+
}, [open]);
|
|
2523
|
+
React23.useEffect(() => {
|
|
2524
|
+
if (shortcut && shortcutControls && toggle) {
|
|
2525
|
+
return toggle();
|
|
2526
|
+
}
|
|
2527
|
+
}, [shortcutControls]);
|
|
2528
|
+
useDisabledScroll(lock && Boolean(states.open));
|
|
2529
|
+
return /* @__PURE__ */ React23.createElement(React23.Fragment, null, states.open && /* @__PURE__ */ React23.createElement(React23.Fragment, null, /* @__PURE__ */ React23.createElement(
|
|
2530
|
+
SheetWrapper,
|
|
2531
|
+
{
|
|
2532
|
+
role: "dialog",
|
|
2533
|
+
tabIndex: -1,
|
|
2534
|
+
id: String(id.containerId),
|
|
2535
|
+
"aria-label": props["aria-label"] ?? `${id.containerId}-sheet`,
|
|
2536
|
+
"aria-labelledby": String(id.containerId),
|
|
2537
|
+
open: Boolean(states.open),
|
|
2538
|
+
"data-expanded": Boolean(states.open),
|
|
2539
|
+
"data-state": applyDataState(Boolean(states.open)),
|
|
2540
|
+
"data-size": sizing,
|
|
2541
|
+
"data-side": side,
|
|
2542
|
+
"data-raw": Boolean(raw),
|
|
2543
|
+
...restProps
|
|
2544
|
+
},
|
|
2545
|
+
children
|
|
2546
|
+
), overlay && /* @__PURE__ */ React23.createElement(
|
|
2547
|
+
Overlay,
|
|
2548
|
+
{
|
|
2549
|
+
onClick: () => toggle && toggle(!states.open),
|
|
2550
|
+
visible: Boolean(states.open),
|
|
2551
|
+
closeOnInteract,
|
|
2552
|
+
"aria-label": props["aria-label"] ? `${props["aria-label"]}-overlay` : `${id.containerId}-sheet-overlay`
|
|
2553
|
+
}
|
|
2554
|
+
)));
|
|
2555
|
+
};
|
|
2556
|
+
Sheet.displayName = "Sheet";
|
|
2557
|
+
var SheetTrigger = (props) => {
|
|
2558
|
+
const {
|
|
2559
|
+
raw,
|
|
2560
|
+
onClick,
|
|
2561
|
+
variant = "ghost" /* Ghost */,
|
|
2562
|
+
sizing = "small" /* Small */,
|
|
2563
|
+
children,
|
|
2564
|
+
...restProps
|
|
2565
|
+
} = props;
|
|
2566
|
+
const { id, methods, states } = useSheet();
|
|
2567
|
+
const { toggle } = methods;
|
|
2568
|
+
const handleClick = (event) => {
|
|
2569
|
+
if (onClick) onClick(event);
|
|
2570
|
+
if (toggle) toggle(!states.open);
|
|
2571
|
+
};
|
|
2572
|
+
return /* @__PURE__ */ React23.createElement(
|
|
2573
|
+
Button,
|
|
2574
|
+
{
|
|
2575
|
+
id: id.triggerId,
|
|
2576
|
+
"aria-controls": String(id.containerId),
|
|
2577
|
+
"data-state": applyDataState(Boolean(states.open)),
|
|
2578
|
+
variant,
|
|
2579
|
+
sizing,
|
|
2580
|
+
raw: Boolean(raw),
|
|
2581
|
+
onClick: handleClick,
|
|
2582
|
+
...restProps
|
|
2583
|
+
},
|
|
2584
|
+
children
|
|
2585
|
+
);
|
|
2586
|
+
};
|
|
2587
|
+
SheetTrigger.displayName = "Sheet.Trigger";
|
|
2588
|
+
Sheet.Root = SheetRoot;
|
|
2589
|
+
Sheet.Trigger = SheetTrigger;
|
|
2590
|
+
|
|
2591
|
+
// src/scrollarea/index.tsx
|
|
2592
|
+
import React24 from "react";
|
|
2593
|
+
var ScrollArea = ({
|
|
2594
|
+
scrollbar = false,
|
|
2595
|
+
children,
|
|
2596
|
+
...restProps
|
|
2597
|
+
}) => {
|
|
2598
|
+
return /* @__PURE__ */ React24.createElement(
|
|
2599
|
+
ScrollAreaWrapper,
|
|
2600
|
+
{
|
|
2601
|
+
"aria-hidden": "true",
|
|
2602
|
+
"data-scrollbar": scrollbar,
|
|
2603
|
+
...restProps
|
|
2604
|
+
},
|
|
2605
|
+
children
|
|
2606
|
+
);
|
|
2607
|
+
};
|
|
2608
|
+
|
|
2609
|
+
// src/switch/index.tsx
|
|
2610
|
+
import React26 from "react";
|
|
2611
|
+
|
|
2612
|
+
// src/switch/hooks/index.tsx
|
|
2613
|
+
import React25, { useState as useState6, createContext as createContext6, useContext as useContext6 } from "react";
|
|
2614
|
+
var defaultComponentAPI6 = {
|
|
2615
|
+
id: "",
|
|
2616
|
+
states: {},
|
|
2617
|
+
methods: {}
|
|
2618
|
+
};
|
|
2619
|
+
var SwitchContext = createContext6(defaultComponentAPI6);
|
|
2620
|
+
var useSwitch = () => useContext6(SwitchContext);
|
|
2621
|
+
var SwitchProvider = ({ children }) => {
|
|
2622
|
+
const context = useSwitchProvider();
|
|
2623
|
+
return /* @__PURE__ */ React25.createElement(SwitchContext.Provider, { value: context }, children);
|
|
2624
|
+
};
|
|
2625
|
+
function useSwitchProvider() {
|
|
2626
|
+
const [checked, setChecked] = useState6(false);
|
|
2627
|
+
const switchId = React25.useId();
|
|
2628
|
+
return {
|
|
2629
|
+
id: switchId,
|
|
2630
|
+
states: {
|
|
2631
|
+
checked
|
|
2632
|
+
},
|
|
2633
|
+
methods: {
|
|
2634
|
+
toggleSwitch: () => setChecked(!checked)
|
|
2635
|
+
}
|
|
2636
|
+
};
|
|
2637
|
+
}
|
|
2638
|
+
|
|
2639
|
+
// src/switch/styles/index.ts
|
|
2640
|
+
import styled14, { css as css10 } from "styled-components";
|
|
2641
|
+
var SwitchDefaultStyles = css10`
|
|
2642
|
+
all: unset;
|
|
2643
|
+
|
|
2644
|
+
border: var(--measurement-small-10) solid transparent;
|
|
2645
|
+
border-radius: var(--measurement-large-90);
|
|
2646
|
+
transition: all 0.2s ease-in-out 0s;
|
|
2647
|
+
|
|
2648
|
+
cursor: pointer;
|
|
2649
|
+
|
|
2650
|
+
&:disabled {
|
|
2651
|
+
cursor: not-allowed;
|
|
2652
|
+
opacity: 0.6;
|
|
2653
|
+
}
|
|
2654
|
+
`;
|
|
2655
|
+
var SwitchVariantsStyles = css10`
|
|
2656
|
+
&[data-variant="primary"] {
|
|
2657
|
+
&[aria-checked="true"] {
|
|
2658
|
+
background-color: var(--color-green);
|
|
2659
|
+
border-color: var(--font-color-alpha-10);
|
|
2660
|
+
}
|
|
2661
|
+
&[aria-checked="false"] {
|
|
2662
|
+
background-color: var(--font-color-alpha-10);
|
|
2663
|
+
border-color: var(--font-color-alpha-10);
|
|
2664
|
+
}
|
|
2665
|
+
}
|
|
2666
|
+
&[data-variant="secondary"] {
|
|
2667
|
+
&[aria-checked="true"] {
|
|
2668
|
+
background-color: var(--font-color-alpha-10);
|
|
2669
|
+
border-color: var(--font-color-alpha-10);
|
|
2670
|
+
}
|
|
2671
|
+
&[aria-checked="false"] {
|
|
2672
|
+
background-color: var(--body-color-alpha-10);
|
|
2673
|
+
}
|
|
2674
|
+
}
|
|
2675
|
+
|
|
2676
|
+
&[data-variant="ghost"] {
|
|
2677
|
+
&[aria-checked="true"] {
|
|
2678
|
+
border-color: var(--font-color-alpha-10);
|
|
2679
|
+
background-color: var(--body-color-alpha-10);
|
|
2680
|
+
}
|
|
2681
|
+
&[aria-checked="false"] {
|
|
2682
|
+
border-color: var(--font-color-alpha-10);
|
|
2683
|
+
}
|
|
2684
|
+
}
|
|
2685
|
+
`;
|
|
2686
|
+
var SwitchSizeStyles = css10`
|
|
2687
|
+
&[data-size="small"] {
|
|
2688
|
+
width: calc(var(--measurement-medium-60) * 1.33);
|
|
2689
|
+
height: var(--measurement-medium-50);
|
|
2690
|
+
|
|
2691
|
+
span {
|
|
2692
|
+
width: var(--measurement-medium-40);
|
|
2693
|
+
height: var(--measurement-medium-40);
|
|
2694
|
+
&[data-checked="true"] {
|
|
2695
|
+
transform: translateX(var(--measurement-medium-40));
|
|
2696
|
+
}
|
|
2697
|
+
&[data-checked="false"] {
|
|
2698
|
+
transform: translateX(var(--measurement-small-60));
|
|
2699
|
+
}
|
|
2700
|
+
}
|
|
2701
|
+
}
|
|
2702
|
+
|
|
2703
|
+
&[data-size="medium"] {
|
|
2704
|
+
width: calc(var(--measurement-medium-60) * 1.66);
|
|
2705
|
+
height: var(--measurement-medium-60);
|
|
2706
|
+
|
|
2707
|
+
span {
|
|
2708
|
+
width: var(--measurement-medium-50);
|
|
2709
|
+
height: var(--measurement-medium-50);
|
|
2710
|
+
&[data-checked="true"] {
|
|
2711
|
+
transform: translateX(var(--measurement-medium-50));
|
|
2712
|
+
}
|
|
2713
|
+
&[data-checked="false"] {
|
|
2714
|
+
transform: translateX(var(--measurement-small-60));
|
|
2715
|
+
}
|
|
2716
|
+
}
|
|
2717
|
+
}
|
|
2718
|
+
|
|
2719
|
+
&[data-size="large"] {
|
|
2720
|
+
width: calc(var(--measurement-medium-60) * 2.33);
|
|
2721
|
+
height: var(--measurement-medium-70);
|
|
2722
|
+
|
|
2723
|
+
span {
|
|
2724
|
+
width: var(--measurement-medium-60);
|
|
2725
|
+
height: var(--measurement-medium-60);
|
|
2726
|
+
&[data-checked="true"] {
|
|
2727
|
+
transform: translateX(calc(var(--measurement-medium-60) * 1.133));
|
|
2728
|
+
}
|
|
2729
|
+
&[data-checked="false"] {
|
|
2730
|
+
transform: translateX(var(--measurement-small-80));
|
|
2731
|
+
}
|
|
2732
|
+
}
|
|
2733
|
+
}
|
|
2734
|
+
`;
|
|
2735
|
+
var TriggerWrapper = styled14.button`
|
|
2736
|
+
&[data-raw="false"] {
|
|
2737
|
+
${SwitchDefaultStyles}
|
|
2738
|
+
${SwitchVariantsStyles}
|
|
2739
|
+
${SwitchSizeStyles}
|
|
2740
|
+
}
|
|
2741
|
+
`;
|
|
2742
|
+
var Thumb = styled14.span`
|
|
2743
|
+
&[data-raw="false"] {
|
|
2744
|
+
all: unset;
|
|
2745
|
+
display: block;
|
|
2746
|
+
|
|
2747
|
+
background: var(--font-color-alpha-60);
|
|
2748
|
+
border-radius: 100%;
|
|
2749
|
+
transition: all 0.1s ease-in-out 0.2s;
|
|
2750
|
+
|
|
2751
|
+
&[data-checked="true"] {
|
|
2752
|
+
background: var(--font-color);
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
2755
|
+
`;
|
|
2756
|
+
|
|
2757
|
+
// src/switch/index.tsx
|
|
2758
|
+
var Switch = (props) => {
|
|
2759
|
+
const {
|
|
2760
|
+
raw,
|
|
2761
|
+
sizing = "medium" /* Medium */,
|
|
2762
|
+
variant = "primary" /* Primary */,
|
|
2763
|
+
value,
|
|
2764
|
+
defaultChecked,
|
|
2765
|
+
disabled,
|
|
2766
|
+
onClick,
|
|
2767
|
+
children,
|
|
2768
|
+
...restProps
|
|
2769
|
+
} = props;
|
|
2770
|
+
const { id, states, methods } = useSwitch();
|
|
2771
|
+
const { toggleSwitch } = methods;
|
|
2772
|
+
const handleClick = (event) => {
|
|
2773
|
+
if (onClick) onClick(event);
|
|
2774
|
+
if (toggleSwitch) toggleSwitch();
|
|
2775
|
+
};
|
|
2776
|
+
React26.useEffect(() => {
|
|
2777
|
+
if (defaultChecked && toggleSwitch) toggleSwitch();
|
|
2778
|
+
}, [defaultChecked]);
|
|
2779
|
+
return /* @__PURE__ */ React26.createElement(
|
|
2780
|
+
TriggerWrapper,
|
|
2781
|
+
{
|
|
2782
|
+
type: "button",
|
|
2783
|
+
role: "switch",
|
|
2784
|
+
title: "switch-trigger",
|
|
2785
|
+
onClick: handleClick,
|
|
2786
|
+
value: String(states.checked),
|
|
2787
|
+
"aria-label": `${id}-switch-trigger`,
|
|
2788
|
+
"aria-checked": Boolean(states.checked),
|
|
2789
|
+
"data-disabled": String(disabled ?? false),
|
|
2790
|
+
"data-variant": variant,
|
|
2791
|
+
"data-size": sizing,
|
|
2792
|
+
"data-raw": Boolean(raw),
|
|
2793
|
+
...restProps
|
|
2794
|
+
},
|
|
2795
|
+
/* @__PURE__ */ React26.createElement("title", null, "Switch"),
|
|
2796
|
+
children
|
|
2797
|
+
);
|
|
2798
|
+
};
|
|
2799
|
+
Switch.displayName = "Switch";
|
|
2800
|
+
var SwitchRoot = ({ children }) => {
|
|
2801
|
+
return /* @__PURE__ */ React26.createElement(SwitchProvider, null, children);
|
|
2802
|
+
};
|
|
2803
|
+
SwitchRoot.displayName = "Switch.Root";
|
|
2804
|
+
var SwitchThumb = (props) => {
|
|
2805
|
+
const { raw, sizing } = props;
|
|
2806
|
+
const { id, states } = useSwitch();
|
|
2807
|
+
return /* @__PURE__ */ React26.createElement(
|
|
2808
|
+
Thumb,
|
|
2809
|
+
{
|
|
2810
|
+
role: "presentation",
|
|
2811
|
+
title: "switch-thumb",
|
|
2812
|
+
tabIndex: -1,
|
|
2813
|
+
"aria-hidden": true,
|
|
2814
|
+
"aria-label": `${id}-switch-thumb`,
|
|
2815
|
+
"data-checked": states.checked,
|
|
2816
|
+
"data-raw": Boolean(raw),
|
|
2817
|
+
"data-size": sizing ?? "medium" /* Medium */,
|
|
2818
|
+
...props
|
|
2819
|
+
}
|
|
2820
|
+
);
|
|
2821
|
+
};
|
|
2822
|
+
SwitchThumb.displayName = "Switch.Thumb";
|
|
2823
|
+
Switch.Root = SwitchRoot;
|
|
2824
|
+
Switch.Thumb = SwitchThumb;
|
|
2825
|
+
|
|
2826
|
+
// src/table/index.tsx
|
|
2827
|
+
import React27 from "react";
|
|
2828
|
+
|
|
2829
|
+
// src/table/styles/index.ts
|
|
2830
|
+
import styled15, { css as css11 } from "styled-components";
|
|
2831
|
+
var CellStyles = css11`
|
|
2832
|
+
box-sizing: border-box;
|
|
2833
|
+
border: none;
|
|
2834
|
+
line-height: 1;
|
|
2835
|
+
font-weight: 500;
|
|
2836
|
+
padding: var(--measurement-medium-40) var(--measurement-medium-30);
|
|
2837
|
+
letter-spacing: calc(
|
|
2838
|
+
var(--fontsize-small-10) - ((var(--fontsize-small-10) * 1.066))
|
|
2839
|
+
);
|
|
2840
|
+
`;
|
|
2841
|
+
var TableLayer = styled15.div`
|
|
2842
|
+
border-radius: var(--measurement-medium-30);
|
|
2843
|
+
border: var(--measurement-small-10) solid var(--font-color-alpha-10);
|
|
2844
|
+
`;
|
|
2845
|
+
var TableWrapper = styled15.table`
|
|
2846
|
+
border-collapse: collapse;
|
|
2847
|
+
|
|
2848
|
+
tbody {
|
|
2849
|
+
tr {
|
|
2850
|
+
&:last-of-type {
|
|
2851
|
+
border-bottom: none;
|
|
2852
|
+
}
|
|
2853
|
+
}
|
|
2854
|
+
}
|
|
2855
|
+
`;
|
|
2856
|
+
var RowWrapper = styled15.tr`
|
|
2857
|
+
border-bottom: var(--measurement-small-10) solid var(--font-color-alpha-10);
|
|
2858
|
+
|
|
2859
|
+
transition: background-color linear 0.1s;
|
|
2860
|
+
|
|
2861
|
+
&:hover {
|
|
2862
|
+
background-color: var(--font-color-alpha-10);
|
|
2863
|
+
}
|
|
2864
|
+
`;
|
|
2865
|
+
var HeadCellWrapper = styled15.th`
|
|
2866
|
+
font-size: var(--fontsize-medium-10);
|
|
2867
|
+
${CellStyles}
|
|
2868
|
+
|
|
2869
|
+
div {
|
|
2870
|
+
color: var(--font-color-alpha-60);
|
|
2871
|
+
}
|
|
2872
|
+
`;
|
|
2873
|
+
var CellWrapper = styled15.td`
|
|
2874
|
+
${CellStyles}
|
|
2875
|
+
`;
|
|
2876
|
+
|
|
2877
|
+
// src/table/index.tsx
|
|
2878
|
+
var Table = ({
|
|
2879
|
+
children,
|
|
2880
|
+
...restProps
|
|
2881
|
+
}) => {
|
|
2882
|
+
return /* @__PURE__ */ React27.createElement(ScrollArea, { as: TableLayer, role: "presentation", tabIndex: -1 }, /* @__PURE__ */ React27.createElement(TableWrapper, { ...restProps, cellSpacing: "0", cellPadding: "0" }, children));
|
|
2883
|
+
};
|
|
2884
|
+
Table.displayName = "Table";
|
|
2885
|
+
var TableHead = ({
|
|
2886
|
+
children,
|
|
2887
|
+
...restProps
|
|
2888
|
+
}) => {
|
|
2889
|
+
return /* @__PURE__ */ React27.createElement("thead", { ...restProps }, children);
|
|
2890
|
+
};
|
|
2891
|
+
TableHead.displayName = "Table.Head";
|
|
2892
|
+
var TableBody = ({
|
|
2893
|
+
children,
|
|
2894
|
+
...restProps
|
|
2895
|
+
}) => {
|
|
2896
|
+
return /* @__PURE__ */ React27.createElement("tbody", { ...restProps }, children);
|
|
2897
|
+
};
|
|
2898
|
+
TableBody.displayName = "Table.Body";
|
|
2899
|
+
var TableHeadCell = ({
|
|
2900
|
+
children,
|
|
2901
|
+
...restProps
|
|
2902
|
+
}) => {
|
|
2903
|
+
return /* @__PURE__ */ React27.createElement(HeadCellWrapper, { colSpan: 1, ...restProps }, /* @__PURE__ */ React27.createElement("div", { className: "flex align-center g-medium-30" }, children));
|
|
2904
|
+
};
|
|
2905
|
+
TableHeadCell.displayName = "Table.HeadCell";
|
|
2906
|
+
var TableRow = ({ children, ...restProps }) => {
|
|
2907
|
+
return /* @__PURE__ */ React27.createElement(RowWrapper, { className: "p-medium-30", ...restProps }, children);
|
|
2908
|
+
};
|
|
2909
|
+
TableRow.displayName = "Table.Row";
|
|
2910
|
+
var TableCell = ({ children, ...restProps }) => {
|
|
2911
|
+
return /* @__PURE__ */ React27.createElement(CellWrapper, { ...restProps }, /* @__PURE__ */ React27.createElement("div", { className: "flex align-center g-medium-30" }, children));
|
|
2912
|
+
};
|
|
2913
|
+
TableCell.displayName = "Table.Cell";
|
|
2914
|
+
var TableFooter = ({
|
|
2915
|
+
children,
|
|
2916
|
+
...restProps
|
|
2917
|
+
}) => {
|
|
2918
|
+
return /* @__PURE__ */ React27.createElement("tfoot", { ...restProps }, children);
|
|
2919
|
+
};
|
|
2920
|
+
TableFooter.displayName = "Table.Footer";
|
|
2921
|
+
Table.Head = TableHead;
|
|
2922
|
+
Table.Body = TableBody;
|
|
2923
|
+
Table.HeadCell = TableHeadCell;
|
|
2924
|
+
Table.Row = TableRow;
|
|
2925
|
+
Table.Cell = TableCell;
|
|
2926
|
+
Table.Footer = TableFooter;
|
|
2927
|
+
|
|
2928
|
+
// src/tabs/index.tsx
|
|
2929
|
+
import React29, { Children } from "react";
|
|
2930
|
+
|
|
2931
|
+
// src/tabs/hooks/index.tsx
|
|
2932
|
+
import React28, { createContext as createContext7, useContext as useContext7, useState as useState7 } from "react";
|
|
2933
|
+
var defaultComponentAPI7 = {
|
|
2934
|
+
id: "",
|
|
2935
|
+
states: {},
|
|
2936
|
+
methods: {}
|
|
2937
|
+
};
|
|
2938
|
+
var TabsContext = createContext7(defaultComponentAPI7);
|
|
2939
|
+
var useTabs = () => useContext7(TabsContext);
|
|
2940
|
+
var TabsProvider = ({ children }) => {
|
|
2941
|
+
const context = useTabsProvider();
|
|
2942
|
+
return /* @__PURE__ */ React28.createElement(TabsContext.Provider, { value: context }, children);
|
|
2943
|
+
};
|
|
2944
|
+
function useTabsProvider() {
|
|
2945
|
+
const [value, setValue] = useState7(null);
|
|
2946
|
+
const tabsId = React28.useId();
|
|
2947
|
+
return {
|
|
2948
|
+
id: tabsId,
|
|
2949
|
+
states: {
|
|
2950
|
+
value
|
|
2951
|
+
},
|
|
2952
|
+
methods: {
|
|
2953
|
+
applyValue: (value2) => setValue(value2),
|
|
2954
|
+
getTabsId: ({ value: value2, type }) => `${tabsId}-${type}-${value2}`
|
|
2955
|
+
}
|
|
2956
|
+
};
|
|
2957
|
+
}
|
|
2958
|
+
|
|
2959
|
+
// src/tabs/styles/index.ts
|
|
2960
|
+
import styled16 from "styled-components";
|
|
2961
|
+
var TabWrapper = styled16.div`
|
|
2962
|
+
button {
|
|
2963
|
+
&[aria-selected="true"] {
|
|
2964
|
+
color: var(--font-color) !important;
|
|
2965
|
+
}
|
|
2966
|
+
}
|
|
2967
|
+
`;
|
|
2968
|
+
|
|
2969
|
+
// src/tabs/index.tsx
|
|
2970
|
+
var Tabs = (props) => {
|
|
2971
|
+
const { defaultOpen, children, ...restProps } = props;
|
|
2972
|
+
const { methods } = useTabs();
|
|
2973
|
+
const { applyValue } = methods;
|
|
2974
|
+
const childArray = Children.toArray(children);
|
|
2975
|
+
const firstChild = childArray[0];
|
|
2976
|
+
React29.useEffect(() => {
|
|
2977
|
+
if (React29.isValidElement(firstChild)) {
|
|
2978
|
+
if (childArray.length > 0 && applyValue)
|
|
2979
|
+
applyValue(firstChild.props.value);
|
|
2980
|
+
}
|
|
2981
|
+
}, []);
|
|
2982
|
+
React29.useEffect(() => {
|
|
2983
|
+
if (defaultOpen && applyValue) applyValue(defaultOpen);
|
|
2984
|
+
}, []);
|
|
2985
|
+
return /* @__PURE__ */ React29.createElement(TabWrapper, { role: "tablist", ...restProps }, children);
|
|
2986
|
+
};
|
|
2987
|
+
Tabs.displayName = "Tabs";
|
|
2988
|
+
var TabsRoot = ({ children }) => {
|
|
2989
|
+
return /* @__PURE__ */ React29.createElement(TabsProvider, null, children);
|
|
2990
|
+
};
|
|
2991
|
+
TabsRoot.displayName = "Tabs.Root";
|
|
2992
|
+
var TabsTrigger = (props) => {
|
|
2993
|
+
const { value, onClick, children, ...restProps } = props;
|
|
2994
|
+
const { states, methods } = useTabs();
|
|
2995
|
+
const { applyValue, getTabsId } = methods;
|
|
2996
|
+
const hasSameValueAsContext = value === states.value;
|
|
2997
|
+
const IdHandler = {
|
|
2998
|
+
trigger: getTabsId && getTabsId({ value, type: "trigger" }),
|
|
2999
|
+
content: getTabsId && getTabsId({ value, type: "content" })
|
|
3000
|
+
};
|
|
3001
|
+
const handleClick = (event) => {
|
|
3002
|
+
if (applyValue) applyValue(value);
|
|
3003
|
+
if (onClick) onClick(event);
|
|
3004
|
+
};
|
|
3005
|
+
return /* @__PURE__ */ React29.createElement(
|
|
3006
|
+
Button,
|
|
3007
|
+
{
|
|
3008
|
+
type: "button",
|
|
3009
|
+
role: "tab",
|
|
3010
|
+
title: `${value}-tab`,
|
|
3011
|
+
id: String(IdHandler.trigger),
|
|
3012
|
+
value,
|
|
3013
|
+
onClick: handleClick,
|
|
3014
|
+
"aria-selected": hasSameValueAsContext,
|
|
3015
|
+
"data-controls": IdHandler.content,
|
|
3016
|
+
"data-state": hasSameValueAsContext ? "active" : "inactive",
|
|
3017
|
+
variant: props.variant ?? "ghost" /* Ghost */,
|
|
3018
|
+
...restProps
|
|
3019
|
+
},
|
|
3020
|
+
children
|
|
3021
|
+
);
|
|
3022
|
+
};
|
|
3023
|
+
TabsTrigger.displayName = "Tabs.Trigger";
|
|
3024
|
+
var TabsContent = (props) => {
|
|
3025
|
+
const { value, children, ...restProps } = props;
|
|
3026
|
+
const { states, methods } = useTabs();
|
|
3027
|
+
const { getTabsId } = methods;
|
|
3028
|
+
const hasSameValueAsContext = value === states.value;
|
|
3029
|
+
const IdHandler = {
|
|
3030
|
+
trigger: getTabsId && getTabsId({ value, type: "trigger" }),
|
|
3031
|
+
content: getTabsId && getTabsId({ value, type: "content" })
|
|
3032
|
+
};
|
|
3033
|
+
return /* @__PURE__ */ React29.createElement(
|
|
3034
|
+
"div",
|
|
3035
|
+
{
|
|
3036
|
+
tabIndex: 0,
|
|
3037
|
+
role: "tabpanel",
|
|
3038
|
+
title: `${value}-tabpanel`,
|
|
3039
|
+
id: String(IdHandler.content),
|
|
3040
|
+
"data-value": value,
|
|
3041
|
+
"data-state": hasSameValueAsContext ? "active" : "inactive",
|
|
3042
|
+
"aria-labelledby": IdHandler.trigger ?? restProps["aria-labelledby"],
|
|
3043
|
+
...restProps
|
|
3044
|
+
},
|
|
3045
|
+
hasSameValueAsContext && children
|
|
3046
|
+
);
|
|
3047
|
+
};
|
|
3048
|
+
TabsContent.displayName = "Tabs.Content";
|
|
3049
|
+
Tabs.Root = TabsRoot;
|
|
3050
|
+
Tabs.Trigger = TabsTrigger;
|
|
3051
|
+
Tabs.Content = TabsContent;
|
|
3052
|
+
|
|
3053
|
+
// src/toggle/index.tsx
|
|
3054
|
+
import React30 from "react";
|
|
3055
|
+
var Toggle = (props) => {
|
|
3056
|
+
const { defaultChecked, onClick, disabled, children, ...restProps } = props;
|
|
3057
|
+
const [checked, setChecked] = React30.useState(
|
|
3058
|
+
defaultChecked ?? false
|
|
3059
|
+
);
|
|
3060
|
+
const handleClick = (event) => {
|
|
3061
|
+
if (onClick) onClick(event);
|
|
3062
|
+
if (!disabled) setChecked((prevChecked) => !prevChecked);
|
|
3063
|
+
};
|
|
3064
|
+
React30.useEffect(() => {
|
|
3065
|
+
if (defaultChecked !== void 0) {
|
|
3066
|
+
setChecked(Boolean(defaultChecked));
|
|
3067
|
+
}
|
|
3068
|
+
}, [defaultChecked]);
|
|
3069
|
+
return /* @__PURE__ */ React30.createElement(
|
|
3070
|
+
Button,
|
|
3071
|
+
{
|
|
3072
|
+
role: "switch",
|
|
3073
|
+
onClick: handleClick,
|
|
3074
|
+
value: String(checked),
|
|
3075
|
+
"aria-checked": checked,
|
|
3076
|
+
"data-checked": Boolean(checked),
|
|
3077
|
+
"data-disabled": Boolean(disabled),
|
|
3078
|
+
disabled,
|
|
3079
|
+
...restProps
|
|
3080
|
+
},
|
|
3081
|
+
children
|
|
3082
|
+
);
|
|
3083
|
+
};
|
|
3084
|
+
Toggle.displayName = "Toggle";
|
|
3085
|
+
|
|
3086
|
+
// src/toolbar/index.tsx
|
|
3087
|
+
import React32 from "react";
|
|
3088
|
+
|
|
3089
|
+
// src/toolbar/hooks/index.tsx
|
|
3090
|
+
import React31, { useState as useState8, createContext as createContext8, useContext as useContext8 } from "react";
|
|
3091
|
+
var defaultComponentAPI8 = {
|
|
3092
|
+
id: "",
|
|
3093
|
+
states: {},
|
|
3094
|
+
methods: {}
|
|
3095
|
+
};
|
|
3096
|
+
var ToolbarContext = createContext8(defaultComponentAPI8);
|
|
3097
|
+
var useToolbar = () => useContext8(ToolbarContext);
|
|
3098
|
+
var ToolbarProvider = ({ children }) => {
|
|
3099
|
+
const context = useToolbarProvider();
|
|
3100
|
+
return /* @__PURE__ */ React31.createElement(ToolbarContext.Provider, { value: context }, children);
|
|
3101
|
+
};
|
|
3102
|
+
function useToolbarProvider() {
|
|
3103
|
+
const [expanded, setExpanded] = useState8(false);
|
|
3104
|
+
const toolbarId = React31.useId();
|
|
3105
|
+
return {
|
|
3106
|
+
id: toolbarId,
|
|
3107
|
+
states: {
|
|
3108
|
+
expanded
|
|
3109
|
+
},
|
|
3110
|
+
methods: {
|
|
3111
|
+
toggleToolbar: (state) => setExpanded(state ?? !expanded)
|
|
3112
|
+
}
|
|
3113
|
+
};
|
|
3114
|
+
}
|
|
3115
|
+
|
|
3116
|
+
// src/toolbar/styles/index.ts
|
|
3117
|
+
import styled17, { css as css12 } from "styled-components";
|
|
3118
|
+
var ToolbarDefaultStyles = css12`
|
|
3119
|
+
margin: 0;
|
|
3120
|
+
display: grid;
|
|
3121
|
+
grid-template-rows: min-content;
|
|
3122
|
+
background-color: var(--body-color);
|
|
3123
|
+
border: var(--measurement-small-10) solid transparent;
|
|
3124
|
+
padding: var(--measurement-medium-30);
|
|
3125
|
+
min-width: var(--measurement-large-30);
|
|
3126
|
+
min-height: fit-content;
|
|
3127
|
+
|
|
3128
|
+
&[aria-expanded="true"] {
|
|
3129
|
+
width: 100%;
|
|
3130
|
+
|
|
3131
|
+
&[aria-orientation="horizontal"] {
|
|
3132
|
+
height: 100%;
|
|
3133
|
+
width: 100%;
|
|
3134
|
+
}
|
|
3135
|
+
|
|
3136
|
+
menu {
|
|
3137
|
+
display: flex;
|
|
3138
|
+
}
|
|
3139
|
+
}
|
|
3140
|
+
|
|
3141
|
+
&[aria-expanded="false"] {
|
|
3142
|
+
width: fit-content;
|
|
3143
|
+
justify-items: center;
|
|
3144
|
+
|
|
3145
|
+
&[aria-orientation="horizontal"] {
|
|
3146
|
+
justify-items: start;
|
|
3147
|
+
height: fit-content;
|
|
3148
|
+
width: 100%;
|
|
3149
|
+
}
|
|
3150
|
+
}
|
|
3151
|
+
`;
|
|
3152
|
+
var ToolbarSizeStyles = css12`
|
|
3153
|
+
&[data-size="small"] {
|
|
3154
|
+
&[aria-orientation="vertical"] {
|
|
3155
|
+
max-width: var(--measurement-large-70);
|
|
3156
|
+
}
|
|
3157
|
+
&[aria-orientation="horizontal"] {
|
|
3158
|
+
max-height: var(--measurement-large-70);
|
|
3159
|
+
}
|
|
3160
|
+
}
|
|
3161
|
+
|
|
3162
|
+
&[data-size="medium"] {
|
|
3163
|
+
&[aria-orientation="vertical"] {
|
|
3164
|
+
max-width: var(--measurement-large-80);
|
|
3165
|
+
}
|
|
3166
|
+
&[aria-orientation="horizontal"] {
|
|
3167
|
+
max-height: var(--measurement-large-80);
|
|
3168
|
+
}
|
|
3169
|
+
}
|
|
3170
|
+
|
|
3171
|
+
&[data-size="large"] {
|
|
3172
|
+
&[aria-orientation="vertical"] {
|
|
3173
|
+
max-width: var(--measurement-large-90);
|
|
3174
|
+
}
|
|
3175
|
+
&[aria-orientation="horizontal"] {
|
|
3176
|
+
max-height: var(--measurement-large-90);
|
|
3177
|
+
}
|
|
3178
|
+
}
|
|
3179
|
+
|
|
3180
|
+
&[data-height="display"] {
|
|
3181
|
+
&[aria-orientation="vertical"] {
|
|
3182
|
+
max-width: calc(var(--measurement-large-90) * 1.618);
|
|
3183
|
+
}
|
|
3184
|
+
&[aria-orientation="horizontal"] {
|
|
3185
|
+
max-height: calc(var(--measurement-large-90) * 1.618);
|
|
3186
|
+
}
|
|
3187
|
+
}
|
|
3188
|
+
|
|
3189
|
+
&[data-height="fullscreen"] {
|
|
3190
|
+
&[aria-orientation="vertical"] {
|
|
3191
|
+
max-width: 100dvw;
|
|
3192
|
+
}
|
|
3193
|
+
&[aria-orientation="horizontal"] {
|
|
3194
|
+
max-height: 100dvh;
|
|
3195
|
+
}
|
|
3196
|
+
}
|
|
3197
|
+
`;
|
|
3198
|
+
var ToolbarSideStyles = css12`
|
|
3199
|
+
&[data-side="top"] {
|
|
3200
|
+
border-bottom-color: var(--font-color-alpha-10);
|
|
3201
|
+
}
|
|
3202
|
+
&[data-side="right"] {
|
|
3203
|
+
border-left-color: var(--font-color-alpha-10);
|
|
3204
|
+
|
|
3205
|
+
&[aria-expanded="true"] {
|
|
3206
|
+
menu {
|
|
3207
|
+
justify-content: flex-end;
|
|
3208
|
+
}
|
|
3209
|
+
}
|
|
3210
|
+
&[aria-expanded="false"] {
|
|
3211
|
+
justify-items: end;
|
|
3212
|
+
}
|
|
3213
|
+
}
|
|
3214
|
+
&[data-side="bottom"] {
|
|
3215
|
+
border-top-color: var(--font-color-alpha-10);
|
|
3216
|
+
}
|
|
3217
|
+
&[data-side="left"] {
|
|
3218
|
+
border-right-color: var(--font-color-alpha-10);
|
|
3219
|
+
|
|
3220
|
+
&[aria-expanded="true"] {
|
|
3221
|
+
menu {
|
|
3222
|
+
justify-content: flex-start;
|
|
3223
|
+
}
|
|
3224
|
+
}
|
|
3225
|
+
&[aria-expanded="false"] {
|
|
3226
|
+
justify-items: start;
|
|
3227
|
+
}
|
|
3228
|
+
}
|
|
3229
|
+
`;
|
|
3230
|
+
var ToolbarWrapper = styled17.menu`
|
|
3231
|
+
&[data-raw="false"] {
|
|
3232
|
+
${ToolbarDefaultStyles}
|
|
3233
|
+
${ToolbarSizeStyles}
|
|
3234
|
+
|
|
3235
|
+
${ToolbarSideStyles}
|
|
3236
|
+
}
|
|
3237
|
+
`;
|
|
3238
|
+
var ToolbarTriggerWrapper = styled17.menu`
|
|
3239
|
+
&[data-raw="false"] {
|
|
3240
|
+
all: unset;
|
|
3241
|
+
align-self: flex-end;
|
|
3242
|
+
}
|
|
3243
|
+
`;
|
|
3244
|
+
|
|
3245
|
+
// src/toolbar/index.tsx
|
|
3246
|
+
var Toolbar = (props) => {
|
|
3247
|
+
const {
|
|
3248
|
+
shortcut,
|
|
3249
|
+
hotkey,
|
|
3250
|
+
bindkey = "ctrlKey" /* Ctrl */,
|
|
3251
|
+
raw,
|
|
3252
|
+
sizing = "medium" /* Medium */,
|
|
3253
|
+
side = "left" /* Left */,
|
|
3254
|
+
height = "fullscreen" /* Fullscreen */,
|
|
3255
|
+
defaultOpen,
|
|
3256
|
+
children,
|
|
3257
|
+
...restProps
|
|
3258
|
+
} = props;
|
|
3259
|
+
const { id, methods, states } = useToolbar();
|
|
3260
|
+
const { toggleToolbar } = methods;
|
|
3261
|
+
const shortcutControls = useKeyPress(String(hotkey), true, bindkey);
|
|
3262
|
+
const orientation = side && ["left", "right"].includes(side) ? "vertical" : "horizontal";
|
|
3263
|
+
React32.useEffect(() => {
|
|
3264
|
+
if (defaultOpen && toggleToolbar) return toggleToolbar(true);
|
|
3265
|
+
}, [defaultOpen]);
|
|
3266
|
+
React32.useEffect(() => {
|
|
3267
|
+
if (shortcut && shortcutControls && toggleToolbar) toggleToolbar();
|
|
3268
|
+
}, [shortcutControls]);
|
|
3269
|
+
return /* @__PURE__ */ React32.createElement(
|
|
3270
|
+
ToolbarWrapper,
|
|
3271
|
+
{
|
|
3272
|
+
id,
|
|
3273
|
+
role: "toolbar",
|
|
3274
|
+
"aria-label": props["aria-label"] ?? `${id}-toolbar`,
|
|
3275
|
+
"aria-controls": `${id}-trigger`,
|
|
3276
|
+
"aria-expanded": Boolean(states.expanded),
|
|
3277
|
+
"aria-orientation": orientation,
|
|
3278
|
+
"data-raw": Boolean(raw),
|
|
3279
|
+
"data-size": sizing,
|
|
3280
|
+
"data-height": height,
|
|
3281
|
+
"data-side": side,
|
|
3282
|
+
...restProps
|
|
3283
|
+
},
|
|
3284
|
+
children
|
|
3285
|
+
);
|
|
3286
|
+
};
|
|
3287
|
+
Toolbar.displayName = "Toolbar";
|
|
3288
|
+
var ToolbarRoot = ({ children }) => {
|
|
3289
|
+
return /* @__PURE__ */ React32.createElement(ToolbarProvider, null, children);
|
|
3290
|
+
};
|
|
3291
|
+
ToolbarRoot.displayName = "Toolbar.Root";
|
|
3292
|
+
var ToolbarTrigger = (props) => {
|
|
3293
|
+
const {
|
|
3294
|
+
raw,
|
|
3295
|
+
onClick,
|
|
3296
|
+
variant = "ghost" /* Ghost */,
|
|
3297
|
+
sizing = "small" /* Small */,
|
|
3298
|
+
children,
|
|
3299
|
+
...restProps
|
|
3300
|
+
} = props;
|
|
3301
|
+
const { id, methods, states } = useToolbar();
|
|
3302
|
+
const { toggleToolbar } = methods;
|
|
3303
|
+
const handleClick = (event) => {
|
|
3304
|
+
if (onClick) onClick(event);
|
|
3305
|
+
if (toggleToolbar) toggleToolbar(!states.expanded);
|
|
3306
|
+
};
|
|
3307
|
+
return /* @__PURE__ */ React32.createElement(ToolbarTriggerWrapper, { "data-raw": Boolean(raw) }, /* @__PURE__ */ React32.createElement(
|
|
3308
|
+
Button,
|
|
3309
|
+
{
|
|
3310
|
+
id: `${id}-trigger`,
|
|
3311
|
+
variant,
|
|
3312
|
+
sizing,
|
|
3313
|
+
raw: Boolean(raw),
|
|
3314
|
+
onClick: handleClick,
|
|
3315
|
+
...restProps
|
|
3316
|
+
},
|
|
3317
|
+
children
|
|
3318
|
+
));
|
|
3319
|
+
};
|
|
3320
|
+
ToolbarTrigger.displayName = "Toolbar.Trigger";
|
|
3321
|
+
var ToolbarSection = (props) => {
|
|
3322
|
+
const { showoncollapse, children, ...restProps } = props;
|
|
3323
|
+
const { states } = useToolbar();
|
|
3324
|
+
const { expanded } = states;
|
|
3325
|
+
if (showoncollapse) return /* @__PURE__ */ React32.createElement("section", { ...restProps }, children);
|
|
3326
|
+
return /* @__PURE__ */ React32.createElement("section", { ...restProps }, expanded && children);
|
|
3327
|
+
};
|
|
3328
|
+
ToolbarSection.displayName = "Toolbar.Section";
|
|
3329
|
+
var ToolbarItem = (props) => {
|
|
3330
|
+
const { showfirstchild, onClick, children, ...restProps } = props;
|
|
3331
|
+
const childArray = React32.Children.toArray(children);
|
|
3332
|
+
const { id, states, methods } = useToolbar();
|
|
3333
|
+
const { expanded } = states;
|
|
3334
|
+
const { toggleToolbar } = methods;
|
|
3335
|
+
const displayFirstChild = showfirstchild && childArray.length > 1 && !expanded;
|
|
3336
|
+
const handleClick = (event) => {
|
|
3337
|
+
if (onClick) onClick(event);
|
|
3338
|
+
if (toggleToolbar && !expanded) toggleToolbar(true);
|
|
3339
|
+
};
|
|
3340
|
+
return /* @__PURE__ */ React32.createElement(
|
|
3341
|
+
"div",
|
|
3342
|
+
{
|
|
3343
|
+
tabIndex: -1,
|
|
3344
|
+
"aria-hidden": true,
|
|
3345
|
+
"aria-describedby": id,
|
|
3346
|
+
"data-expanded": expanded,
|
|
3347
|
+
onClick: handleClick,
|
|
3348
|
+
...restProps
|
|
3349
|
+
},
|
|
3350
|
+
displayFirstChild && childArray[0],
|
|
3351
|
+
expanded && children
|
|
3352
|
+
);
|
|
3353
|
+
};
|
|
3354
|
+
ToolbarItem.displayName = "Toolbar.Item";
|
|
3355
|
+
Toolbar.Root = ToolbarRoot;
|
|
3356
|
+
Toolbar.Trigger = ToolbarTrigger;
|
|
3357
|
+
Toolbar.Item = ToolbarItem;
|
|
3358
|
+
Toolbar.Section = ToolbarSection;
|
|
3359
|
+
|
|
3360
|
+
// src/tooltip/index.tsx
|
|
3361
|
+
import React33 from "react";
|
|
3362
|
+
|
|
3363
|
+
// src/tooltip/styles/index.ts
|
|
3364
|
+
import styled18, { keyframes as keyframes2 } from "styled-components";
|
|
3365
|
+
var FadeIn2 = keyframes2`
|
|
3366
|
+
0% {
|
|
3367
|
+
opacity: 0;
|
|
3368
|
+
}
|
|
3369
|
+
100% {
|
|
3370
|
+
opacity: 1;
|
|
3371
|
+
}
|
|
3372
|
+
`;
|
|
3373
|
+
var ContentBox = styled18.div`
|
|
3374
|
+
display: inline-block;
|
|
3375
|
+
position: relative;
|
|
3376
|
+
`;
|
|
3377
|
+
var ContentWrapper2 = styled18.span`
|
|
3378
|
+
&[data-raw="false"] {
|
|
3379
|
+
width: fit-content;
|
|
3380
|
+
max-width: var(--measurement-large-60);
|
|
3381
|
+
|
|
3382
|
+
* {
|
|
3383
|
+
color: var(--body-color) !important;
|
|
3384
|
+
white-space: nowrap;
|
|
3385
|
+
text-overflow: ellipsis;
|
|
3386
|
+
overflow: hidden;
|
|
3387
|
+
}
|
|
3388
|
+
|
|
3389
|
+
background: var(--font-color);
|
|
3390
|
+
padding: var(--measurement-medium-10) var(--measurement-medium-30);
|
|
3391
|
+
border: var(--measurement-small-10) solid var(--font-color-alpha-10);
|
|
3392
|
+
border-radius: var(--measurement-medium-20);
|
|
3393
|
+
font-size: var(--fontsize-medium-10);
|
|
3394
|
+
z-index: var(--depth-default-100);
|
|
3395
|
+
animation-duration: 0.2s;
|
|
3396
|
+
animation-name: ${FadeIn2};
|
|
3397
|
+
animation-fill-mode: backwards;
|
|
3398
|
+
}
|
|
3399
|
+
`;
|
|
3400
|
+
|
|
3401
|
+
// src/tooltip/index.tsx
|
|
3402
|
+
var Tooltip = ({
|
|
3403
|
+
delay = 200,
|
|
3404
|
+
content,
|
|
3405
|
+
children,
|
|
3406
|
+
...restProps
|
|
3407
|
+
}) => {
|
|
3408
|
+
const [visible, setVisible] = React33.useState(false);
|
|
3409
|
+
const [triggerProps, setTriggerProps] = React33.useState(null);
|
|
3410
|
+
const [contentProps, setContentProps] = React33.useState(null);
|
|
3411
|
+
const mounted = React33.useRef(false);
|
|
3412
|
+
const containerRef = React33.useRef(null);
|
|
3413
|
+
const contentRef = React33.useRef(null);
|
|
3414
|
+
const timeoutRef = React33.useRef(null);
|
|
3415
|
+
const contentRect = () => contentRef?.current?.getBoundingClientRect();
|
|
3416
|
+
const bodyRect = React33.useCallback(() => {
|
|
3417
|
+
if (typeof document !== "undefined") {
|
|
3418
|
+
return document.body.getBoundingClientRect();
|
|
3419
|
+
}
|
|
3420
|
+
}, []);
|
|
3421
|
+
const positions = {
|
|
3422
|
+
btt: `calc((${triggerProps?.top}px - ${contentProps?.height}px) - (var(--measurement-medium-10)))`,
|
|
3423
|
+
ttb: `calc((${triggerProps?.top}px + ${triggerProps?.height}px) + var(--measurement-medium-10))`,
|
|
3424
|
+
ltr: `${triggerProps?.left}px`,
|
|
3425
|
+
rtl: `calc(${triggerProps?.left}px - (${contentProps?.width}px - ${triggerProps?.width}px))`
|
|
3426
|
+
};
|
|
3427
|
+
const dimensions = {
|
|
3428
|
+
body_width: bodyRect()?.width,
|
|
3429
|
+
body_height: bodyRect()?.height,
|
|
3430
|
+
content_width: contentProps?.width,
|
|
3431
|
+
content_height: contentProps?.height,
|
|
3432
|
+
content_left: contentProps?.left,
|
|
3433
|
+
content_bottom: contentProps?.bottom
|
|
3434
|
+
};
|
|
3435
|
+
const hasEnoughHorizontalSpace = Number(dimensions.body_width) - Number(dimensions.content_left) > Number(dimensions.content_width) * 1.1;
|
|
3436
|
+
const hasEnoughVerticalSpace = Number(dimensions.body_height) - Number(dimensions.content_bottom) > Number(dimensions.content_height) * 0.9;
|
|
3437
|
+
const showTooltip = React33.useCallback(() => {
|
|
3438
|
+
timeoutRef.current = setTimeout(() => setVisible(true), delay);
|
|
3439
|
+
}, [delay]);
|
|
3440
|
+
const hideTooltip = React33.useCallback(() => {
|
|
3441
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
3442
|
+
setVisible(false);
|
|
3443
|
+
}, []);
|
|
3444
|
+
const handleMouseEnter = React33.useCallback(() => {
|
|
3445
|
+
const rect = containerRef.current?.getBoundingClientRect();
|
|
3446
|
+
if (rect) {
|
|
3447
|
+
setTriggerProps({
|
|
3448
|
+
top: rect.top,
|
|
3449
|
+
right: rect.right,
|
|
3450
|
+
bottom: rect.bottom,
|
|
3451
|
+
left: rect.left,
|
|
3452
|
+
width: rect.width,
|
|
3453
|
+
height: rect.height
|
|
3454
|
+
});
|
|
3455
|
+
showTooltip();
|
|
3456
|
+
}
|
|
3457
|
+
}, [showTooltip]);
|
|
3458
|
+
const handleMouseLeave = React33.useCallback(
|
|
3459
|
+
() => hideTooltip(),
|
|
3460
|
+
[hideTooltip]
|
|
3461
|
+
);
|
|
3462
|
+
React33.useEffect(() => {
|
|
3463
|
+
mounted.current = true;
|
|
3464
|
+
setContentProps && setContentProps({
|
|
3465
|
+
top: Number(contentRect()?.top),
|
|
3466
|
+
right: Number(contentRect()?.right),
|
|
3467
|
+
bottom: Number(contentRect()?.bottom),
|
|
3468
|
+
left: Number(contentRect()?.left),
|
|
3469
|
+
width: Number(contentRect()?.width),
|
|
3470
|
+
height: Number(contentRect()?.height)
|
|
3471
|
+
});
|
|
3472
|
+
return () => {
|
|
3473
|
+
mounted.current = false;
|
|
3474
|
+
};
|
|
3475
|
+
}, [visible]);
|
|
3476
|
+
return /* @__PURE__ */ React33.createElement(
|
|
3477
|
+
ContentBox,
|
|
3478
|
+
{
|
|
3479
|
+
ref: containerRef,
|
|
3480
|
+
style: { display: "inline-block", position: "relative" },
|
|
3481
|
+
onMouseEnter: handleMouseEnter,
|
|
3482
|
+
onMouseLeave: handleMouseLeave,
|
|
3483
|
+
...restProps
|
|
3484
|
+
},
|
|
3485
|
+
children,
|
|
3486
|
+
visible && /* @__PURE__ */ React33.createElement(
|
|
3487
|
+
ContentWrapper2,
|
|
3488
|
+
{
|
|
3489
|
+
ref: contentRef,
|
|
3490
|
+
style: {
|
|
3491
|
+
top: hasEnoughVerticalSpace ? positions.ttb : positions.btt,
|
|
3492
|
+
left: hasEnoughHorizontalSpace ? positions.ltr : positions.rtl,
|
|
3493
|
+
position: "fixed"
|
|
3494
|
+
},
|
|
3495
|
+
role: "tooltip",
|
|
3496
|
+
"data-state": applyDataState(visible),
|
|
3497
|
+
"data-raw": Boolean(restProps.raw),
|
|
3498
|
+
"data-side": hasEnoughHorizontalSpace ? "left" /* Left */ : "right" /* Right */,
|
|
3499
|
+
"data-align": hasEnoughHorizontalSpace ? "left" /* Left */ : "right" /* Right */
|
|
3500
|
+
},
|
|
3501
|
+
/* @__PURE__ */ React33.createElement("div", null, content)
|
|
3502
|
+
)
|
|
3503
|
+
);
|
|
3504
|
+
};
|
|
3505
|
+
Tooltip.displayName = "Tooltip";
|
|
3506
|
+
export {
|
|
3507
|
+
Accordion,
|
|
3508
|
+
AccordionContent,
|
|
3509
|
+
AccordionRoot,
|
|
3510
|
+
AccordionTrigger,
|
|
3511
|
+
AvataStatusEnum,
|
|
3512
|
+
Avatar,
|
|
3513
|
+
Badge,
|
|
3514
|
+
Button,
|
|
3515
|
+
Checkbox,
|
|
3516
|
+
CheckboxIndicator,
|
|
3517
|
+
CheckboxRoot,
|
|
3518
|
+
Collapsible,
|
|
3519
|
+
CollapsibleContent,
|
|
3520
|
+
CollapsibleRoot,
|
|
3521
|
+
CollapsibleTrigger,
|
|
3522
|
+
Dialog,
|
|
3523
|
+
DialogControl,
|
|
3524
|
+
DialogMenu,
|
|
3525
|
+
DialogOverlay,
|
|
3526
|
+
DialogRoot,
|
|
3527
|
+
DialogTrigger,
|
|
3528
|
+
Divider,
|
|
3529
|
+
DropdownMenu,
|
|
3530
|
+
DropdownMenuContent,
|
|
3531
|
+
DropdownMenuItem,
|
|
3532
|
+
DropdownMenuRoot,
|
|
3533
|
+
DropdownMenuTrigger,
|
|
3534
|
+
Field,
|
|
3535
|
+
FieldLabel,
|
|
3536
|
+
FieldMeta,
|
|
3537
|
+
FieldRoot,
|
|
3538
|
+
FieldWrapper,
|
|
3539
|
+
MetaVariantEnum,
|
|
3540
|
+
OTPField,
|
|
3541
|
+
OTPFieldSlot,
|
|
3542
|
+
Overlay,
|
|
3543
|
+
Page,
|
|
3544
|
+
PageContent,
|
|
3545
|
+
PageMenu,
|
|
3546
|
+
PageNavigation,
|
|
3547
|
+
PagePanel,
|
|
3548
|
+
PageTools,
|
|
3549
|
+
PageWrapper,
|
|
3550
|
+
Portal,
|
|
3551
|
+
ScrollArea,
|
|
3552
|
+
Sheet,
|
|
3553
|
+
SheetRoot,
|
|
3554
|
+
SheetTrigger,
|
|
3555
|
+
Switch,
|
|
3556
|
+
SwitchRoot,
|
|
3557
|
+
SwitchThumb,
|
|
3558
|
+
Table,
|
|
3559
|
+
TableBody,
|
|
3560
|
+
TableCell,
|
|
3561
|
+
TableFooter,
|
|
3562
|
+
TableHead,
|
|
3563
|
+
TableHeadCell,
|
|
3564
|
+
TableRow,
|
|
3565
|
+
Tabs,
|
|
3566
|
+
TabsContent,
|
|
3567
|
+
TabsRoot,
|
|
3568
|
+
TabsTrigger,
|
|
3569
|
+
Toggle,
|
|
3570
|
+
Toolbar,
|
|
3571
|
+
ToolbarItem,
|
|
3572
|
+
ToolbarRoot,
|
|
3573
|
+
ToolbarSection,
|
|
3574
|
+
ToolbarTrigger,
|
|
3575
|
+
Tooltip,
|
|
3576
|
+
useAccordion,
|
|
3577
|
+
useCheckbox,
|
|
3578
|
+
useCollapsible,
|
|
3579
|
+
useDialog,
|
|
3580
|
+
useDropdownMenu,
|
|
3581
|
+
useField,
|
|
3582
|
+
useSheet,
|
|
3583
|
+
useSwitch,
|
|
3584
|
+
useTabs,
|
|
3585
|
+
useToolbar
|
|
3586
|
+
};
|