@zuzjs/ui 0.3.2 → 0.3.4

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.
Files changed (88) hide show
  1. package/README.md +0 -0
  2. package/dist/hooks.js +89 -0
  3. package/dist/styles.css +37 -62
  4. package/dist/ui.js +665 -0
  5. package/jest.config.js +0 -0
  6. package/package.json +16 -18
  7. package/rollup.config.js +30 -47
  8. package/src/comps/box.tsx +24 -28
  9. package/src/comps/button.tsx +23 -47
  10. package/src/comps/crumb.tsx +9 -0
  11. package/src/comps/form.tsx +57 -88
  12. package/src/comps/heading.tsx +25 -31
  13. package/src/comps/icon.tsx +24 -36
  14. package/src/comps/input.tsx +24 -224
  15. package/src/comps/select.tsx +23 -63
  16. package/src/comps/spinner.tsx +23 -35
  17. package/src/comps/stylesheet.tsx +5 -0
  18. package/src/context/AppContext.tsx +2 -2
  19. package/src/context/AppProvider.tsx +68 -105
  20. package/src/context/createSlice.tsx +15 -39
  21. package/src/context/index.tsx +4 -5
  22. package/src/core/css.ts +1 -0
  23. package/src/core/index.tsx +241 -0
  24. package/src/core/styles.ts +378 -371
  25. package/src/hooks/index.tsx +2 -10
  26. package/src/hooks/useDispatch.tsx +36 -36
  27. package/src/hooks/useStore.tsx +24 -26
  28. package/src/hooks.tsx +8 -0
  29. package/src/scss/mixins.scss +2 -2
  30. package/src/scss/props.scss +91 -69
  31. package/src/scss/{style.scss → styles.scss} +102 -132
  32. package/src/ui.tsx +13 -0
  33. package/tsconfig.json +0 -0
  34. package/tsconfig.lib.json +0 -0
  35. package/tsconfig.spec.json +0 -0
  36. package/dist/index.js +0 -1868
  37. package/src/actions/addForm.tsx +0 -0
  38. package/src/actions/index.tsx +0 -29
  39. package/src/actions/redo.tsx +0 -1
  40. package/src/actions/reset.tsx +0 -1
  41. package/src/actions/undo.tsx +0 -1
  42. package/src/comps/app.tsx +0 -34
  43. package/src/comps/checkbox.tsx +0 -74
  44. package/src/comps/component.tsx +0 -32
  45. package/src/comps/contextmenu.tsx +0 -60
  46. package/src/comps/cover.tsx +0 -34
  47. package/src/comps/image.tsx +0 -34
  48. package/src/comps/masonry.tsx +0 -192
  49. package/src/comps/mediaplayer.tsx +0 -12
  50. package/src/comps/placeholder.tsx +0 -58
  51. package/src/comps/root.tsx +0 -32
  52. package/src/comps/spacer.tsx +0 -20
  53. package/src/comps/text.tsx +0 -27
  54. package/src/comps/toaster.tsx +0 -117
  55. package/src/comps/tweet.tsx +0 -48
  56. package/src/context/_AppProvider.tsx +0 -116
  57. package/src/context/combineReducers.tsx +0 -47
  58. package/src/context/combineState.tsx +0 -14
  59. package/src/context/reduceReducers.tsx +0 -6
  60. package/src/context/store/appbase.tsx +0 -19
  61. package/src/context/store/lang.tsx +0 -26
  62. package/src/context/store/theme.tsx +0 -54
  63. package/src/core/defaultTheme.ts +0 -90
  64. package/src/core/extractCurrentDesignState.tsx +0 -0
  65. package/src/core/index.ts +0 -431
  66. package/src/core/router.ts +0 -86
  67. package/src/hooks/useAppReducer.tsx +0 -40
  68. package/src/hooks/useChooseEffect.tsx +0 -6
  69. package/src/hooks/useContextMenu.tsx +0 -123
  70. package/src/hooks/useDevice.tsx +0 -164
  71. package/src/hooks/useImage.tsx +0 -84
  72. package/src/hooks/useLang.tsx +0 -9
  73. package/src/hooks/useMediaPlayer.tsx +0 -27
  74. package/src/hooks/useNavigator.tsx +0 -6
  75. package/src/hooks/useRender.tsx +0 -29
  76. package/src/hooks/useResizeObserver.tsx +0 -84
  77. package/src/hooks/useRouter.tsx +0 -45
  78. package/src/hooks/useSelector.tsx +0 -9
  79. package/src/hooks/useTheme.tsx +0 -9
  80. package/src/hooks/useToast.tsx +0 -11
  81. package/src/index.tsx +0 -35
  82. package/src/kit/Builder.tsx +0 -18
  83. package/src/kit/Component.tsx +0 -32
  84. package/src/kit/Header.tsx +0 -21
  85. package/src/redux/slices/app.js +0 -26
  86. package/src/redux/slices/form.js +0 -46
  87. package/src/redux/store.js +0 -33
  88. package/src/scss/constants.scss +0 -4
