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