@helpdice/ui 1.8.4 → 2.0.5

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 (113) hide show
  1. package/dist/CurrencyInput/components/CurrencyInput.d.ts +4 -0
  2. package/dist/CurrencyInput/components/CurrencyInputProps.d.ts +160 -0
  3. package/dist/CurrencyInput/components/utils/cleanValue.d.ts +8 -0
  4. package/dist/CurrencyInput/components/utils/escapeRegExp.d.ts +6 -0
  5. package/dist/CurrencyInput/components/utils/fixedDecimalValue.d.ts +1 -0
  6. package/dist/CurrencyInput/components/utils/formatValue.d.ts +49 -0
  7. package/dist/CurrencyInput/components/utils/getLocaleConfig.d.ts +13 -0
  8. package/dist/CurrencyInput/components/utils/getSuffix.d.ts +6 -0
  9. package/dist/CurrencyInput/components/utils/index.d.ts +8 -0
  10. package/dist/CurrencyInput/components/utils/isNumber.d.ts +1 -0
  11. package/dist/CurrencyInput/components/utils/padTrimValue.d.ts +1 -0
  12. package/dist/CurrencyInput/components/utils/parseAbbrValue.d.ts +10 -0
  13. package/dist/CurrencyInput/components/utils/removeInvalidChars.d.ts +4 -0
  14. package/dist/CurrencyInput/components/utils/removeSeparators.d.ts +4 -0
  15. package/dist/CurrencyInput/components/utils/repositionCursor.d.ts +16 -0
  16. package/dist/CurrencyInput/index.d.ts +5 -0
  17. package/dist/CurrencyInput/index.js +3 -2122
  18. package/dist/ITooltip/index.d.ts +13 -0
  19. package/dist/Loadable/index.js +29 -3
  20. package/dist/PhoneInput/index.js +21 -2140
  21. package/dist/Placeholder/index.js +5 -2124
  22. package/dist/auto-complete/index.js +73 -12092
  23. package/dist/avatar/index.js +15 -2134
  24. package/dist/badge/index.js +8 -2127
  25. package/dist/breadcrumbs/index.js +19 -2138
  26. package/dist/button/index.js +36 -2229
  27. package/dist/button-dropdown/index.js +28 -2147
  28. package/dist/button-group/index.js +9 -2128
  29. package/dist/capacity/index.js +10 -2129
  30. package/dist/card/index.js +46 -2165
  31. package/dist/carousal/index.js +644 -12666
  32. package/dist/checkbox/index.js +10 -2129
  33. package/dist/code/index.js +14 -2133
  34. package/dist/collapse/index.js +16 -2135
  35. package/dist/description/index.js +9 -2128
  36. package/dist/display/index.js +11 -2130
  37. package/dist/divider/index.js +12 -2131
  38. package/dist/dot/index.js +6 -2125
  39. package/dist/drawer/index.js +21 -2139
  40. package/dist/fieldset/index.js +22 -2141
  41. package/dist/grid/index.js +8 -2127
  42. package/dist/image/index.js +31 -2150
  43. package/dist/index.d.ts +4 -0
  44. package/dist/index.js +2065 -23539
  45. package/dist/input/index.js +42 -2158
  46. package/dist/keyboard/index.js +11 -2130
  47. package/dist/link/index.js +11 -2130
  48. package/dist/list/index.js +25 -2143
  49. package/dist/list/list-item.d.ts +1 -0
  50. package/dist/loading/index.js +14 -2133
  51. package/dist/menu/index.js +2 -10245
  52. package/dist/modal/index.js +59 -2177
  53. package/dist/note/index.js +10 -2129
  54. package/dist/page/index.js +6 -2125
  55. package/dist/pagination/index.js +11 -2130
  56. package/dist/popover/index.js +23 -2141
  57. package/dist/progress/index.js +10 -2129
  58. package/dist/radio/index.js +17 -2136
  59. package/dist/rating/index.js +7 -2126
  60. package/dist/row/index.js +5 -2124
  61. package/dist/select/index.js +54 -2173
  62. package/dist/slider/index.js +21 -2140
  63. package/dist/snippet/index.js +12 -2131
  64. package/dist/spacer/index.js +2 -2121
  65. package/dist/spinner/index.js +5 -2124
  66. package/dist/table/index.js +910 -12918
  67. package/dist/tabs/index.js +16 -2135
  68. package/dist/tag/index.js +5 -2124
  69. package/dist/text/index.js +5 -2124
  70. package/dist/textarea/index.js +10 -2129
  71. package/dist/toggle/index.js +14 -2133
  72. package/dist/tooltip/index.js +17 -2135
  73. package/dist/tree/index.js +39 -2158
  74. package/dist/use-input/index.js +2 -2122
  75. package/dist/use-modal/index.js +2 -2122
  76. package/dist/use-scale/index.js +2 -2121
  77. package/dist/use-tabs/index.js +2 -2122
  78. package/dist/user/index.js +31 -2150
  79. package/esm/CurrencyInput/components/CurrencyInput.d.ts +4 -0
  80. package/esm/CurrencyInput/components/CurrencyInputProps.d.ts +160 -0
  81. package/esm/CurrencyInput/components/utils/cleanValue.d.ts +8 -0
  82. package/esm/CurrencyInput/components/utils/escapeRegExp.d.ts +6 -0
  83. package/esm/CurrencyInput/components/utils/fixedDecimalValue.d.ts +1 -0
  84. package/esm/CurrencyInput/components/utils/formatValue.d.ts +49 -0
  85. package/esm/CurrencyInput/components/utils/getLocaleConfig.d.ts +13 -0
  86. package/esm/CurrencyInput/components/utils/getSuffix.d.ts +6 -0
  87. package/esm/CurrencyInput/components/utils/index.d.ts +8 -0
  88. package/esm/CurrencyInput/components/utils/isNumber.d.ts +1 -0
  89. package/esm/CurrencyInput/components/utils/padTrimValue.d.ts +1 -0
  90. package/esm/CurrencyInput/components/utils/parseAbbrValue.d.ts +10 -0
  91. package/esm/CurrencyInput/components/utils/removeInvalidChars.d.ts +4 -0
  92. package/esm/CurrencyInput/components/utils/removeSeparators.d.ts +4 -0
  93. package/esm/CurrencyInput/components/utils/repositionCursor.d.ts +16 -0
  94. package/esm/CurrencyInput/index.d.ts +5 -0
  95. package/esm/ITooltip/index.d.ts +13 -0
  96. package/esm/ITooltip/index.js +97 -0
  97. package/esm/Loadable/loader.js +13 -0
  98. package/esm/button/button.compact.js +13 -86
  99. package/esm/index.d.ts +4 -0
  100. package/esm/index.js +4 -1
  101. package/esm/input/input.js +13 -10
  102. package/esm/link/link.js +3 -3
  103. package/esm/list/list-item.d.ts +1 -0
  104. package/esm/list/list-item.js +4 -2
  105. package/esm/login-with/LoginSocialAmazon/index.js +1 -1
  106. package/esm/login-with/LoginSocialApple/index.js +1 -1
  107. package/esm/login-with/LoginSocialFacebook/index.js +1 -1
  108. package/esm/login-with/LoginSocialGoogle/index.js +1 -1
  109. package/esm/table/table-body.js +14 -4
  110. package/esm/table/table-cell.js +1 -1
  111. package/esm/table/table-head.js +13 -13
  112. package/esm/table/table.js +8 -8
  113. package/package.json +5 -5
@@ -2,8 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var require$$0 = require('react');
6
- var require$$1 = require('react-dom');
5
+ var theme = require('@helpdice/theme');
7
6
 
8
7
  function _arrayLikeToArray(r, a) {
9
8
  (null == a || a > r.length) && (a = r.length);
@@ -51,2128 +50,9 @@ function _unsupportedIterableToArray(r, a) {
51
50
  }
52
51
  }
53
52
 
