@ttoss/ui 1.30.12 → 1.31.0

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