@ttoss/components 2.0.1 → 2.0.3

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