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