@ttoss/forms 0.22.1 → 0.22.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/README.md +111 -1
- package/dist/MultistepForm/index.d.mts +64 -0
- package/dist/MultistepForm/index.d.ts +64 -0
- package/dist/MultistepForm/index.js +3050 -0
- package/dist/esm/MultistepForm/index.js +2365 -0
- package/dist/esm/chunk-NDUNPJBB.js +638 -0
- package/dist/esm/index.js +2 -632
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +11 -4
- package/package.json +18 -8
- package/src/ErrorMessage.tsx +6 -3
- package/src/MultistepForm/MultistepFlowMessage.tsx +14 -0
- package/src/MultistepForm/MultistepFlowMessageImageText.tsx +37 -0
- package/src/MultistepForm/MultistepFooter.tsx +18 -0
- package/src/MultistepForm/MultistepForm.tsx +117 -0
- package/src/MultistepForm/MultistepFormStepper.tsx +70 -0
- package/src/MultistepForm/MultistepHeader.tsx +78 -0
- package/src/MultistepForm/MultistepNavigation.tsx +38 -0
- package/src/MultistepForm/MultistepQuestion.tsx +28 -0
- package/src/MultistepForm/index.ts +1 -0
- package/src/MultistepForm/types.ts +7 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,3050 @@
|
|
|
1
|
+
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __export = (target, all) => {
|
|
11
|
+
for (var name in all) __defProp(target, name, {
|
|
12
|
+
get: all[name],
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
19
|
+
get: () => from[key],
|
|
20
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
26
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
27
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
28
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
29
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
30
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
31
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
32
|
+
value: mod,
|
|
33
|
+
enumerable: true
|
|
34
|
+
}) : target, mod));
|
|
35
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
36
|
+
value: true
|
|
37
|
+
}), mod);
|
|
38
|
+
|
|
39
|
+
// src/MultistepForm/index.ts
|
|
40
|
+
var MultistepForm_exports = {};
|
|
41
|
+
__export(MultistepForm_exports, {
|
|
42
|
+
MultistepForm: () => MultistepForm
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(MultistepForm_exports);
|
|
45
|
+
|
|
46
|
+
// src/MultistepForm/MultistepForm.tsx
|
|
47
|
+
var React5 = __toESM(require("react"));
|
|
48
|
+
var import_ui19 = require("@ttoss/ui");
|
|
49
|
+
|
|
50
|
+
// src/MultistepForm/MultistepFooter.tsx
|
|
51
|
+
var import_ui = require("@ttoss/ui");
|
|
52
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
53
|
+
var MultistepFooter = ({
|
|
54
|
+
footer
|
|
55
|
+
}) => {
|
|
56
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_ui.Flex, {
|
|
57
|
+
sx: {
|
|
58
|
+
display: "flex",
|
|
59
|
+
justifyContent: "center"
|
|
60
|
+
},
|
|
61
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_ui.Text, {
|
|
62
|
+
sx: {
|
|
63
|
+
textAlign: "center",
|
|
64
|
+
marginTop: "4xl",
|
|
65
|
+
marginBottom: "lg",
|
|
66
|
+
marginX: "2xl"
|
|
67
|
+
},
|
|
68
|
+
children: footer
|
|
69
|
+
})
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// src/MultistepForm/MultistepFormStepper.tsx
|
|
74
|
+
var import_ui16 = require("@ttoss/ui");
|
|
75
|
+
|
|
76
|
+
// src/index.ts
|
|
77
|
+
var src_exports = {};
|
|
78
|
+
__export(src_exports, {
|
|
79
|
+
Form: () => Form,
|
|
80
|
+
FormField: () => FormField,
|
|
81
|
+
FormFieldCheckbox: () => FormFieldCheckbox,
|
|
82
|
+
FormFieldCreditCardNumber: () => FormFieldCreditCardNumber,
|
|
83
|
+
FormFieldCurrencyInput: () => FormFieldCurrencyInput,
|
|
84
|
+
FormFieldInput: () => FormFieldInput,
|
|
85
|
+
FormFieldNumericFormat: () => FormFieldNumericFormat,
|
|
86
|
+
FormFieldPassword: () => FormFieldPassword,
|
|
87
|
+
FormFieldPatternFormat: () => FormFieldPatternFormat,
|
|
88
|
+
FormFieldRadio: () => FormFieldRadio,
|
|
89
|
+
FormFieldSelect: () => FormFieldSelect,
|
|
90
|
+
FormFieldTextarea: () => FormFieldTextarea,
|
|
91
|
+
FormGroup: () => FormGroup,
|
|
92
|
+
useForm: () => import_react_hook_form6.useForm,
|
|
93
|
+
useFormGroup: () => useFormGroup,
|
|
94
|
+
yup: () => yup,
|
|
95
|
+
yupResolver: () => import_yup2.yupResolver
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// src/i18n.ts
|
|
99
|
+
var import_react_i18n = require("@ttoss/react-i18n");
|
|
100
|
+
var import_yup = require("yup");
|
|
101
|
+
(0, import_yup.setLocale)({
|
|
102
|
+
mixed: {
|
|
103
|
+
required: (0, import_react_i18n.defineMessage)({
|
|
104
|
+
defaultMessage: "Field is required",
|
|
105
|
+
description: "Field is required"
|
|
106
|
+
}),
|
|
107
|
+
notType: ({
|
|
108
|
+
type
|
|
109
|
+
}) => {
|
|
110
|
+
return {
|
|
111
|
+
...(0, import_react_i18n.defineMessage)({
|
|
112
|
+
defaultMessage: "Invalid Value for Field of type {type}",
|
|
113
|
+
description: "Invalid Value"
|
|
114
|
+
}),
|
|
115
|
+
values: {
|
|
116
|
+
type
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
string: {
|
|
122
|
+
min: ({
|
|
123
|
+
min
|
|
124
|
+
}) => {
|
|
125
|
+
return {
|
|
126
|
+
...(0, import_react_i18n.defineMessage)({
|
|
127
|
+
defaultMessage: "Field must be at least {min} characters",
|
|
128
|
+
description: "Min length field"
|
|
129
|
+
}),
|
|
130
|
+
values: {
|
|
131
|
+
min
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// src/index.ts
|
|
139
|
+
var import_yup2 = require("@hookform/resolvers/yup");
|
|
140
|
+
__reExport(src_exports, require("react-hook-form"));
|
|
141
|
+
var import_react_hook_form6 = require("react-hook-form");
|
|
142
|
+
var yup = __toESM(require("yup"));
|
|
143
|
+
|
|
144
|
+
// src/Form.tsx
|
|
145
|
+
var import_ui2 = require("@ttoss/ui");
|
|
146
|
+
var import_react_hook_form = require("react-hook-form");
|
|
147
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
148
|
+
var Form = ({
|
|
149
|
+
children,
|
|
150
|
+
onSubmit,
|
|
151
|
+
sx,
|
|
152
|
+
...formMethods
|
|
153
|
+
}) => {
|
|
154
|
+
return /* @__PURE__ */(0, import_jsx_runtime2.jsx)(import_react_hook_form.FormProvider, {
|
|
155
|
+
...formMethods,
|
|
156
|
+
children: /* @__PURE__ */(0, import_jsx_runtime2.jsx)(import_ui2.Box, {
|
|
157
|
+
as: "form",
|
|
158
|
+
variant: "forms.form",
|
|
159
|
+
onSubmit: formMethods.handleSubmit(data => {
|
|
160
|
+
return onSubmit?.(data);
|
|
161
|
+
}),
|
|
162
|
+
sx,
|
|
163
|
+
children
|
|
164
|
+
})
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
// src/FormField.tsx
|
|
169
|
+
var React = __toESM(require("react"));
|
|
170
|
+
|
|
171
|
+
// src/ErrorMessage.tsx
|
|
172
|
+
var import_react_hook_form2 = require("react-hook-form");
|
|
173
|
+
var import_react_i18n2 = require("@ttoss/react-i18n");
|
|
174
|
+
var import_ui3 = require("@ttoss/ui");
|
|
175
|
+
var import_error_message = require("@hookform/error-message");
|
|
176
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
177
|
+
var isMessageDescriptor = possibleMessageDescriptor => {
|
|
178
|
+
return possibleMessageDescriptor !== void 0 && possibleMessageDescriptor.defaultMessage !== void 0;
|
|
179
|
+
};
|
|
180
|
+
var ErrorMessage = ({
|
|
181
|
+
name,
|
|
182
|
+
disabled
|
|
183
|
+
}) => {
|
|
184
|
+
const {
|
|
185
|
+
formState: {
|
|
186
|
+
errors
|
|
187
|
+
}
|
|
188
|
+
} = (0, import_react_hook_form2.useFormContext)();
|
|
189
|
+
return /* @__PURE__ */(0, import_jsx_runtime3.jsx)(import_error_message.ErrorMessage, {
|
|
190
|
+
name,
|
|
191
|
+
errors,
|
|
192
|
+
render: ({
|
|
193
|
+
message
|
|
194
|
+
}) => {
|
|
195
|
+
return /* @__PURE__ */(0, import_jsx_runtime3.jsx)(import_ui3.HelpText, {
|
|
196
|
+
negative: true,
|
|
197
|
+
disabled,
|
|
198
|
+
children: (() => {
|
|
199
|
+
if (typeof message === "string") {
|
|
200
|
+
return message;
|
|
201
|
+
}
|
|
202
|
+
if (isMessageDescriptor(message)) {
|
|
203
|
+
return /* @__PURE__ */(0, import_jsx_runtime3.jsx)(import_react_i18n2.FormattedMessage, {
|
|
204
|
+
...message
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
return JSON.stringify(message);
|
|
208
|
+
})()
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
// src/FormField.tsx
|
|
215
|
+
var import_react_hook_form3 = require("react-hook-form");
|
|
216
|
+
var import_ui4 = require("@ttoss/ui");
|
|
217
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
218
|
+
var FormField = ({
|
|
219
|
+
label,
|
|
220
|
+
id: idProp,
|
|
221
|
+
name,
|
|
222
|
+
defaultValue,
|
|
223
|
+
disabled,
|
|
224
|
+
tooltip,
|
|
225
|
+
onTooltipClick,
|
|
226
|
+
sx,
|
|
227
|
+
css,
|
|
228
|
+
render
|
|
229
|
+
}) => {
|
|
230
|
+
const controllerReturn = (0, import_react_hook_form3.useController)({
|
|
231
|
+
name,
|
|
232
|
+
defaultValue
|
|
233
|
+
});
|
|
234
|
+
const id = idProp || `form-field-${name}`;
|
|
235
|
+
const memoizedRender = React.useMemo(() => {
|
|
236
|
+
return React.Children.map(render(controllerReturn), child => {
|
|
237
|
+
return /* @__PURE__ */(0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, {
|
|
238
|
+
children: [label && /* @__PURE__ */(0, import_jsx_runtime4.jsx)(import_ui4.Label, {
|
|
239
|
+
"aria-disabled": disabled,
|
|
240
|
+
htmlFor: id,
|
|
241
|
+
tooltip,
|
|
242
|
+
onTooltipClick,
|
|
243
|
+
children: label
|
|
244
|
+
}), React.createElement(child.type, {
|
|
245
|
+
id,
|
|
246
|
+
...child.props
|
|
247
|
+
})]
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
}, [controllerReturn, disabled, onTooltipClick, tooltip, id, label, render]);
|
|
251
|
+
return /* @__PURE__ */(0, import_jsx_runtime4.jsxs)(import_ui4.Flex, {
|
|
252
|
+
sx: {
|
|
253
|
+
flexDirection: "column",
|
|
254
|
+
width: "100%",
|
|
255
|
+
gap: "md",
|
|
256
|
+
...sx
|
|
257
|
+
},
|
|
258
|
+
css,
|
|
259
|
+
children: [memoizedRender, /* @__PURE__ */(0, import_jsx_runtime4.jsx)(ErrorMessage, {
|
|
260
|
+
name
|
|
261
|
+
})]
|
|
262
|
+
});
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
// src/FormFieldCheckbox.tsx
|
|
266
|
+
var import_ui5 = require("@ttoss/ui");
|
|
267
|
+
var import_react_hook_form4 = require("react-hook-form");
|
|
268
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
269
|
+
var FormFieldCheckbox = ({
|
|
270
|
+
label,
|
|
271
|
+
name,
|
|
272
|
+
sx,
|
|
273
|
+
...checkboxProps
|
|
274
|
+
}) => {
|
|
275
|
+
const {
|
|
276
|
+
field: {
|
|
277
|
+
onChange,
|
|
278
|
+
onBlur,
|
|
279
|
+
value,
|
|
280
|
+
ref
|
|
281
|
+
},
|
|
282
|
+
formState: {
|
|
283
|
+
errors
|
|
284
|
+
}
|
|
285
|
+
} = (0, import_react_hook_form4.useController)({
|
|
286
|
+
name,
|
|
287
|
+
defaultValue: false
|
|
288
|
+
});
|
|
289
|
+
const id = `form-field-checkbox-${name}`;
|
|
290
|
+
const error = !!errors[name]?.message;
|
|
291
|
+
return /* @__PURE__ */(0, import_jsx_runtime5.jsxs)(import_ui5.Flex, {
|
|
292
|
+
sx: {
|
|
293
|
+
flexDirection: "column",
|
|
294
|
+
width: "100%",
|
|
295
|
+
...sx
|
|
296
|
+
},
|
|
297
|
+
children: [/* @__PURE__ */(0, import_jsx_runtime5.jsx)(import_ui5.Flex, {
|
|
298
|
+
sx: {
|
|
299
|
+
alignItems: "center"
|
|
300
|
+
},
|
|
301
|
+
children: /* @__PURE__ */(0, import_jsx_runtime5.jsxs)(import_ui5.Label, {
|
|
302
|
+
"aria-disabled": checkboxProps.disabled,
|
|
303
|
+
htmlFor: id,
|
|
304
|
+
children: [/* @__PURE__ */(0, import_jsx_runtime5.jsx)(import_ui5.Checkbox, {
|
|
305
|
+
id,
|
|
306
|
+
ref,
|
|
307
|
+
checked: value,
|
|
308
|
+
onChange,
|
|
309
|
+
onBlur,
|
|
310
|
+
name,
|
|
311
|
+
"aria-invalid": error ? "true" : "false",
|
|
312
|
+
...checkboxProps
|
|
313
|
+
}), label]
|
|
314
|
+
})
|
|
315
|
+
}), /* @__PURE__ */(0, import_jsx_runtime5.jsx)(ErrorMessage, {
|
|
316
|
+
name
|
|
317
|
+
})]
|
|
318
|
+
});
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
// src/FormFieldPatternFormat.tsx
|
|
322
|
+
var import_ui6 = require("@ttoss/ui");
|
|
323
|
+
var import_react_number_format = require("react-number-format");
|
|
324
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
325
|
+
var FormFieldPatternFormat = ({
|
|
326
|
+
label,
|
|
327
|
+
name,
|
|
328
|
+
...patternFormatProps
|
|
329
|
+
}) => {
|
|
330
|
+
return /* @__PURE__ */(0, import_jsx_runtime6.jsx)(FormField, {
|
|
331
|
+
name,
|
|
332
|
+
label,
|
|
333
|
+
render: ({
|
|
334
|
+
field,
|
|
335
|
+
fieldState
|
|
336
|
+
}) => {
|
|
337
|
+
return /* @__PURE__ */(0, import_jsx_runtime6.jsx)(import_react_number_format.PatternFormat, {
|
|
338
|
+
name: field.name,
|
|
339
|
+
value: field.value,
|
|
340
|
+
onBlur: field.onBlur,
|
|
341
|
+
onValueChange: values => {
|
|
342
|
+
field.onChange(values.value);
|
|
343
|
+
},
|
|
344
|
+
customInput: import_ui6.Input,
|
|
345
|
+
"aria-invalid": Boolean(fieldState.error).valueOf(),
|
|
346
|
+
...patternFormatProps
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
// src/FormFieldCreditCardNumber.tsx
|
|
353
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
354
|
+
var FormFieldCreditCardNumber = ({
|
|
355
|
+
label,
|
|
356
|
+
name,
|
|
357
|
+
...formFieldPatternFormatProps
|
|
358
|
+
}) => {
|
|
359
|
+
return /* @__PURE__ */(0, import_jsx_runtime7.jsx)(FormFieldPatternFormat, {
|
|
360
|
+
name,
|
|
361
|
+
label,
|
|
362
|
+
format: "#### #### #### ####",
|
|
363
|
+
placeholder: "1234 1234 1234 1234",
|
|
364
|
+
...formFieldPatternFormatProps
|
|
365
|
+
});
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
// src/FormFieldNumericFormat.tsx
|
|
369
|
+
var import_ui7 = require("@ttoss/ui");
|
|
370
|
+
var import_react_number_format2 = require("react-number-format");
|
|
371
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
372
|
+
var FormFieldNumericFormat = ({
|
|
373
|
+
label,
|
|
374
|
+
name,
|
|
375
|
+
...numericFormatProps
|
|
376
|
+
}) => {
|
|
377
|
+
return /* @__PURE__ */(0, import_jsx_runtime8.jsx)(FormField, {
|
|
378
|
+
label,
|
|
379
|
+
name,
|
|
380
|
+
render: ({
|
|
381
|
+
field
|
|
382
|
+
}) => {
|
|
383
|
+
return /* @__PURE__ */(0, import_jsx_runtime8.jsx)(import_react_number_format2.NumericFormat, {
|
|
384
|
+
name: field.name,
|
|
385
|
+
value: field.value,
|
|
386
|
+
onBlur: field.onBlur,
|
|
387
|
+
onValueChange: values => {
|
|
388
|
+
field.onChange(values.floatValue);
|
|
389
|
+
},
|
|
390
|
+
customInput: import_ui7.Input,
|
|
391
|
+
...numericFormatProps
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
// src/FormFieldCurrencyInput.tsx
|
|
398
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
399
|
+
var FormFieldCurrencyInput = ({
|
|
400
|
+
label,
|
|
401
|
+
name,
|
|
402
|
+
prefix,
|
|
403
|
+
decimalSeparator,
|
|
404
|
+
thousandSeparator,
|
|
405
|
+
...formFieldNumericFormatProps
|
|
406
|
+
}) => {
|
|
407
|
+
return /* @__PURE__ */(0, import_jsx_runtime9.jsx)(FormFieldNumericFormat, {
|
|
408
|
+
name,
|
|
409
|
+
label,
|
|
410
|
+
fixedDecimalScale: true,
|
|
411
|
+
decimalScale: 2,
|
|
412
|
+
prefix,
|
|
413
|
+
decimalSeparator,
|
|
414
|
+
thousandSeparator,
|
|
415
|
+
placeholder: `${prefix} 0${decimalSeparator}00`,
|
|
416
|
+
allowNegative: false,
|
|
417
|
+
...formFieldNumericFormatProps
|
|
418
|
+
});
|
|
419
|
+
};
|
|
420
|
+
|
|
421
|
+
// src/FormFieldInput.tsx
|
|
422
|
+
var import_ui8 = require("@ttoss/ui");
|
|
423
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
424
|
+
var FormFieldInput = ({
|
|
425
|
+
label,
|
|
426
|
+
name,
|
|
427
|
+
tooltip,
|
|
428
|
+
onTooltipClick,
|
|
429
|
+
sx,
|
|
430
|
+
defaultValue = "",
|
|
431
|
+
...inputProps
|
|
432
|
+
}) => {
|
|
433
|
+
return /* @__PURE__ */(0, import_jsx_runtime10.jsx)(FormField, {
|
|
434
|
+
name,
|
|
435
|
+
label,
|
|
436
|
+
disabled: inputProps.disabled,
|
|
437
|
+
tooltip,
|
|
438
|
+
onTooltipClick,
|
|
439
|
+
sx,
|
|
440
|
+
defaultValue,
|
|
441
|
+
render: ({
|
|
442
|
+
field,
|
|
443
|
+
fieldState
|
|
444
|
+
}) => {
|
|
445
|
+
return /* @__PURE__ */(0, import_jsx_runtime10.jsx)(import_ui8.Input, {
|
|
446
|
+
...inputProps,
|
|
447
|
+
...field,
|
|
448
|
+
"aria-invalid": fieldState.error ? "true" : void 0
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
// src/FormFieldPassword.tsx
|
|
455
|
+
var import_ui9 = require("@ttoss/ui");
|
|
456
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
457
|
+
var FormFieldPassword = ({
|
|
458
|
+
label,
|
|
459
|
+
name,
|
|
460
|
+
tooltip,
|
|
461
|
+
onTooltipClick,
|
|
462
|
+
sx,
|
|
463
|
+
defaultValue = "",
|
|
464
|
+
...inputProps
|
|
465
|
+
}) => {
|
|
466
|
+
return /* @__PURE__ */(0, import_jsx_runtime11.jsx)(FormField, {
|
|
467
|
+
name,
|
|
468
|
+
label,
|
|
469
|
+
disabled: inputProps.disabled,
|
|
470
|
+
tooltip,
|
|
471
|
+
onTooltipClick,
|
|
472
|
+
sx,
|
|
473
|
+
defaultValue,
|
|
474
|
+
render: ({
|
|
475
|
+
field,
|
|
476
|
+
fieldState
|
|
477
|
+
}) => {
|
|
478
|
+
return /* @__PURE__ */(0, import_jsx_runtime11.jsx)(import_ui9.InputPassword, {
|
|
479
|
+
...inputProps,
|
|
480
|
+
...field,
|
|
481
|
+
"aria-invalid": fieldState.error ? "true" : void 0
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
// src/FormFieldRadio.tsx
|
|
488
|
+
var import_ui10 = require("@ttoss/ui");
|
|
489
|
+
var import_react_hook_form5 = require("react-hook-form");
|
|
490
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
491
|
+
var FormFieldRadio = ({
|
|
492
|
+
label,
|
|
493
|
+
name,
|
|
494
|
+
options,
|
|
495
|
+
sx,
|
|
496
|
+
...radioProps
|
|
497
|
+
}) => {
|
|
498
|
+
const {
|
|
499
|
+
field: {
|
|
500
|
+
onChange,
|
|
501
|
+
onBlur,
|
|
502
|
+
value,
|
|
503
|
+
ref
|
|
504
|
+
}
|
|
505
|
+
} = (0, import_react_hook_form5.useController)({
|
|
506
|
+
name,
|
|
507
|
+
defaultValue: ""
|
|
508
|
+
});
|
|
509
|
+
return /* @__PURE__ */(0, import_jsx_runtime12.jsxs)(import_ui10.Flex, {
|
|
510
|
+
sx: {
|
|
511
|
+
flexDirection: "column",
|
|
512
|
+
width: "100%",
|
|
513
|
+
...sx
|
|
514
|
+
},
|
|
515
|
+
children: [label && /* @__PURE__ */(0, import_jsx_runtime12.jsx)(import_ui10.Label, {
|
|
516
|
+
sx: {
|
|
517
|
+
marginBottom: "md"
|
|
518
|
+
},
|
|
519
|
+
children: label
|
|
520
|
+
}), /* @__PURE__ */(0, import_jsx_runtime12.jsx)(import_ui10.Box, {
|
|
521
|
+
children: options.map(option => {
|
|
522
|
+
const id = `form-field-radio-${name}-${option.value}`;
|
|
523
|
+
return /* @__PURE__ */(0, import_jsx_runtime12.jsxs)(import_ui10.Label, {
|
|
524
|
+
htmlFor: id,
|
|
525
|
+
children: [/* @__PURE__ */(0, import_jsx_runtime12.jsx)(import_ui10.Radio, {
|
|
526
|
+
ref,
|
|
527
|
+
onChange,
|
|
528
|
+
onBlur,
|
|
529
|
+
value: option.value,
|
|
530
|
+
checked: value === option.value,
|
|
531
|
+
name,
|
|
532
|
+
id,
|
|
533
|
+
...radioProps
|
|
534
|
+
}), option.label]
|
|
535
|
+
}, id);
|
|
536
|
+
})
|
|
537
|
+
}), /* @__PURE__ */(0, import_jsx_runtime12.jsx)(ErrorMessage, {
|
|
538
|
+
name
|
|
539
|
+
})]
|
|
540
|
+
});
|
|
541
|
+
};
|
|
542
|
+
|
|
543
|
+
// src/FormFieldSelect.tsx
|
|
544
|
+
var import_ui11 = require("@ttoss/ui");
|
|
545
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
546
|
+
var FormFieldSelect = ({
|
|
547
|
+
label,
|
|
548
|
+
name,
|
|
549
|
+
id,
|
|
550
|
+
defaultValue,
|
|
551
|
+
sx,
|
|
552
|
+
css,
|
|
553
|
+
disabled,
|
|
554
|
+
tooltip,
|
|
555
|
+
onTooltipClick,
|
|
556
|
+
...selectProps
|
|
557
|
+
}) => {
|
|
558
|
+
return /* @__PURE__ */(0, import_jsx_runtime13.jsx)(FormField, {
|
|
559
|
+
name,
|
|
560
|
+
label,
|
|
561
|
+
id,
|
|
562
|
+
defaultValue,
|
|
563
|
+
disabled,
|
|
564
|
+
tooltip,
|
|
565
|
+
onTooltipClick,
|
|
566
|
+
sx,
|
|
567
|
+
css,
|
|
568
|
+
render: ({
|
|
569
|
+
field,
|
|
570
|
+
fieldState
|
|
571
|
+
}) => {
|
|
572
|
+
return /* @__PURE__ */(0, import_jsx_runtime13.jsx)(import_ui11.Select, {
|
|
573
|
+
...selectProps,
|
|
574
|
+
...field,
|
|
575
|
+
isDisabled: disabled,
|
|
576
|
+
"aria-invalid": fieldState.error ? "true" : void 0
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
});
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
// src/FormFieldTextarea.tsx
|
|
583
|
+
var import_ui12 = require("@ttoss/ui");
|
|
584
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
585
|
+
var FormFieldTextarea = ({
|
|
586
|
+
label,
|
|
587
|
+
name,
|
|
588
|
+
sx,
|
|
589
|
+
...textareaProps
|
|
590
|
+
}) => {
|
|
591
|
+
const id = `form-field-textarea-${name}`;
|
|
592
|
+
return /* @__PURE__ */(0, import_jsx_runtime14.jsx)(FormField, {
|
|
593
|
+
label,
|
|
594
|
+
name,
|
|
595
|
+
id,
|
|
596
|
+
sx,
|
|
597
|
+
render: ({
|
|
598
|
+
field,
|
|
599
|
+
fieldState
|
|
600
|
+
}) => {
|
|
601
|
+
return /* @__PURE__ */(0, import_jsx_runtime14.jsx)(import_ui12.Textarea, {
|
|
602
|
+
...field,
|
|
603
|
+
...textareaProps,
|
|
604
|
+
"aria-invalid": fieldState.error ? "true" : void 0
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
});
|
|
608
|
+
};
|
|
609
|
+
|
|
610
|
+
// src/FormGroup.tsx
|
|
611
|
+
var React2 = __toESM(require("react"));
|
|
612
|
+
var import_ui13 = require("@ttoss/ui");
|
|
613
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
614
|
+
var FormGroupLevelsManagerContext = React2.createContext({
|
|
615
|
+
levelsLength: 1,
|
|
616
|
+
registerChild: () => {
|
|
617
|
+
return null;
|
|
618
|
+
}
|
|
619
|
+
});
|
|
620
|
+
var FormGroupLevelsManager = ({
|
|
621
|
+
children
|
|
622
|
+
}) => {
|
|
623
|
+
const [levelsLength, setLevelsLength] = React2.useState(0);
|
|
624
|
+
const registerChild = React2.useCallback(level => {
|
|
625
|
+
if (level + 1 > levelsLength) {
|
|
626
|
+
setLevelsLength(level + 1);
|
|
627
|
+
}
|
|
628
|
+
}, [levelsLength]);
|
|
629
|
+
return /* @__PURE__ */(0, import_jsx_runtime15.jsx)(FormGroupLevelsManagerContext.Provider, {
|
|
630
|
+
value: {
|
|
631
|
+
levelsLength,
|
|
632
|
+
registerChild
|
|
633
|
+
},
|
|
634
|
+
children
|
|
635
|
+
});
|
|
636
|
+
};
|
|
637
|
+
var FormGroupContext = React2.createContext({});
|
|
638
|
+
var useFormGroup = () => {
|
|
639
|
+
const {
|
|
640
|
+
parentLevel
|
|
641
|
+
} = React2.useContext(FormGroupContext);
|
|
642
|
+
const {
|
|
643
|
+
levelsLength
|
|
644
|
+
} = React2.useContext(FormGroupLevelsManagerContext);
|
|
645
|
+
return {
|
|
646
|
+
level: parentLevel,
|
|
647
|
+
levelsLength
|
|
648
|
+
};
|
|
649
|
+
};
|
|
650
|
+
var FormGroupWrapper = ({
|
|
651
|
+
title,
|
|
652
|
+
direction,
|
|
653
|
+
children,
|
|
654
|
+
...boxProps
|
|
655
|
+
}) => {
|
|
656
|
+
const {
|
|
657
|
+
level
|
|
658
|
+
} = useFormGroup();
|
|
659
|
+
const {
|
|
660
|
+
registerChild
|
|
661
|
+
} = React2.useContext(FormGroupLevelsManagerContext);
|
|
662
|
+
React2.useEffect(() => {
|
|
663
|
+
if (typeof level === "number") {
|
|
664
|
+
registerChild(level);
|
|
665
|
+
}
|
|
666
|
+
}, [level, registerChild]);
|
|
667
|
+
const childrenContainerSx = {
|
|
668
|
+
flexDirection: direction || "column",
|
|
669
|
+
gap: "md",
|
|
670
|
+
width: "100%"
|
|
671
|
+
};
|
|
672
|
+
return /* @__PURE__ */(0, import_jsx_runtime15.jsxs)(import_ui13.Box, {
|
|
673
|
+
"aria-level": level,
|
|
674
|
+
...boxProps,
|
|
675
|
+
sx: {
|
|
676
|
+
marginTop: level === 0 ? "none" : "lg",
|
|
677
|
+
marginBottom: "lg",
|
|
678
|
+
...boxProps.sx
|
|
679
|
+
},
|
|
680
|
+
children: [title && /* @__PURE__ */(0, import_jsx_runtime15.jsx)(import_ui13.Box, {
|
|
681
|
+
sx: {
|
|
682
|
+
marginBottom: "md"
|
|
683
|
+
},
|
|
684
|
+
children: /* @__PURE__ */(0, import_jsx_runtime15.jsx)(import_ui13.Text, {
|
|
685
|
+
sx: {
|
|
686
|
+
fontSize: "2xl",
|
|
687
|
+
fontWeight: "bold"
|
|
688
|
+
},
|
|
689
|
+
children: title
|
|
690
|
+
})
|
|
691
|
+
}), /* @__PURE__ */(0, import_jsx_runtime15.jsx)(import_ui13.Flex, {
|
|
692
|
+
sx: childrenContainerSx,
|
|
693
|
+
children
|
|
694
|
+
})]
|
|
695
|
+
});
|
|
696
|
+
};
|
|
697
|
+
var FormGroup = props => {
|
|
698
|
+
const {
|
|
699
|
+
level
|
|
700
|
+
} = useFormGroup();
|
|
701
|
+
const currentLevel = level === void 0 ? 0 : level + 1;
|
|
702
|
+
return /* @__PURE__ */(0, import_jsx_runtime15.jsx)(FormGroupContext.Provider, {
|
|
703
|
+
value: {
|
|
704
|
+
parentLevel: currentLevel
|
|
705
|
+
},
|
|
706
|
+
children: currentLevel === 0 ? /* @__PURE__ */(0, import_jsx_runtime15.jsx)(FormGroupLevelsManager, {
|
|
707
|
+
children: /* @__PURE__ */(0, import_jsx_runtime15.jsx)(FormGroupWrapper, {
|
|
708
|
+
...props
|
|
709
|
+
})
|
|
710
|
+
}) : /* @__PURE__ */(0, import_jsx_runtime15.jsx)(FormGroupWrapper, {
|
|
711
|
+
...props
|
|
712
|
+
})
|
|
713
|
+
});
|
|
714
|
+
};
|
|
715
|
+
|
|
716
|
+
// src/MultistepForm/MultistepFlowMessageImageText.tsx
|
|
717
|
+
var import_ui14 = require("@ttoss/ui");
|
|
718
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
719
|
+
var MultistepFlowMessageImageText = ({
|
|
720
|
+
src,
|
|
721
|
+
description
|
|
722
|
+
}) => {
|
|
723
|
+
return /* @__PURE__ */(0, import_jsx_runtime16.jsxs)(import_ui14.Flex, {
|
|
724
|
+
sx: {
|
|
725
|
+
flexDirection: "column",
|
|
726
|
+
paddingY: "xl",
|
|
727
|
+
paddingX: "2xl",
|
|
728
|
+
gap: "xl"
|
|
729
|
+
},
|
|
730
|
+
children: [/* @__PURE__ */(0, import_jsx_runtime16.jsx)(import_ui14.Image, {
|
|
731
|
+
src,
|
|
732
|
+
sx: {
|
|
733
|
+
width: "184px",
|
|
734
|
+
height: "184px",
|
|
735
|
+
objectFit: "cover",
|
|
736
|
+
alignSelf: "center"
|
|
737
|
+
}
|
|
738
|
+
}), /* @__PURE__ */(0, import_jsx_runtime16.jsx)(import_ui14.Text, {
|
|
739
|
+
sx: {
|
|
740
|
+
textAlign: "center"
|
|
741
|
+
},
|
|
742
|
+
children: description
|
|
743
|
+
})]
|
|
744
|
+
});
|
|
745
|
+
};
|
|
746
|
+
|
|
747
|
+
// src/MultistepForm/MultistepFlowMessage.tsx
|
|
748
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
749
|
+
var MultistepFlowMessage = props => {
|
|
750
|
+
if (props.variant === "image-text") {
|
|
751
|
+
return /* @__PURE__ */(0, import_jsx_runtime17.jsx)(MultistepFlowMessageImageText, {
|
|
752
|
+
...props
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
return null;
|
|
756
|
+
};
|
|
757
|
+
|
|
758
|
+
// src/MultistepForm/MultistepQuestion.tsx
|
|
759
|
+
var import_ui15 = require("@ttoss/ui");
|
|
760
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
761
|
+
var MultistepQuestion = ({
|
|
762
|
+
fields,
|
|
763
|
+
question
|
|
764
|
+
}) => {
|
|
765
|
+
return /* @__PURE__ */(0, import_jsx_runtime18.jsxs)(import_ui15.Flex, {
|
|
766
|
+
sx: {
|
|
767
|
+
flexDirection: "column",
|
|
768
|
+
paddingTop: "xl",
|
|
769
|
+
paddingX: "2xl"
|
|
770
|
+
},
|
|
771
|
+
children: [/* @__PURE__ */(0, import_jsx_runtime18.jsx)(import_ui15.Text, {
|
|
772
|
+
sx: {
|
|
773
|
+
textAlign: "center",
|
|
774
|
+
fontSize: "lg",
|
|
775
|
+
marginBottom: "xl"
|
|
776
|
+
},
|
|
777
|
+
children: question
|
|
778
|
+
}), /* @__PURE__ */(0, import_jsx_runtime18.jsx)(import_ui15.Flex, {
|
|
779
|
+
sx: {
|
|
780
|
+
flexDirection: "column",
|
|
781
|
+
gap: "xl"
|
|
782
|
+
},
|
|
783
|
+
children: fields
|
|
784
|
+
})]
|
|
785
|
+
});
|
|
786
|
+
};
|
|
787
|
+
|
|
788
|
+
// src/MultistepForm/MultistepFormStepper.tsx
|
|
789
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
790
|
+
var MultistepFormStepper = ({
|
|
791
|
+
flowMessage,
|
|
792
|
+
fields,
|
|
793
|
+
onSubmit,
|
|
794
|
+
question,
|
|
795
|
+
submitLabel,
|
|
796
|
+
schema,
|
|
797
|
+
isLastStep,
|
|
798
|
+
defaultValues,
|
|
799
|
+
stepNumber
|
|
800
|
+
// isCurrentStep,
|
|
801
|
+
}) => {
|
|
802
|
+
const formMethods = (0, import_react_hook_form6.useForm)({
|
|
803
|
+
resolver: schema ? (0, import_yup2.yupResolver)(schema) : void 0,
|
|
804
|
+
defaultValues
|
|
805
|
+
});
|
|
806
|
+
return /* @__PURE__ */(0, import_jsx_runtime19.jsxs)(Form, {
|
|
807
|
+
...formMethods,
|
|
808
|
+
sx: {
|
|
809
|
+
display: "flex",
|
|
810
|
+
flexDirection: "column"
|
|
811
|
+
},
|
|
812
|
+
onSubmit,
|
|
813
|
+
children: [/* @__PURE__ */(0, import_jsx_runtime19.jsx)(MultistepFlowMessage, {
|
|
814
|
+
...flowMessage
|
|
815
|
+
}), /* @__PURE__ */(0, import_jsx_runtime19.jsx)(MultistepQuestion, {
|
|
816
|
+
fields,
|
|
817
|
+
question
|
|
818
|
+
}), /* @__PURE__ */(0, import_jsx_runtime19.jsx)(import_ui16.Button, {
|
|
819
|
+
sx: {
|
|
820
|
+
justifyContent: "center",
|
|
821
|
+
marginTop: "2xl",
|
|
822
|
+
marginBottom: "xl",
|
|
823
|
+
marginX: "2xl"
|
|
824
|
+
},
|
|
825
|
+
rightIcon: isLastStep ? void 0 : "nav-right",
|
|
826
|
+
"aria-label": `btn-step-${stepNumber}`,
|
|
827
|
+
type: "submit",
|
|
828
|
+
children: submitLabel
|
|
829
|
+
})]
|
|
830
|
+
});
|
|
831
|
+
};
|
|
832
|
+
|
|
833
|
+
// src/MultistepForm/MultistepHeader.tsx
|
|
834
|
+
var import_ui17 = require("@ttoss/ui");
|
|
835
|
+
|
|
836
|
+
// ../react-icons/dist/esm/index.js
|
|
837
|
+
var React4 = __toESM(require("react"));
|
|
838
|
+
|
|
839
|
+
// ../../node_modules/.pnpm/@iconify-icon+react@1.0.8_react@18.2.0/node_modules/@iconify-icon/react/dist/iconify.mjs
|
|
840
|
+
var import_react = __toESM(require("react"), 1);
|
|
841
|
+
|
|
842
|
+
// ../../node_modules/.pnpm/iconify-icon@1.0.8/node_modules/iconify-icon/dist/iconify-icon.mjs
|
|
843
|
+
var defaultIconDimensions = Object.freeze({
|
|
844
|
+
left: 0,
|
|
845
|
+
top: 0,
|
|
846
|
+
width: 16,
|
|
847
|
+
height: 16
|
|
848
|
+
});
|
|
849
|
+
var defaultIconTransformations = Object.freeze({
|
|
850
|
+
rotate: 0,
|
|
851
|
+
vFlip: false,
|
|
852
|
+
hFlip: false
|
|
853
|
+
});
|
|
854
|
+
var defaultIconProps = Object.freeze({
|
|
855
|
+
...defaultIconDimensions,
|
|
856
|
+
...defaultIconTransformations
|
|
857
|
+
});
|
|
858
|
+
var defaultExtendedIconProps = Object.freeze({
|
|
859
|
+
...defaultIconProps,
|
|
860
|
+
body: "",
|
|
861
|
+
hidden: false
|
|
862
|
+
});
|
|
863
|
+
var defaultIconSizeCustomisations = Object.freeze({
|
|
864
|
+
width: null,
|
|
865
|
+
height: null
|
|
866
|
+
});
|
|
867
|
+
var defaultIconCustomisations = Object.freeze({
|
|
868
|
+
// Dimensions
|
|
869
|
+
...defaultIconSizeCustomisations,
|
|
870
|
+
// Transformations
|
|
871
|
+
...defaultIconTransformations
|
|
872
|
+
});
|
|
873
|
+
function rotateFromString(value, defaultValue = 0) {
|
|
874
|
+
const units = value.replace(/^-?[0-9.]*/, "");
|
|
875
|
+
function cleanup(value2) {
|
|
876
|
+
while (value2 < 0) {
|
|
877
|
+
value2 += 4;
|
|
878
|
+
}
|
|
879
|
+
return value2 % 4;
|
|
880
|
+
}
|
|
881
|
+
if (units === "") {
|
|
882
|
+
const num = parseInt(value);
|
|
883
|
+
return isNaN(num) ? 0 : cleanup(num);
|
|
884
|
+
} else if (units !== value) {
|
|
885
|
+
let split = 0;
|
|
886
|
+
switch (units) {
|
|
887
|
+
case "%":
|
|
888
|
+
split = 25;
|
|
889
|
+
break;
|
|
890
|
+
case "deg":
|
|
891
|
+
split = 90;
|
|
892
|
+
}
|
|
893
|
+
if (split) {
|
|
894
|
+
let num = parseFloat(value.slice(0, value.length - units.length));
|
|
895
|
+
if (isNaN(num)) {
|
|
896
|
+
return 0;
|
|
897
|
+
}
|
|
898
|
+
num = num / split;
|
|
899
|
+
return num % 1 === 0 ? cleanup(num) : 0;
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
return defaultValue;
|
|
903
|
+
}
|
|
904
|
+
var separator = /[\s,]+/;
|
|
905
|
+
function flipFromString(custom, flip) {
|
|
906
|
+
flip.split(separator).forEach(str => {
|
|
907
|
+
const value = str.trim();
|
|
908
|
+
switch (value) {
|
|
909
|
+
case "horizontal":
|
|
910
|
+
custom.hFlip = true;
|
|
911
|
+
break;
|
|
912
|
+
case "vertical":
|
|
913
|
+
custom.vFlip = true;
|
|
914
|
+
break;
|
|
915
|
+
}
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
var defaultCustomisations = {
|
|
919
|
+
...defaultIconCustomisations,
|
|
920
|
+
preserveAspectRatio: ""
|
|
921
|
+
};
|
|
922
|
+
function getCustomisations(node) {
|
|
923
|
+
const customisations = {
|
|
924
|
+
...defaultCustomisations
|
|
925
|
+
};
|
|
926
|
+
const attr = (key, def) => node.getAttribute(key) || def;
|
|
927
|
+
customisations.width = attr("width", null);
|
|
928
|
+
customisations.height = attr("height", null);
|
|
929
|
+
customisations.rotate = rotateFromString(attr("rotate", ""));
|
|
930
|
+
flipFromString(customisations, attr("flip", ""));
|
|
931
|
+
customisations.preserveAspectRatio = attr("preserveAspectRatio", attr("preserveaspectratio", ""));
|
|
932
|
+
return customisations;
|
|
933
|
+
}
|
|
934
|
+
function haveCustomisationsChanged(value1, value2) {
|
|
935
|
+
for (const key in defaultCustomisations) {
|
|
936
|
+
if (value1[key] !== value2[key]) {
|
|
937
|
+
return true;
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
return false;
|
|
941
|
+
}
|
|
942
|
+
var matchIconName = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
943
|
+
var stringToIcon = (value, validate, allowSimpleName, provider = "") => {
|
|
944
|
+
const colonSeparated = value.split(":");
|
|
945
|
+
if (value.slice(0, 1) === "@") {
|
|
946
|
+
if (colonSeparated.length < 2 || colonSeparated.length > 3) {
|
|
947
|
+
return null;
|
|
948
|
+
}
|
|
949
|
+
provider = colonSeparated.shift().slice(1);
|
|
950
|
+
}
|
|
951
|
+
if (colonSeparated.length > 3 || !colonSeparated.length) {
|
|
952
|
+
return null;
|
|
953
|
+
}
|
|
954
|
+
if (colonSeparated.length > 1) {
|
|
955
|
+
const name2 = colonSeparated.pop();
|
|
956
|
+
const prefix = colonSeparated.pop();
|
|
957
|
+
const result = {
|
|
958
|
+
// Allow provider without '@': "provider:prefix:name"
|
|
959
|
+
provider: colonSeparated.length > 0 ? colonSeparated[0] : provider,
|
|
960
|
+
prefix,
|
|
961
|
+
name: name2
|
|
962
|
+
};
|
|
963
|
+
return validate && !validateIconName(result) ? null : result;
|
|
964
|
+
}
|
|
965
|
+
const name = colonSeparated[0];
|
|
966
|
+
const dashSeparated = name.split("-");
|
|
967
|
+
if (dashSeparated.length > 1) {
|
|
968
|
+
const result = {
|
|
969
|
+
provider,
|
|
970
|
+
prefix: dashSeparated.shift(),
|
|
971
|
+
name: dashSeparated.join("-")
|
|
972
|
+
};
|
|
973
|
+
return validate && !validateIconName(result) ? null : result;
|
|
974
|
+
}
|
|
975
|
+
if (allowSimpleName && provider === "") {
|
|
976
|
+
const result = {
|
|
977
|
+
provider,
|
|
978
|
+
prefix: "",
|
|
979
|
+
name
|
|
980
|
+
};
|
|
981
|
+
return validate && !validateIconName(result, allowSimpleName) ? null : result;
|
|
982
|
+
}
|
|
983
|
+
return null;
|
|
984
|
+
};
|
|
985
|
+
var validateIconName = (icon, allowSimpleName) => {
|
|
986
|
+
if (!icon) {
|
|
987
|
+
return false;
|
|
988
|
+
}
|
|
989
|
+
return !!((icon.provider === "" || icon.provider.match(matchIconName)) && (allowSimpleName && icon.prefix === "" || icon.prefix.match(matchIconName)) && icon.name.match(matchIconName));
|
|
990
|
+
};
|
|
991
|
+
function mergeIconTransformations(obj1, obj2) {
|
|
992
|
+
const result = {};
|
|
993
|
+
if (!obj1.hFlip !== !obj2.hFlip) {
|
|
994
|
+
result.hFlip = true;
|
|
995
|
+
}
|
|
996
|
+
if (!obj1.vFlip !== !obj2.vFlip) {
|
|
997
|
+
result.vFlip = true;
|
|
998
|
+
}
|
|
999
|
+
const rotate = ((obj1.rotate || 0) + (obj2.rotate || 0)) % 4;
|
|
1000
|
+
if (rotate) {
|
|
1001
|
+
result.rotate = rotate;
|
|
1002
|
+
}
|
|
1003
|
+
return result;
|
|
1004
|
+
}
|
|
1005
|
+
function mergeIconData(parent, child) {
|
|
1006
|
+
const result = mergeIconTransformations(parent, child);
|
|
1007
|
+
for (const key in defaultExtendedIconProps) {
|
|
1008
|
+
if (key in defaultIconTransformations) {
|
|
1009
|
+
if (key in parent && !(key in result)) {
|
|
1010
|
+
result[key] = defaultIconTransformations[key];
|
|
1011
|
+
}
|
|
1012
|
+
} else if (key in child) {
|
|
1013
|
+
result[key] = child[key];
|
|
1014
|
+
} else if (key in parent) {
|
|
1015
|
+
result[key] = parent[key];
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
return result;
|
|
1019
|
+
}
|
|
1020
|
+
function getIconsTree(data, names) {
|
|
1021
|
+
const icons = data.icons;
|
|
1022
|
+
const aliases = data.aliases || /* @__PURE__ */Object.create(null);
|
|
1023
|
+
const resolved = /* @__PURE__ */Object.create(null);
|
|
1024
|
+
function resolve(name) {
|
|
1025
|
+
if (icons[name]) {
|
|
1026
|
+
return resolved[name] = [];
|
|
1027
|
+
}
|
|
1028
|
+
if (!(name in resolved)) {
|
|
1029
|
+
resolved[name] = null;
|
|
1030
|
+
const parent = aliases[name] && aliases[name].parent;
|
|
1031
|
+
const value = parent && resolve(parent);
|
|
1032
|
+
if (value) {
|
|
1033
|
+
resolved[name] = [parent].concat(value);
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
return resolved[name];
|
|
1037
|
+
}
|
|
1038
|
+
(names || Object.keys(icons).concat(Object.keys(aliases))).forEach(resolve);
|
|
1039
|
+
return resolved;
|
|
1040
|
+
}
|
|
1041
|
+
function internalGetIconData(data, name, tree) {
|
|
1042
|
+
const icons = data.icons;
|
|
1043
|
+
const aliases = data.aliases || /* @__PURE__ */Object.create(null);
|
|
1044
|
+
let currentProps = {};
|
|
1045
|
+
function parse(name2) {
|
|
1046
|
+
currentProps = mergeIconData(icons[name2] || aliases[name2], currentProps);
|
|
1047
|
+
}
|
|
1048
|
+
parse(name);
|
|
1049
|
+
tree.forEach(parse);
|
|
1050
|
+
return mergeIconData(data, currentProps);
|
|
1051
|
+
}
|
|
1052
|
+
function parseIconSet(data, callback) {
|
|
1053
|
+
const names = [];
|
|
1054
|
+
if (typeof data !== "object" || typeof data.icons !== "object") {
|
|
1055
|
+
return names;
|
|
1056
|
+
}
|
|
1057
|
+
if (data.not_found instanceof Array) {
|
|
1058
|
+
data.not_found.forEach(name => {
|
|
1059
|
+
callback(name, null);
|
|
1060
|
+
names.push(name);
|
|
1061
|
+
});
|
|
1062
|
+
}
|
|
1063
|
+
const tree = getIconsTree(data);
|
|
1064
|
+
for (const name in tree) {
|
|
1065
|
+
const item = tree[name];
|
|
1066
|
+
if (item) {
|
|
1067
|
+
callback(name, internalGetIconData(data, name, item));
|
|
1068
|
+
names.push(name);
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
return names;
|
|
1072
|
+
}
|
|
1073
|
+
var optionalPropertyDefaults = {
|
|
1074
|
+
provider: "",
|
|
1075
|
+
aliases: {},
|
|
1076
|
+
not_found: {},
|
|
1077
|
+
...defaultIconDimensions
|
|
1078
|
+
};
|
|
1079
|
+
function checkOptionalProps(item, defaults) {
|
|
1080
|
+
for (const prop in defaults) {
|
|
1081
|
+
if (prop in item && typeof item[prop] !== typeof defaults[prop]) {
|
|
1082
|
+
return false;
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
return true;
|
|
1086
|
+
}
|
|
1087
|
+
function quicklyValidateIconSet(obj) {
|
|
1088
|
+
if (typeof obj !== "object" || obj === null) {
|
|
1089
|
+
return null;
|
|
1090
|
+
}
|
|
1091
|
+
const data = obj;
|
|
1092
|
+
if (typeof data.prefix !== "string" || !obj.icons || typeof obj.icons !== "object") {
|
|
1093
|
+
return null;
|
|
1094
|
+
}
|
|
1095
|
+
if (!checkOptionalProps(obj, optionalPropertyDefaults)) {
|
|
1096
|
+
return null;
|
|
1097
|
+
}
|
|
1098
|
+
const icons = data.icons;
|
|
1099
|
+
for (const name in icons) {
|
|
1100
|
+
const icon = icons[name];
|
|
1101
|
+
if (!name.match(matchIconName) || typeof icon.body !== "string" || !checkOptionalProps(icon, defaultExtendedIconProps)) {
|
|
1102
|
+
return null;
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
const aliases = data.aliases || /* @__PURE__ */Object.create(null);
|
|
1106
|
+
for (const name in aliases) {
|
|
1107
|
+
const icon = aliases[name];
|
|
1108
|
+
const parent = icon.parent;
|
|
1109
|
+
if (!name.match(matchIconName) || typeof parent !== "string" || !icons[parent] && !aliases[parent] || !checkOptionalProps(icon, defaultExtendedIconProps)) {
|
|
1110
|
+
return null;
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
return data;
|
|
1114
|
+
}
|
|
1115
|
+
var dataStorage = /* @__PURE__ */Object.create(null);
|
|
1116
|
+
function newStorage(provider, prefix) {
|
|
1117
|
+
return {
|
|
1118
|
+
provider,
|
|
1119
|
+
prefix,
|
|
1120
|
+
icons: /* @__PURE__ */Object.create(null),
|
|
1121
|
+
missing: /* @__PURE__ */new Set()
|
|
1122
|
+
};
|
|
1123
|
+
}
|
|
1124
|
+
function getStorage(provider, prefix) {
|
|
1125
|
+
const providerStorage = dataStorage[provider] || (dataStorage[provider] = /* @__PURE__ */Object.create(null));
|
|
1126
|
+
return providerStorage[prefix] || (providerStorage[prefix] = newStorage(provider, prefix));
|
|
1127
|
+
}
|
|
1128
|
+
function addIconSet(storage2, data) {
|
|
1129
|
+
if (!quicklyValidateIconSet(data)) {
|
|
1130
|
+
return [];
|
|
1131
|
+
}
|
|
1132
|
+
return parseIconSet(data, (name, icon) => {
|
|
1133
|
+
if (icon) {
|
|
1134
|
+
storage2.icons[name] = icon;
|
|
1135
|
+
} else {
|
|
1136
|
+
storage2.missing.add(name);
|
|
1137
|
+
}
|
|
1138
|
+
});
|
|
1139
|
+
}
|
|
1140
|
+
function addIconToStorage(storage2, name, icon) {
|
|
1141
|
+
try {
|
|
1142
|
+
if (typeof icon.body === "string") {
|
|
1143
|
+
storage2.icons[name] = {
|
|
1144
|
+
...icon
|
|
1145
|
+
};
|
|
1146
|
+
return true;
|
|
1147
|
+
}
|
|
1148
|
+
} catch (err) {}
|
|
1149
|
+
return false;
|
|
1150
|
+
}
|
|
1151
|
+
function listIcons$1(provider, prefix) {
|
|
1152
|
+
let allIcons = [];
|
|
1153
|
+
const providers = typeof provider === "string" ? [provider] : Object.keys(dataStorage);
|
|
1154
|
+
providers.forEach(provider2 => {
|
|
1155
|
+
const prefixes = typeof provider2 === "string" && typeof prefix === "string" ? [prefix] : Object.keys(dataStorage[provider2] || {});
|
|
1156
|
+
prefixes.forEach(prefix2 => {
|
|
1157
|
+
const storage2 = getStorage(provider2, prefix2);
|
|
1158
|
+
allIcons = allIcons.concat(Object.keys(storage2.icons).map(name => (provider2 !== "" ? "@" + provider2 + ":" : "") + prefix2 + ":" + name));
|
|
1159
|
+
});
|
|
1160
|
+
});
|
|
1161
|
+
return allIcons;
|
|
1162
|
+
}
|
|
1163
|
+
var simpleNames = false;
|
|
1164
|
+
function allowSimpleNames(allow) {
|
|
1165
|
+
if (typeof allow === "boolean") {
|
|
1166
|
+
simpleNames = allow;
|
|
1167
|
+
}
|
|
1168
|
+
return simpleNames;
|
|
1169
|
+
}
|
|
1170
|
+
function getIconData(name) {
|
|
1171
|
+
const icon = typeof name === "string" ? stringToIcon(name, true, simpleNames) : name;
|
|
1172
|
+
if (icon) {
|
|
1173
|
+
const storage2 = getStorage(icon.provider, icon.prefix);
|
|
1174
|
+
const iconName = icon.name;
|
|
1175
|
+
return storage2.icons[iconName] || (storage2.missing.has(iconName) ? null : void 0);
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
function addIcon$1(name, data) {
|
|
1179
|
+
const icon = stringToIcon(name, true, simpleNames);
|
|
1180
|
+
if (!icon) {
|
|
1181
|
+
return false;
|
|
1182
|
+
}
|
|
1183
|
+
const storage2 = getStorage(icon.provider, icon.prefix);
|
|
1184
|
+
return addIconToStorage(storage2, icon.name, data);
|
|
1185
|
+
}
|
|
1186
|
+
function addCollection$1(data, provider) {
|
|
1187
|
+
if (typeof data !== "object") {
|
|
1188
|
+
return false;
|
|
1189
|
+
}
|
|
1190
|
+
if (typeof provider !== "string") {
|
|
1191
|
+
provider = data.provider || "";
|
|
1192
|
+
}
|
|
1193
|
+
if (simpleNames && !provider && !data.prefix) {
|
|
1194
|
+
let added = false;
|
|
1195
|
+
if (quicklyValidateIconSet(data)) {
|
|
1196
|
+
data.prefix = "";
|
|
1197
|
+
parseIconSet(data, (name, icon) => {
|
|
1198
|
+
if (icon && addIcon$1(name, icon)) {
|
|
1199
|
+
added = true;
|
|
1200
|
+
}
|
|
1201
|
+
});
|
|
1202
|
+
}
|
|
1203
|
+
return added;
|
|
1204
|
+
}
|
|
1205
|
+
const prefix = data.prefix;
|
|
1206
|
+
if (!validateIconName({
|
|
1207
|
+
provider,
|
|
1208
|
+
prefix,
|
|
1209
|
+
name: "a"
|
|
1210
|
+
})) {
|
|
1211
|
+
return false;
|
|
1212
|
+
}
|
|
1213
|
+
const storage2 = getStorage(provider, prefix);
|
|
1214
|
+
return !!addIconSet(storage2, data);
|
|
1215
|
+
}
|
|
1216
|
+
function iconExists$1(name) {
|
|
1217
|
+
return !!getIconData(name);
|
|
1218
|
+
}
|
|
1219
|
+
function getIcon$1(name) {
|
|
1220
|
+
const result = getIconData(name);
|
|
1221
|
+
return result ? {
|
|
1222
|
+
...defaultIconProps,
|
|
1223
|
+
...result
|
|
1224
|
+
} : null;
|
|
1225
|
+
}
|
|
1226
|
+
function sortIcons(icons) {
|
|
1227
|
+
const result = {
|
|
1228
|
+
loaded: [],
|
|
1229
|
+
missing: [],
|
|
1230
|
+
pending: []
|
|
1231
|
+
};
|
|
1232
|
+
const storage2 = /* @__PURE__ */Object.create(null);
|
|
1233
|
+
icons.sort((a, b) => {
|
|
1234
|
+
if (a.provider !== b.provider) {
|
|
1235
|
+
return a.provider.localeCompare(b.provider);
|
|
1236
|
+
}
|
|
1237
|
+
if (a.prefix !== b.prefix) {
|
|
1238
|
+
return a.prefix.localeCompare(b.prefix);
|
|
1239
|
+
}
|
|
1240
|
+
return a.name.localeCompare(b.name);
|
|
1241
|
+
});
|
|
1242
|
+
let lastIcon = {
|
|
1243
|
+
provider: "",
|
|
1244
|
+
prefix: "",
|
|
1245
|
+
name: ""
|
|
1246
|
+
};
|
|
1247
|
+
icons.forEach(icon => {
|
|
1248
|
+
if (lastIcon.name === icon.name && lastIcon.prefix === icon.prefix && lastIcon.provider === icon.provider) {
|
|
1249
|
+
return;
|
|
1250
|
+
}
|
|
1251
|
+
lastIcon = icon;
|
|
1252
|
+
const provider = icon.provider;
|
|
1253
|
+
const prefix = icon.prefix;
|
|
1254
|
+
const name = icon.name;
|
|
1255
|
+
const providerStorage = storage2[provider] || (storage2[provider] = /* @__PURE__ */Object.create(null));
|
|
1256
|
+
const localStorage = providerStorage[prefix] || (providerStorage[prefix] = getStorage(provider, prefix));
|
|
1257
|
+
let list;
|
|
1258
|
+
if (name in localStorage.icons) {
|
|
1259
|
+
list = result.loaded;
|
|
1260
|
+
} else if (prefix === "" || localStorage.missing.has(name)) {
|
|
1261
|
+
list = result.missing;
|
|
1262
|
+
} else {
|
|
1263
|
+
list = result.pending;
|
|
1264
|
+
}
|
|
1265
|
+
const item = {
|
|
1266
|
+
provider,
|
|
1267
|
+
prefix,
|
|
1268
|
+
name
|
|
1269
|
+
};
|
|
1270
|
+
list.push(item);
|
|
1271
|
+
});
|
|
1272
|
+
return result;
|
|
1273
|
+
}
|
|
1274
|
+
function removeCallback(storages, id) {
|
|
1275
|
+
storages.forEach(storage2 => {
|
|
1276
|
+
const items = storage2.loaderCallbacks;
|
|
1277
|
+
if (items) {
|
|
1278
|
+
storage2.loaderCallbacks = items.filter(row => row.id !== id);
|
|
1279
|
+
}
|
|
1280
|
+
});
|
|
1281
|
+
}
|
|
1282
|
+
function updateCallbacks(storage2) {
|
|
1283
|
+
if (!storage2.pendingCallbacksFlag) {
|
|
1284
|
+
storage2.pendingCallbacksFlag = true;
|
|
1285
|
+
setTimeout(() => {
|
|
1286
|
+
storage2.pendingCallbacksFlag = false;
|
|
1287
|
+
const items = storage2.loaderCallbacks ? storage2.loaderCallbacks.slice(0) : [];
|
|
1288
|
+
if (!items.length) {
|
|
1289
|
+
return;
|
|
1290
|
+
}
|
|
1291
|
+
let hasPending = false;
|
|
1292
|
+
const provider = storage2.provider;
|
|
1293
|
+
const prefix = storage2.prefix;
|
|
1294
|
+
items.forEach(item => {
|
|
1295
|
+
const icons = item.icons;
|
|
1296
|
+
const oldLength = icons.pending.length;
|
|
1297
|
+
icons.pending = icons.pending.filter(icon => {
|
|
1298
|
+
if (icon.prefix !== prefix) {
|
|
1299
|
+
return true;
|
|
1300
|
+
}
|
|
1301
|
+
const name = icon.name;
|
|
1302
|
+
if (storage2.icons[name]) {
|
|
1303
|
+
icons.loaded.push({
|
|
1304
|
+
provider,
|
|
1305
|
+
prefix,
|
|
1306
|
+
name
|
|
1307
|
+
});
|
|
1308
|
+
} else if (storage2.missing.has(name)) {
|
|
1309
|
+
icons.missing.push({
|
|
1310
|
+
provider,
|
|
1311
|
+
prefix,
|
|
1312
|
+
name
|
|
1313
|
+
});
|
|
1314
|
+
} else {
|
|
1315
|
+
hasPending = true;
|
|
1316
|
+
return true;
|
|
1317
|
+
}
|
|
1318
|
+
return false;
|
|
1319
|
+
});
|
|
1320
|
+
if (icons.pending.length !== oldLength) {
|
|
1321
|
+
if (!hasPending) {
|
|
1322
|
+
removeCallback([storage2], item.id);
|
|
1323
|
+
}
|
|
1324
|
+
item.callback(icons.loaded.slice(0), icons.missing.slice(0), icons.pending.slice(0), item.abort);
|
|
1325
|
+
}
|
|
1326
|
+
});
|
|
1327
|
+
});
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
var idCounter = 0;
|
|
1331
|
+
function storeCallback(callback, icons, pendingSources) {
|
|
1332
|
+
const id = idCounter++;
|
|
1333
|
+
const abort = removeCallback.bind(null, pendingSources, id);
|
|
1334
|
+
if (!icons.pending.length) {
|
|
1335
|
+
return abort;
|
|
1336
|
+
}
|
|
1337
|
+
const item = {
|
|
1338
|
+
id,
|
|
1339
|
+
icons,
|
|
1340
|
+
callback,
|
|
1341
|
+
abort
|
|
1342
|
+
};
|
|
1343
|
+
pendingSources.forEach(storage2 => {
|
|
1344
|
+
(storage2.loaderCallbacks || (storage2.loaderCallbacks = [])).push(item);
|
|
1345
|
+
});
|
|
1346
|
+
return abort;
|
|
1347
|
+
}
|
|
1348
|
+
var storage = /* @__PURE__ */Object.create(null);
|
|
1349
|
+
function setAPIModule(provider, item) {
|
|
1350
|
+
storage[provider] = item;
|
|
1351
|
+
}
|
|
1352
|
+
function getAPIModule(provider) {
|
|
1353
|
+
return storage[provider] || storage[""];
|
|
1354
|
+
}
|
|
1355
|
+
function listToIcons(list, validate = true, simpleNames2 = false) {
|
|
1356
|
+
const result = [];
|
|
1357
|
+
list.forEach(item => {
|
|
1358
|
+
const icon = typeof item === "string" ? stringToIcon(item, validate, simpleNames2) : item;
|
|
1359
|
+
if (icon) {
|
|
1360
|
+
result.push(icon);
|
|
1361
|
+
}
|
|
1362
|
+
});
|
|
1363
|
+
return result;
|
|
1364
|
+
}
|
|
1365
|
+
var defaultConfig = {
|
|
1366
|
+
resources: [],
|
|
1367
|
+
index: 0,
|
|
1368
|
+
timeout: 2e3,
|
|
1369
|
+
rotate: 750,
|
|
1370
|
+
random: false,
|
|
1371
|
+
dataAfterTimeout: false
|
|
1372
|
+
};
|
|
1373
|
+
function sendQuery(config, payload, query, done) {
|
|
1374
|
+
const resourcesCount = config.resources.length;
|
|
1375
|
+
const startIndex = config.random ? Math.floor(Math.random() * resourcesCount) : config.index;
|
|
1376
|
+
let resources;
|
|
1377
|
+
if (config.random) {
|
|
1378
|
+
let list = config.resources.slice(0);
|
|
1379
|
+
resources = [];
|
|
1380
|
+
while (list.length > 1) {
|
|
1381
|
+
const nextIndex = Math.floor(Math.random() * list.length);
|
|
1382
|
+
resources.push(list[nextIndex]);
|
|
1383
|
+
list = list.slice(0, nextIndex).concat(list.slice(nextIndex + 1));
|
|
1384
|
+
}
|
|
1385
|
+
resources = resources.concat(list);
|
|
1386
|
+
} else {
|
|
1387
|
+
resources = config.resources.slice(startIndex).concat(config.resources.slice(0, startIndex));
|
|
1388
|
+
}
|
|
1389
|
+
const startTime = Date.now();
|
|
1390
|
+
let status = "pending";
|
|
1391
|
+
let queriesSent = 0;
|
|
1392
|
+
let lastError;
|
|
1393
|
+
let timer = null;
|
|
1394
|
+
let queue = [];
|
|
1395
|
+
let doneCallbacks = [];
|
|
1396
|
+
if (typeof done === "function") {
|
|
1397
|
+
doneCallbacks.push(done);
|
|
1398
|
+
}
|
|
1399
|
+
function resetTimer() {
|
|
1400
|
+
if (timer) {
|
|
1401
|
+
clearTimeout(timer);
|
|
1402
|
+
timer = null;
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
function abort() {
|
|
1406
|
+
if (status === "pending") {
|
|
1407
|
+
status = "aborted";
|
|
1408
|
+
}
|
|
1409
|
+
resetTimer();
|
|
1410
|
+
queue.forEach(item => {
|
|
1411
|
+
if (item.status === "pending") {
|
|
1412
|
+
item.status = "aborted";
|
|
1413
|
+
}
|
|
1414
|
+
});
|
|
1415
|
+
queue = [];
|
|
1416
|
+
}
|
|
1417
|
+
function subscribe(callback, overwrite) {
|
|
1418
|
+
if (overwrite) {
|
|
1419
|
+
doneCallbacks = [];
|
|
1420
|
+
}
|
|
1421
|
+
if (typeof callback === "function") {
|
|
1422
|
+
doneCallbacks.push(callback);
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
function getQueryStatus() {
|
|
1426
|
+
return {
|
|
1427
|
+
startTime,
|
|
1428
|
+
payload,
|
|
1429
|
+
status,
|
|
1430
|
+
queriesSent,
|
|
1431
|
+
queriesPending: queue.length,
|
|
1432
|
+
subscribe,
|
|
1433
|
+
abort
|
|
1434
|
+
};
|
|
1435
|
+
}
|
|
1436
|
+
function failQuery() {
|
|
1437
|
+
status = "failed";
|
|
1438
|
+
doneCallbacks.forEach(callback => {
|
|
1439
|
+
callback(void 0, lastError);
|
|
1440
|
+
});
|
|
1441
|
+
}
|
|
1442
|
+
function clearQueue() {
|
|
1443
|
+
queue.forEach(item => {
|
|
1444
|
+
if (item.status === "pending") {
|
|
1445
|
+
item.status = "aborted";
|
|
1446
|
+
}
|
|
1447
|
+
});
|
|
1448
|
+
queue = [];
|
|
1449
|
+
}
|
|
1450
|
+
function moduleResponse(item, response, data) {
|
|
1451
|
+
const isError = response !== "success";
|
|
1452
|
+
queue = queue.filter(queued => queued !== item);
|
|
1453
|
+
switch (status) {
|
|
1454
|
+
case "pending":
|
|
1455
|
+
break;
|
|
1456
|
+
case "failed":
|
|
1457
|
+
if (isError || !config.dataAfterTimeout) {
|
|
1458
|
+
return;
|
|
1459
|
+
}
|
|
1460
|
+
break;
|
|
1461
|
+
default:
|
|
1462
|
+
return;
|
|
1463
|
+
}
|
|
1464
|
+
if (response === "abort") {
|
|
1465
|
+
lastError = data;
|
|
1466
|
+
failQuery();
|
|
1467
|
+
return;
|
|
1468
|
+
}
|
|
1469
|
+
if (isError) {
|
|
1470
|
+
lastError = data;
|
|
1471
|
+
if (!queue.length) {
|
|
1472
|
+
if (!resources.length) {
|
|
1473
|
+
failQuery();
|
|
1474
|
+
} else {
|
|
1475
|
+
execNext();
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
return;
|
|
1479
|
+
}
|
|
1480
|
+
resetTimer();
|
|
1481
|
+
clearQueue();
|
|
1482
|
+
if (!config.random) {
|
|
1483
|
+
const index = config.resources.indexOf(item.resource);
|
|
1484
|
+
if (index !== -1 && index !== config.index) {
|
|
1485
|
+
config.index = index;
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
status = "completed";
|
|
1489
|
+
doneCallbacks.forEach(callback => {
|
|
1490
|
+
callback(data);
|
|
1491
|
+
});
|
|
1492
|
+
}
|
|
1493
|
+
function execNext() {
|
|
1494
|
+
if (status !== "pending") {
|
|
1495
|
+
return;
|
|
1496
|
+
}
|
|
1497
|
+
resetTimer();
|
|
1498
|
+
const resource = resources.shift();
|
|
1499
|
+
if (resource === void 0) {
|
|
1500
|
+
if (queue.length) {
|
|
1501
|
+
timer = setTimeout(() => {
|
|
1502
|
+
resetTimer();
|
|
1503
|
+
if (status === "pending") {
|
|
1504
|
+
clearQueue();
|
|
1505
|
+
failQuery();
|
|
1506
|
+
}
|
|
1507
|
+
}, config.timeout);
|
|
1508
|
+
return;
|
|
1509
|
+
}
|
|
1510
|
+
failQuery();
|
|
1511
|
+
return;
|
|
1512
|
+
}
|
|
1513
|
+
const item = {
|
|
1514
|
+
status: "pending",
|
|
1515
|
+
resource,
|
|
1516
|
+
callback: (status2, data) => {
|
|
1517
|
+
moduleResponse(item, status2, data);
|
|
1518
|
+
}
|
|
1519
|
+
};
|
|
1520
|
+
queue.push(item);
|
|
1521
|
+
queriesSent++;
|
|
1522
|
+
timer = setTimeout(execNext, config.rotate);
|
|
1523
|
+
query(resource, payload, item.callback);
|
|
1524
|
+
}
|
|
1525
|
+
setTimeout(execNext);
|
|
1526
|
+
return getQueryStatus;
|
|
1527
|
+
}
|
|
1528
|
+
function initRedundancy(cfg) {
|
|
1529
|
+
const config = {
|
|
1530
|
+
...defaultConfig,
|
|
1531
|
+
...cfg
|
|
1532
|
+
};
|
|
1533
|
+
let queries = [];
|
|
1534
|
+
function cleanup() {
|
|
1535
|
+
queries = queries.filter(item => item().status === "pending");
|
|
1536
|
+
}
|
|
1537
|
+
function query(payload, queryCallback, doneCallback) {
|
|
1538
|
+
const query2 = sendQuery(config, payload, queryCallback, (data, error) => {
|
|
1539
|
+
cleanup();
|
|
1540
|
+
if (doneCallback) {
|
|
1541
|
+
doneCallback(data, error);
|
|
1542
|
+
}
|
|
1543
|
+
});
|
|
1544
|
+
queries.push(query2);
|
|
1545
|
+
return query2;
|
|
1546
|
+
}
|
|
1547
|
+
function find(callback) {
|
|
1548
|
+
return queries.find(value => {
|
|
1549
|
+
return callback(value);
|
|
1550
|
+
}) || null;
|
|
1551
|
+
}
|
|
1552
|
+
const instance = {
|
|
1553
|
+
query,
|
|
1554
|
+
find,
|
|
1555
|
+
setIndex: index => {
|
|
1556
|
+
config.index = index;
|
|
1557
|
+
},
|
|
1558
|
+
getIndex: () => config.index,
|
|
1559
|
+
cleanup
|
|
1560
|
+
};
|
|
1561
|
+
return instance;
|
|
1562
|
+
}
|
|
1563
|
+
function createAPIConfig(source) {
|
|
1564
|
+
let resources;
|
|
1565
|
+
if (typeof source.resources === "string") {
|
|
1566
|
+
resources = [source.resources];
|
|
1567
|
+
} else {
|
|
1568
|
+
resources = source.resources;
|
|
1569
|
+
if (!(resources instanceof Array) || !resources.length) {
|
|
1570
|
+
return null;
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
const result = {
|
|
1574
|
+
// API hosts
|
|
1575
|
+
resources,
|
|
1576
|
+
// Root path
|
|
1577
|
+
path: source.path || "/",
|
|
1578
|
+
// URL length limit
|
|
1579
|
+
maxURL: source.maxURL || 500,
|
|
1580
|
+
// Timeout before next host is used.
|
|
1581
|
+
rotate: source.rotate || 750,
|
|
1582
|
+
// Timeout before failing query.
|
|
1583
|
+
timeout: source.timeout || 5e3,
|
|
1584
|
+
// Randomise default API end point.
|
|
1585
|
+
random: source.random === true,
|
|
1586
|
+
// Start index
|
|
1587
|
+
index: source.index || 0,
|
|
1588
|
+
// Receive data after time out (used if time out kicks in first, then API module sends data anyway).
|
|
1589
|
+
dataAfterTimeout: source.dataAfterTimeout !== false
|
|
1590
|
+
};
|
|
1591
|
+
return result;
|
|
1592
|
+
}
|
|
1593
|
+
var configStorage = /* @__PURE__ */Object.create(null);
|
|
1594
|
+
var fallBackAPISources = ["https://api.simplesvg.com", "https://api.unisvg.com"];
|
|
1595
|
+
var fallBackAPI = [];
|
|
1596
|
+
while (fallBackAPISources.length > 0) {
|
|
1597
|
+
if (fallBackAPISources.length === 1) {
|
|
1598
|
+
fallBackAPI.push(fallBackAPISources.shift());
|
|
1599
|
+
} else {
|
|
1600
|
+
if (Math.random() > 0.5) {
|
|
1601
|
+
fallBackAPI.push(fallBackAPISources.shift());
|
|
1602
|
+
} else {
|
|
1603
|
+
fallBackAPI.push(fallBackAPISources.pop());
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
configStorage[""] = createAPIConfig({
|
|
1608
|
+
resources: ["https://api.iconify.design"].concat(fallBackAPI)
|
|
1609
|
+
});
|
|
1610
|
+
function addAPIProvider$1(provider, customConfig) {
|
|
1611
|
+
const config = createAPIConfig(customConfig);
|
|
1612
|
+
if (config === null) {
|
|
1613
|
+
return false;
|
|
1614
|
+
}
|
|
1615
|
+
configStorage[provider] = config;
|
|
1616
|
+
return true;
|
|
1617
|
+
}
|
|
1618
|
+
function getAPIConfig(provider) {
|
|
1619
|
+
return configStorage[provider];
|
|
1620
|
+
}
|
|
1621
|
+
function listAPIProviders() {
|
|
1622
|
+
return Object.keys(configStorage);
|
|
1623
|
+
}
|
|
1624
|
+
function emptyCallback$1() {}
|
|
1625
|
+
var redundancyCache = /* @__PURE__ */Object.create(null);
|
|
1626
|
+
function getRedundancyCache(provider) {
|
|
1627
|
+
if (!redundancyCache[provider]) {
|
|
1628
|
+
const config = getAPIConfig(provider);
|
|
1629
|
+
if (!config) {
|
|
1630
|
+
return;
|
|
1631
|
+
}
|
|
1632
|
+
const redundancy = initRedundancy(config);
|
|
1633
|
+
const cachedReundancy = {
|
|
1634
|
+
config,
|
|
1635
|
+
redundancy
|
|
1636
|
+
};
|
|
1637
|
+
redundancyCache[provider] = cachedReundancy;
|
|
1638
|
+
}
|
|
1639
|
+
return redundancyCache[provider];
|
|
1640
|
+
}
|
|
1641
|
+
function sendAPIQuery(target, query, callback) {
|
|
1642
|
+
let redundancy;
|
|
1643
|
+
let send2;
|
|
1644
|
+
if (typeof target === "string") {
|
|
1645
|
+
const api = getAPIModule(target);
|
|
1646
|
+
if (!api) {
|
|
1647
|
+
callback(void 0, 424);
|
|
1648
|
+
return emptyCallback$1;
|
|
1649
|
+
}
|
|
1650
|
+
send2 = api.send;
|
|
1651
|
+
const cached = getRedundancyCache(target);
|
|
1652
|
+
if (cached) {
|
|
1653
|
+
redundancy = cached.redundancy;
|
|
1654
|
+
}
|
|
1655
|
+
} else {
|
|
1656
|
+
const config = createAPIConfig(target);
|
|
1657
|
+
if (config) {
|
|
1658
|
+
redundancy = initRedundancy(config);
|
|
1659
|
+
const moduleKey = target.resources ? target.resources[0] : "";
|
|
1660
|
+
const api = getAPIModule(moduleKey);
|
|
1661
|
+
if (api) {
|
|
1662
|
+
send2 = api.send;
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
if (!redundancy || !send2) {
|
|
1667
|
+
callback(void 0, 424);
|
|
1668
|
+
return emptyCallback$1;
|
|
1669
|
+
}
|
|
1670
|
+
return redundancy.query(query, send2, callback)().abort;
|
|
1671
|
+
}
|
|
1672
|
+
var browserCacheVersion = "iconify2";
|
|
1673
|
+
var browserCachePrefix = "iconify";
|
|
1674
|
+
var browserCacheCountKey = browserCachePrefix + "-count";
|
|
1675
|
+
var browserCacheVersionKey = browserCachePrefix + "-version";
|
|
1676
|
+
var browserStorageHour = 36e5;
|
|
1677
|
+
var browserStorageCacheExpiration = 168;
|
|
1678
|
+
function getStoredItem(func, key) {
|
|
1679
|
+
try {
|
|
1680
|
+
return func.getItem(key);
|
|
1681
|
+
} catch (err) {}
|
|
1682
|
+
}
|
|
1683
|
+
function setStoredItem(func, key, value) {
|
|
1684
|
+
try {
|
|
1685
|
+
func.setItem(key, value);
|
|
1686
|
+
return true;
|
|
1687
|
+
} catch (err) {}
|
|
1688
|
+
}
|
|
1689
|
+
function removeStoredItem(func, key) {
|
|
1690
|
+
try {
|
|
1691
|
+
func.removeItem(key);
|
|
1692
|
+
} catch (err) {}
|
|
1693
|
+
}
|
|
1694
|
+
function setBrowserStorageItemsCount(storage2, value) {
|
|
1695
|
+
return setStoredItem(storage2, browserCacheCountKey, value.toString());
|
|
1696
|
+
}
|
|
1697
|
+
function getBrowserStorageItemsCount(storage2) {
|
|
1698
|
+
return parseInt(getStoredItem(storage2, browserCacheCountKey)) || 0;
|
|
1699
|
+
}
|
|
1700
|
+
var browserStorageConfig = {
|
|
1701
|
+
local: true,
|
|
1702
|
+
session: true
|
|
1703
|
+
};
|
|
1704
|
+
var browserStorageEmptyItems = {
|
|
1705
|
+
local: /* @__PURE__ */new Set(),
|
|
1706
|
+
session: /* @__PURE__ */new Set()
|
|
1707
|
+
};
|
|
1708
|
+
var browserStorageStatus = false;
|
|
1709
|
+
function setBrowserStorageStatus(status) {
|
|
1710
|
+
browserStorageStatus = status;
|
|
1711
|
+
}
|
|
1712
|
+
var _window = typeof window === "undefined" ? {} : window;
|
|
1713
|
+
function getBrowserStorage(key) {
|
|
1714
|
+
const attr = key + "Storage";
|
|
1715
|
+
try {
|
|
1716
|
+
if (_window && _window[attr] && typeof _window[attr].length === "number") {
|
|
1717
|
+
return _window[attr];
|
|
1718
|
+
}
|
|
1719
|
+
} catch (err) {}
|
|
1720
|
+
browserStorageConfig[key] = false;
|
|
1721
|
+
}
|
|
1722
|
+
function iterateBrowserStorage(key, callback) {
|
|
1723
|
+
const func = getBrowserStorage(key);
|
|
1724
|
+
if (!func) {
|
|
1725
|
+
return;
|
|
1726
|
+
}
|
|
1727
|
+
const version = getStoredItem(func, browserCacheVersionKey);
|
|
1728
|
+
if (version !== browserCacheVersion) {
|
|
1729
|
+
if (version) {
|
|
1730
|
+
const total2 = getBrowserStorageItemsCount(func);
|
|
1731
|
+
for (let i = 0; i < total2; i++) {
|
|
1732
|
+
removeStoredItem(func, browserCachePrefix + i.toString());
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
setStoredItem(func, browserCacheVersionKey, browserCacheVersion);
|
|
1736
|
+
setBrowserStorageItemsCount(func, 0);
|
|
1737
|
+
return;
|
|
1738
|
+
}
|
|
1739
|
+
const minTime = Math.floor(Date.now() / browserStorageHour) - browserStorageCacheExpiration;
|
|
1740
|
+
const parseItem = index => {
|
|
1741
|
+
const name = browserCachePrefix + index.toString();
|
|
1742
|
+
const item = getStoredItem(func, name);
|
|
1743
|
+
if (typeof item !== "string") {
|
|
1744
|
+
return;
|
|
1745
|
+
}
|
|
1746
|
+
try {
|
|
1747
|
+
const data = JSON.parse(item);
|
|
1748
|
+
if (typeof data === "object" && typeof data.cached === "number" && data.cached > minTime && typeof data.provider === "string" && typeof data.data === "object" && typeof data.data.prefix === "string" &&
|
|
1749
|
+
// Valid item: run callback
|
|
1750
|
+
callback(data, index)) {
|
|
1751
|
+
return true;
|
|
1752
|
+
}
|
|
1753
|
+
} catch (err) {}
|
|
1754
|
+
removeStoredItem(func, name);
|
|
1755
|
+
};
|
|
1756
|
+
let total = getBrowserStorageItemsCount(func);
|
|
1757
|
+
for (let i = total - 1; i >= 0; i--) {
|
|
1758
|
+
if (!parseItem(i)) {
|
|
1759
|
+
if (i === total - 1) {
|
|
1760
|
+
total--;
|
|
1761
|
+
setBrowserStorageItemsCount(func, total);
|
|
1762
|
+
} else {
|
|
1763
|
+
browserStorageEmptyItems[key].add(i);
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
function initBrowserStorage() {
|
|
1769
|
+
if (browserStorageStatus) {
|
|
1770
|
+
return;
|
|
1771
|
+
}
|
|
1772
|
+
setBrowserStorageStatus(true);
|
|
1773
|
+
for (const key in browserStorageConfig) {
|
|
1774
|
+
iterateBrowserStorage(key, item => {
|
|
1775
|
+
const iconSet = item.data;
|
|
1776
|
+
const provider = item.provider;
|
|
1777
|
+
const prefix = iconSet.prefix;
|
|
1778
|
+
const storage2 = getStorage(provider, prefix);
|
|
1779
|
+
if (!addIconSet(storage2, iconSet).length) {
|
|
1780
|
+
return false;
|
|
1781
|
+
}
|
|
1782
|
+
const lastModified = iconSet.lastModified || -1;
|
|
1783
|
+
storage2.lastModifiedCached = storage2.lastModifiedCached ? Math.min(storage2.lastModifiedCached, lastModified) : lastModified;
|
|
1784
|
+
return true;
|
|
1785
|
+
});
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
function updateLastModified(storage2, lastModified) {
|
|
1789
|
+
const lastValue = storage2.lastModifiedCached;
|
|
1790
|
+
if (
|
|
1791
|
+
// Matches or newer
|
|
1792
|
+
lastValue && lastValue >= lastModified) {
|
|
1793
|
+
return lastValue === lastModified;
|
|
1794
|
+
}
|
|
1795
|
+
storage2.lastModifiedCached = lastModified;
|
|
1796
|
+
if (lastValue) {
|
|
1797
|
+
for (const key in browserStorageConfig) {
|
|
1798
|
+
iterateBrowserStorage(key, item => {
|
|
1799
|
+
const iconSet = item.data;
|
|
1800
|
+
return item.provider !== storage2.provider || iconSet.prefix !== storage2.prefix || iconSet.lastModified === lastModified;
|
|
1801
|
+
});
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
return true;
|
|
1805
|
+
}
|
|
1806
|
+
function storeInBrowserStorage(storage2, data) {
|
|
1807
|
+
if (!browserStorageStatus) {
|
|
1808
|
+
initBrowserStorage();
|
|
1809
|
+
}
|
|
1810
|
+
function store(key) {
|
|
1811
|
+
let func;
|
|
1812
|
+
if (!browserStorageConfig[key] || !(func = getBrowserStorage(key))) {
|
|
1813
|
+
return;
|
|
1814
|
+
}
|
|
1815
|
+
const set = browserStorageEmptyItems[key];
|
|
1816
|
+
let index;
|
|
1817
|
+
if (set.size) {
|
|
1818
|
+
set.delete(index = Array.from(set).shift());
|
|
1819
|
+
} else {
|
|
1820
|
+
index = getBrowserStorageItemsCount(func);
|
|
1821
|
+
if (!setBrowserStorageItemsCount(func, index + 1)) {
|
|
1822
|
+
return;
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
const item = {
|
|
1826
|
+
cached: Math.floor(Date.now() / browserStorageHour),
|
|
1827
|
+
provider: storage2.provider,
|
|
1828
|
+
data
|
|
1829
|
+
};
|
|
1830
|
+
return setStoredItem(func, browserCachePrefix + index.toString(), JSON.stringify(item));
|
|
1831
|
+
}
|
|
1832
|
+
if (data.lastModified && !updateLastModified(storage2, data.lastModified)) {
|
|
1833
|
+
return;
|
|
1834
|
+
}
|
|
1835
|
+
if (!Object.keys(data.icons).length) {
|
|
1836
|
+
return;
|
|
1837
|
+
}
|
|
1838
|
+
if (data.not_found) {
|
|
1839
|
+
data = Object.assign({}, data);
|
|
1840
|
+
delete data.not_found;
|
|
1841
|
+
}
|
|
1842
|
+
if (!store("local")) {
|
|
1843
|
+
store("session");
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
function emptyCallback() {}
|
|
1847
|
+
function loadedNewIcons(storage2) {
|
|
1848
|
+
if (!storage2.iconsLoaderFlag) {
|
|
1849
|
+
storage2.iconsLoaderFlag = true;
|
|
1850
|
+
setTimeout(() => {
|
|
1851
|
+
storage2.iconsLoaderFlag = false;
|
|
1852
|
+
updateCallbacks(storage2);
|
|
1853
|
+
});
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1856
|
+
function loadNewIcons(storage2, icons) {
|
|
1857
|
+
if (!storage2.iconsToLoad) {
|
|
1858
|
+
storage2.iconsToLoad = icons;
|
|
1859
|
+
} else {
|
|
1860
|
+
storage2.iconsToLoad = storage2.iconsToLoad.concat(icons).sort();
|
|
1861
|
+
}
|
|
1862
|
+
if (!storage2.iconsQueueFlag) {
|
|
1863
|
+
storage2.iconsQueueFlag = true;
|
|
1864
|
+
setTimeout(() => {
|
|
1865
|
+
storage2.iconsQueueFlag = false;
|
|
1866
|
+
const {
|
|
1867
|
+
provider,
|
|
1868
|
+
prefix
|
|
1869
|
+
} = storage2;
|
|
1870
|
+
const icons2 = storage2.iconsToLoad;
|
|
1871
|
+
delete storage2.iconsToLoad;
|
|
1872
|
+
let api;
|
|
1873
|
+
if (!icons2 || !(api = getAPIModule(provider))) {
|
|
1874
|
+
return;
|
|
1875
|
+
}
|
|
1876
|
+
const params = api.prepare(provider, prefix, icons2);
|
|
1877
|
+
params.forEach(item => {
|
|
1878
|
+
sendAPIQuery(provider, item, data => {
|
|
1879
|
+
if (typeof data !== "object") {
|
|
1880
|
+
item.icons.forEach(name => {
|
|
1881
|
+
storage2.missing.add(name);
|
|
1882
|
+
});
|
|
1883
|
+
} else {
|
|
1884
|
+
try {
|
|
1885
|
+
const parsed = addIconSet(storage2, data);
|
|
1886
|
+
if (!parsed.length) {
|
|
1887
|
+
return;
|
|
1888
|
+
}
|
|
1889
|
+
const pending = storage2.pendingIcons;
|
|
1890
|
+
if (pending) {
|
|
1891
|
+
parsed.forEach(name => {
|
|
1892
|
+
pending.delete(name);
|
|
1893
|
+
});
|
|
1894
|
+
}
|
|
1895
|
+
storeInBrowserStorage(storage2, data);
|
|
1896
|
+
} catch (err) {
|
|
1897
|
+
console.error(err);
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
loadedNewIcons(storage2);
|
|
1901
|
+
});
|
|
1902
|
+
});
|
|
1903
|
+
});
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
var loadIcons$1 = (icons, callback) => {
|
|
1907
|
+
const cleanedIcons = listToIcons(icons, true, allowSimpleNames());
|
|
1908
|
+
const sortedIcons = sortIcons(cleanedIcons);
|
|
1909
|
+
if (!sortedIcons.pending.length) {
|
|
1910
|
+
let callCallback = true;
|
|
1911
|
+
if (callback) {
|
|
1912
|
+
setTimeout(() => {
|
|
1913
|
+
if (callCallback) {
|
|
1914
|
+
callback(sortedIcons.loaded, sortedIcons.missing, sortedIcons.pending, emptyCallback);
|
|
1915
|
+
}
|
|
1916
|
+
});
|
|
1917
|
+
}
|
|
1918
|
+
return () => {
|
|
1919
|
+
callCallback = false;
|
|
1920
|
+
};
|
|
1921
|
+
}
|
|
1922
|
+
const newIcons = /* @__PURE__ */Object.create(null);
|
|
1923
|
+
const sources = [];
|
|
1924
|
+
let lastProvider, lastPrefix;
|
|
1925
|
+
sortedIcons.pending.forEach(icon => {
|
|
1926
|
+
const {
|
|
1927
|
+
provider,
|
|
1928
|
+
prefix
|
|
1929
|
+
} = icon;
|
|
1930
|
+
if (prefix === lastPrefix && provider === lastProvider) {
|
|
1931
|
+
return;
|
|
1932
|
+
}
|
|
1933
|
+
lastProvider = provider;
|
|
1934
|
+
lastPrefix = prefix;
|
|
1935
|
+
sources.push(getStorage(provider, prefix));
|
|
1936
|
+
const providerNewIcons = newIcons[provider] || (newIcons[provider] = /* @__PURE__ */Object.create(null));
|
|
1937
|
+
if (!providerNewIcons[prefix]) {
|
|
1938
|
+
providerNewIcons[prefix] = [];
|
|
1939
|
+
}
|
|
1940
|
+
});
|
|
1941
|
+
sortedIcons.pending.forEach(icon => {
|
|
1942
|
+
const {
|
|
1943
|
+
provider,
|
|
1944
|
+
prefix,
|
|
1945
|
+
name
|
|
1946
|
+
} = icon;
|
|
1947
|
+
const storage2 = getStorage(provider, prefix);
|
|
1948
|
+
const pendingQueue = storage2.pendingIcons || (storage2.pendingIcons = /* @__PURE__ */new Set());
|
|
1949
|
+
if (!pendingQueue.has(name)) {
|
|
1950
|
+
pendingQueue.add(name);
|
|
1951
|
+
newIcons[provider][prefix].push(name);
|
|
1952
|
+
}
|
|
1953
|
+
});
|
|
1954
|
+
sources.forEach(storage2 => {
|
|
1955
|
+
const {
|
|
1956
|
+
provider,
|
|
1957
|
+
prefix
|
|
1958
|
+
} = storage2;
|
|
1959
|
+
if (newIcons[provider][prefix].length) {
|
|
1960
|
+
loadNewIcons(storage2, newIcons[provider][prefix]);
|
|
1961
|
+
}
|
|
1962
|
+
});
|
|
1963
|
+
return callback ? storeCallback(callback, sortedIcons, sources) : emptyCallback;
|
|
1964
|
+
};
|
|
1965
|
+
var loadIcon$1 = icon => {
|
|
1966
|
+
return new Promise((fulfill, reject) => {
|
|
1967
|
+
const iconObj = typeof icon === "string" ? stringToIcon(icon, true) : icon;
|
|
1968
|
+
if (!iconObj) {
|
|
1969
|
+
reject(icon);
|
|
1970
|
+
return;
|
|
1971
|
+
}
|
|
1972
|
+
loadIcons$1([iconObj || icon], loaded => {
|
|
1973
|
+
if (loaded.length && iconObj) {
|
|
1974
|
+
const data = getIconData(iconObj);
|
|
1975
|
+
if (data) {
|
|
1976
|
+
fulfill({
|
|
1977
|
+
...defaultIconProps,
|
|
1978
|
+
...data
|
|
1979
|
+
});
|
|
1980
|
+
return;
|
|
1981
|
+
}
|
|
1982
|
+
}
|
|
1983
|
+
reject(icon);
|
|
1984
|
+
});
|
|
1985
|
+
});
|
|
1986
|
+
};
|
|
1987
|
+
function testIconObject(value) {
|
|
1988
|
+
try {
|
|
1989
|
+
const obj = typeof value === "string" ? JSON.parse(value) : value;
|
|
1990
|
+
if (typeof obj.body === "string") {
|
|
1991
|
+
return {
|
|
1992
|
+
...obj
|
|
1993
|
+
};
|
|
1994
|
+
}
|
|
1995
|
+
} catch (err) {}
|
|
1996
|
+
}
|
|
1997
|
+
function parseIconValue(value, onload) {
|
|
1998
|
+
const name = typeof value === "string" ? stringToIcon(value, true, true) : null;
|
|
1999
|
+
if (!name) {
|
|
2000
|
+
const data2 = testIconObject(value);
|
|
2001
|
+
return {
|
|
2002
|
+
value,
|
|
2003
|
+
data: data2
|
|
2004
|
+
};
|
|
2005
|
+
}
|
|
2006
|
+
const data = getIconData(name);
|
|
2007
|
+
if (data !== void 0 || !name.prefix) {
|
|
2008
|
+
return {
|
|
2009
|
+
value,
|
|
2010
|
+
name,
|
|
2011
|
+
data
|
|
2012
|
+
// could be 'null' -> icon is missing
|
|
2013
|
+
};
|
|
2014
|
+
}
|
|
2015
|
+
|
|
2016
|
+
const loading = loadIcons$1([name], () => onload(value, name, getIconData(name)));
|
|
2017
|
+
return {
|
|
2018
|
+
value,
|
|
2019
|
+
name,
|
|
2020
|
+
loading
|
|
2021
|
+
};
|
|
2022
|
+
}
|
|
2023
|
+
function getInline(node) {
|
|
2024
|
+
return node.hasAttribute("inline");
|
|
2025
|
+
}
|
|
2026
|
+
var isBuggedSafari = false;
|
|
2027
|
+
try {
|
|
2028
|
+
isBuggedSafari = navigator.vendor.indexOf("Apple") === 0;
|
|
2029
|
+
} catch (err) {}
|
|
2030
|
+
function getRenderMode(body, mode) {
|
|
2031
|
+
switch (mode) {
|
|
2032
|
+
case "svg":
|
|
2033
|
+
case "bg":
|
|
2034
|
+
case "mask":
|
|
2035
|
+
return mode;
|
|
2036
|
+
}
|
|
2037
|
+
if (mode !== "style" && (isBuggedSafari || body.indexOf("<a") === -1)) {
|
|
2038
|
+
return "svg";
|
|
2039
|
+
}
|
|
2040
|
+
return body.indexOf("currentColor") === -1 ? "bg" : "mask";
|
|
2041
|
+
}
|
|
2042
|
+
var unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g;
|
|
2043
|
+
var unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g;
|
|
2044
|
+
function calculateSize$1(size, ratio, precision) {
|
|
2045
|
+
if (ratio === 1) {
|
|
2046
|
+
return size;
|
|
2047
|
+
}
|
|
2048
|
+
precision = precision || 100;
|
|
2049
|
+
if (typeof size === "number") {
|
|
2050
|
+
return Math.ceil(size * ratio * precision) / precision;
|
|
2051
|
+
}
|
|
2052
|
+
if (typeof size !== "string") {
|
|
2053
|
+
return size;
|
|
2054
|
+
}
|
|
2055
|
+
const oldParts = size.split(unitsSplit);
|
|
2056
|
+
if (oldParts === null || !oldParts.length) {
|
|
2057
|
+
return size;
|
|
2058
|
+
}
|
|
2059
|
+
const newParts = [];
|
|
2060
|
+
let code = oldParts.shift();
|
|
2061
|
+
let isNumber = unitsTest.test(code);
|
|
2062
|
+
while (true) {
|
|
2063
|
+
if (isNumber) {
|
|
2064
|
+
const num = parseFloat(code);
|
|
2065
|
+
if (isNaN(num)) {
|
|
2066
|
+
newParts.push(code);
|
|
2067
|
+
} else {
|
|
2068
|
+
newParts.push(Math.ceil(num * ratio * precision) / precision);
|
|
2069
|
+
}
|
|
2070
|
+
} else {
|
|
2071
|
+
newParts.push(code);
|
|
2072
|
+
}
|
|
2073
|
+
code = oldParts.shift();
|
|
2074
|
+
if (code === void 0) {
|
|
2075
|
+
return newParts.join("");
|
|
2076
|
+
}
|
|
2077
|
+
isNumber = !isNumber;
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
var isUnsetKeyword = value => value === "unset" || value === "undefined" || value === "none";
|
|
2081
|
+
function iconToSVG(icon, customisations) {
|
|
2082
|
+
const fullIcon = {
|
|
2083
|
+
...defaultIconProps,
|
|
2084
|
+
...icon
|
|
2085
|
+
};
|
|
2086
|
+
const fullCustomisations = {
|
|
2087
|
+
...defaultIconCustomisations,
|
|
2088
|
+
...customisations
|
|
2089
|
+
};
|
|
2090
|
+
const box = {
|
|
2091
|
+
left: fullIcon.left,
|
|
2092
|
+
top: fullIcon.top,
|
|
2093
|
+
width: fullIcon.width,
|
|
2094
|
+
height: fullIcon.height
|
|
2095
|
+
};
|
|
2096
|
+
let body = fullIcon.body;
|
|
2097
|
+
[fullIcon, fullCustomisations].forEach(props => {
|
|
2098
|
+
const transformations = [];
|
|
2099
|
+
const hFlip = props.hFlip;
|
|
2100
|
+
const vFlip = props.vFlip;
|
|
2101
|
+
let rotation = props.rotate;
|
|
2102
|
+
if (hFlip) {
|
|
2103
|
+
if (vFlip) {
|
|
2104
|
+
rotation += 2;
|
|
2105
|
+
} else {
|
|
2106
|
+
transformations.push("translate(" + (box.width + box.left).toString() + " " + (0 - box.top).toString() + ")");
|
|
2107
|
+
transformations.push("scale(-1 1)");
|
|
2108
|
+
box.top = box.left = 0;
|
|
2109
|
+
}
|
|
2110
|
+
} else if (vFlip) {
|
|
2111
|
+
transformations.push("translate(" + (0 - box.left).toString() + " " + (box.height + box.top).toString() + ")");
|
|
2112
|
+
transformations.push("scale(1 -1)");
|
|
2113
|
+
box.top = box.left = 0;
|
|
2114
|
+
}
|
|
2115
|
+
let tempValue;
|
|
2116
|
+
if (rotation < 0) {
|
|
2117
|
+
rotation -= Math.floor(rotation / 4) * 4;
|
|
2118
|
+
}
|
|
2119
|
+
rotation = rotation % 4;
|
|
2120
|
+
switch (rotation) {
|
|
2121
|
+
case 1:
|
|
2122
|
+
tempValue = box.height / 2 + box.top;
|
|
2123
|
+
transformations.unshift("rotate(90 " + tempValue.toString() + " " + tempValue.toString() + ")");
|
|
2124
|
+
break;
|
|
2125
|
+
case 2:
|
|
2126
|
+
transformations.unshift("rotate(180 " + (box.width / 2 + box.left).toString() + " " + (box.height / 2 + box.top).toString() + ")");
|
|
2127
|
+
break;
|
|
2128
|
+
case 3:
|
|
2129
|
+
tempValue = box.width / 2 + box.left;
|
|
2130
|
+
transformations.unshift("rotate(-90 " + tempValue.toString() + " " + tempValue.toString() + ")");
|
|
2131
|
+
break;
|
|
2132
|
+
}
|
|
2133
|
+
if (rotation % 2 === 1) {
|
|
2134
|
+
if (box.left !== box.top) {
|
|
2135
|
+
tempValue = box.left;
|
|
2136
|
+
box.left = box.top;
|
|
2137
|
+
box.top = tempValue;
|
|
2138
|
+
}
|
|
2139
|
+
if (box.width !== box.height) {
|
|
2140
|
+
tempValue = box.width;
|
|
2141
|
+
box.width = box.height;
|
|
2142
|
+
box.height = tempValue;
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2145
|
+
if (transformations.length) {
|
|
2146
|
+
body = '<g transform="' + transformations.join(" ") + '">' + body + "</g>";
|
|
2147
|
+
}
|
|
2148
|
+
});
|
|
2149
|
+
const customisationsWidth = fullCustomisations.width;
|
|
2150
|
+
const customisationsHeight = fullCustomisations.height;
|
|
2151
|
+
const boxWidth = box.width;
|
|
2152
|
+
const boxHeight = box.height;
|
|
2153
|
+
let width;
|
|
2154
|
+
let height;
|
|
2155
|
+
if (customisationsWidth === null) {
|
|
2156
|
+
height = customisationsHeight === null ? "1em" : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
|
|
2157
|
+
width = calculateSize$1(height, boxWidth / boxHeight);
|
|
2158
|
+
} else {
|
|
2159
|
+
width = customisationsWidth === "auto" ? boxWidth : customisationsWidth;
|
|
2160
|
+
height = customisationsHeight === null ? calculateSize$1(width, boxHeight / boxWidth) : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
|
|
2161
|
+
}
|
|
2162
|
+
const attributes = {};
|
|
2163
|
+
const setAttr = (prop, value) => {
|
|
2164
|
+
if (!isUnsetKeyword(value)) {
|
|
2165
|
+
attributes[prop] = value.toString();
|
|
2166
|
+
}
|
|
2167
|
+
};
|
|
2168
|
+
setAttr("width", width);
|
|
2169
|
+
setAttr("height", height);
|
|
2170
|
+
attributes.viewBox = box.left.toString() + " " + box.top.toString() + " " + boxWidth.toString() + " " + boxHeight.toString();
|
|
2171
|
+
return {
|
|
2172
|
+
attributes,
|
|
2173
|
+
body
|
|
2174
|
+
};
|
|
2175
|
+
}
|
|
2176
|
+
var detectFetch = () => {
|
|
2177
|
+
let callback;
|
|
2178
|
+
try {
|
|
2179
|
+
callback = fetch;
|
|
2180
|
+
if (typeof callback === "function") {
|
|
2181
|
+
return callback;
|
|
2182
|
+
}
|
|
2183
|
+
} catch (err) {}
|
|
2184
|
+
};
|
|
2185
|
+
var fetchModule = detectFetch();
|
|
2186
|
+
function setFetch(fetch2) {
|
|
2187
|
+
fetchModule = fetch2;
|
|
2188
|
+
}
|
|
2189
|
+
function getFetch() {
|
|
2190
|
+
return fetchModule;
|
|
2191
|
+
}
|
|
2192
|
+
function calculateMaxLength(provider, prefix) {
|
|
2193
|
+
const config = getAPIConfig(provider);
|
|
2194
|
+
if (!config) {
|
|
2195
|
+
return 0;
|
|
2196
|
+
}
|
|
2197
|
+
let result;
|
|
2198
|
+
if (!config.maxURL) {
|
|
2199
|
+
result = 0;
|
|
2200
|
+
} else {
|
|
2201
|
+
let maxHostLength = 0;
|
|
2202
|
+
config.resources.forEach(item => {
|
|
2203
|
+
const host = item;
|
|
2204
|
+
maxHostLength = Math.max(maxHostLength, host.length);
|
|
2205
|
+
});
|
|
2206
|
+
const url = prefix + ".json?icons=";
|
|
2207
|
+
result = config.maxURL - maxHostLength - config.path.length - url.length;
|
|
2208
|
+
}
|
|
2209
|
+
return result;
|
|
2210
|
+
}
|
|
2211
|
+
function shouldAbort(status) {
|
|
2212
|
+
return status === 404;
|
|
2213
|
+
}
|
|
2214
|
+
var prepare = (provider, prefix, icons) => {
|
|
2215
|
+
const results = [];
|
|
2216
|
+
const maxLength = calculateMaxLength(provider, prefix);
|
|
2217
|
+
const type = "icons";
|
|
2218
|
+
let item = {
|
|
2219
|
+
type,
|
|
2220
|
+
provider,
|
|
2221
|
+
prefix,
|
|
2222
|
+
icons: []
|
|
2223
|
+
};
|
|
2224
|
+
let length = 0;
|
|
2225
|
+
icons.forEach((name, index) => {
|
|
2226
|
+
length += name.length + 1;
|
|
2227
|
+
if (length >= maxLength && index > 0) {
|
|
2228
|
+
results.push(item);
|
|
2229
|
+
item = {
|
|
2230
|
+
type,
|
|
2231
|
+
provider,
|
|
2232
|
+
prefix,
|
|
2233
|
+
icons: []
|
|
2234
|
+
};
|
|
2235
|
+
length = name.length;
|
|
2236
|
+
}
|
|
2237
|
+
item.icons.push(name);
|
|
2238
|
+
});
|
|
2239
|
+
results.push(item);
|
|
2240
|
+
return results;
|
|
2241
|
+
};
|
|
2242
|
+
function getPath(provider) {
|
|
2243
|
+
if (typeof provider === "string") {
|
|
2244
|
+
const config = getAPIConfig(provider);
|
|
2245
|
+
if (config) {
|
|
2246
|
+
return config.path;
|
|
2247
|
+
}
|
|
2248
|
+
}
|
|
2249
|
+
return "/";
|
|
2250
|
+
}
|
|
2251
|
+
var send = (host, params, callback) => {
|
|
2252
|
+
if (!fetchModule) {
|
|
2253
|
+
callback("abort", 424);
|
|
2254
|
+
return;
|
|
2255
|
+
}
|
|
2256
|
+
let path = getPath(params.provider);
|
|
2257
|
+
switch (params.type) {
|
|
2258
|
+
case "icons":
|
|
2259
|
+
{
|
|
2260
|
+
const prefix = params.prefix;
|
|
2261
|
+
const icons = params.icons;
|
|
2262
|
+
const iconsList = icons.join(",");
|
|
2263
|
+
const urlParams = new URLSearchParams({
|
|
2264
|
+
icons: iconsList
|
|
2265
|
+
});
|
|
2266
|
+
path += prefix + ".json?" + urlParams.toString();
|
|
2267
|
+
break;
|
|
2268
|
+
}
|
|
2269
|
+
case "custom":
|
|
2270
|
+
{
|
|
2271
|
+
const uri = params.uri;
|
|
2272
|
+
path += uri.slice(0, 1) === "/" ? uri.slice(1) : uri;
|
|
2273
|
+
break;
|
|
2274
|
+
}
|
|
2275
|
+
default:
|
|
2276
|
+
callback("abort", 400);
|
|
2277
|
+
return;
|
|
2278
|
+
}
|
|
2279
|
+
let defaultError = 503;
|
|
2280
|
+
fetchModule(host + path).then(response => {
|
|
2281
|
+
const status = response.status;
|
|
2282
|
+
if (status !== 200) {
|
|
2283
|
+
setTimeout(() => {
|
|
2284
|
+
callback(shouldAbort(status) ? "abort" : "next", status);
|
|
2285
|
+
});
|
|
2286
|
+
return;
|
|
2287
|
+
}
|
|
2288
|
+
defaultError = 501;
|
|
2289
|
+
return response.json();
|
|
2290
|
+
}).then(data => {
|
|
2291
|
+
if (typeof data !== "object" || data === null) {
|
|
2292
|
+
setTimeout(() => {
|
|
2293
|
+
if (data === 404) {
|
|
2294
|
+
callback("abort", data);
|
|
2295
|
+
} else {
|
|
2296
|
+
callback("next", defaultError);
|
|
2297
|
+
}
|
|
2298
|
+
});
|
|
2299
|
+
return;
|
|
2300
|
+
}
|
|
2301
|
+
setTimeout(() => {
|
|
2302
|
+
callback("success", data);
|
|
2303
|
+
});
|
|
2304
|
+
}).catch(() => {
|
|
2305
|
+
callback("next", defaultError);
|
|
2306
|
+
});
|
|
2307
|
+
};
|
|
2308
|
+
var fetchAPIModule = {
|
|
2309
|
+
prepare,
|
|
2310
|
+
send
|
|
2311
|
+
};
|
|
2312
|
+
function toggleBrowserCache(storage2, value) {
|
|
2313
|
+
switch (storage2) {
|
|
2314
|
+
case "local":
|
|
2315
|
+
case "session":
|
|
2316
|
+
browserStorageConfig[storage2] = value;
|
|
2317
|
+
break;
|
|
2318
|
+
case "all":
|
|
2319
|
+
for (const key in browserStorageConfig) {
|
|
2320
|
+
browserStorageConfig[key] = value;
|
|
2321
|
+
}
|
|
2322
|
+
break;
|
|
2323
|
+
}
|
|
2324
|
+
}
|
|
2325
|
+
var nodeAttr = "data-style";
|
|
2326
|
+
var customStyle = "";
|
|
2327
|
+
function appendCustomStyle(style) {
|
|
2328
|
+
customStyle = style;
|
|
2329
|
+
}
|
|
2330
|
+
function updateStyle(parent, inline) {
|
|
2331
|
+
let styleNode = Array.from(parent.childNodes).find(node => node.hasAttribute && node.hasAttribute(nodeAttr));
|
|
2332
|
+
if (!styleNode) {
|
|
2333
|
+
styleNode = document.createElement("style");
|
|
2334
|
+
styleNode.setAttribute(nodeAttr, nodeAttr);
|
|
2335
|
+
parent.appendChild(styleNode);
|
|
2336
|
+
}
|
|
2337
|
+
styleNode.textContent = ":host{display:inline-block;vertical-align:" + (inline ? "-0.125em" : "0") + "}span,svg{display:block}" + customStyle;
|
|
2338
|
+
}
|
|
2339
|
+
function exportFunctions() {
|
|
2340
|
+
setAPIModule("", fetchAPIModule);
|
|
2341
|
+
allowSimpleNames(true);
|
|
2342
|
+
let _window2;
|
|
2343
|
+
try {
|
|
2344
|
+
_window2 = window;
|
|
2345
|
+
} catch (err) {}
|
|
2346
|
+
if (_window2) {
|
|
2347
|
+
initBrowserStorage();
|
|
2348
|
+
if (_window2.IconifyPreload !== void 0) {
|
|
2349
|
+
const preload = _window2.IconifyPreload;
|
|
2350
|
+
const err = "Invalid IconifyPreload syntax.";
|
|
2351
|
+
if (typeof preload === "object" && preload !== null) {
|
|
2352
|
+
(preload instanceof Array ? preload : [preload]).forEach(item => {
|
|
2353
|
+
try {
|
|
2354
|
+
if (
|
|
2355
|
+
// Check if item is an object and not null/array
|
|
2356
|
+
typeof item !== "object" || item === null || item instanceof Array ||
|
|
2357
|
+
// Check for 'icons' and 'prefix'
|
|
2358
|
+
typeof item.icons !== "object" || typeof item.prefix !== "string" ||
|
|
2359
|
+
// Add icon set
|
|
2360
|
+
!addCollection$1(item)) {
|
|
2361
|
+
console.error(err);
|
|
2362
|
+
}
|
|
2363
|
+
} catch (e) {
|
|
2364
|
+
console.error(err);
|
|
2365
|
+
}
|
|
2366
|
+
});
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2369
|
+
if (_window2.IconifyProviders !== void 0) {
|
|
2370
|
+
const providers = _window2.IconifyProviders;
|
|
2371
|
+
if (typeof providers === "object" && providers !== null) {
|
|
2372
|
+
for (const key in providers) {
|
|
2373
|
+
const err = "IconifyProviders[" + key + "] is invalid.";
|
|
2374
|
+
try {
|
|
2375
|
+
const value = providers[key];
|
|
2376
|
+
if (typeof value !== "object" || !value || value.resources === void 0) {
|
|
2377
|
+
continue;
|
|
2378
|
+
}
|
|
2379
|
+
if (!addAPIProvider$1(key, value)) {
|
|
2380
|
+
console.error(err);
|
|
2381
|
+
}
|
|
2382
|
+
} catch (e) {
|
|
2383
|
+
console.error(err);
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
}
|
|
2387
|
+
}
|
|
2388
|
+
}
|
|
2389
|
+
const _api2 = {
|
|
2390
|
+
getAPIConfig,
|
|
2391
|
+
setAPIModule,
|
|
2392
|
+
sendAPIQuery,
|
|
2393
|
+
setFetch,
|
|
2394
|
+
getFetch,
|
|
2395
|
+
listAPIProviders
|
|
2396
|
+
};
|
|
2397
|
+
return {
|
|
2398
|
+
enableCache: storage2 => toggleBrowserCache(storage2, true),
|
|
2399
|
+
disableCache: storage2 => toggleBrowserCache(storage2, false),
|
|
2400
|
+
iconExists: iconExists$1,
|
|
2401
|
+
getIcon: getIcon$1,
|
|
2402
|
+
listIcons: listIcons$1,
|
|
2403
|
+
addIcon: addIcon$1,
|
|
2404
|
+
addCollection: addCollection$1,
|
|
2405
|
+
calculateSize: calculateSize$1,
|
|
2406
|
+
buildIcon: iconToSVG,
|
|
2407
|
+
loadIcons: loadIcons$1,
|
|
2408
|
+
loadIcon: loadIcon$1,
|
|
2409
|
+
addAPIProvider: addAPIProvider$1,
|
|
2410
|
+
appendCustomStyle,
|
|
2411
|
+
_api: _api2
|
|
2412
|
+
};
|
|
2413
|
+
}
|
|
2414
|
+
function iconToHTML(body, attributes) {
|
|
2415
|
+
let renderAttribsHTML = body.indexOf("xlink:") === -1 ? "" : ' xmlns:xlink="http://www.w3.org/1999/xlink"';
|
|
2416
|
+
for (const attr in attributes) {
|
|
2417
|
+
renderAttribsHTML += " " + attr + '="' + attributes[attr] + '"';
|
|
2418
|
+
}
|
|
2419
|
+
return '<svg xmlns="http://www.w3.org/2000/svg"' + renderAttribsHTML + ">" + body + "</svg>";
|
|
2420
|
+
}
|
|
2421
|
+
function encodeSVGforURL(svg) {
|
|
2422
|
+
return svg.replace(/"/g, "'").replace(/%/g, "%25").replace(/#/g, "%23").replace(/</g, "%3C").replace(/>/g, "%3E").replace(/\s+/g, " ");
|
|
2423
|
+
}
|
|
2424
|
+
function svgToData(svg) {
|
|
2425
|
+
return "data:image/svg+xml," + encodeSVGforURL(svg);
|
|
2426
|
+
}
|
|
2427
|
+
function svgToURL(svg) {
|
|
2428
|
+
return 'url("' + svgToData(svg) + '")';
|
|
2429
|
+
}
|
|
2430
|
+
var monotoneProps = {
|
|
2431
|
+
"background-color": "currentColor"
|
|
2432
|
+
};
|
|
2433
|
+
var coloredProps = {
|
|
2434
|
+
"background-color": "transparent"
|
|
2435
|
+
};
|
|
2436
|
+
var propsToAdd = {
|
|
2437
|
+
image: "var(--svg)",
|
|
2438
|
+
repeat: "no-repeat",
|
|
2439
|
+
size: "100% 100%"
|
|
2440
|
+
};
|
|
2441
|
+
var propsToAddTo = {
|
|
2442
|
+
"-webkit-mask": monotoneProps,
|
|
2443
|
+
"mask": monotoneProps,
|
|
2444
|
+
"background": coloredProps
|
|
2445
|
+
};
|
|
2446
|
+
for (const prefix in propsToAddTo) {
|
|
2447
|
+
const list = propsToAddTo[prefix];
|
|
2448
|
+
for (const prop in propsToAdd) {
|
|
2449
|
+
list[prefix + "-" + prop] = propsToAdd[prop];
|
|
2450
|
+
}
|
|
2451
|
+
}
|
|
2452
|
+
function fixSize(value) {
|
|
2453
|
+
return value ? value + (value.match(/^[-0-9.]+$/) ? "px" : "") : "inherit";
|
|
2454
|
+
}
|
|
2455
|
+
function renderSPAN(data, icon, useMask) {
|
|
2456
|
+
const node = document.createElement("span");
|
|
2457
|
+
let body = data.body;
|
|
2458
|
+
if (body.indexOf("<a") !== -1) {
|
|
2459
|
+
body += "<!-- " + Date.now() + " -->";
|
|
2460
|
+
}
|
|
2461
|
+
const renderAttribs = data.attributes;
|
|
2462
|
+
const html = iconToHTML(body, {
|
|
2463
|
+
...renderAttribs,
|
|
2464
|
+
width: icon.width + "",
|
|
2465
|
+
height: icon.height + ""
|
|
2466
|
+
});
|
|
2467
|
+
const url = svgToURL(html);
|
|
2468
|
+
const svgStyle = node.style;
|
|
2469
|
+
const styles = {
|
|
2470
|
+
"--svg": url,
|
|
2471
|
+
"width": fixSize(renderAttribs.width),
|
|
2472
|
+
"height": fixSize(renderAttribs.height),
|
|
2473
|
+
...(useMask ? monotoneProps : coloredProps)
|
|
2474
|
+
};
|
|
2475
|
+
for (const prop in styles) {
|
|
2476
|
+
svgStyle.setProperty(prop, styles[prop]);
|
|
2477
|
+
}
|
|
2478
|
+
return node;
|
|
2479
|
+
}
|
|
2480
|
+
var policy;
|
|
2481
|
+
function createPolicy() {
|
|
2482
|
+
try {
|
|
2483
|
+
policy = window.trustedTypes.createPolicy("iconify", {
|
|
2484
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
2485
|
+
createHTML: s => s
|
|
2486
|
+
});
|
|
2487
|
+
} catch (err) {
|
|
2488
|
+
policy = null;
|
|
2489
|
+
}
|
|
2490
|
+
}
|
|
2491
|
+
function cleanUpInnerHTML(html) {
|
|
2492
|
+
if (policy === void 0) {
|
|
2493
|
+
createPolicy();
|
|
2494
|
+
}
|
|
2495
|
+
return policy ? policy.createHTML(html) : html;
|
|
2496
|
+
}
|
|
2497
|
+
function renderSVG(data) {
|
|
2498
|
+
const node = document.createElement("span");
|
|
2499
|
+
const attr = data.attributes;
|
|
2500
|
+
let style = "";
|
|
2501
|
+
if (!attr.width) {
|
|
2502
|
+
style = "width: inherit;";
|
|
2503
|
+
}
|
|
2504
|
+
if (!attr.height) {
|
|
2505
|
+
style += "height: inherit;";
|
|
2506
|
+
}
|
|
2507
|
+
if (style) {
|
|
2508
|
+
attr.style = style;
|
|
2509
|
+
}
|
|
2510
|
+
const html = iconToHTML(data.body, attr);
|
|
2511
|
+
node.innerHTML = cleanUpInnerHTML(html);
|
|
2512
|
+
return node.firstChild;
|
|
2513
|
+
}
|
|
2514
|
+
function renderIcon(parent, state) {
|
|
2515
|
+
const iconData = state.icon.data;
|
|
2516
|
+
const customisations = state.customisations;
|
|
2517
|
+
const renderData = iconToSVG(iconData, customisations);
|
|
2518
|
+
if (customisations.preserveAspectRatio) {
|
|
2519
|
+
renderData.attributes["preserveAspectRatio"] = customisations.preserveAspectRatio;
|
|
2520
|
+
}
|
|
2521
|
+
const mode = state.renderedMode;
|
|
2522
|
+
let node;
|
|
2523
|
+
switch (mode) {
|
|
2524
|
+
case "svg":
|
|
2525
|
+
node = renderSVG(renderData);
|
|
2526
|
+
break;
|
|
2527
|
+
default:
|
|
2528
|
+
node = renderSPAN(renderData, {
|
|
2529
|
+
...defaultIconProps,
|
|
2530
|
+
...iconData
|
|
2531
|
+
}, mode === "mask");
|
|
2532
|
+
}
|
|
2533
|
+
const oldNode = Array.from(parent.childNodes).find(node2 => {
|
|
2534
|
+
const tag = node2.tagName && node2.tagName.toUpperCase();
|
|
2535
|
+
return tag === "SPAN" || tag === "SVG";
|
|
2536
|
+
});
|
|
2537
|
+
if (oldNode) {
|
|
2538
|
+
if (node.tagName === "SPAN" && oldNode.tagName === node.tagName) {
|
|
2539
|
+
oldNode.setAttribute("style", node.getAttribute("style"));
|
|
2540
|
+
} else {
|
|
2541
|
+
parent.replaceChild(node, oldNode);
|
|
2542
|
+
}
|
|
2543
|
+
} else {
|
|
2544
|
+
parent.appendChild(node);
|
|
2545
|
+
}
|
|
2546
|
+
}
|
|
2547
|
+
function setPendingState(icon, inline, lastState) {
|
|
2548
|
+
const lastRender = lastState && (lastState.rendered ? lastState : lastState.lastRender);
|
|
2549
|
+
return {
|
|
2550
|
+
rendered: false,
|
|
2551
|
+
inline,
|
|
2552
|
+
icon,
|
|
2553
|
+
lastRender
|
|
2554
|
+
};
|
|
2555
|
+
}
|
|
2556
|
+
function defineIconifyIcon(name = "iconify-icon") {
|
|
2557
|
+
let customElements;
|
|
2558
|
+
let ParentClass;
|
|
2559
|
+
try {
|
|
2560
|
+
customElements = window.customElements;
|
|
2561
|
+
ParentClass = window.HTMLElement;
|
|
2562
|
+
} catch (err) {
|
|
2563
|
+
return;
|
|
2564
|
+
}
|
|
2565
|
+
if (!customElements || !ParentClass) {
|
|
2566
|
+
return;
|
|
2567
|
+
}
|
|
2568
|
+
const ConflictingClass = customElements.get(name);
|
|
2569
|
+
if (ConflictingClass) {
|
|
2570
|
+
return ConflictingClass;
|
|
2571
|
+
}
|
|
2572
|
+
const attributes = [
|
|
2573
|
+
// Icon
|
|
2574
|
+
"icon",
|
|
2575
|
+
// Mode
|
|
2576
|
+
"mode", "inline",
|
|
2577
|
+
// Customisations
|
|
2578
|
+
"width", "height", "rotate", "flip"];
|
|
2579
|
+
const IconifyIcon = class extends ParentClass {
|
|
2580
|
+
// Root
|
|
2581
|
+
_shadowRoot;
|
|
2582
|
+
// State
|
|
2583
|
+
_state;
|
|
2584
|
+
// Attributes check queued
|
|
2585
|
+
_checkQueued = false;
|
|
2586
|
+
/**
|
|
2587
|
+
* Constructor
|
|
2588
|
+
*/
|
|
2589
|
+
constructor() {
|
|
2590
|
+
super();
|
|
2591
|
+
const root = this._shadowRoot = this.attachShadow({
|
|
2592
|
+
mode: "open"
|
|
2593
|
+
});
|
|
2594
|
+
const inline = getInline(this);
|
|
2595
|
+
updateStyle(root, inline);
|
|
2596
|
+
this._state = setPendingState({
|
|
2597
|
+
value: ""
|
|
2598
|
+
}, inline);
|
|
2599
|
+
this._queueCheck();
|
|
2600
|
+
}
|
|
2601
|
+
/**
|
|
2602
|
+
* Observed attributes
|
|
2603
|
+
*/
|
|
2604
|
+
static get observedAttributes() {
|
|
2605
|
+
return attributes.slice(0);
|
|
2606
|
+
}
|
|
2607
|
+
/**
|
|
2608
|
+
* Observed properties that are different from attributes
|
|
2609
|
+
*
|
|
2610
|
+
* Experimental! Need to test with various frameworks that support it
|
|
2611
|
+
*/
|
|
2612
|
+
/*
|
|
2613
|
+
static get properties() {
|
|
2614
|
+
return {
|
|
2615
|
+
inline: {
|
|
2616
|
+
type: Boolean,
|
|
2617
|
+
reflect: true,
|
|
2618
|
+
},
|
|
2619
|
+
// Not listing other attributes because they are strings or combination
|
|
2620
|
+
// of string and another type. Cannot have multiple types
|
|
2621
|
+
};
|
|
2622
|
+
}
|
|
2623
|
+
*/
|
|
2624
|
+
/**
|
|
2625
|
+
* Attribute has changed
|
|
2626
|
+
*/
|
|
2627
|
+
attributeChangedCallback(name2) {
|
|
2628
|
+
if (name2 === "inline") {
|
|
2629
|
+
const newInline = getInline(this);
|
|
2630
|
+
const state = this._state;
|
|
2631
|
+
if (newInline !== state.inline) {
|
|
2632
|
+
state.inline = newInline;
|
|
2633
|
+
updateStyle(this._shadowRoot, newInline);
|
|
2634
|
+
}
|
|
2635
|
+
} else {
|
|
2636
|
+
this._queueCheck();
|
|
2637
|
+
}
|
|
2638
|
+
}
|
|
2639
|
+
/**
|
|
2640
|
+
* Get/set icon
|
|
2641
|
+
*/
|
|
2642
|
+
get icon() {
|
|
2643
|
+
const value = this.getAttribute("icon");
|
|
2644
|
+
if (value && value.slice(0, 1) === "{") {
|
|
2645
|
+
try {
|
|
2646
|
+
return JSON.parse(value);
|
|
2647
|
+
} catch (err) {}
|
|
2648
|
+
}
|
|
2649
|
+
return value;
|
|
2650
|
+
}
|
|
2651
|
+
set icon(value) {
|
|
2652
|
+
if (typeof value === "object") {
|
|
2653
|
+
value = JSON.stringify(value);
|
|
2654
|
+
}
|
|
2655
|
+
this.setAttribute("icon", value);
|
|
2656
|
+
}
|
|
2657
|
+
/**
|
|
2658
|
+
* Get/set inline
|
|
2659
|
+
*/
|
|
2660
|
+
get inline() {
|
|
2661
|
+
return getInline(this);
|
|
2662
|
+
}
|
|
2663
|
+
set inline(value) {
|
|
2664
|
+
if (value) {
|
|
2665
|
+
this.setAttribute("inline", "true");
|
|
2666
|
+
} else {
|
|
2667
|
+
this.removeAttribute("inline");
|
|
2668
|
+
}
|
|
2669
|
+
}
|
|
2670
|
+
/**
|
|
2671
|
+
* Restart animation
|
|
2672
|
+
*/
|
|
2673
|
+
restartAnimation() {
|
|
2674
|
+
const state = this._state;
|
|
2675
|
+
if (state.rendered) {
|
|
2676
|
+
const root = this._shadowRoot;
|
|
2677
|
+
if (state.renderedMode === "svg") {
|
|
2678
|
+
try {
|
|
2679
|
+
root.lastChild.setCurrentTime(0);
|
|
2680
|
+
return;
|
|
2681
|
+
} catch (err) {}
|
|
2682
|
+
}
|
|
2683
|
+
renderIcon(root, state);
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
/**
|
|
2687
|
+
* Get status
|
|
2688
|
+
*/
|
|
2689
|
+
get status() {
|
|
2690
|
+
const state = this._state;
|
|
2691
|
+
return state.rendered ? "rendered" : state.icon.data === null ? "failed" : "loading";
|
|
2692
|
+
}
|
|
2693
|
+
/**
|
|
2694
|
+
* Queue attributes re-check
|
|
2695
|
+
*/
|
|
2696
|
+
_queueCheck() {
|
|
2697
|
+
if (!this._checkQueued) {
|
|
2698
|
+
this._checkQueued = true;
|
|
2699
|
+
setTimeout(() => {
|
|
2700
|
+
this._check();
|
|
2701
|
+
});
|
|
2702
|
+
}
|
|
2703
|
+
}
|
|
2704
|
+
/**
|
|
2705
|
+
* Check for changes
|
|
2706
|
+
*/
|
|
2707
|
+
_check() {
|
|
2708
|
+
if (!this._checkQueued) {
|
|
2709
|
+
return;
|
|
2710
|
+
}
|
|
2711
|
+
this._checkQueued = false;
|
|
2712
|
+
const state = this._state;
|
|
2713
|
+
const newIcon = this.getAttribute("icon");
|
|
2714
|
+
if (newIcon !== state.icon.value) {
|
|
2715
|
+
this._iconChanged(newIcon);
|
|
2716
|
+
return;
|
|
2717
|
+
}
|
|
2718
|
+
if (!state.rendered) {
|
|
2719
|
+
return;
|
|
2720
|
+
}
|
|
2721
|
+
const mode = this.getAttribute("mode");
|
|
2722
|
+
const customisations = getCustomisations(this);
|
|
2723
|
+
if (state.attrMode !== mode || haveCustomisationsChanged(state.customisations, customisations)) {
|
|
2724
|
+
this._renderIcon(state.icon, customisations, mode);
|
|
2725
|
+
}
|
|
2726
|
+
}
|
|
2727
|
+
/**
|
|
2728
|
+
* Icon value has changed
|
|
2729
|
+
*/
|
|
2730
|
+
_iconChanged(newValue) {
|
|
2731
|
+
const icon = parseIconValue(newValue, (value, name2, data) => {
|
|
2732
|
+
const state = this._state;
|
|
2733
|
+
if (state.rendered || this.getAttribute("icon") !== value) {
|
|
2734
|
+
return;
|
|
2735
|
+
}
|
|
2736
|
+
const icon2 = {
|
|
2737
|
+
value,
|
|
2738
|
+
name: name2,
|
|
2739
|
+
data
|
|
2740
|
+
};
|
|
2741
|
+
if (icon2.data) {
|
|
2742
|
+
this._gotIconData(icon2);
|
|
2743
|
+
} else {
|
|
2744
|
+
state.icon = icon2;
|
|
2745
|
+
}
|
|
2746
|
+
});
|
|
2747
|
+
if (icon.data) {
|
|
2748
|
+
this._gotIconData(icon);
|
|
2749
|
+
} else {
|
|
2750
|
+
this._state = setPendingState(icon, this._state.inline, this._state);
|
|
2751
|
+
}
|
|
2752
|
+
}
|
|
2753
|
+
/**
|
|
2754
|
+
* Got new icon data, icon is ready to (re)render
|
|
2755
|
+
*/
|
|
2756
|
+
_gotIconData(icon) {
|
|
2757
|
+
this._checkQueued = false;
|
|
2758
|
+
this._renderIcon(icon, getCustomisations(this), this.getAttribute("mode"));
|
|
2759
|
+
}
|
|
2760
|
+
/**
|
|
2761
|
+
* Re-render based on icon data
|
|
2762
|
+
*/
|
|
2763
|
+
_renderIcon(icon, customisations, attrMode) {
|
|
2764
|
+
const renderedMode = getRenderMode(icon.data.body, attrMode);
|
|
2765
|
+
const inline = this._state.inline;
|
|
2766
|
+
renderIcon(this._shadowRoot, this._state = {
|
|
2767
|
+
rendered: true,
|
|
2768
|
+
icon,
|
|
2769
|
+
inline,
|
|
2770
|
+
customisations,
|
|
2771
|
+
attrMode,
|
|
2772
|
+
renderedMode
|
|
2773
|
+
});
|
|
2774
|
+
}
|
|
2775
|
+
};
|
|
2776
|
+
attributes.forEach(attr => {
|
|
2777
|
+
if (!(attr in IconifyIcon.prototype)) {
|
|
2778
|
+
Object.defineProperty(IconifyIcon.prototype, attr, {
|
|
2779
|
+
get: function () {
|
|
2780
|
+
return this.getAttribute(attr);
|
|
2781
|
+
},
|
|
2782
|
+
set: function (value) {
|
|
2783
|
+
if (value !== null) {
|
|
2784
|
+
this.setAttribute(attr, value);
|
|
2785
|
+
} else {
|
|
2786
|
+
this.removeAttribute(attr);
|
|
2787
|
+
}
|
|
2788
|
+
}
|
|
2789
|
+
});
|
|
2790
|
+
}
|
|
2791
|
+
});
|
|
2792
|
+
const functions = exportFunctions();
|
|
2793
|
+
for (const key in functions) {
|
|
2794
|
+
IconifyIcon[key] = IconifyIcon.prototype[key] = functions[key];
|
|
2795
|
+
}
|
|
2796
|
+
customElements.define(name, IconifyIcon);
|
|
2797
|
+
return IconifyIcon;
|
|
2798
|
+
}
|
|
2799
|
+
var IconifyIconComponent = defineIconifyIcon() || exportFunctions();
|
|
2800
|
+
var {
|
|
2801
|
+
enableCache,
|
|
2802
|
+
disableCache,
|
|
2803
|
+
iconExists,
|
|
2804
|
+
getIcon,
|
|
2805
|
+
listIcons,
|
|
2806
|
+
addIcon,
|
|
2807
|
+
addCollection,
|
|
2808
|
+
calculateSize,
|
|
2809
|
+
buildIcon,
|
|
2810
|
+
loadIcons,
|
|
2811
|
+
loadIcon,
|
|
2812
|
+
addAPIProvider,
|
|
2813
|
+
_api
|
|
2814
|
+
} = IconifyIconComponent;
|
|
2815
|
+
|
|
2816
|
+
// ../../node_modules/.pnpm/@iconify-icon+react@1.0.8_react@18.2.0/node_modules/@iconify-icon/react/dist/iconify.mjs
|
|
2817
|
+
var Icon = import_react.default.forwardRef((props, ref) => {
|
|
2818
|
+
const newProps = {
|
|
2819
|
+
...props,
|
|
2820
|
+
ref
|
|
2821
|
+
};
|
|
2822
|
+
if (typeof props.icon === "object") {
|
|
2823
|
+
newProps.icon = JSON.stringify(props.icon);
|
|
2824
|
+
}
|
|
2825
|
+
if (!props.inline) {
|
|
2826
|
+
delete newProps.inline;
|
|
2827
|
+
}
|
|
2828
|
+
if (props.className) {
|
|
2829
|
+
newProps["class"] = props.className;
|
|
2830
|
+
}
|
|
2831
|
+
return import_react.default.createElement("iconify-icon", newProps);
|
|
2832
|
+
});
|
|
2833
|
+
|
|
2834
|
+
// ../react-icons/dist/esm/index.js
|
|
2835
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2836
|
+
var Icon2 = /* @__PURE__ */React4.forwardRef((props, ref) => {
|
|
2837
|
+
return /* @__PURE__ */(0, import_jsx_runtime20.jsx)(Icon, {
|
|
2838
|
+
ref,
|
|
2839
|
+
"data-testid": "iconify-icon",
|
|
2840
|
+
...props
|
|
2841
|
+
});
|
|
2842
|
+
});
|
|
2843
|
+
Icon2.displayName = "Icon";
|
|
2844
|
+
|
|
2845
|
+
// src/MultistepForm/MultistepHeader.tsx
|
|
2846
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2847
|
+
var MultistepHeaderTitled = ({
|
|
2848
|
+
title,
|
|
2849
|
+
leftIcon,
|
|
2850
|
+
onLeftIconClick,
|
|
2851
|
+
rightIcon,
|
|
2852
|
+
onRightIconClick
|
|
2853
|
+
}) => {
|
|
2854
|
+
return /* @__PURE__ */(0, import_jsx_runtime21.jsxs)(import_ui17.Flex, {
|
|
2855
|
+
sx: {
|
|
2856
|
+
display: "flex",
|
|
2857
|
+
justifyContent: "space-between",
|
|
2858
|
+
paddingX: "xl",
|
|
2859
|
+
paddingY: "lg",
|
|
2860
|
+
alignItems: "center"
|
|
2861
|
+
},
|
|
2862
|
+
children: [/* @__PURE__ */(0, import_jsx_runtime21.jsx)(Icon2, {
|
|
2863
|
+
icon: leftIcon,
|
|
2864
|
+
onClick: onLeftIconClick
|
|
2865
|
+
}), /* @__PURE__ */(0, import_jsx_runtime21.jsx)(import_ui17.Text, {
|
|
2866
|
+
sx: {
|
|
2867
|
+
fontWeight: "bold",
|
|
2868
|
+
fontSize: "lg"
|
|
2869
|
+
},
|
|
2870
|
+
children: title
|
|
2871
|
+
}), /* @__PURE__ */(0, import_jsx_runtime21.jsx)(Icon2, {
|
|
2872
|
+
icon: rightIcon,
|
|
2873
|
+
onClick: onRightIconClick
|
|
2874
|
+
})]
|
|
2875
|
+
});
|
|
2876
|
+
};
|
|
2877
|
+
var MultistepHeaderLogo = ({
|
|
2878
|
+
onClose,
|
|
2879
|
+
src
|
|
2880
|
+
}) => {
|
|
2881
|
+
return /* @__PURE__ */(0, import_jsx_runtime21.jsxs)(import_ui17.Flex, {
|
|
2882
|
+
sx: {
|
|
2883
|
+
justifyContent: "space-between",
|
|
2884
|
+
alignItems: "center",
|
|
2885
|
+
paddingX: "xl",
|
|
2886
|
+
paddingY: "lg"
|
|
2887
|
+
},
|
|
2888
|
+
children: [/* @__PURE__ */(0, import_jsx_runtime21.jsx)(import_ui17.Image, {
|
|
2889
|
+
width: 115,
|
|
2890
|
+
height: 32,
|
|
2891
|
+
sx: {
|
|
2892
|
+
objectFit: "cover",
|
|
2893
|
+
width: 115,
|
|
2894
|
+
height: 32
|
|
2895
|
+
},
|
|
2896
|
+
src
|
|
2897
|
+
}), onClose && /* @__PURE__ */(0, import_jsx_runtime21.jsx)(import_ui17.CloseButton, {
|
|
2898
|
+
onClick: onClose
|
|
2899
|
+
})]
|
|
2900
|
+
});
|
|
2901
|
+
};
|
|
2902
|
+
var MultistepHeader = props => {
|
|
2903
|
+
if (props.variant === "logo") {
|
|
2904
|
+
return /* @__PURE__ */(0, import_jsx_runtime21.jsx)(MultistepHeaderLogo, {
|
|
2905
|
+
...props
|
|
2906
|
+
});
|
|
2907
|
+
}
|
|
2908
|
+
if (props.variant === "titled") {
|
|
2909
|
+
return /* @__PURE__ */(0, import_jsx_runtime21.jsx)(MultistepHeaderTitled, {
|
|
2910
|
+
...props
|
|
2911
|
+
});
|
|
2912
|
+
}
|
|
2913
|
+
return null;
|
|
2914
|
+
};
|
|
2915
|
+
|
|
2916
|
+
// src/MultistepForm/MultistepNavigation.tsx
|
|
2917
|
+
var import_ui18 = require("@ttoss/ui");
|
|
2918
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2919
|
+
var MultistepNavigation = ({
|
|
2920
|
+
amountOfSteps,
|
|
2921
|
+
currentStepNumber,
|
|
2922
|
+
onBack,
|
|
2923
|
+
stepsLabel
|
|
2924
|
+
}) => {
|
|
2925
|
+
return /* @__PURE__ */(0, import_jsx_runtime22.jsxs)(import_ui18.Flex, {
|
|
2926
|
+
sx: {
|
|
2927
|
+
justifyContent: "space-between",
|
|
2928
|
+
marginX: "2xl"
|
|
2929
|
+
},
|
|
2930
|
+
children: [/* @__PURE__ */(0, import_jsx_runtime22.jsxs)(import_ui18.Flex, {
|
|
2931
|
+
onClick: onBack,
|
|
2932
|
+
sx: {
|
|
2933
|
+
alignItems: "center",
|
|
2934
|
+
cursor: "pointer"
|
|
2935
|
+
},
|
|
2936
|
+
children: [/* @__PURE__ */(0, import_jsx_runtime22.jsx)(import_ui18.Text, {
|
|
2937
|
+
sx: {
|
|
2938
|
+
color: "#ACADB7",
|
|
2939
|
+
display: "flex"
|
|
2940
|
+
},
|
|
2941
|
+
children: /* @__PURE__ */(0, import_jsx_runtime22.jsx)(Icon2, {
|
|
2942
|
+
icon: "nav-left"
|
|
2943
|
+
})
|
|
2944
|
+
}), /* @__PURE__ */(0, import_jsx_runtime22.jsx)(import_ui18.Text, {
|
|
2945
|
+
sx: {
|
|
2946
|
+
color: "#ACADB7"
|
|
2947
|
+
},
|
|
2948
|
+
children: stepsLabel[currentStepNumber - 2]
|
|
2949
|
+
})]
|
|
2950
|
+
}), /* @__PURE__ */(0, import_jsx_runtime22.jsxs)(import_ui18.Text, {
|
|
2951
|
+
sx: {
|
|
2952
|
+
alignItems: "center",
|
|
2953
|
+
color: "#ACADB7"
|
|
2954
|
+
},
|
|
2955
|
+
children: [currentStepNumber, "/", amountOfSteps]
|
|
2956
|
+
})]
|
|
2957
|
+
});
|
|
2958
|
+
};
|
|
2959
|
+
|
|
2960
|
+
// src/MultistepForm/MultistepForm.tsx
|
|
2961
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
2962
|
+
var MultistepForm = ({
|
|
2963
|
+
nextStepButtonLabel = "Next",
|
|
2964
|
+
submitButtonLabel = "Send",
|
|
2965
|
+
...props
|
|
2966
|
+
}) => {
|
|
2967
|
+
const amountOfSteps = props.steps.length;
|
|
2968
|
+
const [currentStep, setCurrentStep] = React5.useState(1);
|
|
2969
|
+
const [form, setForm] = React5.useState({});
|
|
2970
|
+
const nextStep = () => {
|
|
2971
|
+
if (currentStep < amountOfSteps) {
|
|
2972
|
+
setCurrentStep(step => {
|
|
2973
|
+
return step + 1;
|
|
2974
|
+
});
|
|
2975
|
+
}
|
|
2976
|
+
};
|
|
2977
|
+
const backStep = () => {
|
|
2978
|
+
if (currentStep > 1) {
|
|
2979
|
+
setCurrentStep(step => {
|
|
2980
|
+
return step - 1;
|
|
2981
|
+
});
|
|
2982
|
+
}
|
|
2983
|
+
};
|
|
2984
|
+
return /* @__PURE__ */(0, import_jsx_runtime23.jsxs)(import_ui19.Flex, {
|
|
2985
|
+
sx: {
|
|
2986
|
+
flexDirection: "column",
|
|
2987
|
+
maxWidth: "390px",
|
|
2988
|
+
background: "#fff"
|
|
2989
|
+
},
|
|
2990
|
+
children: [/* @__PURE__ */(0, import_jsx_runtime23.jsx)(MultistepHeader, {
|
|
2991
|
+
...props.header
|
|
2992
|
+
}), props.steps.map((step, stepIndex) => {
|
|
2993
|
+
const isLastStep = stepIndex + 1 === amountOfSteps;
|
|
2994
|
+
const isCurrentStep = stepIndex + 1 === currentStep;
|
|
2995
|
+
return /* @__PURE__ */(0, import_jsx_runtime23.jsx)(import_ui19.Flex, {
|
|
2996
|
+
sx: {
|
|
2997
|
+
flexDirection: "column",
|
|
2998
|
+
display: isCurrentStep ? "flex" : "none"
|
|
2999
|
+
},
|
|
3000
|
+
"aria-hidden": !isCurrentStep,
|
|
3001
|
+
children: /* @__PURE__ */(0, import_jsx_runtime23.jsx)(MultistepFormStepper, {
|
|
3002
|
+
...step,
|
|
3003
|
+
stepNumber: stepIndex + 1,
|
|
3004
|
+
isLastStep,
|
|
3005
|
+
onSubmit: data => {
|
|
3006
|
+
const newValue = {
|
|
3007
|
+
...form,
|
|
3008
|
+
...data
|
|
3009
|
+
};
|
|
3010
|
+
setForm(newValue);
|
|
3011
|
+
if (isLastStep) {
|
|
3012
|
+
props.onSubmit(newValue);
|
|
3013
|
+
} else {
|
|
3014
|
+
nextStep();
|
|
3015
|
+
}
|
|
3016
|
+
},
|
|
3017
|
+
submitLabel: isLastStep ? submitButtonLabel : nextStepButtonLabel
|
|
3018
|
+
})
|
|
3019
|
+
}, `form-step-${step.question}`);
|
|
3020
|
+
}), currentStep > 1 && /* @__PURE__ */(0, import_jsx_runtime23.jsx)(MultistepNavigation, {
|
|
3021
|
+
amountOfSteps,
|
|
3022
|
+
currentStepNumber: currentStep,
|
|
3023
|
+
onBack: backStep,
|
|
3024
|
+
stepsLabel: props.steps.map(s => {
|
|
3025
|
+
return s.label;
|
|
3026
|
+
})
|
|
3027
|
+
}), props.footer && /* @__PURE__ */(0, import_jsx_runtime23.jsx)(MultistepFooter, {
|
|
3028
|
+
footer: props.footer
|
|
3029
|
+
})]
|
|
3030
|
+
});
|
|
3031
|
+
};
|
|
3032
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
3033
|
+
0 && (module.exports = {
|
|
3034
|
+
MultistepForm
|
|
3035
|
+
});
|
|
3036
|
+
/*! Bundled license information:
|
|
3037
|
+
|
|
3038
|
+
iconify-icon/dist/iconify-icon.mjs:
|
|
3039
|
+
(**
|
|
3040
|
+
* (c) Iconify
|
|
3041
|
+
*
|
|
3042
|
+
* For the full copyright and license information, please view the license.txt
|
|
3043
|
+
* files at https://github.com/iconify/iconify
|
|
3044
|
+
*
|
|
3045
|
+
* Licensed under MIT.
|
|
3046
|
+
*
|
|
3047
|
+
* @license MIT
|
|
3048
|
+
* @version 1.0.8
|
|
3049
|
+
*)
|
|
3050
|
+
*/
|