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