@team-frieeren/components 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Accordian/Accordion.d.ts +6 -0
- package/dist/components/Accordian/Accordion.stories.d.ts +34 -0
- package/dist/components/Accordian/Accordion.type.d.ts +7 -0
- package/dist/components/BottomSheet/BottomSheet.d.ts +2 -0
- package/dist/components/BottomSheet/BottomSheet.stories.d.ts +10 -0
- package/dist/components/BottomSheet/BottomSheet.type.d.ts +26 -0
- package/dist/components/BottomSheet/index.d.ts +2 -0
- package/dist/components/Button/Button.d.ts +16 -0
- package/dist/components/Button/Button.stories.d.ts +44 -0
- package/dist/components/Button/Button.type.d.ts +17 -0
- package/dist/components/Button/index.d.ts +2 -0
- package/dist/components/Checkbox/Checkbox.d.ts +6 -0
- package/dist/components/Checkbox/Checkbox.stories.d.ts +15 -0
- package/dist/components/Checkbox/index.d.ts +2 -0
- package/dist/components/Dialog/Dialog.d.ts +2 -0
- package/dist/components/Dialog/Dialog.stories.d.ts +10 -0
- package/dist/components/Dialog/Dialog.type.d.ts +22 -0
- package/dist/components/Funnel/Funnel.d.ts +3 -0
- package/dist/components/Funnel/Funnel.stories.d.ts +31 -0
- package/dist/components/Funnel/Funnel.type.d.ts +13 -0
- package/dist/components/Funnel/index.d.ts +1 -0
- package/dist/components/Funnel/useFunnel.d.ts +9 -0
- package/dist/components/Funnel/useQueryParam.d.ts +6 -0
- package/dist/components/Input/Input.d.ts +3 -0
- package/dist/components/Input/Input.stories.d.ts +6 -0
- package/dist/components/Input/index.d.ts +2 -0
- package/dist/components/Input/input.type.d.ts +10 -0
- package/dist/components/Popover/Popover.d.ts +5 -0
- package/dist/components/Popover/Popover.stories.d.ts +36 -0
- package/dist/components/Popover/Popover.type.d.ts +7 -0
- package/dist/components/Popup/Popup.d.ts +4 -0
- package/dist/components/Popup/Popup.stories.d.ts +21 -0
- package/dist/components/Popup/Popup.type.d.ts +21 -0
- package/dist/components/Popup/index.d.ts +2 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +8 -0
- package/dist/components/RadioGroup/RadioGroup.stories.d.ts +16 -0
- package/dist/components/RadioGroup/index.d.ts +2 -0
- package/dist/components/Select/Select.d.ts +15 -0
- package/dist/components/Select/Select.stories.d.ts +13 -0
- package/dist/components/Select/Select.type.d.ts +4 -0
- package/dist/components/Select/index.d.ts +2 -0
- package/dist/components/Tabs/Tabs.d.ts +3 -0
- package/dist/components/Tabs/Tabs.stories.d.ts +38 -0
- package/dist/components/Tabs/Tabs.type.d.ts +15 -0
- package/dist/components/Tabs/TabsBase.d.ts +7 -0
- package/dist/components/Tabs/index.d.ts +1 -0
- package/dist/components/Tabs/useTabsIndicator.d.ts +10 -0
- package/dist/components/Text/Text.d.ts +2 -0
- package/dist/components/Text/Text.stories.d.ts +41 -0
- package/dist/components/Text/Text.type.d.ts +22 -0
- package/dist/components/Text/index.d.ts +2 -0
- package/dist/components/Toast/Toast.d.ts +5 -0
- package/dist/components/Toast/Toast.stories.d.ts +6 -0
- package/dist/components/Toast/Toast.type.d.ts +31 -0
- package/dist/components/Toast/ToastProvider.d.ts +3 -0
- package/dist/components/Toast/index.d.ts +2 -0
- package/dist/components/Toast/useToast.d.ts +2 -0
- package/dist/components/Toast/useToastStack.d.ts +12 -0
- package/dist/components/Toggle/Toggle.d.ts +3 -0
- package/dist/components/Toggle/Toggle.stories.d.ts +22 -0
- package/dist/components/Toggle/Toggle.type.d.ts +6 -0
- package/dist/components/Toggle/index.d.ts +1 -0
- package/dist/components/layout/Box/Box.d.ts +2 -0
- package/dist/components/layout/Box/Box.stories.d.ts +13 -0
- package/dist/components/layout/Box/Box.type.d.ts +10 -0
- package/dist/components/layout/Box/index.d.ts +2 -0
- package/dist/components/layout/Container/Container.d.ts +2 -0
- package/dist/components/layout/Container/Container.stories.d.ts +13 -0
- package/dist/components/layout/Container/Container.type.d.ts +4 -0
- package/dist/components/layout/Container/index.d.ts +2 -0
- package/dist/components/layout/Flex/Flex.d.ts +2 -0
- package/dist/components/layout/Flex/Flex.stories.d.ts +13 -0
- package/dist/components/layout/Flex/Flex.type.d.ts +10 -0
- package/dist/components/layout/Flex/index.d.ts +2 -0
- package/dist/components/layout/Grid/Grid.d.ts +2 -0
- package/dist/components/layout/Grid/Grid.stories.d.ts +13 -0
- package/dist/components/layout/Grid/Grid.type.d.ts +10 -0
- package/dist/components/layout/Grid/index.d.ts +2 -0
- package/dist/hooks/useIsMounted.d.ts +1 -0
- package/dist/hooks/useOverlay/OverlayController.d.ts +10 -0
- package/dist/hooks/useOverlay/OverlayProvider.d.ts +6 -0
- package/dist/hooks/useOverlay/index.d.ts +2 -0
- package/dist/hooks/useOverlay/types.d.ts +5 -0
- package/dist/hooks/useOverlay/useOverlay.d.ts +10 -0
- package/dist/hooks/useRouter.d.ts +3 -0
- package/dist/index.css +1896 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +1378 -0
- package/dist/router/router.type.d.ts +26 -0
- package/dist/router/windowRouter.d.ts +12 -0
- package/dist/shared/components/SwitchCase.d.ts +7 -0
- package/dist/shared/icon/index.d.ts +1 -0
- package/dist/shared/icon/isIcon.d.ts +3 -0
- package/dist/shared/storage/LocalStorage.d.ts +14 -0
- package/dist/shared/storage/MemoryStorage.d.ts +11 -0
- package/dist/shared/storage/SessionStorage.d.ts +14 -0
- package/dist/shared/storage/index.d.ts +2 -0
- package/dist/shared/storage/storage.type.d.ts +9 -0
- package/dist/utils/generateRandomKey.d.ts +1 -0
- package/dist/utils/getSpacingStyle.d.ts +6 -0
- package/package.json +91 -0
package/dist/index.js
ADDED
@@ -0,0 +1,1378 @@
|
|
1
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
2
|
+
import * as React from 'react';
|
3
|
+
import { Children, isValidElement, useEffect, createContext, useContext, useMemo, useCallback, forwardRef, useState, useRef, Fragment as Fragment$1 } from 'react';
|
4
|
+
import cx from 'classnames';
|
5
|
+
import * as RadioGroupBase from '@radix-ui/react-radio-group';
|
6
|
+
import * as CheckboxBase from '@radix-ui/react-checkbox';
|
7
|
+
import { Switch, Dialog } from 'radix-ui';
|
8
|
+
import * as SelectBase from '@radix-ui/react-select';
|
9
|
+
import { Drawer } from 'vaul';
|
10
|
+
import * as TabsBase from '@radix-ui/react-tabs';
|
11
|
+
import { createPortal } from 'react-dom';
|
12
|
+
|
13
|
+
var _assign = function __assign() {
|
14
|
+
_assign = Object.assign || function __assign(t) {
|
15
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
16
|
+
s = arguments[i];
|
17
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
18
|
+
}
|
19
|
+
return t;
|
20
|
+
};
|
21
|
+
return _assign.apply(this, arguments);
|
22
|
+
};
|
23
|
+
function __rest(s, e) {
|
24
|
+
var t = {};
|
25
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
26
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
27
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
28
|
+
}
|
29
|
+
return t;
|
30
|
+
}
|
31
|
+
function __spreadArray(to, from, pack) {
|
32
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
33
|
+
if (ar || !(i in from)) {
|
34
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
35
|
+
ar[i] = from[i];
|
36
|
+
}
|
37
|
+
}
|
38
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
39
|
+
}
|
40
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
41
|
+
var e = new Error(message);
|
42
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
43
|
+
};
|
44
|
+
|
45
|
+
var Funnel = function Funnel(_a) {
|
46
|
+
var steps = _a.steps,
|
47
|
+
step = _a.step,
|
48
|
+
children = _a.children;
|
49
|
+
var validChildren = Children.toArray(children).filter(isValidElement).filter(function (i) {
|
50
|
+
var _a;
|
51
|
+
return steps.includes((_a = i.props.name) !== null && _a !== void 0 ? _a : "");
|
52
|
+
});
|
53
|
+
var targetStep = validChildren.find(function (child) {
|
54
|
+
return child.props.name === step;
|
55
|
+
});
|
56
|
+
if (!targetStep) {
|
57
|
+
throw new Error("".concat(step, " Step Component\uB97C \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4."));
|
58
|
+
}
|
59
|
+
return jsx(Fragment, {
|
60
|
+
children: targetStep
|
61
|
+
});
|
62
|
+
};
|
63
|
+
var Step = function Step(_a) {
|
64
|
+
var onMounted = _a.onMounted,
|
65
|
+
onUnMounted = _a.onUnMounted,
|
66
|
+
children = _a.children;
|
67
|
+
useEffect(function () {
|
68
|
+
onMounted === null || onMounted === void 0 ? void 0 : onMounted();
|
69
|
+
return function () {
|
70
|
+
onUnMounted === null || onUnMounted === void 0 ? void 0 : onUnMounted();
|
71
|
+
};
|
72
|
+
}, [onMounted, onUnMounted]);
|
73
|
+
return jsx(Fragment, {
|
74
|
+
children: children
|
75
|
+
});
|
76
|
+
};
|
77
|
+
|
78
|
+
var RouterContext = /*#__PURE__*/createContext(null);
|
79
|
+
var RouterProvider = RouterContext.Provider;
|
80
|
+
function useRouter() {
|
81
|
+
var router = useContext(RouterContext);
|
82
|
+
if (!router) {
|
83
|
+
throw new Error("RouterProvider를 설정해주세요");
|
84
|
+
}
|
85
|
+
return router;
|
86
|
+
}
|
87
|
+
|
88
|
+
function useQueryParam(name, options) {
|
89
|
+
var router = useRouter();
|
90
|
+
var value = router.getQuery(name);
|
91
|
+
return value;
|
92
|
+
}
|
93
|
+
|
94
|
+
var DEFAULT_STEP_QUERY_KEY = "funnel-step";
|
95
|
+
var useFunnel = function useFunnel(steps, options) {
|
96
|
+
var _a;
|
97
|
+
var router = useRouter();
|
98
|
+
var stepQueryKey = (_a = options === null || options === void 0 ? void 0 : options.stepQueryKey) !== null && _a !== void 0 ? _a : DEFAULT_STEP_QUERY_KEY;
|
99
|
+
if (steps.length === 0) {
|
100
|
+
throw new Error("steps가 비어있습니다.");
|
101
|
+
}
|
102
|
+
var FunnelComponent = useMemo(function () {
|
103
|
+
return Object.assign(function RouteFunnel(props) {
|
104
|
+
var _a;
|
105
|
+
var step = (_a = useQueryParam(stepQueryKey)) !== null && _a !== void 0 ? _a : options === null || options === void 0 ? void 0 : options.initialStep;
|
106
|
+
if (!step) {
|
107
|
+
throw new Error("\uD45C\uC2DC\uD560 \uC2A4\uD15D\uC744 ".concat(stepQueryKey, " \uCFFC\uB9AC \uD30C\uB77C\uBBF8\uD130\uC5D0 \uC9C0\uC815\uD574\uC8FC\uC138\uC694. \uCFFC\uB9AC \uD30C\uB77C\uBBF8\uD130\uAC00 \uC5C6\uC744 \uB54C \uCD08\uAE30 Step\uC744 \uB80C\uB354\uD558\uB824\uBA74 useFunnel\uC758 \uB450 \uBC88\uC9F8 \uD30C\uB77C\uBBF8\uD130 options\uC5D0 initialStep\uC744 \uC9C0\uC815\uD574\uC8FC\uC138\uC694."));
|
108
|
+
}
|
109
|
+
return jsx(Funnel, _assign({
|
110
|
+
steps: steps,
|
111
|
+
step: step
|
112
|
+
}, props));
|
113
|
+
}, {
|
114
|
+
Step: Step
|
115
|
+
});
|
116
|
+
}, []);
|
117
|
+
var setStep = useCallback(function (step) {
|
118
|
+
var _a;
|
119
|
+
router.setQuery((_a = {}, _a[stepQueryKey] = step, _a));
|
120
|
+
}, [stepQueryKey, router]);
|
121
|
+
return [FunnelComponent, setStep];
|
122
|
+
};
|
123
|
+
|
124
|
+
var SpacingMap = {
|
125
|
+
m: ["margin"],
|
126
|
+
mx: ["marginLeft", "marginRight"],
|
127
|
+
my: ["marginTop", "marginBottom"],
|
128
|
+
mt: ["marginTop"],
|
129
|
+
mb: ["marginBottom"],
|
130
|
+
ml: ["marginLeft"],
|
131
|
+
mr: ["marginRight"],
|
132
|
+
p: ["padding"],
|
133
|
+
px: ["paddingLeft", "paddingRight"],
|
134
|
+
py: ["paddingTop", "paddingBottom"],
|
135
|
+
pt: ["paddingTop"],
|
136
|
+
pb: ["paddingBottom"],
|
137
|
+
pl: ["paddingLeft"],
|
138
|
+
pr: ["paddingRight"]
|
139
|
+
};
|
140
|
+
var getSpacingStyle = function getSpacingStyle(props) {
|
141
|
+
var style = {};
|
142
|
+
Object.entries(props).forEach(function (_a) {
|
143
|
+
var key = _a[0],
|
144
|
+
value = _a[1];
|
145
|
+
if (value === undefined) return;
|
146
|
+
var properties = SpacingMap[key];
|
147
|
+
properties.forEach(function (property) {
|
148
|
+
style[property] = value;
|
149
|
+
});
|
150
|
+
});
|
151
|
+
return style;
|
152
|
+
};
|
153
|
+
|
154
|
+
function Box(_a) {
|
155
|
+
var _b = _a.as,
|
156
|
+
Component = _b === void 0 ? "div" : _b,
|
157
|
+
className = _a.className,
|
158
|
+
style = _a.style,
|
159
|
+
width = _a.width,
|
160
|
+
height = _a.height,
|
161
|
+
_c = _a.display,
|
162
|
+
display = _c === void 0 ? "inline-block" : _c,
|
163
|
+
children = _a.children,
|
164
|
+
rest = __rest(_a, ["as", "className", "style", "width", "height", "display", "children"]);
|
165
|
+
var m = rest.m,
|
166
|
+
mt = rest.mt,
|
167
|
+
mb = rest.mb,
|
168
|
+
ml = rest.ml,
|
169
|
+
mr = rest.mr,
|
170
|
+
mx = rest.mx,
|
171
|
+
my = rest.my,
|
172
|
+
p = rest.p,
|
173
|
+
pt = rest.pt,
|
174
|
+
pb = rest.pb,
|
175
|
+
pl = rest.pl,
|
176
|
+
pr = rest.pr,
|
177
|
+
px = rest.px,
|
178
|
+
py = rest.py,
|
179
|
+
props = __rest(rest, ["m", "mt", "mb", "ml", "mr", "mx", "my", "p", "pt", "pb", "pl", "pr", "px", "py"]);
|
180
|
+
var spacingStyle = getSpacingStyle({
|
181
|
+
m: m,
|
182
|
+
mt: mt,
|
183
|
+
mb: mb,
|
184
|
+
ml: ml,
|
185
|
+
mr: mr,
|
186
|
+
mx: mx,
|
187
|
+
my: my,
|
188
|
+
p: p,
|
189
|
+
pt: pt,
|
190
|
+
pb: pb,
|
191
|
+
pl: pl,
|
192
|
+
pr: pr,
|
193
|
+
px: px,
|
194
|
+
py: py
|
195
|
+
});
|
196
|
+
return jsx(Component, _assign({
|
197
|
+
"data-frieeren-component": "Box",
|
198
|
+
className: cx("box", className),
|
199
|
+
style: _assign(_assign({
|
200
|
+
width: width,
|
201
|
+
height: height,
|
202
|
+
display: display
|
203
|
+
}, spacingStyle), style)
|
204
|
+
}, props, {
|
205
|
+
children: children
|
206
|
+
}));
|
207
|
+
}
|
208
|
+
|
209
|
+
function Container(_a) {
|
210
|
+
var _b = _a.as,
|
211
|
+
Component = _b === void 0 ? "div" : _b,
|
212
|
+
_c = _a.maxWidth,
|
213
|
+
maxWidth = _c === void 0 ? "100%" : _c,
|
214
|
+
className = _a.className,
|
215
|
+
style = _a.style,
|
216
|
+
rest = __rest(_a, ["as", "maxWidth", "className", "style"]);
|
217
|
+
return jsx(Box, _assign({
|
218
|
+
"data-frieeren-component": "Container",
|
219
|
+
as: Component,
|
220
|
+
className: cx("container", className),
|
221
|
+
style: _assign({
|
222
|
+
maxWidth: maxWidth,
|
223
|
+
marginLeft: "auto",
|
224
|
+
marginRight: "auto"
|
225
|
+
}, style)
|
226
|
+
}, rest));
|
227
|
+
}
|
228
|
+
|
229
|
+
function Flex(_a) {
|
230
|
+
var _b = _a.as,
|
231
|
+
Component = _b === void 0 ? "div" : _b,
|
232
|
+
align = _a.align,
|
233
|
+
justify = _a.justify,
|
234
|
+
flex = _a.flex,
|
235
|
+
direction = _a.direction,
|
236
|
+
wrap = _a.wrap,
|
237
|
+
gap = _a.gap,
|
238
|
+
className = _a.className,
|
239
|
+
style = _a.style,
|
240
|
+
rest = __rest(_a, ["as", "align", "justify", "flex", "direction", "wrap", "gap", "className", "style"]);
|
241
|
+
return jsx(Box, _assign({
|
242
|
+
"data-frieeren-component": "Flex",
|
243
|
+
as: Component,
|
244
|
+
className: cx("flex", className),
|
245
|
+
style: _assign({
|
246
|
+
display: "flex",
|
247
|
+
alignItems: align,
|
248
|
+
justifyContent: justify,
|
249
|
+
flex: flex,
|
250
|
+
flexDirection: direction,
|
251
|
+
flexWrap: wrap,
|
252
|
+
gap: gap
|
253
|
+
}, style)
|
254
|
+
}, rest));
|
255
|
+
}
|
256
|
+
|
257
|
+
function Grid(_a) {
|
258
|
+
var _b = _a.as,
|
259
|
+
Component = _b === void 0 ? "div" : _b,
|
260
|
+
columns = _a.columns,
|
261
|
+
gap = _a.gap,
|
262
|
+
rowGap = _a.rowGap,
|
263
|
+
columnGap = _a.columnGap,
|
264
|
+
autoFlow = _a.autoFlow,
|
265
|
+
areas = _a.areas,
|
266
|
+
className = _a.className,
|
267
|
+
style = _a.style,
|
268
|
+
rest = __rest(_a, ["as", "columns", "gap", "rowGap", "columnGap", "autoFlow", "areas", "className", "style"]);
|
269
|
+
return jsx(Box, _assign({
|
270
|
+
"data-frieeren-component": "Grid",
|
271
|
+
as: Component,
|
272
|
+
className: cx("grid", className),
|
273
|
+
style: _assign({
|
274
|
+
display: "grid",
|
275
|
+
gridTemplateColumns: typeof columns === "number" ? "repeat(".concat(columns, ", 1fr)") : columns,
|
276
|
+
gap: gap,
|
277
|
+
rowGap: rowGap,
|
278
|
+
columnGap: columnGap,
|
279
|
+
gridAutoFlow: autoFlow,
|
280
|
+
gridTemplateAreas: areas
|
281
|
+
}, style)
|
282
|
+
}, rest));
|
283
|
+
}
|
284
|
+
|
285
|
+
var Button = /*#__PURE__*/forwardRef(function (_a, ref) {
|
286
|
+
var _b;
|
287
|
+
var _c = _a.type,
|
288
|
+
type = _c === void 0 ? "base" : _c,
|
289
|
+
_d = _a.display,
|
290
|
+
display = _d === void 0 ? "inline" : _d,
|
291
|
+
_e = _a.disabled,
|
292
|
+
disabled = _e === void 0 ? false : _e,
|
293
|
+
_f = _a.loading,
|
294
|
+
loading = _f === void 0 ? false : _f,
|
295
|
+
_g = _a.size,
|
296
|
+
size = _g === void 0 ? "md" : _g,
|
297
|
+
className = _a.className,
|
298
|
+
children = _a.children,
|
299
|
+
color = _a.color,
|
300
|
+
backgroundColor = _a.backgroundColor,
|
301
|
+
borderColor = _a.borderColor,
|
302
|
+
rest = __rest(_a, ["type", "display", "disabled", "loading", "size", "className", "children", "color", "backgroundColor", "borderColor"]);
|
303
|
+
return jsxs("button", _assign({
|
304
|
+
ref: ref,
|
305
|
+
"data-frieeren-component": "Button",
|
306
|
+
className: cx("button", (_b = {}, _b["button--size-".concat(size)] = size, _b["button--type-".concat(type)] = type, _b["button--display-".concat(display)] = display, _b), {
|
307
|
+
disabled: disabled
|
308
|
+
}, className),
|
309
|
+
disabled: disabled || loading,
|
310
|
+
style: {
|
311
|
+
color: color,
|
312
|
+
backgroundColor: backgroundColor,
|
313
|
+
borderColor: borderColor
|
314
|
+
}
|
315
|
+
}, rest, {
|
316
|
+
children: [jsx("span", {
|
317
|
+
className: cx("button--content", {
|
318
|
+
"button--content--hidden": loading
|
319
|
+
}),
|
320
|
+
children: children
|
321
|
+
}), loading && jsxs("span", {
|
322
|
+
className: "button--loading",
|
323
|
+
children: [jsx("div", {
|
324
|
+
className: "button--loading-dot"
|
325
|
+
}), jsx("div", {
|
326
|
+
className: "button--loading-dot"
|
327
|
+
}), jsx("div", {
|
328
|
+
className: "button--loading-dot"
|
329
|
+
})]
|
330
|
+
})]
|
331
|
+
}));
|
332
|
+
});
|
333
|
+
Button.displayName = "Button";
|
334
|
+
|
335
|
+
var Typography;
|
336
|
+
(function (Typography) {
|
337
|
+
Typography["Heading"] = "heading";
|
338
|
+
Typography["Body"] = "body";
|
339
|
+
Typography["Text"] = "text";
|
340
|
+
})(Typography || (Typography = {}));
|
341
|
+
var FontWeight;
|
342
|
+
(function (FontWeight) {
|
343
|
+
FontWeight["Regular"] = "regular";
|
344
|
+
FontWeight["Medium"] = "medium";
|
345
|
+
FontWeight["Bold"] = "bold";
|
346
|
+
})(FontWeight || (FontWeight = {}));
|
347
|
+
|
348
|
+
function Text(_a) {
|
349
|
+
var _b;
|
350
|
+
var _c = _a.as,
|
351
|
+
Component = _c === void 0 ? "span" : _c,
|
352
|
+
className = _a.className,
|
353
|
+
children = _a.children,
|
354
|
+
ellipsisLines = _a.ellipsisLines,
|
355
|
+
_d = _a.typography,
|
356
|
+
typography = _d === void 0 ? Typography.Body : _d,
|
357
|
+
_e = _a.fontWeight,
|
358
|
+
fontWeight = _e === void 0 ? FontWeight.Regular : _e,
|
359
|
+
color = _a.color,
|
360
|
+
_f = _a.display,
|
361
|
+
display = _f === void 0 ? "inline-block" : _f,
|
362
|
+
textAlign = _a.textAlign,
|
363
|
+
style = _a.style,
|
364
|
+
rest = __rest(_a, ["as", "className", "children", "ellipsisLines", "typography", "fontWeight", "color", "display", "textAlign", "style"]);
|
365
|
+
var isSingleLine = ellipsisLines !== undefined && ellipsisLines === 1;
|
366
|
+
var isMultiLine = ellipsisLines !== undefined && ellipsisLines > 1;
|
367
|
+
return jsx(Component, _assign({
|
368
|
+
"data-frieeren-component": "Text",
|
369
|
+
className: cx("text", (_b = {
|
370
|
+
"text--single-line": isSingleLine,
|
371
|
+
"text--multi-line": isMultiLine
|
372
|
+
}, _b["text--font-weight-".concat(fontWeight)] = fontWeight, _b["text--display-".concat(display)] = display && !isSingleLine && !isMultiLine, _b["text--typography-".concat(typography)] = typography, _b), className),
|
373
|
+
style: _assign({
|
374
|
+
color: color,
|
375
|
+
textAlign: textAlign,
|
376
|
+
WebkitLineClamp: ellipsisLines
|
377
|
+
}, style)
|
378
|
+
}, rest, {
|
379
|
+
children: children
|
380
|
+
}));
|
381
|
+
}
|
382
|
+
|
383
|
+
function Root$3(_a) {
|
384
|
+
var className = _a.className,
|
385
|
+
props = __rest(_a, ["className"]);
|
386
|
+
return jsx(RadioGroupBase.Root, _assign({
|
387
|
+
className: cx("radio-group", className),
|
388
|
+
"data-frieeren-component": "RadioGroup"
|
389
|
+
}, props));
|
390
|
+
}
|
391
|
+
var Item$1 = function Item(_a) {
|
392
|
+
_a.children;
|
393
|
+
var value = _a.value,
|
394
|
+
props = __rest(_a, ["children", "value"]);
|
395
|
+
return jsx(RadioGroupBase.Item, _assign({
|
396
|
+
value: value,
|
397
|
+
"data-frieeren-component": "RadioGroupItem"
|
398
|
+
}, props));
|
399
|
+
};
|
400
|
+
var Indicator$1 = function Indicator(_a) {
|
401
|
+
var props = __rest(_a, []);
|
402
|
+
return jsx(RadioGroupBase.Indicator, _assign({
|
403
|
+
"data-frieeren-component": "RadioGroupIndicator"
|
404
|
+
}, props));
|
405
|
+
};
|
406
|
+
var RadioGroup = {
|
407
|
+
Root: Root$3,
|
408
|
+
Item: Item$1,
|
409
|
+
Indicator: Indicator$1
|
410
|
+
};
|
411
|
+
|
412
|
+
var Root$2 = function Root(_a) {
|
413
|
+
var className = _a.className,
|
414
|
+
props = __rest(_a, ["className"]);
|
415
|
+
return jsx(CheckboxBase.Root, _assign({
|
416
|
+
className: cx("checkbox", className),
|
417
|
+
"data-frieeren-component": "Checkbox"
|
418
|
+
}, props));
|
419
|
+
};
|
420
|
+
var Indicator = function Indicator(_a) {
|
421
|
+
var props = __rest(_a, []);
|
422
|
+
jsx(CheckboxBase.Indicator, _assign({
|
423
|
+
"data-frieeren-component": "CheckboxIndicator"
|
424
|
+
}, props));
|
425
|
+
};
|
426
|
+
var Checkbox = {
|
427
|
+
Root: Root$2,
|
428
|
+
Indicator: Indicator
|
429
|
+
};
|
430
|
+
|
431
|
+
var Toggle = /*#__PURE__*/forwardRef(function (_a, ref) {
|
432
|
+
var className = _a.className,
|
433
|
+
_b = _a.states,
|
434
|
+
states = _b === void 0 ? "active" : _b,
|
435
|
+
onChange = _a.onChange;
|
436
|
+
return jsx(Switch.Root, {
|
437
|
+
ref: ref,
|
438
|
+
onCheckedChange: onChange,
|
439
|
+
checked: states === "active",
|
440
|
+
className: cx("toggle", className),
|
441
|
+
"data-frieeren-component": "Toggle",
|
442
|
+
children: jsx(Switch.Thumb, {
|
443
|
+
className: "toggle-thumb"
|
444
|
+
})
|
445
|
+
});
|
446
|
+
});
|
447
|
+
Toggle.displayName = "Toggle";
|
448
|
+
|
449
|
+
var Root$1 = function Root(_a) {
|
450
|
+
var className = _a.className,
|
451
|
+
props = __rest(_a, ["className"]);
|
452
|
+
return jsx("div", {
|
453
|
+
className: cx("select", className),
|
454
|
+
children: jsx(SelectBase.Root, _assign({
|
455
|
+
"data-frieeren-component": "Select"
|
456
|
+
}, props))
|
457
|
+
});
|
458
|
+
};
|
459
|
+
var Trigger$1 = function Trigger(_a) {
|
460
|
+
var props = __rest(_a, []);
|
461
|
+
return jsx(SelectBase.Trigger, _assign({
|
462
|
+
"data-frieeren-component": "SelectTrigger"
|
463
|
+
}, props));
|
464
|
+
};
|
465
|
+
var Portal = function Portal(_a) {
|
466
|
+
var props = __rest(_a, []);
|
467
|
+
return jsx(SelectBase.Portal, _assign({
|
468
|
+
"data-frieeren-component": "SelectPortal"
|
469
|
+
}, props));
|
470
|
+
};
|
471
|
+
var Content$1 = function Content(_a) {
|
472
|
+
var props = __rest(_a, []);
|
473
|
+
return jsx(SelectBase.Content, _assign({
|
474
|
+
"data-frieeren-component": "SelectContent"
|
475
|
+
}, props));
|
476
|
+
};
|
477
|
+
var Viewport = function Viewport(_a) {
|
478
|
+
var props = __rest(_a, []);
|
479
|
+
return jsx(SelectBase.Viewport, _assign({
|
480
|
+
"data-frieeren-component": "SelectViewport"
|
481
|
+
}, props));
|
482
|
+
};
|
483
|
+
var Group = function Group(_a) {
|
484
|
+
var props = __rest(_a, []);
|
485
|
+
return jsx(SelectBase.Group, _assign({
|
486
|
+
"data-frieeren-component": "SelectGroup"
|
487
|
+
}, props));
|
488
|
+
};
|
489
|
+
var Item = function Item(_a) {
|
490
|
+
var props = __rest(_a, []);
|
491
|
+
return jsx(SelectBase.Item, _assign({
|
492
|
+
"data-frieeren-component": "SelectItem"
|
493
|
+
}, props));
|
494
|
+
};
|
495
|
+
var Label = function Label(_a) {
|
496
|
+
var props = __rest(_a, []);
|
497
|
+
return jsx(SelectBase.Label, _assign({
|
498
|
+
"data-frieeren-component": "SelectLabel"
|
499
|
+
}, props));
|
500
|
+
};
|
501
|
+
var ItemText = function ItemText(_a) {
|
502
|
+
var props = __rest(_a, []);
|
503
|
+
return jsx(SelectBase.ItemText, _assign({
|
504
|
+
"data-frieeren-component": "SelectItemText"
|
505
|
+
}, props));
|
506
|
+
};
|
507
|
+
var Value = function Value(_a) {
|
508
|
+
var props = __rest(_a, []);
|
509
|
+
return jsx(SelectBase.Value, _assign({
|
510
|
+
"data-frieeren-component": "SelectValue"
|
511
|
+
}, props));
|
512
|
+
};
|
513
|
+
var Select = {
|
514
|
+
Root: Root$1,
|
515
|
+
Trigger: Trigger$1,
|
516
|
+
Portal: Portal,
|
517
|
+
Content: Content$1,
|
518
|
+
Viewport: Viewport,
|
519
|
+
Group: Group,
|
520
|
+
Item: Item,
|
521
|
+
Label: Label,
|
522
|
+
ItemText: ItemText,
|
523
|
+
Value: Value
|
524
|
+
};
|
525
|
+
|
526
|
+
var Popup = function Popup(props) {
|
527
|
+
var _a;
|
528
|
+
var className = props.className,
|
529
|
+
children = props.children,
|
530
|
+
buttonLayoutType = props.buttonLayoutType,
|
531
|
+
container = props.container,
|
532
|
+
title = props.title,
|
533
|
+
description = props.description,
|
534
|
+
onClose = props.onClose,
|
535
|
+
rest = __rest(props, ["className", "children", "buttonLayoutType", "container", "title", "description", "onClose"]);
|
536
|
+
return jsx(Dialog.Root, _assign({}, rest, {
|
537
|
+
defaultOpen: true,
|
538
|
+
children: jsxs(Dialog.Portal, {
|
539
|
+
container: container || document.body,
|
540
|
+
children: [jsx(Dialog.Overlay, {
|
541
|
+
className: "popup--overlay",
|
542
|
+
onClick: onClose
|
543
|
+
}), jsxs(Dialog.Content, {
|
544
|
+
"data-frieeren-component": "Popup",
|
545
|
+
className: cx("popup", (_a = {}, _a["popup--layout-".concat(buttonLayoutType)] = buttonLayoutType, _a), className),
|
546
|
+
children: [jsx(Dialog.Title, {
|
547
|
+
className: "visually-hidden",
|
548
|
+
children: title || "Popup"
|
549
|
+
}), jsx(Dialog.Description, {
|
550
|
+
className: "visually-hidden",
|
551
|
+
children: description || "Popup"
|
552
|
+
}), jsx("div", {
|
553
|
+
className: "popup--body",
|
554
|
+
children: children
|
555
|
+
}), buttonLayoutType === "typeA" && "button" in props && props.button && jsx("div", {
|
556
|
+
className: "popup--actions",
|
557
|
+
children: props.button
|
558
|
+
}), buttonLayoutType === "typeB" && "leftButton" in props && "rightButton" in props && jsxs("div", {
|
559
|
+
className: "popup--actions popup--actions-typeB",
|
560
|
+
children: [jsx("div", {
|
561
|
+
className: "popup--actions-left",
|
562
|
+
children: props.leftButton
|
563
|
+
}), jsx("div", {
|
564
|
+
className: "popup--actions-right",
|
565
|
+
children: props.rightButton
|
566
|
+
})]
|
567
|
+
})]
|
568
|
+
})]
|
569
|
+
})
|
570
|
+
}));
|
571
|
+
};
|
572
|
+
|
573
|
+
function SwitchCase(_a) {
|
574
|
+
var _b;
|
575
|
+
var value = _a.value,
|
576
|
+
caseBy = _a.caseBy,
|
577
|
+
_c = _a.defaultComponent,
|
578
|
+
defaultComponent = _c === void 0 ? null : _c;
|
579
|
+
if (value == null) {
|
580
|
+
return defaultComponent;
|
581
|
+
}
|
582
|
+
return (_b = caseBy[value]) !== null && _b !== void 0 ? _b : defaultComponent;
|
583
|
+
}
|
584
|
+
|
585
|
+
var BottomSheet = function BottomSheet(_a) {
|
586
|
+
var _b;
|
587
|
+
var open = _a.open,
|
588
|
+
onClose = _a.onClose,
|
589
|
+
_c = _a.locked,
|
590
|
+
locked = _c === void 0 ? true : _c,
|
591
|
+
_d = _a.showHandle,
|
592
|
+
showHandle = _d === void 0 ? true : _d,
|
593
|
+
_e = _a.handleOnly,
|
594
|
+
handleOnly = _e === void 0 ? false : _e,
|
595
|
+
radius = _a.radius,
|
596
|
+
_f = _a.theme,
|
597
|
+
theme = _f === void 0 ? "light" : _f,
|
598
|
+
_g = _a.zIndex,
|
599
|
+
zIndex = _g === void 0 ? 1 : _g,
|
600
|
+
className = _a.className,
|
601
|
+
children = _a.children;
|
602
|
+
return jsx(Drawer.Root, {
|
603
|
+
open: open,
|
604
|
+
onClose: onClose,
|
605
|
+
modal: locked,
|
606
|
+
handleOnly: handleOnly,
|
607
|
+
children: jsxs(Drawer.Portal, {
|
608
|
+
children: [jsx(Drawer.Overlay, {
|
609
|
+
className: "overlay",
|
610
|
+
"data-frieeren-component": "BottomSheetOverlay",
|
611
|
+
style: {
|
612
|
+
zIndex: zIndex
|
613
|
+
}
|
614
|
+
}), jsxs(Drawer.Content, {
|
615
|
+
className: cx("drawer-content", (_b = {}, _b["bottomsheet-container--radius-".concat(radius)] = radius, _b["bottomsheet-container--theme-".concat(theme)] = theme, _b), className),
|
616
|
+
"data-frieeren-component": "BottomSheet",
|
617
|
+
style: {
|
618
|
+
zIndex: zIndex
|
619
|
+
},
|
620
|
+
children: [jsx(SwitchCase, {
|
621
|
+
value: String(showHandle),
|
622
|
+
caseBy: {
|
623
|
+
"true": jsx(Flex, {
|
624
|
+
className: "drawer-handle",
|
625
|
+
align: "center",
|
626
|
+
justify: "center",
|
627
|
+
children: jsx(Drawer.Handle, {
|
628
|
+
style: {
|
629
|
+
width: 36
|
630
|
+
}
|
631
|
+
})
|
632
|
+
})
|
633
|
+
}
|
634
|
+
}), jsx("div", {
|
635
|
+
className: "drawer-content-inner",
|
636
|
+
children: children
|
637
|
+
})]
|
638
|
+
})]
|
639
|
+
})
|
640
|
+
});
|
641
|
+
};
|
642
|
+
|
643
|
+
var _rect, _path$4;
|
644
|
+
function _extends$4() { return _extends$4 = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$4.apply(null, arguments); }
|
645
|
+
var SvgClose = function SvgClose(props) {
|
646
|
+
return /*#__PURE__*/React.createElement("svg", _extends$4({
|
647
|
+
xmlns: "http://www.w3.org/2000/svg",
|
648
|
+
width: "1em",
|
649
|
+
height: "1em",
|
650
|
+
fill: "none",
|
651
|
+
viewBox: "0 0 16 16"
|
652
|
+
}, props), _rect || (_rect = /*#__PURE__*/React.createElement("rect", {
|
653
|
+
width: 16,
|
654
|
+
height: 16,
|
655
|
+
fill: "#F6F7F9",
|
656
|
+
rx: 8
|
657
|
+
})), _path$4 || (_path$4 = /*#__PURE__*/React.createElement("path", {
|
658
|
+
fill: "#A6ABAF",
|
659
|
+
fillRule: "evenodd",
|
660
|
+
d: "M5.997 5.29a.5.5 0 0 0-.707.707L7.293 8 5.29 10.004a.5.5 0 1 0 .707.707L8 8.708l2.004 2.003a.5.5 0 0 0 .707-.707L8.707 8l2.004-2.003a.5.5 0 0 0-.707-.707L8 7.293z",
|
661
|
+
clipRule: "evenodd"
|
662
|
+
})));
|
663
|
+
};
|
664
|
+
|
665
|
+
var _path$3, _path2;
|
666
|
+
function _extends$3() { return _extends$3 = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$3.apply(null, arguments); }
|
667
|
+
var SvgLink = function SvgLink(props) {
|
668
|
+
return /*#__PURE__*/React.createElement("svg", _extends$3({
|
669
|
+
xmlns: "http://www.w3.org/2000/svg",
|
670
|
+
width: "1em",
|
671
|
+
height: "1em",
|
672
|
+
fill: "none",
|
673
|
+
viewBox: "0 0 24 24"
|
674
|
+
}, props), _path$3 || (_path$3 = /*#__PURE__*/React.createElement("path", {
|
675
|
+
stroke: "#A6ABAF",
|
676
|
+
strokeLinecap: "round",
|
677
|
+
strokeLinejoin: "round",
|
678
|
+
strokeWidth: 1.5,
|
679
|
+
d: "m14 10-4 4"
|
680
|
+
})), _path2 || (_path2 = /*#__PURE__*/React.createElement("path", {
|
681
|
+
stroke: "#A6ABAF",
|
682
|
+
strokeLinecap: "round",
|
683
|
+
strokeWidth: 1.5,
|
684
|
+
d: "m16 13 2-2a3.536 3.536 0 0 0 0-5v0a3.536 3.536 0 0 0-5 0l-2 2m-3 3-2 2a3.536 3.536 0 0 0 0 5v0a3.536 3.536 0 0 0 5 0l2-2"
|
685
|
+
})));
|
686
|
+
};
|
687
|
+
|
688
|
+
var Input = /*#__PURE__*/forwardRef(function (_a, ref) {
|
689
|
+
var _b;
|
690
|
+
var _c = _a.type,
|
691
|
+
type = _c === void 0 ? "text" : _c;
|
692
|
+
_a.accept;
|
693
|
+
var _d = _a.display,
|
694
|
+
display = _d === void 0 ? "box" : _d,
|
695
|
+
_e = _a.disabled,
|
696
|
+
disabled = _e === void 0 ? false : _e,
|
697
|
+
_f = _a.error,
|
698
|
+
error = _f === void 0 ? false : _f,
|
699
|
+
onClear = _a.onClear,
|
700
|
+
className = _a.className,
|
701
|
+
value = _a.value,
|
702
|
+
onChange = _a.onChange,
|
703
|
+
_g = _a.placeholder,
|
704
|
+
placeholder = _g === void 0 ? "텍스트를 입력하세요" : _g,
|
705
|
+
rest = __rest(_a, ["type", "accept", "display", "disabled", "error", "onClear", "className", "value", "onChange", "placeholder"]);
|
706
|
+
var _h = useState(false),
|
707
|
+
hasFile = _h[0],
|
708
|
+
setHasFile = _h[1];
|
709
|
+
var handleChange = function handleChange(e) {
|
710
|
+
if (type === "file") {
|
711
|
+
setHasFile(!!(e.target.files && e.target.files.length > 0));
|
712
|
+
}
|
713
|
+
if (onChange) {
|
714
|
+
onChange(e);
|
715
|
+
}
|
716
|
+
};
|
717
|
+
return jsxs("div", {
|
718
|
+
className: cx("input-wrapper", (_b = {}, _b["input--display-".concat(display)] = display, _b["input--disabled"] = disabled, _b["input--error"] = error, _b), className),
|
719
|
+
children: [jsx("input", _assign({
|
720
|
+
placeholder: placeholder,
|
721
|
+
ref: ref,
|
722
|
+
type: type,
|
723
|
+
disabled: disabled,
|
724
|
+
className: cx("input", {
|
725
|
+
"has-file": hasFile
|
726
|
+
}),
|
727
|
+
"data-frieeren-component": "Input",
|
728
|
+
onChange: handleChange
|
729
|
+
}, rest)), type === "file" && jsx("button", {
|
730
|
+
className: "input--action input--action-link",
|
731
|
+
disabled: disabled,
|
732
|
+
children: jsx(SvgLink, {})
|
733
|
+
}), value && onClear && jsx("button", {
|
734
|
+
onClick: onClear,
|
735
|
+
className: "input--close",
|
736
|
+
disabled: disabled,
|
737
|
+
children: jsx(SvgClose, {})
|
738
|
+
})]
|
739
|
+
});
|
740
|
+
});
|
741
|
+
Input.displayName = "Input";
|
742
|
+
|
743
|
+
var Root = function Root(_a) {
|
744
|
+
var props = __rest(_a, []);
|
745
|
+
return jsx(TabsBase.Root, _assign({
|
746
|
+
"data-frieeren-component": "Tabs",
|
747
|
+
className: "tabs"
|
748
|
+
}, props));
|
749
|
+
};
|
750
|
+
var List = function List(_a) {
|
751
|
+
var props = __rest(_a, []);
|
752
|
+
return jsx(TabsBase.List, _assign({
|
753
|
+
"data-frieeren-component": "TabsList",
|
754
|
+
className: "tabs--list"
|
755
|
+
}, props));
|
756
|
+
};
|
757
|
+
var Trigger = function Trigger(_a) {
|
758
|
+
var props = __rest(_a, []);
|
759
|
+
return jsx(TabsBase.Trigger, _assign({
|
760
|
+
"data-frieeren-component": "TabsTrigger",
|
761
|
+
className: "tabs--trigger"
|
762
|
+
}, props));
|
763
|
+
};
|
764
|
+
var Content = function Content(_a) {
|
765
|
+
var props = __rest(_a, []);
|
766
|
+
return jsx(TabsBase.Content, _assign({
|
767
|
+
"data-frieeren-component": "TabsContent",
|
768
|
+
className: "tabs--content"
|
769
|
+
}, props));
|
770
|
+
};
|
771
|
+
|
772
|
+
/**
|
773
|
+
* 탭 인디케이터의 위치를 계산하고 관리하는 커스텀 훅
|
774
|
+
* @param {UseTabsIndicatorProps} props - 탭 인디케이터 설정
|
775
|
+
* @returns {Object} indicatorStyle - 인디케이터의 스타일 객체
|
776
|
+
*/
|
777
|
+
var useTabsIndicator = function useTabsIndicator(_a) {
|
778
|
+
var listRef = _a.listRef;
|
779
|
+
var _b = useState({}),
|
780
|
+
indicatorStyle = _b[0],
|
781
|
+
setIndicatorStyle = _b[1];
|
782
|
+
// 활성화된 탭의 위치를 기반으로 인디케이터의 위치를 계산합니다.
|
783
|
+
var updateIndicatorPosition = useCallback(function (listRef) {
|
784
|
+
var _a;
|
785
|
+
var activeTab = (_a = listRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('[data-state="active"]');
|
786
|
+
if (!activeTab) return;
|
787
|
+
var _b = activeTab,
|
788
|
+
offsetLeft = _b.offsetLeft,
|
789
|
+
offsetWidth = _b.offsetWidth;
|
790
|
+
setIndicatorStyle({
|
791
|
+
transform: "translateX(".concat(offsetLeft, "px)"),
|
792
|
+
width: "".concat(offsetWidth, "px")
|
793
|
+
});
|
794
|
+
}, []);
|
795
|
+
useEffect(function () {
|
796
|
+
if (!listRef.current) return;
|
797
|
+
// 초기 인디케이터 위치 설정
|
798
|
+
updateIndicatorPosition(listRef);
|
799
|
+
/**
|
800
|
+
* 탭의 상태 변화를 감지하는 MutationObserver
|
801
|
+
* data-state 속성이 변경될 때마다 인디케이터 위치를 업데이트합니다.
|
802
|
+
*/
|
803
|
+
var mutationObserver = new MutationObserver(function (mutations) {
|
804
|
+
mutations.forEach(function (mutation) {
|
805
|
+
if (mutation.type === "attributes" && mutation.attributeName === "data-state") {
|
806
|
+
updateIndicatorPosition(listRef);
|
807
|
+
}
|
808
|
+
});
|
809
|
+
});
|
810
|
+
/**
|
811
|
+
* 탭의 크기 변화를 감지하는 ResizeObserver
|
812
|
+
* 윈도우 리사이즈나 탭 크기 변경 시 인디케이터 위치를 업데이트합니다.
|
813
|
+
*/
|
814
|
+
var resizeObserver = new ResizeObserver(function () {
|
815
|
+
updateIndicatorPosition(listRef);
|
816
|
+
});
|
817
|
+
// 모든 탭 트리거에 옵저버 적용
|
818
|
+
var triggers = listRef.current.querySelectorAll('[role="tab"]');
|
819
|
+
triggers.forEach(function (trigger) {
|
820
|
+
mutationObserver.observe(trigger, {
|
821
|
+
attributes: true
|
822
|
+
});
|
823
|
+
resizeObserver.observe(trigger);
|
824
|
+
});
|
825
|
+
return function () {
|
826
|
+
mutationObserver.disconnect();
|
827
|
+
resizeObserver.disconnect();
|
828
|
+
};
|
829
|
+
}, [listRef, updateIndicatorPosition]);
|
830
|
+
return {
|
831
|
+
indicatorStyle: indicatorStyle
|
832
|
+
};
|
833
|
+
};
|
834
|
+
|
835
|
+
var Tabs = function Tabs(props) {
|
836
|
+
var _a = props.width,
|
837
|
+
width = _a === void 0 ? "100%" : _a,
|
838
|
+
tabItems = props.tabItems,
|
839
|
+
value = props.value,
|
840
|
+
rest = __rest(props, ["width", "tabItems", "value"]);
|
841
|
+
var listRef = useRef(null);
|
842
|
+
var indicatorStyle = useTabsIndicator({
|
843
|
+
listRef: listRef
|
844
|
+
}).indicatorStyle;
|
845
|
+
return jsxs(Root, _assign({
|
846
|
+
value: value
|
847
|
+
}, rest, {
|
848
|
+
style: {
|
849
|
+
width: width
|
850
|
+
},
|
851
|
+
children: [jsxs("div", {
|
852
|
+
ref: listRef,
|
853
|
+
className: "tabs--list-wrapper",
|
854
|
+
children: [jsx(List, {
|
855
|
+
"data-orientation": "horizontal",
|
856
|
+
children: tabItems.map(function (item) {
|
857
|
+
return jsx(Trigger, {
|
858
|
+
value: item.value,
|
859
|
+
children: item.text
|
860
|
+
}, "tabTrigger_".concat(item.value));
|
861
|
+
})
|
862
|
+
}), jsx("div", {
|
863
|
+
className: "tabs--indicator",
|
864
|
+
style: indicatorStyle
|
865
|
+
})]
|
866
|
+
}), tabItems.map(function (item) {
|
867
|
+
return jsx(Content, {
|
868
|
+
value: item.value,
|
869
|
+
children: item.content
|
870
|
+
}, "tabContent_".concat(item.value));
|
871
|
+
})]
|
872
|
+
}));
|
873
|
+
};
|
874
|
+
|
875
|
+
function useIsMounted() {
|
876
|
+
var _a = useState(false),
|
877
|
+
mounted = _a[0],
|
878
|
+
setMounted = _a[1];
|
879
|
+
useEffect(function () {
|
880
|
+
setMounted(true);
|
881
|
+
}, []);
|
882
|
+
return mounted;
|
883
|
+
}
|
884
|
+
|
885
|
+
/** between the toasts spacing */
|
886
|
+
var GAP = 8;
|
887
|
+
var useToastStack = function useToastStack(toasts) {
|
888
|
+
var _a = useState({}),
|
889
|
+
heights = _a[0],
|
890
|
+
setHeights = _a[1];
|
891
|
+
var updateHeight = useCallback(function (id, height) {
|
892
|
+
setHeights(function (prev) {
|
893
|
+
var _a;
|
894
|
+
return _assign(_assign({}, prev), (_a = {}, _a[id] = height, _a));
|
895
|
+
});
|
896
|
+
}, []);
|
897
|
+
var groupedToasts = useMemo(function () {
|
898
|
+
var groups = {
|
899
|
+
"top-left": [],
|
900
|
+
"top-right": [],
|
901
|
+
"top-center": [],
|
902
|
+
"bottom-left": [],
|
903
|
+
"bottom-right": [],
|
904
|
+
"bottom-center": []
|
905
|
+
};
|
906
|
+
toasts.forEach(function (toast) {
|
907
|
+
var position = toast.position;
|
908
|
+
groups[position].push(toast);
|
909
|
+
});
|
910
|
+
return groups;
|
911
|
+
}, [toasts]);
|
912
|
+
var getToasterProps = useCallback(function (toast, index, position) {
|
913
|
+
var positionToasts = groupedToasts[position];
|
914
|
+
var offset = positionToasts.slice(0, index).reduce(function (total, t) {
|
915
|
+
return total + (heights[t.id] || 0) + GAP;
|
916
|
+
}, 0);
|
917
|
+
var translateY = "".concat(offset * (position.includes("top") ? 1 : -1), "px");
|
918
|
+
var translateX = position.includes("center") ? "-50%" : "0";
|
919
|
+
return {
|
920
|
+
ref: function ref(el) {
|
921
|
+
if (el) {
|
922
|
+
var height = el.getBoundingClientRect().height;
|
923
|
+
if (heights[toast.id] !== height) {
|
924
|
+
updateHeight(toast.id, height);
|
925
|
+
}
|
926
|
+
}
|
927
|
+
},
|
928
|
+
style: {
|
929
|
+
transform: "translate(".concat(translateX, ", ").concat(translateY, ")"),
|
930
|
+
transition: "transform 0.23s cubic-bezier(0.21, 1.02, 0.73, 1)"
|
931
|
+
},
|
932
|
+
className: cx("toast-wrapper", "toast-wrapper--".concat(position))
|
933
|
+
};
|
934
|
+
}, [heights, groupedToasts]);
|
935
|
+
return {
|
936
|
+
getToasterProps: getToasterProps,
|
937
|
+
groupedToasts: groupedToasts
|
938
|
+
};
|
939
|
+
};
|
940
|
+
|
941
|
+
var _path$2;
|
942
|
+
function _extends$2() { return _extends$2 = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$2.apply(null, arguments); }
|
943
|
+
var SvgToastSuccess = function SvgToastSuccess(props) {
|
944
|
+
return /*#__PURE__*/React.createElement("svg", _extends$2({
|
945
|
+
xmlns: "http://www.w3.org/2000/svg",
|
946
|
+
width: "1em",
|
947
|
+
height: "1em",
|
948
|
+
fill: "none",
|
949
|
+
viewBox: "0 0 18 18"
|
950
|
+
}, props), _path$2 || (_path$2 = /*#__PURE__*/React.createElement("path", {
|
951
|
+
fill: "#50BF50",
|
952
|
+
fillRule: "evenodd",
|
953
|
+
d: "M9 18A9 9 0 1 0 9 0a9 9 0 0 0 0 18m4.768-11.36a1 1 0 1 0-1.536-1.28L8.634 9.677c-.347.416-.542.647-.697.788l-.006.006-.007-.005c-.168-.127-.383-.339-.766-.722l-1.45-1.451a1 1 0 0 0-1.415 1.414l1.451 1.451.041.041c.327.327.64.641.933.862.327.248.756.48 1.305.456.55-.025.956-.296 1.26-.572.27-.247.555-.588.85-.943l.037-.044z",
|
954
|
+
clipRule: "evenodd"
|
955
|
+
})));
|
956
|
+
};
|
957
|
+
|
958
|
+
var _path$1;
|
959
|
+
function _extends$1() { return _extends$1 = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$1.apply(null, arguments); }
|
960
|
+
var SvgToastWarning = function SvgToastWarning(props) {
|
961
|
+
return /*#__PURE__*/React.createElement("svg", _extends$1({
|
962
|
+
xmlns: "http://www.w3.org/2000/svg",
|
963
|
+
width: "1em",
|
964
|
+
height: "1em",
|
965
|
+
fill: "none",
|
966
|
+
viewBox: "0 0 18 16"
|
967
|
+
}, props), _path$1 || (_path$1 = /*#__PURE__*/React.createElement("path", {
|
968
|
+
fill: "#FEF08A",
|
969
|
+
fillRule: "evenodd",
|
970
|
+
d: "M8.133.504a1 1 0 0 1 1.737 0l8 14A1 1 0 0 1 17 15.998h-16a1 1 0 0 1-.868-1.496zM7.981 5.16a1.02 1.02 0 1 1 2.042 0v4.146a1.02 1.02 0 0 1-2.042 0zm1.02 8.26c.565 0 1.022-.461 1.022-1.031s-.457-1.031-1.021-1.031-1.02.461-1.02 1.031.456 1.031 1.02 1.031",
|
971
|
+
clipRule: "evenodd"
|
972
|
+
})));
|
973
|
+
};
|
974
|
+
|
975
|
+
var _path;
|
976
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
977
|
+
var SvgToastError = function SvgToastError(props) {
|
978
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
979
|
+
xmlns: "http://www.w3.org/2000/svg",
|
980
|
+
width: "1em",
|
981
|
+
height: "1em",
|
982
|
+
fill: "none",
|
983
|
+
viewBox: "0 0 18 18"
|
984
|
+
}, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
|
985
|
+
fill: "#EF4444",
|
986
|
+
fillRule: "evenodd",
|
987
|
+
d: "M18 9A9 9 0 1 1 0 9a9 9 0 0 1 18 0M4.293 13.707a1 1 0 0 1 0-1.414L7.586 9 4.293 5.707a1 1 0 0 1 1.414-1.414L9 7.586l3.293-3.293a1 1 0 1 1 1.414 1.414L10.414 9l3.293 3.293a1 1 0 0 1-1.414 1.414L9 10.414l-3.293 3.293a1 1 0 0 1-1.414 0",
|
988
|
+
clipRule: "evenodd"
|
989
|
+
})));
|
990
|
+
};
|
991
|
+
|
992
|
+
var Toaster = function Toaster(_a) {
|
993
|
+
var toasts = _a.toasts;
|
994
|
+
var _b = useToastStack(toasts),
|
995
|
+
getToasterProps = _b.getToasterProps,
|
996
|
+
groupedToasts = _b.groupedToasts;
|
997
|
+
return jsx(Fragment$1, {
|
998
|
+
children: Object.entries(groupedToasts).map(function (_a) {
|
999
|
+
var position = _a[0],
|
1000
|
+
positionToasts = _a[1];
|
1001
|
+
return positionToasts.length > 0 && jsx("div", {
|
1002
|
+
className: "toaster-content",
|
1003
|
+
children: positionToasts.map(function (toast, idx) {
|
1004
|
+
var toasterProps = getToasterProps(toast, idx, position);
|
1005
|
+
return jsx("div", _assign({}, toasterProps, {
|
1006
|
+
children: jsx(Toast, _assign({}, toast))
|
1007
|
+
}), toast.id);
|
1008
|
+
})
|
1009
|
+
}, position);
|
1010
|
+
})
|
1011
|
+
});
|
1012
|
+
};
|
1013
|
+
var Toast = function Toast(_a) {
|
1014
|
+
var toast = __rest(_a, []);
|
1015
|
+
var width = toast.width,
|
1016
|
+
type = toast.type,
|
1017
|
+
action = toast.action,
|
1018
|
+
position = toast.position,
|
1019
|
+
offest = toast.offest,
|
1020
|
+
duration = toast.duration,
|
1021
|
+
style = toast.style,
|
1022
|
+
message = toast.message,
|
1023
|
+
buttonText = toast.buttonText,
|
1024
|
+
onAction = toast.onAction;
|
1025
|
+
var isMounted = useIsMounted();
|
1026
|
+
var _b = useState(false),
|
1027
|
+
visible = _b[0],
|
1028
|
+
setVisible = _b[1];
|
1029
|
+
var isTop = position === null || position === void 0 ? void 0 : position.includes("top");
|
1030
|
+
var positionClass = isTop ? "top" : "bottom";
|
1031
|
+
var offsetStyle = useMemo(function () {
|
1032
|
+
var offsetValue = offest;
|
1033
|
+
return isTop ? {
|
1034
|
+
top: offsetValue + "px"
|
1035
|
+
} : {
|
1036
|
+
bottom: offsetValue + "px"
|
1037
|
+
};
|
1038
|
+
}, [isTop, offest]);
|
1039
|
+
useEffect(function () {
|
1040
|
+
if (isMounted) {
|
1041
|
+
requestAnimationFrame(function () {
|
1042
|
+
setVisible(true);
|
1043
|
+
});
|
1044
|
+
}
|
1045
|
+
var timer = setTimeout(function () {
|
1046
|
+
setVisible(false);
|
1047
|
+
}, duration - 500);
|
1048
|
+
return function () {
|
1049
|
+
return clearTimeout(timer);
|
1050
|
+
};
|
1051
|
+
}, [isMounted]);
|
1052
|
+
return jsxs("div", {
|
1053
|
+
"data-frieeren-component": "Toast",
|
1054
|
+
className: cx("toast--content", positionClass, {
|
1055
|
+
visible: visible,
|
1056
|
+
hidden: !visible
|
1057
|
+
}),
|
1058
|
+
style: _assign(_assign({
|
1059
|
+
width: width,
|
1060
|
+
visibility: visible ? "visible" : "hidden"
|
1061
|
+
}, offsetStyle), style),
|
1062
|
+
children: [jsxs("div", {
|
1063
|
+
className: "toast--type-message",
|
1064
|
+
children: [jsx("div", {
|
1065
|
+
className: "toast--type-icon",
|
1066
|
+
"data-toast-type": type,
|
1067
|
+
children: jsx(SwitchCase, {
|
1068
|
+
value: type || "default",
|
1069
|
+
caseBy: {
|
1070
|
+
success: jsx(SvgToastSuccess, {}),
|
1071
|
+
warning: jsx(SvgToastWarning, {}),
|
1072
|
+
error: jsx(SvgToastError, {})
|
1073
|
+
},
|
1074
|
+
defaultComponent: null
|
1075
|
+
})
|
1076
|
+
}), jsx("div", {
|
1077
|
+
className: "toast--message",
|
1078
|
+
children: message
|
1079
|
+
})]
|
1080
|
+
}), jsx(SwitchCase, {
|
1081
|
+
value: action || "defualt",
|
1082
|
+
caseBy: {
|
1083
|
+
"icon-link": jsx("button", {
|
1084
|
+
className: "toast--action-link",
|
1085
|
+
onClick: onAction,
|
1086
|
+
children: "\uB9C1\uD06C\u2192"
|
1087
|
+
}),
|
1088
|
+
"icon-button": jsx("button", {
|
1089
|
+
className: "toast--action-button",
|
1090
|
+
onClick: onAction,
|
1091
|
+
children: buttonText
|
1092
|
+
})
|
1093
|
+
},
|
1094
|
+
defaultComponent: null
|
1095
|
+
})]
|
1096
|
+
});
|
1097
|
+
};
|
1098
|
+
|
1099
|
+
var defaultToastValue = {
|
1100
|
+
type: "default",
|
1101
|
+
action: "defualt",
|
1102
|
+
style: {},
|
1103
|
+
offest: 0,
|
1104
|
+
message: "",
|
1105
|
+
duration: 3000,
|
1106
|
+
position: "top-right"
|
1107
|
+
};
|
1108
|
+
var ToastContext = /*#__PURE__*/createContext({
|
1109
|
+
toasts: [],
|
1110
|
+
add: function add() {
|
1111
|
+
return "";
|
1112
|
+
},
|
1113
|
+
remove: function remove() {}
|
1114
|
+
});
|
1115
|
+
var ToastPortal = function ToastPortal(_a) {
|
1116
|
+
var children = _a.children;
|
1117
|
+
var isMounted = useIsMounted();
|
1118
|
+
var node = document.getElementById("toast-portal");
|
1119
|
+
if (!isMounted) return null;
|
1120
|
+
return /*#__PURE__*/createPortal(children, node);
|
1121
|
+
};
|
1122
|
+
var ToastProvider = function ToastProvider(_a) {
|
1123
|
+
var options = _a.options,
|
1124
|
+
children = _a.children;
|
1125
|
+
var _b = useState([]),
|
1126
|
+
toasts = _b[0],
|
1127
|
+
setToasts = _b[1];
|
1128
|
+
var add = useCallback(function (toast) {
|
1129
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
1130
|
+
var id = Math.random().toString(36).substring(2, 9);
|
1131
|
+
var newToast = _assign(_assign({}, toast), {
|
1132
|
+
id: id,
|
1133
|
+
type: (_b = (_a = toast.type) !== null && _a !== void 0 ? _a : options === null || options === void 0 ? void 0 : options.type) !== null && _b !== void 0 ? _b : defaultToastValue.type,
|
1134
|
+
action: (_d = (_c = toast.action) !== null && _c !== void 0 ? _c : options === null || options === void 0 ? void 0 : options.action) !== null && _d !== void 0 ? _d : defaultToastValue.action,
|
1135
|
+
style: (_f = (_e = toast.style) !== null && _e !== void 0 ? _e : options === null || options === void 0 ? void 0 : options.style) !== null && _f !== void 0 ? _f : defaultToastValue.style,
|
1136
|
+
offest: (_h = (_g = toast.offest) !== null && _g !== void 0 ? _g : options === null || options === void 0 ? void 0 : options.offest) !== null && _h !== void 0 ? _h : defaultToastValue.offest,
|
1137
|
+
radius: (_k = (_j = toast.radius) !== null && _j !== void 0 ? _j : options === null || options === void 0 ? void 0 : options.radius) !== null && _k !== void 0 ? _k : defaultToastValue.radius,
|
1138
|
+
message: (_m = (_l = toast.message) !== null && _l !== void 0 ? _l : options === null || options === void 0 ? void 0 : options.message) !== null && _m !== void 0 ? _m : defaultToastValue.message,
|
1139
|
+
duration: (_p = (_o = toast.duration) !== null && _o !== void 0 ? _o : options === null || options === void 0 ? void 0 : options.duration) !== null && _p !== void 0 ? _p : defaultToastValue.duration,
|
1140
|
+
position: (_r = (_q = toast.position) !== null && _q !== void 0 ? _q : options === null || options === void 0 ? void 0 : options.position) !== null && _r !== void 0 ? _r : defaultToastValue.position
|
1141
|
+
});
|
1142
|
+
setToasts(function (prev) {
|
1143
|
+
return __spreadArray([newToast], prev, true);
|
1144
|
+
});
|
1145
|
+
if (newToast.duration > 0) {
|
1146
|
+
setTimeout(function () {
|
1147
|
+
return remove(id);
|
1148
|
+
}, newToast.duration);
|
1149
|
+
}
|
1150
|
+
return id;
|
1151
|
+
}, [options]);
|
1152
|
+
var remove = useCallback(function (id) {
|
1153
|
+
setToasts(function (prev) {
|
1154
|
+
return prev.filter(function (toast) {
|
1155
|
+
return toast.id !== id;
|
1156
|
+
});
|
1157
|
+
});
|
1158
|
+
}, []);
|
1159
|
+
var value = useMemo(function () {
|
1160
|
+
return {
|
1161
|
+
toasts: toasts,
|
1162
|
+
add: add,
|
1163
|
+
remove: remove
|
1164
|
+
};
|
1165
|
+
}, [toasts, add, remove]);
|
1166
|
+
return jsxs(ToastContext.Provider, {
|
1167
|
+
value: value,
|
1168
|
+
children: [children, jsx(ToastPortal, {
|
1169
|
+
children: toasts.length && jsx(Toaster, {
|
1170
|
+
toasts: toasts
|
1171
|
+
})
|
1172
|
+
})]
|
1173
|
+
});
|
1174
|
+
};
|
1175
|
+
|
1176
|
+
var useToast = function useToast() {
|
1177
|
+
var context = useContext(ToastContext);
|
1178
|
+
if (!context) {
|
1179
|
+
throw new Error("useToast must be used within a ToastProvider");
|
1180
|
+
}
|
1181
|
+
return context;
|
1182
|
+
};
|
1183
|
+
|
1184
|
+
var generateRandomKey = function generateRandomKey() {
|
1185
|
+
return Math.random().toString(36).substring(2, 11);
|
1186
|
+
};
|
1187
|
+
|
1188
|
+
var MemoryStorage = /** @class */function () {
|
1189
|
+
function MemoryStorage() {
|
1190
|
+
this.map = new Map();
|
1191
|
+
}
|
1192
|
+
MemoryStorage.prototype.has = function (key) {
|
1193
|
+
return this.map.get(key) !== null;
|
1194
|
+
};
|
1195
|
+
MemoryStorage.prototype.get = function (key) {
|
1196
|
+
return this.map.get(key) || null;
|
1197
|
+
};
|
1198
|
+
MemoryStorage.prototype.set = function (key, value) {
|
1199
|
+
this.map.set(key, value);
|
1200
|
+
};
|
1201
|
+
MemoryStorage.prototype.remove = function (key) {
|
1202
|
+
this.map["delete"](key);
|
1203
|
+
};
|
1204
|
+
MemoryStorage.prototype.clear = function () {
|
1205
|
+
this.map.clear();
|
1206
|
+
};
|
1207
|
+
MemoryStorage.prototype.setObject = function (key, value) {
|
1208
|
+
this.map.set(key, JSON.stringify(value));
|
1209
|
+
};
|
1210
|
+
MemoryStorage.prototype.getObject = function (key) {
|
1211
|
+
var value = this.map.get(key);
|
1212
|
+
if (!value) return null;
|
1213
|
+
return JSON.parse(value);
|
1214
|
+
};
|
1215
|
+
return MemoryStorage;
|
1216
|
+
}();
|
1217
|
+
|
1218
|
+
var LocalStorage = /** @class */function () {
|
1219
|
+
function LocalStorage() {}
|
1220
|
+
LocalStorage.isEnabled = function () {
|
1221
|
+
if (typeof window === "undefined" || !!window.localStorage) {
|
1222
|
+
return false;
|
1223
|
+
}
|
1224
|
+
try {
|
1225
|
+
var KEY = generateRandomKey();
|
1226
|
+
localStorage.setItem(KEY, "test");
|
1227
|
+
localStorage.removeItem(KEY);
|
1228
|
+
return true;
|
1229
|
+
} catch (_a) {
|
1230
|
+
return false;
|
1231
|
+
}
|
1232
|
+
};
|
1233
|
+
LocalStorage.prototype.has = function (key) {
|
1234
|
+
return localStorage.getItem(key) !== null;
|
1235
|
+
};
|
1236
|
+
LocalStorage.prototype.get = function (key) {
|
1237
|
+
return localStorage.getItem(key);
|
1238
|
+
};
|
1239
|
+
LocalStorage.prototype.set = function (key, value) {
|
1240
|
+
localStorage.setItem(key, value);
|
1241
|
+
};
|
1242
|
+
LocalStorage.prototype.remove = function (key) {
|
1243
|
+
localStorage.removeItem(key);
|
1244
|
+
};
|
1245
|
+
LocalStorage.prototype.clear = function () {
|
1246
|
+
localStorage.clear();
|
1247
|
+
};
|
1248
|
+
LocalStorage.prototype.setObject = function (key, value) {
|
1249
|
+
localStorage.setItem(key, JSON.stringify(value));
|
1250
|
+
};
|
1251
|
+
LocalStorage.prototype.getObject = function (key) {
|
1252
|
+
var value = localStorage.getItem(key);
|
1253
|
+
if (!value) return null;
|
1254
|
+
return JSON.parse(value);
|
1255
|
+
};
|
1256
|
+
return LocalStorage;
|
1257
|
+
}();
|
1258
|
+
var safeLocalStorage = LocalStorage.isEnabled() ? new LocalStorage() : new MemoryStorage();
|
1259
|
+
|
1260
|
+
var SessionStorage = /** @class */function () {
|
1261
|
+
function SessionStorage() {}
|
1262
|
+
SessionStorage.isEnabled = function () {
|
1263
|
+
if (typeof window === "undefined" || !!window.sessionStorage) {
|
1264
|
+
return false;
|
1265
|
+
}
|
1266
|
+
try {
|
1267
|
+
var KEY = generateRandomKey();
|
1268
|
+
sessionStorage.setItem(KEY, "test");
|
1269
|
+
sessionStorage.removeItem(KEY);
|
1270
|
+
return true;
|
1271
|
+
} catch (_a) {
|
1272
|
+
return false;
|
1273
|
+
}
|
1274
|
+
};
|
1275
|
+
SessionStorage.prototype.has = function (key) {
|
1276
|
+
return sessionStorage.getItem(key) !== null;
|
1277
|
+
};
|
1278
|
+
SessionStorage.prototype.get = function (key) {
|
1279
|
+
return sessionStorage.getItem(key);
|
1280
|
+
};
|
1281
|
+
SessionStorage.prototype.set = function (key, value) {
|
1282
|
+
sessionStorage.setItem(key, value);
|
1283
|
+
};
|
1284
|
+
SessionStorage.prototype.remove = function (key) {
|
1285
|
+
sessionStorage.removeItem(key);
|
1286
|
+
};
|
1287
|
+
SessionStorage.prototype.clear = function () {
|
1288
|
+
sessionStorage.clear();
|
1289
|
+
};
|
1290
|
+
SessionStorage.prototype.setObject = function (key, value) {
|
1291
|
+
sessionStorage.setItem(key, JSON.stringify(value));
|
1292
|
+
};
|
1293
|
+
SessionStorage.prototype.getObject = function (key) {
|
1294
|
+
var value = sessionStorage.getItem(key);
|
1295
|
+
if (!value) return null;
|
1296
|
+
return JSON.parse(value);
|
1297
|
+
};
|
1298
|
+
return SessionStorage;
|
1299
|
+
}();
|
1300
|
+
var safeSessionStorage = SessionStorage.isEnabled() ? new SessionStorage() : new MemoryStorage();
|
1301
|
+
|
1302
|
+
var WindowRouter = /** @class */function () {
|
1303
|
+
function WindowRouter() {}
|
1304
|
+
Object.defineProperty(WindowRouter.prototype, "location", {
|
1305
|
+
get: function get() {
|
1306
|
+
return {
|
1307
|
+
pathname: window.location.pathname,
|
1308
|
+
search: window.location.search,
|
1309
|
+
hash: window.location.hash,
|
1310
|
+
state: window.history.state
|
1311
|
+
};
|
1312
|
+
},
|
1313
|
+
enumerable: false,
|
1314
|
+
configurable: true
|
1315
|
+
});
|
1316
|
+
WindowRouter.prototype.push = function (path, options) {
|
1317
|
+
var _a;
|
1318
|
+
window.history.pushState((_a = options === null || options === void 0 ? void 0 : options.state) !== null && _a !== void 0 ? _a : null, "", this.normalizePath(path));
|
1319
|
+
};
|
1320
|
+
WindowRouter.prototype.replace = function (path, options) {
|
1321
|
+
var _a;
|
1322
|
+
window.history.replaceState((_a = options === null || options === void 0 ? void 0 : options.state) !== null && _a !== void 0 ? _a : null, "", this.normalizePath(path));
|
1323
|
+
};
|
1324
|
+
WindowRouter.prototype.back = function () {
|
1325
|
+
window.history.back();
|
1326
|
+
};
|
1327
|
+
WindowRouter.prototype.forward = function () {
|
1328
|
+
window.history.forward();
|
1329
|
+
};
|
1330
|
+
WindowRouter.prototype.setQuery = function (query) {
|
1331
|
+
var searchParams = new URLSearchParams(window.location.search);
|
1332
|
+
Object.entries(query).forEach(function (_a) {
|
1333
|
+
var key = _a[0],
|
1334
|
+
value = _a[1];
|
1335
|
+
if (Array.isArray(value)) {
|
1336
|
+
searchParams["delete"](key);
|
1337
|
+
value.forEach(function (v) {
|
1338
|
+
return searchParams.append(key, v);
|
1339
|
+
});
|
1340
|
+
} else if (value !== undefined) {
|
1341
|
+
searchParams.set(key, value);
|
1342
|
+
} else {
|
1343
|
+
searchParams["delete"](key);
|
1344
|
+
}
|
1345
|
+
});
|
1346
|
+
this.replace("".concat(window.location.pathname, "?").concat(searchParams.toString()));
|
1347
|
+
};
|
1348
|
+
WindowRouter.prototype.getQuery = function (key) {
|
1349
|
+
var searchParams = new URLSearchParams(window.location.search);
|
1350
|
+
var values = searchParams.getAll(key);
|
1351
|
+
if (values.length > 1) {
|
1352
|
+
return values;
|
1353
|
+
}
|
1354
|
+
return searchParams.get(key);
|
1355
|
+
};
|
1356
|
+
WindowRouter.prototype.getAllQueries = function () {
|
1357
|
+
var searchParams = new URLSearchParams(window.location.search);
|
1358
|
+
var query = {};
|
1359
|
+
searchParams.forEach(function (value, key) {
|
1360
|
+
var existing = query[key];
|
1361
|
+
if (existing !== undefined) {
|
1362
|
+
query[key] = Array.isArray(existing) ? __spreadArray(__spreadArray([], existing, true), [value], false) : [existing, value];
|
1363
|
+
} else {
|
1364
|
+
query[key] = value;
|
1365
|
+
}
|
1366
|
+
});
|
1367
|
+
return query;
|
1368
|
+
};
|
1369
|
+
WindowRouter.prototype.normalizePath = function (path) {
|
1370
|
+
if (path.startsWith("http://") || path.startsWith("https://")) {
|
1371
|
+
return path;
|
1372
|
+
}
|
1373
|
+
return path.startsWith("/") ? path : "/".concat(path);
|
1374
|
+
};
|
1375
|
+
return WindowRouter;
|
1376
|
+
}();
|
1377
|
+
|
1378
|
+
export { BottomSheet, Box, Button, Checkbox, Container, Flex, Grid, Input, Popup, RadioGroup, RouterProvider, Select, Tabs, Text, ToastProvider, Toggle, WindowRouter, safeLocalStorage, safeSessionStorage, useFunnel, useRouter, useToast };
|