@ttoss/ui 1.30.0 → 1.30.2
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/esm/index.js +2462 -121
- package/dist/index.d.ts +11 -10
- package/dist/index.js +2442 -119
- package/package.json +10 -10
- package/src/components/Button.tsx +54 -9
- package/src/components/Icon.tsx +374 -12
- package/src/index.ts +2 -5
- package/src/theme/ThemeProvider.tsx +13 -24
package/dist/index.js
CHANGED
|
@@ -6,6 +6,13 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __esm = (fn, res) => function __init() {
|
|
11
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
12
|
+
};
|
|
13
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
14
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
15
|
+
};
|
|
9
16
|
var __export = (target, all) => {
|
|
10
17
|
for (var name in all)
|
|
11
18
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -19,14 +26,136 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
26
|
return to;
|
|
20
27
|
};
|
|
21
28
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
33
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
34
|
mod
|
|
24
35
|
));
|
|
25
36
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
+
var __publicField = (obj, key, value) => {
|
|
38
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
39
|
+
return value;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// tsup.inject.js
|
|
43
|
+
var React;
|
|
44
|
+
var init_tsup_inject = __esm({
|
|
45
|
+
"tsup.inject.js"() {
|
|
46
|
+
"use strict";
|
|
47
|
+
React = __toESM(require("react"));
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// ../../node_modules/deepmerge/dist/cjs.js
|
|
52
|
+
var require_cjs = __commonJS({
|
|
53
|
+
"../../node_modules/deepmerge/dist/cjs.js"(exports, module2) {
|
|
54
|
+
"use strict";
|
|
55
|
+
init_tsup_inject();
|
|
56
|
+
var isMergeableObject = function isMergeableObject2(value) {
|
|
57
|
+
return isNonNullObject(value) && !isSpecial(value);
|
|
58
|
+
};
|
|
59
|
+
function isNonNullObject(value) {
|
|
60
|
+
return !!value && typeof value === "object";
|
|
61
|
+
}
|
|
62
|
+
function isSpecial(value) {
|
|
63
|
+
var stringValue = Object.prototype.toString.call(value);
|
|
64
|
+
return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value);
|
|
65
|
+
}
|
|
66
|
+
var canUseSymbol = typeof Symbol === "function" && Symbol.for;
|
|
67
|
+
var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for("react.element") : 60103;
|
|
68
|
+
function isReactElement(value) {
|
|
69
|
+
return value.$$typeof === REACT_ELEMENT_TYPE;
|
|
70
|
+
}
|
|
71
|
+
function emptyTarget(val) {
|
|
72
|
+
return Array.isArray(val) ? [] : {};
|
|
73
|
+
}
|
|
74
|
+
function cloneUnlessOtherwiseSpecified(value, options) {
|
|
75
|
+
return options.clone !== false && options.isMergeableObject(value) ? deepmerge2(emptyTarget(value), value, options) : value;
|
|
76
|
+
}
|
|
77
|
+
function defaultArrayMerge(target, source, options) {
|
|
78
|
+
return target.concat(source).map(function(element) {
|
|
79
|
+
return cloneUnlessOtherwiseSpecified(element, options);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function getMergeFunction(key, options) {
|
|
83
|
+
if (!options.customMerge) {
|
|
84
|
+
return deepmerge2;
|
|
85
|
+
}
|
|
86
|
+
var customMerge = options.customMerge(key);
|
|
87
|
+
return typeof customMerge === "function" ? customMerge : deepmerge2;
|
|
88
|
+
}
|
|
89
|
+
function getEnumerableOwnPropertySymbols(target) {
|
|
90
|
+
return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol) {
|
|
91
|
+
return Object.propertyIsEnumerable.call(target, symbol);
|
|
92
|
+
}) : [];
|
|
93
|
+
}
|
|
94
|
+
function getKeys(target) {
|
|
95
|
+
return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target));
|
|
96
|
+
}
|
|
97
|
+
function propertyIsOnObject(object, property) {
|
|
98
|
+
try {
|
|
99
|
+
return property in object;
|
|
100
|
+
} catch (_) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function propertyIsUnsafe(target, key) {
|
|
105
|
+
return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key));
|
|
106
|
+
}
|
|
107
|
+
function mergeObject(target, source, options) {
|
|
108
|
+
var destination = {};
|
|
109
|
+
if (options.isMergeableObject(target)) {
|
|
110
|
+
getKeys(target).forEach(function(key) {
|
|
111
|
+
destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
getKeys(source).forEach(function(key) {
|
|
115
|
+
if (propertyIsUnsafe(target, key)) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
|
|
119
|
+
destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
|
|
120
|
+
} else {
|
|
121
|
+
destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
return destination;
|
|
125
|
+
}
|
|
126
|
+
function deepmerge2(target, source, options) {
|
|
127
|
+
options = options || {};
|
|
128
|
+
options.arrayMerge = options.arrayMerge || defaultArrayMerge;
|
|
129
|
+
options.isMergeableObject = options.isMergeableObject || isMergeableObject;
|
|
130
|
+
options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
|
|
131
|
+
var sourceIsArray = Array.isArray(source);
|
|
132
|
+
var targetIsArray = Array.isArray(target);
|
|
133
|
+
var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
|
|
134
|
+
if (!sourceAndTargetTypesMatch) {
|
|
135
|
+
return cloneUnlessOtherwiseSpecified(source, options);
|
|
136
|
+
} else if (sourceIsArray) {
|
|
137
|
+
return options.arrayMerge(target, source, options);
|
|
138
|
+
} else {
|
|
139
|
+
return mergeObject(target, source, options);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
deepmerge2.all = function deepmergeAll(array, options) {
|
|
143
|
+
if (!Array.isArray(array)) {
|
|
144
|
+
throw new Error("first argument should be an array");
|
|
145
|
+
}
|
|
146
|
+
return array.reduce(function(prev, next) {
|
|
147
|
+
return deepmerge2(prev, next, options);
|
|
148
|
+
}, {});
|
|
149
|
+
};
|
|
150
|
+
var deepmerge_1 = deepmerge2;
|
|
151
|
+
module2.exports = deepmerge_1;
|
|
152
|
+
}
|
|
153
|
+
});
|
|
26
154
|
|
|
27
155
|
// src/index.ts
|
|
28
156
|
var src_exports = {};
|
|
29
157
|
__export(src_exports, {
|
|
158
|
+
BaseStyles: () => import_theme_ui23.BaseStyles,
|
|
30
159
|
Box: () => import_theme_ui3.Box,
|
|
31
160
|
Button: () => Button,
|
|
32
161
|
Card: () => import_theme_ui5.Card,
|
|
@@ -36,7 +165,7 @@ __export(src_exports, {
|
|
|
36
165
|
Flex: () => import_theme_ui7.Flex,
|
|
37
166
|
Grid: () => import_theme_ui8.Grid,
|
|
38
167
|
Heading: () => import_theme_ui9.Heading,
|
|
39
|
-
Icon: () =>
|
|
168
|
+
Icon: () => Icon2,
|
|
40
169
|
Image: () => import_theme_ui10.Image,
|
|
41
170
|
InfiniteLinearProgress: () => InfiniteLinearProgress,
|
|
42
171
|
Input: () => import_theme_ui11.Input,
|
|
@@ -49,122 +178,261 @@ __export(src_exports, {
|
|
|
49
178
|
Spinner: () => import_theme_ui17.Spinner,
|
|
50
179
|
Text: () => import_theme_ui15.Text,
|
|
51
180
|
Textarea: () => import_theme_ui21.Textarea,
|
|
52
|
-
ThemeProvider: () =>
|
|
181
|
+
ThemeProvider: () => ThemeProvider,
|
|
53
182
|
useBreakpointIndex: () => import_match_media.useBreakpointIndex,
|
|
54
183
|
useResponsiveValue: () => import_match_media.useResponsiveValue,
|
|
55
184
|
useTheme: () => useTheme
|
|
56
185
|
});
|
|
57
186
|
module.exports = __toCommonJS(src_exports);
|
|
187
|
+
init_tsup_inject();
|
|
188
|
+
var import_theme_ui23 = require("theme-ui");
|
|
58
189
|
var import_match_media = require("@theme-ui/match-media");
|
|
59
190
|
|
|
60
191
|
// src/theme/ThemeProvider.tsx
|
|
61
|
-
|
|
192
|
+
init_tsup_inject();
|
|
62
193
|
|
|
63
194
|
// ../theme/dist/esm/index.js
|
|
195
|
+
init_tsup_inject();
|
|
196
|
+
var import_deepmerge = __toESM(require_cjs());
|
|
197
|
+
var fontSizes = {
|
|
198
|
+
"2xs": "0.5rem",
|
|
199
|
+
xs: "0.75rem",
|
|
200
|
+
sm: "0.875rem",
|
|
201
|
+
base: "1rem",
|
|
202
|
+
lg: "1.125rem",
|
|
203
|
+
xl: "1.25rem",
|
|
204
|
+
"2xl": "1.5rem",
|
|
205
|
+
"3xl": "1.875rem",
|
|
206
|
+
"4xl": "2.25rem",
|
|
207
|
+
"5xl": "3rem",
|
|
208
|
+
"6xl": "3.75rem",
|
|
209
|
+
"7xl": "4.5rem",
|
|
210
|
+
"8xl": "6rem",
|
|
211
|
+
"9xl": "8rem"
|
|
212
|
+
};
|
|
213
|
+
var fontWeights = {
|
|
214
|
+
thin: 100,
|
|
215
|
+
extralight: 200,
|
|
216
|
+
light: 300,
|
|
217
|
+
normal: 400,
|
|
218
|
+
medium: 500,
|
|
219
|
+
semibold: 600,
|
|
220
|
+
bold: 700,
|
|
221
|
+
extrabold: 800
|
|
222
|
+
};
|
|
223
|
+
var letterSpacings = {
|
|
224
|
+
tighter: "-0.05em",
|
|
225
|
+
tight: "-0.025em",
|
|
226
|
+
normal: "0em",
|
|
227
|
+
wide: "0.025em",
|
|
228
|
+
wider: "0.05em",
|
|
229
|
+
widest: "0.1em"
|
|
230
|
+
};
|
|
231
|
+
var space = {
|
|
232
|
+
none: 0,
|
|
233
|
+
"2xs": "2px",
|
|
234
|
+
xs: "3px",
|
|
235
|
+
sm: "5px",
|
|
236
|
+
md: "8px",
|
|
237
|
+
lg: "13px",
|
|
238
|
+
xl: "21px",
|
|
239
|
+
"2xl": "34px",
|
|
240
|
+
"3xl": "55px",
|
|
241
|
+
"4xl": "89px",
|
|
242
|
+
"5xl": "144px",
|
|
243
|
+
"6xl": "233px",
|
|
244
|
+
"7xl": "377px"
|
|
245
|
+
};
|
|
246
|
+
var coreFonts = {
|
|
247
|
+
main: '"Atkinson Hyperlegible", sans-serif',
|
|
248
|
+
contrast: '"Work Sans", sans-serif',
|
|
249
|
+
monospace: '"Inconsolata", sans-serif'
|
|
250
|
+
};
|
|
251
|
+
var brandColors = {
|
|
252
|
+
complimentary: "#f5f5f5",
|
|
253
|
+
main: "#292c2a",
|
|
254
|
+
darkNeutral: "#515389",
|
|
255
|
+
accent: "#0000ff",
|
|
256
|
+
lightNeutral: "#e3e3e3"
|
|
257
|
+
};
|
|
258
|
+
var coreColors = {
|
|
259
|
+
...brandColors,
|
|
260
|
+
gray100: "#f0f1f3",
|
|
261
|
+
gray200: "#ced1d7",
|
|
262
|
+
gray300: "#acb1ba",
|
|
263
|
+
gray400: "#8b919e",
|
|
264
|
+
gray500: "#6b7280",
|
|
265
|
+
gray600: "#535863",
|
|
266
|
+
gray700: "#3b3f46",
|
|
267
|
+
gray800: "#23252a",
|
|
268
|
+
gray900: "#0b0b0d",
|
|
269
|
+
black: "#000000",
|
|
270
|
+
red100: "#ffebeb",
|
|
271
|
+
red200: "#fdbfbf",
|
|
272
|
+
red300: "#f99595",
|
|
273
|
+
red400: "#f56c6c",
|
|
274
|
+
red500: "#ef4444",
|
|
275
|
+
red600: "#e42828",
|
|
276
|
+
red700: "#c62121",
|
|
277
|
+
white: "#ffffff"
|
|
278
|
+
};
|
|
279
|
+
var coreBorders = {
|
|
280
|
+
none: "0px solid",
|
|
281
|
+
thin: "1px solid",
|
|
282
|
+
medium: "2px solid",
|
|
283
|
+
thick: "4px solid"
|
|
284
|
+
};
|
|
285
|
+
var coreRadii = {
|
|
286
|
+
sharp: "0px",
|
|
287
|
+
xs: "2px",
|
|
288
|
+
sm: "4px",
|
|
289
|
+
md: "6px",
|
|
290
|
+
lg: "8px",
|
|
291
|
+
xl: "12px",
|
|
292
|
+
"2xl": "16px",
|
|
293
|
+
"3xl": "24px",
|
|
294
|
+
circle: "9999px"
|
|
295
|
+
};
|
|
64
296
|
var BruttalTheme = {
|
|
297
|
+
/**
|
|
298
|
+
* Tokens
|
|
299
|
+
*/
|
|
300
|
+
fontSizes,
|
|
301
|
+
fontWeights,
|
|
302
|
+
letterSpacings,
|
|
303
|
+
space,
|
|
65
304
|
colors: {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
305
|
+
background: coreColors.lightNeutral,
|
|
306
|
+
text: coreColors.gray900,
|
|
307
|
+
muted: coreColors.gray200,
|
|
308
|
+
outline: coreColors.gray200,
|
|
309
|
+
primary: coreColors.main,
|
|
310
|
+
onPrimary: coreColors.white,
|
|
311
|
+
secondary: coreColors.gray500,
|
|
312
|
+
onSecondary: coreColors.white,
|
|
313
|
+
highlight: coreColors.darkNeutral,
|
|
314
|
+
onHighlight: coreColors.white,
|
|
315
|
+
accent: coreColors.accent,
|
|
316
|
+
onAccent: coreColors.white,
|
|
317
|
+
neutral: coreColors.white,
|
|
318
|
+
onNeutral: coreColors.gray900
|
|
76
319
|
},
|
|
77
|
-
space: [0, 4, 8, 16, 32, 64, 128, 256, 512, 1024],
|
|
78
320
|
fonts: {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
lg: "1.125rem",
|
|
89
|
-
xl: "1.25rem",
|
|
90
|
-
"2xl": "1.5rem",
|
|
91
|
-
"3xl": "1.875rem",
|
|
92
|
-
"4xl": "2.25rem",
|
|
93
|
-
"5xl": "3rem",
|
|
94
|
-
"6xl": "3.75rem",
|
|
95
|
-
"7xl": "4.5rem",
|
|
96
|
-
"8xl": "6rem",
|
|
97
|
-
"9xl": "8rem"
|
|
321
|
+
h1: coreFonts.contrast,
|
|
322
|
+
h2: coreFonts.contrast,
|
|
323
|
+
h3: coreFonts.contrast,
|
|
324
|
+
h4: coreFonts.contrast,
|
|
325
|
+
h5: coreFonts.contrast,
|
|
326
|
+
h6: coreFonts.contrast,
|
|
327
|
+
body: coreFonts.main,
|
|
328
|
+
highlight: coreFonts.main,
|
|
329
|
+
caption: coreFonts.monospace
|
|
98
330
|
},
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
extralight: 200,
|
|
102
|
-
light: 300,
|
|
103
|
-
normal: 400,
|
|
104
|
-
medium: 500,
|
|
105
|
-
semibold: 600,
|
|
106
|
-
bold: 700,
|
|
107
|
-
extrabold: 800
|
|
331
|
+
borders: {
|
|
332
|
+
default: coreBorders.medium
|
|
108
333
|
},
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
tight: "-0.025em",
|
|
112
|
-
normal: "0em",
|
|
113
|
-
wide: "0.025em",
|
|
114
|
-
wider: "0.05em",
|
|
115
|
-
widest: "0.1em"
|
|
334
|
+
radii: {
|
|
335
|
+
default: coreRadii.sm
|
|
116
336
|
},
|
|
337
|
+
/**
|
|
338
|
+
* Global styles
|
|
339
|
+
*/
|
|
117
340
|
styles: {
|
|
118
341
|
root: {
|
|
119
342
|
fontFamily: "body",
|
|
120
343
|
fontWeight: "normal"
|
|
121
|
-
},
|
|
122
|
-
a: {
|
|
123
|
-
color: "primary",
|
|
124
|
-
textDecoration: "underline",
|
|
125
|
-
cursor: "pointer",
|
|
126
|
-
fontFamily: "body"
|
|
127
|
-
},
|
|
128
|
-
progress: {
|
|
129
|
-
color: "primary",
|
|
130
|
-
backgroundColor: "background"
|
|
131
344
|
}
|
|
132
345
|
},
|
|
133
|
-
|
|
346
|
+
/**
|
|
347
|
+
* Components
|
|
348
|
+
*/
|
|
134
349
|
buttons: {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
350
|
+
accent: {
|
|
351
|
+
backgroundColor: "accent",
|
|
352
|
+
color: "onAccent",
|
|
353
|
+
fontFamily: "highlight",
|
|
354
|
+
fontWeight: "bold",
|
|
355
|
+
border: "default",
|
|
356
|
+
borderRadius: "default",
|
|
357
|
+
borderColor: "accent",
|
|
358
|
+
":hover:not(:active,[disabled])": {
|
|
359
|
+
backgroundColor: "highlight",
|
|
360
|
+
color: "onHighlight",
|
|
361
|
+
borderColor: "highlight"
|
|
362
|
+
},
|
|
363
|
+
":disabled": {
|
|
364
|
+
cursor: "default",
|
|
365
|
+
backgroundColor: "muted",
|
|
366
|
+
borderColor: "muted"
|
|
367
|
+
}
|
|
146
368
|
},
|
|
147
369
|
primary: {
|
|
370
|
+
backgroundColor: "primary",
|
|
371
|
+
color: "onPrimary",
|
|
372
|
+
fontFamily: "body",
|
|
373
|
+
border: "default",
|
|
374
|
+
borderRadius: "default",
|
|
375
|
+
borderColor: "outline",
|
|
376
|
+
":hover:not(:active,[disabled])": {
|
|
377
|
+
backgroundColor: "highlight",
|
|
378
|
+
color: "onHighlight",
|
|
379
|
+
borderColor: "highlight"
|
|
380
|
+
},
|
|
381
|
+
":active": {
|
|
382
|
+
backgroundColor: "primary",
|
|
383
|
+
color: "onPrimary",
|
|
384
|
+
borderColor: "outline"
|
|
385
|
+
},
|
|
148
386
|
":disabled": {
|
|
149
|
-
|
|
150
|
-
|
|
387
|
+
cursor: "default",
|
|
388
|
+
backgroundColor: "muted",
|
|
389
|
+
borderColor: "muted"
|
|
151
390
|
}
|
|
152
391
|
},
|
|
153
392
|
secondary: {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
393
|
+
backgroundColor: "secondary",
|
|
394
|
+
color: "onSecondary",
|
|
395
|
+
fontFamily: "body",
|
|
396
|
+
border: "default",
|
|
397
|
+
borderRadius: "default",
|
|
398
|
+
borderColor: "outline",
|
|
399
|
+
":hover:not(:active,[disabled])": {
|
|
400
|
+
backgroundColor: "highlight",
|
|
401
|
+
color: "onHighlight",
|
|
402
|
+
borderColor: "highlight"
|
|
403
|
+
},
|
|
404
|
+
":disabled": {
|
|
405
|
+
cursor: "default",
|
|
406
|
+
backgroundColor: "muted",
|
|
407
|
+
borderColor: "muted"
|
|
408
|
+
}
|
|
409
|
+
},
|
|
410
|
+
neutral: {
|
|
411
|
+
backgroundColor: "neutral",
|
|
412
|
+
color: "onNeutral",
|
|
413
|
+
fontFamily: "body",
|
|
414
|
+
border: "default",
|
|
415
|
+
borderRadius: "default",
|
|
416
|
+
borderColor: "outline",
|
|
417
|
+
":hover:not(:active,[disabled])": {
|
|
418
|
+
backgroundColor: "highlight",
|
|
419
|
+
color: "onHighlight",
|
|
420
|
+
borderColor: "highlight"
|
|
421
|
+
},
|
|
159
422
|
":disabled": {
|
|
160
|
-
|
|
161
|
-
|
|
423
|
+
cursor: "default",
|
|
424
|
+
backgroundColor: "muted",
|
|
425
|
+
borderColor: "muted"
|
|
162
426
|
}
|
|
427
|
+
},
|
|
428
|
+
danger: {
|
|
429
|
+
color: "white",
|
|
430
|
+
backgroundColor: "danger"
|
|
163
431
|
}
|
|
164
432
|
},
|
|
165
433
|
cards: {
|
|
166
434
|
primary: {
|
|
167
|
-
backgroundColor: "
|
|
435
|
+
backgroundColor: "primary",
|
|
168
436
|
border: "1px solid black",
|
|
169
437
|
padding: [4, 5],
|
|
170
438
|
display: "flex",
|
|
@@ -222,7 +490,8 @@ var BruttalTheme = {
|
|
|
222
490
|
};
|
|
223
491
|
var BruttalFonts = [
|
|
224
492
|
"https://fonts.googleapis.com/css?family=Inconsolata:wght@100;200;300;400;500;700;800;900",
|
|
225
|
-
"https://fonts.googleapis.com/css?family=Work+Sans:wght@100;200;300;400;500;700;800;900"
|
|
493
|
+
"https://fonts.googleapis.com/css?family=Work+Sans:wght@100;200;300;400;500;700;800;900",
|
|
494
|
+
"https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:ital,wght@0,400;0,700;1,400;1,700&display=swap"
|
|
226
495
|
];
|
|
227
496
|
|
|
228
497
|
// src/theme/ThemeProvider.tsx
|
|
@@ -231,114 +500,2150 @@ var import_theme_ui = require("theme-ui");
|
|
|
231
500
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
232
501
|
var ThemeProvider = ({
|
|
233
502
|
children,
|
|
234
|
-
theme =
|
|
503
|
+
theme = BruttalTheme,
|
|
235
504
|
fonts = BruttalFonts
|
|
236
505
|
}) => {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
styles: import_react.css`
|
|
249
|
-
@import url('${url}');
|
|
250
|
-
`
|
|
251
|
-
},
|
|
252
|
-
url
|
|
253
|
-
);
|
|
254
|
-
}),
|
|
506
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_theme_ui.ThemeProvider, { theme, children: [
|
|
507
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
508
|
+
import_react.Global,
|
|
509
|
+
{
|
|
510
|
+
styles: import_react.css`
|
|
511
|
+
${fonts.map((url) => {
|
|
512
|
+
return `@import url('${url}');`;
|
|
513
|
+
}).join("\n")}
|
|
514
|
+
`
|
|
515
|
+
}
|
|
516
|
+
),
|
|
255
517
|
children
|
|
256
518
|
] }) });
|
|
257
519
|
};
|
|
258
|
-
var ThemeProvider_default = ThemeProvider;
|
|
259
520
|
|
|
260
521
|
// src/theme/useTheme.ts
|
|
522
|
+
init_tsup_inject();
|
|
261
523
|
var import_theme_ui2 = require("theme-ui");
|
|
262
524
|
var useTheme = import_theme_ui2.useThemeUI;
|
|
263
525
|
|
|
264
526
|
// src/components/Box.tsx
|
|
527
|
+
init_tsup_inject();
|
|
265
528
|
var import_theme_ui3 = require("theme-ui");
|
|
266
529
|
|
|
267
530
|
// src/components/Button.tsx
|
|
531
|
+
init_tsup_inject();
|
|
532
|
+
var React3 = __toESM(require("react"));
|
|
268
533
|
var import_theme_ui4 = require("theme-ui");
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
534
|
+
|
|
535
|
+
// src/components/Icon.tsx
|
|
536
|
+
init_tsup_inject();
|
|
537
|
+
|
|
538
|
+
// ../../node_modules/@iconify-icon/react/dist/iconify.mjs
|
|
539
|
+
init_tsup_inject();
|
|
540
|
+
var import_react2 = __toESM(require("react"), 1);
|
|
541
|
+
|
|
542
|
+
// ../../node_modules/iconify-icon/dist/iconify-icon.mjs
|
|
543
|
+
init_tsup_inject();
|
|
544
|
+
var defaultIconDimensions = Object.freeze(
|
|
545
|
+
{
|
|
546
|
+
left: 0,
|
|
547
|
+
top: 0,
|
|
548
|
+
width: 16,
|
|
549
|
+
height: 16
|
|
550
|
+
}
|
|
551
|
+
);
|
|
552
|
+
var defaultIconTransformations = Object.freeze({
|
|
553
|
+
rotate: 0,
|
|
554
|
+
vFlip: false,
|
|
555
|
+
hFlip: false
|
|
556
|
+
});
|
|
557
|
+
var defaultIconProps = Object.freeze({
|
|
558
|
+
...defaultIconDimensions,
|
|
559
|
+
...defaultIconTransformations
|
|
560
|
+
});
|
|
561
|
+
var defaultExtendedIconProps = Object.freeze({
|
|
562
|
+
...defaultIconProps,
|
|
563
|
+
body: "",
|
|
564
|
+
hidden: false
|
|
565
|
+
});
|
|
566
|
+
var defaultIconSizeCustomisations = Object.freeze({
|
|
567
|
+
width: null,
|
|
568
|
+
height: null
|
|
569
|
+
});
|
|
570
|
+
var defaultIconCustomisations = Object.freeze({
|
|
571
|
+
...defaultIconSizeCustomisations,
|
|
572
|
+
...defaultIconTransformations
|
|
573
|
+
});
|
|
574
|
+
function rotateFromString(value, defaultValue = 0) {
|
|
575
|
+
const units = value.replace(/^-?[0-9.]*/, "");
|
|
576
|
+
function cleanup(value2) {
|
|
577
|
+
while (value2 < 0) {
|
|
578
|
+
value2 += 4;
|
|
579
|
+
}
|
|
580
|
+
return value2 % 4;
|
|
581
|
+
}
|
|
582
|
+
if (units === "") {
|
|
583
|
+
const num = parseInt(value);
|
|
584
|
+
return isNaN(num) ? 0 : cleanup(num);
|
|
585
|
+
} else if (units !== value) {
|
|
586
|
+
let split = 0;
|
|
587
|
+
switch (units) {
|
|
588
|
+
case "%":
|
|
589
|
+
split = 25;
|
|
590
|
+
break;
|
|
591
|
+
case "deg":
|
|
592
|
+
split = 90;
|
|
593
|
+
}
|
|
594
|
+
if (split) {
|
|
595
|
+
let num = parseFloat(value.slice(0, value.length - units.length));
|
|
596
|
+
if (isNaN(num)) {
|
|
597
|
+
return 0;
|
|
598
|
+
}
|
|
599
|
+
num = num / split;
|
|
600
|
+
return num % 1 === 0 ? cleanup(num) : 0;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
return defaultValue;
|
|
604
|
+
}
|
|
605
|
+
var separator = /[\s,]+/;
|
|
606
|
+
function flipFromString(custom, flip) {
|
|
607
|
+
flip.split(separator).forEach((str) => {
|
|
608
|
+
const value = str.trim();
|
|
609
|
+
switch (value) {
|
|
610
|
+
case "horizontal":
|
|
611
|
+
custom.hFlip = true;
|
|
612
|
+
break;
|
|
613
|
+
case "vertical":
|
|
614
|
+
custom.vFlip = true;
|
|
615
|
+
break;
|
|
616
|
+
}
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
var defaultCustomisations = {
|
|
620
|
+
...defaultIconCustomisations,
|
|
621
|
+
preserveAspectRatio: ""
|
|
622
|
+
};
|
|
623
|
+
function getCustomisations(node) {
|
|
624
|
+
const customisations = {
|
|
625
|
+
...defaultCustomisations
|
|
626
|
+
};
|
|
627
|
+
const attr = (key, def) => node.getAttribute(key) || def;
|
|
628
|
+
customisations.width = attr("width", null);
|
|
629
|
+
customisations.height = attr("height", null);
|
|
630
|
+
customisations.rotate = rotateFromString(attr("rotate", ""));
|
|
631
|
+
flipFromString(customisations, attr("flip", ""));
|
|
632
|
+
customisations.preserveAspectRatio = attr("preserveAspectRatio", attr("preserveaspectratio", ""));
|
|
633
|
+
return customisations;
|
|
634
|
+
}
|
|
635
|
+
function haveCustomisationsChanged(value1, value2) {
|
|
636
|
+
for (const key in defaultCustomisations) {
|
|
637
|
+
if (value1[key] !== value2[key]) {
|
|
638
|
+
return true;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
return false;
|
|
642
|
+
}
|
|
643
|
+
var matchIconName = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
644
|
+
var stringToIcon = (value, validate, allowSimpleName, provider = "") => {
|
|
645
|
+
const colonSeparated = value.split(":");
|
|
646
|
+
if (value.slice(0, 1) === "@") {
|
|
647
|
+
if (colonSeparated.length < 2 || colonSeparated.length > 3) {
|
|
648
|
+
return null;
|
|
649
|
+
}
|
|
650
|
+
provider = colonSeparated.shift().slice(1);
|
|
651
|
+
}
|
|
652
|
+
if (colonSeparated.length > 3 || !colonSeparated.length) {
|
|
653
|
+
return null;
|
|
654
|
+
}
|
|
655
|
+
if (colonSeparated.length > 1) {
|
|
656
|
+
const name2 = colonSeparated.pop();
|
|
657
|
+
const prefix = colonSeparated.pop();
|
|
658
|
+
const result = {
|
|
659
|
+
provider: colonSeparated.length > 0 ? colonSeparated[0] : provider,
|
|
660
|
+
prefix,
|
|
661
|
+
name: name2
|
|
662
|
+
};
|
|
663
|
+
return validate && !validateIconName(result) ? null : result;
|
|
664
|
+
}
|
|
665
|
+
const name = colonSeparated[0];
|
|
666
|
+
const dashSeparated = name.split("-");
|
|
667
|
+
if (dashSeparated.length > 1) {
|
|
668
|
+
const result = {
|
|
669
|
+
provider,
|
|
670
|
+
prefix: dashSeparated.shift(),
|
|
671
|
+
name: dashSeparated.join("-")
|
|
672
|
+
};
|
|
673
|
+
return validate && !validateIconName(result) ? null : result;
|
|
674
|
+
}
|
|
675
|
+
if (allowSimpleName && provider === "") {
|
|
676
|
+
const result = {
|
|
677
|
+
provider,
|
|
678
|
+
prefix: "",
|
|
679
|
+
name
|
|
680
|
+
};
|
|
681
|
+
return validate && !validateIconName(result, allowSimpleName) ? null : result;
|
|
682
|
+
}
|
|
683
|
+
return null;
|
|
684
|
+
};
|
|
685
|
+
var validateIconName = (icon, allowSimpleName) => {
|
|
686
|
+
if (!icon) {
|
|
687
|
+
return false;
|
|
688
|
+
}
|
|
689
|
+
return !!((icon.provider === "" || icon.provider.match(matchIconName)) && (allowSimpleName && icon.prefix === "" || icon.prefix.match(matchIconName)) && icon.name.match(matchIconName));
|
|
690
|
+
};
|
|
691
|
+
function mergeIconTransformations(obj1, obj2) {
|
|
692
|
+
const result = {};
|
|
693
|
+
if (!obj1.hFlip !== !obj2.hFlip) {
|
|
694
|
+
result.hFlip = true;
|
|
695
|
+
}
|
|
696
|
+
if (!obj1.vFlip !== !obj2.vFlip) {
|
|
697
|
+
result.vFlip = true;
|
|
698
|
+
}
|
|
699
|
+
const rotate = ((obj1.rotate || 0) + (obj2.rotate || 0)) % 4;
|
|
700
|
+
if (rotate) {
|
|
701
|
+
result.rotate = rotate;
|
|
702
|
+
}
|
|
703
|
+
return result;
|
|
704
|
+
}
|
|
705
|
+
function mergeIconData(parent, child) {
|
|
706
|
+
const result = mergeIconTransformations(parent, child);
|
|
707
|
+
for (const key in defaultExtendedIconProps) {
|
|
708
|
+
if (key in defaultIconTransformations) {
|
|
709
|
+
if (key in parent && !(key in result)) {
|
|
710
|
+
result[key] = defaultIconTransformations[key];
|
|
711
|
+
}
|
|
712
|
+
} else if (key in child) {
|
|
713
|
+
result[key] = child[key];
|
|
714
|
+
} else if (key in parent) {
|
|
715
|
+
result[key] = parent[key];
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
return result;
|
|
719
|
+
}
|
|
720
|
+
function getIconsTree(data, names) {
|
|
721
|
+
const icons = data.icons;
|
|
722
|
+
const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
|
|
723
|
+
const resolved = /* @__PURE__ */ Object.create(null);
|
|
724
|
+
function resolve(name) {
|
|
725
|
+
if (icons[name]) {
|
|
726
|
+
return resolved[name] = [];
|
|
727
|
+
}
|
|
728
|
+
if (!(name in resolved)) {
|
|
729
|
+
resolved[name] = null;
|
|
730
|
+
const parent = aliases[name] && aliases[name].parent;
|
|
731
|
+
const value = parent && resolve(parent);
|
|
732
|
+
if (value) {
|
|
733
|
+
resolved[name] = [parent].concat(value);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
return resolved[name];
|
|
737
|
+
}
|
|
738
|
+
(names || Object.keys(icons).concat(Object.keys(aliases))).forEach(resolve);
|
|
739
|
+
return resolved;
|
|
740
|
+
}
|
|
741
|
+
function internalGetIconData(data, name, tree) {
|
|
742
|
+
const icons = data.icons;
|
|
743
|
+
const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
|
|
744
|
+
let currentProps = {};
|
|
745
|
+
function parse(name2) {
|
|
746
|
+
currentProps = mergeIconData(
|
|
747
|
+
icons[name2] || aliases[name2],
|
|
748
|
+
currentProps
|
|
749
|
+
);
|
|
750
|
+
}
|
|
751
|
+
parse(name);
|
|
752
|
+
tree.forEach(parse);
|
|
753
|
+
return mergeIconData(data, currentProps);
|
|
754
|
+
}
|
|
755
|
+
function parseIconSet(data, callback) {
|
|
756
|
+
const names = [];
|
|
757
|
+
if (typeof data !== "object" || typeof data.icons !== "object") {
|
|
758
|
+
return names;
|
|
759
|
+
}
|
|
760
|
+
if (data.not_found instanceof Array) {
|
|
761
|
+
data.not_found.forEach((name) => {
|
|
762
|
+
callback(name, null);
|
|
763
|
+
names.push(name);
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
const tree = getIconsTree(data);
|
|
767
|
+
for (const name in tree) {
|
|
768
|
+
const item = tree[name];
|
|
769
|
+
if (item) {
|
|
770
|
+
callback(name, internalGetIconData(data, name, item));
|
|
771
|
+
names.push(name);
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
return names;
|
|
775
|
+
}
|
|
776
|
+
var optionalPropertyDefaults = {
|
|
777
|
+
provider: "",
|
|
778
|
+
aliases: {},
|
|
779
|
+
not_found: {},
|
|
780
|
+
...defaultIconDimensions
|
|
781
|
+
};
|
|
782
|
+
function checkOptionalProps(item, defaults) {
|
|
783
|
+
for (const prop in defaults) {
|
|
784
|
+
if (prop in item && typeof item[prop] !== typeof defaults[prop]) {
|
|
785
|
+
return false;
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
return true;
|
|
789
|
+
}
|
|
790
|
+
function quicklyValidateIconSet(obj) {
|
|
791
|
+
if (typeof obj !== "object" || obj === null) {
|
|
792
|
+
return null;
|
|
793
|
+
}
|
|
794
|
+
const data = obj;
|
|
795
|
+
if (typeof data.prefix !== "string" || !obj.icons || typeof obj.icons !== "object") {
|
|
796
|
+
return null;
|
|
797
|
+
}
|
|
798
|
+
if (!checkOptionalProps(obj, optionalPropertyDefaults)) {
|
|
799
|
+
return null;
|
|
800
|
+
}
|
|
801
|
+
const icons = data.icons;
|
|
802
|
+
for (const name in icons) {
|
|
803
|
+
const icon = icons[name];
|
|
804
|
+
if (!name.match(matchIconName) || typeof icon.body !== "string" || !checkOptionalProps(
|
|
805
|
+
icon,
|
|
806
|
+
defaultExtendedIconProps
|
|
807
|
+
)) {
|
|
808
|
+
return null;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
|
|
812
|
+
for (const name in aliases) {
|
|
813
|
+
const icon = aliases[name];
|
|
814
|
+
const parent = icon.parent;
|
|
815
|
+
if (!name.match(matchIconName) || typeof parent !== "string" || !icons[parent] && !aliases[parent] || !checkOptionalProps(
|
|
816
|
+
icon,
|
|
817
|
+
defaultExtendedIconProps
|
|
818
|
+
)) {
|
|
819
|
+
return null;
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
return data;
|
|
823
|
+
}
|
|
824
|
+
var dataStorage = /* @__PURE__ */ Object.create(null);
|
|
825
|
+
function newStorage(provider, prefix) {
|
|
826
|
+
return {
|
|
827
|
+
provider,
|
|
828
|
+
prefix,
|
|
829
|
+
icons: /* @__PURE__ */ Object.create(null),
|
|
830
|
+
missing: /* @__PURE__ */ new Set()
|
|
831
|
+
};
|
|
832
|
+
}
|
|
833
|
+
function getStorage(provider, prefix) {
|
|
834
|
+
const providerStorage = dataStorage[provider] || (dataStorage[provider] = /* @__PURE__ */ Object.create(null));
|
|
835
|
+
return providerStorage[prefix] || (providerStorage[prefix] = newStorage(provider, prefix));
|
|
836
|
+
}
|
|
837
|
+
function addIconSet(storage2, data) {
|
|
838
|
+
if (!quicklyValidateIconSet(data)) {
|
|
839
|
+
return [];
|
|
840
|
+
}
|
|
841
|
+
return parseIconSet(data, (name, icon) => {
|
|
842
|
+
if (icon) {
|
|
843
|
+
storage2.icons[name] = icon;
|
|
844
|
+
} else {
|
|
845
|
+
storage2.missing.add(name);
|
|
846
|
+
}
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
function addIconToStorage(storage2, name, icon) {
|
|
850
|
+
try {
|
|
851
|
+
if (typeof icon.body === "string") {
|
|
852
|
+
storage2.icons[name] = { ...icon };
|
|
853
|
+
return true;
|
|
854
|
+
}
|
|
855
|
+
} catch (err) {
|
|
856
|
+
}
|
|
857
|
+
return false;
|
|
858
|
+
}
|
|
859
|
+
function listIcons$1(provider, prefix) {
|
|
860
|
+
let allIcons = [];
|
|
861
|
+
const providers = typeof provider === "string" ? [provider] : Object.keys(dataStorage);
|
|
862
|
+
providers.forEach((provider2) => {
|
|
863
|
+
const prefixes = typeof provider2 === "string" && typeof prefix === "string" ? [prefix] : Object.keys(dataStorage[provider2] || {});
|
|
864
|
+
prefixes.forEach((prefix2) => {
|
|
865
|
+
const storage2 = getStorage(provider2, prefix2);
|
|
866
|
+
allIcons = allIcons.concat(
|
|
867
|
+
Object.keys(storage2.icons).map(
|
|
868
|
+
(name) => (provider2 !== "" ? "@" + provider2 + ":" : "") + prefix2 + ":" + name
|
|
869
|
+
)
|
|
870
|
+
);
|
|
871
|
+
});
|
|
872
|
+
});
|
|
873
|
+
return allIcons;
|
|
874
|
+
}
|
|
875
|
+
var simpleNames = false;
|
|
876
|
+
function allowSimpleNames(allow) {
|
|
877
|
+
if (typeof allow === "boolean") {
|
|
878
|
+
simpleNames = allow;
|
|
879
|
+
}
|
|
880
|
+
return simpleNames;
|
|
881
|
+
}
|
|
882
|
+
function getIconData(name) {
|
|
883
|
+
const icon = typeof name === "string" ? stringToIcon(name, true, simpleNames) : name;
|
|
884
|
+
if (icon) {
|
|
885
|
+
const storage2 = getStorage(icon.provider, icon.prefix);
|
|
886
|
+
const iconName = icon.name;
|
|
887
|
+
return storage2.icons[iconName] || (storage2.missing.has(iconName) ? null : void 0);
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
function addIcon$1(name, data) {
|
|
891
|
+
const icon = stringToIcon(name, true, simpleNames);
|
|
892
|
+
if (!icon) {
|
|
893
|
+
return false;
|
|
894
|
+
}
|
|
895
|
+
const storage2 = getStorage(icon.provider, icon.prefix);
|
|
896
|
+
return addIconToStorage(storage2, icon.name, data);
|
|
897
|
+
}
|
|
898
|
+
function addCollection$1(data, provider) {
|
|
899
|
+
if (typeof data !== "object") {
|
|
900
|
+
return false;
|
|
901
|
+
}
|
|
902
|
+
if (typeof provider !== "string") {
|
|
903
|
+
provider = data.provider || "";
|
|
904
|
+
}
|
|
905
|
+
if (simpleNames && !provider && !data.prefix) {
|
|
906
|
+
let added = false;
|
|
907
|
+
if (quicklyValidateIconSet(data)) {
|
|
908
|
+
data.prefix = "";
|
|
909
|
+
parseIconSet(data, (name, icon) => {
|
|
910
|
+
if (icon && addIcon$1(name, icon)) {
|
|
911
|
+
added = true;
|
|
912
|
+
}
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
return added;
|
|
916
|
+
}
|
|
917
|
+
const prefix = data.prefix;
|
|
918
|
+
if (!validateIconName({
|
|
919
|
+
provider,
|
|
920
|
+
prefix,
|
|
921
|
+
name: "a"
|
|
922
|
+
})) {
|
|
923
|
+
return false;
|
|
924
|
+
}
|
|
925
|
+
const storage2 = getStorage(provider, prefix);
|
|
926
|
+
return !!addIconSet(storage2, data);
|
|
927
|
+
}
|
|
928
|
+
function iconExists$1(name) {
|
|
929
|
+
return !!getIconData(name);
|
|
930
|
+
}
|
|
931
|
+
function getIcon$1(name) {
|
|
932
|
+
const result = getIconData(name);
|
|
933
|
+
return result ? {
|
|
934
|
+
...defaultIconProps,
|
|
935
|
+
...result
|
|
936
|
+
} : null;
|
|
937
|
+
}
|
|
938
|
+
function sortIcons(icons) {
|
|
939
|
+
const result = {
|
|
940
|
+
loaded: [],
|
|
941
|
+
missing: [],
|
|
942
|
+
pending: []
|
|
943
|
+
};
|
|
944
|
+
const storage2 = /* @__PURE__ */ Object.create(null);
|
|
945
|
+
icons.sort((a, b) => {
|
|
946
|
+
if (a.provider !== b.provider) {
|
|
947
|
+
return a.provider.localeCompare(b.provider);
|
|
948
|
+
}
|
|
949
|
+
if (a.prefix !== b.prefix) {
|
|
950
|
+
return a.prefix.localeCompare(b.prefix);
|
|
951
|
+
}
|
|
952
|
+
return a.name.localeCompare(b.name);
|
|
953
|
+
});
|
|
954
|
+
let lastIcon = {
|
|
955
|
+
provider: "",
|
|
956
|
+
prefix: "",
|
|
957
|
+
name: ""
|
|
958
|
+
};
|
|
959
|
+
icons.forEach((icon) => {
|
|
960
|
+
if (lastIcon.name === icon.name && lastIcon.prefix === icon.prefix && lastIcon.provider === icon.provider) {
|
|
961
|
+
return;
|
|
962
|
+
}
|
|
963
|
+
lastIcon = icon;
|
|
964
|
+
const provider = icon.provider;
|
|
965
|
+
const prefix = icon.prefix;
|
|
966
|
+
const name = icon.name;
|
|
967
|
+
const providerStorage = storage2[provider] || (storage2[provider] = /* @__PURE__ */ Object.create(null));
|
|
968
|
+
const localStorage = providerStorage[prefix] || (providerStorage[prefix] = getStorage(provider, prefix));
|
|
969
|
+
let list;
|
|
970
|
+
if (name in localStorage.icons) {
|
|
971
|
+
list = result.loaded;
|
|
972
|
+
} else if (prefix === "" || localStorage.missing.has(name)) {
|
|
973
|
+
list = result.missing;
|
|
974
|
+
} else {
|
|
975
|
+
list = result.pending;
|
|
976
|
+
}
|
|
977
|
+
const item = {
|
|
978
|
+
provider,
|
|
979
|
+
prefix,
|
|
980
|
+
name
|
|
981
|
+
};
|
|
982
|
+
list.push(item);
|
|
983
|
+
});
|
|
984
|
+
return result;
|
|
985
|
+
}
|
|
986
|
+
function removeCallback(storages, id) {
|
|
987
|
+
storages.forEach((storage2) => {
|
|
988
|
+
const items = storage2.loaderCallbacks;
|
|
989
|
+
if (items) {
|
|
990
|
+
storage2.loaderCallbacks = items.filter((row) => row.id !== id);
|
|
991
|
+
}
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
function updateCallbacks(storage2) {
|
|
995
|
+
if (!storage2.pendingCallbacksFlag) {
|
|
996
|
+
storage2.pendingCallbacksFlag = true;
|
|
997
|
+
setTimeout(() => {
|
|
998
|
+
storage2.pendingCallbacksFlag = false;
|
|
999
|
+
const items = storage2.loaderCallbacks ? storage2.loaderCallbacks.slice(0) : [];
|
|
1000
|
+
if (!items.length) {
|
|
1001
|
+
return;
|
|
1002
|
+
}
|
|
1003
|
+
let hasPending = false;
|
|
1004
|
+
const provider = storage2.provider;
|
|
1005
|
+
const prefix = storage2.prefix;
|
|
1006
|
+
items.forEach((item) => {
|
|
1007
|
+
const icons = item.icons;
|
|
1008
|
+
const oldLength = icons.pending.length;
|
|
1009
|
+
icons.pending = icons.pending.filter((icon) => {
|
|
1010
|
+
if (icon.prefix !== prefix) {
|
|
1011
|
+
return true;
|
|
1012
|
+
}
|
|
1013
|
+
const name = icon.name;
|
|
1014
|
+
if (storage2.icons[name]) {
|
|
1015
|
+
icons.loaded.push({
|
|
1016
|
+
provider,
|
|
1017
|
+
prefix,
|
|
1018
|
+
name
|
|
1019
|
+
});
|
|
1020
|
+
} else if (storage2.missing.has(name)) {
|
|
1021
|
+
icons.missing.push({
|
|
1022
|
+
provider,
|
|
1023
|
+
prefix,
|
|
1024
|
+
name
|
|
1025
|
+
});
|
|
1026
|
+
} else {
|
|
1027
|
+
hasPending = true;
|
|
1028
|
+
return true;
|
|
1029
|
+
}
|
|
1030
|
+
return false;
|
|
1031
|
+
});
|
|
1032
|
+
if (icons.pending.length !== oldLength) {
|
|
1033
|
+
if (!hasPending) {
|
|
1034
|
+
removeCallback([storage2], item.id);
|
|
1035
|
+
}
|
|
1036
|
+
item.callback(
|
|
1037
|
+
icons.loaded.slice(0),
|
|
1038
|
+
icons.missing.slice(0),
|
|
1039
|
+
icons.pending.slice(0),
|
|
1040
|
+
item.abort
|
|
1041
|
+
);
|
|
1042
|
+
}
|
|
1043
|
+
});
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
var idCounter = 0;
|
|
1048
|
+
function storeCallback(callback, icons, pendingSources) {
|
|
1049
|
+
const id = idCounter++;
|
|
1050
|
+
const abort = removeCallback.bind(null, pendingSources, id);
|
|
1051
|
+
if (!icons.pending.length) {
|
|
1052
|
+
return abort;
|
|
1053
|
+
}
|
|
1054
|
+
const item = {
|
|
1055
|
+
id,
|
|
1056
|
+
icons,
|
|
1057
|
+
callback,
|
|
1058
|
+
abort
|
|
1059
|
+
};
|
|
1060
|
+
pendingSources.forEach((storage2) => {
|
|
1061
|
+
(storage2.loaderCallbacks || (storage2.loaderCallbacks = [])).push(item);
|
|
1062
|
+
});
|
|
1063
|
+
return abort;
|
|
1064
|
+
}
|
|
1065
|
+
var storage = /* @__PURE__ */ Object.create(null);
|
|
1066
|
+
function setAPIModule(provider, item) {
|
|
1067
|
+
storage[provider] = item;
|
|
1068
|
+
}
|
|
1069
|
+
function getAPIModule(provider) {
|
|
1070
|
+
return storage[provider] || storage[""];
|
|
1071
|
+
}
|
|
1072
|
+
function listToIcons(list, validate = true, simpleNames2 = false) {
|
|
1073
|
+
const result = [];
|
|
1074
|
+
list.forEach((item) => {
|
|
1075
|
+
const icon = typeof item === "string" ? stringToIcon(item, validate, simpleNames2) : item;
|
|
1076
|
+
if (icon) {
|
|
1077
|
+
result.push(icon);
|
|
1078
|
+
}
|
|
1079
|
+
});
|
|
1080
|
+
return result;
|
|
1081
|
+
}
|
|
1082
|
+
var defaultConfig = {
|
|
1083
|
+
resources: [],
|
|
1084
|
+
index: 0,
|
|
1085
|
+
timeout: 2e3,
|
|
1086
|
+
rotate: 750,
|
|
1087
|
+
random: false,
|
|
1088
|
+
dataAfterTimeout: false
|
|
1089
|
+
};
|
|
1090
|
+
function sendQuery(config, payload, query, done) {
|
|
1091
|
+
const resourcesCount = config.resources.length;
|
|
1092
|
+
const startIndex = config.random ? Math.floor(Math.random() * resourcesCount) : config.index;
|
|
1093
|
+
let resources;
|
|
1094
|
+
if (config.random) {
|
|
1095
|
+
let list = config.resources.slice(0);
|
|
1096
|
+
resources = [];
|
|
1097
|
+
while (list.length > 1) {
|
|
1098
|
+
const nextIndex = Math.floor(Math.random() * list.length);
|
|
1099
|
+
resources.push(list[nextIndex]);
|
|
1100
|
+
list = list.slice(0, nextIndex).concat(list.slice(nextIndex + 1));
|
|
1101
|
+
}
|
|
1102
|
+
resources = resources.concat(list);
|
|
1103
|
+
} else {
|
|
1104
|
+
resources = config.resources.slice(startIndex).concat(config.resources.slice(0, startIndex));
|
|
1105
|
+
}
|
|
1106
|
+
const startTime = Date.now();
|
|
1107
|
+
let status = "pending";
|
|
1108
|
+
let queriesSent = 0;
|
|
1109
|
+
let lastError;
|
|
1110
|
+
let timer = null;
|
|
1111
|
+
let queue = [];
|
|
1112
|
+
let doneCallbacks = [];
|
|
1113
|
+
if (typeof done === "function") {
|
|
1114
|
+
doneCallbacks.push(done);
|
|
1115
|
+
}
|
|
1116
|
+
function resetTimer() {
|
|
1117
|
+
if (timer) {
|
|
1118
|
+
clearTimeout(timer);
|
|
1119
|
+
timer = null;
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
function abort() {
|
|
1123
|
+
if (status === "pending") {
|
|
1124
|
+
status = "aborted";
|
|
1125
|
+
}
|
|
1126
|
+
resetTimer();
|
|
1127
|
+
queue.forEach((item) => {
|
|
1128
|
+
if (item.status === "pending") {
|
|
1129
|
+
item.status = "aborted";
|
|
1130
|
+
}
|
|
1131
|
+
});
|
|
1132
|
+
queue = [];
|
|
1133
|
+
}
|
|
1134
|
+
function subscribe(callback, overwrite) {
|
|
1135
|
+
if (overwrite) {
|
|
1136
|
+
doneCallbacks = [];
|
|
1137
|
+
}
|
|
1138
|
+
if (typeof callback === "function") {
|
|
1139
|
+
doneCallbacks.push(callback);
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
function getQueryStatus() {
|
|
1143
|
+
return {
|
|
1144
|
+
startTime,
|
|
1145
|
+
payload,
|
|
1146
|
+
status,
|
|
1147
|
+
queriesSent,
|
|
1148
|
+
queriesPending: queue.length,
|
|
1149
|
+
subscribe,
|
|
1150
|
+
abort
|
|
1151
|
+
};
|
|
1152
|
+
}
|
|
1153
|
+
function failQuery() {
|
|
1154
|
+
status = "failed";
|
|
1155
|
+
doneCallbacks.forEach((callback) => {
|
|
1156
|
+
callback(void 0, lastError);
|
|
1157
|
+
});
|
|
1158
|
+
}
|
|
1159
|
+
function clearQueue() {
|
|
1160
|
+
queue.forEach((item) => {
|
|
1161
|
+
if (item.status === "pending") {
|
|
1162
|
+
item.status = "aborted";
|
|
1163
|
+
}
|
|
1164
|
+
});
|
|
1165
|
+
queue = [];
|
|
1166
|
+
}
|
|
1167
|
+
function moduleResponse(item, response, data) {
|
|
1168
|
+
const isError = response !== "success";
|
|
1169
|
+
queue = queue.filter((queued) => queued !== item);
|
|
1170
|
+
switch (status) {
|
|
1171
|
+
case "pending":
|
|
1172
|
+
break;
|
|
1173
|
+
case "failed":
|
|
1174
|
+
if (isError || !config.dataAfterTimeout) {
|
|
1175
|
+
return;
|
|
1176
|
+
}
|
|
1177
|
+
break;
|
|
1178
|
+
default:
|
|
1179
|
+
return;
|
|
1180
|
+
}
|
|
1181
|
+
if (response === "abort") {
|
|
1182
|
+
lastError = data;
|
|
1183
|
+
failQuery();
|
|
1184
|
+
return;
|
|
1185
|
+
}
|
|
1186
|
+
if (isError) {
|
|
1187
|
+
lastError = data;
|
|
1188
|
+
if (!queue.length) {
|
|
1189
|
+
if (!resources.length) {
|
|
1190
|
+
failQuery();
|
|
1191
|
+
} else {
|
|
1192
|
+
execNext();
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
return;
|
|
1196
|
+
}
|
|
1197
|
+
resetTimer();
|
|
1198
|
+
clearQueue();
|
|
1199
|
+
if (!config.random) {
|
|
1200
|
+
const index = config.resources.indexOf(item.resource);
|
|
1201
|
+
if (index !== -1 && index !== config.index) {
|
|
1202
|
+
config.index = index;
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
status = "completed";
|
|
1206
|
+
doneCallbacks.forEach((callback) => {
|
|
1207
|
+
callback(data);
|
|
1208
|
+
});
|
|
1209
|
+
}
|
|
1210
|
+
function execNext() {
|
|
1211
|
+
if (status !== "pending") {
|
|
1212
|
+
return;
|
|
1213
|
+
}
|
|
1214
|
+
resetTimer();
|
|
1215
|
+
const resource = resources.shift();
|
|
1216
|
+
if (resource === void 0) {
|
|
1217
|
+
if (queue.length) {
|
|
1218
|
+
timer = setTimeout(() => {
|
|
1219
|
+
resetTimer();
|
|
1220
|
+
if (status === "pending") {
|
|
1221
|
+
clearQueue();
|
|
1222
|
+
failQuery();
|
|
1223
|
+
}
|
|
1224
|
+
}, config.timeout);
|
|
1225
|
+
return;
|
|
1226
|
+
}
|
|
1227
|
+
failQuery();
|
|
1228
|
+
return;
|
|
1229
|
+
}
|
|
1230
|
+
const item = {
|
|
1231
|
+
status: "pending",
|
|
1232
|
+
resource,
|
|
1233
|
+
callback: (status2, data) => {
|
|
1234
|
+
moduleResponse(item, status2, data);
|
|
1235
|
+
}
|
|
1236
|
+
};
|
|
1237
|
+
queue.push(item);
|
|
1238
|
+
queriesSent++;
|
|
1239
|
+
timer = setTimeout(execNext, config.rotate);
|
|
1240
|
+
query(resource, payload, item.callback);
|
|
1241
|
+
}
|
|
1242
|
+
setTimeout(execNext);
|
|
1243
|
+
return getQueryStatus;
|
|
1244
|
+
}
|
|
1245
|
+
function initRedundancy(cfg) {
|
|
1246
|
+
const config = {
|
|
1247
|
+
...defaultConfig,
|
|
1248
|
+
...cfg
|
|
1249
|
+
};
|
|
1250
|
+
let queries = [];
|
|
1251
|
+
function cleanup() {
|
|
1252
|
+
queries = queries.filter((item) => item().status === "pending");
|
|
1253
|
+
}
|
|
1254
|
+
function query(payload, queryCallback, doneCallback) {
|
|
1255
|
+
const query2 = sendQuery(
|
|
1256
|
+
config,
|
|
1257
|
+
payload,
|
|
1258
|
+
queryCallback,
|
|
1259
|
+
(data, error) => {
|
|
1260
|
+
cleanup();
|
|
1261
|
+
if (doneCallback) {
|
|
1262
|
+
doneCallback(data, error);
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
);
|
|
1266
|
+
queries.push(query2);
|
|
1267
|
+
return query2;
|
|
1268
|
+
}
|
|
1269
|
+
function find(callback) {
|
|
1270
|
+
return queries.find((value) => {
|
|
1271
|
+
return callback(value);
|
|
1272
|
+
}) || null;
|
|
1273
|
+
}
|
|
1274
|
+
const instance = {
|
|
1275
|
+
query,
|
|
1276
|
+
find,
|
|
1277
|
+
setIndex: (index) => {
|
|
1278
|
+
config.index = index;
|
|
1279
|
+
},
|
|
1280
|
+
getIndex: () => config.index,
|
|
1281
|
+
cleanup
|
|
1282
|
+
};
|
|
1283
|
+
return instance;
|
|
1284
|
+
}
|
|
1285
|
+
function createAPIConfig(source) {
|
|
1286
|
+
let resources;
|
|
1287
|
+
if (typeof source.resources === "string") {
|
|
1288
|
+
resources = [source.resources];
|
|
1289
|
+
} else {
|
|
1290
|
+
resources = source.resources;
|
|
1291
|
+
if (!(resources instanceof Array) || !resources.length) {
|
|
1292
|
+
return null;
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
const result = {
|
|
1296
|
+
resources,
|
|
1297
|
+
path: source.path || "/",
|
|
1298
|
+
maxURL: source.maxURL || 500,
|
|
1299
|
+
rotate: source.rotate || 750,
|
|
1300
|
+
timeout: source.timeout || 5e3,
|
|
1301
|
+
random: source.random === true,
|
|
1302
|
+
index: source.index || 0,
|
|
1303
|
+
dataAfterTimeout: source.dataAfterTimeout !== false
|
|
1304
|
+
};
|
|
1305
|
+
return result;
|
|
1306
|
+
}
|
|
1307
|
+
var configStorage = /* @__PURE__ */ Object.create(null);
|
|
1308
|
+
var fallBackAPISources = [
|
|
1309
|
+
"https://api.simplesvg.com",
|
|
1310
|
+
"https://api.unisvg.com"
|
|
1311
|
+
];
|
|
1312
|
+
var fallBackAPI = [];
|
|
1313
|
+
while (fallBackAPISources.length > 0) {
|
|
1314
|
+
if (fallBackAPISources.length === 1) {
|
|
1315
|
+
fallBackAPI.push(fallBackAPISources.shift());
|
|
1316
|
+
} else {
|
|
1317
|
+
if (Math.random() > 0.5) {
|
|
1318
|
+
fallBackAPI.push(fallBackAPISources.shift());
|
|
1319
|
+
} else {
|
|
1320
|
+
fallBackAPI.push(fallBackAPISources.pop());
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
configStorage[""] = createAPIConfig({
|
|
1325
|
+
resources: ["https://api.iconify.design"].concat(fallBackAPI)
|
|
1326
|
+
});
|
|
1327
|
+
function addAPIProvider$1(provider, customConfig) {
|
|
1328
|
+
const config = createAPIConfig(customConfig);
|
|
1329
|
+
if (config === null) {
|
|
1330
|
+
return false;
|
|
1331
|
+
}
|
|
1332
|
+
configStorage[provider] = config;
|
|
1333
|
+
return true;
|
|
1334
|
+
}
|
|
1335
|
+
function getAPIConfig(provider) {
|
|
1336
|
+
return configStorage[provider];
|
|
1337
|
+
}
|
|
1338
|
+
function listAPIProviders() {
|
|
1339
|
+
return Object.keys(configStorage);
|
|
1340
|
+
}
|
|
1341
|
+
function emptyCallback$1() {
|
|
1342
|
+
}
|
|
1343
|
+
var redundancyCache = /* @__PURE__ */ Object.create(null);
|
|
1344
|
+
function getRedundancyCache(provider) {
|
|
1345
|
+
if (!redundancyCache[provider]) {
|
|
1346
|
+
const config = getAPIConfig(provider);
|
|
1347
|
+
if (!config) {
|
|
1348
|
+
return;
|
|
1349
|
+
}
|
|
1350
|
+
const redundancy = initRedundancy(config);
|
|
1351
|
+
const cachedReundancy = {
|
|
1352
|
+
config,
|
|
1353
|
+
redundancy
|
|
1354
|
+
};
|
|
1355
|
+
redundancyCache[provider] = cachedReundancy;
|
|
1356
|
+
}
|
|
1357
|
+
return redundancyCache[provider];
|
|
1358
|
+
}
|
|
1359
|
+
function sendAPIQuery(target, query, callback) {
|
|
1360
|
+
let redundancy;
|
|
1361
|
+
let send2;
|
|
1362
|
+
if (typeof target === "string") {
|
|
1363
|
+
const api = getAPIModule(target);
|
|
1364
|
+
if (!api) {
|
|
1365
|
+
callback(void 0, 424);
|
|
1366
|
+
return emptyCallback$1;
|
|
1367
|
+
}
|
|
1368
|
+
send2 = api.send;
|
|
1369
|
+
const cached = getRedundancyCache(target);
|
|
1370
|
+
if (cached) {
|
|
1371
|
+
redundancy = cached.redundancy;
|
|
1372
|
+
}
|
|
1373
|
+
} else {
|
|
1374
|
+
const config = createAPIConfig(target);
|
|
1375
|
+
if (config) {
|
|
1376
|
+
redundancy = initRedundancy(config);
|
|
1377
|
+
const moduleKey = target.resources ? target.resources[0] : "";
|
|
1378
|
+
const api = getAPIModule(moduleKey);
|
|
1379
|
+
if (api) {
|
|
1380
|
+
send2 = api.send;
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
if (!redundancy || !send2) {
|
|
1385
|
+
callback(void 0, 424);
|
|
1386
|
+
return emptyCallback$1;
|
|
1387
|
+
}
|
|
1388
|
+
return redundancy.query(query, send2, callback)().abort;
|
|
1389
|
+
}
|
|
1390
|
+
var browserCacheVersion = "iconify2";
|
|
1391
|
+
var browserCachePrefix = "iconify";
|
|
1392
|
+
var browserCacheCountKey = browserCachePrefix + "-count";
|
|
1393
|
+
var browserCacheVersionKey = browserCachePrefix + "-version";
|
|
1394
|
+
var browserStorageHour = 36e5;
|
|
1395
|
+
var browserStorageCacheExpiration = 168;
|
|
1396
|
+
function getStoredItem(func, key) {
|
|
1397
|
+
try {
|
|
1398
|
+
return func.getItem(key);
|
|
1399
|
+
} catch (err) {
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
function setStoredItem(func, key, value) {
|
|
1403
|
+
try {
|
|
1404
|
+
func.setItem(key, value);
|
|
1405
|
+
return true;
|
|
1406
|
+
} catch (err) {
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
function removeStoredItem(func, key) {
|
|
1410
|
+
try {
|
|
1411
|
+
func.removeItem(key);
|
|
1412
|
+
} catch (err) {
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
function setBrowserStorageItemsCount(storage2, value) {
|
|
1416
|
+
return setStoredItem(storage2, browserCacheCountKey, value.toString());
|
|
1417
|
+
}
|
|
1418
|
+
function getBrowserStorageItemsCount(storage2) {
|
|
1419
|
+
return parseInt(getStoredItem(storage2, browserCacheCountKey)) || 0;
|
|
1420
|
+
}
|
|
1421
|
+
var browserStorageConfig = {
|
|
1422
|
+
local: true,
|
|
1423
|
+
session: true
|
|
1424
|
+
};
|
|
1425
|
+
var browserStorageEmptyItems = {
|
|
1426
|
+
local: /* @__PURE__ */ new Set(),
|
|
1427
|
+
session: /* @__PURE__ */ new Set()
|
|
1428
|
+
};
|
|
1429
|
+
var browserStorageStatus = false;
|
|
1430
|
+
function setBrowserStorageStatus(status) {
|
|
1431
|
+
browserStorageStatus = status;
|
|
1432
|
+
}
|
|
1433
|
+
var _window = typeof window === "undefined" ? {} : window;
|
|
1434
|
+
function getBrowserStorage(key) {
|
|
1435
|
+
const attr = key + "Storage";
|
|
1436
|
+
try {
|
|
1437
|
+
if (_window && _window[attr] && typeof _window[attr].length === "number") {
|
|
1438
|
+
return _window[attr];
|
|
1439
|
+
}
|
|
1440
|
+
} catch (err) {
|
|
1441
|
+
}
|
|
1442
|
+
browserStorageConfig[key] = false;
|
|
1443
|
+
}
|
|
1444
|
+
function iterateBrowserStorage(key, callback) {
|
|
1445
|
+
const func = getBrowserStorage(key);
|
|
1446
|
+
if (!func) {
|
|
1447
|
+
return;
|
|
1448
|
+
}
|
|
1449
|
+
const version = getStoredItem(func, browserCacheVersionKey);
|
|
1450
|
+
if (version !== browserCacheVersion) {
|
|
1451
|
+
if (version) {
|
|
1452
|
+
const total2 = getBrowserStorageItemsCount(func);
|
|
1453
|
+
for (let i = 0; i < total2; i++) {
|
|
1454
|
+
removeStoredItem(func, browserCachePrefix + i.toString());
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
setStoredItem(func, browserCacheVersionKey, browserCacheVersion);
|
|
1458
|
+
setBrowserStorageItemsCount(func, 0);
|
|
1459
|
+
return;
|
|
1460
|
+
}
|
|
1461
|
+
const minTime = Math.floor(Date.now() / browserStorageHour) - browserStorageCacheExpiration;
|
|
1462
|
+
const parseItem = (index) => {
|
|
1463
|
+
const name = browserCachePrefix + index.toString();
|
|
1464
|
+
const item = getStoredItem(func, name);
|
|
1465
|
+
if (typeof item !== "string") {
|
|
1466
|
+
return;
|
|
1467
|
+
}
|
|
1468
|
+
try {
|
|
1469
|
+
const data = JSON.parse(item);
|
|
1470
|
+
if (typeof data === "object" && typeof data.cached === "number" && data.cached > minTime && typeof data.provider === "string" && typeof data.data === "object" && typeof data.data.prefix === "string" && callback(data, index)) {
|
|
1471
|
+
return true;
|
|
1472
|
+
}
|
|
1473
|
+
} catch (err) {
|
|
1474
|
+
}
|
|
1475
|
+
removeStoredItem(func, name);
|
|
1476
|
+
};
|
|
1477
|
+
let total = getBrowserStorageItemsCount(func);
|
|
1478
|
+
for (let i = total - 1; i >= 0; i--) {
|
|
1479
|
+
if (!parseItem(i)) {
|
|
1480
|
+
if (i === total - 1) {
|
|
1481
|
+
total--;
|
|
1482
|
+
setBrowserStorageItemsCount(func, total);
|
|
1483
|
+
} else {
|
|
1484
|
+
browserStorageEmptyItems[key].add(i);
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
function initBrowserStorage() {
|
|
1490
|
+
if (browserStorageStatus) {
|
|
1491
|
+
return;
|
|
1492
|
+
}
|
|
1493
|
+
setBrowserStorageStatus(true);
|
|
1494
|
+
for (const key in browserStorageConfig) {
|
|
1495
|
+
iterateBrowserStorage(key, (item) => {
|
|
1496
|
+
const iconSet = item.data;
|
|
1497
|
+
const provider = item.provider;
|
|
1498
|
+
const prefix = iconSet.prefix;
|
|
1499
|
+
const storage2 = getStorage(
|
|
1500
|
+
provider,
|
|
1501
|
+
prefix
|
|
1502
|
+
);
|
|
1503
|
+
if (!addIconSet(storage2, iconSet).length) {
|
|
1504
|
+
return false;
|
|
1505
|
+
}
|
|
1506
|
+
const lastModified = iconSet.lastModified || -1;
|
|
1507
|
+
storage2.lastModifiedCached = storage2.lastModifiedCached ? Math.min(storage2.lastModifiedCached, lastModified) : lastModified;
|
|
1508
|
+
return true;
|
|
1509
|
+
});
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
function updateLastModified(storage2, lastModified) {
|
|
1513
|
+
const lastValue = storage2.lastModifiedCached;
|
|
1514
|
+
if (lastValue && lastValue >= lastModified) {
|
|
1515
|
+
return lastValue === lastModified;
|
|
1516
|
+
}
|
|
1517
|
+
storage2.lastModifiedCached = lastModified;
|
|
1518
|
+
if (lastValue) {
|
|
1519
|
+
for (const key in browserStorageConfig) {
|
|
1520
|
+
iterateBrowserStorage(key, (item) => {
|
|
1521
|
+
const iconSet = item.data;
|
|
1522
|
+
return item.provider !== storage2.provider || iconSet.prefix !== storage2.prefix || iconSet.lastModified === lastModified;
|
|
1523
|
+
});
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
return true;
|
|
1527
|
+
}
|
|
1528
|
+
function storeInBrowserStorage(storage2, data) {
|
|
1529
|
+
if (!browserStorageStatus) {
|
|
1530
|
+
initBrowserStorage();
|
|
1531
|
+
}
|
|
1532
|
+
function store(key) {
|
|
1533
|
+
let func;
|
|
1534
|
+
if (!browserStorageConfig[key] || !(func = getBrowserStorage(key))) {
|
|
1535
|
+
return;
|
|
1536
|
+
}
|
|
1537
|
+
const set = browserStorageEmptyItems[key];
|
|
1538
|
+
let index;
|
|
1539
|
+
if (set.size) {
|
|
1540
|
+
set.delete(index = Array.from(set).shift());
|
|
1541
|
+
} else {
|
|
1542
|
+
index = getBrowserStorageItemsCount(func);
|
|
1543
|
+
if (!setBrowserStorageItemsCount(func, index + 1)) {
|
|
1544
|
+
return;
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
const item = {
|
|
1548
|
+
cached: Math.floor(Date.now() / browserStorageHour),
|
|
1549
|
+
provider: storage2.provider,
|
|
1550
|
+
data
|
|
1551
|
+
};
|
|
1552
|
+
return setStoredItem(
|
|
1553
|
+
func,
|
|
1554
|
+
browserCachePrefix + index.toString(),
|
|
1555
|
+
JSON.stringify(item)
|
|
1556
|
+
);
|
|
1557
|
+
}
|
|
1558
|
+
if (data.lastModified && !updateLastModified(storage2, data.lastModified)) {
|
|
1559
|
+
return;
|
|
1560
|
+
}
|
|
1561
|
+
if (!Object.keys(data.icons).length) {
|
|
1562
|
+
return;
|
|
1563
|
+
}
|
|
1564
|
+
if (data.not_found) {
|
|
1565
|
+
data = Object.assign({}, data);
|
|
1566
|
+
delete data.not_found;
|
|
1567
|
+
}
|
|
1568
|
+
if (!store("local")) {
|
|
1569
|
+
store("session");
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
function emptyCallback() {
|
|
1573
|
+
}
|
|
1574
|
+
function loadedNewIcons(storage2) {
|
|
1575
|
+
if (!storage2.iconsLoaderFlag) {
|
|
1576
|
+
storage2.iconsLoaderFlag = true;
|
|
1577
|
+
setTimeout(() => {
|
|
1578
|
+
storage2.iconsLoaderFlag = false;
|
|
1579
|
+
updateCallbacks(storage2);
|
|
1580
|
+
});
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
function loadNewIcons(storage2, icons) {
|
|
1584
|
+
if (!storage2.iconsToLoad) {
|
|
1585
|
+
storage2.iconsToLoad = icons;
|
|
1586
|
+
} else {
|
|
1587
|
+
storage2.iconsToLoad = storage2.iconsToLoad.concat(icons).sort();
|
|
1588
|
+
}
|
|
1589
|
+
if (!storage2.iconsQueueFlag) {
|
|
1590
|
+
storage2.iconsQueueFlag = true;
|
|
1591
|
+
setTimeout(() => {
|
|
1592
|
+
storage2.iconsQueueFlag = false;
|
|
1593
|
+
const { provider, prefix } = storage2;
|
|
1594
|
+
const icons2 = storage2.iconsToLoad;
|
|
1595
|
+
delete storage2.iconsToLoad;
|
|
1596
|
+
let api;
|
|
1597
|
+
if (!icons2 || !(api = getAPIModule(provider))) {
|
|
1598
|
+
return;
|
|
1599
|
+
}
|
|
1600
|
+
const params = api.prepare(provider, prefix, icons2);
|
|
1601
|
+
params.forEach((item) => {
|
|
1602
|
+
sendAPIQuery(provider, item, (data) => {
|
|
1603
|
+
if (typeof data !== "object") {
|
|
1604
|
+
item.icons.forEach((name) => {
|
|
1605
|
+
storage2.missing.add(name);
|
|
1606
|
+
});
|
|
1607
|
+
} else {
|
|
1608
|
+
try {
|
|
1609
|
+
const parsed = addIconSet(
|
|
1610
|
+
storage2,
|
|
1611
|
+
data
|
|
1612
|
+
);
|
|
1613
|
+
if (!parsed.length) {
|
|
1614
|
+
return;
|
|
1615
|
+
}
|
|
1616
|
+
const pending = storage2.pendingIcons;
|
|
1617
|
+
if (pending) {
|
|
1618
|
+
parsed.forEach((name) => {
|
|
1619
|
+
pending.delete(name);
|
|
1620
|
+
});
|
|
1621
|
+
}
|
|
1622
|
+
storeInBrowserStorage(storage2, data);
|
|
1623
|
+
} catch (err) {
|
|
1624
|
+
console.error(err);
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
loadedNewIcons(storage2);
|
|
1628
|
+
});
|
|
1629
|
+
});
|
|
1630
|
+
});
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
var loadIcons$1 = (icons, callback) => {
|
|
1634
|
+
const cleanedIcons = listToIcons(icons, true, allowSimpleNames());
|
|
1635
|
+
const sortedIcons = sortIcons(cleanedIcons);
|
|
1636
|
+
if (!sortedIcons.pending.length) {
|
|
1637
|
+
let callCallback = true;
|
|
1638
|
+
if (callback) {
|
|
1639
|
+
setTimeout(() => {
|
|
1640
|
+
if (callCallback) {
|
|
1641
|
+
callback(
|
|
1642
|
+
sortedIcons.loaded,
|
|
1643
|
+
sortedIcons.missing,
|
|
1644
|
+
sortedIcons.pending,
|
|
1645
|
+
emptyCallback
|
|
1646
|
+
);
|
|
1647
|
+
}
|
|
1648
|
+
});
|
|
1649
|
+
}
|
|
1650
|
+
return () => {
|
|
1651
|
+
callCallback = false;
|
|
1652
|
+
};
|
|
1653
|
+
}
|
|
1654
|
+
const newIcons = /* @__PURE__ */ Object.create(null);
|
|
1655
|
+
const sources = [];
|
|
1656
|
+
let lastProvider, lastPrefix;
|
|
1657
|
+
sortedIcons.pending.forEach((icon) => {
|
|
1658
|
+
const { provider, prefix } = icon;
|
|
1659
|
+
if (prefix === lastPrefix && provider === lastProvider) {
|
|
1660
|
+
return;
|
|
1661
|
+
}
|
|
1662
|
+
lastProvider = provider;
|
|
1663
|
+
lastPrefix = prefix;
|
|
1664
|
+
sources.push(getStorage(provider, prefix));
|
|
1665
|
+
const providerNewIcons = newIcons[provider] || (newIcons[provider] = /* @__PURE__ */ Object.create(null));
|
|
1666
|
+
if (!providerNewIcons[prefix]) {
|
|
1667
|
+
providerNewIcons[prefix] = [];
|
|
1668
|
+
}
|
|
1669
|
+
});
|
|
1670
|
+
sortedIcons.pending.forEach((icon) => {
|
|
1671
|
+
const { provider, prefix, name } = icon;
|
|
1672
|
+
const storage2 = getStorage(provider, prefix);
|
|
1673
|
+
const pendingQueue = storage2.pendingIcons || (storage2.pendingIcons = /* @__PURE__ */ new Set());
|
|
1674
|
+
if (!pendingQueue.has(name)) {
|
|
1675
|
+
pendingQueue.add(name);
|
|
1676
|
+
newIcons[provider][prefix].push(name);
|
|
1677
|
+
}
|
|
1678
|
+
});
|
|
1679
|
+
sources.forEach((storage2) => {
|
|
1680
|
+
const { provider, prefix } = storage2;
|
|
1681
|
+
if (newIcons[provider][prefix].length) {
|
|
1682
|
+
loadNewIcons(storage2, newIcons[provider][prefix]);
|
|
1683
|
+
}
|
|
1684
|
+
});
|
|
1685
|
+
return callback ? storeCallback(callback, sortedIcons, sources) : emptyCallback;
|
|
1686
|
+
};
|
|
1687
|
+
var loadIcon$1 = (icon) => {
|
|
1688
|
+
return new Promise((fulfill, reject) => {
|
|
1689
|
+
const iconObj = typeof icon === "string" ? stringToIcon(icon, true) : icon;
|
|
1690
|
+
if (!iconObj) {
|
|
1691
|
+
reject(icon);
|
|
1692
|
+
return;
|
|
1693
|
+
}
|
|
1694
|
+
loadIcons$1([iconObj || icon], (loaded) => {
|
|
1695
|
+
if (loaded.length && iconObj) {
|
|
1696
|
+
const data = getIconData(iconObj);
|
|
1697
|
+
if (data) {
|
|
1698
|
+
fulfill({
|
|
1699
|
+
...defaultIconProps,
|
|
1700
|
+
...data
|
|
1701
|
+
});
|
|
1702
|
+
return;
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
reject(icon);
|
|
1706
|
+
});
|
|
1707
|
+
});
|
|
1708
|
+
};
|
|
1709
|
+
function testIconObject(value) {
|
|
1710
|
+
try {
|
|
1711
|
+
const obj = typeof value === "string" ? JSON.parse(value) : value;
|
|
1712
|
+
if (typeof obj.body === "string") {
|
|
1713
|
+
return {
|
|
1714
|
+
...obj
|
|
1715
|
+
};
|
|
1716
|
+
}
|
|
1717
|
+
} catch (err) {
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
function parseIconValue(value, onload) {
|
|
1721
|
+
const name = typeof value === "string" ? stringToIcon(value, true, true) : null;
|
|
1722
|
+
if (!name) {
|
|
1723
|
+
const data2 = testIconObject(value);
|
|
1724
|
+
return {
|
|
1725
|
+
value,
|
|
1726
|
+
data: data2
|
|
1727
|
+
};
|
|
1728
|
+
}
|
|
1729
|
+
const data = getIconData(name);
|
|
1730
|
+
if (data !== void 0 || !name.prefix) {
|
|
1731
|
+
return {
|
|
1732
|
+
value,
|
|
1733
|
+
name,
|
|
1734
|
+
data
|
|
1735
|
+
// could be 'null' -> icon is missing
|
|
1736
|
+
};
|
|
1737
|
+
}
|
|
1738
|
+
const loading = loadIcons$1([name], () => onload(value, name, getIconData(name)));
|
|
1739
|
+
return {
|
|
1740
|
+
value,
|
|
1741
|
+
name,
|
|
1742
|
+
loading
|
|
1743
|
+
};
|
|
1744
|
+
}
|
|
1745
|
+
function getInline(node) {
|
|
1746
|
+
return node.hasAttribute("inline");
|
|
1747
|
+
}
|
|
1748
|
+
var isBuggedSafari = false;
|
|
1749
|
+
try {
|
|
1750
|
+
isBuggedSafari = navigator.vendor.indexOf("Apple") === 0;
|
|
1751
|
+
} catch (err) {
|
|
1752
|
+
}
|
|
1753
|
+
function getRenderMode(body, mode) {
|
|
1754
|
+
switch (mode) {
|
|
1755
|
+
case "svg":
|
|
1756
|
+
case "bg":
|
|
1757
|
+
case "mask":
|
|
1758
|
+
return mode;
|
|
1759
|
+
}
|
|
1760
|
+
if (mode !== "style" && (isBuggedSafari || body.indexOf("<a") === -1)) {
|
|
1761
|
+
return "svg";
|
|
1762
|
+
}
|
|
1763
|
+
return body.indexOf("currentColor") === -1 ? "bg" : "mask";
|
|
1764
|
+
}
|
|
1765
|
+
var unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g;
|
|
1766
|
+
var unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g;
|
|
1767
|
+
function calculateSize$1(size, ratio, precision) {
|
|
1768
|
+
if (ratio === 1) {
|
|
1769
|
+
return size;
|
|
1770
|
+
}
|
|
1771
|
+
precision = precision || 100;
|
|
1772
|
+
if (typeof size === "number") {
|
|
1773
|
+
return Math.ceil(size * ratio * precision) / precision;
|
|
1774
|
+
}
|
|
1775
|
+
if (typeof size !== "string") {
|
|
1776
|
+
return size;
|
|
1777
|
+
}
|
|
1778
|
+
const oldParts = size.split(unitsSplit);
|
|
1779
|
+
if (oldParts === null || !oldParts.length) {
|
|
1780
|
+
return size;
|
|
1781
|
+
}
|
|
1782
|
+
const newParts = [];
|
|
1783
|
+
let code = oldParts.shift();
|
|
1784
|
+
let isNumber = unitsTest.test(code);
|
|
1785
|
+
while (true) {
|
|
1786
|
+
if (isNumber) {
|
|
1787
|
+
const num = parseFloat(code);
|
|
1788
|
+
if (isNaN(num)) {
|
|
1789
|
+
newParts.push(code);
|
|
1790
|
+
} else {
|
|
1791
|
+
newParts.push(Math.ceil(num * ratio * precision) / precision);
|
|
1792
|
+
}
|
|
1793
|
+
} else {
|
|
1794
|
+
newParts.push(code);
|
|
1795
|
+
}
|
|
1796
|
+
code = oldParts.shift();
|
|
1797
|
+
if (code === void 0) {
|
|
1798
|
+
return newParts.join("");
|
|
1799
|
+
}
|
|
1800
|
+
isNumber = !isNumber;
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
var isUnsetKeyword = (value) => value === "unset" || value === "undefined" || value === "none";
|
|
1804
|
+
function iconToSVG(icon, customisations) {
|
|
1805
|
+
const fullIcon = {
|
|
1806
|
+
...defaultIconProps,
|
|
1807
|
+
...icon
|
|
1808
|
+
};
|
|
1809
|
+
const fullCustomisations = {
|
|
1810
|
+
...defaultIconCustomisations,
|
|
1811
|
+
...customisations
|
|
1812
|
+
};
|
|
1813
|
+
const box = {
|
|
1814
|
+
left: fullIcon.left,
|
|
1815
|
+
top: fullIcon.top,
|
|
1816
|
+
width: fullIcon.width,
|
|
1817
|
+
height: fullIcon.height
|
|
1818
|
+
};
|
|
1819
|
+
let body = fullIcon.body;
|
|
1820
|
+
[fullIcon, fullCustomisations].forEach((props) => {
|
|
1821
|
+
const transformations = [];
|
|
1822
|
+
const hFlip = props.hFlip;
|
|
1823
|
+
const vFlip = props.vFlip;
|
|
1824
|
+
let rotation = props.rotate;
|
|
1825
|
+
if (hFlip) {
|
|
1826
|
+
if (vFlip) {
|
|
1827
|
+
rotation += 2;
|
|
1828
|
+
} else {
|
|
1829
|
+
transformations.push(
|
|
1830
|
+
"translate(" + (box.width + box.left).toString() + " " + (0 - box.top).toString() + ")"
|
|
1831
|
+
);
|
|
1832
|
+
transformations.push("scale(-1 1)");
|
|
1833
|
+
box.top = box.left = 0;
|
|
1834
|
+
}
|
|
1835
|
+
} else if (vFlip) {
|
|
1836
|
+
transformations.push(
|
|
1837
|
+
"translate(" + (0 - box.left).toString() + " " + (box.height + box.top).toString() + ")"
|
|
1838
|
+
);
|
|
1839
|
+
transformations.push("scale(1 -1)");
|
|
1840
|
+
box.top = box.left = 0;
|
|
1841
|
+
}
|
|
1842
|
+
let tempValue;
|
|
1843
|
+
if (rotation < 0) {
|
|
1844
|
+
rotation -= Math.floor(rotation / 4) * 4;
|
|
1845
|
+
}
|
|
1846
|
+
rotation = rotation % 4;
|
|
1847
|
+
switch (rotation) {
|
|
1848
|
+
case 1:
|
|
1849
|
+
tempValue = box.height / 2 + box.top;
|
|
1850
|
+
transformations.unshift(
|
|
1851
|
+
"rotate(90 " + tempValue.toString() + " " + tempValue.toString() + ")"
|
|
1852
|
+
);
|
|
1853
|
+
break;
|
|
1854
|
+
case 2:
|
|
1855
|
+
transformations.unshift(
|
|
1856
|
+
"rotate(180 " + (box.width / 2 + box.left).toString() + " " + (box.height / 2 + box.top).toString() + ")"
|
|
1857
|
+
);
|
|
1858
|
+
break;
|
|
1859
|
+
case 3:
|
|
1860
|
+
tempValue = box.width / 2 + box.left;
|
|
1861
|
+
transformations.unshift(
|
|
1862
|
+
"rotate(-90 " + tempValue.toString() + " " + tempValue.toString() + ")"
|
|
1863
|
+
);
|
|
1864
|
+
break;
|
|
1865
|
+
}
|
|
1866
|
+
if (rotation % 2 === 1) {
|
|
1867
|
+
if (box.left !== box.top) {
|
|
1868
|
+
tempValue = box.left;
|
|
1869
|
+
box.left = box.top;
|
|
1870
|
+
box.top = tempValue;
|
|
1871
|
+
}
|
|
1872
|
+
if (box.width !== box.height) {
|
|
1873
|
+
tempValue = box.width;
|
|
1874
|
+
box.width = box.height;
|
|
1875
|
+
box.height = tempValue;
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1878
|
+
if (transformations.length) {
|
|
1879
|
+
body = '<g transform="' + transformations.join(" ") + '">' + body + "</g>";
|
|
1880
|
+
}
|
|
1881
|
+
});
|
|
1882
|
+
const customisationsWidth = fullCustomisations.width;
|
|
1883
|
+
const customisationsHeight = fullCustomisations.height;
|
|
1884
|
+
const boxWidth = box.width;
|
|
1885
|
+
const boxHeight = box.height;
|
|
1886
|
+
let width;
|
|
1887
|
+
let height;
|
|
1888
|
+
if (customisationsWidth === null) {
|
|
1889
|
+
height = customisationsHeight === null ? "1em" : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
|
|
1890
|
+
width = calculateSize$1(height, boxWidth / boxHeight);
|
|
1891
|
+
} else {
|
|
1892
|
+
width = customisationsWidth === "auto" ? boxWidth : customisationsWidth;
|
|
1893
|
+
height = customisationsHeight === null ? calculateSize$1(width, boxHeight / boxWidth) : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
|
|
1894
|
+
}
|
|
1895
|
+
const attributes = {};
|
|
1896
|
+
const setAttr = (prop, value) => {
|
|
1897
|
+
if (!isUnsetKeyword(value)) {
|
|
1898
|
+
attributes[prop] = value.toString();
|
|
1899
|
+
}
|
|
1900
|
+
};
|
|
1901
|
+
setAttr("width", width);
|
|
1902
|
+
setAttr("height", height);
|
|
1903
|
+
attributes.viewBox = box.left.toString() + " " + box.top.toString() + " " + boxWidth.toString() + " " + boxHeight.toString();
|
|
1904
|
+
return {
|
|
1905
|
+
attributes,
|
|
1906
|
+
body
|
|
1907
|
+
};
|
|
1908
|
+
}
|
|
1909
|
+
var detectFetch = () => {
|
|
1910
|
+
let callback;
|
|
1911
|
+
try {
|
|
1912
|
+
callback = fetch;
|
|
1913
|
+
if (typeof callback === "function") {
|
|
1914
|
+
return callback;
|
|
1915
|
+
}
|
|
1916
|
+
} catch (err) {
|
|
1917
|
+
}
|
|
1918
|
+
};
|
|
1919
|
+
var fetchModule = detectFetch();
|
|
1920
|
+
function setFetch(fetch2) {
|
|
1921
|
+
fetchModule = fetch2;
|
|
1922
|
+
}
|
|
1923
|
+
function getFetch() {
|
|
1924
|
+
return fetchModule;
|
|
1925
|
+
}
|
|
1926
|
+
function calculateMaxLength(provider, prefix) {
|
|
1927
|
+
const config = getAPIConfig(provider);
|
|
1928
|
+
if (!config) {
|
|
1929
|
+
return 0;
|
|
1930
|
+
}
|
|
1931
|
+
let result;
|
|
1932
|
+
if (!config.maxURL) {
|
|
1933
|
+
result = 0;
|
|
1934
|
+
} else {
|
|
1935
|
+
let maxHostLength = 0;
|
|
1936
|
+
config.resources.forEach((item) => {
|
|
1937
|
+
const host = item;
|
|
1938
|
+
maxHostLength = Math.max(maxHostLength, host.length);
|
|
1939
|
+
});
|
|
1940
|
+
const url = prefix + ".json?icons=";
|
|
1941
|
+
result = config.maxURL - maxHostLength - config.path.length - url.length;
|
|
1942
|
+
}
|
|
1943
|
+
return result;
|
|
1944
|
+
}
|
|
1945
|
+
function shouldAbort(status) {
|
|
1946
|
+
return status === 404;
|
|
1947
|
+
}
|
|
1948
|
+
var prepare = (provider, prefix, icons) => {
|
|
1949
|
+
const results = [];
|
|
1950
|
+
const maxLength = calculateMaxLength(provider, prefix);
|
|
1951
|
+
const type = "icons";
|
|
1952
|
+
let item = {
|
|
1953
|
+
type,
|
|
1954
|
+
provider,
|
|
1955
|
+
prefix,
|
|
1956
|
+
icons: []
|
|
1957
|
+
};
|
|
1958
|
+
let length = 0;
|
|
1959
|
+
icons.forEach((name, index) => {
|
|
1960
|
+
length += name.length + 1;
|
|
1961
|
+
if (length >= maxLength && index > 0) {
|
|
1962
|
+
results.push(item);
|
|
1963
|
+
item = {
|
|
1964
|
+
type,
|
|
1965
|
+
provider,
|
|
1966
|
+
prefix,
|
|
1967
|
+
icons: []
|
|
1968
|
+
};
|
|
1969
|
+
length = name.length;
|
|
1970
|
+
}
|
|
1971
|
+
item.icons.push(name);
|
|
1972
|
+
});
|
|
1973
|
+
results.push(item);
|
|
1974
|
+
return results;
|
|
1975
|
+
};
|
|
1976
|
+
function getPath(provider) {
|
|
1977
|
+
if (typeof provider === "string") {
|
|
1978
|
+
const config = getAPIConfig(provider);
|
|
1979
|
+
if (config) {
|
|
1980
|
+
return config.path;
|
|
1981
|
+
}
|
|
1982
|
+
}
|
|
1983
|
+
return "/";
|
|
1984
|
+
}
|
|
1985
|
+
var send = (host, params, callback) => {
|
|
1986
|
+
if (!fetchModule) {
|
|
1987
|
+
callback("abort", 424);
|
|
1988
|
+
return;
|
|
1989
|
+
}
|
|
1990
|
+
let path = getPath(params.provider);
|
|
1991
|
+
switch (params.type) {
|
|
1992
|
+
case "icons": {
|
|
1993
|
+
const prefix = params.prefix;
|
|
1994
|
+
const icons = params.icons;
|
|
1995
|
+
const iconsList = icons.join(",");
|
|
1996
|
+
const urlParams = new URLSearchParams({
|
|
1997
|
+
icons: iconsList
|
|
1998
|
+
});
|
|
1999
|
+
path += prefix + ".json?" + urlParams.toString();
|
|
2000
|
+
break;
|
|
2001
|
+
}
|
|
2002
|
+
case "custom": {
|
|
2003
|
+
const uri = params.uri;
|
|
2004
|
+
path += uri.slice(0, 1) === "/" ? uri.slice(1) : uri;
|
|
2005
|
+
break;
|
|
2006
|
+
}
|
|
2007
|
+
default:
|
|
2008
|
+
callback("abort", 400);
|
|
2009
|
+
return;
|
|
2010
|
+
}
|
|
2011
|
+
let defaultError = 503;
|
|
2012
|
+
fetchModule(host + path).then((response) => {
|
|
2013
|
+
const status = response.status;
|
|
2014
|
+
if (status !== 200) {
|
|
2015
|
+
setTimeout(() => {
|
|
2016
|
+
callback(shouldAbort(status) ? "abort" : "next", status);
|
|
2017
|
+
});
|
|
2018
|
+
return;
|
|
2019
|
+
}
|
|
2020
|
+
defaultError = 501;
|
|
2021
|
+
return response.json();
|
|
2022
|
+
}).then((data) => {
|
|
2023
|
+
if (typeof data !== "object" || data === null) {
|
|
2024
|
+
setTimeout(() => {
|
|
2025
|
+
if (data === 404) {
|
|
2026
|
+
callback("abort", data);
|
|
2027
|
+
} else {
|
|
2028
|
+
callback("next", defaultError);
|
|
2029
|
+
}
|
|
2030
|
+
});
|
|
2031
|
+
return;
|
|
2032
|
+
}
|
|
2033
|
+
setTimeout(() => {
|
|
2034
|
+
callback("success", data);
|
|
2035
|
+
});
|
|
2036
|
+
}).catch(() => {
|
|
2037
|
+
callback("next", defaultError);
|
|
2038
|
+
});
|
|
2039
|
+
};
|
|
2040
|
+
var fetchAPIModule = {
|
|
2041
|
+
prepare,
|
|
2042
|
+
send
|
|
2043
|
+
};
|
|
2044
|
+
function toggleBrowserCache(storage2, value) {
|
|
2045
|
+
switch (storage2) {
|
|
2046
|
+
case "local":
|
|
2047
|
+
case "session":
|
|
2048
|
+
browserStorageConfig[storage2] = value;
|
|
2049
|
+
break;
|
|
2050
|
+
case "all":
|
|
2051
|
+
for (const key in browserStorageConfig) {
|
|
2052
|
+
browserStorageConfig[key] = value;
|
|
2053
|
+
}
|
|
2054
|
+
break;
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
var nodeAttr = "data-style";
|
|
2058
|
+
var customStyle = "";
|
|
2059
|
+
function appendCustomStyle(style) {
|
|
2060
|
+
customStyle = style;
|
|
2061
|
+
}
|
|
2062
|
+
function updateStyle(parent, inline) {
|
|
2063
|
+
let styleNode = Array.from(parent.childNodes).find((node) => node.hasAttribute && node.hasAttribute(nodeAttr));
|
|
2064
|
+
if (!styleNode) {
|
|
2065
|
+
styleNode = document.createElement("style");
|
|
2066
|
+
styleNode.setAttribute(nodeAttr, nodeAttr);
|
|
2067
|
+
parent.appendChild(styleNode);
|
|
2068
|
+
}
|
|
2069
|
+
styleNode.textContent = ":host{display:inline-block;vertical-align:" + (inline ? "-0.125em" : "0") + "}span,svg{display:block}" + customStyle;
|
|
2070
|
+
}
|
|
2071
|
+
function exportFunctions() {
|
|
2072
|
+
setAPIModule("", fetchAPIModule);
|
|
2073
|
+
allowSimpleNames(true);
|
|
2074
|
+
let _window2;
|
|
2075
|
+
try {
|
|
2076
|
+
_window2 = window;
|
|
2077
|
+
} catch (err) {
|
|
2078
|
+
}
|
|
2079
|
+
if (_window2) {
|
|
2080
|
+
initBrowserStorage();
|
|
2081
|
+
if (_window2.IconifyPreload !== void 0) {
|
|
2082
|
+
const preload = _window2.IconifyPreload;
|
|
2083
|
+
const err = "Invalid IconifyPreload syntax.";
|
|
2084
|
+
if (typeof preload === "object" && preload !== null) {
|
|
2085
|
+
(preload instanceof Array ? preload : [preload]).forEach((item) => {
|
|
2086
|
+
try {
|
|
2087
|
+
if (
|
|
2088
|
+
// Check if item is an object and not null/array
|
|
2089
|
+
typeof item !== "object" || item === null || item instanceof Array || // Check for 'icons' and 'prefix'
|
|
2090
|
+
typeof item.icons !== "object" || typeof item.prefix !== "string" || // Add icon set
|
|
2091
|
+
!addCollection$1(item)
|
|
2092
|
+
) {
|
|
2093
|
+
console.error(err);
|
|
2094
|
+
}
|
|
2095
|
+
} catch (e) {
|
|
2096
|
+
console.error(err);
|
|
2097
|
+
}
|
|
2098
|
+
});
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
if (_window2.IconifyProviders !== void 0) {
|
|
2102
|
+
const providers = _window2.IconifyProviders;
|
|
2103
|
+
if (typeof providers === "object" && providers !== null) {
|
|
2104
|
+
for (const key in providers) {
|
|
2105
|
+
const err = "IconifyProviders[" + key + "] is invalid.";
|
|
2106
|
+
try {
|
|
2107
|
+
const value = providers[key];
|
|
2108
|
+
if (typeof value !== "object" || !value || value.resources === void 0) {
|
|
2109
|
+
continue;
|
|
2110
|
+
}
|
|
2111
|
+
if (!addAPIProvider$1(key, value)) {
|
|
2112
|
+
console.error(err);
|
|
2113
|
+
}
|
|
2114
|
+
} catch (e) {
|
|
2115
|
+
console.error(err);
|
|
2116
|
+
}
|
|
2117
|
+
}
|
|
2118
|
+
}
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2121
|
+
const _api2 = {
|
|
2122
|
+
getAPIConfig,
|
|
2123
|
+
setAPIModule,
|
|
2124
|
+
sendAPIQuery,
|
|
2125
|
+
setFetch,
|
|
2126
|
+
getFetch,
|
|
2127
|
+
listAPIProviders
|
|
2128
|
+
};
|
|
2129
|
+
return {
|
|
2130
|
+
enableCache: (storage2) => toggleBrowserCache(storage2, true),
|
|
2131
|
+
disableCache: (storage2) => toggleBrowserCache(storage2, false),
|
|
2132
|
+
iconExists: iconExists$1,
|
|
2133
|
+
getIcon: getIcon$1,
|
|
2134
|
+
listIcons: listIcons$1,
|
|
2135
|
+
addIcon: addIcon$1,
|
|
2136
|
+
addCollection: addCollection$1,
|
|
2137
|
+
calculateSize: calculateSize$1,
|
|
2138
|
+
buildIcon: iconToSVG,
|
|
2139
|
+
loadIcons: loadIcons$1,
|
|
2140
|
+
loadIcon: loadIcon$1,
|
|
2141
|
+
addAPIProvider: addAPIProvider$1,
|
|
2142
|
+
appendCustomStyle,
|
|
2143
|
+
_api: _api2
|
|
2144
|
+
};
|
|
2145
|
+
}
|
|
2146
|
+
function iconToHTML(body, attributes) {
|
|
2147
|
+
let renderAttribsHTML = body.indexOf("xlink:") === -1 ? "" : ' xmlns:xlink="http://www.w3.org/1999/xlink"';
|
|
2148
|
+
for (const attr in attributes) {
|
|
2149
|
+
renderAttribsHTML += " " + attr + '="' + attributes[attr] + '"';
|
|
2150
|
+
}
|
|
2151
|
+
return '<svg xmlns="http://www.w3.org/2000/svg"' + renderAttribsHTML + ">" + body + "</svg>";
|
|
2152
|
+
}
|
|
2153
|
+
function encodeSVGforURL(svg) {
|
|
2154
|
+
return svg.replace(/"/g, "'").replace(/%/g, "%25").replace(/#/g, "%23").replace(/</g, "%3C").replace(/>/g, "%3E").replace(/\s+/g, " ");
|
|
2155
|
+
}
|
|
2156
|
+
function svgToURL(svg) {
|
|
2157
|
+
return 'url("data:image/svg+xml,' + encodeSVGforURL(svg) + '")';
|
|
2158
|
+
}
|
|
2159
|
+
var monotoneProps = {
|
|
2160
|
+
"background-color": "currentColor"
|
|
2161
|
+
};
|
|
2162
|
+
var coloredProps = {
|
|
2163
|
+
"background-color": "transparent"
|
|
2164
|
+
};
|
|
2165
|
+
var propsToAdd = {
|
|
2166
|
+
image: "var(--svg)",
|
|
2167
|
+
repeat: "no-repeat",
|
|
2168
|
+
size: "100% 100%"
|
|
2169
|
+
};
|
|
2170
|
+
var propsToAddTo = {
|
|
2171
|
+
"-webkit-mask": monotoneProps,
|
|
2172
|
+
"mask": monotoneProps,
|
|
2173
|
+
"background": coloredProps
|
|
2174
|
+
};
|
|
2175
|
+
for (const prefix in propsToAddTo) {
|
|
2176
|
+
const list = propsToAddTo[prefix];
|
|
2177
|
+
for (const prop in propsToAdd) {
|
|
2178
|
+
list[prefix + "-" + prop] = propsToAdd[prop];
|
|
2179
|
+
}
|
|
2180
|
+
}
|
|
2181
|
+
function fixSize(value) {
|
|
2182
|
+
return value + (value.match(/^[-0-9.]+$/) ? "px" : "");
|
|
2183
|
+
}
|
|
2184
|
+
function renderSPAN(data, icon, useMask) {
|
|
2185
|
+
const node = document.createElement("span");
|
|
2186
|
+
let body = data.body;
|
|
2187
|
+
if (body.indexOf("<a") !== -1) {
|
|
2188
|
+
body += "<!-- " + Date.now() + " -->";
|
|
2189
|
+
}
|
|
2190
|
+
const renderAttribs = data.attributes;
|
|
2191
|
+
const html = iconToHTML(body, {
|
|
2192
|
+
...renderAttribs,
|
|
2193
|
+
width: icon.width + "",
|
|
2194
|
+
height: icon.height + ""
|
|
2195
|
+
});
|
|
2196
|
+
const url = svgToURL(html);
|
|
2197
|
+
const svgStyle = node.style;
|
|
2198
|
+
const styles = {
|
|
2199
|
+
"--svg": url,
|
|
2200
|
+
"width": fixSize(renderAttribs.width),
|
|
2201
|
+
"height": fixSize(renderAttribs.height),
|
|
2202
|
+
...useMask ? monotoneProps : coloredProps
|
|
2203
|
+
};
|
|
2204
|
+
for (const prop in styles) {
|
|
2205
|
+
svgStyle.setProperty(prop, styles[prop]);
|
|
2206
|
+
}
|
|
2207
|
+
return node;
|
|
2208
|
+
}
|
|
2209
|
+
function renderSVG(data) {
|
|
2210
|
+
const node = document.createElement("span");
|
|
2211
|
+
node.innerHTML = iconToHTML(data.body, data.attributes);
|
|
2212
|
+
return node.firstChild;
|
|
2213
|
+
}
|
|
2214
|
+
function renderIcon(parent, state) {
|
|
2215
|
+
const iconData = state.icon.data;
|
|
2216
|
+
const customisations = state.customisations;
|
|
2217
|
+
const renderData = iconToSVG(iconData, customisations);
|
|
2218
|
+
if (customisations.preserveAspectRatio) {
|
|
2219
|
+
renderData.attributes["preserveAspectRatio"] = customisations.preserveAspectRatio;
|
|
2220
|
+
}
|
|
2221
|
+
const mode = state.renderedMode;
|
|
2222
|
+
let node;
|
|
2223
|
+
switch (mode) {
|
|
2224
|
+
case "svg":
|
|
2225
|
+
node = renderSVG(renderData);
|
|
2226
|
+
break;
|
|
2227
|
+
default:
|
|
2228
|
+
node = renderSPAN(renderData, {
|
|
2229
|
+
...defaultIconProps,
|
|
2230
|
+
...iconData
|
|
2231
|
+
}, mode === "mask");
|
|
2232
|
+
}
|
|
2233
|
+
const oldNode = Array.from(parent.childNodes).find((node2) => {
|
|
2234
|
+
const tag = node2.tagName && node2.tagName.toUpperCase();
|
|
2235
|
+
return tag === "SPAN" || tag === "SVG";
|
|
2236
|
+
});
|
|
2237
|
+
if (oldNode) {
|
|
2238
|
+
if (node.tagName === "SPAN" && oldNode.tagName === node.tagName) {
|
|
2239
|
+
oldNode.setAttribute("style", node.getAttribute("style"));
|
|
2240
|
+
} else {
|
|
2241
|
+
parent.replaceChild(node, oldNode);
|
|
2242
|
+
}
|
|
2243
|
+
} else {
|
|
2244
|
+
parent.appendChild(node);
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
function setPendingState(icon, inline, lastState) {
|
|
2248
|
+
const lastRender = lastState && (lastState.rendered ? lastState : lastState.lastRender);
|
|
2249
|
+
return {
|
|
2250
|
+
rendered: false,
|
|
2251
|
+
inline,
|
|
2252
|
+
icon,
|
|
2253
|
+
lastRender
|
|
2254
|
+
};
|
|
2255
|
+
}
|
|
2256
|
+
function defineIconifyIcon(name = "iconify-icon") {
|
|
2257
|
+
let customElements;
|
|
2258
|
+
let ParentClass;
|
|
2259
|
+
try {
|
|
2260
|
+
customElements = window.customElements;
|
|
2261
|
+
ParentClass = window.HTMLElement;
|
|
2262
|
+
} catch (err) {
|
|
2263
|
+
return;
|
|
2264
|
+
}
|
|
2265
|
+
if (!customElements || !ParentClass) {
|
|
2266
|
+
return;
|
|
2267
|
+
}
|
|
2268
|
+
const ConflictingClass = customElements.get(name);
|
|
2269
|
+
if (ConflictingClass) {
|
|
2270
|
+
return ConflictingClass;
|
|
2271
|
+
}
|
|
2272
|
+
const attributes = [
|
|
2273
|
+
// Icon
|
|
2274
|
+
"icon",
|
|
2275
|
+
// Mode
|
|
2276
|
+
"mode",
|
|
2277
|
+
"inline",
|
|
2278
|
+
// Customisations
|
|
2279
|
+
"width",
|
|
2280
|
+
"height",
|
|
2281
|
+
"rotate",
|
|
2282
|
+
"flip"
|
|
2283
|
+
];
|
|
2284
|
+
const IconifyIcon = class extends ParentClass {
|
|
2285
|
+
/**
|
|
2286
|
+
* Constructor
|
|
2287
|
+
*/
|
|
2288
|
+
constructor() {
|
|
2289
|
+
super();
|
|
2290
|
+
// Root
|
|
2291
|
+
__publicField(this, "_shadowRoot");
|
|
2292
|
+
// State
|
|
2293
|
+
__publicField(this, "_state");
|
|
2294
|
+
// Attributes check queued
|
|
2295
|
+
__publicField(this, "_checkQueued", false);
|
|
2296
|
+
const root = this._shadowRoot = this.attachShadow({
|
|
2297
|
+
mode: "open"
|
|
2298
|
+
});
|
|
2299
|
+
const inline = getInline(this);
|
|
2300
|
+
updateStyle(root, inline);
|
|
2301
|
+
this._state = setPendingState({
|
|
2302
|
+
value: ""
|
|
2303
|
+
}, inline);
|
|
2304
|
+
this._queueCheck();
|
|
2305
|
+
}
|
|
2306
|
+
/**
|
|
2307
|
+
* Observed attributes
|
|
2308
|
+
*/
|
|
2309
|
+
static get observedAttributes() {
|
|
2310
|
+
return attributes.slice(0);
|
|
2311
|
+
}
|
|
2312
|
+
/**
|
|
2313
|
+
* Observed properties that are different from attributes
|
|
2314
|
+
*
|
|
2315
|
+
* Experimental! Need to test with various frameworks that support it
|
|
2316
|
+
*/
|
|
2317
|
+
/*
|
|
2318
|
+
static get properties() {
|
|
2319
|
+
return {
|
|
2320
|
+
inline: {
|
|
2321
|
+
type: Boolean,
|
|
2322
|
+
reflect: true,
|
|
2323
|
+
},
|
|
2324
|
+
// Not listing other attributes because they are strings or combination
|
|
2325
|
+
// of string and another type. Cannot have multiple types
|
|
2326
|
+
};
|
|
2327
|
+
}
|
|
2328
|
+
*/
|
|
2329
|
+
/**
|
|
2330
|
+
* Attribute has changed
|
|
2331
|
+
*/
|
|
2332
|
+
attributeChangedCallback(name2) {
|
|
2333
|
+
if (name2 === "inline") {
|
|
2334
|
+
const newInline = getInline(this);
|
|
2335
|
+
const state = this._state;
|
|
2336
|
+
if (newInline !== state.inline) {
|
|
2337
|
+
state.inline = newInline;
|
|
2338
|
+
updateStyle(this._shadowRoot, newInline);
|
|
2339
|
+
}
|
|
2340
|
+
} else {
|
|
2341
|
+
this._queueCheck();
|
|
2342
|
+
}
|
|
2343
|
+
}
|
|
2344
|
+
/**
|
|
2345
|
+
* Get/set icon
|
|
2346
|
+
*/
|
|
2347
|
+
get icon() {
|
|
2348
|
+
const value = this.getAttribute("icon");
|
|
2349
|
+
if (value && value.slice(0, 1) === "{") {
|
|
2350
|
+
try {
|
|
2351
|
+
return JSON.parse(value);
|
|
2352
|
+
} catch (err) {
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
return value;
|
|
2356
|
+
}
|
|
2357
|
+
set icon(value) {
|
|
2358
|
+
if (typeof value === "object") {
|
|
2359
|
+
value = JSON.stringify(value);
|
|
2360
|
+
}
|
|
2361
|
+
this.setAttribute("icon", value);
|
|
2362
|
+
}
|
|
2363
|
+
/**
|
|
2364
|
+
* Get/set inline
|
|
2365
|
+
*/
|
|
2366
|
+
get inline() {
|
|
2367
|
+
return getInline(this);
|
|
2368
|
+
}
|
|
2369
|
+
set inline(value) {
|
|
2370
|
+
if (value) {
|
|
2371
|
+
this.setAttribute("inline", "true");
|
|
2372
|
+
} else {
|
|
2373
|
+
this.removeAttribute("inline");
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2376
|
+
/**
|
|
2377
|
+
* Restart animation
|
|
2378
|
+
*/
|
|
2379
|
+
restartAnimation() {
|
|
2380
|
+
const state = this._state;
|
|
2381
|
+
if (state.rendered) {
|
|
2382
|
+
const root = this._shadowRoot;
|
|
2383
|
+
if (state.renderedMode === "svg") {
|
|
2384
|
+
try {
|
|
2385
|
+
root.lastChild.setCurrentTime(0);
|
|
2386
|
+
return;
|
|
2387
|
+
} catch (err) {
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2390
|
+
renderIcon(root, state);
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
/**
|
|
2394
|
+
* Get status
|
|
2395
|
+
*/
|
|
2396
|
+
get status() {
|
|
2397
|
+
const state = this._state;
|
|
2398
|
+
return state.rendered ? "rendered" : state.icon.data === null ? "failed" : "loading";
|
|
2399
|
+
}
|
|
2400
|
+
/**
|
|
2401
|
+
* Queue attributes re-check
|
|
2402
|
+
*/
|
|
2403
|
+
_queueCheck() {
|
|
2404
|
+
if (!this._checkQueued) {
|
|
2405
|
+
this._checkQueued = true;
|
|
2406
|
+
setTimeout(() => {
|
|
2407
|
+
this._check();
|
|
2408
|
+
});
|
|
2409
|
+
}
|
|
2410
|
+
}
|
|
2411
|
+
/**
|
|
2412
|
+
* Check for changes
|
|
2413
|
+
*/
|
|
2414
|
+
_check() {
|
|
2415
|
+
if (!this._checkQueued) {
|
|
2416
|
+
return;
|
|
2417
|
+
}
|
|
2418
|
+
this._checkQueued = false;
|
|
2419
|
+
const state = this._state;
|
|
2420
|
+
const newIcon = this.getAttribute("icon");
|
|
2421
|
+
if (newIcon !== state.icon.value) {
|
|
2422
|
+
this._iconChanged(newIcon);
|
|
2423
|
+
return;
|
|
2424
|
+
}
|
|
2425
|
+
if (!state.rendered) {
|
|
2426
|
+
return;
|
|
2427
|
+
}
|
|
2428
|
+
const mode = this.getAttribute("mode");
|
|
2429
|
+
const customisations = getCustomisations(this);
|
|
2430
|
+
if (state.attrMode !== mode || haveCustomisationsChanged(state.customisations, customisations)) {
|
|
2431
|
+
this._renderIcon(state.icon, customisations, mode);
|
|
2432
|
+
}
|
|
2433
|
+
}
|
|
2434
|
+
/**
|
|
2435
|
+
* Icon value has changed
|
|
2436
|
+
*/
|
|
2437
|
+
_iconChanged(newValue) {
|
|
2438
|
+
const icon = parseIconValue(newValue, (value, name2, data) => {
|
|
2439
|
+
const state = this._state;
|
|
2440
|
+
if (state.rendered || this.getAttribute("icon") !== value) {
|
|
2441
|
+
return;
|
|
2442
|
+
}
|
|
2443
|
+
const icon2 = {
|
|
2444
|
+
value,
|
|
2445
|
+
name: name2,
|
|
2446
|
+
data
|
|
2447
|
+
};
|
|
2448
|
+
if (icon2.data) {
|
|
2449
|
+
this._gotIconData(icon2);
|
|
2450
|
+
} else {
|
|
2451
|
+
state.icon = icon2;
|
|
2452
|
+
}
|
|
2453
|
+
});
|
|
2454
|
+
if (icon.data) {
|
|
2455
|
+
this._gotIconData(icon);
|
|
2456
|
+
} else {
|
|
2457
|
+
this._state = setPendingState(icon, this._state.inline, this._state);
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2460
|
+
/**
|
|
2461
|
+
* Got new icon data, icon is ready to (re)render
|
|
2462
|
+
*/
|
|
2463
|
+
_gotIconData(icon) {
|
|
2464
|
+
this._checkQueued = false;
|
|
2465
|
+
this._renderIcon(icon, getCustomisations(this), this.getAttribute("mode"));
|
|
2466
|
+
}
|
|
2467
|
+
/**
|
|
2468
|
+
* Re-render based on icon data
|
|
2469
|
+
*/
|
|
2470
|
+
_renderIcon(icon, customisations, attrMode) {
|
|
2471
|
+
const renderedMode = getRenderMode(icon.data.body, attrMode);
|
|
2472
|
+
const inline = this._state.inline;
|
|
2473
|
+
renderIcon(this._shadowRoot, this._state = {
|
|
2474
|
+
rendered: true,
|
|
2475
|
+
icon,
|
|
2476
|
+
inline,
|
|
2477
|
+
customisations,
|
|
2478
|
+
attrMode,
|
|
2479
|
+
renderedMode
|
|
2480
|
+
});
|
|
2481
|
+
}
|
|
2482
|
+
};
|
|
2483
|
+
attributes.forEach((attr) => {
|
|
2484
|
+
if (!(attr in IconifyIcon.prototype)) {
|
|
2485
|
+
Object.defineProperty(IconifyIcon.prototype, attr, {
|
|
2486
|
+
get: function() {
|
|
2487
|
+
return this.getAttribute(attr);
|
|
2488
|
+
},
|
|
2489
|
+
set: function(value) {
|
|
2490
|
+
if (value !== null) {
|
|
2491
|
+
this.setAttribute(attr, value);
|
|
2492
|
+
} else {
|
|
2493
|
+
this.removeAttribute(attr);
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2496
|
+
});
|
|
2497
|
+
}
|
|
2498
|
+
});
|
|
2499
|
+
const functions = exportFunctions();
|
|
2500
|
+
for (const key in functions) {
|
|
2501
|
+
IconifyIcon[key] = IconifyIcon.prototype[key] = functions[key];
|
|
2502
|
+
}
|
|
2503
|
+
customElements.define(name, IconifyIcon);
|
|
2504
|
+
return IconifyIcon;
|
|
2505
|
+
}
|
|
2506
|
+
var IconifyIconComponent = defineIconifyIcon() || exportFunctions();
|
|
2507
|
+
var { enableCache, disableCache, iconExists, getIcon, listIcons, addIcon, addCollection, calculateSize, buildIcon, loadIcons, loadIcon, addAPIProvider, _api } = IconifyIconComponent;
|
|
2508
|
+
|
|
2509
|
+
// ../../node_modules/@iconify-icon/react/dist/iconify.mjs
|
|
2510
|
+
var Icon = import_react2.default.forwardRef(
|
|
2511
|
+
(props, ref) => {
|
|
2512
|
+
const newProps = {
|
|
274
2513
|
...props,
|
|
275
|
-
|
|
2514
|
+
ref
|
|
2515
|
+
};
|
|
2516
|
+
if (typeof props.icon === "object") {
|
|
2517
|
+
newProps.icon = JSON.stringify(props.icon);
|
|
276
2518
|
}
|
|
277
|
-
|
|
2519
|
+
if (!props.inline) {
|
|
2520
|
+
delete newProps.inline;
|
|
2521
|
+
}
|
|
2522
|
+
if (props.className) {
|
|
2523
|
+
newProps["class"] = props.className;
|
|
2524
|
+
}
|
|
2525
|
+
return import_react2.default.createElement("iconify-icon", newProps);
|
|
2526
|
+
}
|
|
2527
|
+
);
|
|
2528
|
+
|
|
2529
|
+
// src/components/Icon.tsx
|
|
2530
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
2531
|
+
var Icon2 = (props) => {
|
|
2532
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { ...props });
|
|
278
2533
|
};
|
|
279
2534
|
|
|
2535
|
+
// src/components/Button.tsx
|
|
2536
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
2537
|
+
var RenderIcon = ({ icon }) => {
|
|
2538
|
+
if (!icon) {
|
|
2539
|
+
return null;
|
|
2540
|
+
}
|
|
2541
|
+
if (typeof icon === "string") {
|
|
2542
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon2, { icon }) });
|
|
2543
|
+
}
|
|
2544
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: icon });
|
|
2545
|
+
};
|
|
2546
|
+
var MemoizedRenderIcon = React3.memo(RenderIcon);
|
|
2547
|
+
var Button = React3.forwardRef(
|
|
2548
|
+
(props, ref) => {
|
|
2549
|
+
const { children, leftIcon, rightIcon, ...restProps } = props;
|
|
2550
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2551
|
+
import_theme_ui4.Button,
|
|
2552
|
+
{
|
|
2553
|
+
ref,
|
|
2554
|
+
...restProps,
|
|
2555
|
+
sx: {
|
|
2556
|
+
cursor: "pointer",
|
|
2557
|
+
paddingX: "lg",
|
|
2558
|
+
paddingY: "md",
|
|
2559
|
+
display: "inline-flex",
|
|
2560
|
+
alignItems: "center",
|
|
2561
|
+
gap: "lg",
|
|
2562
|
+
...restProps.sx
|
|
2563
|
+
},
|
|
2564
|
+
children: [
|
|
2565
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(MemoizedRenderIcon, { icon: leftIcon }),
|
|
2566
|
+
children,
|
|
2567
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(MemoizedRenderIcon, { icon: rightIcon })
|
|
2568
|
+
]
|
|
2569
|
+
}
|
|
2570
|
+
);
|
|
2571
|
+
}
|
|
2572
|
+
);
|
|
2573
|
+
Button.displayName = "Button";
|
|
2574
|
+
|
|
280
2575
|
// src/components/Card.tsx
|
|
2576
|
+
init_tsup_inject();
|
|
281
2577
|
var import_theme_ui5 = require("theme-ui");
|
|
282
2578
|
|
|
283
2579
|
// src/components/Divider.tsx
|
|
2580
|
+
init_tsup_inject();
|
|
284
2581
|
var import_theme_ui6 = require("theme-ui");
|
|
285
2582
|
|
|
286
2583
|
// src/components/Flex.tsx
|
|
2584
|
+
init_tsup_inject();
|
|
287
2585
|
var import_theme_ui7 = require("theme-ui");
|
|
288
2586
|
|
|
289
2587
|
// src/components/Grid.tsx
|
|
2588
|
+
init_tsup_inject();
|
|
290
2589
|
var import_theme_ui8 = require("theme-ui");
|
|
291
2590
|
|
|
292
2591
|
// src/components/Heading.tsx
|
|
2592
|
+
init_tsup_inject();
|
|
293
2593
|
var import_theme_ui9 = require("theme-ui");
|
|
294
2594
|
|
|
295
2595
|
// src/components/Image.tsx
|
|
2596
|
+
init_tsup_inject();
|
|
296
2597
|
var import_theme_ui10 = require("theme-ui");
|
|
297
2598
|
|
|
298
2599
|
// src/components/Input.tsx
|
|
2600
|
+
init_tsup_inject();
|
|
299
2601
|
var import_theme_ui11 = require("theme-ui");
|
|
300
2602
|
|
|
301
2603
|
// src/components/Label.tsx
|
|
2604
|
+
init_tsup_inject();
|
|
302
2605
|
var import_theme_ui12 = require("theme-ui");
|
|
303
2606
|
|
|
304
2607
|
// src/components/Link.tsx
|
|
2608
|
+
init_tsup_inject();
|
|
305
2609
|
var import_theme_ui13 = require("theme-ui");
|
|
306
2610
|
|
|
307
2611
|
// src/components/LinearProgress.tsx
|
|
2612
|
+
init_tsup_inject();
|
|
308
2613
|
var import_theme_ui14 = require("theme-ui");
|
|
309
2614
|
|
|
310
2615
|
// src/components/Text.tsx
|
|
2616
|
+
init_tsup_inject();
|
|
311
2617
|
var import_theme_ui15 = require("theme-ui");
|
|
312
2618
|
|
|
313
2619
|
// src/components/Select.tsx
|
|
2620
|
+
init_tsup_inject();
|
|
314
2621
|
var import_theme_ui16 = require("theme-ui");
|
|
315
2622
|
|
|
316
2623
|
// src/components/Spinner.tsx
|
|
2624
|
+
init_tsup_inject();
|
|
317
2625
|
var import_theme_ui17 = require("theme-ui");
|
|
318
2626
|
|
|
319
2627
|
// src/components/Radio.tsx
|
|
2628
|
+
init_tsup_inject();
|
|
320
2629
|
var import_theme_ui18 = require("theme-ui");
|
|
321
2630
|
|
|
322
|
-
// src/components/Icon.tsx
|
|
323
|
-
var import_react2 = require("@iconify/react");
|
|
324
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
325
|
-
var Icon = ({ icon, sx, iconProps, ...props }) => {
|
|
326
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_theme_ui15.Text, { sx, ...props, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react2.Icon, { ...iconProps, icon }) });
|
|
327
|
-
};
|
|
328
|
-
|
|
329
2631
|
// src/components/Slider.tsx
|
|
2632
|
+
init_tsup_inject();
|
|
330
2633
|
var import_theme_ui19 = require("theme-ui");
|
|
331
2634
|
|
|
332
2635
|
// src/components/Checkbox.tsx
|
|
2636
|
+
init_tsup_inject();
|
|
333
2637
|
var import_theme_ui20 = require("theme-ui");
|
|
334
2638
|
|
|
335
2639
|
// src/components/InfiniteLinearProgress.tsx
|
|
336
|
-
|
|
2640
|
+
init_tsup_inject();
|
|
2641
|
+
var React4 = __toESM(require("react"));
|
|
337
2642
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
338
2643
|
var MAX_PROGRESS = 100;
|
|
339
2644
|
var InfiniteLinearProgress = () => {
|
|
340
|
-
const [progress, setProgress] =
|
|
341
|
-
|
|
2645
|
+
const [progress, setProgress] = React4.useState(0);
|
|
2646
|
+
React4.useEffect(() => {
|
|
342
2647
|
const timer = setInterval(() => {
|
|
343
2648
|
setProgress((oldProgress) => {
|
|
344
2649
|
if (oldProgress === MAX_PROGRESS) {
|
|
@@ -363,12 +2668,15 @@ var InfiniteLinearProgress = () => {
|
|
|
363
2668
|
};
|
|
364
2669
|
|
|
365
2670
|
// src/components/Textarea.tsx
|
|
2671
|
+
init_tsup_inject();
|
|
366
2672
|
var import_theme_ui21 = require("theme-ui");
|
|
367
2673
|
|
|
368
2674
|
// src/components/Container.tsx
|
|
2675
|
+
init_tsup_inject();
|
|
369
2676
|
var import_theme_ui22 = require("theme-ui");
|
|
370
2677
|
// Annotate the CommonJS export names for ESM import in node:
|
|
371
2678
|
0 && (module.exports = {
|
|
2679
|
+
BaseStyles,
|
|
372
2680
|
Box,
|
|
373
2681
|
Button,
|
|
374
2682
|
Card,
|
|
@@ -396,3 +2704,18 @@ var import_theme_ui22 = require("theme-ui");
|
|
|
396
2704
|
useResponsiveValue,
|
|
397
2705
|
useTheme
|
|
398
2706
|
});
|
|
2707
|
+
/*! Bundled license information:
|
|
2708
|
+
|
|
2709
|
+
iconify-icon/dist/iconify-icon.mjs:
|
|
2710
|
+
(**
|
|
2711
|
+
* (c) Iconify
|
|
2712
|
+
*
|
|
2713
|
+
* For the full copyright and license information, please view the license.txt
|
|
2714
|
+
* files at https://github.com/iconify/iconify
|
|
2715
|
+
*
|
|
2716
|
+
* Licensed under MIT.
|
|
2717
|
+
*
|
|
2718
|
+
* @license MIT
|
|
2719
|
+
* @version 1.0.5
|
|
2720
|
+
*)
|
|
2721
|
+
*/
|