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