@eightshift/ui-components 5.0.0 → 5.0.2
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/Button-BpwTmkAe.js +185 -0
- package/dist/Collection-n5d0zIgb.js +2398 -0
- package/dist/Color-lVhk8V_G.js +2452 -0
- package/dist/ColorSwatch-DntWEAC3.js +64 -0
- package/dist/ComboBox-BJpTEATT.js +1915 -0
- package/dist/Dialog-O9uw63D7.js +2317 -0
- package/dist/FieldError-DHrSdE_Q.js +42 -0
- package/dist/FocusScope-BEPI2m7u.js +831 -0
- package/dist/Form-Cq3fu75_.js +5 -0
- package/dist/Group-DDPhPPTQ.js +48 -0
- package/dist/Heading-ba38ScjJ.js +16 -0
- package/dist/Hidden-rE6uR-lr.js +41 -0
- package/dist/Input-BmDS8Juy.js +133 -0
- package/dist/Label-JS_ob-kh.js +17 -0
- package/dist/List-CZMUbkFU.js +593 -0
- package/dist/ListBox-BTxlCGcc.js +664 -0
- package/dist/NumberFormatter-DA8u1Ot7.js +140 -0
- package/dist/OverlayArrow-5aDgmImj.js +637 -0
- package/dist/RSPContexts-2lR5GG9p.js +14 -0
- package/dist/Select-aab027f3.esm-BKIJGje-.js +2469 -0
- package/dist/Separator-CaTBkETC.js +332 -0
- package/dist/Slider-C-S1oEH9.js +853 -0
- package/dist/Text-BuJgePCv.js +16 -0
- package/dist/VisuallyHidden-BYi0pekx.js +48 -0
- package/dist/_commonjsHelpers-CUmg6egw.js +6 -0
- package/dist/assets/index.css +57 -0
- package/dist/assets/style-admin.css +5908 -0
- package/dist/assets/style-editor.css +5908 -0
- package/dist/assets/style.css +5914 -0
- package/dist/assets/wp-font-enhancements.css +8 -0
- package/dist/assets/wp-ui-enhancements.css +396 -0
- package/dist/components/animated-visibility/animated-visibility.js +105 -0
- package/dist/components/base-control/base-control.js +86 -0
- package/dist/components/breakpoint-preview/breakpoint-preview.js +161 -0
- package/dist/components/button/button.js +387 -0
- package/dist/components/checkbox/checkbox.js +323 -0
- package/dist/components/color-pickers/color-picker.js +272 -0
- package/dist/components/color-pickers/color-swatch.js +59 -0
- package/dist/components/color-pickers/gradient-editor.js +534 -0
- package/dist/components/color-pickers/solid-color-picker.js +1567 -0
- package/dist/components/component-toggle/component-toggle.js +161 -0
- package/dist/components/container-panel/container-panel.js +131 -0
- package/dist/components/draggable/draggable-context.js +5 -0
- package/dist/components/draggable/draggable-handle.js +46 -0
- package/dist/components/draggable/draggable.js +7320 -0
- package/dist/components/draggable-list/draggable-list-context.js +5 -0
- package/dist/components/draggable-list/draggable-list-item.js +77 -0
- package/dist/components/draggable-list/draggable-list.js +151 -0
- package/dist/components/expandable/expandable.js +342 -0
- package/dist/components/index.js +137 -0
- package/dist/components/input-field/input-field.js +231 -0
- package/dist/components/item-collection/item-collection.js +59 -0
- package/dist/components/layout/hstack.js +30 -0
- package/dist/components/layout/vstack.js +30 -0
- package/dist/components/link-input/link-input.js +284 -0
- package/dist/components/matrix-align/matrix-align.js +134 -0
- package/dist/components/menu/menu.js +285 -0
- package/dist/components/modal/modal.js +305 -0
- package/dist/components/notice/notice.js +123 -0
- package/dist/components/number-picker/number-picker.js +292 -0
- package/dist/components/option-select/option-select.js +264 -0
- package/dist/components/options-panel/options-panel.js +158 -0
- package/dist/components/placeholders/file-placeholder.js +42 -0
- package/dist/components/placeholders/image-placeholder.js +88 -0
- package/dist/components/placeholders/media-placeholder.js +63 -0
- package/dist/components/popover/popover.js +207 -0
- package/dist/components/radio/radio.js +582 -0
- package/dist/components/repeater/repeater-context.js +5 -0
- package/dist/components/repeater/repeater-item.js +119 -0
- package/dist/components/repeater/repeater.js +280 -0
- package/dist/components/responsive/mini-responsive.js +498 -0
- package/dist/components/responsive/responsive-legacy.js +343 -0
- package/dist/components/responsive/responsive.js +583 -0
- package/dist/components/responsive-preview/responsive-preview.js +123 -0
- package/dist/components/rich-label/rich-label.js +66 -0
- package/dist/components/select/async-multi-select.js +157 -0
- package/dist/components/select/async-single-select.js +137 -0
- package/dist/components/select/custom-select-default-components.js +38 -0
- package/dist/components/select/multi-select-components.js +8 -0
- package/dist/components/select/multi-select.js +151 -0
- package/dist/components/select/react-select-component-wrappers.js +90 -0
- package/dist/components/select/shared.js +26 -0
- package/dist/components/select/single-select.js +131 -0
- package/dist/components/select/styles.js +49 -0
- package/dist/components/select/v2/async-select.js +297 -0
- package/dist/components/select/v2/shared.js +24 -0
- package/dist/components/select/v2/single-select.js +1004 -0
- package/dist/components/slider/column-config-slider.js +210 -0
- package/dist/components/slider/slider.js +345 -0
- package/dist/components/slider/utils.js +94 -0
- package/dist/components/spacer/spacer.js +97 -0
- package/dist/components/tabs/tabs.js +703 -0
- package/dist/components/toggle/switch.js +156 -0
- package/dist/components/toggle/toggle.js +64 -0
- package/dist/components/toggle-button/toggle-button.js +343 -0
- package/dist/components/tooltip/tooltip.js +527 -0
- package/dist/context-BbYZoHvX.js +92 -0
- package/dist/default-i18n-CT_oS1Fy.js +922 -0
- package/dist/filterDOMProps-EDDcM64A.js +28 -0
- package/dist/icons/block-icon.js +42 -0
- package/dist/icons/generic-color-swatch.js +113 -0
- package/dist/icons/icons.js +30495 -0
- package/dist/icons/index.js +11 -0
- package/dist/icons/jsx-svg.js +50 -0
- package/dist/index-641ee5b8.esm-BPU8rMZr.js +3137 -0
- package/dist/index-BljRBEr_.js +44 -0
- package/dist/index-CFozsmNS.js +28321 -0
- package/dist/index.js +139 -0
- package/dist/lite-DVmmD_-j.js +7 -0
- package/dist/modifiers.esm-BuJQPI1X.js +31 -0
- package/dist/multi-select-components-Sp-JEFEX.js +3744 -0
- package/dist/number-GajL10e1.js +36 -0
- package/dist/react-jsx-parser.min-DZCiis5V.js +11753 -0
- package/dist/react-select-async.esm-D937XTWW.js +107 -0
- package/dist/react-select.esm-Ciai3aKf.js +15 -0
- package/dist/style-admin.js +1 -0
- package/dist/style-editor.js +1 -0
- package/dist/style.js +1 -0
- package/dist/textSelection-8DpK8fJl.js +46 -0
- package/dist/useButton-Bt3BffJm.js +50 -0
- package/dist/useEvent-ICdlokG-.js +23 -0
- package/dist/useFocusRing-Bv0UJQl8.js +107 -0
- package/dist/useFormReset-D2YaWRIA.js +22 -0
- package/dist/useFormValidation-Dy0PXJg5.js +224 -0
- package/dist/useHover-C2SkI1Fn.js +895 -0
- package/dist/useLabel-BPCd5c7-.js +27 -0
- package/dist/useLabels-B7-lUnAF.js +23 -0
- package/dist/useListState-DkyH7elT.js +168 -0
- package/dist/useLocalizedStringFormatter-C9GO0IDB.js +121 -0
- package/dist/useNumberField-CU1_u8ze.js +1215 -0
- package/dist/useNumberFormatter-CZ9QUnRt.js +13 -0
- package/dist/usePress-BrJylgPR.js +688 -0
- package/dist/useSingleSelectListState-C4sorv2p.js +38 -0
- package/dist/useToggle-CDa3YAZI.js +59 -0
- package/dist/useToggleState-ibcBUHnB.js +19 -0
- package/dist/utilities/array-helpers.js +56 -0
- package/dist/utilities/debounce-throttle.js +123 -0
- package/dist/utilities/es-dash.js +382 -0
- package/dist/utilities/index.js +27 -0
- package/dist/utilities/text-helpers.js +136 -0
- package/dist/utils-CZt7LCbO.js +403 -0
- package/dist/wp/wp-font-enhancements.js +1 -0
- package/dist/wp/wp-ui-enhancements.js +1 -0
- package/package.json +24 -24
|
@@ -0,0 +1,922 @@
|
|
|
1
|
+
import { g as getDefaultExportFromCjs } from "./_commonjsHelpers-CUmg6egw.js";
|
|
2
|
+
function memize(fn, options) {
|
|
3
|
+
var size = 0;
|
|
4
|
+
var head;
|
|
5
|
+
var tail;
|
|
6
|
+
options = options || {};
|
|
7
|
+
function memoized() {
|
|
8
|
+
var node = head, len = arguments.length, args, i;
|
|
9
|
+
searchCache: while (node) {
|
|
10
|
+
if (node.args.length !== arguments.length) {
|
|
11
|
+
node = node.next;
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
for (i = 0; i < len; i++) {
|
|
15
|
+
if (node.args[i] !== arguments[i]) {
|
|
16
|
+
node = node.next;
|
|
17
|
+
continue searchCache;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (node !== head) {
|
|
21
|
+
if (node === tail) {
|
|
22
|
+
tail = node.prev;
|
|
23
|
+
}
|
|
24
|
+
node.prev.next = node.next;
|
|
25
|
+
if (node.next) {
|
|
26
|
+
node.next.prev = node.prev;
|
|
27
|
+
}
|
|
28
|
+
node.next = head;
|
|
29
|
+
node.prev = null;
|
|
30
|
+
head.prev = node;
|
|
31
|
+
head = node;
|
|
32
|
+
}
|
|
33
|
+
return node.val;
|
|
34
|
+
}
|
|
35
|
+
args = new Array(len);
|
|
36
|
+
for (i = 0; i < len; i++) {
|
|
37
|
+
args[i] = arguments[i];
|
|
38
|
+
}
|
|
39
|
+
node = {
|
|
40
|
+
args,
|
|
41
|
+
// Generate the result from original function
|
|
42
|
+
val: fn.apply(null, args)
|
|
43
|
+
};
|
|
44
|
+
if (head) {
|
|
45
|
+
head.prev = node;
|
|
46
|
+
node.next = head;
|
|
47
|
+
} else {
|
|
48
|
+
tail = node;
|
|
49
|
+
}
|
|
50
|
+
if (size === /** @type {MemizeOptions} */
|
|
51
|
+
options.maxSize) {
|
|
52
|
+
tail = /** @type {MemizeCacheNode} */
|
|
53
|
+
tail.prev;
|
|
54
|
+
tail.next = null;
|
|
55
|
+
} else {
|
|
56
|
+
size++;
|
|
57
|
+
}
|
|
58
|
+
head = node;
|
|
59
|
+
return node.val;
|
|
60
|
+
}
|
|
61
|
+
memoized.clear = function() {
|
|
62
|
+
head = null;
|
|
63
|
+
tail = null;
|
|
64
|
+
size = 0;
|
|
65
|
+
};
|
|
66
|
+
return memoized;
|
|
67
|
+
}
|
|
68
|
+
var sprintf$1 = {};
|
|
69
|
+
var hasRequiredSprintf;
|
|
70
|
+
function requireSprintf() {
|
|
71
|
+
if (hasRequiredSprintf) return sprintf$1;
|
|
72
|
+
hasRequiredSprintf = 1;
|
|
73
|
+
(function(exports) {
|
|
74
|
+
!function() {
|
|
75
|
+
var re = {
|
|
76
|
+
not_type: /[^T]/,
|
|
77
|
+
not_primitive: /[^v]/,
|
|
78
|
+
number: /[diefg]/,
|
|
79
|
+
numeric_arg: /[bcdiefguxX]/,
|
|
80
|
+
json: /[j]/,
|
|
81
|
+
text: /^[^\x25]+/,
|
|
82
|
+
modulo: /^\x25{2}/,
|
|
83
|
+
placeholder: /^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,
|
|
84
|
+
key: /^([a-z_][a-z_\d]*)/i,
|
|
85
|
+
key_access: /^\.([a-z_][a-z_\d]*)/i,
|
|
86
|
+
index_access: /^\[(\d+)\]/,
|
|
87
|
+
sign: /^[+-]/
|
|
88
|
+
};
|
|
89
|
+
function sprintf2(key) {
|
|
90
|
+
return sprintf_format(sprintf_parse(key), arguments);
|
|
91
|
+
}
|
|
92
|
+
function vsprintf(fmt, argv) {
|
|
93
|
+
return sprintf2.apply(null, [fmt].concat(argv || []));
|
|
94
|
+
}
|
|
95
|
+
function sprintf_format(parse_tree, argv) {
|
|
96
|
+
var cursor = 1, tree_length = parse_tree.length, arg, output = "", i, k, ph, pad, pad_character, pad_length, is_positive, sign;
|
|
97
|
+
for (i = 0; i < tree_length; i++) {
|
|
98
|
+
if (typeof parse_tree[i] === "string") {
|
|
99
|
+
output += parse_tree[i];
|
|
100
|
+
} else if (typeof parse_tree[i] === "object") {
|
|
101
|
+
ph = parse_tree[i];
|
|
102
|
+
if (ph.keys) {
|
|
103
|
+
arg = argv[cursor];
|
|
104
|
+
for (k = 0; k < ph.keys.length; k++) {
|
|
105
|
+
if (arg == void 0) {
|
|
106
|
+
throw new Error(sprintf2('[sprintf] Cannot access property "%s" of undefined value "%s"', ph.keys[k], ph.keys[k - 1]));
|
|
107
|
+
}
|
|
108
|
+
arg = arg[ph.keys[k]];
|
|
109
|
+
}
|
|
110
|
+
} else if (ph.param_no) {
|
|
111
|
+
arg = argv[ph.param_no];
|
|
112
|
+
} else {
|
|
113
|
+
arg = argv[cursor++];
|
|
114
|
+
}
|
|
115
|
+
if (re.not_type.test(ph.type) && re.not_primitive.test(ph.type) && arg instanceof Function) {
|
|
116
|
+
arg = arg();
|
|
117
|
+
}
|
|
118
|
+
if (re.numeric_arg.test(ph.type) && (typeof arg !== "number" && isNaN(arg))) {
|
|
119
|
+
throw new TypeError(sprintf2("[sprintf] expecting number but found %T", arg));
|
|
120
|
+
}
|
|
121
|
+
if (re.number.test(ph.type)) {
|
|
122
|
+
is_positive = arg >= 0;
|
|
123
|
+
}
|
|
124
|
+
switch (ph.type) {
|
|
125
|
+
case "b":
|
|
126
|
+
arg = parseInt(arg, 10).toString(2);
|
|
127
|
+
break;
|
|
128
|
+
case "c":
|
|
129
|
+
arg = String.fromCharCode(parseInt(arg, 10));
|
|
130
|
+
break;
|
|
131
|
+
case "d":
|
|
132
|
+
case "i":
|
|
133
|
+
arg = parseInt(arg, 10);
|
|
134
|
+
break;
|
|
135
|
+
case "j":
|
|
136
|
+
arg = JSON.stringify(arg, null, ph.width ? parseInt(ph.width) : 0);
|
|
137
|
+
break;
|
|
138
|
+
case "e":
|
|
139
|
+
arg = ph.precision ? parseFloat(arg).toExponential(ph.precision) : parseFloat(arg).toExponential();
|
|
140
|
+
break;
|
|
141
|
+
case "f":
|
|
142
|
+
arg = ph.precision ? parseFloat(arg).toFixed(ph.precision) : parseFloat(arg);
|
|
143
|
+
break;
|
|
144
|
+
case "g":
|
|
145
|
+
arg = ph.precision ? String(Number(arg.toPrecision(ph.precision))) : parseFloat(arg);
|
|
146
|
+
break;
|
|
147
|
+
case "o":
|
|
148
|
+
arg = (parseInt(arg, 10) >>> 0).toString(8);
|
|
149
|
+
break;
|
|
150
|
+
case "s":
|
|
151
|
+
arg = String(arg);
|
|
152
|
+
arg = ph.precision ? arg.substring(0, ph.precision) : arg;
|
|
153
|
+
break;
|
|
154
|
+
case "t":
|
|
155
|
+
arg = String(!!arg);
|
|
156
|
+
arg = ph.precision ? arg.substring(0, ph.precision) : arg;
|
|
157
|
+
break;
|
|
158
|
+
case "T":
|
|
159
|
+
arg = Object.prototype.toString.call(arg).slice(8, -1).toLowerCase();
|
|
160
|
+
arg = ph.precision ? arg.substring(0, ph.precision) : arg;
|
|
161
|
+
break;
|
|
162
|
+
case "u":
|
|
163
|
+
arg = parseInt(arg, 10) >>> 0;
|
|
164
|
+
break;
|
|
165
|
+
case "v":
|
|
166
|
+
arg = arg.valueOf();
|
|
167
|
+
arg = ph.precision ? arg.substring(0, ph.precision) : arg;
|
|
168
|
+
break;
|
|
169
|
+
case "x":
|
|
170
|
+
arg = (parseInt(arg, 10) >>> 0).toString(16);
|
|
171
|
+
break;
|
|
172
|
+
case "X":
|
|
173
|
+
arg = (parseInt(arg, 10) >>> 0).toString(16).toUpperCase();
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
if (re.json.test(ph.type)) {
|
|
177
|
+
output += arg;
|
|
178
|
+
} else {
|
|
179
|
+
if (re.number.test(ph.type) && (!is_positive || ph.sign)) {
|
|
180
|
+
sign = is_positive ? "+" : "-";
|
|
181
|
+
arg = arg.toString().replace(re.sign, "");
|
|
182
|
+
} else {
|
|
183
|
+
sign = "";
|
|
184
|
+
}
|
|
185
|
+
pad_character = ph.pad_char ? ph.pad_char === "0" ? "0" : ph.pad_char.charAt(1) : " ";
|
|
186
|
+
pad_length = ph.width - (sign + arg).length;
|
|
187
|
+
pad = ph.width ? pad_length > 0 ? pad_character.repeat(pad_length) : "" : "";
|
|
188
|
+
output += ph.align ? sign + arg + pad : pad_character === "0" ? sign + pad + arg : pad + sign + arg;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return output;
|
|
193
|
+
}
|
|
194
|
+
var sprintf_cache = /* @__PURE__ */ Object.create(null);
|
|
195
|
+
function sprintf_parse(fmt) {
|
|
196
|
+
if (sprintf_cache[fmt]) {
|
|
197
|
+
return sprintf_cache[fmt];
|
|
198
|
+
}
|
|
199
|
+
var _fmt = fmt, match, parse_tree = [], arg_names = 0;
|
|
200
|
+
while (_fmt) {
|
|
201
|
+
if ((match = re.text.exec(_fmt)) !== null) {
|
|
202
|
+
parse_tree.push(match[0]);
|
|
203
|
+
} else if ((match = re.modulo.exec(_fmt)) !== null) {
|
|
204
|
+
parse_tree.push("%");
|
|
205
|
+
} else if ((match = re.placeholder.exec(_fmt)) !== null) {
|
|
206
|
+
if (match[2]) {
|
|
207
|
+
arg_names |= 1;
|
|
208
|
+
var field_list = [], replacement_field = match[2], field_match = [];
|
|
209
|
+
if ((field_match = re.key.exec(replacement_field)) !== null) {
|
|
210
|
+
field_list.push(field_match[1]);
|
|
211
|
+
while ((replacement_field = replacement_field.substring(field_match[0].length)) !== "") {
|
|
212
|
+
if ((field_match = re.key_access.exec(replacement_field)) !== null) {
|
|
213
|
+
field_list.push(field_match[1]);
|
|
214
|
+
} else if ((field_match = re.index_access.exec(replacement_field)) !== null) {
|
|
215
|
+
field_list.push(field_match[1]);
|
|
216
|
+
} else {
|
|
217
|
+
throw new SyntaxError("[sprintf] failed to parse named argument key");
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
} else {
|
|
221
|
+
throw new SyntaxError("[sprintf] failed to parse named argument key");
|
|
222
|
+
}
|
|
223
|
+
match[2] = field_list;
|
|
224
|
+
} else {
|
|
225
|
+
arg_names |= 2;
|
|
226
|
+
}
|
|
227
|
+
if (arg_names === 3) {
|
|
228
|
+
throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");
|
|
229
|
+
}
|
|
230
|
+
parse_tree.push(
|
|
231
|
+
{
|
|
232
|
+
placeholder: match[0],
|
|
233
|
+
param_no: match[1],
|
|
234
|
+
keys: match[2],
|
|
235
|
+
sign: match[3],
|
|
236
|
+
pad_char: match[4],
|
|
237
|
+
align: match[5],
|
|
238
|
+
width: match[6],
|
|
239
|
+
precision: match[7],
|
|
240
|
+
type: match[8]
|
|
241
|
+
}
|
|
242
|
+
);
|
|
243
|
+
} else {
|
|
244
|
+
throw new SyntaxError("[sprintf] unexpected placeholder");
|
|
245
|
+
}
|
|
246
|
+
_fmt = _fmt.substring(match[0].length);
|
|
247
|
+
}
|
|
248
|
+
return sprintf_cache[fmt] = parse_tree;
|
|
249
|
+
}
|
|
250
|
+
{
|
|
251
|
+
exports["sprintf"] = sprintf2;
|
|
252
|
+
exports["vsprintf"] = vsprintf;
|
|
253
|
+
}
|
|
254
|
+
if (typeof window !== "undefined") {
|
|
255
|
+
window["sprintf"] = sprintf2;
|
|
256
|
+
window["vsprintf"] = vsprintf;
|
|
257
|
+
}
|
|
258
|
+
}();
|
|
259
|
+
})(sprintf$1);
|
|
260
|
+
return sprintf$1;
|
|
261
|
+
}
|
|
262
|
+
var sprintfExports = requireSprintf();
|
|
263
|
+
const sprintfjs = /* @__PURE__ */ getDefaultExportFromCjs(sprintfExports);
|
|
264
|
+
const logErrorOnce = memize(console.error);
|
|
265
|
+
function sprintf(format, ...args) {
|
|
266
|
+
try {
|
|
267
|
+
return sprintfjs.sprintf(format, ...args);
|
|
268
|
+
} catch (error) {
|
|
269
|
+
if (error instanceof Error) {
|
|
270
|
+
logErrorOnce("sprintf error: \n\n" + error.toString());
|
|
271
|
+
}
|
|
272
|
+
return format;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
var PRECEDENCE, OPENERS, TERMINATORS, PATTERN;
|
|
276
|
+
PRECEDENCE = {
|
|
277
|
+
"(": 9,
|
|
278
|
+
"!": 8,
|
|
279
|
+
"*": 7,
|
|
280
|
+
"/": 7,
|
|
281
|
+
"%": 7,
|
|
282
|
+
"+": 6,
|
|
283
|
+
"-": 6,
|
|
284
|
+
"<": 5,
|
|
285
|
+
"<=": 5,
|
|
286
|
+
">": 5,
|
|
287
|
+
">=": 5,
|
|
288
|
+
"==": 4,
|
|
289
|
+
"!=": 4,
|
|
290
|
+
"&&": 3,
|
|
291
|
+
"||": 2,
|
|
292
|
+
"?": 1,
|
|
293
|
+
"?:": 1
|
|
294
|
+
};
|
|
295
|
+
OPENERS = ["(", "?"];
|
|
296
|
+
TERMINATORS = {
|
|
297
|
+
")": ["("],
|
|
298
|
+
":": ["?", "?:"]
|
|
299
|
+
};
|
|
300
|
+
PATTERN = /<=|>=|==|!=|&&|\|\||\?:|\(|!|\*|\/|%|\+|-|<|>|\?|\)|:/;
|
|
301
|
+
function postfix(expression) {
|
|
302
|
+
var terms = [], stack = [], match, operator, term, element;
|
|
303
|
+
while (match = expression.match(PATTERN)) {
|
|
304
|
+
operator = match[0];
|
|
305
|
+
term = expression.substr(0, match.index).trim();
|
|
306
|
+
if (term) {
|
|
307
|
+
terms.push(term);
|
|
308
|
+
}
|
|
309
|
+
while (element = stack.pop()) {
|
|
310
|
+
if (TERMINATORS[operator]) {
|
|
311
|
+
if (TERMINATORS[operator][0] === element) {
|
|
312
|
+
operator = TERMINATORS[operator][1] || operator;
|
|
313
|
+
break;
|
|
314
|
+
}
|
|
315
|
+
} else if (OPENERS.indexOf(element) >= 0 || PRECEDENCE[element] < PRECEDENCE[operator]) {
|
|
316
|
+
stack.push(element);
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
terms.push(element);
|
|
320
|
+
}
|
|
321
|
+
if (!TERMINATORS[operator]) {
|
|
322
|
+
stack.push(operator);
|
|
323
|
+
}
|
|
324
|
+
expression = expression.substr(match.index + operator.length);
|
|
325
|
+
}
|
|
326
|
+
expression = expression.trim();
|
|
327
|
+
if (expression) {
|
|
328
|
+
terms.push(expression);
|
|
329
|
+
}
|
|
330
|
+
return terms.concat(stack.reverse());
|
|
331
|
+
}
|
|
332
|
+
var OPERATORS = {
|
|
333
|
+
"!": function(a) {
|
|
334
|
+
return !a;
|
|
335
|
+
},
|
|
336
|
+
"*": function(a, b) {
|
|
337
|
+
return a * b;
|
|
338
|
+
},
|
|
339
|
+
"/": function(a, b) {
|
|
340
|
+
return a / b;
|
|
341
|
+
},
|
|
342
|
+
"%": function(a, b) {
|
|
343
|
+
return a % b;
|
|
344
|
+
},
|
|
345
|
+
"+": function(a, b) {
|
|
346
|
+
return a + b;
|
|
347
|
+
},
|
|
348
|
+
"-": function(a, b) {
|
|
349
|
+
return a - b;
|
|
350
|
+
},
|
|
351
|
+
"<": function(a, b) {
|
|
352
|
+
return a < b;
|
|
353
|
+
},
|
|
354
|
+
"<=": function(a, b) {
|
|
355
|
+
return a <= b;
|
|
356
|
+
},
|
|
357
|
+
">": function(a, b) {
|
|
358
|
+
return a > b;
|
|
359
|
+
},
|
|
360
|
+
">=": function(a, b) {
|
|
361
|
+
return a >= b;
|
|
362
|
+
},
|
|
363
|
+
"==": function(a, b) {
|
|
364
|
+
return a === b;
|
|
365
|
+
},
|
|
366
|
+
"!=": function(a, b) {
|
|
367
|
+
return a !== b;
|
|
368
|
+
},
|
|
369
|
+
"&&": function(a, b) {
|
|
370
|
+
return a && b;
|
|
371
|
+
},
|
|
372
|
+
"||": function(a, b) {
|
|
373
|
+
return a || b;
|
|
374
|
+
},
|
|
375
|
+
"?:": function(a, b, c) {
|
|
376
|
+
if (a) {
|
|
377
|
+
throw b;
|
|
378
|
+
}
|
|
379
|
+
return c;
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
function evaluate(postfix2, variables) {
|
|
383
|
+
var stack = [], i, j, args, getOperatorResult, term, value;
|
|
384
|
+
for (i = 0; i < postfix2.length; i++) {
|
|
385
|
+
term = postfix2[i];
|
|
386
|
+
getOperatorResult = OPERATORS[term];
|
|
387
|
+
if (getOperatorResult) {
|
|
388
|
+
j = getOperatorResult.length;
|
|
389
|
+
args = Array(j);
|
|
390
|
+
while (j--) {
|
|
391
|
+
args[j] = stack.pop();
|
|
392
|
+
}
|
|
393
|
+
try {
|
|
394
|
+
value = getOperatorResult.apply(null, args);
|
|
395
|
+
} catch (earlyReturn) {
|
|
396
|
+
return earlyReturn;
|
|
397
|
+
}
|
|
398
|
+
} else if (variables.hasOwnProperty(term)) {
|
|
399
|
+
value = variables[term];
|
|
400
|
+
} else {
|
|
401
|
+
value = +term;
|
|
402
|
+
}
|
|
403
|
+
stack.push(value);
|
|
404
|
+
}
|
|
405
|
+
return stack[0];
|
|
406
|
+
}
|
|
407
|
+
function compile(expression) {
|
|
408
|
+
var terms = postfix(expression);
|
|
409
|
+
return function(variables) {
|
|
410
|
+
return evaluate(terms, variables);
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
function pluralForms(expression) {
|
|
414
|
+
var evaluate2 = compile(expression);
|
|
415
|
+
return function(n) {
|
|
416
|
+
return +evaluate2({ n });
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
var DEFAULT_OPTIONS = {
|
|
420
|
+
contextDelimiter: "",
|
|
421
|
+
onMissingKey: null
|
|
422
|
+
};
|
|
423
|
+
function getPluralExpression(pf) {
|
|
424
|
+
var parts, i, part;
|
|
425
|
+
parts = pf.split(";");
|
|
426
|
+
for (i = 0; i < parts.length; i++) {
|
|
427
|
+
part = parts[i].trim();
|
|
428
|
+
if (part.indexOf("plural=") === 0) {
|
|
429
|
+
return part.substr(7);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
function Tannin(data, options) {
|
|
434
|
+
var key;
|
|
435
|
+
this.data = data;
|
|
436
|
+
this.pluralForms = {};
|
|
437
|
+
this.options = {};
|
|
438
|
+
for (key in DEFAULT_OPTIONS) {
|
|
439
|
+
this.options[key] = options !== void 0 && key in options ? options[key] : DEFAULT_OPTIONS[key];
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
Tannin.prototype.getPluralForm = function(domain, n) {
|
|
443
|
+
var getPluralForm = this.pluralForms[domain], config, plural, pf;
|
|
444
|
+
if (!getPluralForm) {
|
|
445
|
+
config = this.data[domain][""];
|
|
446
|
+
pf = config["Plural-Forms"] || config["plural-forms"] || // Ignore reason: As known, there's no way to document the empty
|
|
447
|
+
// string property on a key to guarantee this as metadata.
|
|
448
|
+
// @ts-ignore
|
|
449
|
+
config.plural_forms;
|
|
450
|
+
if (typeof pf !== "function") {
|
|
451
|
+
plural = getPluralExpression(
|
|
452
|
+
config["Plural-Forms"] || config["plural-forms"] || // Ignore reason: As known, there's no way to document the empty
|
|
453
|
+
// string property on a key to guarantee this as metadata.
|
|
454
|
+
// @ts-ignore
|
|
455
|
+
config.plural_forms
|
|
456
|
+
);
|
|
457
|
+
pf = pluralForms(plural);
|
|
458
|
+
}
|
|
459
|
+
getPluralForm = this.pluralForms[domain] = pf;
|
|
460
|
+
}
|
|
461
|
+
return getPluralForm(n);
|
|
462
|
+
};
|
|
463
|
+
Tannin.prototype.dcnpgettext = function(domain, context, singular, plural, n) {
|
|
464
|
+
var index, key, entry;
|
|
465
|
+
if (n === void 0) {
|
|
466
|
+
index = 0;
|
|
467
|
+
} else {
|
|
468
|
+
index = this.getPluralForm(domain, n);
|
|
469
|
+
}
|
|
470
|
+
key = singular;
|
|
471
|
+
if (context) {
|
|
472
|
+
key = context + this.options.contextDelimiter + singular;
|
|
473
|
+
}
|
|
474
|
+
entry = this.data[domain][key];
|
|
475
|
+
if (entry && entry[index]) {
|
|
476
|
+
return entry[index];
|
|
477
|
+
}
|
|
478
|
+
if (this.options.onMissingKey) {
|
|
479
|
+
this.options.onMissingKey(singular, domain);
|
|
480
|
+
}
|
|
481
|
+
return index === 0 ? singular : plural;
|
|
482
|
+
};
|
|
483
|
+
const DEFAULT_LOCALE_DATA = {
|
|
484
|
+
"": {
|
|
485
|
+
/** @param {number} n */
|
|
486
|
+
plural_forms(n) {
|
|
487
|
+
return n === 1 ? 0 : 1;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
};
|
|
491
|
+
const I18N_HOOK_REGEXP = /^i18n\.(n?gettext|has_translation)(_|$)/;
|
|
492
|
+
const createI18n = (initialData, initialDomain, hooks) => {
|
|
493
|
+
const tannin = new Tannin({});
|
|
494
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
495
|
+
const notifyListeners = () => {
|
|
496
|
+
listeners.forEach((listener) => listener());
|
|
497
|
+
};
|
|
498
|
+
const subscribe = (callback) => {
|
|
499
|
+
listeners.add(callback);
|
|
500
|
+
return () => listeners.delete(callback);
|
|
501
|
+
};
|
|
502
|
+
const getLocaleData = (domain = "default") => tannin.data[domain];
|
|
503
|
+
const doSetLocaleData = (data, domain = "default") => {
|
|
504
|
+
var _a;
|
|
505
|
+
tannin.data[domain] = {
|
|
506
|
+
...tannin.data[domain],
|
|
507
|
+
...data
|
|
508
|
+
};
|
|
509
|
+
tannin.data[domain][""] = {
|
|
510
|
+
...DEFAULT_LOCALE_DATA[""],
|
|
511
|
+
...(_a = tannin.data[domain]) == null ? void 0 : _a[""]
|
|
512
|
+
};
|
|
513
|
+
delete tannin.pluralForms[domain];
|
|
514
|
+
};
|
|
515
|
+
const setLocaleData = (data, domain) => {
|
|
516
|
+
doSetLocaleData(data, domain);
|
|
517
|
+
notifyListeners();
|
|
518
|
+
};
|
|
519
|
+
const addLocaleData = (data, domain = "default") => {
|
|
520
|
+
var _a;
|
|
521
|
+
tannin.data[domain] = {
|
|
522
|
+
...tannin.data[domain],
|
|
523
|
+
...data,
|
|
524
|
+
// Populate default domain configuration (supported locale date which omits
|
|
525
|
+
// a plural forms expression).
|
|
526
|
+
"": {
|
|
527
|
+
...DEFAULT_LOCALE_DATA[""],
|
|
528
|
+
...(_a = tannin.data[domain]) == null ? void 0 : _a[""],
|
|
529
|
+
...data == null ? void 0 : data[""]
|
|
530
|
+
}
|
|
531
|
+
};
|
|
532
|
+
delete tannin.pluralForms[domain];
|
|
533
|
+
notifyListeners();
|
|
534
|
+
};
|
|
535
|
+
const resetLocaleData = (data, domain) => {
|
|
536
|
+
tannin.data = {};
|
|
537
|
+
tannin.pluralForms = {};
|
|
538
|
+
setLocaleData(data, domain);
|
|
539
|
+
};
|
|
540
|
+
const dcnpgettext = (domain = "default", context, single, plural, number) => {
|
|
541
|
+
if (!tannin.data[domain]) {
|
|
542
|
+
doSetLocaleData(void 0, domain);
|
|
543
|
+
}
|
|
544
|
+
return tannin.dcnpgettext(domain, context, single, plural, number);
|
|
545
|
+
};
|
|
546
|
+
const getFilterDomain = (domain = "default") => domain;
|
|
547
|
+
const __2 = (text, domain) => {
|
|
548
|
+
let translation = dcnpgettext(domain, void 0, text);
|
|
549
|
+
if (!hooks) {
|
|
550
|
+
return translation;
|
|
551
|
+
}
|
|
552
|
+
translation = /** @type {string} */
|
|
553
|
+
/** @type {*} */
|
|
554
|
+
hooks.applyFilters("i18n.gettext", translation, text, domain);
|
|
555
|
+
return (
|
|
556
|
+
/** @type {string} */
|
|
557
|
+
/** @type {*} */
|
|
558
|
+
hooks.applyFilters("i18n.gettext_" + getFilterDomain(domain), translation, text, domain)
|
|
559
|
+
);
|
|
560
|
+
};
|
|
561
|
+
const _x = (text, context, domain) => {
|
|
562
|
+
let translation = dcnpgettext(domain, context, text);
|
|
563
|
+
if (!hooks) {
|
|
564
|
+
return translation;
|
|
565
|
+
}
|
|
566
|
+
translation = /** @type {string} */
|
|
567
|
+
/** @type {*} */
|
|
568
|
+
hooks.applyFilters("i18n.gettext_with_context", translation, text, context, domain);
|
|
569
|
+
return (
|
|
570
|
+
/** @type {string} */
|
|
571
|
+
/** @type {*} */
|
|
572
|
+
hooks.applyFilters("i18n.gettext_with_context_" + getFilterDomain(domain), translation, text, context, domain)
|
|
573
|
+
);
|
|
574
|
+
};
|
|
575
|
+
const _n2 = (single, plural, number, domain) => {
|
|
576
|
+
let translation = dcnpgettext(domain, void 0, single, plural, number);
|
|
577
|
+
if (!hooks) {
|
|
578
|
+
return translation;
|
|
579
|
+
}
|
|
580
|
+
translation = /** @type {string} */
|
|
581
|
+
/** @type {*} */
|
|
582
|
+
hooks.applyFilters("i18n.ngettext", translation, single, plural, number, domain);
|
|
583
|
+
return (
|
|
584
|
+
/** @type {string} */
|
|
585
|
+
/** @type {*} */
|
|
586
|
+
hooks.applyFilters("i18n.ngettext_" + getFilterDomain(domain), translation, single, plural, number, domain)
|
|
587
|
+
);
|
|
588
|
+
};
|
|
589
|
+
const _nx = (single, plural, number, context, domain) => {
|
|
590
|
+
let translation = dcnpgettext(domain, context, single, plural, number);
|
|
591
|
+
if (!hooks) {
|
|
592
|
+
return translation;
|
|
593
|
+
}
|
|
594
|
+
translation = /** @type {string} */
|
|
595
|
+
/** @type {*} */
|
|
596
|
+
hooks.applyFilters("i18n.ngettext_with_context", translation, single, plural, number, context, domain);
|
|
597
|
+
return (
|
|
598
|
+
/** @type {string} */
|
|
599
|
+
/** @type {*} */
|
|
600
|
+
hooks.applyFilters("i18n.ngettext_with_context_" + getFilterDomain(domain), translation, single, plural, number, context, domain)
|
|
601
|
+
);
|
|
602
|
+
};
|
|
603
|
+
const isRTL = () => {
|
|
604
|
+
return "rtl" === _x("ltr", "text direction");
|
|
605
|
+
};
|
|
606
|
+
const hasTranslation = (single, context, domain) => {
|
|
607
|
+
var _a, _b;
|
|
608
|
+
const key = context ? context + "" + single : single;
|
|
609
|
+
let result = !!((_b = (_a = tannin.data) == null ? void 0 : _a[domain !== null && domain !== void 0 ? domain : "default"]) == null ? void 0 : _b[key]);
|
|
610
|
+
if (hooks) {
|
|
611
|
+
result = /** @type { boolean } */
|
|
612
|
+
/** @type {*} */
|
|
613
|
+
hooks.applyFilters("i18n.has_translation", result, single, context, domain);
|
|
614
|
+
result = /** @type { boolean } */
|
|
615
|
+
/** @type {*} */
|
|
616
|
+
hooks.applyFilters("i18n.has_translation_" + getFilterDomain(domain), result, single, context, domain);
|
|
617
|
+
}
|
|
618
|
+
return result;
|
|
619
|
+
};
|
|
620
|
+
if (hooks) {
|
|
621
|
+
const onHookAddedOrRemoved = (hookName) => {
|
|
622
|
+
if (I18N_HOOK_REGEXP.test(hookName)) {
|
|
623
|
+
notifyListeners();
|
|
624
|
+
}
|
|
625
|
+
};
|
|
626
|
+
hooks.addAction("hookAdded", "core/i18n", onHookAddedOrRemoved);
|
|
627
|
+
hooks.addAction("hookRemoved", "core/i18n", onHookAddedOrRemoved);
|
|
628
|
+
}
|
|
629
|
+
return {
|
|
630
|
+
getLocaleData,
|
|
631
|
+
setLocaleData,
|
|
632
|
+
addLocaleData,
|
|
633
|
+
resetLocaleData,
|
|
634
|
+
subscribe,
|
|
635
|
+
__: __2,
|
|
636
|
+
_x,
|
|
637
|
+
_n: _n2,
|
|
638
|
+
_nx,
|
|
639
|
+
isRTL,
|
|
640
|
+
hasTranslation
|
|
641
|
+
};
|
|
642
|
+
};
|
|
643
|
+
function validateNamespace(namespace) {
|
|
644
|
+
if ("string" !== typeof namespace || "" === namespace) {
|
|
645
|
+
console.error("The namespace must be a non-empty string.");
|
|
646
|
+
return false;
|
|
647
|
+
}
|
|
648
|
+
if (!/^[a-zA-Z][a-zA-Z0-9_.\-\/]*$/.test(namespace)) {
|
|
649
|
+
console.error("The namespace can only contain numbers, letters, dashes, periods, underscores and slashes.");
|
|
650
|
+
return false;
|
|
651
|
+
}
|
|
652
|
+
return true;
|
|
653
|
+
}
|
|
654
|
+
function validateHookName(hookName) {
|
|
655
|
+
if ("string" !== typeof hookName || "" === hookName) {
|
|
656
|
+
console.error("The hook name must be a non-empty string.");
|
|
657
|
+
return false;
|
|
658
|
+
}
|
|
659
|
+
if (/^__/.test(hookName)) {
|
|
660
|
+
console.error("The hook name cannot begin with `__`.");
|
|
661
|
+
return false;
|
|
662
|
+
}
|
|
663
|
+
if (!/^[a-zA-Z][a-zA-Z0-9_.-]*$/.test(hookName)) {
|
|
664
|
+
console.error("The hook name can only contain numbers, letters, dashes, periods and underscores.");
|
|
665
|
+
return false;
|
|
666
|
+
}
|
|
667
|
+
return true;
|
|
668
|
+
}
|
|
669
|
+
function createAddHook(hooks, storeKey) {
|
|
670
|
+
return function addHook(hookName, namespace, callback, priority = 10) {
|
|
671
|
+
const hooksStore = hooks[storeKey];
|
|
672
|
+
if (!validateHookName(hookName)) {
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
if (!validateNamespace(namespace)) {
|
|
676
|
+
return;
|
|
677
|
+
}
|
|
678
|
+
if ("function" !== typeof callback) {
|
|
679
|
+
console.error("The hook callback must be a function.");
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
if ("number" !== typeof priority) {
|
|
683
|
+
console.error("If specified, the hook priority must be a number.");
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
const handler = {
|
|
687
|
+
callback,
|
|
688
|
+
priority,
|
|
689
|
+
namespace
|
|
690
|
+
};
|
|
691
|
+
if (hooksStore[hookName]) {
|
|
692
|
+
const handlers = hooksStore[hookName].handlers;
|
|
693
|
+
let i;
|
|
694
|
+
for (i = handlers.length; i > 0; i--) {
|
|
695
|
+
if (priority >= handlers[i - 1].priority) {
|
|
696
|
+
break;
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
if (i === handlers.length) {
|
|
700
|
+
handlers[i] = handler;
|
|
701
|
+
} else {
|
|
702
|
+
handlers.splice(i, 0, handler);
|
|
703
|
+
}
|
|
704
|
+
hooksStore.__current.forEach((hookInfo) => {
|
|
705
|
+
if (hookInfo.name === hookName && hookInfo.currentIndex >= i) {
|
|
706
|
+
hookInfo.currentIndex++;
|
|
707
|
+
}
|
|
708
|
+
});
|
|
709
|
+
} else {
|
|
710
|
+
hooksStore[hookName] = {
|
|
711
|
+
handlers: [handler],
|
|
712
|
+
runs: 0
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
if (hookName !== "hookAdded") {
|
|
716
|
+
hooks.doAction("hookAdded", hookName, namespace, callback, priority);
|
|
717
|
+
}
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
function createRemoveHook(hooks, storeKey, removeAll = false) {
|
|
721
|
+
return function removeHook(hookName, namespace) {
|
|
722
|
+
const hooksStore = hooks[storeKey];
|
|
723
|
+
if (!validateHookName(hookName)) {
|
|
724
|
+
return;
|
|
725
|
+
}
|
|
726
|
+
if (!removeAll && !validateNamespace(namespace)) {
|
|
727
|
+
return;
|
|
728
|
+
}
|
|
729
|
+
if (!hooksStore[hookName]) {
|
|
730
|
+
return 0;
|
|
731
|
+
}
|
|
732
|
+
let handlersRemoved = 0;
|
|
733
|
+
if (removeAll) {
|
|
734
|
+
handlersRemoved = hooksStore[hookName].handlers.length;
|
|
735
|
+
hooksStore[hookName] = {
|
|
736
|
+
runs: hooksStore[hookName].runs,
|
|
737
|
+
handlers: []
|
|
738
|
+
};
|
|
739
|
+
} else {
|
|
740
|
+
const handlers = hooksStore[hookName].handlers;
|
|
741
|
+
for (let i = handlers.length - 1; i >= 0; i--) {
|
|
742
|
+
if (handlers[i].namespace === namespace) {
|
|
743
|
+
handlers.splice(i, 1);
|
|
744
|
+
handlersRemoved++;
|
|
745
|
+
hooksStore.__current.forEach((hookInfo) => {
|
|
746
|
+
if (hookInfo.name === hookName && hookInfo.currentIndex >= i) {
|
|
747
|
+
hookInfo.currentIndex--;
|
|
748
|
+
}
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
if (hookName !== "hookRemoved") {
|
|
754
|
+
hooks.doAction("hookRemoved", hookName, namespace);
|
|
755
|
+
}
|
|
756
|
+
return handlersRemoved;
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
function createHasHook(hooks, storeKey) {
|
|
760
|
+
return function hasHook(hookName, namespace) {
|
|
761
|
+
const hooksStore = hooks[storeKey];
|
|
762
|
+
if ("undefined" !== typeof namespace) {
|
|
763
|
+
return hookName in hooksStore && hooksStore[hookName].handlers.some((hook) => hook.namespace === namespace);
|
|
764
|
+
}
|
|
765
|
+
return hookName in hooksStore;
|
|
766
|
+
};
|
|
767
|
+
}
|
|
768
|
+
function createRunHook(hooks, storeKey, returnFirstArg, async) {
|
|
769
|
+
return function runHook(hookName, ...args) {
|
|
770
|
+
const hooksStore = hooks[storeKey];
|
|
771
|
+
if (!hooksStore[hookName]) {
|
|
772
|
+
hooksStore[hookName] = {
|
|
773
|
+
handlers: [],
|
|
774
|
+
runs: 0
|
|
775
|
+
};
|
|
776
|
+
}
|
|
777
|
+
hooksStore[hookName].runs++;
|
|
778
|
+
const handlers = hooksStore[hookName].handlers;
|
|
779
|
+
if ("production" !== process.env.NODE_ENV) {
|
|
780
|
+
if ("hookAdded" !== hookName && hooksStore.all) {
|
|
781
|
+
handlers.push(...hooksStore.all.handlers);
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
if (!handlers || !handlers.length) {
|
|
785
|
+
return returnFirstArg ? args[0] : void 0;
|
|
786
|
+
}
|
|
787
|
+
const hookInfo = {
|
|
788
|
+
name: hookName,
|
|
789
|
+
currentIndex: 0
|
|
790
|
+
};
|
|
791
|
+
async function asyncRunner() {
|
|
792
|
+
try {
|
|
793
|
+
hooksStore.__current.add(hookInfo);
|
|
794
|
+
let result = returnFirstArg ? args[0] : void 0;
|
|
795
|
+
while (hookInfo.currentIndex < handlers.length) {
|
|
796
|
+
const handler = handlers[hookInfo.currentIndex];
|
|
797
|
+
result = await handler.callback.apply(null, args);
|
|
798
|
+
if (returnFirstArg) {
|
|
799
|
+
args[0] = result;
|
|
800
|
+
}
|
|
801
|
+
hookInfo.currentIndex++;
|
|
802
|
+
}
|
|
803
|
+
return returnFirstArg ? result : void 0;
|
|
804
|
+
} finally {
|
|
805
|
+
hooksStore.__current.delete(hookInfo);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
function syncRunner() {
|
|
809
|
+
try {
|
|
810
|
+
hooksStore.__current.add(hookInfo);
|
|
811
|
+
let result = returnFirstArg ? args[0] : void 0;
|
|
812
|
+
while (hookInfo.currentIndex < handlers.length) {
|
|
813
|
+
const handler = handlers[hookInfo.currentIndex];
|
|
814
|
+
result = handler.callback.apply(null, args);
|
|
815
|
+
if (returnFirstArg) {
|
|
816
|
+
args[0] = result;
|
|
817
|
+
}
|
|
818
|
+
hookInfo.currentIndex++;
|
|
819
|
+
}
|
|
820
|
+
return returnFirstArg ? result : void 0;
|
|
821
|
+
} finally {
|
|
822
|
+
hooksStore.__current.delete(hookInfo);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
return (async ? asyncRunner : syncRunner)();
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
function createCurrentHook(hooks, storeKey) {
|
|
829
|
+
return function currentHook() {
|
|
830
|
+
var _a;
|
|
831
|
+
var _currentArray$at$name;
|
|
832
|
+
const hooksStore = hooks[storeKey];
|
|
833
|
+
const currentArray = Array.from(hooksStore.__current);
|
|
834
|
+
return (_currentArray$at$name = (_a = currentArray.at(-1)) == null ? void 0 : _a.name) !== null && _currentArray$at$name !== void 0 ? _currentArray$at$name : null;
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
function createDoingHook(hooks, storeKey) {
|
|
838
|
+
return function doingHook(hookName) {
|
|
839
|
+
const hooksStore = hooks[storeKey];
|
|
840
|
+
if ("undefined" === typeof hookName) {
|
|
841
|
+
return hooksStore.__current.size > 0;
|
|
842
|
+
}
|
|
843
|
+
return Array.from(hooksStore.__current).some((hook) => hook.name === hookName);
|
|
844
|
+
};
|
|
845
|
+
}
|
|
846
|
+
function createDidHook(hooks, storeKey) {
|
|
847
|
+
return function didHook(hookName) {
|
|
848
|
+
const hooksStore = hooks[storeKey];
|
|
849
|
+
if (!validateHookName(hookName)) {
|
|
850
|
+
return;
|
|
851
|
+
}
|
|
852
|
+
return hooksStore[hookName] && hooksStore[hookName].runs ? hooksStore[hookName].runs : 0;
|
|
853
|
+
};
|
|
854
|
+
}
|
|
855
|
+
class _Hooks {
|
|
856
|
+
constructor() {
|
|
857
|
+
this.actions = /* @__PURE__ */ Object.create(null);
|
|
858
|
+
this.actions.__current = /* @__PURE__ */ new Set();
|
|
859
|
+
this.filters = /* @__PURE__ */ Object.create(null);
|
|
860
|
+
this.filters.__current = /* @__PURE__ */ new Set();
|
|
861
|
+
this.addAction = createAddHook(this, "actions");
|
|
862
|
+
this.addFilter = createAddHook(this, "filters");
|
|
863
|
+
this.removeAction = createRemoveHook(this, "actions");
|
|
864
|
+
this.removeFilter = createRemoveHook(this, "filters");
|
|
865
|
+
this.hasAction = createHasHook(this, "actions");
|
|
866
|
+
this.hasFilter = createHasHook(this, "filters");
|
|
867
|
+
this.removeAllActions = createRemoveHook(this, "actions", true);
|
|
868
|
+
this.removeAllFilters = createRemoveHook(this, "filters", true);
|
|
869
|
+
this.doAction = createRunHook(this, "actions", false, false);
|
|
870
|
+
this.doActionAsync = createRunHook(this, "actions", false, true);
|
|
871
|
+
this.applyFilters = createRunHook(this, "filters", true, false);
|
|
872
|
+
this.applyFiltersAsync = createRunHook(this, "filters", true, true);
|
|
873
|
+
this.currentAction = createCurrentHook(this, "actions");
|
|
874
|
+
this.currentFilter = createCurrentHook(this, "filters");
|
|
875
|
+
this.doingAction = createDoingHook(this, "actions");
|
|
876
|
+
this.doingFilter = createDoingHook(this, "filters");
|
|
877
|
+
this.didAction = createDidHook(this, "actions");
|
|
878
|
+
this.didFilter = createDidHook(this, "filters");
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
function createHooks() {
|
|
882
|
+
return new _Hooks();
|
|
883
|
+
}
|
|
884
|
+
const defaultHooks = createHooks();
|
|
885
|
+
const {
|
|
886
|
+
addAction,
|
|
887
|
+
addFilter,
|
|
888
|
+
removeAction,
|
|
889
|
+
removeFilter,
|
|
890
|
+
hasAction,
|
|
891
|
+
hasFilter,
|
|
892
|
+
removeAllActions,
|
|
893
|
+
removeAllFilters,
|
|
894
|
+
doAction,
|
|
895
|
+
doActionAsync,
|
|
896
|
+
applyFilters,
|
|
897
|
+
applyFiltersAsync,
|
|
898
|
+
currentAction,
|
|
899
|
+
currentFilter,
|
|
900
|
+
doingAction,
|
|
901
|
+
doingFilter,
|
|
902
|
+
didAction,
|
|
903
|
+
didFilter,
|
|
904
|
+
actions,
|
|
905
|
+
filters
|
|
906
|
+
} = defaultHooks;
|
|
907
|
+
const i18n = createI18n(void 0, void 0, defaultHooks);
|
|
908
|
+
i18n.getLocaleData.bind(i18n);
|
|
909
|
+
i18n.setLocaleData.bind(i18n);
|
|
910
|
+
i18n.resetLocaleData.bind(i18n);
|
|
911
|
+
i18n.subscribe.bind(i18n);
|
|
912
|
+
const __ = i18n.__.bind(i18n);
|
|
913
|
+
i18n._x.bind(i18n);
|
|
914
|
+
const _n = i18n._n.bind(i18n);
|
|
915
|
+
i18n._nx.bind(i18n);
|
|
916
|
+
i18n.isRTL.bind(i18n);
|
|
917
|
+
i18n.hasTranslation.bind(i18n);
|
|
918
|
+
export {
|
|
919
|
+
__ as _,
|
|
920
|
+
_n as a,
|
|
921
|
+
sprintf as s
|
|
922
|
+
};
|