@helpdice/theme 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +37 -0
- package/dist/css-baseline/css-baseline.d.ts +9 -0
- package/dist/css-baseline/index.d.ts +1 -0
- package/dist/css-baseline/index.js +868 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +1516 -0
- package/dist/shared/css-transition.d.ts +13 -0
- package/dist/styled-jsx.cjs.js +748 -0
- package/dist/themes/index.d.ts +4 -0
- package/dist/themes/index.js +299 -0
- package/dist/themes/presets/dark.d.ts +8 -0
- package/dist/themes/presets/default.d.ts +8 -0
- package/dist/themes/presets/index.d.ts +90 -0
- package/dist/themes/presets/shared.d.ts +4 -0
- package/dist/themes/themes.d.ts +18 -0
- package/dist/ui-provider/index.d.ts +3 -0
- package/dist/ui-provider/index.js +1425 -0
- package/dist/ui-provider/theme-provider.d.ts +8 -0
- package/dist/ui-provider/ui-provider.d.ts +8 -0
- package/dist/use-all-themes/all-themes-context.d.ts +7 -0
- package/dist/use-all-themes/index.d.ts +3 -0
- package/dist/use-all-themes/index.js +311 -0
- package/dist/use-classes/index.d.ts +2 -0
- package/dist/use-classes/index.js +48 -0
- package/dist/use-classes/use-classes.d.ts +4 -0
- package/dist/use-current-state/index.d.ts +2 -0
- package/dist/use-current-state/index.js +72 -0
- package/dist/use-current-state/use-current-state.d.ts +4 -0
- package/dist/use-media-query/index.js +444 -0
- package/dist/use-theme/index.d.ts +2 -0
- package/dist/use-theme/index.js +309 -0
- package/dist/use-theme/theme-context.d.ts +4 -0
- package/dist/use-toasts/helpers.d.ts +18 -0
- package/dist/use-toasts/index.js +204 -0
- package/dist/use-toasts/toast-container.d.ts +3 -0
- package/dist/use-toasts/toast-item.d.ts +8 -0
- package/dist/use-toasts/use-toast.d.ts +40 -0
- package/dist/utils/collections.d.ts +15 -0
- package/dist/utils/layouts.d.ts +20 -0
- package/dist/utils/prop-types.d.ts +19 -0
- package/dist/utils/types.d.ts +3 -0
- package/dist/utils/use-current-state.d.ts +2 -0
- package/dist/utils/use-hd-ui-context.d.ts +16 -0
- package/dist/utils/use-portal.d.ts +2 -0
- package/dist/utils/use-ssr.d.ts +6 -0
- package/esm/css-baseline/css-baseline.d.ts +9 -0
- package/esm/css-baseline/css-baseline.js +23 -0
- package/esm/css-baseline/index.d.ts +1 -0
- package/esm/css-baseline/index.js +2 -0
- package/esm/index.d.ts +12 -0
- package/esm/index.js +11 -0
- package/esm/shared/backdrop.js +66 -0
- package/esm/shared/css-transition.d.ts +13 -0
- package/esm/shared/css-transition.js +65 -0
- package/esm/shared/dropdown.js +99 -0
- package/esm/shared/ellipsis.js +13 -0
- package/esm/shared/expand.js +86 -0
- package/esm/shared/highlight.js +46 -0
- package/esm/styled-jsx-server.es.js +5 -0
- package/esm/styled-jsx.es.js +737 -0
- package/esm/themes/index.d.ts +4 -0
- package/esm/themes/index.js +2 -0
- package/esm/themes/presets/dark.d.ts +8 -0
- package/esm/themes/presets/dark.js +64 -0
- package/esm/themes/presets/default.d.ts +8 -0
- package/esm/themes/presets/default.js +64 -0
- package/esm/themes/presets/index.d.ts +90 -0
- package/esm/themes/presets/index.js +1 -0
- package/esm/themes/presets/shared.d.ts +4 -0
- package/esm/themes/presets/shared.js +42 -0
- package/esm/themes/themes.d.ts +18 -0
- package/esm/themes/themes.js +77 -0
- package/esm/ui-provider/index.d.ts +3 -0
- package/esm/ui-provider/index.js +4 -0
- package/esm/ui-provider/theme-provider.d.ts +8 -0
- package/esm/ui-provider/theme-provider.js +45 -0
- package/esm/ui-provider/ui-provider.d.ts +8 -0
- package/esm/ui-provider/ui-provider.js +55 -0
- package/esm/use-all-themes/all-themes-context.d.ts +7 -0
- package/esm/use-all-themes/all-themes-context.js +11 -0
- package/esm/use-all-themes/index.d.ts +3 -0
- package/esm/use-all-themes/index.js +2 -0
- package/esm/use-classes/index.d.ts +2 -0
- package/esm/use-classes/index.js +2 -0
- package/esm/use-classes/use-classes.d.ts +4 -0
- package/esm/use-classes/use-classes.js +34 -0
- package/esm/use-current-state/index.d.ts +2 -0
- package/esm/use-current-state/index.js +2 -0
- package/esm/use-current-state/use-current-state.d.ts +4 -0
- package/esm/use-current-state/use-current-state.js +23 -0
- package/esm/use-media-query/index.js +2 -0
- package/esm/use-media-query/use-media-query.js +81 -0
- package/esm/use-theme/index.d.ts +2 -0
- package/esm/use-theme/index.js +2 -0
- package/esm/use-theme/theme-context.d.ts +4 -0
- package/esm/use-theme/theme-context.js +9 -0
- package/esm/use-toasts/helpers.d.ts +18 -0
- package/esm/use-toasts/helpers.js +66 -0
- package/esm/use-toasts/index.js +2 -0
- package/esm/use-toasts/toast-container.d.ts +3 -0
- package/esm/use-toasts/toast-container.js +120 -0
- package/esm/use-toasts/toast-item.d.ts +8 -0
- package/esm/use-toasts/toast-item.js +45 -0
- package/esm/use-toasts/use-toast.d.ts +40 -0
- package/esm/use-toasts/use-toast.js +103 -0
- package/esm/utils/calculations.js +29 -0
- package/esm/utils/collections.d.ts +15 -0
- package/esm/utils/collections.js +128 -0
- package/esm/utils/color.js +35 -0
- package/esm/utils/layouts.d.ts +20 -0
- package/esm/utils/layouts.js +73 -0
- package/esm/utils/prop-types.d.ts +19 -0
- package/esm/utils/prop-types.js +20 -0
- package/esm/utils/types.d.ts +3 -0
- package/esm/utils/types.js +1 -0
- package/esm/utils/use-click-anywhere.js +15 -0
- package/esm/utils/use-context-state/create-ui-context.js +50 -0
- package/esm/utils/use-context-state/use-context-state.js +40 -0
- package/esm/utils/use-current-state.d.ts +2 -0
- package/esm/utils/use-current-state.js +2 -0
- package/esm/utils/use-default-props.js +17 -0
- package/esm/utils/use-dom-observer.js +26 -0
- package/esm/utils/use-hd-ui-context.d.ts +16 -0
- package/esm/utils/use-hd-ui-context.js +27 -0
- package/esm/utils/use-portal.d.ts +2 -0
- package/esm/utils/use-portal.js +34 -0
- package/esm/utils/use-previous.js +11 -0
- package/esm/utils/use-real-shape.js +47 -0
- package/esm/utils/use-resize.js +19 -0
- package/esm/utils/use-ssr.d.ts +6 -0
- package/esm/utils/use-ssr.js +19 -0
- package/esm/utils/use-warning.js +13 -0
- package/package.json +111 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1516 @@
|
|
|
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 _defineProperty(e, r, t) {
|
|
17
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
18
|
+
value: t,
|
|
19
|
+
enumerable: true,
|
|
20
|
+
configurable: true,
|
|
21
|
+
writable: true
|
|
22
|
+
}) : e[r] = t, e;
|
|
23
|
+
}
|
|
24
|
+
function _iterableToArrayLimit(r, l) {
|
|
25
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
26
|
+
if (null != t) {
|
|
27
|
+
var e,
|
|
28
|
+
n,
|
|
29
|
+
i,
|
|
30
|
+
u,
|
|
31
|
+
a = [],
|
|
32
|
+
f = true,
|
|
33
|
+
o = false;
|
|
34
|
+
try {
|
|
35
|
+
if (i = (t = t.call(r)).next, 0 === l) {
|
|
36
|
+
if (Object(t) !== t) return;
|
|
37
|
+
f = !1;
|
|
38
|
+
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
39
|
+
} catch (r) {
|
|
40
|
+
o = true, n = r;
|
|
41
|
+
} finally {
|
|
42
|
+
try {
|
|
43
|
+
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
44
|
+
} finally {
|
|
45
|
+
if (o) throw n;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return a;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function _nonIterableRest() {
|
|
52
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
53
|
+
}
|
|
54
|
+
function ownKeys(e, r) {
|
|
55
|
+
var t = Object.keys(e);
|
|
56
|
+
if (Object.getOwnPropertySymbols) {
|
|
57
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
58
|
+
r && (o = o.filter(function (r) {
|
|
59
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
60
|
+
})), t.push.apply(t, o);
|
|
61
|
+
}
|
|
62
|
+
return t;
|
|
63
|
+
}
|
|
64
|
+
function _objectSpread2(e) {
|
|
65
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
66
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
67
|
+
r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
|
|
68
|
+
_defineProperty(e, r, t[r]);
|
|
69
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
70
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return e;
|
|
74
|
+
}
|
|
75
|
+
function _objectWithoutProperties(e, t) {
|
|
76
|
+
if (null == e) return {};
|
|
77
|
+
var o,
|
|
78
|
+
r,
|
|
79
|
+
i = _objectWithoutPropertiesLoose(e, t);
|
|
80
|
+
if (Object.getOwnPropertySymbols) {
|
|
81
|
+
var n = Object.getOwnPropertySymbols(e);
|
|
82
|
+
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
83
|
+
}
|
|
84
|
+
return i;
|
|
85
|
+
}
|
|
86
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
87
|
+
if (null == r) return {};
|
|
88
|
+
var t = {};
|
|
89
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
90
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
91
|
+
t[n] = r[n];
|
|
92
|
+
}
|
|
93
|
+
return t;
|
|
94
|
+
}
|
|
95
|
+
function _slicedToArray(r, e) {
|
|
96
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
97
|
+
}
|
|
98
|
+
function _toPrimitive(t, r) {
|
|
99
|
+
if ("object" != typeof t || !t) return t;
|
|
100
|
+
var e = t[Symbol.toPrimitive];
|
|
101
|
+
if (void 0 !== e) {
|
|
102
|
+
var i = e.call(t, r);
|
|
103
|
+
if ("object" != typeof i) return i;
|
|
104
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
105
|
+
}
|
|
106
|
+
return ("string" === r ? String : Number)(t);
|
|
107
|
+
}
|
|
108
|
+
function _toPropertyKey(t) {
|
|
109
|
+
var i = _toPrimitive(t, "string");
|
|
110
|
+
return "symbol" == typeof i ? i : i + "";
|
|
111
|
+
}
|
|
112
|
+
function _typeof(o) {
|
|
113
|
+
"@babel/helpers - typeof";
|
|
114
|
+
|
|
115
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
116
|
+
return typeof o;
|
|
117
|
+
} : function (o) {
|
|
118
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
119
|
+
}, _typeof(o);
|
|
120
|
+
}
|
|
121
|
+
function _unsupportedIterableToArray(r, a) {
|
|
122
|
+
if (r) {
|
|
123
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
124
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
125
|
+
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;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
var defaultFont = {
|
|
130
|
+
sans: '"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif',
|
|
131
|
+
mono: 'Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace',
|
|
132
|
+
prism: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,"Liberation Mono", "Courier New", monospace'
|
|
133
|
+
};
|
|
134
|
+
var defaultBreakpoints = {
|
|
135
|
+
xs: {
|
|
136
|
+
min: '0',
|
|
137
|
+
max: '650px'
|
|
138
|
+
},
|
|
139
|
+
sm: {
|
|
140
|
+
min: '650px',
|
|
141
|
+
max: '900px'
|
|
142
|
+
},
|
|
143
|
+
md: {
|
|
144
|
+
min: '900px',
|
|
145
|
+
max: '1280px'
|
|
146
|
+
},
|
|
147
|
+
lg: {
|
|
148
|
+
min: '1280px',
|
|
149
|
+
max: '1920px'
|
|
150
|
+
},
|
|
151
|
+
xl: {
|
|
152
|
+
min: '1920px',
|
|
153
|
+
max: '10000px'
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
var defaultLayout = {
|
|
157
|
+
gap: '16pt',
|
|
158
|
+
gapNegative: '-16pt',
|
|
159
|
+
gapHalf: '8pt',
|
|
160
|
+
gapHalfNegative: '-8pt',
|
|
161
|
+
gapQuarter: '4pt',
|
|
162
|
+
gapQuarterNegative: '-4pt',
|
|
163
|
+
pageMargin: '16pt',
|
|
164
|
+
pageWidth: '750pt',
|
|
165
|
+
pageWidthWithMargin: '782pt',
|
|
166
|
+
breakpointMobile: defaultBreakpoints.xs.max,
|
|
167
|
+
breakpointTablet: defaultBreakpoints.sm.max,
|
|
168
|
+
radius: '6px',
|
|
169
|
+
unit: '16px'
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
var palette$1 = {
|
|
173
|
+
accents_1: '#fafafa',
|
|
174
|
+
accents_2: '#eaeaea',
|
|
175
|
+
accents_3: '#999',
|
|
176
|
+
accents_4: '#888',
|
|
177
|
+
accents_5: '#666',
|
|
178
|
+
accents_6: '#444',
|
|
179
|
+
accents_7: '#333',
|
|
180
|
+
accents_8: '#111',
|
|
181
|
+
background: '#fff',
|
|
182
|
+
foreground: '#000',
|
|
183
|
+
selection: '#79ffe1',
|
|
184
|
+
secondary: '#666',
|
|
185
|
+
code: '#f81ce5',
|
|
186
|
+
border: '#eaeaea',
|
|
187
|
+
error: '#e00',
|
|
188
|
+
errorLight: '#ff1a1a',
|
|
189
|
+
errorLighter: '#f7d4d6',
|
|
190
|
+
errorDark: '#c50000',
|
|
191
|
+
success: '#0070f3',
|
|
192
|
+
successLight: '#3291ff',
|
|
193
|
+
successLighter: '#d3e5ff',
|
|
194
|
+
successDark: '#0761d1',
|
|
195
|
+
warning: '#f5a623',
|
|
196
|
+
warningLight: '#f7b955',
|
|
197
|
+
warningLighter: '#ffefcf',
|
|
198
|
+
warningDark: '#ab570a',
|
|
199
|
+
cyan: '#50e3c2',
|
|
200
|
+
cyanLighter: '#aaffec',
|
|
201
|
+
cyanLight: '#79ffe1',
|
|
202
|
+
cyanDark: '#29bc9b',
|
|
203
|
+
violet: '#7928ca',
|
|
204
|
+
violetLighter: '#e3d7fc',
|
|
205
|
+
violetLight: '#8a63d2',
|
|
206
|
+
violetDark: '#4c2889',
|
|
207
|
+
purple: '#f81ce5',
|
|
208
|
+
alert: '#ff0080',
|
|
209
|
+
magenta: '#eb367f',
|
|
210
|
+
link: '#0070f3'
|
|
211
|
+
};
|
|
212
|
+
var expressiveness$1 = {
|
|
213
|
+
linkStyle: 'none',
|
|
214
|
+
linkHoverStyle: 'none',
|
|
215
|
+
dropdownBoxShadow: '0 4px 4px 0 rgba(0, 0, 0, 0.02)',
|
|
216
|
+
scrollerStart: 'rgba(255, 255, 255, 1)',
|
|
217
|
+
scrollerEnd: 'rgba(255, 255, 255, 0)',
|
|
218
|
+
shadowSmall: '0 5px 10px rgba(0, 0, 0, 0.12)',
|
|
219
|
+
shadowMedium: '0 8px 30px rgba(0, 0, 0, 0.12)',
|
|
220
|
+
shadowLarge: '0 30px 60px rgba(0, 0, 0, 0.12)',
|
|
221
|
+
portalOpacity: 0.25
|
|
222
|
+
};
|
|
223
|
+
var font$1 = defaultFont;
|
|
224
|
+
var breakpoints$1 = defaultBreakpoints;
|
|
225
|
+
var layout$1 = defaultLayout;
|
|
226
|
+
var themes$1 = {
|
|
227
|
+
type: 'light',
|
|
228
|
+
font: font$1,
|
|
229
|
+
layout: layout$1,
|
|
230
|
+
palette: palette$1,
|
|
231
|
+
breakpoints: breakpoints$1,
|
|
232
|
+
expressiveness: expressiveness$1
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
var palette = {
|
|
236
|
+
accents_1: '#111',
|
|
237
|
+
accents_2: '#333',
|
|
238
|
+
accents_3: '#444',
|
|
239
|
+
accents_4: '#666',
|
|
240
|
+
accents_5: '#888',
|
|
241
|
+
accents_6: '#999',
|
|
242
|
+
accents_7: '#eaeaea',
|
|
243
|
+
accents_8: '#fafafa',
|
|
244
|
+
background: '#000',
|
|
245
|
+
foreground: '#fff',
|
|
246
|
+
selection: '#f81ce5',
|
|
247
|
+
secondary: '#888',
|
|
248
|
+
code: '#79ffe1',
|
|
249
|
+
border: '#333',
|
|
250
|
+
error: '#e00',
|
|
251
|
+
errorLighter: '#f7d4d6',
|
|
252
|
+
errorLight: '#ff1a1a',
|
|
253
|
+
errorDark: '#c50000',
|
|
254
|
+
success: '#0070f3',
|
|
255
|
+
successLighter: '#d3e5ff',
|
|
256
|
+
successLight: '#3291ff',
|
|
257
|
+
successDark: '#0761d1',
|
|
258
|
+
warning: '#f5a623',
|
|
259
|
+
warningLighter: '#ffefcf',
|
|
260
|
+
warningLight: '#f7b955',
|
|
261
|
+
warningDark: '#ab570a',
|
|
262
|
+
cyan: '#50e3c2',
|
|
263
|
+
cyanLighter: '#aaffec',
|
|
264
|
+
cyanLight: '#79ffe1',
|
|
265
|
+
cyanDark: '#29bc9b',
|
|
266
|
+
violet: '#7928ca',
|
|
267
|
+
violetLighter: '#e3d7fc',
|
|
268
|
+
violetLight: '#8a63d2',
|
|
269
|
+
violetDark: '#4c2889',
|
|
270
|
+
purple: '#f81ce5',
|
|
271
|
+
alert: '#ff0080',
|
|
272
|
+
magenta: '#eb367f',
|
|
273
|
+
link: '#3291ff'
|
|
274
|
+
};
|
|
275
|
+
var expressiveness = {
|
|
276
|
+
linkStyle: 'none',
|
|
277
|
+
linkHoverStyle: 'none',
|
|
278
|
+
dropdownBoxShadow: '0 0 0 1px #333',
|
|
279
|
+
scrollerStart: 'rgba(255, 255, 255, 1)',
|
|
280
|
+
scrollerEnd: 'rgba(255, 255, 255, 0)',
|
|
281
|
+
shadowSmall: '0 0 0 1px #333',
|
|
282
|
+
shadowMedium: '0 0 0 1px #333',
|
|
283
|
+
shadowLarge: '0 0 0 1px #333',
|
|
284
|
+
portalOpacity: 0.75
|
|
285
|
+
};
|
|
286
|
+
var font = defaultFont;
|
|
287
|
+
var breakpoints = defaultBreakpoints;
|
|
288
|
+
var layout = defaultLayout;
|
|
289
|
+
var themes = {
|
|
290
|
+
type: 'dark',
|
|
291
|
+
font: font,
|
|
292
|
+
layout: layout,
|
|
293
|
+
palette: palette,
|
|
294
|
+
breakpoints: breakpoints,
|
|
295
|
+
expressiveness: expressiveness
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
var isObject = function isObject(target) {
|
|
299
|
+
return target && _typeof(target) === 'object';
|
|
300
|
+
};
|
|
301
|
+
var _deepDuplicable = function deepDuplicable(source, target) {
|
|
302
|
+
if (!isObject(target) || !isObject(source)) return source;
|
|
303
|
+
var sourceKeys = Object.keys(source);
|
|
304
|
+
var result = {};
|
|
305
|
+
for (var _i = 0, _sourceKeys = sourceKeys; _i < _sourceKeys.length; _i++) {
|
|
306
|
+
var key = _sourceKeys[_i];
|
|
307
|
+
var sourceValue = source[key];
|
|
308
|
+
var targetValue = target[key];
|
|
309
|
+
if (Array.isArray(sourceValue) && Array.isArray(targetValue)) {
|
|
310
|
+
result[key] = targetValue.concat(sourceValue);
|
|
311
|
+
} else if (isObject(sourceValue) && isObject(targetValue)) {
|
|
312
|
+
result[key] = _deepDuplicable(sourceValue, _objectSpread2({}, targetValue));
|
|
313
|
+
} else if (targetValue) {
|
|
314
|
+
result[key] = targetValue;
|
|
315
|
+
} else {
|
|
316
|
+
result[key] = sourceValue;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
return result;
|
|
320
|
+
};
|
|
321
|
+
var getPresets = function getPresets() {
|
|
322
|
+
return [themes$1, themes];
|
|
323
|
+
};
|
|
324
|
+
var getPresetStaticTheme = function getPresetStaticTheme() {
|
|
325
|
+
return themes$1;
|
|
326
|
+
};
|
|
327
|
+
var isAvailableThemeType = function isAvailableThemeType(type) {
|
|
328
|
+
if (!type) return false;
|
|
329
|
+
var presetThemes = getPresets();
|
|
330
|
+
var hasType = presetThemes.find(function (theme) {
|
|
331
|
+
return theme.type === type;
|
|
332
|
+
});
|
|
333
|
+
return !hasType;
|
|
334
|
+
};
|
|
335
|
+
var isPresetTheme = function isPresetTheme(themeOrType) {
|
|
336
|
+
if (!themeOrType) return false;
|
|
337
|
+
var isType = typeof themeOrType === 'string';
|
|
338
|
+
var type = isType ? themeOrType : themeOrType.type;
|
|
339
|
+
return !isAvailableThemeType(type);
|
|
340
|
+
};
|
|
341
|
+
var hasUserCustomTheme = function hasUserCustomTheme() {
|
|
342
|
+
var themes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
343
|
+
return !!themes.find(function (item) {
|
|
344
|
+
return isAvailableThemeType(item.type);
|
|
345
|
+
});
|
|
346
|
+
};
|
|
347
|
+
var create = function create(base, custom) {
|
|
348
|
+
if (!isAvailableThemeType(custom.type)) {
|
|
349
|
+
throw new Error('Duplicate or unavailable theme type');
|
|
350
|
+
}
|
|
351
|
+
return _deepDuplicable(base, custom);
|
|
352
|
+
};
|
|
353
|
+
var createFromDark = function createFromDark(custom) {
|
|
354
|
+
return create(themes, custom);
|
|
355
|
+
};
|
|
356
|
+
var createFromLight = function createFromLight(custom) {
|
|
357
|
+
return create(themes$1, custom);
|
|
358
|
+
};
|
|
359
|
+
var Themes = {
|
|
360
|
+
isPresetTheme: isPresetTheme,
|
|
361
|
+
isAvailableThemeType: isAvailableThemeType,
|
|
362
|
+
hasUserCustomTheme: hasUserCustomTheme,
|
|
363
|
+
getPresets: getPresets,
|
|
364
|
+
getPresetStaticTheme: getPresetStaticTheme,
|
|
365
|
+
create: create,
|
|
366
|
+
createFromDark: createFromDark,
|
|
367
|
+
createFromLight: createFromLight
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
/* "use client" */
|
|
371
|
+
|
|
372
|
+
var defaultTheme = Themes.getPresetStaticTheme();
|
|
373
|
+
var ThemeContext = /*#__PURE__*/React.createContext(defaultTheme);
|
|
374
|
+
var useTheme = function useTheme() {
|
|
375
|
+
return React.useContext(ThemeContext);
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
var defaultToastLayout = {
|
|
379
|
+
padding: '12px 16px',
|
|
380
|
+
margin: '8px 0',
|
|
381
|
+
width: '420px',
|
|
382
|
+
maxWidth: '90vw',
|
|
383
|
+
maxHeight: '75px',
|
|
384
|
+
placement: 'bottomRight'
|
|
385
|
+
};
|
|
386
|
+
var defaultParams = {
|
|
387
|
+
toasts: [],
|
|
388
|
+
toastLayout: defaultToastLayout,
|
|
389
|
+
updateToastLayout: function updateToastLayout(t) {
|
|
390
|
+
return t;
|
|
391
|
+
},
|
|
392
|
+
updateToasts: function updateToasts(t) {
|
|
393
|
+
return t;
|
|
394
|
+
},
|
|
395
|
+
lastUpdateToastId: null,
|
|
396
|
+
updateLastToastId: function updateLastToastId() {
|
|
397
|
+
return null;
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
var HUIContent = /*#__PURE__*/React.createContext(defaultParams);
|
|
401
|
+
var useHUIContext = function useHUIContext() {
|
|
402
|
+
return React.useContext(HUIContent);
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
/* "use client" */
|
|
406
|
+
|
|
407
|
+
var defaultAllThemesConfig = {
|
|
408
|
+
themes: Themes.getPresets()
|
|
409
|
+
};
|
|
410
|
+
var AllThemesContext = /*#__PURE__*/React.createContext(defaultAllThemesConfig);
|
|
411
|
+
var useAllThemes = function useAllThemes() {
|
|
412
|
+
return React.useContext(AllThemesContext);
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
var ThemeProvider = function ThemeProvider(_ref) {
|
|
416
|
+
var children = _ref.children,
|
|
417
|
+
themeType = _ref.themeType,
|
|
418
|
+
_ref$themes = _ref.themes,
|
|
419
|
+
themes = _ref$themes === void 0 ? [] : _ref$themes;
|
|
420
|
+
var _React$useState = React.useState({
|
|
421
|
+
themes: Themes.getPresets()
|
|
422
|
+
}),
|
|
423
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
424
|
+
allThemes = _React$useState2[0],
|
|
425
|
+
setAllThemes = _React$useState2[1];
|
|
426
|
+
var currentTheme = React.useMemo(function () {
|
|
427
|
+
var theme = allThemes.themes.find(function (item) {
|
|
428
|
+
return item.type === themeType;
|
|
429
|
+
});
|
|
430
|
+
if (theme) return theme;
|
|
431
|
+
return Themes.getPresetStaticTheme();
|
|
432
|
+
}, [allThemes, themeType]);
|
|
433
|
+
React.useEffect(function () {
|
|
434
|
+
if (!(themes !== null && themes !== void 0 && themes.length)) return;
|
|
435
|
+
setAllThemes(function (last) {
|
|
436
|
+
var safeThemes = themes.filter(function (item) {
|
|
437
|
+
return Themes.isAvailableThemeType(item.type);
|
|
438
|
+
});
|
|
439
|
+
var nextThemes = Themes.getPresets().concat(safeThemes);
|
|
440
|
+
return _objectSpread2(_objectSpread2({}, last), {}, {
|
|
441
|
+
themes: nextThemes
|
|
442
|
+
});
|
|
443
|
+
});
|
|
444
|
+
}, [themes]);
|
|
445
|
+
return /*#__PURE__*/React.createElement(AllThemesContext.Provider, {
|
|
446
|
+
value: allThemes
|
|
447
|
+
}, /*#__PURE__*/React.createElement(ThemeContext.Provider, {
|
|
448
|
+
value: currentTheme
|
|
449
|
+
}, children));
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
var useCurrentState = function useCurrentState(initialState) {
|
|
453
|
+
var _useState = React.useState(function () {
|
|
454
|
+
return typeof initialState === 'function' ? initialState() : initialState;
|
|
455
|
+
}),
|
|
456
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
457
|
+
state = _useState2[0],
|
|
458
|
+
setState = _useState2[1];
|
|
459
|
+
var ref = React.useRef(initialState);
|
|
460
|
+
React.useEffect(function () {
|
|
461
|
+
ref.current = state;
|
|
462
|
+
}, [state]);
|
|
463
|
+
var setValue = function setValue(val) {
|
|
464
|
+
var result = typeof val === 'function' ? val(ref.current) : val;
|
|
465
|
+
ref.current = result;
|
|
466
|
+
setState(result);
|
|
467
|
+
};
|
|
468
|
+
return [state, setValue, ref];
|
|
469
|
+
};
|
|
470
|
+
|
|
471
|
+
function getDefaultExportFromCjs (x) {
|
|
472
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
var index = {};
|
|
476
|
+
|
|
477
|
+
var hasRequiredIndex;
|
|
478
|
+
|
|
479
|
+
function requireIndex () {
|
|
480
|
+
if (hasRequiredIndex) return index;
|
|
481
|
+
hasRequiredIndex = 1;
|
|
482
|
+
var React$1 = React;
|
|
483
|
+
|
|
484
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
485
|
+
|
|
486
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React$1);
|
|
487
|
+
|
|
488
|
+
/*
|
|
489
|
+
Based on Glamor's sheet
|
|
490
|
+
https://github.com/threepointone/glamor/blob/667b480d31b3721a905021b26e1290ce92ca2879/src/sheet.js
|
|
491
|
+
*/ function _defineProperties(target, props) {
|
|
492
|
+
for(var i = 0; i < props.length; i++){
|
|
493
|
+
var descriptor = props[i];
|
|
494
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
495
|
+
descriptor.configurable = true;
|
|
496
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
497
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
501
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
502
|
+
return Constructor;
|
|
503
|
+
}
|
|
504
|
+
var isProd = typeof process !== "undefined" && process.env && process.env.NODE_ENV === "production";
|
|
505
|
+
var isString = function(o) {
|
|
506
|
+
return Object.prototype.toString.call(o) === "[object String]";
|
|
507
|
+
};
|
|
508
|
+
var StyleSheet = /*#__PURE__*/ function() {
|
|
509
|
+
function StyleSheet(param) {
|
|
510
|
+
var ref = param === void 0 ? {} : param, _name = ref.name, name = _name === void 0 ? "stylesheet" : _name, _optimizeForSpeed = ref.optimizeForSpeed, optimizeForSpeed = _optimizeForSpeed === void 0 ? isProd : _optimizeForSpeed;
|
|
511
|
+
invariant$1(isString(name), "`name` must be a string");
|
|
512
|
+
this._name = name;
|
|
513
|
+
this._deletedRulePlaceholder = "#" + name + "-deleted-rule____{}";
|
|
514
|
+
invariant$1(typeof optimizeForSpeed === "boolean", "`optimizeForSpeed` must be a boolean");
|
|
515
|
+
this._optimizeForSpeed = optimizeForSpeed;
|
|
516
|
+
this._serverSheet = undefined;
|
|
517
|
+
this._tags = [];
|
|
518
|
+
this._injected = false;
|
|
519
|
+
this._rulesCount = 0;
|
|
520
|
+
var node = typeof window !== "undefined" && document.querySelector('meta[property="csp-nonce"]');
|
|
521
|
+
this._nonce = node ? node.getAttribute("content") : null;
|
|
522
|
+
}
|
|
523
|
+
var _proto = StyleSheet.prototype;
|
|
524
|
+
_proto.setOptimizeForSpeed = function setOptimizeForSpeed(bool) {
|
|
525
|
+
invariant$1(typeof bool === "boolean", "`setOptimizeForSpeed` accepts a boolean");
|
|
526
|
+
invariant$1(this._rulesCount === 0, "optimizeForSpeed cannot be when rules have already been inserted");
|
|
527
|
+
this.flush();
|
|
528
|
+
this._optimizeForSpeed = bool;
|
|
529
|
+
this.inject();
|
|
530
|
+
};
|
|
531
|
+
_proto.isOptimizeForSpeed = function isOptimizeForSpeed() {
|
|
532
|
+
return this._optimizeForSpeed;
|
|
533
|
+
};
|
|
534
|
+
_proto.inject = function inject() {
|
|
535
|
+
var _this = this;
|
|
536
|
+
invariant$1(!this._injected, "sheet already injected");
|
|
537
|
+
this._injected = true;
|
|
538
|
+
if (typeof window !== "undefined" && this._optimizeForSpeed) {
|
|
539
|
+
this._tags[0] = this.makeStyleTag(this._name);
|
|
540
|
+
this._optimizeForSpeed = "insertRule" in this.getSheet();
|
|
541
|
+
if (!this._optimizeForSpeed) {
|
|
542
|
+
if (!isProd) {
|
|
543
|
+
console.warn("StyleSheet: optimizeForSpeed mode not supported falling back to standard mode.");
|
|
544
|
+
}
|
|
545
|
+
this.flush();
|
|
546
|
+
this._injected = true;
|
|
547
|
+
}
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
this._serverSheet = {
|
|
551
|
+
cssRules: [],
|
|
552
|
+
insertRule: function(rule, index) {
|
|
553
|
+
if (typeof index === "number") {
|
|
554
|
+
_this._serverSheet.cssRules[index] = {
|
|
555
|
+
cssText: rule
|
|
556
|
+
};
|
|
557
|
+
} else {
|
|
558
|
+
_this._serverSheet.cssRules.push({
|
|
559
|
+
cssText: rule
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
return index;
|
|
563
|
+
},
|
|
564
|
+
deleteRule: function(index) {
|
|
565
|
+
_this._serverSheet.cssRules[index] = null;
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
};
|
|
569
|
+
_proto.getSheetForTag = function getSheetForTag(tag) {
|
|
570
|
+
if (tag.sheet) {
|
|
571
|
+
return tag.sheet;
|
|
572
|
+
}
|
|
573
|
+
// this weirdness brought to you by firefox
|
|
574
|
+
for(var i = 0; i < document.styleSheets.length; i++){
|
|
575
|
+
if (document.styleSheets[i].ownerNode === tag) {
|
|
576
|
+
return document.styleSheets[i];
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
};
|
|
580
|
+
_proto.getSheet = function getSheet() {
|
|
581
|
+
return this.getSheetForTag(this._tags[this._tags.length - 1]);
|
|
582
|
+
};
|
|
583
|
+
_proto.insertRule = function insertRule(rule, index) {
|
|
584
|
+
invariant$1(isString(rule), "`insertRule` accepts only strings");
|
|
585
|
+
if (typeof window === "undefined") {
|
|
586
|
+
if (typeof index !== "number") {
|
|
587
|
+
index = this._serverSheet.cssRules.length;
|
|
588
|
+
}
|
|
589
|
+
this._serverSheet.insertRule(rule, index);
|
|
590
|
+
return this._rulesCount++;
|
|
591
|
+
}
|
|
592
|
+
if (this._optimizeForSpeed) {
|
|
593
|
+
var sheet = this.getSheet();
|
|
594
|
+
if (typeof index !== "number") {
|
|
595
|
+
index = sheet.cssRules.length;
|
|
596
|
+
}
|
|
597
|
+
// this weirdness for perf, and chrome's weird bug
|
|
598
|
+
// https://stackoverflow.com/questions/20007992/chrome-suddenly-stopped-accepting-insertrule
|
|
599
|
+
try {
|
|
600
|
+
sheet.insertRule(rule, index);
|
|
601
|
+
} catch (error) {
|
|
602
|
+
if (!isProd) {
|
|
603
|
+
console.warn("StyleSheet: illegal rule: \n\n" + rule + "\n\nSee https://stackoverflow.com/q/20007992 for more info");
|
|
604
|
+
}
|
|
605
|
+
return -1;
|
|
606
|
+
}
|
|
607
|
+
} else {
|
|
608
|
+
var insertionPoint = this._tags[index];
|
|
609
|
+
this._tags.push(this.makeStyleTag(this._name, rule, insertionPoint));
|
|
610
|
+
}
|
|
611
|
+
return this._rulesCount++;
|
|
612
|
+
};
|
|
613
|
+
_proto.replaceRule = function replaceRule(index, rule) {
|
|
614
|
+
if (this._optimizeForSpeed || typeof window === "undefined") {
|
|
615
|
+
var sheet = typeof window !== "undefined" ? this.getSheet() : this._serverSheet;
|
|
616
|
+
if (!rule.trim()) {
|
|
617
|
+
rule = this._deletedRulePlaceholder;
|
|
618
|
+
}
|
|
619
|
+
if (!sheet.cssRules[index]) {
|
|
620
|
+
// @TBD Should we throw an error?
|
|
621
|
+
return index;
|
|
622
|
+
}
|
|
623
|
+
sheet.deleteRule(index);
|
|
624
|
+
try {
|
|
625
|
+
sheet.insertRule(rule, index);
|
|
626
|
+
} catch (error) {
|
|
627
|
+
if (!isProd) {
|
|
628
|
+
console.warn("StyleSheet: illegal rule: \n\n" + rule + "\n\nSee https://stackoverflow.com/q/20007992 for more info");
|
|
629
|
+
}
|
|
630
|
+
// In order to preserve the indices we insert a deleteRulePlaceholder
|
|
631
|
+
sheet.insertRule(this._deletedRulePlaceholder, index);
|
|
632
|
+
}
|
|
633
|
+
} else {
|
|
634
|
+
var tag = this._tags[index];
|
|
635
|
+
invariant$1(tag, "old rule at index `" + index + "` not found");
|
|
636
|
+
tag.textContent = rule;
|
|
637
|
+
}
|
|
638
|
+
return index;
|
|
639
|
+
};
|
|
640
|
+
_proto.deleteRule = function deleteRule(index) {
|
|
641
|
+
if (typeof window === "undefined") {
|
|
642
|
+
this._serverSheet.deleteRule(index);
|
|
643
|
+
return;
|
|
644
|
+
}
|
|
645
|
+
if (this._optimizeForSpeed) {
|
|
646
|
+
this.replaceRule(index, "");
|
|
647
|
+
} else {
|
|
648
|
+
var tag = this._tags[index];
|
|
649
|
+
invariant$1(tag, "rule at index `" + index + "` not found");
|
|
650
|
+
tag.parentNode.removeChild(tag);
|
|
651
|
+
this._tags[index] = null;
|
|
652
|
+
}
|
|
653
|
+
};
|
|
654
|
+
_proto.flush = function flush() {
|
|
655
|
+
this._injected = false;
|
|
656
|
+
this._rulesCount = 0;
|
|
657
|
+
if (typeof window !== "undefined") {
|
|
658
|
+
this._tags.forEach(function(tag) {
|
|
659
|
+
return tag && tag.parentNode.removeChild(tag);
|
|
660
|
+
});
|
|
661
|
+
this._tags = [];
|
|
662
|
+
} else {
|
|
663
|
+
// simpler on server
|
|
664
|
+
this._serverSheet.cssRules = [];
|
|
665
|
+
}
|
|
666
|
+
};
|
|
667
|
+
_proto.cssRules = function cssRules() {
|
|
668
|
+
var _this = this;
|
|
669
|
+
if (typeof window === "undefined") {
|
|
670
|
+
return this._serverSheet.cssRules;
|
|
671
|
+
}
|
|
672
|
+
return this._tags.reduce(function(rules, tag) {
|
|
673
|
+
if (tag) {
|
|
674
|
+
rules = rules.concat(Array.prototype.map.call(_this.getSheetForTag(tag).cssRules, function(rule) {
|
|
675
|
+
return rule.cssText === _this._deletedRulePlaceholder ? null : rule;
|
|
676
|
+
}));
|
|
677
|
+
} else {
|
|
678
|
+
rules.push(null);
|
|
679
|
+
}
|
|
680
|
+
return rules;
|
|
681
|
+
}, []);
|
|
682
|
+
};
|
|
683
|
+
_proto.makeStyleTag = function makeStyleTag(name, cssString, relativeToTag) {
|
|
684
|
+
if (cssString) {
|
|
685
|
+
invariant$1(isString(cssString), "makeStyleTag accepts only strings as second parameter");
|
|
686
|
+
}
|
|
687
|
+
var tag = document.createElement("style");
|
|
688
|
+
if (this._nonce) tag.setAttribute("nonce", this._nonce);
|
|
689
|
+
tag.type = "text/css";
|
|
690
|
+
tag.setAttribute("data-" + name, "");
|
|
691
|
+
if (cssString) {
|
|
692
|
+
tag.appendChild(document.createTextNode(cssString));
|
|
693
|
+
}
|
|
694
|
+
var head = document.head || document.getElementsByTagName("head")[0];
|
|
695
|
+
if (relativeToTag) {
|
|
696
|
+
head.insertBefore(tag, relativeToTag);
|
|
697
|
+
} else {
|
|
698
|
+
head.appendChild(tag);
|
|
699
|
+
}
|
|
700
|
+
return tag;
|
|
701
|
+
};
|
|
702
|
+
_createClass(StyleSheet, [
|
|
703
|
+
{
|
|
704
|
+
key: "length",
|
|
705
|
+
get: function get() {
|
|
706
|
+
return this._rulesCount;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
]);
|
|
710
|
+
return StyleSheet;
|
|
711
|
+
}();
|
|
712
|
+
function invariant$1(condition, message) {
|
|
713
|
+
if (!condition) {
|
|
714
|
+
throw new Error("StyleSheet: " + message + ".");
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
function hash(str) {
|
|
719
|
+
var _$hash = 5381, i = str.length;
|
|
720
|
+
while(i){
|
|
721
|
+
_$hash = _$hash * 33 ^ str.charCodeAt(--i);
|
|
722
|
+
}
|
|
723
|
+
/* JavaScript does bitwise operations (like XOR, above) on 32-bit signed
|
|
724
|
+
* integers. Since we want the results to be always positive, convert the
|
|
725
|
+
* signed int to an unsigned by doing an unsigned bitshift. */ return _$hash >>> 0;
|
|
726
|
+
}
|
|
727
|
+
var stringHash = hash;
|
|
728
|
+
|
|
729
|
+
var sanitize = function(rule) {
|
|
730
|
+
return rule.replace(/\/style/gi, "\\/style");
|
|
731
|
+
};
|
|
732
|
+
var cache = {};
|
|
733
|
+
/**
|
|
734
|
+
* computeId
|
|
735
|
+
*
|
|
736
|
+
* Compute and memoize a jsx id from a basedId and optionally props.
|
|
737
|
+
*/ function computeId(baseId, props) {
|
|
738
|
+
if (!props) {
|
|
739
|
+
return "jsx-" + baseId;
|
|
740
|
+
}
|
|
741
|
+
var propsToString = String(props);
|
|
742
|
+
var key = baseId + propsToString;
|
|
743
|
+
if (!cache[key]) {
|
|
744
|
+
cache[key] = "jsx-" + stringHash(baseId + "-" + propsToString);
|
|
745
|
+
}
|
|
746
|
+
return cache[key];
|
|
747
|
+
}
|
|
748
|
+
/**
|
|
749
|
+
* computeSelector
|
|
750
|
+
*
|
|
751
|
+
* Compute and memoize dynamic selectors.
|
|
752
|
+
*/ function computeSelector(id, css) {
|
|
753
|
+
var selectoPlaceholderRegexp = /__jsx-style-dynamic-selector/g;
|
|
754
|
+
// Sanitize SSR-ed CSS.
|
|
755
|
+
// Client side code doesn't need to be sanitized since we use
|
|
756
|
+
// document.createTextNode (dev) and the CSSOM api sheet.insertRule (prod).
|
|
757
|
+
if (typeof window === "undefined") {
|
|
758
|
+
css = sanitize(css);
|
|
759
|
+
}
|
|
760
|
+
var idcss = id + css;
|
|
761
|
+
if (!cache[idcss]) {
|
|
762
|
+
cache[idcss] = css.replace(selectoPlaceholderRegexp, id);
|
|
763
|
+
}
|
|
764
|
+
return cache[idcss];
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
function mapRulesToStyle(cssRules, options) {
|
|
768
|
+
if (options === void 0) options = {};
|
|
769
|
+
return cssRules.map(function(args) {
|
|
770
|
+
var id = args[0];
|
|
771
|
+
var css = args[1];
|
|
772
|
+
return /*#__PURE__*/ React__default["default"].createElement("style", {
|
|
773
|
+
id: "__" + id,
|
|
774
|
+
// Avoid warnings upon render with a key
|
|
775
|
+
key: "__" + id,
|
|
776
|
+
nonce: options.nonce ? options.nonce : undefined,
|
|
777
|
+
dangerouslySetInnerHTML: {
|
|
778
|
+
__html: css
|
|
779
|
+
}
|
|
780
|
+
});
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
var StyleSheetRegistry = /*#__PURE__*/ function() {
|
|
784
|
+
function StyleSheetRegistry(param) {
|
|
785
|
+
var ref = param === void 0 ? {} : param, _styleSheet = ref.styleSheet, styleSheet = _styleSheet === void 0 ? null : _styleSheet, _optimizeForSpeed = ref.optimizeForSpeed, optimizeForSpeed = _optimizeForSpeed === void 0 ? false : _optimizeForSpeed;
|
|
786
|
+
this._sheet = styleSheet || new StyleSheet({
|
|
787
|
+
name: "styled-jsx",
|
|
788
|
+
optimizeForSpeed: optimizeForSpeed
|
|
789
|
+
});
|
|
790
|
+
this._sheet.inject();
|
|
791
|
+
if (styleSheet && typeof optimizeForSpeed === "boolean") {
|
|
792
|
+
this._sheet.setOptimizeForSpeed(optimizeForSpeed);
|
|
793
|
+
this._optimizeForSpeed = this._sheet.isOptimizeForSpeed();
|
|
794
|
+
}
|
|
795
|
+
this._fromServer = undefined;
|
|
796
|
+
this._indices = {};
|
|
797
|
+
this._instancesCounts = {};
|
|
798
|
+
}
|
|
799
|
+
var _proto = StyleSheetRegistry.prototype;
|
|
800
|
+
_proto.add = function add(props) {
|
|
801
|
+
var _this = this;
|
|
802
|
+
if (undefined === this._optimizeForSpeed) {
|
|
803
|
+
this._optimizeForSpeed = Array.isArray(props.children);
|
|
804
|
+
this._sheet.setOptimizeForSpeed(this._optimizeForSpeed);
|
|
805
|
+
this._optimizeForSpeed = this._sheet.isOptimizeForSpeed();
|
|
806
|
+
}
|
|
807
|
+
if (typeof window !== "undefined" && !this._fromServer) {
|
|
808
|
+
this._fromServer = this.selectFromServer();
|
|
809
|
+
this._instancesCounts = Object.keys(this._fromServer).reduce(function(acc, tagName) {
|
|
810
|
+
acc[tagName] = 0;
|
|
811
|
+
return acc;
|
|
812
|
+
}, {});
|
|
813
|
+
}
|
|
814
|
+
var ref = this.getIdAndRules(props), styleId = ref.styleId, rules = ref.rules;
|
|
815
|
+
// Deduping: just increase the instances count.
|
|
816
|
+
if (styleId in this._instancesCounts) {
|
|
817
|
+
this._instancesCounts[styleId] += 1;
|
|
818
|
+
return;
|
|
819
|
+
}
|
|
820
|
+
var indices = rules.map(function(rule) {
|
|
821
|
+
return _this._sheet.insertRule(rule);
|
|
822
|
+
})// Filter out invalid rules
|
|
823
|
+
.filter(function(index) {
|
|
824
|
+
return index !== -1;
|
|
825
|
+
});
|
|
826
|
+
this._indices[styleId] = indices;
|
|
827
|
+
this._instancesCounts[styleId] = 1;
|
|
828
|
+
};
|
|
829
|
+
_proto.remove = function remove(props) {
|
|
830
|
+
var _this = this;
|
|
831
|
+
var styleId = this.getIdAndRules(props).styleId;
|
|
832
|
+
invariant(styleId in this._instancesCounts, "styleId: `" + styleId + "` not found");
|
|
833
|
+
this._instancesCounts[styleId] -= 1;
|
|
834
|
+
if (this._instancesCounts[styleId] < 1) {
|
|
835
|
+
var tagFromServer = this._fromServer && this._fromServer[styleId];
|
|
836
|
+
if (tagFromServer) {
|
|
837
|
+
tagFromServer.parentNode.removeChild(tagFromServer);
|
|
838
|
+
delete this._fromServer[styleId];
|
|
839
|
+
} else {
|
|
840
|
+
this._indices[styleId].forEach(function(index) {
|
|
841
|
+
return _this._sheet.deleteRule(index);
|
|
842
|
+
});
|
|
843
|
+
delete this._indices[styleId];
|
|
844
|
+
}
|
|
845
|
+
delete this._instancesCounts[styleId];
|
|
846
|
+
}
|
|
847
|
+
};
|
|
848
|
+
_proto.update = function update(props, nextProps) {
|
|
849
|
+
this.add(nextProps);
|
|
850
|
+
this.remove(props);
|
|
851
|
+
};
|
|
852
|
+
_proto.flush = function flush() {
|
|
853
|
+
this._sheet.flush();
|
|
854
|
+
this._sheet.inject();
|
|
855
|
+
this._fromServer = undefined;
|
|
856
|
+
this._indices = {};
|
|
857
|
+
this._instancesCounts = {};
|
|
858
|
+
};
|
|
859
|
+
_proto.cssRules = function cssRules() {
|
|
860
|
+
var _this = this;
|
|
861
|
+
var fromServer = this._fromServer ? Object.keys(this._fromServer).map(function(styleId) {
|
|
862
|
+
return [
|
|
863
|
+
styleId,
|
|
864
|
+
_this._fromServer[styleId]
|
|
865
|
+
];
|
|
866
|
+
}) : [];
|
|
867
|
+
var cssRules = this._sheet.cssRules();
|
|
868
|
+
return fromServer.concat(Object.keys(this._indices).map(function(styleId) {
|
|
869
|
+
return [
|
|
870
|
+
styleId,
|
|
871
|
+
_this._indices[styleId].map(function(index) {
|
|
872
|
+
return cssRules[index].cssText;
|
|
873
|
+
}).join(_this._optimizeForSpeed ? "" : "\n")
|
|
874
|
+
];
|
|
875
|
+
})// filter out empty rules
|
|
876
|
+
.filter(function(rule) {
|
|
877
|
+
return Boolean(rule[1]);
|
|
878
|
+
}));
|
|
879
|
+
};
|
|
880
|
+
_proto.styles = function styles(options) {
|
|
881
|
+
return mapRulesToStyle(this.cssRules(), options);
|
|
882
|
+
};
|
|
883
|
+
_proto.getIdAndRules = function getIdAndRules(props) {
|
|
884
|
+
var css = props.children, dynamic = props.dynamic, id = props.id;
|
|
885
|
+
if (dynamic) {
|
|
886
|
+
var styleId = computeId(id, dynamic);
|
|
887
|
+
return {
|
|
888
|
+
styleId: styleId,
|
|
889
|
+
rules: Array.isArray(css) ? css.map(function(rule) {
|
|
890
|
+
return computeSelector(styleId, rule);
|
|
891
|
+
}) : [
|
|
892
|
+
computeSelector(styleId, css)
|
|
893
|
+
]
|
|
894
|
+
};
|
|
895
|
+
}
|
|
896
|
+
return {
|
|
897
|
+
styleId: computeId(id),
|
|
898
|
+
rules: Array.isArray(css) ? css : [
|
|
899
|
+
css
|
|
900
|
+
]
|
|
901
|
+
};
|
|
902
|
+
};
|
|
903
|
+
/**
|
|
904
|
+
* selectFromServer
|
|
905
|
+
*
|
|
906
|
+
* Collects style tags from the document with id __jsx-XXX
|
|
907
|
+
*/ _proto.selectFromServer = function selectFromServer() {
|
|
908
|
+
var elements = Array.prototype.slice.call(document.querySelectorAll('[id^="__jsx-"]'));
|
|
909
|
+
return elements.reduce(function(acc, element) {
|
|
910
|
+
var id = element.id.slice(2);
|
|
911
|
+
acc[id] = element;
|
|
912
|
+
return acc;
|
|
913
|
+
}, {});
|
|
914
|
+
};
|
|
915
|
+
return StyleSheetRegistry;
|
|
916
|
+
}();
|
|
917
|
+
function invariant(condition, message) {
|
|
918
|
+
if (!condition) {
|
|
919
|
+
throw new Error("StyleSheetRegistry: " + message + ".");
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
var StyleSheetContext = /*#__PURE__*/ React$1.createContext(null);
|
|
923
|
+
StyleSheetContext.displayName = "StyleSheetContext";
|
|
924
|
+
function createStyleRegistry() {
|
|
925
|
+
return new StyleSheetRegistry();
|
|
926
|
+
}
|
|
927
|
+
function StyleRegistry(param) {
|
|
928
|
+
var configuredRegistry = param.registry, children = param.children;
|
|
929
|
+
var rootRegistry = React$1.useContext(StyleSheetContext);
|
|
930
|
+
var ref = React$1.useState(function() {
|
|
931
|
+
return rootRegistry || configuredRegistry || createStyleRegistry();
|
|
932
|
+
}), registry = ref[0];
|
|
933
|
+
return /*#__PURE__*/ React__default["default"].createElement(StyleSheetContext.Provider, {
|
|
934
|
+
value: registry
|
|
935
|
+
}, children);
|
|
936
|
+
}
|
|
937
|
+
function useStyleRegistry() {
|
|
938
|
+
return React$1.useContext(StyleSheetContext);
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
// Opt-into the new `useInsertionEffect` API in React 18, fallback to `useLayoutEffect`.
|
|
942
|
+
// https://github.com/reactwg/react-18/discussions/110
|
|
943
|
+
var useInsertionEffect = React__default["default"].useInsertionEffect || React$1.useLayoutEffect;
|
|
944
|
+
var defaultRegistry = typeof window !== "undefined" ? createStyleRegistry() : undefined;
|
|
945
|
+
function JSXStyle(props) {
|
|
946
|
+
var registry = defaultRegistry ? defaultRegistry : useStyleRegistry();
|
|
947
|
+
var insertionEffectCalled = React$1.useRef(false);
|
|
948
|
+
// `registry` might not exist while server-side rendering
|
|
949
|
+
if (!registry) {
|
|
950
|
+
return null;
|
|
951
|
+
}
|
|
952
|
+
if (typeof window === "undefined") {
|
|
953
|
+
registry.add(props);
|
|
954
|
+
return null;
|
|
955
|
+
}
|
|
956
|
+
useInsertionEffect(function() {
|
|
957
|
+
// ReactDOM removes all DOM during hydration in certain cases
|
|
958
|
+
if (!document.head) {
|
|
959
|
+
return;
|
|
960
|
+
}
|
|
961
|
+
registry.add(props);
|
|
962
|
+
insertionEffectCalled.current = true;
|
|
963
|
+
return function() {
|
|
964
|
+
insertionEffectCalled.current = false;
|
|
965
|
+
registry.remove(props);
|
|
966
|
+
};
|
|
967
|
+
}, [
|
|
968
|
+
props.id,
|
|
969
|
+
String(props.dynamic)
|
|
970
|
+
]);
|
|
971
|
+
React$1.useLayoutEffect(function() {
|
|
972
|
+
if (!document.head || insertionEffectCalled.current) {
|
|
973
|
+
return;
|
|
974
|
+
}
|
|
975
|
+
registry.add(props);
|
|
976
|
+
return function() {
|
|
977
|
+
registry.remove(props);
|
|
978
|
+
};
|
|
979
|
+
// props.children can be string[], will be striped since id is identical
|
|
980
|
+
}, [
|
|
981
|
+
props.id,
|
|
982
|
+
String(props.dynamic)
|
|
983
|
+
]);
|
|
984
|
+
return null;
|
|
985
|
+
}
|
|
986
|
+
JSXStyle.dynamic = function(info) {
|
|
987
|
+
return info.map(function(tagInfo) {
|
|
988
|
+
var baseId = tagInfo[0];
|
|
989
|
+
var props = tagInfo[1];
|
|
990
|
+
return computeId(baseId, props);
|
|
991
|
+
}).join(" ");
|
|
992
|
+
};
|
|
993
|
+
|
|
994
|
+
index.StyleRegistry = StyleRegistry;
|
|
995
|
+
index.createStyleRegistry = createStyleRegistry;
|
|
996
|
+
index.style = JSXStyle;
|
|
997
|
+
index.useStyleRegistry = useStyleRegistry;
|
|
998
|
+
return index;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
var style;
|
|
1002
|
+
var hasRequiredStyle;
|
|
1003
|
+
|
|
1004
|
+
function requireStyle () {
|
|
1005
|
+
if (hasRequiredStyle) return style;
|
|
1006
|
+
hasRequiredStyle = 1;
|
|
1007
|
+
style = requireIndex().style;
|
|
1008
|
+
return style;
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
var styleExports = requireStyle();
|
|
1012
|
+
var _JSXStyle = /*@__PURE__*/getDefaultExportFromCjs(styleExports);
|
|
1013
|
+
|
|
1014
|
+
/* "use client" */
|
|
1015
|
+
|
|
1016
|
+
var getId = function getId() {
|
|
1017
|
+
return Math.random().toString(32).slice(2, 10);
|
|
1018
|
+
};
|
|
1019
|
+
var isBrowser = function isBrowser() {
|
|
1020
|
+
return Boolean(typeof window !== 'undefined' && window.document && window.document.createElement);
|
|
1021
|
+
};
|
|
1022
|
+
|
|
1023
|
+
var useSSR = function useSSR() {
|
|
1024
|
+
var _useState = React.useState(false),
|
|
1025
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1026
|
+
browser = _useState2[0],
|
|
1027
|
+
setBrowser = _useState2[1];
|
|
1028
|
+
React.useEffect(function () {
|
|
1029
|
+
setBrowser(isBrowser());
|
|
1030
|
+
}, []);
|
|
1031
|
+
return {
|
|
1032
|
+
isBrowser: browser,
|
|
1033
|
+
isServer: !browser
|
|
1034
|
+
};
|
|
1035
|
+
};
|
|
1036
|
+
|
|
1037
|
+
var createElement = function createElement(id) {
|
|
1038
|
+
var el = document.createElement('div');
|
|
1039
|
+
el.setAttribute('id', id);
|
|
1040
|
+
return el;
|
|
1041
|
+
};
|
|
1042
|
+
var usePortal = function usePortal() {
|
|
1043
|
+
var selectId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getId();
|
|
1044
|
+
var getContainer = arguments.length > 1 ? arguments[1] : undefined;
|
|
1045
|
+
var id = "helpdice-ui-".concat(selectId);
|
|
1046
|
+
var _useSSR = useSSR(),
|
|
1047
|
+
isBrowser = _useSSR.isBrowser;
|
|
1048
|
+
var _useState = React.useState(isBrowser ? createElement(id) : null),
|
|
1049
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1050
|
+
elSnapshot = _useState2[0],
|
|
1051
|
+
setElSnapshot = _useState2[1];
|
|
1052
|
+
React.useEffect(function () {
|
|
1053
|
+
var customContainer = getContainer ? getContainer() : null;
|
|
1054
|
+
var parentElement = customContainer || document.body;
|
|
1055
|
+
var hasElement = parentElement.querySelector("#".concat(id));
|
|
1056
|
+
var el = hasElement || createElement(id);
|
|
1057
|
+
if (!hasElement) {
|
|
1058
|
+
parentElement.appendChild(el);
|
|
1059
|
+
}
|
|
1060
|
+
setElSnapshot(el);
|
|
1061
|
+
}, []);
|
|
1062
|
+
return elSnapshot;
|
|
1063
|
+
};
|
|
1064
|
+
|
|
1065
|
+
var _excluded = ["children", "className", "visible", "enterTime", "leaveTime", "clearTime", "name"];
|
|
1066
|
+
var CssTransition = function CssTransition(_ref) {
|
|
1067
|
+
var children = _ref.children,
|
|
1068
|
+
_ref$className = _ref.className,
|
|
1069
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
1070
|
+
_ref$visible = _ref.visible,
|
|
1071
|
+
visible = _ref$visible === void 0 ? false : _ref$visible,
|
|
1072
|
+
_ref$enterTime = _ref.enterTime,
|
|
1073
|
+
enterTime = _ref$enterTime === void 0 ? 60 : _ref$enterTime,
|
|
1074
|
+
_ref$leaveTime = _ref.leaveTime,
|
|
1075
|
+
leaveTime = _ref$leaveTime === void 0 ? 60 : _ref$leaveTime,
|
|
1076
|
+
_ref$clearTime = _ref.clearTime,
|
|
1077
|
+
clearTime = _ref$clearTime === void 0 ? 60 : _ref$clearTime,
|
|
1078
|
+
_ref$name = _ref.name,
|
|
1079
|
+
name = _ref$name === void 0 ? 'transition' : _ref$name,
|
|
1080
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
1081
|
+
var _useState = React.useState(''),
|
|
1082
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1083
|
+
classes = _useState2[0],
|
|
1084
|
+
setClasses = _useState2[1];
|
|
1085
|
+
var _useState3 = React.useState(visible),
|
|
1086
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
1087
|
+
renderable = _useState4[0],
|
|
1088
|
+
setRenderable = _useState4[1];
|
|
1089
|
+
React.useEffect(function () {
|
|
1090
|
+
var statusClassName = visible ? 'enter' : 'leave';
|
|
1091
|
+
var time = visible ? enterTime : leaveTime;
|
|
1092
|
+
if (visible && !renderable) {
|
|
1093
|
+
setRenderable(true);
|
|
1094
|
+
}
|
|
1095
|
+
setClasses("".concat(name, "-").concat(statusClassName));
|
|
1096
|
+
|
|
1097
|
+
// set class to active
|
|
1098
|
+
var timer = setTimeout(function () {
|
|
1099
|
+
setClasses("".concat(name, "-").concat(statusClassName, " ").concat(name, "-").concat(statusClassName, "-active"));
|
|
1100
|
+
clearTimeout(timer);
|
|
1101
|
+
}, time);
|
|
1102
|
+
|
|
1103
|
+
// remove classess when animation over
|
|
1104
|
+
var clearClassesTimer = setTimeout(function () {
|
|
1105
|
+
if (!visible) {
|
|
1106
|
+
setClasses('');
|
|
1107
|
+
setRenderable(false);
|
|
1108
|
+
}
|
|
1109
|
+
clearTimeout(clearClassesTimer);
|
|
1110
|
+
}, time + clearTime);
|
|
1111
|
+
return function () {
|
|
1112
|
+
clearTimeout(timer);
|
|
1113
|
+
clearTimeout(clearClassesTimer);
|
|
1114
|
+
};
|
|
1115
|
+
}, [visible, renderable]);
|
|
1116
|
+
if (! /*#__PURE__*/React.isValidElement(children) || !renderable) return null;
|
|
1117
|
+
var propsTransition = _objectSpread2(_objectSpread2({}, props), {}, {
|
|
1118
|
+
className: "".concat(children.props.className, " ").concat(className, " ").concat(classes)
|
|
1119
|
+
});
|
|
1120
|
+
return /*#__PURE__*/React.cloneElement(children, propsTransition);
|
|
1121
|
+
};
|
|
1122
|
+
CssTransition.displayName = 'CssTransition';
|
|
1123
|
+
|
|
1124
|
+
var tuple = function tuple() {
|
|
1125
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1126
|
+
args[_key] = arguments[_key];
|
|
1127
|
+
}
|
|
1128
|
+
return args;
|
|
1129
|
+
};
|
|
1130
|
+
tuple('default', 'secondary', 'success', 'warning', 'error', 'abort', 'secondary-light', 'success-light', 'warning-light', 'error-light');
|
|
1131
|
+
tuple('default', 'secondary', 'success', 'warning', 'error');
|
|
1132
|
+
tuple('default', 'secondary', 'success', 'warning', 'error', 'dark', 'lite');
|
|
1133
|
+
tuple('default', 'secondary', 'success', 'warning', 'error', 'dark', 'lite', 'alert', 'purple', 'violet', 'cyan');
|
|
1134
|
+
tuple('default', 'silent', 'prevent');
|
|
1135
|
+
tuple('hover', 'click');
|
|
1136
|
+
tuple('top', 'topStart', 'topEnd', 'left', 'leftStart', 'leftEnd', 'bottom', 'bottomStart', 'bottomEnd', 'right', 'rightStart', 'rightEnd');
|
|
1137
|
+
tuple('start', 'center', 'end', 'left', 'right');
|
|
1138
|
+
|
|
1139
|
+
var makeToastActions = function makeToastActions(actions, cancelHandle) {
|
|
1140
|
+
var handler = function handler(event, userHandler) {
|
|
1141
|
+
userHandler && userHandler(event, cancelHandle);
|
|
1142
|
+
};
|
|
1143
|
+
if (!actions || !actions.length) return null;
|
|
1144
|
+
return actions.map(function (action, index) {
|
|
1145
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
1146
|
+
color: action.passive ? 'default' : 'secondary',
|
|
1147
|
+
key: "action-".concat(index),
|
|
1148
|
+
onClick: function onClick(event) {
|
|
1149
|
+
return handler(event, action.handler);
|
|
1150
|
+
}
|
|
1151
|
+
}, action.name);
|
|
1152
|
+
});
|
|
1153
|
+
};
|
|
1154
|
+
var getColors = function getColors(palette, type) {
|
|
1155
|
+
var colors = {
|
|
1156
|
+
"default": palette.background,
|
|
1157
|
+
secondary: palette.secondary,
|
|
1158
|
+
success: palette.success,
|
|
1159
|
+
warning: palette.warning,
|
|
1160
|
+
error: palette.error
|
|
1161
|
+
};
|
|
1162
|
+
var isDefault = !type || type === 'default';
|
|
1163
|
+
if (isDefault) return {
|
|
1164
|
+
bgColor: colors["default"],
|
|
1165
|
+
color: palette.foreground
|
|
1166
|
+
};
|
|
1167
|
+
/**
|
|
1168
|
+
* Prevent main color change in special types.
|
|
1169
|
+
* The color will only follow the theme when it is in the default type.
|
|
1170
|
+
*/
|
|
1171
|
+
return {
|
|
1172
|
+
bgColor: colors[type],
|
|
1173
|
+
color: 'white'
|
|
1174
|
+
};
|
|
1175
|
+
};
|
|
1176
|
+
tuple('topLeft', 'topRight', 'bottomLeft', 'bottomRight');
|
|
1177
|
+
var isTopPlacement = function isTopPlacement(placement) {
|
|
1178
|
+
return "".concat(placement).toLowerCase().startsWith('top');
|
|
1179
|
+
};
|
|
1180
|
+
var isLeftPlacement = function isLeftPlacement(placement) {
|
|
1181
|
+
return "".concat(placement).toLowerCase().endsWith('left');
|
|
1182
|
+
};
|
|
1183
|
+
var getTranslateByPlacement = function getTranslateByPlacement(placement) {
|
|
1184
|
+
var translateInByPlacement = {
|
|
1185
|
+
topLeft: 'translate(-60px, -60px)',
|
|
1186
|
+
topRight: 'translate(60px, -60px)',
|
|
1187
|
+
bottomLeft: 'translate(-60px, 60px)',
|
|
1188
|
+
bottomRight: 'translate(60px, 60px)'
|
|
1189
|
+
};
|
|
1190
|
+
var translateOutByPlacement = {
|
|
1191
|
+
topLeft: 'translate(-50px, 15px) scale(0.85)',
|
|
1192
|
+
topRight: 'translate(50px, 15px) scale(0.85)',
|
|
1193
|
+
bottomLeft: 'translate(-50px, -15px) scale(0.85)',
|
|
1194
|
+
bottomRight: 'translate(50px, -15px) scale(0.85)'
|
|
1195
|
+
};
|
|
1196
|
+
return {
|
|
1197
|
+
enter: translateInByPlacement[placement],
|
|
1198
|
+
leave: translateOutByPlacement[placement]
|
|
1199
|
+
};
|
|
1200
|
+
};
|
|
1201
|
+
|
|
1202
|
+
var ToastItem = /*#__PURE__*/React.memo(function (_ref) {
|
|
1203
|
+
var toast = _ref.toast,
|
|
1204
|
+
layout = _ref.layout;
|
|
1205
|
+
var theme = useTheme();
|
|
1206
|
+
var _useMemo = React.useMemo(function () {
|
|
1207
|
+
return getColors(theme.palette, toast.type);
|
|
1208
|
+
}, [theme.palette, toast.type]),
|
|
1209
|
+
color = _useMemo.color,
|
|
1210
|
+
bgColor = _useMemo.bgColor;
|
|
1211
|
+
var isReactNode = typeof toast.text !== 'string';
|
|
1212
|
+
var padding = layout.padding,
|
|
1213
|
+
margin = layout.margin,
|
|
1214
|
+
maxHeight = layout.maxHeight,
|
|
1215
|
+
maxWidth = layout.maxWidth,
|
|
1216
|
+
width = layout.width,
|
|
1217
|
+
placement = layout.placement;
|
|
1218
|
+
var _useMemo2 = React.useMemo(function () {
|
|
1219
|
+
return getTranslateByPlacement(placement);
|
|
1220
|
+
}, [placement]),
|
|
1221
|
+
enter = _useMemo2.enter,
|
|
1222
|
+
leave = _useMemo2.leave;
|
|
1223
|
+
return /*#__PURE__*/React.createElement(CssTransition, {
|
|
1224
|
+
name: "toast",
|
|
1225
|
+
visible: toast.visible,
|
|
1226
|
+
clearTime: 350
|
|
1227
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1228
|
+
key: toast.id,
|
|
1229
|
+
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"
|
|
1230
|
+
}, isReactNode ? toast.text : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
1231
|
+
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"
|
|
1232
|
+
}, toast.text), /*#__PURE__*/React.createElement("div", {
|
|
1233
|
+
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"
|
|
1234
|
+
}, makeToastActions(toast.actions, toast.cancel))), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
1235
|
+
id: "1407001838",
|
|
1236
|
+
dynamic: [width, maxWidth, maxHeight, theme.palette.foreground, bgColor, color, theme.layout.radius, theme.expressiveness.shadowSmall, theme.layout.gapHalf, enter, margin, padding, margin, padding, leave]
|
|
1237
|
+
}, ".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, ";}"))));
|
|
1238
|
+
});
|
|
1239
|
+
|
|
1240
|
+
/* "use client" */
|
|
1241
|
+
|
|
1242
|
+
var classObjectToString = function classObjectToString(className) {
|
|
1243
|
+
var keys = Object.keys(className);
|
|
1244
|
+
var len = keys.length;
|
|
1245
|
+
var str = '';
|
|
1246
|
+
for (var index = 0; index < len; index++) {
|
|
1247
|
+
var key = keys[index];
|
|
1248
|
+
var val = className[keys[index]];
|
|
1249
|
+
if (!val) continue;
|
|
1250
|
+
str = str ? "".concat(str, " ").concat(String(key)) : String(key);
|
|
1251
|
+
}
|
|
1252
|
+
return str;
|
|
1253
|
+
};
|
|
1254
|
+
var isObjectClassName = function isObjectClassName(value) {
|
|
1255
|
+
return _typeof(value) === 'object' && !Array.isArray(value);
|
|
1256
|
+
};
|
|
1257
|
+
var useClasses = function useClasses() {
|
|
1258
|
+
var len = arguments.length;
|
|
1259
|
+
var classes = '';
|
|
1260
|
+
if (len === 0) return classes;
|
|
1261
|
+
for (var index = 0; index < len; index++) {
|
|
1262
|
+
var val = index < 0 || arguments.length <= index ? undefined : arguments[index];
|
|
1263
|
+
if (!val) continue;
|
|
1264
|
+
if (isObjectClassName(val)) {
|
|
1265
|
+
classes += " ".concat(classObjectToString(val));
|
|
1266
|
+
} else {
|
|
1267
|
+
classes += " ".concat(String(val).trim());
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
return classes.trim();
|
|
1271
|
+
};
|
|
1272
|
+
|
|
1273
|
+
var ToastContainer = function ToastContainer() {
|
|
1274
|
+
var theme = useTheme();
|
|
1275
|
+
var portal = usePortal('toast');
|
|
1276
|
+
var _useCurrentState = useCurrentState(false),
|
|
1277
|
+
_useCurrentState2 = _slicedToArray(_useCurrentState, 3),
|
|
1278
|
+
setHovering = _useCurrentState2[1],
|
|
1279
|
+
hoveringRef = _useCurrentState2[2];
|
|
1280
|
+
var _useHUIContext = useHUIContext(),
|
|
1281
|
+
toasts = _useHUIContext.toasts,
|
|
1282
|
+
updateToasts = _useHUIContext.updateToasts,
|
|
1283
|
+
toastLayout = _useHUIContext.toastLayout,
|
|
1284
|
+
lastUpdateToastId = _useHUIContext.lastUpdateToastId;
|
|
1285
|
+
var memoizedLayout = React.useMemo(function () {
|
|
1286
|
+
return toastLayout;
|
|
1287
|
+
}, [toastLayout]);
|
|
1288
|
+
var toastElements = React.useMemo(function () {
|
|
1289
|
+
return toasts.map(function (toast) {
|
|
1290
|
+
return /*#__PURE__*/React.createElement(ToastItem, {
|
|
1291
|
+
toast: toast,
|
|
1292
|
+
layout: memoizedLayout,
|
|
1293
|
+
key: toast._internalIdent
|
|
1294
|
+
});
|
|
1295
|
+
});
|
|
1296
|
+
}, [toasts, memoizedLayout]);
|
|
1297
|
+
var classNames = React.useMemo(function () {
|
|
1298
|
+
return useClasses('toasts', {
|
|
1299
|
+
top: isTopPlacement(toastLayout.placement),
|
|
1300
|
+
left: isLeftPlacement(toastLayout.placement)
|
|
1301
|
+
});
|
|
1302
|
+
}, [memoizedLayout]);
|
|
1303
|
+
var hoverHandler = function hoverHandler(isHovering) {
|
|
1304
|
+
setHovering(isHovering);
|
|
1305
|
+
if (isHovering) {
|
|
1306
|
+
return updateToasts(function (last) {
|
|
1307
|
+
return last.map(function (toast) {
|
|
1308
|
+
if (!toast.visible) return toast;
|
|
1309
|
+
toast._timeout && window.clearTimeout(toast._timeout);
|
|
1310
|
+
return _objectSpread2(_objectSpread2({}, toast), {}, {
|
|
1311
|
+
timeout: null
|
|
1312
|
+
});
|
|
1313
|
+
});
|
|
1314
|
+
});
|
|
1315
|
+
}
|
|
1316
|
+
updateToasts(function (last) {
|
|
1317
|
+
return last.map(function (toast, index) {
|
|
1318
|
+
if (!toast.visible) return toast;
|
|
1319
|
+
toast._timeout && window.clearTimeout(toast._timeout);
|
|
1320
|
+
return _objectSpread2(_objectSpread2({}, toast), {}, {
|
|
1321
|
+
_timeout: function () {
|
|
1322
|
+
var timer = window.setTimeout(function () {
|
|
1323
|
+
toast.cancel();
|
|
1324
|
+
window.clearTimeout(timer);
|
|
1325
|
+
}, toast.delay + index * 100);
|
|
1326
|
+
return timer;
|
|
1327
|
+
}()
|
|
1328
|
+
});
|
|
1329
|
+
});
|
|
1330
|
+
});
|
|
1331
|
+
};
|
|
1332
|
+
React.useEffect(function () {
|
|
1333
|
+
var index = toasts.findIndex(function (r) {
|
|
1334
|
+
return r._internalIdent === lastUpdateToastId;
|
|
1335
|
+
});
|
|
1336
|
+
var toast = toasts[index];
|
|
1337
|
+
if (!toast || toast.visible || !hoveringRef.current) return;
|
|
1338
|
+
var hasVisible = toasts.find(function (r, i) {
|
|
1339
|
+
return i < index && r.visible;
|
|
1340
|
+
});
|
|
1341
|
+
if (hasVisible || !hoveringRef.current) return;
|
|
1342
|
+
hoverHandler(false);
|
|
1343
|
+
}, [toasts, lastUpdateToastId]);
|
|
1344
|
+
React.useEffect(function () {
|
|
1345
|
+
var timeout = null;
|
|
1346
|
+
var timer = window.setInterval(function () {
|
|
1347
|
+
if (toasts.length === 0) return;
|
|
1348
|
+
timeout = window.setTimeout(function () {
|
|
1349
|
+
var allInvisible = !toasts.find(function (r) {
|
|
1350
|
+
return r.visible;
|
|
1351
|
+
});
|
|
1352
|
+
allInvisible && updateToasts(function () {
|
|
1353
|
+
return [];
|
|
1354
|
+
});
|
|
1355
|
+
timeout && clearTimeout(timeout);
|
|
1356
|
+
}, 350);
|
|
1357
|
+
}, 5000);
|
|
1358
|
+
return function () {
|
|
1359
|
+
timer && clearInterval(timer);
|
|
1360
|
+
timeout && clearTimeout(timeout);
|
|
1361
|
+
};
|
|
1362
|
+
}, [toasts]);
|
|
1363
|
+
if (!portal) return null;
|
|
1364
|
+
if (!toasts || toasts.length === 0) return null;
|
|
1365
|
+
return /*#__PURE__*/reactDom.createPortal(/*#__PURE__*/React.createElement("div", {
|
|
1366
|
+
onMouseEnter: function onMouseEnter() {
|
|
1367
|
+
return hoverHandler(true);
|
|
1368
|
+
},
|
|
1369
|
+
onMouseLeave: function onMouseLeave() {
|
|
1370
|
+
return hoverHandler(false);
|
|
1371
|
+
},
|
|
1372
|
+
className: _JSXStyle.dynamic([["622610754", [theme.layout.gap, theme.layout.gap, theme.layout.gap, theme.layout.gap]]]) + " " + (classNames || "")
|
|
1373
|
+
}, toastElements, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
1374
|
+
id: "622610754",
|
|
1375
|
+
dynamic: [theme.layout.gap, theme.layout.gap, theme.layout.gap, theme.layout.gap]
|
|
1376
|
+
}, ".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);
|
|
1377
|
+
};
|
|
1378
|
+
|
|
1379
|
+
var HuiProvider = function HuiProvider(_ref) {
|
|
1380
|
+
var themes = _ref.themes,
|
|
1381
|
+
themeType = _ref.themeType,
|
|
1382
|
+
children = _ref.children;
|
|
1383
|
+
var _React$useState = React.useState(''),
|
|
1384
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
1385
|
+
lastUpdateToastId = _React$useState2[0],
|
|
1386
|
+
setLastUpdateToastId = _React$useState2[1];
|
|
1387
|
+
var _useCurrentState = useCurrentState([]),
|
|
1388
|
+
_useCurrentState2 = _slicedToArray(_useCurrentState, 3),
|
|
1389
|
+
toasts = _useCurrentState2[0],
|
|
1390
|
+
setToasts = _useCurrentState2[1],
|
|
1391
|
+
toastsRef = _useCurrentState2[2];
|
|
1392
|
+
var _useCurrentState3 = useCurrentState(defaultToastLayout),
|
|
1393
|
+
_useCurrentState4 = _slicedToArray(_useCurrentState3, 3),
|
|
1394
|
+
toastLayout = _useCurrentState4[0],
|
|
1395
|
+
setToastLayout = _useCurrentState4[1],
|
|
1396
|
+
toastLayoutRef = _useCurrentState4[2];
|
|
1397
|
+
var updateToasts = function updateToasts(fn) {
|
|
1398
|
+
var nextToasts = fn(toastsRef.current);
|
|
1399
|
+
setToasts(nextToasts);
|
|
1400
|
+
};
|
|
1401
|
+
var updateToastLayout = function updateToastLayout(fn) {
|
|
1402
|
+
var nextLayout = fn(toastLayoutRef.current);
|
|
1403
|
+
setToastLayout(nextLayout);
|
|
1404
|
+
};
|
|
1405
|
+
var updateLastToastId = function updateLastToastId(fn) {
|
|
1406
|
+
setLastUpdateToastId(fn());
|
|
1407
|
+
};
|
|
1408
|
+
var initialValue = React.useMemo(function () {
|
|
1409
|
+
return {
|
|
1410
|
+
toasts: toasts,
|
|
1411
|
+
toastLayout: toastLayout,
|
|
1412
|
+
updateToasts: updateToasts,
|
|
1413
|
+
lastUpdateToastId: lastUpdateToastId,
|
|
1414
|
+
updateToastLayout: updateToastLayout,
|
|
1415
|
+
updateLastToastId: updateLastToastId
|
|
1416
|
+
};
|
|
1417
|
+
}, [toasts, toastLayout, lastUpdateToastId]);
|
|
1418
|
+
return /*#__PURE__*/React.createElement(HUIContent.Provider, {
|
|
1419
|
+
value: initialValue
|
|
1420
|
+
}, /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
1421
|
+
themes: themes,
|
|
1422
|
+
themeType: themeType
|
|
1423
|
+
}, children, /*#__PURE__*/React.createElement(ToastContainer, null)));
|
|
1424
|
+
};
|
|
1425
|
+
|
|
1426
|
+
// import flush from 'styled-jsx'
|
|
1427
|
+
|
|
1428
|
+
// export type FlushToReact = <T>(opts?: { nonce?: string }) => Array<ReactElement<T>>
|
|
1429
|
+
|
|
1430
|
+
// export type FlushToHTML = (opts?: { nonce?: string }) => string
|
|
1431
|
+
|
|
1432
|
+
var CssBaseline = function CssBaseline(_ref) {
|
|
1433
|
+
var children = _ref.children;
|
|
1434
|
+
var theme = useTheme();
|
|
1435
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
1436
|
+
id: "3647548829",
|
|
1437
|
+
dynamic: [theme.palette.background, theme.palette.foreground, theme.palette.background, theme.font.sans, theme.font.sans, theme.palette.link, theme.expressiveness.linkStyle, theme.expressiveness.linkHoverStyle, theme.layout.gapHalf, theme.layout.gapHalf, theme.layout.gapHalf, theme.layout.gap, theme.palette.foreground, theme.palette.code, theme.font.mono, theme.layout.gap, theme.layout.gap, theme.layout.gap, theme.palette.accents_2, theme.layout.radius, theme.font.mono, theme.palette.foreground, theme.palette.accents_2, theme.palette.accents_1, theme.layout.gap, theme.layout.gap, theme.palette.accents_5, theme.palette.accents_1, theme.layout.radius, theme.palette.border, theme.palette.selection, theme.palette.foreground]
|
|
1438
|
+
}, "html,body{background-color:".concat(theme.palette.background, ";color:").concat(theme.palette.foreground, ";}html{font-size:16px;--helpdice-icons-background:").concat(theme.palette.background, ";}body{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-rendering:optimizeLegibility;font-size:1rem;line-height:1.5;margin:0;padding:0;min-height:100%;position:relative;overflow-x:hidden;font-family:").concat(theme.font.sans, ";}#__next{overflow-x:hidden;}*,*:before,*:after{box-sizing:inherit;text-rendering:geometricPrecision;-webkit-tap-highlight-color:transparent;}p,small{font-weight:400;color:inherit;-webkit-letter-spacing:-0.005625em;-moz-letter-spacing:-0.005625em;-ms-letter-spacing:-0.005625em;letter-spacing:-0.005625em;font-family:").concat(theme.font.sans, ";}p{margin:1em 0;font-size:1em;line-height:1.625em;}small{margin:0;line-height:1.5;font-size:0.875em;}b{font-weight:600;}span{font-size:inherit;color:inherit;font-weight:inherit;}img{max-width:100%;}a{cursor:pointer;font-size:inherit;-webkit-touch-callout:none;-webkit-tap-highlight-color:rgba(0,0,0,0);-webkit-box-align:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:").concat(theme.palette.link, ";-webkit-text-decoration:").concat(theme.expressiveness.linkStyle, ";text-decoration:").concat(theme.expressiveness.linkStyle, ";}a:hover{-webkit-text-decoration:").concat(theme.expressiveness.linkHoverStyle, ";text-decoration:").concat(theme.expressiveness.linkHoverStyle, ";}ul,ol{padding:0;list-style-type:none;margin:").concat(theme.layout.gapHalf, " ").concat(theme.layout.gapHalf, " ").concat(theme.layout.gapHalf, " ").concat(theme.layout.gap, ";color:").concat(theme.palette.foreground, ";}ol{list-style-type:decimal;}li{margin-bottom:0.625em;font-size:1em;line-height:1.625em;}h1,h2,h3,h4,h5,h6{color:inherit;margin:0 0 0.7rem 0;}h1{font-size:3rem;-webkit-letter-spacing:-0.02em;-moz-letter-spacing:-0.02em;-ms-letter-spacing:-0.02em;letter-spacing:-0.02em;line-height:1.5;font-weight:700;}h2{font-size:2.25rem;-webkit-letter-spacing:-0.02em;-moz-letter-spacing:-0.02em;-ms-letter-spacing:-0.02em;letter-spacing:-0.02em;font-weight:600;}h3{font-size:1.5rem;-webkit-letter-spacing:-0.02em;-moz-letter-spacing:-0.02em;-ms-letter-spacing:-0.02em;letter-spacing:-0.02em;font-weight:600;}h4{font-size:1.25rem;-webkit-letter-spacing:-0.02em;-moz-letter-spacing:-0.02em;-ms-letter-spacing:-0.02em;letter-spacing:-0.02em;font-weight:600;}h5{font-size:1rem;-webkit-letter-spacing:-0.01em;-moz-letter-spacing:-0.01em;-ms-letter-spacing:-0.01em;letter-spacing:-0.01em;font-weight:600;}h6{font-size:0.875rem;-webkit-letter-spacing:-0.005em;-moz-letter-spacing:-0.005em;-ms-letter-spacing:-0.005em;letter-spacing:-0.005em;font-weight:600;}button,input,select,textarea{font-family:inherit;font-size:inherit;line-height:inherit;color:inherit;margin:0;}button:focus,input:focus,select:focus,textarea:focus{outline:none;}code{color:").concat(theme.palette.code, ";font-family:").concat(theme.font.mono, ";font-size:0.9em;white-space:pre-wrap;}code:before,code:after{content:'\\`';}pre{padding:calc(").concat(theme.layout.gap, " * 0.9) ").concat(theme.layout.gap, ";margin:").concat(theme.layout.gap, " 0;border:1px solid ").concat(theme.palette.accents_2, ";border-radius:").concat(theme.layout.radius, ";font-family:").concat(theme.font.mono, ";white-space:pre;overflow:auto;line-height:1.5;text-align:left;font-size:14px;-webkit-overflow-scrolling:touch;}pre code{color:").concat(theme.palette.foreground, ";font-size:1em;line-height:1.25em;white-space:pre;}pre code:before,pre code:after{display:none;}pre p{margin:0;}pre::-webkit-scrollbar{display:none;width:0;height:0;background:transparent;}hr{border-color:").concat(theme.palette.accents_2, ";}details{background-color:").concat(theme.palette.accents_1, ";border:none;}details:focus,details:hover,details:active{outline:none;}summary{cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;list-style:none;outline:none;}summary::marker,summary::before,summary::-webkit-details-marker{display:none;}summary::-moz-list-bullet{font-size:0;}summary:focus,summary:hover,summary:active{outline:none;list-style:none;}blockquote{padding:calc(0.667 * ").concat(theme.layout.gap, ") ").concat(theme.layout.gap, ";color:").concat(theme.palette.accents_5, ";background-color:").concat(theme.palette.accents_1, ";border-radius:").concat(theme.layout.radius, ";margin:1.5em 0;border:1px solid ").concat(theme.palette.border, ";}blockquote *:first-child{margin-top:0;}blockquote *:last-child{margin-bottom:0;}::selection{background-color:").concat(theme.palette.selection, ";color:").concat(theme.palette.foreground, ";}")));
|
|
1439
|
+
};
|
|
1440
|
+
var MemoCssBaseline = /*#__PURE__*/React.memo(CssBaseline);
|
|
1441
|
+
|
|
1442
|
+
var getElementOffset = function getElementOffset(el) {
|
|
1443
|
+
if (!el) return {
|
|
1444
|
+
top: 0,
|
|
1445
|
+
left: 0
|
|
1446
|
+
};
|
|
1447
|
+
var _el$getBoundingClient = el.getBoundingClientRect(),
|
|
1448
|
+
top = _el$getBoundingClient.top,
|
|
1449
|
+
left = _el$getBoundingClient.left;
|
|
1450
|
+
return {
|
|
1451
|
+
top: top,
|
|
1452
|
+
left: left
|
|
1453
|
+
};
|
|
1454
|
+
};
|
|
1455
|
+
var defaultRect = {
|
|
1456
|
+
top: -1e3,
|
|
1457
|
+
left: -1e3,
|
|
1458
|
+
right: -1e3,
|
|
1459
|
+
width: 0,
|
|
1460
|
+
height: 0,
|
|
1461
|
+
elementTop: -1e3
|
|
1462
|
+
};
|
|
1463
|
+
var getRectFromDOMWithContainer = function getRectFromDOMWithContainer(domRect, getContainer) {
|
|
1464
|
+
if (!domRect) return defaultRect;
|
|
1465
|
+
var container = getContainer ? getContainer() : null;
|
|
1466
|
+
var scrollElement = container || document.documentElement;
|
|
1467
|
+
var _getElementOffset = getElementOffset(container),
|
|
1468
|
+
offsetTop = _getElementOffset.top,
|
|
1469
|
+
offsetLeft = _getElementOffset.left;
|
|
1470
|
+
return _objectSpread2(_objectSpread2({}, domRect), {}, {
|
|
1471
|
+
width: domRect.width || domRect.right - domRect.left,
|
|
1472
|
+
height: domRect.height || domRect.top - domRect.bottom,
|
|
1473
|
+
top: domRect.bottom + scrollElement.scrollTop - offsetTop,
|
|
1474
|
+
left: domRect.left + scrollElement.scrollLeft - offsetLeft,
|
|
1475
|
+
elementTop: domRect.top + scrollElement.scrollTop - offsetTop
|
|
1476
|
+
});
|
|
1477
|
+
};
|
|
1478
|
+
var getRefRect = function getRefRect(ref, getContainer) {
|
|
1479
|
+
if (!ref || !ref.current) return defaultRect;
|
|
1480
|
+
var rect = ref.current.getBoundingClientRect();
|
|
1481
|
+
return getRectFromDOMWithContainer(rect, getContainer);
|
|
1482
|
+
};
|
|
1483
|
+
var getEventRect = function getEventRect(event, getContainer) {
|
|
1484
|
+
var _event$target;
|
|
1485
|
+
var rect = event === null || event === void 0 || (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.getBoundingClientRect();
|
|
1486
|
+
if (!rect) return defaultRect;
|
|
1487
|
+
return getRectFromDOMWithContainer(rect, getContainer);
|
|
1488
|
+
};
|
|
1489
|
+
var isRefTarget = function isRefTarget(eventOrRef) {
|
|
1490
|
+
return typeof (eventOrRef === null || eventOrRef === void 0 ? void 0 : eventOrRef.target) === 'undefined';
|
|
1491
|
+
};
|
|
1492
|
+
var useRect = function useRect(initialState) {
|
|
1493
|
+
var _useState = React.useState(initialState || defaultRect),
|
|
1494
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1495
|
+
rect = _useState2[0],
|
|
1496
|
+
setRect = _useState2[1];
|
|
1497
|
+
var updateRect = function updateRect(eventOrRef, getContainer) {
|
|
1498
|
+
if (isRefTarget(eventOrRef)) return setRect(getRefRect(eventOrRef, getContainer));
|
|
1499
|
+
setRect(getEventRect(eventOrRef, getContainer));
|
|
1500
|
+
};
|
|
1501
|
+
return {
|
|
1502
|
+
rect: rect,
|
|
1503
|
+
setRect: updateRect
|
|
1504
|
+
};
|
|
1505
|
+
};
|
|
1506
|
+
|
|
1507
|
+
// @ts-ignore
|
|
1508
|
+
/// <reference types="styled-jsx" />
|
|
1509
|
+
|
|
1510
|
+
exports.CssBaseline = MemoCssBaseline;
|
|
1511
|
+
exports.Themes = Themes;
|
|
1512
|
+
exports.UiProvider = HuiProvider;
|
|
1513
|
+
exports.default = useTheme;
|
|
1514
|
+
exports.useAllThemes = useAllThemes;
|
|
1515
|
+
exports.useRect = useRect;
|
|
1516
|
+
exports.useTheme = useTheme;
|