54
- var dist = {};
55
-
56
- var hasRequiredDist;
57
-
58
- function requireDist () {
59
- if (hasRequiredDist) return dist;
60
- hasRequiredDist = 1;
61
-
62
- var React = require$$0;
63
- var reactDom = require$$1;
64
-
65
- function _arrayLikeToArray(r, a) {
66
- (null == a || a > r.length) && (a = r.length);
67
- for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
68
- return n;
69
- }
70
- function _arrayWithHoles(r) {
71
- if (Array.isArray(r)) return r;
72
- }
73
- function _arrayWithoutHoles(r) {
74
- if (Array.isArray(r)) return _arrayLikeToArray(r);
75
- }
76
- function _defineProperty(e, r, t) {
77
- return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
78
- value: t,
79
- enumerable: true,
80
- configurable: true,
81
- writable: true
82
- }) : e[r] = t, e;
83
- }
84
- function _extends() {
85
- return _extends = Object.assign ? Object.assign.bind() : function (n) {
86
- for (var e = 1; e < arguments.length; e++) {
87
- var t = arguments[e];
88
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
89
- }
90
- return n;
91
- }, _extends.apply(null, arguments);
92
- }
93
- function _iterableToArray(r) {
94
- if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
95
- }
96
- function _iterableToArrayLimit(r, l) {
97
- var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
98
- if (null != t) {
99
- var e,
100
- n,
101
- i,
102
- u,
103
- a = [],
104
- f = true,
105
- o = false;
106
- try {
107
- if (i = (t = t.call(r)).next, 0 === l) {
108
- if (Object(t) !== t) return;
109
- f = !1;
110
- } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
111
- } catch (r) {
112
- o = true, n = r;
113
- } finally {
114
- try {
115
- if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
116
- } finally {
117
- if (o) throw n;
118
- }
119
- }
120
- return a;
121
- }
122
- }
123
- function _nonIterableRest() {
124
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
125
- }
126
- function _nonIterableSpread() {
127
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
128
- }
129
- function ownKeys(e, r) {
130
- var t = Object.keys(e);
131
- if (Object.getOwnPropertySymbols) {
132
- var o = Object.getOwnPropertySymbols(e);
133
- r && (o = o.filter(function (r) {
134
- return Object.getOwnPropertyDescriptor(e, r).enumerable;
135
- })), t.push.apply(t, o);
136
- }
137
- return t;
138
- }
139
- function _objectSpread2(e) {
140
- for (var r = 1; r < arguments.length; r++) {
141
- var t = null != arguments[r] ? arguments[r] : {};
142
- r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
143
- _defineProperty(e, r, t[r]);
144
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
145
- Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
146
- });
147
- }
148
- return e;
149
- }
150
- function _objectWithoutProperties(e, t) {
151
- if (null == e) return {};
152
- var o,
153
- r,
154
- i = _objectWithoutPropertiesLoose(e, t);
155
- if (Object.getOwnPropertySymbols) {
156
- var n = Object.getOwnPropertySymbols(e);
157
- for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
158
- }
159
- return i;
160
- }
161
- function _objectWithoutPropertiesLoose(r, e) {
162
- if (null == r) return {};
163
- var t = {};
164
- for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
165
- if (-1 !== e.indexOf(n)) continue;
166
- t[n] = r[n];
167
- }
168
- return t;
169
- }
170
- function _slicedToArray(r, e) {
171
- return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
172
- }
173
- function _toConsumableArray(r) {
174
- return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
175
- }
176
- function _toPrimitive(t, r) {
177
- if ("object" != typeof t || !t) return t;
178
- var e = t[Symbol.toPrimitive];
179
- if (void 0 !== e) {
180
- var i = e.call(t, r);
181
- if ("object" != typeof i) return i;
182
- throw new TypeError("@@toPrimitive must return a primitive value.");
183
- }
184
- return ("string" === r ? String : Number)(t);
185
- }
186
- function _toPropertyKey(t) {
187
- var i = _toPrimitive(t, "string");
188
- return "symbol" == typeof i ? i : i + "";
189
- }
190
- function _typeof(o) {
191
- "@babel/helpers - typeof";
192
-
193
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
194
- return typeof o;
195
- } : function (o) {
196
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
197
- }, _typeof(o);
198
- }
199
- function _unsupportedIterableToArray(r, a) {
200
- if (r) {
201
- if ("string" == typeof r) return _arrayLikeToArray(r, a);
202
- var t = {}.toString.call(r).slice(8, -1);
203
- return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
204
- }
205
- }
206
-
207
- var defaultToastLayout = {
208
- padding: '12px 16px',
209
- margin: '8px 0',
210
- width: '420px',
211
- maxWidth: '90vw',
212
- maxHeight: '75px',
213
- placement: 'bottomRight'
214
- };
215
- var defaultParams = {
216
- toasts: [],
217
- toastLayout: defaultToastLayout,
218
- updateToastLayout: function updateToastLayout(t) {
219
- return t;
220
- },
221
- updateToasts: function updateToasts(t) {
222
- return t;
223
- },
224
- lastUpdateToastId: null,
225
- updateLastToastId: function updateLastToastId() {
226
- return null;
227
- }
228
- };
229
- var HUIContent = /*#__PURE__*/React.createContext(defaultParams);
230
- var useHUIContext = function useHUIContext() {
231
- return React.useContext(HUIContent);
232
- };
233
-
234
- var defaultFont = {
235
- sans: '"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif',
236
- mono: 'Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace',
237
- prism: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,"Liberation Mono", "Courier New", monospace'
238
- };
239
- var defaultBreakpoints = {
240
- xs: {
241
- min: '0',
242
- max: '650px'
243
- },
244
- sm: {
245
- min: '650px',
246
- max: '900px'
247
- },
248
- md: {
249
- min: '900px',
250
- max: '1280px'
251
- },
252
- lg: {
253
- min: '1280px',
254
- max: '1920px'
255
- },
256
- xl: {
257
- min: '1920px',
258
- max: '10000px'
259
- }
260
- };
261
- var defaultLayout = {
262
- gap: '16pt',
263
- gapNegative: '-16pt',
264
- gapHalf: '8pt',
265
- gapHalfNegative: '-8pt',
266
- gapQuarter: '4pt',
267
- gapQuarterNegative: '-4pt',
268
- pageMargin: '16pt',
269
- pageWidth: '750pt',
270
- pageWidthWithMargin: '782pt',
271
- breakpointMobile: defaultBreakpoints.xs.max,
272
- breakpointTablet: defaultBreakpoints.sm.max,
273
- radius: '6px',
274
- unit: '16px'
275
- };
276
-
277
- var palette$1 = {
278
- accents_1: '#fafafa',
279
- accents_2: '#eaeaea',
280
- accents_3: '#999',
281
- accents_4: '#888',
282
- accents_5: '#666',
283
- accents_6: '#444',
284
- accents_7: '#333',
285
- accents_8: '#111',
286
- background: '#fff',
287
- foreground: '#000',
288
- selection: '#79ffe1',
289
- secondary: '#666',
290
- code: '#f81ce5',
291
- border: '#eaeaea',
292
- error: '#e00',
293
- errorLight: '#ff1a1a',
294
- errorLighter: '#f7d4d6',
295
- errorDark: '#c50000',
296
- success: '#0070f3',
297
- successLight: '#3291ff',
298
- successLighter: '#d3e5ff',
299
- successDark: '#0761d1',
300
- warning: '#f5a623',
301
- warningLight: '#f7b955',
302
- warningLighter: '#ffefcf',
303
- warningDark: '#ab570a',
304
- cyan: '#50e3c2',
305
- cyanLighter: '#aaffec',
306
- cyanLight: '#79ffe1',
307
- cyanDark: '#29bc9b',
308
- violet: '#7928ca',
309
- violetLighter: '#e3d7fc',
310
- violetLight: '#8a63d2',
311
- violetDark: '#4c2889',
312
- purple: '#f81ce5',
313
- alert: '#ff0080',
314
- magenta: '#eb367f',
315
- link: '#0070f3'
316
- };
317
- var expressiveness$1 = {
318
- linkStyle: 'none',
319
- linkHoverStyle: 'none',
320
- dropdownBoxShadow: '0 4px 4px 0 rgba(0, 0, 0, 0.02)',
321
- scrollerStart: 'rgba(255, 255, 255, 1)',
322
- scrollerEnd: 'rgba(255, 255, 255, 0)',
323
- shadowSmall: '0 5px 10px rgba(0, 0, 0, 0.12)',
324
- shadowMedium: '0 8px 30px rgba(0, 0, 0, 0.12)',
325
- shadowLarge: '0 30px 60px rgba(0, 0, 0, 0.12)',
326
- portalOpacity: 0.25
327
- };
328
- var font$1 = defaultFont;
329
- var breakpoints$1 = defaultBreakpoints;
330
- var layout$1 = defaultLayout;
331
- var themes$1 = {
332
- type: 'light',
333
- font: font$1,
334
- layout: layout$1,
335
- palette: palette$1,
336
- breakpoints: breakpoints$1,
337
- expressiveness: expressiveness$1
338
- };
339
-
340
- var palette = {
341
- accents_1: '#111',
342
- accents_2: '#333',
343
- accents_3: '#444',
344
- accents_4: '#666',
345
- accents_5: '#888',
346
- accents_6: '#999',
347
- accents_7: '#eaeaea',
348
- accents_8: '#fafafa',
349
- background: '#000',
350
- foreground: '#fff',
351
- selection: '#f81ce5',
352
- secondary: '#888',
353
- code: '#79ffe1',
354
- border: '#333',
355
- error: '#e00',
356
- errorLighter: '#f7d4d6',
357
- errorLight: '#ff1a1a',
358
- errorDark: '#c50000',
359
- success: '#0070f3',
360
- successLighter: '#d3e5ff',
361
- successLight: '#3291ff',
362
- successDark: '#0761d1',
363
- warning: '#f5a623',
364
- warningLighter: '#ffefcf',
365
- warningLight: '#f7b955',
366
- warningDark: '#ab570a',
367
- cyan: '#50e3c2',
368
- cyanLighter: '#aaffec',
369
- cyanLight: '#79ffe1',
370
- cyanDark: '#29bc9b',
371
- violet: '#7928ca',
372
- violetLighter: '#e3d7fc',
373
- violetLight: '#8a63d2',
374
- violetDark: '#4c2889',
375
- purple: '#f81ce5',
376
- alert: '#ff0080',
377
- magenta: '#eb367f',
378
- link: '#3291ff'
379
- };
380
- var expressiveness = {
381
- linkStyle: 'none',
382
- linkHoverStyle: 'none',
383
- dropdownBoxShadow: '0 0 0 1px #333',
384
- scrollerStart: 'rgba(255, 255, 255, 1)',
385
- scrollerEnd: 'rgba(255, 255, 255, 0)',
386
- shadowSmall: '0 0 0 1px #333',
387
- shadowMedium: '0 0 0 1px #333',
388
- shadowLarge: '0 0 0 1px #333',
389
- portalOpacity: 0.75
390
- };
391
- var font = defaultFont;
392
- var breakpoints = defaultBreakpoints;
393
- var layout = defaultLayout;
394
- var themes = {
395
- type: 'dark',
396
- font: font,
397
- layout: layout,
398
- palette: palette,
399
- breakpoints: breakpoints,
400
- expressiveness: expressiveness
401
- };
402
-
403
- var isObject = function isObject(target) {
404
- return target && _typeof(target) === 'object';
405
- };
406
- var _deepDuplicable = function deepDuplicable(source, target) {
407
- if (!isObject(target) || !isObject(source)) return source;
408
- var sourceKeys = Object.keys(source);
409
- var result = {};
410
- for (var _i = 0, _sourceKeys = sourceKeys; _i < _sourceKeys.length; _i++) {
411
- var key = _sourceKeys[_i];
412
- var sourceValue = source[key];
413
- var targetValue = target[key];
414
- if (Array.isArray(sourceValue) && Array.isArray(targetValue)) {
415
- result[key] = targetValue.concat(sourceValue);
416
- } else if (isObject(sourceValue) && isObject(targetValue)) {
417
- result[key] = _deepDuplicable(sourceValue, _objectSpread2({}, targetValue));
418
- } else if (targetValue) {
419
- result[key] = targetValue;
420
- } else {
421
- result[key] = sourceValue;
422
- }
423
- }
424
- return result;
425
- };
426
- var getPresets = function getPresets() {
427
- return [themes$1, themes];
428
- };
429
- var getPresetStaticTheme = function getPresetStaticTheme() {
430
- return themes$1;
431
- };
432
- var isAvailableThemeType = function isAvailableThemeType(type) {
433
- if (!type) return false;
434
- var presetThemes = getPresets();
435
- var hasType = presetThemes.find(function (theme) {
436
- return theme.type === type;
437
- });
438
- return !hasType;
439
- };
440
- var isPresetTheme = function isPresetTheme(themeOrType) {
441
- if (!themeOrType) return false;
442
- var isType = typeof themeOrType === 'string';
443
- var type = isType ? themeOrType : themeOrType.type;
444
- return !isAvailableThemeType(type);
445
- };
446
- var hasUserCustomTheme = function hasUserCustomTheme() {
447
- var themes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
448
- return !!themes.find(function (item) {
449
- return isAvailableThemeType(item.type);
450
- });
451
- };
452
- var create = function create(base, custom) {
453
- if (!isAvailableThemeType(custom.type)) {
454
- throw new Error('Duplicate or unavailable theme type');
455
- }
456
- return _deepDuplicable(base, custom);
457
- };
458
- var createFromDark = function createFromDark(custom) {
459
- return create(themes, custom);
460
- };
461
- var createFromLight = function createFromLight(custom) {
462
- return create(themes$1, custom);
463
- };
464
- var Themes = {
465
- isPresetTheme: isPresetTheme,
466
- isAvailableThemeType: isAvailableThemeType,
467
- hasUserCustomTheme: hasUserCustomTheme,
468
- getPresets: getPresets,
469
- getPresetStaticTheme: getPresetStaticTheme,
470
- create: create,
471
- createFromDark: createFromDark,
472
- createFromLight: createFromLight
473
- };
474
-
475
- /* "use client" */
476
-
477
- var defaultTheme = Themes.getPresetStaticTheme();
478
- var ThemeContext = /*#__PURE__*/React.createContext(defaultTheme);
479
- var useTheme = function useTheme() {
480
- return React.useContext(ThemeContext);
481
- };
482
-
483
- /* "use client" */
484
-
485
- var defaultAllThemesConfig = {
486
- themes: Themes.getPresets()
487
- };
488
- var AllThemesContext = /*#__PURE__*/React.createContext(defaultAllThemesConfig);
489
- var useAllThemes = function useAllThemes() {
490
- return React.useContext(AllThemesContext);
491
- };
492
-
493
- var ThemeProvider = function ThemeProvider(_ref) {
494
- var children = _ref.children,
495
- themeType = _ref.themeType,
496
- _ref$themes = _ref.themes,
497
- themes = _ref$themes === void 0 ? [] : _ref$themes;
498
- var _React$useState = React.useState({
499
- themes: Themes.getPresets()
500
- }),
501
- _React$useState2 = _slicedToArray(_React$useState, 2),
502
- allThemes = _React$useState2[0],
503
- setAllThemes = _React$useState2[1];
504
- var currentTheme = React.useMemo(function () {
505
- var theme = allThemes.themes.find(function (item) {
506
- return item.type === themeType;
507
- });
508
- if (theme) return theme;
509
- return Themes.getPresetStaticTheme();
510
- }, [allThemes, themeType]);
511
- React.useEffect(function () {
512
- if (!(themes !== null && themes !== void 0 && themes.length)) return;
513
- setAllThemes(function (last) {
514
- var safeThemes = themes.filter(function (item) {
515
- return Themes.isAvailableThemeType(item.type);
516
- });
517
- var nextThemes = Themes.getPresets().concat(safeThemes);
518
- return _objectSpread2(_objectSpread2({}, last), {}, {
519
- themes: nextThemes
520
- });
521
- });
522
- }, [themes]);
523
- return /*#__PURE__*/React.createElement(AllThemesContext.Provider, {
524
- value: allThemes
525
- }, /*#__PURE__*/React.createElement(ThemeContext.Provider, {
526
- value: currentTheme
527
- }, children));
528
- };
529
-
530
- var useCurrentState = function useCurrentState(initialState) {
531
- var _useState = React.useState(function () {
532
- return typeof initialState === 'function' ? initialState() : initialState;
533
- }),
534
- _useState2 = _slicedToArray(_useState, 2),
535
- state = _useState2[0],
536
- setState = _useState2[1];
537
- var ref = React.useRef(initialState);
538
- React.useEffect(function () {
539
- ref.current = state;
540
- }, [state]);
541
- var setValue = function setValue(val) {
542
- var result = typeof val === 'function' ? val(ref.current) : val;
543
- ref.current = result;
544
- setState(result);
545
- };
546
- return [state, setValue, ref];
547
- };
548
-
549
- function getDefaultExportFromCjs (x) {
550
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
551
- }
552
-
553
- var index = {};
554
-
555
- var hasRequiredIndex;
556
-
557
- function requireIndex () {
558
- if (hasRequiredIndex) return index;
559
- hasRequiredIndex = 1;
560
- var React$1 = React;
561
-
562
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
563
-
564
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React$1);
565
-
566
- /*
567
- Based on Glamor's sheet
568
- https://github.com/threepointone/glamor/blob/667b480d31b3721a905021b26e1290ce92ca2879/src/sheet.js
569
- */ function _defineProperties(target, props) {
570
- for(var i = 0; i < props.length; i++){
571
- var descriptor = props[i];
572
- descriptor.enumerable = descriptor.enumerable || false;
573
- descriptor.configurable = true;
574
- if ("value" in descriptor) descriptor.writable = true;
575
- Object.defineProperty(target, descriptor.key, descriptor);
576
- }
577
- }
578
- function _createClass(Constructor, protoProps, staticProps) {
579
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
580
- return Constructor;
581
- }
582
- var isProd = typeof process !== "undefined" && process.env && process.env.NODE_ENV === "production";
583
- var isString = function(o) {
584
- return Object.prototype.toString.call(o) === "[object String]";
585
- };
586
- var StyleSheet = /*#__PURE__*/ function() {
587
- function StyleSheet(param) {
588
- var ref = param === void 0 ? {} : param, _name = ref.name, name = _name === void 0 ? "stylesheet" : _name, _optimizeForSpeed = ref.optimizeForSpeed, optimizeForSpeed = _optimizeForSpeed === void 0 ? isProd : _optimizeForSpeed;
589
- invariant$1(isString(name), "`name` must be a string");
590
- this._name = name;
591
- this._deletedRulePlaceholder = "#" + name + "-deleted-rule____{}";
592
- invariant$1(typeof optimizeForSpeed === "boolean", "`optimizeForSpeed` must be a boolean");
593
- this._optimizeForSpeed = optimizeForSpeed;
594
- this._serverSheet = undefined;
595
- this._tags = [];
596
- this._injected = false;
597
- this._rulesCount = 0;
598
- var node = typeof window !== "undefined" && document.querySelector('meta[property="csp-nonce"]');
599
- this._nonce = node ? node.getAttribute("content") : null;
600
- }
601
- var _proto = StyleSheet.prototype;
602
- _proto.setOptimizeForSpeed = function setOptimizeForSpeed(bool) {
603
- invariant$1(typeof bool === "boolean", "`setOptimizeForSpeed` accepts a boolean");
604
- invariant$1(this._rulesCount === 0, "optimizeForSpeed cannot be when rules have already been inserted");
605
- this.flush();
606
- this._optimizeForSpeed = bool;
607
- this.inject();
608
- };
609
- _proto.isOptimizeForSpeed = function isOptimizeForSpeed() {
610
- return this._optimizeForSpeed;
611
- };
612
- _proto.inject = function inject() {
613
- var _this = this;
614
- invariant$1(!this._injected, "sheet already injected");
615
- this._injected = true;
616
- if (typeof window !== "undefined" && this._optimizeForSpeed) {
617
- this._tags[0] = this.makeStyleTag(this._name);
618
- this._optimizeForSpeed = "insertRule" in this.getSheet();
619
- if (!this._optimizeForSpeed) {
620
- if (!isProd) {
621
- console.warn("StyleSheet: optimizeForSpeed mode not supported falling back to standard mode.");
622
- }
623
- this.flush();
624
- this._injected = true;
625
- }
626
- return;
627
- }
628
- this._serverSheet = {
629
- cssRules: [],
630
- insertRule: function(rule, index) {
631
- if (typeof index === "number") {
632
- _this._serverSheet.cssRules[index] = {
633
- cssText: rule
634
- };
635
- } else {
636
- _this._serverSheet.cssRules.push({
637
- cssText: rule
638
- });
639
- }
640
- return index;
641
- },
642
- deleteRule: function(index) {
643
- _this._serverSheet.cssRules[index] = null;
644
- }
645
- };
646
- };
647
- _proto.getSheetForTag = function getSheetForTag(tag) {
648
- if (tag.sheet) {
649
- return tag.sheet;
650
- }
651
- // this weirdness brought to you by firefox
652
- for(var i = 0; i < document.styleSheets.length; i++){
653
- if (document.styleSheets[i].ownerNode === tag) {
654
- return document.styleSheets[i];
655
- }
656
- }
657
- };
658
- _proto.getSheet = function getSheet() {
659
- return this.getSheetForTag(this._tags[this._tags.length - 1]);
660
- };
661
- _proto.insertRule = function insertRule(rule, index) {
662
- invariant$1(isString(rule), "`insertRule` accepts only strings");
663
- if (typeof window === "undefined") {
664
- if (typeof index !== "number") {
665
- index = this._serverSheet.cssRules.length;
666
- }
667
- this._serverSheet.insertRule(rule, index);
668
- return this._rulesCount++;
669
- }
670
- if (this._optimizeForSpeed) {
671
- var sheet = this.getSheet();
672
- if (typeof index !== "number") {
673
- index = sheet.cssRules.length;
674
- }
675
- // this weirdness for perf, and chrome's weird bug
676
- // https://stackoverflow.com/questions/20007992/chrome-suddenly-stopped-accepting-insertrule
677
- try {
678
- sheet.insertRule(rule, index);
679
- } catch (error) {
680
- if (!isProd) {
681
- console.warn("StyleSheet: illegal rule: \n\n" + rule + "\n\nSee https://stackoverflow.com/q/20007992 for more info");
682
- }
683
- return -1;
684
- }
685
- } else {
686
- var insertionPoint = this._tags[index];
687
- this._tags.push(this.makeStyleTag(this._name, rule, insertionPoint));
688
- }
689
- return this._rulesCount++;
690
- };
691
- _proto.replaceRule = function replaceRule(index, rule) {
692
- if (this._optimizeForSpeed || typeof window === "undefined") {
693
- var sheet = typeof window !== "undefined" ? this.getSheet() : this._serverSheet;
694
- if (!rule.trim()) {
695
- rule = this._deletedRulePlaceholder;
696
- }
697
- if (!sheet.cssRules[index]) {
698
- // @TBD Should we throw an error?
699
- return index;
700
- }
701
- sheet.deleteRule(index);
702
- try {
703
- sheet.insertRule(rule, index);
704
- } catch (error) {
705
- if (!isProd) {
706
- console.warn("StyleSheet: illegal rule: \n\n" + rule + "\n\nSee https://stackoverflow.com/q/20007992 for more info");
707
- }
708
- // In order to preserve the indices we insert a deleteRulePlaceholder
709
- sheet.insertRule(this._deletedRulePlaceholder, index);
710
- }
711
- } else {
712
- var tag = this._tags[index];
713
- invariant$1(tag, "old rule at index `" + index + "` not found");
714
- tag.textContent = rule;
715
- }
716
- return index;
717
- };
718
- _proto.deleteRule = function deleteRule(index) {
719
- if (typeof window === "undefined") {
720
- this._serverSheet.deleteRule(index);
721
- return;
722
- }
723
- if (this._optimizeForSpeed) {
724
- this.replaceRule(index, "");
725
- } else {
726
- var tag = this._tags[index];
727
- invariant$1(tag, "rule at index `" + index + "` not found");
728
- tag.parentNode.removeChild(tag);
729
- this._tags[index] = null;
730
- }
731
- };
732
- _proto.flush = function flush() {
733
- this._injected = false;
734
- this._rulesCount = 0;
735
- if (typeof window !== "undefined") {
736
- this._tags.forEach(function(tag) {
737
- return tag && tag.parentNode.removeChild(tag);
738
- });
739
- this._tags = [];
740
- } else {
741
- // simpler on server
742
- this._serverSheet.cssRules = [];
743
- }
744
- };
745
- _proto.cssRules = function cssRules() {
746
- var _this = this;
747
- if (typeof window === "undefined") {
748
- return this._serverSheet.cssRules;
749
- }
750
- return this._tags.reduce(function(rules, tag) {
751
- if (tag) {
752
- rules = rules.concat(Array.prototype.map.call(_this.getSheetForTag(tag).cssRules, function(rule) {
753
- return rule.cssText === _this._deletedRulePlaceholder ? null : rule;
754
- }));
755
- } else {
756
- rules.push(null);
757
- }
758
- return rules;
759
- }, []);
760
- };
761
- _proto.makeStyleTag = function makeStyleTag(name, cssString, relativeToTag) {
762
- if (cssString) {
763
- invariant$1(isString(cssString), "makeStyleTag accepts only strings as second parameter");
764
- }
765
- var tag = document.createElement("style");
766
- if (this._nonce) tag.setAttribute("nonce", this._nonce);
767
- tag.type = "text/css";
768
- tag.setAttribute("data-" + name, "");
769
- if (cssString) {
770
- tag.appendChild(document.createTextNode(cssString));
771
- }
772
- var head = document.head || document.getElementsByTagName("head")[0];
773
- if (relativeToTag) {
774
- head.insertBefore(tag, relativeToTag);
775
- } else {
776
- head.appendChild(tag);
777
- }
778
- return tag;
779
- };
780
- _createClass(StyleSheet, [
781
- {
782
- key: "length",
783
- get: function get() {
784
- return this._rulesCount;
785
- }
786
- }
787
- ]);
788
- return StyleSheet;
789
- }();
790
- function invariant$1(condition, message) {
791
- if (!condition) {
792
- throw new Error("StyleSheet: " + message + ".");
793
- }
794
- }
795
-
796
- function hash(str) {
797
- var _$hash = 5381, i = str.length;
798
- while(i){
799
- _$hash = _$hash * 33 ^ str.charCodeAt(--i);
800
- }
801
- /* JavaScript does bitwise operations (like XOR, above) on 32-bit signed
802
- * integers. Since we want the results to be always positive, convert the
803
- * signed int to an unsigned by doing an unsigned bitshift. */ return _$hash >>> 0;
804
- }
805
- var stringHash = hash;
806
-
807
- var sanitize = function(rule) {
808
- return rule.replace(/\/style/gi, "\\/style");
809
- };
810
- var cache = {};
811
- /**
812
- * computeId
813
- *
814
- * Compute and memoize a jsx id from a basedId and optionally props.
815
- */ function computeId(baseId, props) {
816
- if (!props) {
817
- return "jsx-" + baseId;
818
- }
819
- var propsToString = String(props);
820
- var key = baseId + propsToString;
821
- if (!cache[key]) {
822
- cache[key] = "jsx-" + stringHash(baseId + "-" + propsToString);
823
- }
824
- return cache[key];
825
- }
826
- /**
827
- * computeSelector
828
- *
829
- * Compute and memoize dynamic selectors.
830
- */ function computeSelector(id, css) {
831
- var selectoPlaceholderRegexp = /__jsx-style-dynamic-selector/g;
832
- // Sanitize SSR-ed CSS.
833
- // Client side code doesn't need to be sanitized since we use
834
- // document.createTextNode (dev) and the CSSOM api sheet.insertRule (prod).
835
- if (typeof window === "undefined") {
836
- css = sanitize(css);
837
- }
838
- var idcss = id + css;
839
- if (!cache[idcss]) {
840
- cache[idcss] = css.replace(selectoPlaceholderRegexp, id);
841
- }
842
- return cache[idcss];
843
- }
844
-
845
- function mapRulesToStyle(cssRules, options) {
846
- if (options === void 0) options = {};
847
- return cssRules.map(function(args) {
848
- var id = args[0];
849
- var css = args[1];
850
- return /*#__PURE__*/ React__default["default"].createElement("style", {
851
- id: "__" + id,
852
- // Avoid warnings upon render with a key
853
- key: "__" + id,
854
- nonce: options.nonce ? options.nonce : undefined,
855
- dangerouslySetInnerHTML: {
856
- __html: css
857
- }
858
- });
859
- });
860
- }
861
- var StyleSheetRegistry = /*#__PURE__*/ function() {
862
- function StyleSheetRegistry(param) {
863
- var ref = param === void 0 ? {} : param, _styleSheet = ref.styleSheet, styleSheet = _styleSheet === void 0 ? null : _styleSheet, _optimizeForSpeed = ref.optimizeForSpeed, optimizeForSpeed = _optimizeForSpeed === void 0 ? false : _optimizeForSpeed;
864
- this._sheet = styleSheet || new StyleSheet({
865
- name: "styled-jsx",
866
- optimizeForSpeed: optimizeForSpeed
867
- });
868
- this._sheet.inject();
869
- if (styleSheet && typeof optimizeForSpeed === "boolean") {
870
- this._sheet.setOptimizeForSpeed(optimizeForSpeed);
871
- this._optimizeForSpeed = this._sheet.isOptimizeForSpeed();
872
- }
873
- this._fromServer = undefined;
874
- this._indices = {};
875
- this._instancesCounts = {};
876
- }
877
- var _proto = StyleSheetRegistry.prototype;
878
- _proto.add = function add(props) {
879
- var _this = this;
880
- if (undefined === this._optimizeForSpeed) {
881
- this._optimizeForSpeed = Array.isArray(props.children);
882
- this._sheet.setOptimizeForSpeed(this._optimizeForSpeed);
883
- this._optimizeForSpeed = this._sheet.isOptimizeForSpeed();
884
- }
885
- if (typeof window !== "undefined" && !this._fromServer) {
886
- this._fromServer = this.selectFromServer();
887
- this._instancesCounts = Object.keys(this._fromServer).reduce(function(acc, tagName) {
888
- acc[tagName] = 0;
889
- return acc;
890
- }, {});
891
- }
892
- var ref = this.getIdAndRules(props), styleId = ref.styleId, rules = ref.rules;
893
- // Deduping: just increase the instances count.
894
- if (styleId in this._instancesCounts) {
895
- this._instancesCounts[styleId] += 1;
896
- return;
897
- }
898
- var indices = rules.map(function(rule) {
899
- return _this._sheet.insertRule(rule);
900
- })// Filter out invalid rules
901
- .filter(function(index) {
902
- return index !== -1;
903
- });
904
- this._indices[styleId] = indices;
905
- this._instancesCounts[styleId] = 1;
906
- };
907
- _proto.remove = function remove(props) {
908
- var _this = this;
909
- var styleId = this.getIdAndRules(props).styleId;
910
- invariant(styleId in this._instancesCounts, "styleId: `" + styleId + "` not found");
911
- this._instancesCounts[styleId] -= 1;
912
- if (this._instancesCounts[styleId] < 1) {
913
- var tagFromServer = this._fromServer && this._fromServer[styleId];
914
- if (tagFromServer) {
915
- tagFromServer.parentNode.removeChild(tagFromServer);
916
- delete this._fromServer[styleId];
917
- } else {
918
- this._indices[styleId].forEach(function(index) {
919
- return _this._sheet.deleteRule(index);
920
- });
921
- delete this._indices[styleId];
922
- }
923
- delete this._instancesCounts[styleId];
924
- }
925
- };
926
- _proto.update = function update(props, nextProps) {
927
- this.add(nextProps);
928
- this.remove(props);
929
- };
930
- _proto.flush = function flush() {
931
- this._sheet.flush();
932
- this._sheet.inject();
933
- this._fromServer = undefined;
934
- this._indices = {};
935
- this._instancesCounts = {};
936
- };
937
- _proto.cssRules = function cssRules() {
938
- var _this = this;
939
- var fromServer = this._fromServer ? Object.keys(this._fromServer).map(function(styleId) {
940
- return [
941
- styleId,
942
- _this._fromServer[styleId]
943
- ];
944
- }) : [];
945
- var cssRules = this._sheet.cssRules();
946
- return fromServer.concat(Object.keys(this._indices).map(function(styleId) {
947
- return [
948
- styleId,
949
- _this._indices[styleId].map(function(index) {
950
- return cssRules[index].cssText;
951
- }).join(_this._optimizeForSpeed ? "" : "\n")
952
- ];
953
- })// filter out empty rules
954
- .filter(function(rule) {
955
- return Boolean(rule[1]);
956
- }));
957
- };
958
- _proto.styles = function styles(options) {
959
- return mapRulesToStyle(this.cssRules(), options);
960
- };
961
- _proto.getIdAndRules = function getIdAndRules(props) {
962
- var css = props.children, dynamic = props.dynamic, id = props.id;
963
- if (dynamic) {
964
- var styleId = computeId(id, dynamic);
965
- return {
966
- styleId: styleId,
967
- rules: Array.isArray(css) ? css.map(function(rule) {
968
- return computeSelector(styleId, rule);
969
- }) : [
970
- computeSelector(styleId, css)
971
- ]
972
- };
973
- }
974
- return {
975
- styleId: computeId(id),
976
- rules: Array.isArray(css) ? css : [
977
- css
978
- ]
979
- };
980
- };
981
- /**
982
- * selectFromServer
983
- *
984
- * Collects style tags from the document with id __jsx-XXX
985
- */ _proto.selectFromServer = function selectFromServer() {
986
- var elements = Array.prototype.slice.call(document.querySelectorAll('[id^="__jsx-"]'));
987
- return elements.reduce(function(acc, element) {
988
- var id = element.id.slice(2);
989
- acc[id] = element;
990
- return acc;
991
- }, {});
992
- };
993
- return StyleSheetRegistry;
994
- }();
995
- function invariant(condition, message) {
996
- if (!condition) {
997
- throw new Error("StyleSheetRegistry: " + message + ".");
998
- }
999
- }
1000
- var StyleSheetContext = /*#__PURE__*/ React$1.createContext(null);
1001
- StyleSheetContext.displayName = "StyleSheetContext";
1002
- function createStyleRegistry() {
1003
- return new StyleSheetRegistry();
1004
- }
1005
- function StyleRegistry(param) {
1006
- var configuredRegistry = param.registry, children = param.children;
1007
- var rootRegistry = React$1.useContext(StyleSheetContext);
1008
- var ref = React$1.useState(function() {
1009
- return rootRegistry || configuredRegistry || createStyleRegistry();
1010
- }), registry = ref[0];
1011
- return /*#__PURE__*/ React__default["default"].createElement(StyleSheetContext.Provider, {
1012
- value: registry
1013
- }, children);
1014
- }
1015
- function useStyleRegistry() {
1016
- return React$1.useContext(StyleSheetContext);
1017
- }
1018
-
1019
- // Opt-into the new `useInsertionEffect` API in React 18, fallback to `useLayoutEffect`.
1020
- // https://github.com/reactwg/react-18/discussions/110
1021
- var useInsertionEffect = React__default["default"].useInsertionEffect || React$1.useLayoutEffect;
1022
- var defaultRegistry = typeof window !== "undefined" ? createStyleRegistry() : undefined;
1023
- function JSXStyle(props) {
1024
- var registry = defaultRegistry ? defaultRegistry : useStyleRegistry();
1025
- var insertionEffectCalled = React$1.useRef(false);
1026
- // `registry` might not exist while server-side rendering
1027
- if (!registry) {
1028
- return null;
1029
- }
1030
- if (typeof window === "undefined") {
1031
- registry.add(props);
1032
- return null;
1033
- }
1034
- useInsertionEffect(function() {
1035
- // ReactDOM removes all DOM during hydration in certain cases
1036
- if (!document.head) {
1037
- return;
1038
- }
1039
- registry.add(props);
1040
- insertionEffectCalled.current = true;
1041
- return function() {
1042
- insertionEffectCalled.current = false;
1043
- registry.remove(props);
1044
- };
1045
- }, [
1046
- props.id,
1047
- String(props.dynamic)
1048
- ]);
1049
- React$1.useLayoutEffect(function() {
1050
- if (!document.head || insertionEffectCalled.current) {
1051
- return;
1052
- }
1053
- registry.add(props);
1054
- return function() {
1055
- registry.remove(props);
1056
- };
1057
- // props.children can be string[], will be striped since id is identical
1058
- }, [
1059
- props.id,
1060
- String(props.dynamic)
1061
- ]);
1062
- return null;
1063
- }
1064
- JSXStyle.dynamic = function(info) {
1065
- return info.map(function(tagInfo) {
1066
- var baseId = tagInfo[0];
1067
- var props = tagInfo[1];
1068
- return computeId(baseId, props);
1069
- }).join(" ");
1070
- };
1071
-
1072
- index.StyleRegistry = StyleRegistry;
1073
- index.createStyleRegistry = createStyleRegistry;
1074
- index.style = JSXStyle;
1075
- index.useStyleRegistry = useStyleRegistry;
1076
- return index;
1077
- }
1078
-
1079
- var style;
1080
- var hasRequiredStyle;
1081
-
1082
- function requireStyle () {
1083
- if (hasRequiredStyle) return style;
1084
- hasRequiredStyle = 1;
1085
- style = requireIndex().style;
1086
- return style;
1087
- }
1088
-
1089
- var styleExports = requireStyle();
1090
- var _JSXStyle = /*@__PURE__*/getDefaultExportFromCjs(styleExports);
1091
-
1092
- /* "use client" */
1093
-
1094
- var getId = function getId() {
1095
- return Math.random().toString(32).slice(2, 10);
1096
- };
1097
- var isBrowser = function isBrowser() {
1098
- return Boolean(typeof window !== 'undefined' && window.document && window.document.createElement);
1099
- };
1100
-
1101
- var useSSR = function useSSR() {
1102
- var _useState = React.useState(false),
1103
- _useState2 = _slicedToArray(_useState, 2),
1104
- browser = _useState2[0],
1105
- setBrowser = _useState2[1];
1106
- React.useEffect(function () {
1107
- setBrowser(isBrowser());
1108
- }, []);
1109
- return {
1110
- isBrowser: browser,
1111
- isServer: !browser
1112
- };
1113
- };
1114
-
1115
- var createElement = function createElement(id) {
1116
- var el = document.createElement('div');
1117
- el.setAttribute('id', id);
1118
- return el;
1119
- };
1120
- var usePortal = function usePortal() {
1121
- var selectId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getId();
1122
- var getContainer = arguments.length > 1 ? arguments[1] : undefined;
1123
- var id = "helpdice-ui-".concat(selectId);
1124
- var _useSSR = useSSR(),
1125
- isBrowser = _useSSR.isBrowser;
1126
- var _useState = React.useState(isBrowser ? createElement(id) : null),
1127
- _useState2 = _slicedToArray(_useState, 2),
1128
- elSnapshot = _useState2[0],
1129
- setElSnapshot = _useState2[1];
1130
- React.useEffect(function () {
1131
- var customContainer = getContainer ? getContainer() : null;
1132
- var parentElement = customContainer || document.body;
1133
- var hasElement = parentElement.querySelector("#".concat(id));
1134
- var el = hasElement || createElement(id);
1135
- if (!hasElement) {
1136
- parentElement.appendChild(el);
1137
- }
1138
- setElSnapshot(el);
1139
- }, []);
1140
- return elSnapshot;
1141
- };
1142
-
1143
- var _excluded$2 = ["children", "className", "visible", "enterTime", "leaveTime", "clearTime", "name"];
1144
- var CssTransition = function CssTransition(_ref) {
1145
- var children = _ref.children,
1146
- _ref$className = _ref.className,
1147
- className = _ref$className === void 0 ? '' : _ref$className,
1148
- _ref$visible = _ref.visible,
1149
- visible = _ref$visible === void 0 ? false : _ref$visible,
1150
- _ref$enterTime = _ref.enterTime,
1151
- enterTime = _ref$enterTime === void 0 ? 60 : _ref$enterTime,
1152
- _ref$leaveTime = _ref.leaveTime,
1153
- leaveTime = _ref$leaveTime === void 0 ? 60 : _ref$leaveTime,
1154
- _ref$clearTime = _ref.clearTime,
1155
- clearTime = _ref$clearTime === void 0 ? 60 : _ref$clearTime,
1156
- _ref$name = _ref.name,
1157
- name = _ref$name === void 0 ? 'transition' : _ref$name,
1158
- props = _objectWithoutProperties(_ref, _excluded$2);
1159
- var _useState = React.useState(''),
1160
- _useState2 = _slicedToArray(_useState, 2),
1161
- classes = _useState2[0],
1162
- setClasses = _useState2[1];
1163
- var _useState3 = React.useState(visible),
1164
- _useState4 = _slicedToArray(_useState3, 2),
1165
- renderable = _useState4[0],
1166
- setRenderable = _useState4[1];
1167
- React.useEffect(function () {
1168
- var statusClassName = visible ? 'enter' : 'leave';
1169
- var time = visible ? enterTime : leaveTime;
1170
- if (visible && !renderable) {
1171
- setRenderable(true);
1172
- }
1173
- setClasses("".concat(name, "-").concat(statusClassName));
1174
-
1175
- // set class to active
1176
- var timer = setTimeout(function () {
1177
- setClasses("".concat(name, "-").concat(statusClassName, " ").concat(name, "-").concat(statusClassName, "-active"));
1178
- clearTimeout(timer);
1179
- }, time);
1180
-
1181
- // remove classess when animation over
1182
- var clearClassesTimer = setTimeout(function () {
1183
- if (!visible) {
1184
- setClasses('');
1185
- setRenderable(false);
1186
- }
1187
- clearTimeout(clearClassesTimer);
1188
- }, time + clearTime);
1189
- return function () {
1190
- clearTimeout(timer);
1191
- clearTimeout(clearClassesTimer);
1192
- };
1193
- }, [visible, renderable]);
1194
- if (! /*#__PURE__*/React.isValidElement(children) || !renderable) return null;
1195
- var propsTransition = _objectSpread2(_objectSpread2({}, props), {}, {
1196
- className: "".concat(children.props.className, " ").concat(className, " ").concat(classes)
1197
- });
1198
- return /*#__PURE__*/React.cloneElement(children, propsTransition);
1199
- };
1200
- CssTransition.displayName = 'CssTransition';
1201
-
1202
- var tuple = function tuple() {
1203
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1204
- args[_key] = arguments[_key];
1205
- }
1206
- return args;
1207
- };
1208
- tuple('default', 'secondary', 'success', 'warning', 'error', 'abort', 'secondary-light', 'success-light', 'warning-light', 'error-light');
1209
- tuple('default', 'secondary', 'success', 'warning', 'error');
1210
- tuple('default', 'secondary', 'success', 'warning', 'error', 'dark', 'lite');
1211
- tuple('default', 'secondary', 'success', 'warning', 'error', 'dark', 'lite', 'alert', 'purple', 'violet', 'cyan');
1212
- tuple('default', 'silent', 'prevent');
1213
- tuple('hover', 'click');
1214
- tuple('top', 'topStart', 'topEnd', 'left', 'leftStart', 'leftEnd', 'bottom', 'bottomStart', 'bottomEnd', 'right', 'rightStart', 'rightEnd');
1215
- tuple('start', 'center', 'end', 'left', 'right');
1216
-
1217
- var makeToastActions = function makeToastActions(actions, cancelHandle) {
1218
- var handler = function handler(event, userHandler) {
1219
- userHandler && userHandler(event, cancelHandle);
1220
- };
1221
- if (!actions || !actions.length) return null;
1222
- return actions.map(function (action, index) {
1223
- return /*#__PURE__*/React.createElement("button", {
1224
- color: action.passive ? 'default' : 'secondary',
1225
- key: "action-".concat(index),
1226
- onClick: function onClick(event) {
1227
- return handler(event, action.handler);
1228
- }
1229
- }, action.name);
1230
- });
1231
- };
1232
- var getColors = function getColors(palette, type) {
1233
- var colors = {
1234
- "default": palette.background,
1235
- secondary: palette.secondary,
1236
- success: palette.success,
1237
- warning: palette.warning,
1238
- error: palette.error
1239
- };
1240
- var isDefault = !type || type === 'default';
1241
- if (isDefault) return {
1242
- bgColor: colors["default"],
1243
- color: palette.foreground
1244
- };
1245
- /**
1246
- * Prevent main color change in special types.
1247
- * The color will only follow the theme when it is in the default type.
1248
- */
1249
- return {
1250
- bgColor: colors[type],
1251
- color: 'white'
1252
- };
1253
- };
1254
- tuple('topLeft', 'topRight', 'bottomLeft', 'bottomRight');
1255
- var isTopPlacement = function isTopPlacement(placement) {
1256
- return "".concat(placement).toLowerCase().startsWith('top');
1257
- };
1258
- var isLeftPlacement = function isLeftPlacement(placement) {
1259
- return "".concat(placement).toLowerCase().endsWith('left');
1260
- };
1261
- var getTranslateByPlacement = function getTranslateByPlacement(placement) {
1262
- var translateInByPlacement = {
1263
- topLeft: 'translate(-60px, -60px)',
1264
- topRight: 'translate(60px, -60px)',
1265
- bottomLeft: 'translate(-60px, 60px)',
1266
- bottomRight: 'translate(60px, 60px)'
1267
- };
1268
- var translateOutByPlacement = {
1269
- topLeft: 'translate(-50px, 15px) scale(0.85)',
1270
- topRight: 'translate(50px, 15px) scale(0.85)',
1271
- bottomLeft: 'translate(-50px, -15px) scale(0.85)',
1272
- bottomRight: 'translate(50px, -15px) scale(0.85)'
1273
- };
1274
- return {
1275
- enter: translateInByPlacement[placement],
1276
- leave: translateOutByPlacement[placement]
1277
- };
1278
- };
1279
-
1280
- var ToastItem = /*#__PURE__*/React.memo(function (_ref) {
1281
- var toast = _ref.toast,
1282
- layout = _ref.layout;
1283
- var theme = useTheme();
1284
- var _useMemo = React.useMemo(function () {
1285
- return getColors(theme.palette, toast.type);
1286
- }, [theme.palette, toast.type]),
1287
- color = _useMemo.color,
1288
- bgColor = _useMemo.bgColor;
1289
- var isReactNode = typeof toast.text !== 'string';
1290
- var padding = layout.padding,
1291
- margin = layout.margin,
1292
- maxHeight = layout.maxHeight,
1293
- maxWidth = layout.maxWidth,
1294
- width = layout.width,
1295
- placement = layout.placement;
1296
- var _useMemo2 = React.useMemo(function () {
1297
- return getTranslateByPlacement(placement);
1298
- }, [placement]),
1299
- enter = _useMemo2.enter,
1300
- leave = _useMemo2.leave;
1301
- return /*#__PURE__*/React.createElement(CssTransition, {
1302
- name: "toast",
1303
- visible: toast.visible,
1304
- clearTime: 350
1305
- }, /*#__PURE__*/React.createElement("div", {
1306
- key: toast.id,
1307
- className: _JSXStyle.dynamic([["1407001838", [width, maxWidth, maxHeight, theme.palette.foreground, bgColor, color, theme.layout.radius, theme.expressiveness.shadowSmall, theme.layout.gapHalf, enter, margin, padding, margin, padding, leave]]]) + " " + "toast"
1308
- }, isReactNode ? toast.text : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
1309
- className: _JSXStyle.dynamic([["1407001838", [width, maxWidth, maxHeight, theme.palette.foreground, bgColor, color, theme.layout.radius, theme.expressiveness.shadowSmall, theme.layout.gapHalf, enter, margin, padding, margin, padding, leave]]]) + " " + "message"
1310
- }, toast.text), /*#__PURE__*/React.createElement("div", {
1311
- className: _JSXStyle.dynamic([["1407001838", [width, maxWidth, maxHeight, theme.palette.foreground, bgColor, color, theme.layout.radius, theme.expressiveness.shadowSmall, theme.layout.gapHalf, enter, margin, padding, margin, padding, leave]]]) + " " + "action"
1312
- }, makeToastActions(toast.actions, toast.cancel))), /*#__PURE__*/React.createElement(_JSXStyle, {
1313
- id: "1407001838",
1314
- dynamic: [width, maxWidth, maxHeight, theme.palette.foreground, bgColor, color, theme.layout.radius, theme.expressiveness.shadowSmall, theme.layout.gapHalf, enter, margin, padding, margin, padding, leave]
1315
- }, ".toast.__jsx-style-dynamic-selector{width:".concat(width, ";max-width:").concat(maxWidth, ";max-height:").concat(maxHeight, ";display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:justify;-webkit-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:").concat(theme.palette.foreground, ";background-color:").concat(bgColor, ";color:").concat(color, ";border:0;border-radius:").concat(theme.layout.radius, ";opacity:1;box-shadow:").concat(theme.expressiveness.shadowSmall, ";-webkit-transition:all 350ms cubic-bezier(0.1,0.2,0.1,1);transition:all 350ms cubic-bezier(0.1,0.2,0.1,1);overflow:hidden;}.message.__jsx-style-dynamic-selector{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;height:100%;font-size:0.875em;display:-webkit-box;word-break:break-all;padding-right:").concat(theme.layout.gapHalf, ";overflow:hidden;max-height:100%;text-overflow:ellipsis;-webkit-box-orient:vertical;-webkit-line-clamp:2;line-height:1.1rem;}.toast-enter.__jsx-style-dynamic-selector{opacity:0;height:0;padding:0;margin:0;-webkit-transform:").concat(enter, ";-ms-transform:").concat(enter, ";transform:").concat(enter, ";}.toast-enter-active.__jsx-style-dynamic-selector{opacity:1;height:auto;margin:").concat(margin, ";padding:").concat(padding, ";-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0);}.toast-leave.__jsx-style-dynamic-selector{opacity:1;-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0);height:auto;margin:").concat(margin, ";padding:").concat(padding, ";}.toast-leave-active.__jsx-style-dynamic-selector{opacity:0;-webkit-transform:").concat(leave, ";-ms-transform:").concat(leave, ";transform:").concat(leave, ";}"))));
1316
- });
1317
-
1318
- /* "use client" */
1319
-
1320
- var classObjectToString = function classObjectToString(className) {
1321
- var keys = Object.keys(className);
1322
- var len = keys.length;
1323
- var str = '';
1324
- for (var index = 0; index < len; index++) {
1325
- var key = keys[index];
1326
- var val = className[keys[index]];
1327
- if (!val) continue;
1328
- str = str ? "".concat(str, " ").concat(String(key)) : String(key);
1329
- }
1330
- return str;
1331
- };
1332
- var isObjectClassName = function isObjectClassName(value) {
1333
- return _typeof(value) === 'object' && !Array.isArray(value);
1334
- };
1335
- var useClasses = function useClasses() {
1336
- var len = arguments.length;
1337
- var classes = '';
1338
- if (len === 0) return classes;
1339
- for (var index = 0; index < len; index++) {
1340
- var val = index < 0 || arguments.length <= index ? undefined : arguments[index];
1341
- if (!val) continue;
1342
- if (isObjectClassName(val)) {
1343
- classes += " ".concat(classObjectToString(val));
1344
- } else {
1345
- classes += " ".concat(String(val).trim());
1346
- }
1347
- }
1348
- return classes.trim();
1349
- };
1350
-
1351
- var ToastContainer = function ToastContainer() {
1352
- var theme = useTheme();
1353
- var portal = usePortal('toast');
1354
- var _useCurrentState = useCurrentState(false),
1355
- _useCurrentState2 = _slicedToArray(_useCurrentState, 3),
1356
- setHovering = _useCurrentState2[1],
1357
- hoveringRef = _useCurrentState2[2];
1358
- var _useHUIContext = useHUIContext(),
1359
- toasts = _useHUIContext.toasts,
1360
- updateToasts = _useHUIContext.updateToasts,
1361
- toastLayout = _useHUIContext.toastLayout,
1362
- lastUpdateToastId = _useHUIContext.lastUpdateToastId;
1363
- var memoizedLayout = React.useMemo(function () {
1364
- return toastLayout;
1365
- }, [toastLayout]);
1366
- var toastElements = React.useMemo(function () {
1367
- return toasts.map(function (toast) {
1368
- return /*#__PURE__*/React.createElement(ToastItem, {
1369
- toast: toast,
1370
- layout: memoizedLayout,
1371
- key: toast._internalIdent
1372
- });
1373
- });
1374
- }, [toasts, memoizedLayout]);
1375
- var classNames = React.useMemo(function () {
1376
- return useClasses('toasts', {
1377
- top: isTopPlacement(toastLayout.placement),
1378
- left: isLeftPlacement(toastLayout.placement)
1379
- });
1380
- }, [memoizedLayout]);
1381
- var hoverHandler = function hoverHandler(isHovering) {
1382
- setHovering(isHovering);
1383
- if (isHovering) {
1384
- return updateToasts(function (last) {
1385
- return last.map(function (toast) {
1386
- if (!toast.visible) return toast;
1387
- toast._timeout && window.clearTimeout(toast._timeout);
1388
- return _objectSpread2(_objectSpread2({}, toast), {}, {
1389
- timeout: null
1390
- });
1391
- });
1392
- });
1393
- }
1394
- updateToasts(function (last) {
1395
- return last.map(function (toast, index) {
1396
- if (!toast.visible) return toast;
1397
- toast._timeout && window.clearTimeout(toast._timeout);
1398
- return _objectSpread2(_objectSpread2({}, toast), {}, {
1399
- _timeout: function () {
1400
- var timer = window.setTimeout(function () {
1401
- toast.cancel();
1402
- window.clearTimeout(timer);
1403
- }, toast.delay + index * 100);
1404
- return timer;
1405
- }()
1406
- });
1407
- });
1408
- });
1409
- };
1410
- React.useEffect(function () {
1411
- var index = toasts.findIndex(function (r) {
1412
- return r._internalIdent === lastUpdateToastId;
1413
- });
1414
- var toast = toasts[index];
1415
- if (!toast || toast.visible || !hoveringRef.current) return;
1416
- var hasVisible = toasts.find(function (r, i) {
1417
- return i < index && r.visible;
1418
- });
1419
- if (hasVisible || !hoveringRef.current) return;
1420
- hoverHandler(false);
1421
- }, [toasts, lastUpdateToastId]);
1422
- React.useEffect(function () {
1423
- var timeout = null;
1424
- var timer = window.setInterval(function () {
1425
- if (toasts.length === 0) return;
1426
- timeout = window.setTimeout(function () {
1427
- var allInvisible = !toasts.find(function (r) {
1428
- return r.visible;
1429
- });
1430
- allInvisible && updateToasts(function () {
1431
- return [];
1432
- });
1433
- timeout && clearTimeout(timeout);
1434
- }, 350);
1435
- }, 5000);
1436
- return function () {
1437
- timer && clearInterval(timer);
1438
- timeout && clearTimeout(timeout);
1439
- };
1440
- }, [toasts]);
1441
- if (!portal) return null;
1442
- if (!toasts || toasts.length === 0) return null;
1443
- return /*#__PURE__*/reactDom.createPortal(/*#__PURE__*/React.createElement("div", {
1444
- onMouseEnter: function onMouseEnter() {
1445
- return hoverHandler(true);
1446
- },
1447
- onMouseLeave: function onMouseLeave() {
1448
- return hoverHandler(false);
1449
- },
1450
- className: _JSXStyle.dynamic([["622610754", [theme.layout.gap, theme.layout.gap, theme.layout.gap, theme.layout.gap]]]) + " " + (classNames || "")
1451
- }, toastElements, /*#__PURE__*/React.createElement(_JSXStyle, {
1452
- id: "622610754",
1453
- dynamic: [theme.layout.gap, theme.layout.gap, theme.layout.gap, theme.layout.gap]
1454
- }, ".toasts.__jsx-style-dynamic-selector{position:fixed;width:auto;max-width:100%;right:".concat(theme.layout.gap, ";bottom:").concat(theme.layout.gap, ";z-index:2000;-webkit-transition:all 400ms ease;transition:all 400ms ease;box-sizing:border-box;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}.top.__jsx-style-dynamic-selector{bottom:unset;-webkit-flex-direction:column-reverse;-ms-flex-direction:column-reverse;flex-direction:column-reverse;top:").concat(theme.layout.gap, ";}.left.__jsx-style-dynamic-selector{right:unset;left:").concat(theme.layout.gap, ";}"))), portal);
1455
- };
1456
-
1457
- var HuiProvider = function HuiProvider(_ref) {
1458
- var themes = _ref.themes,
1459
- themeType = _ref.themeType,
1460
- children = _ref.children;
1461
- var _React$useState = React.useState(''),
1462
- _React$useState2 = _slicedToArray(_React$useState, 2),
1463
- lastUpdateToastId = _React$useState2[0],
1464
- setLastUpdateToastId = _React$useState2[1];
1465
- var _useCurrentState = useCurrentState([]),
1466
- _useCurrentState2 = _slicedToArray(_useCurrentState, 3),
1467
- toasts = _useCurrentState2[0],
1468
- setToasts = _useCurrentState2[1],
1469
- toastsRef = _useCurrentState2[2];
1470
- var _useCurrentState3 = useCurrentState(defaultToastLayout),
1471
- _useCurrentState4 = _slicedToArray(_useCurrentState3, 3),
1472
- toastLayout = _useCurrentState4[0],
1473
- setToastLayout = _useCurrentState4[1],
1474
- toastLayoutRef = _useCurrentState4[2];
1475
- var updateToasts = function updateToasts(fn) {
1476
- var nextToasts = fn(toastsRef.current);
1477
- setToasts(nextToasts);
1478
- };
1479
- var updateToastLayout = function updateToastLayout(fn) {
1480
- var nextLayout = fn(toastLayoutRef.current);
1481
- setToastLayout(nextLayout);
1482
- };
1483
- var updateLastToastId = function updateLastToastId(fn) {
1484
- setLastUpdateToastId(fn());
1485
- };
1486
- var initialValue = React.useMemo(function () {
1487
- return {
1488
- toasts: toasts,
1489
- toastLayout: toastLayout,
1490
- updateToasts: updateToasts,
1491
- lastUpdateToastId: lastUpdateToastId,
1492
- updateToastLayout: updateToastLayout,
1493
- updateLastToastId: updateLastToastId
1494
- };
1495
- }, [toasts, toastLayout, lastUpdateToastId]);
1496
- return /*#__PURE__*/React.createElement(HUIContent.Provider, {
1497
- value: initialValue
1498
- }, /*#__PURE__*/React.createElement(ThemeProvider, {
1499
- themes: themes,
1500
- themeType: themeType
1501
- }, children, /*#__PURE__*/React.createElement(ToastContainer, null)));
1502
- };
1503
-
1504
- // import flush from 'styled-jsx'
1505
-
1506
- // export type FlushToReact = <T>(opts?: { nonce?: string }) => Array<ReactElement<T>>
1507
-
1508
- // export type FlushToHTML = (opts?: { nonce?: string }) => string
1509
-
1510
- var CssBaseline = function CssBaseline(_ref) {
1511
- var children = _ref.children;
1512
- var theme = useTheme();
1513
- return /*#__PURE__*/React.createElement(React.Fragment, null, children, /*#__PURE__*/React.createElement(_JSXStyle, {
1514
- id: "3647548829",
1515
- dynamic: [theme.palette.background, theme.palette.foreground, theme.palette.background, theme.font.sans, theme.font.sans, theme.palette.link, theme.expressiveness.linkStyle, theme.expressiveness.linkHoverStyle, theme.layout.gapHalf, theme.layout.gapHalf, theme.layout.gapHalf, theme.layout.gap, theme.palette.foreground, theme.palette.code, theme.font.mono, theme.layout.gap, theme.layout.gap, theme.layout.gap, theme.palette.accents_2, theme.layout.radius, theme.font.mono, theme.palette.foreground, theme.palette.accents_2, theme.palette.accents_1, theme.layout.gap, theme.layout.gap, theme.palette.accents_5, theme.palette.accents_1, theme.layout.radius, theme.palette.border, theme.palette.selection, theme.palette.foreground]
1516
- }, "html,body{background-color:".concat(theme.palette.background, ";color:").concat(theme.palette.foreground, ";}html{font-size:16px;--helpdice-icons-background:").concat(theme.palette.background, ";}body{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-rendering:optimizeLegibility;font-size:1rem;line-height:1.5;margin:0;padding:0;min-height:100%;position:relative;overflow-x:hidden;font-family:").concat(theme.font.sans, ";}#__next{overflow-x:hidden;}*,*:before,*:after{box-sizing:inherit;text-rendering:geometricPrecision;-webkit-tap-highlight-color:transparent;}p,small{font-weight:400;color:inherit;-webkit-letter-spacing:-0.005625em;-moz-letter-spacing:-0.005625em;-ms-letter-spacing:-0.005625em;letter-spacing:-0.005625em;font-family:").concat(theme.font.sans, ";}p{margin:1em 0;font-size:1em;line-height:1.625em;}small{margin:0;line-height:1.5;font-size:0.875em;}b{font-weight:600;}span{font-size:inherit;color:inherit;font-weight:inherit;}img{max-width:100%;}a{cursor:pointer;font-size:inherit;-webkit-touch-callout:none;-webkit-tap-highlight-color:rgba(0,0,0,0);-webkit-box-align:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:").concat(theme.palette.link, ";-webkit-text-decoration:").concat(theme.expressiveness.linkStyle, ";text-decoration:").concat(theme.expressiveness.linkStyle, ";}a:hover{-webkit-text-decoration:").concat(theme.expressiveness.linkHoverStyle, ";text-decoration:").concat(theme.expressiveness.linkHoverStyle, ";}ul,ol{padding:0;list-style-type:none;margin:").concat(theme.layout.gapHalf, " ").concat(theme.layout.gapHalf, " ").concat(theme.layout.gapHalf, " ").concat(theme.layout.gap, ";color:").concat(theme.palette.foreground, ";}ol{list-style-type:decimal;}li{margin-bottom:0.625em;font-size:1em;line-height:1.625em;}h1,h2,h3,h4,h5,h6{color:inherit;margin:0 0 0.7rem 0;}h1{font-size:3rem;-webkit-letter-spacing:-0.02em;-moz-letter-spacing:-0.02em;-ms-letter-spacing:-0.02em;letter-spacing:-0.02em;line-height:1.5;font-weight:700;}h2{font-size:2.25rem;-webkit-letter-spacing:-0.02em;-moz-letter-spacing:-0.02em;-ms-letter-spacing:-0.02em;letter-spacing:-0.02em;font-weight:600;}h3{font-size:1.5rem;-webkit-letter-spacing:-0.02em;-moz-letter-spacing:-0.02em;-ms-letter-spacing:-0.02em;letter-spacing:-0.02em;font-weight:600;}h4{font-size:1.25rem;-webkit-letter-spacing:-0.02em;-moz-letter-spacing:-0.02em;-ms-letter-spacing:-0.02em;letter-spacing:-0.02em;font-weight:600;}h5{font-size:1rem;-webkit-letter-spacing:-0.01em;-moz-letter-spacing:-0.01em;-ms-letter-spacing:-0.01em;letter-spacing:-0.01em;font-weight:600;}h6{font-size:0.875rem;-webkit-letter-spacing:-0.005em;-moz-letter-spacing:-0.005em;-ms-letter-spacing:-0.005em;letter-spacing:-0.005em;font-weight:600;}button,input,select,textarea{font-family:inherit;font-size:inherit;line-height:inherit;color:inherit;margin:0;}button:focus,input:focus,select:focus,textarea:focus{outline:none;}code{color:").concat(theme.palette.code, ";font-family:").concat(theme.font.mono, ";font-size:0.9em;white-space:pre-wrap;}code:before,code:after{content:'\\`';}pre{padding:calc(").concat(theme.layout.gap, " * 0.9) ").concat(theme.layout.gap, ";margin:").concat(theme.layout.gap, " 0;border:1px solid ").concat(theme.palette.accents_2, ";border-radius:").concat(theme.layout.radius, ";font-family:").concat(theme.font.mono, ";white-space:pre;overflow:auto;line-height:1.5;text-align:left;font-size:14px;-webkit-overflow-scrolling:touch;}pre code{color:").concat(theme.palette.foreground, ";font-size:1em;line-height:1.25em;white-space:pre;}pre code:before,pre code:after{display:none;}pre p{margin:0;}pre::-webkit-scrollbar{display:none;width:0;height:0;background:transparent;}hr{border-color:").concat(theme.palette.accents_2, ";}details{background-color:").concat(theme.palette.accents_1, ";border:none;}details:focus,details:hover,details:active{outline:none;}summary{cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;list-style:none;outline:none;}summary::marker,summary::before,summary::-webkit-details-marker{display:none;}summary::-moz-list-bullet{font-size:0;}summary:focus,summary:hover,summary:active{outline:none;list-style:none;}blockquote{padding:calc(0.667 * ").concat(theme.layout.gap, ") ").concat(theme.layout.gap, ";color:").concat(theme.palette.accents_5, ";background-color:").concat(theme.palette.accents_1, ";border-radius:").concat(theme.layout.radius, ";margin:1.5em 0;border:1px solid ").concat(theme.palette.border, ";}blockquote *:first-child{margin-top:0;}blockquote *:last-child{margin-bottom:0;}::selection{background-color:").concat(theme.palette.selection, ";color:").concat(theme.palette.foreground, ";}")));
1517
- };
1518
- var MemoCssBaseline = /*#__PURE__*/React.memo(CssBaseline);
1519
-
1520
- var getElementOffset = function getElementOffset(el) {
1521
- if (!el) return {
1522
- top: 0,
1523
- left: 0
1524
- };
1525
- var _el$getBoundingClient = el.getBoundingClientRect(),
1526
- top = _el$getBoundingClient.top,
1527
- left = _el$getBoundingClient.left;
1528
- return {
1529
- top: top,
1530
- left: left
1531
- };
1532
- };
1533
- var defaultRect$1 = {
1534
- top: -1e3,
1535
- left: -1e3,
1536
- right: -1e3,
1537
- width: 0,
1538
- height: 0,
1539
- elementTop: -1e3
1540
- };
1541
- var getRectFromDOMWithContainer = function getRectFromDOMWithContainer(domRect, getContainer) {
1542
- if (!domRect) return defaultRect$1;
1543
- var container = getContainer ? getContainer() : null;
1544
- var scrollElement = container || document.documentElement;
1545
- var _getElementOffset = getElementOffset(container),
1546
- offsetTop = _getElementOffset.top,
1547
- offsetLeft = _getElementOffset.left;
1548
- return _objectSpread2(_objectSpread2({}, domRect), {}, {
1549
- width: domRect.width || domRect.right - domRect.left,
1550
- height: domRect.height || domRect.top - domRect.bottom,
1551
- top: domRect.bottom + scrollElement.scrollTop - offsetTop,
1552
- left: domRect.left + scrollElement.scrollLeft - offsetLeft,
1553
- elementTop: domRect.top + scrollElement.scrollTop - offsetTop
1554
- });
1555
- };
1556
- var isUnplacedRect = function isUnplacedRect(rect) {
1557
- if (!rect) return true;
1558
- return rect.top === defaultRect$1.top && rect.left === defaultRect$1.left;
1559
- };
1560
- var getRefRect = function getRefRect(ref, getContainer) {
1561
- if (!ref || !ref.current) return defaultRect$1;
1562
- var rect = ref.current.getBoundingClientRect();
1563
- return getRectFromDOMWithContainer(rect, getContainer);
1564
- };
1565
- var getEventRect = function getEventRect(event, getContainer) {
1566
- var _event$target;
1567
- var rect = event === null || event === void 0 || (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.getBoundingClientRect();
1568
- if (!rect) return defaultRect$1;
1569
- return getRectFromDOMWithContainer(rect, getContainer);
1570
- };
1571
- var isRefTarget = function isRefTarget(eventOrRef) {
1572
- return typeof (eventOrRef === null || eventOrRef === void 0 ? void 0 : eventOrRef.target) === 'undefined';
1573
- };
1574
- var useRect = function useRect(initialState) {
1575
- var _useState = React.useState(initialState || defaultRect$1),
1576
- _useState2 = _slicedToArray(_useState, 2),
1577
- rect = _useState2[0],
1578
- setRect = _useState2[1];
1579
- var updateRect = function updateRect(eventOrRef, getContainer) {
1580
- if (isRefTarget(eventOrRef)) return setRect(getRefRect(eventOrRef, getContainer));
1581
- setRect(getEventRect(eventOrRef, getContainer));
1582
- };
1583
- return {
1584
- rect: rect,
1585
- setRect: updateRect
1586
- };
1587
- };
1588
-
1589
- var defaultToast = {
1590
- delay: 2000,
1591
- type: 'default'
1592
- };
1593
- var useToasts = function useToasts(layout) {
1594
- var _useHUIContext = useHUIContext(),
1595
- updateToasts = _useHUIContext.updateToasts,
1596
- toasts = _useHUIContext.toasts,
1597
- updateToastLayout = _useHUIContext.updateToastLayout,
1598
- updateLastToastId = _useHUIContext.updateLastToastId;
1599
- React.useEffect(function () {
1600
- if (!layout) return;
1601
- updateToastLayout(function () {
1602
- return layout ? _objectSpread2(_objectSpread2({}, defaultToastLayout), layout) : defaultToastLayout;
1603
- });
1604
- }, []);
1605
- var _cancel = function cancel(internalId) {
1606
- updateToasts(function (currentToasts) {
1607
- return currentToasts.map(function (item) {
1608
- if (item._internalIdent !== internalId) return item;
1609
- return _objectSpread2(_objectSpread2({}, item), {}, {
1610
- visible: false
1611
- });
1612
- });
1613
- });
1614
- updateLastToastId(function () {
1615
- return internalId;
1616
- });
1617
- };
1618
- var removeAll = function removeAll() {
1619
- updateToasts(function (last) {
1620
- return last.map(function (toast) {
1621
- return _objectSpread2(_objectSpread2({}, toast), {}, {
1622
- visible: false
1623
- });
1624
- });
1625
- });
1626
- };
1627
- var findToastOneByID = function findToastOneByID(id) {
1628
- return toasts.find(function (t) {
1629
- return t.id === id;
1630
- });
1631
- };
1632
- var removeToastOneByID = function removeToastOneByID(id) {
1633
- updateToasts(function (last) {
1634
- return last.map(function (toast) {
1635
- if (toast.id !== id) return toast;
1636
- return _objectSpread2(_objectSpread2({}, toast), {}, {
1637
- visible: false
1638
- });
1639
- });
1640
- });
1641
- };
1642
- var setToast = function setToast(toast) {
1643
- var internalIdent = "toast-".concat(getId());
1644
- var delay = toast.delay || defaultToast.delay;
1645
- if (toast.id) {
1646
- var hasIdent = toasts.find(function (t) {
1647
- return t.id === toast.id;
1648
- });
1649
- if (hasIdent) {
1650
- throw new Error('Toast: Already have the same key: "ident"');
1651
- }
1652
- }
1653
- updateToasts(function (last) {
1654
- var newToast = {
1655
- delay: delay,
1656
- text: toast.text,
1657
- visible: true,
1658
- type: toast.type || defaultToast.type,
1659
- id: toast.id || internalIdent,
1660
- actions: toast.actions || [],
1661
- _internalIdent: internalIdent,
1662
- _timeout: window.setTimeout(function () {
1663
- _cancel(internalIdent);
1664
- if (newToast._timeout) {
1665
- window.clearTimeout(newToast._timeout);
1666
- newToast._timeout = null;
1667
- }
1668
- }, delay),
1669
- cancel: function cancel() {
1670
- return _cancel(internalIdent);
1671
- }
1672
- };
1673
- return [].concat(_toConsumableArray(last), [newToast]);
1674
- });
1675
- };
1676
- return {
1677
- toasts: toasts,
1678
- setToast: setToast,
1679
- removeAll: removeAll,
1680
- findToastOneByID: findToastOneByID,
1681
- removeToastOneByID: removeToastOneByID
1682
- };
1683
- };
1684
-
1685
- tuple('xs', 'sm', 'md', 'lg', 'xl', 'mobile');
1686
- tuple('up', 'down', 'default');
1687
- var defaultResponsiveOptions = {
1688
- match: 'default'
1689
- };
1690
- var makeQueries = function makeQueries(bp, up, down) {
1691
- var queryString = function queryString(item) {
1692
- var upQuery = "(min-width: ".concat(item.min, ")");
1693
- var downQuery = "(max-width: ".concat(item.max, ")");
1694
- return up ? upQuery : down ? downQuery : "".concat(upQuery, " and ").concat(downQuery);
1695
- };
1696
- var xs = queryString(bp.xs);
1697
- return {
1698
- xs: xs,
1699
- mobile: xs,
1700
- sm: queryString(bp.sm),
1701
- md: queryString(bp.md),
1702
- lg: queryString(bp.lg),
1703
- xl: queryString(bp.xl)
1704
- };
1705
- };
1706
- var useMediaQuery = function useMediaQuery(breakpoint) {
1707
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultResponsiveOptions;
1708
- var _options$match = options.match,
1709
- matchType = _options$match === void 0 ? 'default' : _options$match,
1710
- _options$ssrMatchMedi = options.ssrMatchMedia,
1711
- ssrMatchMedia = _options$ssrMatchMedi === void 0 ? null : _options$ssrMatchMedi;
1712
- var supportMedia = typeof window !== 'undefined' && typeof window.matchMedia !== 'undefined';
1713
- var theme = useTheme();
1714
- var mediaQueries = React.useMemo(function () {
1715
- var up = matchType === 'up';
1716
- var down = matchType === 'down';
1717
- return makeQueries(theme.breakpoints, up, down);
1718
- }, [theme.breakpoints, options]);
1719
- var query = React.useMemo(function () {
1720
- return mediaQueries[breakpoint];
1721
- }, [mediaQueries, breakpoint]);
1722
- var matchQuery = function matchQuery(q) {
1723
- return window.matchMedia(q);
1724
- };
1725
-
1726
- /**
1727
- * Do nothing in the server-side rendering.
1728
- * If server match query fucntion is simulated, return user-defined value first.
1729
- */
1730
- var _useState = React.useState(function () {
1731
- if (supportMedia) return matchQuery(query).matches;
1732
- if (ssrMatchMedia && typeof ssrMatchMedia === 'function') {
1733
- return ssrMatchMedia(query).matches;
1734
- }
1735
- return false;
1736
- }),
1737
- _useState2 = _slicedToArray(_useState, 2),
1738
- state = _useState2[0],
1739
- setState = _useState2[1];
1740
- React.useEffect(function () {
1741
- if (!supportMedia) return;
1742
- var queryList = matchQuery(query);
1743
- var update = function update() {
1744
- return setState(matchQuery(query).matches);
1745
- };
1746
- update();
1747
-
1748
- /**
1749
- * addListener is deprecated. EventTarget.addEventListener is recommended.
1750
- * But in some old browsers, MediaQueryList does not inherit from EventTarget.
1751
- */
1752
- queryList.addListener(update);
1753
- return function () {
1754
- queryList.removeListener(update);
1755
- };
1756
- }, [supportMedia]);
1757
- return state;
1758
- };
1759
-
1760
- /* "use client" */
1761
-
1762
- var usePrevious = function usePrevious(state) {
1763
- var ref = React.useRef(null);
1764
- React.useEffect(function () {
1765
- ref.current = state;
1766
- });
1767
- return ref ? ref.current : null;
1768
- };
1769
-
1770
- var _excluded$1 = ["rect", "visible", "hoverHeightRatio", "hoverWidthRatio", "activeOpacity", "className"];
1771
- var Highlight = function Highlight(_ref) {
1772
- var rect = _ref.rect,
1773
- visible = _ref.visible,
1774
- _ref$hoverHeightRatio = _ref.hoverHeightRatio,
1775
- hoverHeightRatio = _ref$hoverHeightRatio === void 0 ? 1 : _ref$hoverHeightRatio,
1776
- _ref$hoverWidthRatio = _ref.hoverWidthRatio,
1777
- hoverWidthRatio = _ref$hoverWidthRatio === void 0 ? 1 : _ref$hoverWidthRatio,
1778
- _ref$activeOpacity = _ref.activeOpacity,
1779
- activeOpacity = _ref$activeOpacity === void 0 ? 0.8 : _ref$activeOpacity,
1780
- className = _ref.className,
1781
- props = _objectWithoutProperties(_ref, _excluded$1);
1782
- var theme = useTheme();
1783
- var ref = React.useRef(null);
1784
- var isFirstVisible = usePrevious(isUnplacedRect(rect));
1785
- var position = React.useMemo(function () {
1786
- var width = rect.width * hoverWidthRatio;
1787
- var height = rect.height * hoverHeightRatio;
1788
- return {
1789
- width: "".concat(width, "px"),
1790
- left: "".concat(rect.left + (rect.width - width) / 2, "px"),
1791
- height: "".concat(height, "px"),
1792
- top: "".concat(rect.elementTop + (rect.height - height) / 2, "px"),
1793
- transition: isFirstVisible ? 'opacity' : 'opacity, width, left, top'
1794
- };
1795
- }, [rect, hoverWidthRatio, hoverHeightRatio]);
1796
- return /*#__PURE__*/React.createElement("div", _extends({
1797
- ref: ref
1798
- }, props, {
1799
- className: _JSXStyle.dynamic([["603024321", [theme.palette.accents_2, position.width, position.left, position.height, position.top, visible ? activeOpacity : 0, position.transition]]]) + " " + (props && props.className != null && props.className || useClasses('highlight', className) || "")
1800
- }), /*#__PURE__*/React.createElement(_JSXStyle, {
1801
- id: "603024321",
1802
- dynamic: [theme.palette.accents_2, position.width, position.left, position.height, position.top, visible ? activeOpacity : 0, position.transition]
1803
- }, ".highlight.__jsx-style-dynamic-selector{background:".concat(theme.palette.accents_2, ";position:absolute;border-radius:5px;width:").concat(position.width, ";left:").concat(position.left, ";height:").concat(position.height, ";top:").concat(position.top, ";opacity:").concat(visible ? activeOpacity : 0, ";-webkit-transition:0.15s ease;transition:0.15s ease;-webkit-transition-property:").concat(position.transition, ";transition-property:").concat(position.transition, ";}")));
1804
- };
1805
-
1806
- var Ellipsis = function Ellipsis(_ref) {
1807
- var children = _ref.children,
1808
- height = _ref.height;
1809
- return /*#__PURE__*/React.createElement("span", {
1810
- className: _JSXStyle.dynamic([["822089635", [height]]])
1811
- }, children, /*#__PURE__*/React.createElement(_JSXStyle, {
1812
- id: "822089635",
1813
- dynamic: [height]
1814
- }, "span.__jsx-style-dynamic-selector{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:".concat(height, ";min-width:0;}")));
1815
- };
1816
- var ellipsis = /*#__PURE__*/React.memo(Ellipsis);
1817
-
1818
- var getRealShape = function getRealShape(el) {
1819
- var defaultShape = {
1820
- width: 0,
1821
- height: 0
1822
- };
1823
- if (!el || typeof window === 'undefined') return defaultShape;
1824
- var rect = el.getBoundingClientRect();
1825
- var _window$getComputedSt = window.getComputedStyle(el),
1826
- width = _window$getComputedSt.width,
1827
- height = _window$getComputedSt.height;
1828
- var getCSSStyleVal = function getCSSStyleVal(str, parentNum) {
1829
- if (!str) return 0;
1830
- var strVal = str.includes('px') ? +str.split('px')[0] : str.includes('%') ? +str.split('%')[0] * parentNum * 0.01 : str;
1831
- return Number.isNaN(+strVal) ? 0 : +strVal;
1832
- };
1833
- return {
1834
- width: getCSSStyleVal("".concat(width), rect.width),
1835
- height: getCSSStyleVal("".concat(height), rect.height)
1836
- };
1837
- };
1838
- var useRealShape = function useRealShape(ref) {
1839
- var _useState = React.useState({
1840
- width: 0,
1841
- height: 0
1842
- }),
1843
- _useState2 = _slicedToArray(_useState, 2),
1844
- state = _useState2[0],
1845
- setState = _useState2[1];
1846
- var update = function update() {
1847
- var _getRealShape = getRealShape(ref.current),
1848
- width = _getRealShape.width,
1849
- height = _getRealShape.height;
1850
- setState({
1851
- width: width,
1852
- height: height
1853
- });
1854
- };
1855
- React.useEffect(function () {
1856
- return update();
1857
- }, [ref.current]);
1858
- return [state, update];
1859
- };
1860
-
1861
- var Expand = function Expand(_ref) {
1862
- var _ref$isExpanded = _ref.isExpanded,
1863
- isExpanded = _ref$isExpanded === void 0 ? false : _ref$isExpanded,
1864
- _ref$delay = _ref.delay,
1865
- delay = _ref$delay === void 0 ? 200 : _ref$delay,
1866
- children = _ref.children;
1867
- var _useState = React.useState(isExpanded ? 'auto' : '0'),
1868
- _useState2 = _slicedToArray(_useState, 2),
1869
- height = _useState2[0],
1870
- setHeight = _useState2[1];
1871
- var _useState3 = React.useState(isExpanded),
1872
- _useState4 = _slicedToArray(_useState3, 2),
1873
- selfExpanded = _useState4[0],
1874
- setSelfExpanded = _useState4[1];
1875
- var _useState5 = React.useState(isExpanded),
1876
- _useState6 = _slicedToArray(_useState5, 2),
1877
- visible = _useState6[0],
1878
- setVisible = _useState6[1];
1879
- var contentRef = React.useRef(null);
1880
- var entryTimer = React.useRef();
1881
- var leaveTimer = React.useRef();
1882
- var resetTimer = React.useRef();
1883
- var _useRealShape = useRealShape(contentRef),
1884
- _useRealShape2 = _slicedToArray(_useRealShape, 2),
1885
- state = _useRealShape2[0],
1886
- updateShape = _useRealShape2[1];
1887
- var classes = useClasses('container', {
1888
- expanded: selfExpanded
1889
- });
1890
- React.useEffect(function () {
1891
- return setHeight("".concat(state.height, "px"));
1892
- }, [state.height]);
1893
- React.useEffect(function () {
1894
- // show element or reset height.
1895
- // force an update once manually, even if the element does not change.
1896
- // (the height of the element might be "auto")
1897
- if (isExpanded) {
1898
- setVisible(isExpanded);
1899
- } else {
1900
- updateShape();
1901
- setHeight("".concat(state.height, "px"));
1902
- }
1903
-
1904
- // show expand animation
1905
- entryTimer.current = window.setTimeout(function () {
1906
- setSelfExpanded(isExpanded);
1907
- clearTimeout(entryTimer.current);
1908
- }, 30);
1909
-
1910
- // Reset height after animation
1911
- if (isExpanded) {
1912
- resetTimer.current = window.setTimeout(function () {
1913
- setHeight('auto');
1914
- clearTimeout(resetTimer.current);
1915
- }, delay);
1916
- } else {
1917
- leaveTimer.current = window.setTimeout(function () {
1918
- setVisible(isExpanded);
1919
- clearTimeout(leaveTimer.current);
1920
- }, delay / 2);
1921
- }
1922
- return function () {
1923
- clearTimeout(entryTimer.current);
1924
- clearTimeout(leaveTimer.current);
1925
- clearTimeout(resetTimer.current);
1926
- };
1927
- }, [isExpanded]);
1928
- return /*#__PURE__*/React.createElement("div", {
1929
- className: _JSXStyle.dynamic([["1918690829", [visible ? 'visible' : 'hidden', delay, height]]]) + " " + (classes || "")
1930
- }, /*#__PURE__*/React.createElement("div", {
1931
- ref: contentRef,
1932
- className: _JSXStyle.dynamic([["1918690829", [visible ? 'visible' : 'hidden', delay, height]]]) + " " + "content"
1933
- }, children), /*#__PURE__*/React.createElement(_JSXStyle, {
1934
- id: "1918690829",
1935
- dynamic: [visible ? 'visible' : 'hidden', delay, height]
1936
- }, ".container.__jsx-style-dynamic-selector{padding:0;margin:0;height:0;overflow:hidden;visibility:".concat(visible ? 'visible' : 'hidden', ";-webkit-transition:height ").concat(delay, "ms ease;transition:height ").concat(delay, "ms ease;}.expanded.__jsx-style-dynamic-selector{height:").concat(height, ";visibility:visible;}")));
1937
- };
1938
- Expand.displayName = 'Expand';
1939
-
1940
- /* "use client" */
1941
-
1942
- var useResize = function useResize(callback) {
1943
- var immediatelyInvoke = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
1944
- React.useEffect(function () {
1945
- var fn = function fn() {
1946
- return callback();
1947
- };
1948
- if (immediatelyInvoke) {
1949
- fn();
1950
- }
1951
- window.addEventListener('resize', fn);
1952
- return function () {
1953
- return window.removeEventListener('resize', fn);
1954
- };
1955
- }, []);
1956
- };
1957
-
1958
- /* "use client" */
1959
-
1960
- var useClickAnyWhere = function useClickAnyWhere(handler) {
1961
- React.useEffect(function () {
1962
- var callback = function callback(event) {
1963
- return handler(event);
1964
- };
1965
- document.addEventListener('click', callback);
1966
- return function () {
1967
- return document.removeEventListener('click', callback);
1968
- };
1969
- }, [handler]);
1970
- };
1971
-
1972
- /* "use client" */
1973
-
1974
- var useDOMObserver = function useDOMObserver(ref) {
1975
- var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
1976
- var config = {
1977
- attributes: false,
1978
- childList: true,
1979
- subtree: true
1980
- };
1981
- React.useEffect(function () {
1982
- if (!ref || !ref.current) return;
1983
- var unmount = false;
1984
- var done = function done() {
1985
- if (unmount) return;
1986
- callback.apply(void 0, arguments);
1987
- };
1988
- var observer = new MutationObserver(done);
1989
- observer.observe(ref.current, config);
1990
- return function () {
1991
- unmount = true;
1992
- observer.disconnect();
1993
- };
1994
- }, [ref]);
1995
- };
1996
-
1997
- var warningStack = {};
1998
- var useWarning = function useWarning(message, component) {
1999
- var tag = ' ';
2000
- var log = "[Helpdice UI]".concat(tag, ": ").concat(message);
2001
- if (typeof console === 'undefined') return;
2002
- if (warningStack[log]) return;
2003
- warningStack[log] = true;
2004
- if (process.env.NODE_ENV !== 'production') {
2005
- return console.error(log);
2006
- }
2007
- console.warn(log);
2008
- };
2009
-
2010
- var defaultRect = {
2011
- top: -1e3,
2012
- left: -1e3,
2013
- right: -1e3,
2014
- width: 0
2015
- };
2016
- var Dropdown = /*#__PURE__*/React.memo(function (_ref) {
2017
- var children = _ref.children,
2018
- parent = _ref.parent,
2019
- visible = _ref.visible,
2020
- disableMatchWidth = _ref.disableMatchWidth,
2021
- getPopupContainer = _ref.getPopupContainer;
2022
- var el = usePortal('dropdown', getPopupContainer);
2023
- var _useState = React.useState(defaultRect),
2024
- _useState2 = _slicedToArray(_useState, 2),
2025
- rect = _useState2[0],
2026
- setRect = _useState2[1];
2027
- var classes = useClasses('dropdown', disableMatchWidth ? 'disable-match' : 'width-match');
2028
- if (!parent) return null;
2029
-
2030
- /* istanbul ignore next */
2031
- if (process.env.NODE_ENV !== 'production') {
2032
- if (getPopupContainer && getPopupContainer()) {
2033
- var _el = getPopupContainer();
2034
- var style = window.getComputedStyle(_el);
2035
- if (style.position === 'static') {
2036
- useWarning('The element specified by "getPopupContainer" must have "position" set.');
2037
- }
2038
- }
2039
- }
2040
- var updateRect = function updateRect() {
2041
- var _getRefRect = getRefRect(parent, getPopupContainer),
2042
- top = _getRefRect.top,
2043
- left = _getRefRect.left,
2044
- right = _getRefRect.right,
2045
- nativeWidth = _getRefRect.width;
2046
- setRect({
2047
- top: top,
2048
- left: left,
2049
- right: right,
2050
- width: nativeWidth
2051
- });
2052
- };
2053
- useResize(updateRect);
2054
- useClickAnyWhere(function () {
2055
- var _getRefRect2 = getRefRect(parent, getPopupContainer),
2056
- top = _getRefRect2.top,
2057
- left = _getRefRect2.left;
2058
- var shouldUpdatePosition = top !== rect.top || left !== rect.left;
2059
- if (!shouldUpdatePosition) return;
2060
- updateRect();
2061
- });
2062
- useDOMObserver(parent, function () {
2063
- updateRect();
2064
- });
2065
- React.useEffect(function () {
2066
- if (!parent || !parent.current) return;
2067
- parent.current.addEventListener('mouseenter', updateRect);
2068
- /* istanbul ignore next */
2069
- return function () {
2070
- if (!parent || !parent.current) return;
2071
- parent.current.removeEventListener('mouseenter', updateRect);
2072
- };
2073
- }, [parent]);
2074
- var clickHandler = function clickHandler(event) {
2075
- event.stopPropagation();
2076
- event.nativeEvent.stopImmediatePropagation();
2077
- event.preventDefault();
2078
- };
2079
- var mouseDownHandler = function mouseDownHandler(event) {
2080
- event.preventDefault();
2081
- };
2082
- if (!el) return null;
2083
- return /*#__PURE__*/reactDom.createPortal(/*#__PURE__*/React.createElement(CssTransition, {
2084
- visible: visible
2085
- }, /*#__PURE__*/React.createElement("div", {
2086
- onClick: clickHandler,
2087
- onMouseDown: mouseDownHandler,
2088
- className: _JSXStyle.dynamic([["1644673105", [rect.top + 2, rect.left, rect.width, rect.width]]]) + " " + (classes || "")
2089
- }, children, /*#__PURE__*/React.createElement(_JSXStyle, {
2090
- id: "1644673105",
2091
- dynamic: [rect.top + 2, rect.left, rect.width, rect.width]
2092
- }, ".dropdown.__jsx-style-dynamic-selector{position:absolute;top:".concat(rect.top + 2, "px;left:").concat(rect.left, "px;z-index:1100;}.width-match.__jsx-style-dynamic-selector{width:").concat(rect.width, "px;}.disable-match.__jsx-style-dynamic-selector{min-width:").concat(rect.width, "px;}")))), el);
2093
- });
2094
-
2095
- var _excluded = ["children", "onClick", "visible", "width", "onContentClick", "backdropClassName", "positionClassName", "layerClassName"];
2096
- var Backdrop = /*#__PURE__*/React.memo(function (_ref) {
2097
- var children = _ref.children,
2098
- _ref$onClick = _ref.onClick,
2099
- onClick = _ref$onClick === void 0 ? function () {} : _ref$onClick,
2100
- _ref$visible = _ref.visible,
2101
- visible = _ref$visible === void 0 ? false : _ref$visible,
2102
- width = _ref.width,
2103
- _ref$onContentClick = _ref.onContentClick,
2104
- onContentClick = _ref$onContentClick === void 0 ? function () {} : _ref$onContentClick,
2105
- _ref$backdropClassNam = _ref.backdropClassName,
2106
- backdropClassName = _ref$backdropClassNam === void 0 ? '' : _ref$backdropClassNam,
2107
- _ref$positionClassNam = _ref.positionClassName,
2108
- positionClassName = _ref$positionClassNam === void 0 ? '' : _ref$positionClassNam,
2109
- _ref$layerClassName = _ref.layerClassName,
2110
- layerClassName = _ref$layerClassName === void 0 ? '' : _ref$layerClassName,
2111
- props = _objectWithoutProperties(_ref, _excluded);
2112
- var theme = useTheme();
2113
- var _useCurrentState = useCurrentState(false),
2114
- _useCurrentState2 = _slicedToArray(_useCurrentState, 3),
2115
- setIsContentMouseDown = _useCurrentState2[1],
2116
- IsContentMouseDownRef = _useCurrentState2[2];
2117
- var clickHandler = function clickHandler(event) {
2118
- if (IsContentMouseDownRef.current) return;
2119
- onClick && onClick(event);
2120
- };
2121
- var mouseUpHandler = function mouseUpHandler() {
2122
- if (!IsContentMouseDownRef.current) return;
2123
- var timer = setTimeout(function () {
2124
- setIsContentMouseDown(false);
2125
- clearTimeout(timer);
2126
- }, 0);
2127
- };
2128
- return /*#__PURE__*/React.createElement(CssTransition, {
2129
- name: "backdrop-wrapper",
2130
- visible: visible,
2131
- clearTime: 300
2132
- }, /*#__PURE__*/React.createElement("div", _extends({
2133
- onClick: clickHandler,
2134
- onMouseUp: mouseUpHandler
2135
- }, props, {
2136
- className: _JSXStyle.dynamic([["2021762493", [width, theme.expressiveness.portalOpacity, theme.expressiveness.portalOpacity, theme.expressiveness.portalOpacity]]]) + " " + (props && props.className != null && props.className || useClasses('backdrop', backdropClassName) || "")
2137
- }), /*#__PURE__*/React.createElement("div", {
2138
- className: _JSXStyle.dynamic([["2021762493", [width, theme.expressiveness.portalOpacity, theme.expressiveness.portalOpacity, theme.expressiveness.portalOpacity]]]) + " " + (useClasses('layer', layerClassName) || "")
2139
- }), /*#__PURE__*/React.createElement("div", {
2140
- onClick: onContentClick,
2141
- onMouseDown: function onMouseDown() {
2142
- return setIsContentMouseDown(true);
2143
- },
2144
- className: _JSXStyle.dynamic([["2021762493", [width, theme.expressiveness.portalOpacity, theme.expressiveness.portalOpacity, theme.expressiveness.portalOpacity]]]) + " " + (useClasses('position', positionClassName) || "")
2145
- }, children), /*#__PURE__*/React.createElement(_JSXStyle, {
2146
- id: "2021762493",
2147
- dynamic: [width, theme.expressiveness.portalOpacity, theme.expressiveness.portalOpacity, theme.expressiveness.portalOpacity]
2148
- }, ".backdrop.__jsx-style-dynamic-selector{position:fixed;top:0;left:0;right:0;bottom:0;overflow:auto;z-index:1000;-webkit-overflow-scrolling:touch;box-sizing:border-box;text-align:center;}.position.__jsx-style-dynamic-selector{position:relative;z-index:1001;outline:none;max-width:90%;width:".concat(width, ";margin:20px auto;vertical-align:middle;display:inline-block;}.backdrop.__jsx-style-dynamic-selector:before{display:inline-block;width:0;height:100%;vertical-align:middle;content:'';}.layer.__jsx-style-dynamic-selector{position:fixed;top:0;left:0;right:0;bottom:0;width:100%;height:100%;opacity:").concat(theme.expressiveness.portalOpacity, ";background-color:black;-webkit-transition:opacity 0.35s cubic-bezier(0.4,0,0.2,1);transition:opacity 0.35s cubic-bezier(0.4,0,0.2,1);pointer-events:none;z-index:1000;}.backdrop-wrapper-enter.__jsx-style-dynamic-selector .layer.__jsx-style-dynamic-selector{opacity:0;}.backdrop-wrapper-enter-active.__jsx-style-dynamic-selector .layer.__jsx-style-dynamic-selector{opacity:").concat(theme.expressiveness.portalOpacity, ";}.backdrop-wrapper-leave.__jsx-style-dynamic-selector .layer.__jsx-style-dynamic-selector{opacity:").concat(theme.expressiveness.portalOpacity, ";}.backdrop-wrapper-leave-active.__jsx-style-dynamic-selector .layer.__jsx-style-dynamic-selector{opacity:0;}"))));
2149
- });
2150
- Backdrop.displayName = 'Backdrop';
2151
-
2152
- dist.Backdrop = Backdrop;
2153
- dist.CssBaseline = MemoCssBaseline;
2154
- dist.CssTransition = CssTransition;
2155
- dist.Dropdown = Dropdown;
2156
- dist.Ellipsis = ellipsis;
2157
- dist.Expand = Expand;
2158
- dist.Highlight = Highlight;
2159
- dist.Themes = Themes;
2160
- dist.UiProvider = HuiProvider;
2161
- dist.useAllThemes = useAllThemes;
2162
- dist.useClasses = useClasses;
2163
- dist.useCurrentState = useCurrentState;
2164
- dist.useMediaQuery = useMediaQuery;
2165
- dist.useRect = useRect;
2166
- dist.useTheme = useTheme;
2167
- dist.useToasts = useToasts;
2168
- return dist;
2169
- }
2170
-
2171
- var distExports = /*@__PURE__*/ requireDist();
2172
-
2173
53
  var useModal = function useModal() {
2174
54
  var initialVisible = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
2175
- var _useCurrentState = distExports.useCurrentState(initialVisible),
55
+ var _useCurrentState = theme.useCurrentState(initialVisible),
2176
56
  _useCurrentState2 = _slicedToArray(_useCurrentState, 3),
2177
57
  visible = _useCurrentState2[0],
2178
58
  setVisible = _useCurrentState2[1],