package/dist/index.js DELETED
@@ -1,1868 +0,0 @@
1
- import { createContext, useEffect, useMemo, useReducer, useCallback, useContext, forwardRef, useRef, useState, useLayoutEffect, useDebugValue, cloneElement, useImperativeHandle, createElement, Component as Component$1, Children as Children$1 } from 'react';
2
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
- import PropTypes from 'prop-types';
4
- import Children from 'react-children-utilities';
5
- import Cookies from 'js-cookie';
6
- import axios from 'axios';
7
- import { nanoid } from 'nanoid';
8
- import { ClassNames } from '@emotion/react';
9
- import ReactDOM from 'react-dom/client';
10
- export { Link } from 'react-router-dom';
11
- import styled from '@emotion/styled';
12
-
13
- const AppContext = createContext({});
14
-
15
- /******************************************************************************
16
- Copyright (c) Microsoft Corporation.
17
-
18
- Permission to use, copy, modify, and/or distribute this software for any
19
- purpose with or without fee is hereby granted.
20
-
21
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
22
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
23
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
24
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
25
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
26
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
27
- PERFORMANCE OF THIS SOFTWARE.
28
- ***************************************************************************** */
29
-
30
- function __rest(s, e) {
31
- var t = {};
32
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
33
- t[p] = s[p];
34
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
35
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
36
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
37
- t[p[i]] = s[p[i]];
38
- }
39
- return t;
40
- }
41
-
42
- function __classPrivateFieldGet(receiver, state, kind, f) {
43
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
44
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
45
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
46
- }
47
-
48
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
49
- if (kind === "m") throw new TypeError("Private method is not writable");
50
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
51
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
52
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
53
- }
54
-
55
- var _AppTheme_mode, _AppTheme_listen, _AppTheme_lightTheme, _AppTheme_darkTheme;
56
- class AppTheme {
57
- constructor(_conf) {
58
- _AppTheme_mode.set(this, void 0);
59
- _AppTheme_listen.set(this, void 0);
60
- _AppTheme_lightTheme.set(this, void 0);
61
- _AppTheme_darkTheme.set(this, void 0);
62
- this.get = () => {
63
- let self = this;
64
- if (__classPrivateFieldGet(self, _AppTheme_mode, "f") === "auto") {
65
- window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
66
- __classPrivateFieldSet(self, _AppTheme_mode, event.matches ? "dark" : "light", "f");
67
- __classPrivateFieldGet(self, _AppTheme_listen, "f").call(self, __classPrivateFieldGet(self, _AppTheme_mode, "f"));
68
- });
69
- return window.matchMedia &&
70
- window.matchMedia('(prefers-color-scheme: dark)').matches ?
71
- __classPrivateFieldGet(self, _AppTheme_darkTheme, "f") : __classPrivateFieldGet(self, _AppTheme_lightTheme, "f");
72
- }
73
- else {
74
- if (__classPrivateFieldGet(self, _AppTheme_mode, "f") === "light") {
75
- return __classPrivateFieldGet(self, _AppTheme_lightTheme, "f");
76
- }
77
- else if (__classPrivateFieldGet(self, _AppTheme_mode, "f") === "dark") {
78
- return __classPrivateFieldGet(self, _AppTheme_darkTheme, "f");
79
- }
80
- }
81
- };
82
- const conf = _conf || {};
83
- __classPrivateFieldSet(this, _AppTheme_listen, "listen" in conf ? conf.listen : (mod) => { console.log(`Theme switched to ${mod}`); }, "f");
84
- __classPrivateFieldSet(this, _AppTheme_mode, conf.mode || conf.theme.mode || "auto", "f");
85
- __classPrivateFieldSet(this, _AppTheme_lightTheme, Object.assign({
86
- //CORE
87
- tag: "light", dark: false, primary: '#edeef5', secondary: '#f9f9f9', textColor: '#111111' }, ("theme" in conf && "light" in conf.theme ? Object.assign({}, conf.theme.light) : {})), "f");
88
- __classPrivateFieldSet(this, _AppTheme_darkTheme, Object.assign({
89
- //CORE
90
- tag: "dark", dark: true, primary: '#21222d', secondary: '#282a37', textColor: '#f9f9f9' }, ("theme" in conf && "dark" in conf.theme ? Object.assign({}, conf.theme.dark) : {})), "f");
91
- }
92
- }
93
- _AppTheme_mode = new WeakMap(), _AppTheme_listen = new WeakMap(), _AppTheme_lightTheme = new WeakMap(), _AppTheme_darkTheme = new WeakMap();
94
-
95
- var _AppLang_mode, _AppLang_listen, _AppLang_lang;
96
- class AppLang {
97
- constructor(_conf) {
98
- _AppLang_mode.set(this, void 0);
99
- _AppLang_listen.set(this, void 0);
100
- _AppLang_lang.set(this, void 0);
101
- this.get = () => {
102
- let self = this;
103
- return __classPrivateFieldGet(self, _AppLang_lang, "f");
104
- };
105
- const conf = _conf || {};
106
- __classPrivateFieldSet(this, _AppLang_listen, "listen" in conf ? conf.listen : (mod) => { console.log(`Lang switched to ${mod}`); }, "f");
107
- __classPrivateFieldSet(this, _AppLang_mode, conf.mode || "en", "f");
108
- __classPrivateFieldSet(this, _AppLang_lang, Object.assign({
109
- //CORE
110
- tag: "en" }, ("lang" in conf ? Object.assign({}, conf.lang) : {})), "f");
111
- }
112
- }
113
- _AppLang_mode = new WeakMap(), _AppLang_listen = new WeakMap(), _AppLang_lang = new WeakMap();
114
-
115
- let isMounted = true;
116
- const STORE_KEY = `__zuzjs`;
117
- const STORE_FORM_KEY = `${STORE_KEY}forms`;
118
- const defaultState = {
119
- [`${STORE_KEY}base`]: {
120
- debug: true,
121
- loading: false,
122
- _tmp: Math.random()
123
- },
124
- [STORE_FORM_KEY]: {
125
- forms: {}
126
- }
127
- };
128
- const rootReducer = (state, action) => (Object.assign(Object.assign({}, state), action.payload));
129
- const AppProvider = ({ children, initialState = {}, theme = {}, lang = {} }) => {
130
- useEffect(() => {
131
- isMounted = true;
132
- return () => {
133
- isMounted = false;
134
- };
135
- }, []);
136
- const rootState = useMemo(() => (Object.assign(Object.assign(Object.assign({}, defaultState), initialState), { theme: new AppTheme({ theme }).get(), lang: new AppLang({ lang }).get() })), [initialState]);
137
- const [state, _dispatch] = useReducer(rootReducer, rootState);
138
- const dispatch = useCallback((args) => {
139
- if (isMounted) {
140
- _dispatch(Object.assign({}, args));
141
- }
142
- }, [_dispatch]);
143
- // const dispatch = useCallback((payload = {}, _key = 'base') => {
144
- // if(isMounted){
145
- // const key = STORE_DEFAUTLS.indexOf(`${STORE_KEY}${_key}`) > -1 ? `${STORE_KEY}${_key}` : _key;
146
- // const _state = { ...state[key] }
147
- // console.log('key', key)
148
- // console.log('state', _state)
149
- // _dispatch({
150
- // type: 'any',
151
- // payload: {
152
- // payload
153
- // }
154
- // })
155
- // }
156
- // }, [_dispatch]);
157
- const providedValue = useMemo(() => (Object.assign(Object.assign({}, state), { dispatch })), [state]);
158
- return jsx(AppContext.Provider, Object.assign({ value: providedValue }, { children: children }));
159
- };
160
- AppProvider.defaultProps = {
161
- theme: {},
162
- lang: {},
163
- initialState: {},
164
- };
165
- AppProvider.propTypes = {
166
- children: PropTypes.node.isRequired,
167
- initialState: PropTypes.instanceOf(Object),
168
- theme: PropTypes.instanceOf(Object),
169
- lang: PropTypes.instanceOf(Object)
170
- };
171
-
172
- const createSlice = ({ name, initialState, reducers }) => {
173
- // const _dynamiceReducers = {}
174
- // Object.keys(reducers).map(k => {
175
- // _dynamiceReducers[reducers[k].name] = [reducers[k].reducer, initialState]
176
- // })
177
- // const _keys = Object.keys(reducers);
178
- // const [reducer, state] = combineReducers(_dynamiceReducers);
179
- return {
180
- name,
181
- reducer: reducers,
182
- actions: reducers,
183
- state: initialState
184
- };
185
- };
186
- createSlice.defaultProps = {
187
- name: `app`,
188
- initialState: {},
189
- reducers: {}
190
- };
191
- createSlice.propTypes = {
192
- name: PropTypes.string.isRequired,
193
- initialState: PropTypes.instanceOf(Object).isRequired,
194
- reducers: PropTypes.instanceOf(Object).isRequired
195
- };
196
-
197
- const cssProps = {
198
- "ac": "align-content",
199
- "alignContent": "align-content",
200
- "aic": "aic",
201
- "ais": "ais",
202
- "aie": "aie",
203
- "nous": "nous",
204
- "nope": "nope",
205
- "ai": "align-items",
206
- "alignItems": "align-items",
207
- "ass": "ass",
208
- "asc": "asc",
209
- "ase": "ase",
210
- "alignSelf": "align-self",
211
- "all": "all",
212
- "animation": "animation",
213
- "animationDelay": "animation-delay",
214
- "animationDirection": "animation-direction",
215
- "animationDuration": "animation-duration",
216
- "animationFillMode": "animation-fill-mode",
217
- "animationIterationCount": "animation-iteration-count",
218
- "animationName": "animation-name",
219
- "animationPlayState": "animation-play-state",
220
- "animationTimingFunction": "animation-timing-function",
221
- "backfaceVisibility": "backface-visibility",
222
- "backgroundAttachment": "background-attachment",
223
- "backgroundBlendMode": "background-blend-mode",
224
- "backgroundClip": "background-clip",
225
- "bg": "background",
226
- "background": "background",
227
- "bgc": "background-color",
228
- "bgColor": "background-color",
229
- "backgroundColor": "background-color",
230
- "backgroundImage": "background-image",
231
- "backgroundOrigin": "background-origin",
232
- "backgroundPosition": "background-position",
233
- "backgroundRepeat": "background-repeat",
234
- "backgroundSize": "background-size",
235
- "border": "border",
236
- "borderBottom": "border-bottom",
237
- "borderBottomColor": "border-bottom-color",
238
- "borderBottomStyle": "border-bottom-style",
239
- "borderBottomWidth": "border-bottom-width",
240
- "borderCollapse": "border-collapse",
241
- "borderColor": "border-color",
242
- "borderImage": "border-image",
243
- "borderImageOutset": "border-image-outset",
244
- "borderImageRepeat": "border-image-repeat",
245
- "borderImageSlice": "border-image-slice",
246
- "borderImageSource": "border-image-source",
247
- "borderImageWidth": "border-image-width",
248
- "borderLeft": "border-left",
249
- "borderLeftColor": "border-left-color",
250
- "borderLeftStyle": "border-left-style",
251
- "borderLeftWidth": "border-left-width",
252
- //Radius
253
- "r": "border-radius",
254
- "br": "border-radius",
255
- "borderRadius": "border-radius",
256
- "brtl": "border-top-left-radius",
257
- "borderTopLeftRadius": "border-top-left-radius",
258
- "brtr": "border-top-right-radius",
259
- "borderTopRightRadius": "border-top-right-radius",
260
- "brbl": "border-bottom-left-radius",
261
- "borderBottomLeftRadius": "border-bottom-left-radius",
262
- "brbr": "border-bottom-right-radius",
263
- "borderBottomRightRadius": "border-bottom-right-radius",
264
- "borderRight": "border-right",
265
- "borderRightColor": "border-right-color",
266
- "borderRightStyle": "border-right-style",
267
- "borderRightWidth": "border-right-width",
268
- "borderSpacing": "border-spacing",
269
- "borderStyle": "border-style",
270
- "borderTop": "border-top",
271
- "borderTopColor": "border-top-color",
272
- "borderTopStyle": "border-top-style",
273
- "borderTopWidth": "border-top-width",
274
- "borderWidth": "border-width",
275
- "bottom": "bottom",
276
- "boxDecorationBreak": "box-decoration-break",
277
- "boxShadow": "box-shadow",
278
- "boxSizing": "box-sizing",
279
- "captionSide": "caption-side",
280
- "caretColor": "caret-color",
281
- "@charset": "@charset",
282
- "clear": "clear",
283
- "clip": "clip",
284
- "clipPath": "clip-path",
285
- "color": "color",
286
- "columnCount": "column-count",
287
- "columnFill": "column-fill",
288
- "columnGap": "column-gap",
289
- "colGap": "column-gap",
290
- "columnRule": "column-rule",
291
- "columnRuleColor": "column-rule-color",
292
- "columnRuleStyle": "column-rule-style",
293
- "columnRuleWidth": "column-rule-width",
294
- "columnSpan": "column-span",
295
- "columnWidth": "column-width",
296
- "colW": "column-width",
297
- "columns": "columns",
298
- "content": "content",
299
- "counterIncrement": "counter-increment",
300
- "counterReset": "counter-reset",
301
- "cursor": "cursor",
302
- "pointer": "pointer",
303
- "direction": "direction",
304
- "display": "display",
305
- "emptyCells": "empty-cells",
306
- "filter": "filter",
307
- "flex": "flex",
308
- "flexBasis": "flex-basis",
309
- "dir": "flex-direction",
310
- "flexDirection": "flex-direction",
311
- "flexFlow": "flex-flow",
312
- "flexGrow": "flex-grow",
313
- "flexShrink": "flex-shrink",
314
- "flexWrap": "flex-wrap",
315
- "float": "float",
316
- "font": "font",
317
- "fontFamily": "font-family",
318
- "fontKerning": "font-kerning",
319
- "size": "font-size",
320
- "fontSize": "font-size",
321
- "fontSizeAdjust": "font-size-adjust",
322
- "fontStretch": "font-stretch",
323
- "fontStyle": "font-style",
324
- "fontVariant": "font-variant",
325
- "bold": "bold",
326
- "fontWeight": "font-weight",
327
- "gap": "gap",
328
- "grid": "grid",
329
- "gridArea": "grid-area",
330
- "gridAutoColumns": "grid-auto-columns",
331
- "gridAutoFlow": "grid-auto-flow",
332
- "gridAutoRows": "grid-auto-rows",
333
- "gridColumn": "grid-column",
334
- "gridColumnEnd": "grid-column-end",
335
- "gridColumnGap": "grid-column-gap",
336
- "gridColumnStart": "grid-column-start",
337
- "gridGap": "grid-gap",
338
- "gridRow": "grid-row",
339
- "gridRowEnd": "grid-row-end",
340
- "gridRowGap": "grid-row-gap",
341
- "gridRowStart": "grid-row-start",
342
- "gridTemplate": "grid-template",
343
- "gridTemplateAreas": "grid-template-areas",
344
- "gridTemplateColumns": "grid-template-columns",
345
- "gridTemplateRows": "grid-template-rows",
346
- "hangingPunctuation": "hanging-punctuation",
347
- "hyphens": "hyphens",
348
- "isolation": "isolation",
349
- "jcc": "jcc",
350
- "jcs": "jcs",
351
- "jce": "jce",
352
- "jc": "justify-content",
353
- "justifyContent": "justify-content",
354
- "left": "left",
355
- "letterSpacing": "letter-spacing",
356
- "lineHeight": "line-height",
357
- "listStyle": "list-style",
358
- "listStyleImage": "list-style-image",
359
- "listStylePosition": "list-style-position",
360
- "listStyleType": "list-style-type",
361
- //Margin
362
- "m": "margin",
363
- "margin": "margin",
364
- "mb": "margin-bottom",
365
- "marginBottom": "margin-bottom",
366
- "ml": "margin-left",
367
- "marginLeft": "margin-left",
368
- "mr": "margin-right",
369
- "marginRight": "margin-right",
370
- "mt": "margin-top",
371
- "marginTop": "margin-top",
372
- //Height
373
- "h": "height",
374
- "height": "height",
375
- "minH": "min-height",
376
- "minHeight": "min-height",
377
- "maxH": "max-height",
378
- "maxHeight": "max-height",
379
- //Width
380
- "w": "width",
381
- "width": "width",
382
- "minW": "min-width",
383
- "minWidth": "min-width",
384
- "maxW": "max-width",
385
- "maxWidth": "max-width",
386
- "mixBlendMode": "mix-blend-mode",
387
- "objectFit": "object-fit",
388
- "objectPosition": "object-position",
389
- "opacity": "opacity",
390
- "order": "order",
391
- "outline": "outline",
392
- "outlineColor": "outline-color",
393
- "outlineOffset": "outline-offset",
394
- "outlineStyle": "outline-style",
395
- "outlineWidth": "outline-width",
396
- "overflow": "overflow",
397
- "overflowX": "overflow-x",
398
- "overflowY": "overflow-y",
399
- "p": "padding",
400
- "padding": "padding",
401
- "pb": "padding-bottom",
402
- "paddingBottom": "padding-bottom",
403
- "pl": "padding-left",
404
- "paddingLeft": "padding-left",
405
- "pr": "padding-right",
406
- "paddingRight": "padding-right",
407
- "pt": "padding-top",
408
- "paddingTop": "padding-top",
409
- "pageBreakAfter": "page-break-after",
410
- "pageBreakBefore": "page-break-before",
411
- "pageBreakInside": "page-break-inside",
412
- "perspective": "perspective",
413
- "perspectiveOrigin": "perspective-origin",
414
- "pointerEvents": "pointer-events",
415
- "rel": "rel",
416
- "abs": "abs",
417
- "fixed": "fixed",
418
- "sticky": "sticky",
419
- "pos": "position",
420
- "position": "position",
421
- "quotes": "quotes",
422
- "resize": "resize",
423
- "right": "right",
424
- "scrollBehavior": "scroll-behavior",
425
- "tabSize": "tab-size",
426
- "tableLayout": "table-layout",
427
- "align": "text-align",
428
- "textAlign": "text-align",
429
- "textAlignLast": "text-align-last",
430
- "tdh": "tdh",
431
- "td": "text-decoration",
432
- "textDecoration": "text-decoration",
433
- "textDecorationColor": "text-decoration-color",
434
- "textDecorationLine": "text-decoration-line",
435
- "textDecorationStyle": "text-decoration-style",
436
- "textIndent": "text-indent",
437
- "textJustify": "text-justify",
438
- "textOverflow": "text-overflow",
439
- "textShadow": "text-shadow",
440
- "textTransform": "text-transform",
441
- "top": "top",
442
- "transform": "transform",
443
- "transform(2D)": "transform(2D)",
444
- "transformOrigin(twoValue syntax)": "transform-origin(two-value syntax)",
445
- "transformStyle": "transform-style",
446
- "transition": "transition",
447
- "transitionDelay": "transition-delay",
448
- "transitionDuration": "transition-duration",
449
- "transitionProperty": "transition-property",
450
- "transitionTimingFunction": "transition-timing-function",
451
- "unicodeBidi": "unicode-bidi",
452
- "userSelect": "user-select",
453
- "verticalAlign": "vertical-align",
454
- "visibility": "visibility",
455
- "weight": "flex",
456
- "whiteSpace": "white-space",
457
- "ws": "white-space",
458
- "wordBreak": "word-break",
459
- "wordSpacing": "word-spacing",
460
- "wrap": "wrap",
461
- "textWrap": "textWrap",
462
- "wordWrap": "word-wrap",
463
- "writingMode": "writing-mode",
464
- "zIndex": "z-index",
465
- "backdropFilter": "backdrop-filter",
466
- "bgFilter": "backdrop-filter",
467
- //Custom
468
- "anim": "anim",
469
- "fill": "fill",
470
- "abc": "abc",
471
- "fb": "fb",
472
- "ph": "ph",
473
- "pv": "pv",
474
- "mv": "mv",
475
- "mh": "mh"
476
- };
477
- const cssPropsVals = {
478
- //Colors
479
- "primary": 'var(--primary-color)',
480
- "c": "center",
481
- //Flex Directions
482
- "cols": "column",
483
- "colsr": "column-reverse",
484
- "rows": "row",
485
- "rowsr": "row-reverse",
486
- //Positions
487
- "rel": "relative",
488
- "abs": "absolute",
489
- };
490
- const cssPropsDirect = {
491
- 'rel': 'position: relative;',
492
- 'fixed': 'position: fixed;',
493
- 'abs': 'position: absolute;',
494
- 'sticky': 'position: sticky;',
495
- 'flex': 'display: flex;',
496
- 'fwrap': 'flex-wrap: wrap;',
497
- 'aic': 'align-items: center;',
498
- 'ais': 'align-items: flex-start;',
499
- 'aie': 'align-items: flex-end;',
500
- 'ass': 'align-self: flex-start;',
501
- 'asc': 'align-self: center;',
502
- 'ase': 'align-self: flex-end;',
503
- 'jcc': 'justify-content: center;',
504
- 'jcs': 'justify-content: flex-start;',
505
- 'jce': 'justify-content: flex-end;',
506
- 'grid': 'display: grid;',
507
- 'fill': 'top: 0px;left: 0px;right: 0px;bottom: 0px;',
508
- 'abc': 'top: 50%;left: 50%;transform: translate(-50%, -50%);',
509
- 'block': 'display: block;',
510
- 'bold': "font-weight: bold;",
511
- 'wrap': "word-wrap: break-word;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;max-width: 99%;",
512
- 'textWrap': "word-wrap: break-word;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;max-width: 99%;",
513
- 'pointer': "cursor: pointer;",
514
- 'fb': 'font-family: var(--primary-font-bold);',
515
- 'ph': 'padding-left: __VALUE__;padding-right: __VALUE__;',
516
- 'pv': 'padding-bottom: __VALUE__;padding-top: __VALUE__;',
517
- 'mv': 'margin-bottom: __VALUE__;margin-top: __VALUE__;',
518
- 'mh': 'margin-left: __VALUE__;margin-right: __VALUE__;',
519
- 'anim': 'transition:all __VALUE__s linear 0s;',
520
- 'nous': 'user-select: none;',
521
- 'nope': 'pointer-events: none;',
522
- 'tdn': 'text-decoration: none;',
523
- };
524
- const cssPropsIgnore = [
525
- 'weight', `opacity`
526
- ];
527
- const _cssColors = [`white`, `black`, `gray`, `red`, `orange`, `yellow`, `green`, `teal`, `blue`, `cyan`, `purple`, `pink`, `linkedin`, `facebook`, `messenger`, `whatsapp`, `twitter`, `telegram`];
528
- const _cssColorsRange = [`50`, `100`, `200`, `300`, `400`, `500`, `600`, `700`, `800`, `900`];
529
- let cssColors = [];
530
- if (cssColors.length == 0) {
531
- _cssColors.map(c => {
532
- _cssColorsRange.map(r => cssColors.push(`${c}.${r}`));
533
- });
534
- }
535
-
536
- const useDispatch = (key) => {
537
- const state = useContext(AppContext);
538
- const dispatch = state['dispatch'];
539
- const prepareState = (prevState, nextState) => {
540
- const nextKeys = Object.keys(nextState);
541
- nextKeys.map(k => {
542
- if (prevState[k] !== nextState[k]) {
543
- prevState[k] = nextState[k];
544
- }
545
- });
546
- return Object.assign(Object.assign({}, prevState), nextState);
547
- };
548
- if (key) {
549
- return (payload = {}) => {
550
- dispatch({
551
- action: key,
552
- payload: {
553
- [key]: prepareState(state[key], payload)
554
- }
555
- });
556
- };
557
- }
558
- return dispatch;
559
- };
560
-
561
- const useStore = (callback, withFilter = true) => {
562
- // if(withInititalState){
563
- // return useContext(AppContext)
564
- // }
565
- let _state = useContext(AppContext);
566
- let state = withFilter ? {} : _state;
567
- if (withFilter) {
568
- const filters = ['defaultState', 'theme', 'dispatch', `${STORE_KEY}base`, `${STORE_KEY}forms`];
569
- Object.keys(_state).map(k => {
570
- if (filters.indexOf(k) == -1) {
571
- state[k] = _state[k];
572
- }
573
- });
574
- }
575
- if ("function" == typeof callback) {
576
- return callback(state);
577
- }
578
- return state;
579
- };
580
-
581
- const ADD_FORM = (name, fields, forms) => ({
582
- forms: Object.assign(Object.assign({}, forms), { [name]: Object.assign({ touched: false, loading: false }, fields) })
583
- });
584
- const UPDATE_FORM_FIELD = (formName, field, value, forms) => {
585
- if (forms[formName]) {
586
- let _forms = Object.assign({}, forms);
587
- _forms[formName][field] = value;
588
- return {
589
- forms: _forms
590
- };
591
- }
592
- return {};
593
- };
594
-
595
- !!document.documentElement.currentStyle;
596
- const Input = forwardRef((props, ref) => {
597
- const { as, accept, multiple, onChange, onKeyUp, onClick, onBlur, onFocus, readOnly, type, tag, placeholder, name, form, touched, onSubmit, value, defaultValue, fref, autoComplete, elastic, minRows, maxRows } = props;
598
- const dispatch = useDispatch(STORE_FORM_KEY);
599
- const { forms } = useStore(state => state[STORE_FORM_KEY], false);
600
- let Tag = tag || 'input';
601
- const El = Tag;
602
- const _ref = fref || useRef();
603
- const _defaultCSS = `width: 100%;border-radius: var(--radius-base);padding-left: 4px;padding-right: 4px;border-style: solid;border-width: 1px;border-color: var(--colors-gray-200);`;
604
- props.value !== undefined;
605
- useRef();
606
- useEffect(() => { }, []);
607
- return (jsx(ClassNames, { children: ({ css, cx }) => jsx(El, Object.assign({}, cleanProps(props), { type: type || `text`, placeholder: placeholder || undefined, autoComplete: autoComplete || undefined, name: name || nanoid(), multiple: type == 'file' ? multiple : undefined, accept: accept || `*`, className: `${as ? `${as} ` : ``}f ${cx(css `${_defaultCSS}${buildCSS(props)}&:hover {${buildCSS(props.hover || {})}} &:focus {${buildCSS(props.focus || {})}}`)}`, ref: _ref, value: value || undefined, defaultValue: defaultValue || ``, onKeyUp: (e) => {
608
- let k = e['keyCode'] || ['which'];
609
- if (form && onSubmit && El != 'textarea' && k == 13) {
610
- onSubmit(forms[form]);
611
- }
612
- else {
613
- if (onKeyUp)
614
- onKeyUp(e);
615
- }
616
- }, onChange: e => {
617
- let val = type == 'file' ?
618
- e.currentTarget.files
619
- : e.currentTarget.value;
620
- if (form)
621
- dispatch(dispatch(UPDATE_FORM_FIELD(form || 'orphan', name, val == "" ? null : val, forms)));
622
- // if(El == `textarea` && elastic) handleElastic()
623
- onChange && onChange(val == "" ? null : val);
624
- }, onClick: onClick ? onClick : () => { }, readOnly: readOnly || false, onBlur: e => {
625
- if (onBlur)
626
- onBlur(e);
627
- }, onFocus: e => {
628
- if (touched == false)
629
- dispatch(UPDATE_FORM_FIELD(form || 'orphan', `touched`, true, forms));
630
- if (onFocus)
631
- onFocus(e);
632
- } })) }));
633
- });
634
-
635
- const Select = forwardRef((props, ref) => {
636
- const { as, onChange, name, form, touched, options, defaultValue } = props;
637
- const _ref = useRef();
638
- const dispatch = useDispatch(STORE_FORM_KEY);
639
- const { forms } = useStore(state => state[STORE_FORM_KEY], false);
640
- const _defaultCSS = `width: 100%;border-radius: var(--radius-base);padding-left: 4px;padding-right: 4px;border-style: solid;border-width: 1px;border-color: var(--colors-gray-200);`;
641
- useEffect(() => {
642
- var _a;
643
- dispatch(dispatch(UPDATE_FORM_FIELD(form || 'orphan', name, defaultValue && defaultValue != null && defaultValue != "" && defaultValue != undefined ? defaultValue : ((_a = options[0]) === null || _a === void 0 ? void 0 : _a.value) || '-1', forms)));
644
- }, []);
645
- return (jsx(ClassNames, { children: ({ css, cx }) => jsx("select", Object.assign({ onChange: e => {
646
- let val = e.currentTarget.value;
647
- dispatch(dispatch(UPDATE_FORM_FIELD(form || 'orphan', name, val, forms)));
648
- onChange && onChange(val);
649
- }, onFocus: e => touched == false && dispatch(UPDATE_FORM_FIELD(form || 'orphan', `touched`, true, forms)), onBlur: e => {
650
- }, name: name || nanoid(), className: `${as ? as : ``} ${cx(css `${_defaultCSS}${buildCSS(props)}&:hover {${buildCSS(props.hover || {})}}`)}`, ref: _ref }, { children: options === null || options === void 0 ? void 0 : options.map(o => jsx("option", Object.assign({ value: o.value }, { children: o.label }), `select-${name}-option-${o.value}`)) })) }));
651
- });
652
-
653
- const useTheme = (mod = 'auto') => {
654
- const state = useContext(AppContext);
655
- return state['theme'] || {};
656
- };
657
-
658
- const removeBlankArrayElements = (a) => a.filter((x) => x);
659
- const stringToArray = (x) => (Array.isArray(x) ? x : [x]);
660
- const cache = {};
661
- // sequential map.find for promises
662
- const promiseFind = (arr, promiseFactory) => {
663
- let done = false;
664
- return new Promise((resolve, reject) => {
665
- const queueNext = (src) => {
666
- return promiseFactory(src).then(() => {
667
- done = true;
668
- resolve(src);
669
- });
670
- };
671
- arr
672
- .reduce((p, src) => {
673
- // ensure we aren't done before enqueuing the next source
674
- return p.catch(() => {
675
- if (!done)
676
- return queueNext(src);
677
- });
678
- }, queueNext(arr.shift()))
679
- .catch(reject);
680
- });
681
- };
682
- const useImage = ({ srcList, imgPromise = imgPromiseFactory({ decode: true }), useSuspense = true, }) => {
683
- const [, setIsSettled] = useState(false);
684
- const sourceList = removeBlankArrayElements(stringToArray(srcList));
685
- const sourceKey = sourceList.join('');
686
- if (!cache[sourceKey]) {
687
- // create promise to loop through sources and try to load one
688
- cache[sourceKey] = {
689
- promise: promiseFind(sourceList, imgPromise),
690
- cache: 'pending',
691
- error: null,
692
- };
693
- }
694
- // when promise resolves/reject, update cache & state
695
- if (cache[sourceKey].cache === 'resolved') {
696
- return { src: cache[sourceKey].src, isLoading: false, error: null };
697
- }
698
- if (cache[sourceKey].cache === 'rejected') {
699
- if (useSuspense)
700
- throw cache[sourceKey].error;
701
- return { isLoading: false, error: cache[sourceKey].error, src: undefined };
702
- }
703
- cache[sourceKey].promise
704
- // if a source was found, update cache
705
- // when not using suspense, update state to force a rerender
706
- .then((src) => {
707
- cache[sourceKey] = Object.assign(Object.assign({}, cache[sourceKey]), { cache: 'resolved', src });
708
- if (!useSuspense)
709
- setIsSettled(sourceKey);
710
- })
711
- // if no source was found, or if another error occurred, update cache
712
- // when not using suspense, update state to force a rerender
713
- .catch((error) => {
714
- cache[sourceKey] = Object.assign(Object.assign({}, cache[sourceKey]), { cache: 'rejected', error });
715
- if (!useSuspense)
716
- setIsSettled(sourceKey);
717
- });
718
- // cache[sourceKey].cache === 'pending')
719
- if (useSuspense)
720
- throw cache[sourceKey].promise;
721
- return { isLoading: true, src: undefined, error: null };
722
- };
723
-
724
- /** External Dependencies */
725
- const useResizeObserver = (onResized) => {
726
- const onResize = onResized ? onResized : () => { };
727
- const onResizeCallback = useRef(onResize);
728
- const resizeObserver = useRef();
729
- const observerCallback = useCallback((entries) => {
730
- entries.forEach((entry) => {
731
- if (entry.contentRect) {
732
- const { width, height } = entry.contentRect;
733
- onResizeCallback.current({
734
- entry,
735
- width,
736
- height,
737
- });
738
- }
739
- });
740
- }, []);
741
- const updateOnResizeCallback = useCallback((newOnResizeCallback) => {
742
- onResizeCallback.current = newOnResizeCallback;
743
- }, []);
744
- const initObserver = useCallback(() => {
745
- if (!resizeObserver.current) {
746
- resizeObserver.current = new ResizeObserver(observerCallback);
747
- }
748
- }, []);
749
- const observeElement = useCallback((element, newOnResizeCallback) => {
750
- if (element) {
751
- if (!resizeObserver.current) {
752
- initObserver();
753
- }
754
- resizeObserver.current.observe(element);
755
- if (newOnResizeCallback) {
756
- onResizeCallback.current = newOnResizeCallback;
757
- }
758
- }
759
- }, []);
760
- const unobserveElement = useCallback((element, newOnResizeCallback) => {
761
- if (resizeObserver.current && element) {
762
- resizeObserver.current.unobserve(element);
763
- if (newOnResizeCallback) {
764
- onResizeCallback.current = newOnResizeCallback;
765
- }
766
- }
767
- }, []);
768
- const removeObserver = useCallback(() => {
769
- if (resizeObserver.current) {
770
- resizeObserver.current.disconnect();
771
- }
772
- }, []);
773
- useEffect(() => {
774
- initObserver();
775
- return removeObserver;
776
- }, []);
777
- return useMemo(() => [observeElement, unobserveElement, updateOnResizeCallback], []);
778
- };
779
-
780
- const useChooseEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;
781
-
782
- const EMPTY_BREAKPOINT = {
783
- breakpoint: undefined,
784
- minWidth: undefined,
785
- maxWidth: undefined,
786
- };
787
- const useDevice = (config, defaultBreakpoint, hydrateInitial = true) => {
788
- const buildQueries = (breakpoints) => {
789
- const sorted = Object.keys(breakpoints).sort((a, b) => breakpoints[b] - breakpoints[a]);
790
- return sorted.map((breakpoint, index) => {
791
- let query = '';
792
- const minWidth = breakpoints[breakpoint];
793
- const nextBreakpoint = sorted[index - 1];
794
- const maxWidth = nextBreakpoint ? breakpoints[nextBreakpoint] : null;
795
- if (minWidth >= 0) {
796
- query = `(min-width: ${minWidth}px)`;
797
- }
798
- if (maxWidth !== null) {
799
- if (query) {
800
- query += ' and ';
801
- }
802
- query += `(max-width: ${maxWidth - 1}px)`;
803
- }
804
- const mediaQuery = {
805
- breakpoint,
806
- maxWidth: maxWidth ? maxWidth - 1 : null,
807
- minWidth,
808
- query,
809
- };
810
- return mediaQuery;
811
- });
812
- };
813
- /** Memoize list of calculated media queries from config */
814
- const mediaQueries = useMemo(() => buildQueries(config), [config]);
815
- /** Get initial breakpoint value */
816
- const [currentBreakpoint, setCurrentBreakpoint] = useState(() => {
817
- /** Loop through all media queries */
818
- for (let _a of mediaQueries) {
819
- const { query } = _a, breakpoint = __rest(_a, ["query"]);
820
- /**
821
- * If we're in the browser and there's no default value,
822
- * try to match actual breakpoint. If the default value
823
- * should not be hydrated, use the actual breakpoint.
824
- */
825
- if (typeof window !== 'undefined' &&
826
- !(defaultBreakpoint && hydrateInitial)) {
827
- const mediaQuery = window.matchMedia(query);
828
- if (mediaQuery.matches) {
829
- return breakpoint;
830
- }
831
- }
832
- else if (breakpoint.breakpoint === defaultBreakpoint) {
833
- /** Otherwise, try to match default value */
834
- return breakpoint;
835
- }
836
- }
837
- return EMPTY_BREAKPOINT;
838
- });
839
- /** If there's a match, update the current breakpoint */
840
- const updateBreakpoint = useCallback(({ matches }, breakpoint) => {
841
- if (matches) {
842
- setCurrentBreakpoint(breakpoint);
843
- }
844
- }, []);
845
- /** On changes to mediaQueries, subscribe to changes using window.matchMedia */
846
- useChooseEffect(() => {
847
- const unsubscribers = mediaQueries.map((_a) => {
848
- var { query } = _a, breakpoint = __rest(_a, ["query"]);
849
- const list = window.matchMedia(query);
850
- updateBreakpoint(list, breakpoint);
851
- const handleChange = (event) => {
852
- updateBreakpoint(event, breakpoint);
853
- };
854
- const supportsNewEventListeners = 'addEventListener' in list && 'removeEventListener' in list;
855
- if (supportsNewEventListeners) {
856
- list.addEventListener('change', handleChange);
857
- }
858
- else {
859
- list.addListener(handleChange);
860
- }
861
- /** Map the unsubscribers array to a list of unsubscriber methods */
862
- return () => {
863
- if (supportsNewEventListeners) {
864
- list.removeEventListener('change', handleChange);
865
- }
866
- else {
867
- list.removeListener(handleChange);
868
- }
869
- };
870
- });
871
- /** Return a function that when called, will call all unsubscribers */
872
- return () => unsubscribers.forEach((unsubscriber) => unsubscriber());
873
- }, [mediaQueries, updateBreakpoint]);
874
- /** Print a nice debug value for React Devtools */
875
- useDebugValue(currentBreakpoint, (c) => typeof c.breakpoint === 'string'
876
- ? `${c.breakpoint} (${c.minWidth} ≤ x${c.maxWidth ? ` < ${c.maxWidth + 1}` : ''})`
877
- : '');
878
- return currentBreakpoint;
879
- };
880
-
881
- var _Toaster_container, _Toaster_startTop, _Toaster_tout, _Toaster_defaultTimeLeft, _Toaster_root;
882
- class Toaster {
883
- constructor(config) {
884
- _Toaster_container.set(this, void 0);
885
- _Toaster_startTop.set(this, void 0);
886
- _Toaster_tout.set(this, void 0);
887
- _Toaster_defaultTimeLeft.set(this, void 0);
888
- _Toaster_root.set(this, void 0);
889
- this.show = (message, duration) => {
890
- let self = this;
891
- self.toast({
892
- message: message,
893
- duration: duration
894
- });
895
- };
896
- __classPrivateFieldSet(this, _Toaster_startTop, 20, "f");
897
- __classPrivateFieldSet(this, _Toaster_defaultTimeLeft, 4, "f");
898
- const rootID = (config === null || config === void 0 ? void 0 : config.root) || `toast-container`;
899
- __classPrivateFieldSet(this, _Toaster_root, rootID, "f");
900
- if (window.document.querySelector(`#${rootID}`))
901
- return;
902
- var root = window.document.createElement('div');
903
- root.id = rootID;
904
- window.document.body.appendChild(root);
905
- __classPrivateFieldSet(this, _Toaster_container, window.document.querySelector(`#${rootID}`), "f");
906
- }
907
- dismiss(ID) {
908
- let self = this;
909
- __classPrivateFieldGet(self, _Toaster_tout, "f") && clearTimeout(__classPrivateFieldGet(self, _Toaster_tout, "f"));
910
- setTimeout(() => {
911
- let tost = document.querySelector(`#${ID}`);
912
- tost && tost.classList.remove("visible");
913
- // tost && tost.classList.add("hidden");
914
- setTimeout(() => {
915
- try {
916
- document.getElementById(ID).parentNode.removeChild(document.getElementById(ID));
917
- }
918
- catch (e) { }
919
- self.arrangeToasts();
920
- }, 200);
921
- }, 200);
922
- }
923
- toast(config) {
924
- var self = this;
925
- var ID = 'toast-' + nanoid(), toast = window.document.createElement('div'); window.document.createElement('div');
926
- toast.id = ID;
927
- toast.style.backgroundColor = `#111`;
928
- toast.style.color = `#fff`;
929
- toast.style.transform = `translate(-50%, -300px) scale(0.5)`;
930
- toast.style.position = `fixed`;
931
- toast.style.padding = `6px 12px`;
932
- toast.style.fontSize = `14px`;
933
- toast.style.left = `50%`;
934
- toast.style.maxWidth = `95%`;
935
- toast.style.zIndex = `2147483647`;
936
- toast.classList.add('zuz-toast');
937
- toast.classList.add('fixed');
938
- toast.classList.add('f');
939
- toast.innerHTML = config.message || `You haven't passed "message" in this toast`;
940
- (__classPrivateFieldGet(self, _Toaster_container, "f") || window.document.querySelector(`#${__classPrivateFieldGet(self, _Toaster_root, "f")}`)).appendChild(toast);
941
- self.arrangeToasts()
942
- .then(() => {
943
- setTimeout(() => {
944
- let tost = document.querySelector("#" + ID);
945
- tost.classList.add("showing");
946
- setTimeout(() => self.dismiss(ID), ((config === null || config === void 0 ? void 0 : config.duration) == undefined ? __classPrivateFieldGet(self, _Toaster_defaultTimeLeft, "f") : (config === null || config === void 0 ? void 0 : config.duration) == -1 ? 86400 : config === null || config === void 0 ? void 0 : config.duration) * 1000);
947
- setTimeout(() => {
948
- let tost = document.querySelector("#" + ID);
949
- tost.classList.remove("showing");
950
- tost.classList.add("visible");
951
- }, 200);
952
- }, 10);
953
- });
954
- }
955
- arrangeToasts() {
956
- var self = this, top = __classPrivateFieldGet(self, _Toaster_startTop, "f");
957
- return new Promise((resolve, reject) => {
958
- var toasts = document.querySelectorAll(".zuz-toast"), i = toasts.length;
959
- while (i--) {
960
- toasts[i]['style'].top = `${top}px`;
961
- top += parseInt(getComputedStyle(toasts[i]).height.replace('px', '')) + 6;
962
- }
963
- resolve(null);
964
- });
965
- }
966
- }
967
- _Toaster_container = new WeakMap(), _Toaster_startTop = new WeakMap(), _Toaster_tout = new WeakMap(), _Toaster_defaultTimeLeft = new WeakMap(), _Toaster_root = new WeakMap();
968
-
969
- const useToast = () => {
970
- const toaster = useMemo(() => new Toaster(), []);
971
- return toaster;
972
- };
973
-
974
- const useLang = (mod = 'en') => {
975
- const state = useContext(AppContext);
976
- return state['lang'] || {};
977
- };
978
-
979
- const Box = forwardRef((props, ref) => {
980
- const _noClick = () => { };
981
- // console.log(props)
982
- return (jsx(ClassNames, { children: ({ css, cx }) => jsx("div", Object.assign({}, cleanProps(props), { title: props.title || undefined, id: props.id || undefined, onDoubleClick: props.onDoubleClick || undefined, onClick: props.onClick || _noClick, className: `${props.as ? `${props.as} ` : ``}${cx(css `${buildCSS(props)} &:hover {${buildCSS(props.hover || {})}} &:active {${buildCSS(props.active || {})}}`)}`, ref: props.bref || ref }, { children: props.html ? jsx("span", { dangerouslySetInnerHTML: { __html: props.html } }) : props.children })) }));
983
- });
984
-
985
- const Menu = ({ ID, hide, e, items, width }) => {
986
- const nodeRef = useRef(null);
987
- const [p, setP] = useState(getMousePosition(e));
988
- const [visible, setVisible] = useState(false);
989
- const checkBoundaries = (x, y) => {
990
- if (nodeRef.current) {
991
- const { innerWidth, innerHeight } = window;
992
- const { offsetWidth, offsetHeight } = nodeRef.current;
993
- if (x + offsetWidth > innerWidth)
994
- x -= offsetWidth; //x + offsetWidth - innerWidth;
995
- if (y + offsetHeight > innerHeight)
996
- y -= offsetHeight;
997
- }
998
- setP({ x, y });
999
- setVisible(true);
1000
- };
1001
- useEffect(() => {
1002
- checkBoundaries(p.x, p.y);
1003
- }, [e]);
1004
- return (jsx(Box, Object.assign({ bref: nodeRef, flex: true, dir: `cols`, fixed: true, top: p.y, left: p.x, w: width || 220, opacity: visible ? 1 : 0, as: `zuz-contextmenu ${ID}` }, { children: items.map((m, i) => m.id == `line` ? jsx(Box, { as: `line` }, `line-${i}-${m.id}`) : jsx("button", Object.assign({ onClick: ev => {
1005
- if (m.onClick) {
1006
- m.onClick(ev, m);
1007
- }
1008
- else {
1009
- console.log(`No onClick eventFound`);
1010
- }
1011
- hide();
1012
- } }, { children: m.label }), `cm-${i}-${m.id}`)) })));
1013
- };
1014
- const useContextMenu = (contextID, contextWidth, contextToken = `____uchides`) => {
1015
- const ID = `contextmenu-${contextID}`;
1016
- useState(false);
1017
- const [root, setRoot] = useState(null);
1018
- const el = (e) => window.document.createElement(e);
1019
- const createRoot = () => {
1020
- if (!window.document.querySelector(`#${ID}`)) {
1021
- let div = el(`div`);
1022
- div.id = ID;
1023
- window.document.body.appendChild(div);
1024
- }
1025
- };
1026
- const hideAll = () => {
1027
- if (window[contextToken]) {
1028
- window[contextToken].map((h) => h['ID'] != ID && h['fnc']());
1029
- }
1030
- };
1031
- const _hide = () => {
1032
- try {
1033
- root === null || root === void 0 ? void 0 : root.unmount();
1034
- document.querySelector(`#${ID}`).parentNode.removeChild(document.querySelector(`#${ID}`));
1035
- setRoot(null);
1036
- }
1037
- catch (e) { }
1038
- };
1039
- const hide = () => {
1040
- _hide();
1041
- hideAll();
1042
- };
1043
- const show = (e, items) => {
1044
- e.preventDefault();
1045
- e.stopPropagation();
1046
- hideAll();
1047
- root.render(jsx(Menu, { e: e, width: contextWidth || 220, items: items, ID: ID, hide: hide }));
1048
- };
1049
- useEffect(() => {
1050
- createRoot();
1051
- if (!root)
1052
- setRoot(ReactDOM.createRoot(document.getElementById(ID)));
1053
- }, [root]);
1054
- useEffect(() => {
1055
- if (contextToken in window == false) {
1056
- window[contextToken] = [];
1057
- }
1058
- if (window[contextToken].findIndex(x => x.ID == ID) == -1) {
1059
- window[contextToken].push({ ID: ID, fnc: _hide });
1060
- if (window[contextToken].length > document.querySelectorAll('div[id^="contextmenu-"]').length) {
1061
- window[contextToken].shift();
1062
- }
1063
- }
1064
- }, []);
1065
- return {
1066
- show,
1067
- hide,
1068
- hideAll
1069
- };
1070
- };
1071
-
1072
- const useRender = (isMounted, delay) => {
1073
- const [canRender, setCanRender] = useState(false);
1074
- // console.log(
1075
- // `isMounted:`, isMounted,
1076
- // `canRender:`, canRender,
1077
- // )
1078
- useEffect(() => {
1079
- let outID;
1080
- if (isMounted && !canRender) {
1081
- setCanRender(true);
1082
- }
1083
- else if (isMounted && canRender) {
1084
- outID = setTimeout(() => setCanRender(false), delay * 1000);
1085
- }
1086
- return () => clearTimeout(outID);
1087
- }, [isMounted, delay]);
1088
- return canRender;
1089
- };
1090
-
1091
- const Button = forwardRef((props, ref) => {
1092
- const { forms } = useStore(state => state[STORE_FORM_KEY], false);
1093
- if (props.html) {
1094
- ({ __html: props.html });
1095
- }
1096
- return (jsx(ClassNames, { children: ({ css, cx }) => {
1097
- return (jsx("button", Object.assign({}, cleanProps(props), { title: "title" in props ? props.title : undefined, type: props.type, className: `button${props.as ? ` ${props.as}` : ``} ${cx(css `
1098
- padding: 5px 10px;
1099
- border-radius: 2px;
1100
- ${buildCSS(props)} &:hover {${buildCSS(props.hover || {})}} &:active {${buildCSS(props.active || {})}}`)}`, ref: ref, onDoubleClick: props.onDoubleClick || undefined, onClick: e => {
1101
- if (props.form && props.type && props.type == 'submit') {
1102
- props.onSubmit(forms[props.form]);
1103
- }
1104
- else {
1105
- props.onClick ? props.onClick(e) : () => console.warn('onClick Missing');
1106
- }
1107
- }, disabled: props.disabled || false }, { children: props.html ? jsx("span", { dangerouslySetInnerHTML: { __html: props.html } }) : props.children })));
1108
- } }));
1109
- });
1110
-
1111
- const patterns = {
1112
- route: [/^.*\/src\/pages\/|\.(jsx|tsx)$/g, ''],
1113
- splat: [/\[\.{3}\w+\]/g, '*'],
1114
- param: [/\[([^\]]+)\]/g, ':$1'],
1115
- slash: [/^index$|\./g, '/'],
1116
- optional: [/^-(:?[\w-]+)/, '$1?'],
1117
- };
1118
- const generatePreservedRoutes = (files) => {
1119
- return Object.keys(files).reduce((routes, key) => {
1120
- const path = key.replace(...patterns.route);
1121
- return Object.assign(Object.assign({}, routes), { [path]: files[key] });
1122
- }, {});
1123
- };
1124
- const generateRegularRoutes = (files, buildRoute) => {
1125
- const filteredRoutes = Object.keys(files).filter((key) => !key.includes('/_') || /_layout\.(jsx|tsx)$/.test(key));
1126
- return filteredRoutes.reduce((routes, key) => {
1127
- const module = files[key];
1128
- const route = Object.assign({ id: key.replace(...patterns.route) }, buildRoute(module, key));
1129
- const segments = key
1130
- .replace(...patterns.route)
1131
- .replace(...patterns.splat)
1132
- .replace(...patterns.param)
1133
- .split('/')
1134
- .filter(Boolean);
1135
- segments.reduce((parent, segment, index) => {
1136
- var _a, _b;
1137
- const path = segment.replace(...patterns.slash).replace(...patterns.optional);
1138
- const root = index === 0;
1139
- const leaf = index === segments.length - 1 && segments.length > 1;
1140
- const node = !root && !leaf;
1141
- const layout = segment === '_layout';
1142
- const group = /\(\w+\)/.test(path);
1143
- const insert = /^\w|\//.test(path) ? 'unshift' : 'push';
1144
- if (root) {
1145
- const last = segments.length === 1;
1146
- if (last) {
1147
- routes.push(Object.assign({ path }, route));
1148
- return parent;
1149
- }
1150
- }
1151
- if (root || node) {
1152
- const current = root ? routes : parent.children;
1153
- const found = current === null || current === void 0 ? void 0 : current.find((route) => { var _a, _b; return route.path === path || ((_b = (_a = route.id) === null || _a === void 0 ? void 0 : _a.split('@')) === null || _b === void 0 ? void 0 : _b[0]) === path; });
1154
- const props = group ? ((route === null || route === void 0 ? void 0 : route.component) ? { id: path, path: '/' } : { id: path }) : { path };
1155
- if (found)
1156
- (_a = found.children) !== null && _a !== void 0 ? _a : (found.children = []);
1157
- else
1158
- current === null || current === void 0 ? void 0 : current[insert](Object.assign(Object.assign({}, props), { children: [] }));
1159
- return found || (current === null || current === void 0 ? void 0 : current[insert === 'unshift' ? 0 : current.length - 1]);
1160
- }
1161
- if (layout) {
1162
- return Object.assign(parent, Object.assign(Object.assign({}, route), { id: `${parent.id || parent.path}@${route.id}` }));
1163
- }
1164
- if (leaf) {
1165
- (_b = parent === null || parent === void 0 ? void 0 : parent.children) === null || _b === void 0 ? void 0 : _b[insert]((route === null || route === void 0 ? void 0 : route.index) ? route : Object.assign({ path }, route));
1166
- }
1167
- return parent;
1168
- }, {});
1169
- return routes;
1170
- }, []);
1171
- };
1172
- const generateModalRoutes = (files) => {
1173
- return Object.keys(files).reduce((modals, key) => {
1174
- var _a;
1175
- const path = key
1176
- .replace(...patterns.route)
1177
- .replace(/\+|\(\w+\)\//g, '')
1178
- .replace(/(\/)?index/g, '')
1179
- .replace(/\./g, '/');
1180
- return Object.assign(Object.assign({}, modals), { [`/${path}`]: (_a = files[key]) === null || _a === void 0 ? void 0 : _a.default });
1181
- }, {});
1182
- };
1183
-
1184
- const makeCSSValue = (k, v, o) => {
1185
- let ignore = cssPropsIgnore.indexOf(o) == -1;
1186
- if (k in cssPropsDirect && ignore == true) {
1187
- // return cssPropsDirect[k];
1188
- return cssPropsDirect[k].indexOf(`__VALUE__`) > -1 ?
1189
- cssPropsDirect[k].replaceAll(`__VALUE__`, `${v}${"number" == typeof v ? `px` : ``}`)
1190
- : cssPropsDirect[k];
1191
- }
1192
- let unit = "number" == typeof v && ignore ? `px` : ``;
1193
- if (cssColors.indexOf(v) > -1) {
1194
- v = `var(--colors-${v.replaceAll(`.`, `-`)})`;
1195
- unit = ``;
1196
- }
1197
- else if (v in cssPropsVals) {
1198
- v = cssPropsVals[v];
1199
- }
1200
- return `${k}:${v}${unit};`;
1201
- };
1202
- const cleanProps = (props) => {
1203
- let _props = Object.assign({}, props);
1204
- Object.keys(_props).map(k => {
1205
- if (k in cssProps) {
1206
- delete _props[k];
1207
- }
1208
- });
1209
- let _extras = [`as`, `hover`, `bref`, `tag`];
1210
- _extras.map(x => x in _props && delete _props[x]);
1211
- return _props;
1212
- };
1213
- const buildCSS = (props) => {
1214
- let css = ``;
1215
- Object.keys(props).map(k => {
1216
- css += k in cssProps ? makeCSSValue(cssProps[k], props[k], k) : '';
1217
- });
1218
- return css;
1219
- };
1220
- const setCSSVar = (key, val) => {
1221
- document.documentElement.style.setProperty(`--${key}`, val);
1222
- };
1223
- const isUrl = (u) => {
1224
- let url;
1225
- try {
1226
- url = new URL(u);
1227
- }
1228
- catch (_) {
1229
- return false;
1230
- }
1231
- return url.protocol === 'http:' || url.protocol === 'https:';
1232
- };
1233
- const isEmail = (e) => {
1234
- let reg = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
1235
- return reg.test(e);
1236
- };
1237
- const isIPv4 = (ipaddress) => {
1238
- return /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(ipaddress);
1239
- };
1240
- const randstr = function (len) {
1241
- var text = "";
1242
- var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
1243
- len = len || 10;
1244
- for (var i = 0; i < len; i++) {
1245
- text += possible.charAt(Math.floor(Math.random() * possible.length));
1246
- }
1247
- return text;
1248
- };
1249
- const setCookie = (key, value, expiry, host) => Cookies.set(key, value, { expires: expiry || 7, domain: host || window.location.host });
1250
- const getCookie = (key) => Cookies.get(key) || null;
1251
- const removeCookie = (key) => Cookies.remove(key);
1252
- const buildFormData = (data) => {
1253
- var formData = new FormData();
1254
- var _data = Cookies.get();
1255
- Object.keys(_data).map(k => formData.append(k, _data[k]));
1256
- Object.keys(data).filter(x => x != 'files').map(k => formData.append(k, data[k]));
1257
- if ('files' in data)
1258
- [data['files']].map((f) => formData.append('files[]', f));
1259
- return formData;
1260
- };
1261
- const grab = async (uri, data, timeout = 60, fd = null, progress, bearer = `__ha`) => {
1262
- var Bearer = getCookie(bearer) || `${randstr(8)}^${randstr(8)}`;
1263
- window['__grabToken'] = axios.CancelToken.source();
1264
- if (fd) {
1265
- return new Promise((resolve, reject) => {
1266
- axios({
1267
- method: "post",
1268
- url: uri,
1269
- data: buildFormData(data),
1270
- timeout: 1000 * timeout,
1271
- cancelToken: window['__grabToken'].token,
1272
- headers: {
1273
- 'Content-Type': 'multipart/form-data',
1274
- 'Authorization': `Bearer ${Bearer}`
1275
- },
1276
- onUploadProgress: ev => {
1277
- //TODO: Add progress
1278
- // if(progress) progress(ev.)
1279
- }
1280
- })
1281
- .then(resp => {
1282
- if (resp.data && "kind" in resp.data) {
1283
- resolve(resp.data);
1284
- }
1285
- else {
1286
- reject(resp.data);
1287
- }
1288
- })
1289
- .catch(err => reject(err));
1290
- });
1291
- }
1292
- return new Promise((resolve, reject) => {
1293
- axios.post(uri, Object.assign(Object.assign(Object.assign({}, Cookies.get()), data), { __ustmp: new Date().getTime() / 1000 }), {
1294
- timeout: 1000 * timeout,
1295
- headers: {
1296
- 'Content-Type': 'application/json',
1297
- 'Authorization': `Bearer ${Bearer}`
1298
- },
1299
- cancelToken: window['__grabToken'].token
1300
- })
1301
- .then(resp => {
1302
- if (resp.data && "kind" in resp.data) {
1303
- resolve(resp.data);
1304
- }
1305
- else {
1306
- reject(resp.data);
1307
- }
1308
- })
1309
- .catch(err => reject(err));
1310
- });
1311
- };
1312
- const el = (e) => document.querySelector(e);
1313
- const byName = (e) => document.querySelector(`*[name="${e}"]`);
1314
- const byId = (e) => document.getElementById(e);
1315
- const addProps = (children, prop) => {
1316
- let form = {};
1317
- let allowedFields = [Input, Select, Button];
1318
- let child = Children.deepMap(children, c => {
1319
- if (allowedFields.indexOf(c['type']) > -1 && c['props'] && !form[c['props'].name]) {
1320
- form[c['props'].name] = c['props'].value || null;
1321
- }
1322
- let Clone = cloneElement(c, prop);
1323
- return Clone;
1324
- });
1325
- return {
1326
- children: child,
1327
- fields: form
1328
- };
1329
- };
1330
- const ucfirst = (str) => {
1331
- return str.charAt(0).toUpperCase() + str.slice(1);
1332
- };
1333
- const filterStyleProps = (props) => {
1334
- const pks = Object.keys(props);
1335
- const css = Object.keys(cssProps);
1336
- let filter = {};
1337
- css.filter(x => pks.includes(x));
1338
- // .map(k => filter[k] = props[k].toString());
1339
- return filter;
1340
- // const allowed = Object.keys(props);
1341
- // let allowed = Object.keys(cssProps);
1342
- // return Object.keys(props)
1343
- // .filter( k => allowed.includes(k))
1344
- // .reduce( (o, k) => {
1345
- // // console.log(o)
1346
- // console.log(k, props[k])
1347
- // // o[k] = props[k].toString();
1348
- // // return o;
1349
- // })
1350
- // return [props].filter( row => (
1351
- // Object.keys(row)
1352
- // .map(key => css.includes(key))
1353
- // ));
1354
- };
1355
- const filterHTMLProps = (props) => {
1356
- const pks = Object.keys(props);
1357
- const css = Object.keys(cssProps);
1358
- let filter = {};
1359
- pks.filter(x => {
1360
- if (x != `for` && !css.includes(x)) {
1361
- filter[x] = props[x];
1362
- }
1363
- });
1364
- return filter;
1365
- };
1366
- const uuid = (len = 21) => nanoid(len);
1367
- const addScript = (src, callback) => {
1368
- var s = document.createElement('script');
1369
- s.setAttribute('src', src);
1370
- s.addEventListener('load', callback, false);
1371
- document.body.appendChild(s);
1372
- };
1373
- const shuffleArray = array => {
1374
- for (let i = array.length - 1; i > 0; i--) {
1375
- const j = Math.floor(Math.random() * (i + 1));
1376
- [array[i], array[j]] = [array[j], array[i]];
1377
- }
1378
- return array;
1379
- };
1380
- const getUriParams = () => {
1381
- var search = location.search.substring(1);
1382
- if (search == '')
1383
- return JSON.parse('{}');
1384
- var xny = {};
1385
- if ("URLSearchParams" in window) {
1386
- var items = new URLSearchParams(search);
1387
- for (const [k, v] of items) {
1388
- xny[k] = v || ``;
1389
- }
1390
- }
1391
- else {
1392
- try {
1393
- xny = JSON.parse('{"' + decodeURI(search).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g, '":"') + '"}');
1394
- }
1395
- catch (e) {
1396
- xny = {};
1397
- }
1398
- }
1399
- return xny;
1400
- };
1401
- const rgb2hex = rgb => `#${rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/).slice(1).map(n => parseInt(n, 10).toString(16).padStart(2, '0')).join('')}`;
1402
- const getHostname = url => {
1403
- if (window.URL) {
1404
- let u = new window.URL(url);
1405
- return u.hostname;
1406
- }
1407
- else {
1408
- var a = document.createElement(`a`);
1409
- a.href = url;
1410
- return a.hostname.replace("www.", "");
1411
- }
1412
- };
1413
- const imgPromiseFactory = ({ decode = true, crossOrigin = '' }) => (src) => {
1414
- return new Promise((resolve, reject) => {
1415
- const i = new Image();
1416
- if (crossOrigin)
1417
- i.crossOrigin = crossOrigin;
1418
- i.onload = () => {
1419
- decode && i.decode ? i.decode().then(resolve).catch(reject) : resolve();
1420
- };
1421
- i.onerror = reject;
1422
- i.src = src;
1423
- });
1424
- };
1425
- const parseFilename = nm => {
1426
- var re = /(?:\.([^.]+))?$/;
1427
- return {
1428
- name: nm.split('.').slice(0, -1).join('.'),
1429
- ext: re.exec(nm)[1]
1430
- };
1431
- };
1432
- const camelCase = str => str.replace(":", "-").replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); });
1433
- const getMousePosition = e => {
1434
- const pos = {
1435
- x: e.clientX,
1436
- y: e.clientY,
1437
- };
1438
- const touch = e.changedTouches;
1439
- if (touch) {
1440
- pos.x = touch[0].clientX;
1441
- pos.y = touch[0].clientY;
1442
- }
1443
- if (!pos.x || pos.x < 0)
1444
- pos.x = 0;
1445
- if (!pos.y || pos.y < 0)
1446
- pos.y = 0;
1447
- return pos;
1448
- };
1449
- const copyToClipboard = (str, callback) => {
1450
- const el = document.createElement('textarea');
1451
- let storeContentEditable = el.contentEditable;
1452
- let storeReadOnly = el.readOnly;
1453
- el.value = str;
1454
- el.contentEditable = `true`;
1455
- el.readOnly = false;
1456
- el.setAttribute('readonly', `false`);
1457
- el.setAttribute('contenteditable', `true`);
1458
- el.style.position = 'absolute';
1459
- el.style.left = '-999999999px';
1460
- document.body.appendChild(el);
1461
- const selected = document.getSelection().rangeCount > 0
1462
- ? document.getSelection().getRangeAt(0)
1463
- : false;
1464
- el.select();
1465
- el.setSelectionRange(0, 999999);
1466
- document.execCommand('copy');
1467
- document.body.removeChild(el);
1468
- if (selected) {
1469
- document.getSelection().removeAllRanges();
1470
- document.getSelection().addRange(selected);
1471
- }
1472
- el.contentEditable = storeContentEditable;
1473
- el.readOnly = storeReadOnly;
1474
- if (callback)
1475
- callback();
1476
- };
1477
- /**
1478
- * Format bytes as human-readable text.
1479
- *
1480
- * @param bytes Number of bytes.
1481
- * @param si True to use metric (SI) units, aka powers of 1000. False to use
1482
- * binary (IEC), aka powers of 1024.
1483
- * @param dp Number of decimal places to display.
1484
- *
1485
- * @return Formatted string.
1486
- */
1487
- const formatSize = (bytes, si = false, dp = 1) => {
1488
- const thresh = si ? 1000 : 1024;
1489
- if (Math.abs(bytes) < thresh) {
1490
- return bytes + ' B';
1491
- }
1492
- const units = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
1493
- let u = -1;
1494
- const r = 10 ** dp;
1495
- do {
1496
- bytes /= thresh;
1497
- ++u;
1498
- } while (Math.round(Math.abs(bytes) * r) / r >= thresh && u < units.length - 1);
1499
- return bytes.toFixed(dp) + ' ' + units[u];
1500
- };
1501
- const slugify = (...args) => {
1502
- const value = args.join(' ');
1503
- return value
1504
- .normalize('NFD') // split an accented letter in the base letter and the acent
1505
- .replace(/[\u0300-\u036f]/g, '') // remove all previously split accents
1506
- .toLowerCase()
1507
- .trim()
1508
- .replace(/[^a-z0-9 ]/g, '') // remove all chars not letters, numbers and spaces (to be replaced)
1509
- .replace(/\s+/g, '-'); // separator
1510
- };
1511
-
1512
- const AppMain = forwardRef((props, ref) => {
1513
- // const { dispatch } = useStore()
1514
- // if("theme" in props && !theme){
1515
- // dispatch(setTheme(props.theme));
1516
- // }
1517
- return (jsx(ClassNames, { children: ({ css, cx }) => jsx("main", Object.assign({ className: `${props.as ? props.as : `zuz-app`} ${cx(css `${buildCSS(props)} &:hover {${buildCSS(props.hover || {})}} &:active {${buildCSS(props.active || {})}}`)}` }, { children: props.children })) }));
1518
- });
1519
- const App = forwardRef((props, ref) => {
1520
- return (jsx(AppProvider, { children: jsx(AppMain, {}) }));
1521
- });
1522
-
1523
- // const CoreBlock = styled.section`display: block;`
1524
- // const buildComponent = (props: any) => Block.withComponent(props.for || `div`)`${buildCSS(props)}`
1525
- const Component = forwardRef((props, ref) => {
1526
- const Tag = props.for;
1527
- const Block = (typeof props.for == 'string' ?
1528
- styled[props.for || `div`] : Tag) `${buildCSS(props)}`;
1529
- // const Block = styled.`${buildCSS(props)}`;
1530
- // const Block = CoreBlock.withComponent(props.for)`background: red`
1531
- // console.log(props)
1532
- // console.log(Styles)
1533
- // return <button>{props.children}</button>
1534
- return jsx(Block, Object.assign({ className: props.as || `` }, filterHTMLProps(props)));
1535
- });
1536
-
1537
- function Checkbox(props) {
1538
- const { checked, as, name, form, touched, onChange } = props;
1539
- const [_checked, setChecked] = useState(checked || false);
1540
- const theme = useTheme();
1541
- const dispatch = useDispatch(STORE_FORM_KEY);
1542
- const { forms } = useStore(state => state[STORE_FORM_KEY], false);
1543
- const switchCheck = useCallback(() => {
1544
- let nextVal = !_checked;
1545
- onChange && onChange(nextVal);
1546
- setChecked(nextVal);
1547
- dispatch(dispatch(UPDATE_FORM_FIELD(form || 'orphan', name, nextVal, forms)));
1548
- }, [_checked]);
1549
- const defaultCSS = `cursor: pointer;&:before {
1550
- background: ${!_checked ? `transparent` : theme.color} !important;
1551
- }`;
1552
- const _name = useMemo(() => name || nanoid(), [name]);
1553
- return (jsx(ClassNames, { children: ({ css, cx }) => jsxs(Fragment, { children: [jsx("input", { onChange: switchCheck, id: `zuz${_name}`,
1554
- // className={`${_checked ? 'y' : 'n'} ${as ? ` ${as} ` : ``}f ${cx(css`opacity: 0;position: absolute;&:checked {${defaultCSSChecked}}`)}`}
1555
- className: `zuz-checkbox`, name: _name, type: `checkbox`, value: `checked` }), jsx("label", { className: `${as ? `${as} ` : ``}f ${cx(css `${defaultCSS}`)}`, htmlFor: `zuz${_name}` })] }) })
1556
- // <Button
1557
- // overflow={`hidden`}
1558
- // name={name || nanoid()}
1559
- // onClick={switchCheck}
1560
- // w={38} h={22} r={20} bg={`#ddd`} rel>
1561
- // <Box w={38} h={22} anim={`0.2`} abs top={0} r={20} left={0} transform={`translateX(${_checked ? 0 : -16}px)`} bg={theme.color}>
1562
- // <Box w={18} h={18} abs right={2} top={2} bg={`#fff`} r={20} boxShadow={`0px 0px 0px 5px ${_checked ? theme.color : `#ddd`}`} />
1563
- // </Box>
1564
- // </Button>
1565
- );
1566
- }
1567
-
1568
- const Spinner = (props) => {
1569
- return (jsxs(Box, Object.assign({ rel: true, w: props.size, h: props.size, zIndex: `1`, useSelect: `none` }, { children: [jsx(Box, { abs: true, as: `spinner rotating`, animationDirection: `reverse`, animationDuration: typeof props.s1 == `string` ? props.s1 : `${props.s1}s`, w: props.size, r: props.radius, h: props.size, bg: props.color, opacity: 0.2 }), jsx(Box, { abs: true, as: `spinner rotating`, animationDuration: typeof props.s2 == `string` ? props.s2 : `${props.s2}s`, w: props.size, r: props.radius, h: props.size, bg: props.color, opacity: 0.5 })] })));
1570
- };
1571
- Spinner.defaultProps = {
1572
- size: 30,
1573
- radius: 4,
1574
- color: `black`,
1575
- s1: `5s`,
1576
- s2: `1s`
1577
- };
1578
- Spinner.propTypes = {
1579
- size: PropTypes.number.isRequired,
1580
- color: PropTypes.string,
1581
- radius: PropTypes.number,
1582
- s1: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
1583
- s2: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
1584
- };
1585
-
1586
- const Heading = forwardRef((props, ref) => {
1587
- const { children, as, h } = props;
1588
- let Tag = `h${h || 1}`;
1589
- const HeadingTag = Tag;
1590
- return (jsx(ClassNames, { children: ({ css, cx }) => jsx(HeadingTag, Object.assign({ className: `${as ? `${as} ` : ``}${cx(css `${buildCSS(props)}`)}`, ref: ref }, { children: props.html ? jsx("span", { dangerouslySetInnerHTML: { __html: props.html } }) : children })) }));
1591
- });
1592
-
1593
- const Cover = (props) => {
1594
- return (jsx(Box, Object.assign({ abs: true, fill: true, bgFilter: props.backdrop ? `saturate(${props.backdrop.saturate}%) blur(${props.backdrop.blur}px)` : undefined, zIndex: `2`, bg: props.bg }, { children: jsxs(Box, Object.assign({ abs: true, abc: true, aic: true, jcc: true, flex: true, dir: `cols`, gap: 20 }, { children: [jsx(Spinner, {}, `cover-spinner`), props.label && jsx(Heading, Object.assign({ size: 16, as: `f`, opacity: 0.7 }, { children: props.label }), `cover-label`)] }), `cover-shadow`) }), `cover-cloud`));
1595
- };
1596
- Cover.defaultProps = {
1597
- bg: `rgba(0,0,0,0.5)`,
1598
- backdrop: { saturate: 80, blur: 10 },
1599
- label: null
1600
- };
1601
- Cover.propTypes = {
1602
- bg: PropTypes.string,
1603
- backdrop: PropTypes.object,
1604
- label: PropTypes.string,
1605
- };
1606
-
1607
- const Form = forwardRef((props, ref) => {
1608
- var _a;
1609
- const { name, children, onSubmit, cover, debug } = props;
1610
- const [_html, setHTML] = useState(null);
1611
- const [_loading, setLoading] = useState((debug === null || debug === void 0 ? void 0 : debug.loading) || false);
1612
- const dispatch = useDispatch(STORE_FORM_KEY);
1613
- const { forms } = useStore(state => state[STORE_FORM_KEY], false);
1614
- const buildFields = () => {
1615
- return addProps(children, { form: name, touched: undefined, loading: undefined, onSubmit: onSubmit ? onSubmit : () => console.log(`onSubmit Missing`) });
1616
- };
1617
- const update = (e) => Object.keys(e).map(k => {
1618
- dispatch(UPDATE_FORM_FIELD(name || 'orphan', k, e[k], forms));
1619
- if (k == 'loading')
1620
- setLoading(e[k]);
1621
- });
1622
- const get = (k) => forms[name][k] || null;
1623
- useImperativeHandle(ref, () => ({
1624
- update,
1625
- get
1626
- }));
1627
- useEffect(() => {
1628
- let f = buildFields();
1629
- setHTML(f.children);
1630
- if (!forms[name]) {
1631
- dispatch(ADD_FORM(name, f.fields, forms));
1632
- }
1633
- }, [children, (_a = forms[name]) === null || _a === void 0 ? void 0 : _a.loading]);
1634
- return createElement(Box, Object.assign(Object.assign({ rel: true }, props), { as: name }), [
1635
- _loading ? jsx(Cover, { backdrop: (cover === null || cover === void 0 ? void 0 : cover.filter) || { saturate: 80, blur: 10 }, bg: (cover === null || cover === void 0 ? void 0 : cover.bg) || `rgba(0,0,0,0.5)` }, `form-${name}-cover`) : null,
1636
- _html
1637
- ]);
1638
- });
1639
- Form.defaultProps = {
1640
- name: 'form1',
1641
- onSubmit: () => { console.log(`onSubmit not provided`); }
1642
- };
1643
- Form.propTypes = {
1644
- name: PropTypes.string.isRequired,
1645
- children: PropTypes.node.isRequired,
1646
- onSubmit: PropTypes.func.isRequired
1647
- };
1648
-
1649
- const Icon = forwardRef((props, ref) => {
1650
- const { as, path, size, color, hover } = props;
1651
- return (jsx(Box, Object.assign({ hover: hover || {}, flex: true, bref: ref, as: `icon-${as}`, ai: `c`, jc: `c`, size: size || 24, color: color || `#111111` }, { children: path && Array(path).fill(undefined).map((p, i) => jsx("span", { className: `path${i + 1}` }, `ico-${as}-${i}`)) })));
1652
- });
1653
-
1654
- const Image$1 = forwardRef((props, ref) => {
1655
- const { src, isLoading, error } = useImage({ srcList: props.src, useSuspense: false });
1656
- return (jsx(ClassNames, { children: ({ css, cx }) => jsxs(Fragment, { children: [isLoading && jsx(Box, { className: `${props.as ? `${props.as} ` : ``}${cx(css `background: #eee;${buildCSS(props)}`)}` }), !isLoading && jsx("img", { src: src, className: `${props.as ? `${props.as} ` : ``}${cx(css `${buildCSS(props)}`)}`, ref: ref })] }) })
1657
- // <ClassNames>
1658
- // {({ css, cx }) => <picture className={cx(css`${buildCSS({ flex: true })}`)}>
1659
- // {status == 'loading' && <Box className={`${props.as ? `${props.as} ` : ``}${cx(css`background: #eee;${buildCSS(props)}`)}`} />}
1660
- // {status == 'loaded' && <img src={props.src}
1661
- // className={`${props.as ? `${props.as} ` : ``}${cx(css`${buildCSS(props)}`)}`}
1662
- // ref={ref} />}
1663
- // </picture>}
1664
- // </ClassNames>
1665
- );
1666
- });
1667
-
1668
- const DEFAULT_COLUMNS = 2;
1669
- class Masonry extends Component$1 {
1670
- constructor(props) {
1671
- super(props);
1672
- this._lastRecalculateAnimationFrame = window.requestAnimationFrame(() => {
1673
- this.reCalculateColumnCount();
1674
- });
1675
- // Correct scope for when methods are accessed externally
1676
- this.reCalculateColumnCount = this.reCalculateColumnCount.bind(this);
1677
- this.reCalculateColumnCountDebounce = this.reCalculateColumnCountDebounce.bind(this);
1678
- // default state
1679
- let columnCount;
1680
- if (this.props && this.props.breakpointCols.default) {
1681
- columnCount = this.props.breakpointCols.default;
1682
- }
1683
- else {
1684
- columnCount = parseInt(this.props.breakpointCols) || DEFAULT_COLUMNS;
1685
- }
1686
- this.state = {
1687
- columnCount
1688
- };
1689
- }
1690
- componentDidMount() {
1691
- this.reCalculateColumnCount();
1692
- // window may not be available in some environments
1693
- if (window) {
1694
- window.addEventListener('resize', this.reCalculateColumnCountDebounce);
1695
- }
1696
- }
1697
- componentDidUpdate() {
1698
- this.reCalculateColumnCount();
1699
- }
1700
- componentWillUnmount() {
1701
- if (window) {
1702
- window.removeEventListener('resize', this.reCalculateColumnCountDebounce);
1703
- }
1704
- }
1705
- reCalculateColumnCountDebounce() {
1706
- if (!window || !window.requestAnimationFrame) { // IE10+
1707
- this.reCalculateColumnCount();
1708
- return;
1709
- }
1710
- if (window.cancelAnimationFrame) { // IE10+
1711
- window.cancelAnimationFrame(this._lastRecalculateAnimationFrame);
1712
- }
1713
- }
1714
- reCalculateColumnCount() {
1715
- const windowWidth = window && window.innerWidth || Infinity;
1716
- let breakpointColsObject = this.props.breakpointCols;
1717
- // Allow passing a single number to `breakpointCols` instead of an object
1718
- if (typeof breakpointColsObject !== 'object') {
1719
- breakpointColsObject = {
1720
- default: parseInt(breakpointColsObject) || DEFAULT_COLUMNS
1721
- };
1722
- }
1723
- let matchedBreakpoint = Infinity;
1724
- let columns = breakpointColsObject.default || DEFAULT_COLUMNS;
1725
- for (let breakpoint in breakpointColsObject) {
1726
- const optBreakpoint = parseInt(breakpoint);
1727
- const isCurrentBreakpoint = optBreakpoint > 0 && windowWidth <= optBreakpoint;
1728
- if (isCurrentBreakpoint && optBreakpoint < matchedBreakpoint) {
1729
- matchedBreakpoint = optBreakpoint;
1730
- columns = breakpointColsObject[breakpoint];
1731
- }
1732
- }
1733
- columns = Math.max(1, parseInt(columns) || 1);
1734
- if (this.state.columnCount !== columns) {
1735
- this.setState({
1736
- columnCount: columns
1737
- });
1738
- this.props.onChange && this.props.onChange({ columns: columns });
1739
- }
1740
- }
1741
- itemsInColumns() {
1742
- const currentColumnCount = this.state.columnCount;
1743
- const itemsInColumns = new Array(currentColumnCount);
1744
- // Force children to be handled as an array
1745
- const items = Children$1.toArray(this.props.children);
1746
- for (let i = 0; i < items.length; i++) {
1747
- const columnIndex = i % currentColumnCount;
1748
- if (!itemsInColumns[columnIndex]) {
1749
- itemsInColumns[columnIndex] = [];
1750
- }
1751
- itemsInColumns[columnIndex].push(items[i]);
1752
- }
1753
- return itemsInColumns;
1754
- }
1755
- renderColumns() {
1756
- const { column, columnAttrs = {}, columnClassName } = this.props;
1757
- const childrenInColumns = this.itemsInColumns();
1758
- const columnWidth = `${100 / childrenInColumns.length}%`;
1759
- let className = columnClassName;
1760
- if (className && typeof className !== 'string') {
1761
- this.logDeprecated('The property "columnClassName" requires a string');
1762
- // This is a deprecated default and will be removed soon.
1763
- if (typeof className === 'undefined') {
1764
- className = 'my-masonry-grid_column';
1765
- }
1766
- }
1767
- const columnAttributes = Object.assign(Object.assign(Object.assign({}, column), columnAttrs), { style: Object.assign(Object.assign({}, columnAttrs.style), { width: columnWidth }), className });
1768
- return childrenInColumns.map((items, i) => {
1769
- return createElement("div", Object.assign({}, columnAttributes, { key: i }), items);
1770
- });
1771
- }
1772
- logDeprecated(message) {
1773
- console.error('[Masonry]', message);
1774
- }
1775
- render() {
1776
- const _a = this.props, {
1777
- // ignored
1778
- children, breakpointCols, columnClassName, columnAttrs, column,
1779
- // used
1780
- className } = _a, rest = __rest(_a, ["children", "breakpointCols", "columnClassName", "columnAttrs", "column", "className"]);
1781
- let classNameOutput = className;
1782
- if (typeof className !== 'string') {
1783
- this.logDeprecated('The property "className" requires a string');
1784
- // This is a deprecated default and will be removed soon.
1785
- if (typeof className === 'undefined') {
1786
- classNameOutput = 'my-masonry-grid';
1787
- }
1788
- }
1789
- return (jsx("div", Object.assign({}, rest, { className: classNameOutput }, { children: this.renderColumns() })));
1790
- }
1791
- }
1792
-
1793
- const calcPlaceholderStyle = (width, height, duration = 1600) => ({
1794
- backgroundSize: `${parseInt(width.toString()) * 10}px ${height}px`,
1795
- animationDuration: `${(duration / 1000).toFixed(1)}s`,
1796
- });
1797
- const Placeholder = forwardRef(({ width, height, duration, bg, bgFrom, bgTo }, ref) => {
1798
- const placeholderStyle = calcPlaceholderStyle(width, height, duration);
1799
- return (jsx(Box, { as: `shimmer`, w: width, h: height, bg: bg || `#f6f7f8`, backgroundImage: `linear-gradient(to right, ${bgFrom || `rgb(238, 238, 238)`} 8%, ${bgTo || `rgb(203, 203, 203)`} 18%, ${bgFrom || `rgb(238, 238, 238)`} 33%);`, backgroundSize: placeholderStyle.backgroundSize, animationDuration: placeholderStyle.animationDuration }));
1800
- });
1801
- Placeholder.propTypes = {
1802
- width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
1803
- height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
1804
- duration: PropTypes.number,
1805
- bg: PropTypes.string,
1806
- bgFrom: PropTypes.string,
1807
- bgTo: PropTypes.string
1808
- };
1809
-
1810
- const Spacer = ({ w, h }) => {
1811
- return (jsx(Box, { as: `spacer`, w: w || 0, h: h || 0 }));
1812
- };
1813
-
1814
- const Text = forwardRef((props, ref) => {
1815
- const { children, as } = props;
1816
- return (jsx(ClassNames, { children: ({ css, cx }) => jsx("p", Object.assign({ className: `${as ? `${as} ` : ``}${cx(css `${buildCSS(props)}`)}`, ref: ref }, { children: props.html ? jsx("span", { dangerouslySetInnerHTML: { __html: props.html } }) : children })) }));
1817
- });
1818
-
1819
- const Tweet = (props) => {
1820
- const [rand, setRand] = useState(Math.random());
1821
- const _tweet = useRef();
1822
- const renderTweet = () => {
1823
- const twttr = window['twttr'];
1824
- twttr.ready().then(({ widgets }) => {
1825
- const { options, onTweetLoadSuccess, onTweetLoadError } = props;
1826
- widgets
1827
- .createTweetEmbed(props.id, _tweet.current, options || {})
1828
- .then((twitterWidgetElement) => {
1829
- // this.setState({
1830
- // isLoading: false
1831
- // })
1832
- // onTweetLoadSuccess && onTweetLoadSuccess(twitterWidgetElement)
1833
- })
1834
- .catch(() => { });
1835
- });
1836
- };
1837
- useEffect(() => {
1838
- const twttr = window['twttr'];
1839
- if (!(twttr && twttr.ready)) {
1840
- addScript(`https://platform.twitter.com/widgets.js`, renderTweet);
1841
- }
1842
- else {
1843
- renderTweet();
1844
- }
1845
- }, []);
1846
- useEffect(() => {
1847
- }, [rand]);
1848
- return (jsx(Box, { as: `tweet`, weight: 1, bref: _tweet }));
1849
- };
1850
-
1851
- const buildElement = (el) => {
1852
- switch (el.is) {
1853
- case "Box":
1854
- return jsx(Box, Object.assign({}, (el.props || {}), { children: el.children || null }), el.key || nanoid());
1855
- }
1856
- };
1857
- const buildComponent = (data) => {
1858
- return data.map(e => buildElement(e));
1859
- };
1860
-
1861
- const Header = forwardRef((props, ref) => {
1862
- const data = [
1863
- { is: `Box` }
1864
- ];
1865
- return (jsx(Fragment, { children: buildComponent(data) }));
1866
- });
1867
-
1868
- export { App, Component as Block, Box, Button, Checkbox, Cover, Form, Header, Heading, Icon, Image$1 as Image, Input, Masonry, Placeholder, AppProvider as Provider, Select, Spacer, Spinner, Text, Toaster, Tweet, addProps, addScript, buildCSS, buildFormData, byId, byName, camelCase, cleanProps, copyToClipboard, createSlice, el, filterHTMLProps, filterStyleProps, formatSize, generateModalRoutes, generatePreservedRoutes, generateRegularRoutes, getCookie, getHostname, getMousePosition, getUriParams, grab, imgPromiseFactory, isEmail, isIPv4, isUrl, parseFilename, randstr, removeCookie, rgb2hex, setCSSVar, setCookie, shuffleArray, slugify, ucfirst, useContextMenu, useDevice, useDispatch, useImage, useLang, useRender, useResizeObserver, useStore, useTheme, useToast, uuid };