@eightshift/ui-components 3.0.1 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +101 -101
- package/dist/Button-BPLceDeW.js +0 -185
- package/dist/Collection-CZxddMZS.js +0 -2332
- package/dist/Color-MV5kBVXr.js +0 -2452
- package/dist/ColorSwatch-BqQfVu4L.js +0 -64
- package/dist/ComboBox-_RfyhwZw.js +0 -1906
- package/dist/Dialog-8tYeQ9n4.js +0 -2300
- package/dist/FieldError-52GVSGgC.js +0 -42
- package/dist/FocusScope-Cri5BFRz.js +0 -831
- package/dist/Form-Cq3fu75_.js +0 -5
- package/dist/Group-_emcIVxI.js +0 -48
- package/dist/Heading-B2153VXe.js +0 -16
- package/dist/Hidden-rE6uR-lr.js +0 -41
- package/dist/Input-BxpFEIXV.js +0 -133
- package/dist/Label-icmbmNdI.js +0 -17
- package/dist/List-CZMUbkFU.js +0 -593
- package/dist/ListBox-Ca6hiCqz.js +0 -581
- package/dist/NumberFormatter-DA8u1Ot7.js +0 -140
- package/dist/OverlayArrow-CYXQSlEU.js +0 -629
- package/dist/RSPContexts-2lR5GG9p.js +0 -14
- package/dist/Select-aab027f3.esm-PDJCDE95.js +0 -2469
- package/dist/Separator-4IIDRlV_.js +0 -322
- package/dist/Slider-rz2XRMGm.js +0 -853
- package/dist/Text-DVSAPY-K.js +0 -16
- package/dist/VisuallyHidden-f9zX67a_.js +0 -48
- package/dist/_commonjsHelpers-CUmg6egw.js +0 -6
- package/dist/assets/index.css +0 -37
- package/dist/assets/style-admin.css +0 -5255
- package/dist/assets/style-editor.css +0 -5255
- package/dist/assets/style.css +0 -5261
- package/dist/assets/wp-font-enhancements.css +0 -8
- package/dist/assets/wp-ui-enhancements.css +0 -299
- package/dist/components/animated-visibility/animated-visibility.js +0 -105
- package/dist/components/base-control/base-control.js +0 -86
- package/dist/components/breakpoint-preview/breakpoint-preview.js +0 -161
- package/dist/components/button/button.js +0 -387
- package/dist/components/checkbox/checkbox.js +0 -320
- package/dist/components/color-pickers/color-picker.js +0 -272
- package/dist/components/color-pickers/color-swatch.js +0 -58
- package/dist/components/color-pickers/gradient-editor.js +0 -534
- package/dist/components/color-pickers/solid-color-picker.js +0 -1567
- package/dist/components/component-toggle/component-toggle.js +0 -158
- package/dist/components/container-panel/container-panel.js +0 -131
- package/dist/components/draggable/draggable-context.js +0 -5
- package/dist/components/draggable/draggable-handle.js +0 -46
- package/dist/components/draggable/draggable.js +0 -6207
- package/dist/components/draggable-list/draggable-list-context.js +0 -5
- package/dist/components/draggable-list/draggable-list-item.js +0 -77
- package/dist/components/draggable-list/draggable-list.js +0 -151
- package/dist/components/expandable/expandable.js +0 -342
- package/dist/components/index.js +0 -137
- package/dist/components/input-field/input-field.js +0 -231
- package/dist/components/item-collection/item-collection.js +0 -59
- package/dist/components/layout/hstack.js +0 -30
- package/dist/components/layout/vstack.js +0 -30
- package/dist/components/link-input/link-input.js +0 -293
- package/dist/components/matrix-align/matrix-align.js +0 -134
- package/dist/components/menu/menu.js +0 -285
- package/dist/components/modal/modal.js +0 -305
- package/dist/components/notice/notice.js +0 -123
- package/dist/components/number-picker/number-picker.js +0 -292
- package/dist/components/option-select/option-select.js +0 -264
- package/dist/components/options-panel/options-panel.js +0 -158
- package/dist/components/placeholders/file-placeholder.js +0 -42
- package/dist/components/placeholders/image-placeholder.js +0 -88
- package/dist/components/placeholders/media-placeholder.js +0 -63
- package/dist/components/popover/popover.js +0 -207
- package/dist/components/radio/radio.js +0 -579
- package/dist/components/repeater/repeater-context.js +0 -5
- package/dist/components/repeater/repeater-item.js +0 -119
- package/dist/components/repeater/repeater.js +0 -280
- package/dist/components/responsive/mini-responsive.js +0 -498
- package/dist/components/responsive/responsive-legacy.js +0 -343
- package/dist/components/responsive/responsive.js +0 -580
- package/dist/components/responsive-preview/responsive-preview.js +0 -123
- package/dist/components/rich-label/rich-label.js +0 -66
- package/dist/components/select/async-multi-select.js +0 -157
- package/dist/components/select/async-single-select.js +0 -137
- package/dist/components/select/custom-select-default-components.js +0 -38
- package/dist/components/select/multi-select-components.js +0 -8
- package/dist/components/select/multi-select.js +0 -151
- package/dist/components/select/react-select-component-wrappers.js +0 -90
- package/dist/components/select/shared.js +0 -26
- package/dist/components/select/single-select.js +0 -131
- package/dist/components/select/styles.js +0 -49
- package/dist/components/select/v2/async-select.js +0 -297
- package/dist/components/select/v2/shared.js +0 -24
- package/dist/components/select/v2/single-select.js +0 -990
- package/dist/components/slider/column-config-slider.js +0 -210
- package/dist/components/slider/slider.js +0 -343
- package/dist/components/slider/utils.js +0 -84
- package/dist/components/spacer/spacer.js +0 -97
- package/dist/components/tabs/tabs.js +0 -702
- package/dist/components/toggle/switch.js +0 -155
- package/dist/components/toggle/toggle.js +0 -64
- package/dist/components/toggle-button/toggle-button.js +0 -324
- package/dist/components/tooltip/tooltip.js +0 -525
- package/dist/context-D2KUdwNL.js +0 -92
- package/dist/default-i18n-CT_oS1Fy.js +0 -922
- package/dist/filterDOMProps-EDDcM64A.js +0 -28
- package/dist/icons/block-icon.js +0 -42
- package/dist/icons/generic-color-swatch.js +0 -113
- package/dist/icons/icons.js +0 -30371
- package/dist/icons/index.js +0 -11
- package/dist/icons/jsx-svg.js +0 -50
- package/dist/index-641ee5b8.esm-DIuJijyT.js +0 -3137
- package/dist/index-BKGQ6jGS.js +0 -44
- package/dist/index-CFozsmNS.js +0 -28321
- package/dist/index.js +0 -139
- package/dist/lite-DVmmD_-j.js +0 -7
- package/dist/modifiers.esm-BuJQPI1X.js +0 -31
- package/dist/multi-select-components-Sp-JEFEX.js +0 -3744
- package/dist/number-GajL10e1.js +0 -36
- package/dist/react-jsx-parser.min-DZCiis5V.js +0 -11753
- package/dist/react-select-async.esm-Bql4G5iV.js +0 -107
- package/dist/react-select.esm-B_TudhTU.js +0 -15
- package/dist/style-admin.js +0 -1
- package/dist/style-editor.js +0 -1
- package/dist/style.js +0 -1
- package/dist/textSelection-0UUS8Yfg.js +0 -46
- package/dist/useButton-Cg474OYB.js +0 -71
- package/dist/useEvent-B0b-6KBr.js +0 -23
- package/dist/useFocusRing-CV5l3lf6.js +0 -107
- package/dist/useFormReset-C5OggHsw.js +0 -22
- package/dist/useFormValidation-DhDNSjws.js +0 -224
- package/dist/useHover-DwDr6ozG.js +0 -900
- package/dist/useLabel-D7HkNEHT.js +0 -27
- package/dist/useLabels-D8cxd1Z8.js +0 -23
- package/dist/useListState-DVr6aYd_.js +0 -161
- package/dist/useLocalizedStringFormatter-CFP1YZWQ.js +0 -121
- package/dist/useNumberField-TwM0Z9D1.js +0 -1204
- package/dist/useNumberFormatter-321rAb4J.js +0 -13
- package/dist/usePress-Cucx-xSA.js +0 -664
- package/dist/useSingleSelectListState-CMGsRHHh.js +0 -38
- package/dist/useToggle-C0I3vs0g.js +0 -59
- package/dist/useToggleState-CmQX3SoX.js +0 -19
- package/dist/utilities/array-helpers.js +0 -56
- package/dist/utilities/debounce-throttle.js +0 -123
- package/dist/utilities/es-dash.js +0 -376
- package/dist/utilities/index.js +0 -27
- package/dist/utilities/text-helpers.js +0 -136
- package/dist/utils-DkCSC521.js +0 -370
- package/dist/wp/wp-font-enhancements.js +0 -1
- package/dist/wp/wp-ui-enhancements.js +0 -1
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { e as $bdb11010cef70236$export$f680877a34711e37 } from "./utils-DkCSC521.js";
|
|
2
|
-
import { $ as $313b98861ee5dd6c$export$d6875122194c7b44 } from "./useLabels-D8cxd1Z8.js";
|
|
3
|
-
function $d191a55c9702f145$export$8467354a121f1b9f(props) {
|
|
4
|
-
let { id, label, "aria-labelledby": ariaLabelledby, "aria-label": ariaLabel, labelElementType = "label" } = props;
|
|
5
|
-
id = $bdb11010cef70236$export$f680877a34711e37(id);
|
|
6
|
-
let labelId = $bdb11010cef70236$export$f680877a34711e37();
|
|
7
|
-
let labelProps = {};
|
|
8
|
-
if (label) {
|
|
9
|
-
ariaLabelledby = ariaLabelledby ? `${labelId} ${ariaLabelledby}` : labelId;
|
|
10
|
-
labelProps = {
|
|
11
|
-
id: labelId,
|
|
12
|
-
htmlFor: labelElementType === "label" ? id : void 0
|
|
13
|
-
};
|
|
14
|
-
} else if (!ariaLabelledby && !ariaLabel) console.warn("If you do not provide a visible label, you must specify an aria-label or aria-labelledby attribute for accessibility");
|
|
15
|
-
let fieldProps = $313b98861ee5dd6c$export$d6875122194c7b44({
|
|
16
|
-
id,
|
|
17
|
-
"aria-label": ariaLabel,
|
|
18
|
-
"aria-labelledby": ariaLabelledby
|
|
19
|
-
});
|
|
20
|
-
return {
|
|
21
|
-
labelProps,
|
|
22
|
-
fieldProps
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
export {
|
|
26
|
-
$d191a55c9702f145$export$8467354a121f1b9f as $
|
|
27
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { e as $bdb11010cef70236$export$f680877a34711e37 } from "./utils-DkCSC521.js";
|
|
2
|
-
function $313b98861ee5dd6c$export$d6875122194c7b44(props, defaultLabel) {
|
|
3
|
-
let { id, "aria-label": label, "aria-labelledby": labelledBy } = props;
|
|
4
|
-
id = $bdb11010cef70236$export$f680877a34711e37(id);
|
|
5
|
-
if (labelledBy && label) {
|
|
6
|
-
let ids = /* @__PURE__ */ new Set([
|
|
7
|
-
id,
|
|
8
|
-
...labelledBy.trim().split(/\s+/)
|
|
9
|
-
]);
|
|
10
|
-
labelledBy = [
|
|
11
|
-
...ids
|
|
12
|
-
].join(" ");
|
|
13
|
-
} else if (labelledBy) labelledBy = labelledBy.trim().split(/\s+/).join(" ");
|
|
14
|
-
if (!label && !labelledBy && defaultLabel) label = defaultLabel;
|
|
15
|
-
return {
|
|
16
|
-
id,
|
|
17
|
-
"aria-label": label,
|
|
18
|
-
"aria-labelledby": labelledBy
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
export {
|
|
22
|
-
$313b98861ee5dd6c$export$d6875122194c7b44 as $
|
|
23
|
-
};
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { $ as $7af3f5b51489e0b5$export$253fe78d46329472, a as $7613b1592d41b092$export$6cd28814d92fa9c9, b as $d496c0a20b6e58ec$export$6c8a5aaad13c9852 } from "./Collection-CZxddMZS.js";
|
|
2
|
-
import { useMemo, useCallback, useRef, useEffect } from "react";
|
|
3
|
-
class $a02d57049d202695$export$d085fb9e920b5ca7 {
|
|
4
|
-
*[Symbol.iterator]() {
|
|
5
|
-
yield* this.iterable;
|
|
6
|
-
}
|
|
7
|
-
get size() {
|
|
8
|
-
return this.keyMap.size;
|
|
9
|
-
}
|
|
10
|
-
getKeys() {
|
|
11
|
-
return this.keyMap.keys();
|
|
12
|
-
}
|
|
13
|
-
getKeyBefore(key) {
|
|
14
|
-
let node = this.keyMap.get(key);
|
|
15
|
-
var _node_prevKey;
|
|
16
|
-
return node ? (_node_prevKey = node.prevKey) !== null && _node_prevKey !== void 0 ? _node_prevKey : null : null;
|
|
17
|
-
}
|
|
18
|
-
getKeyAfter(key) {
|
|
19
|
-
let node = this.keyMap.get(key);
|
|
20
|
-
var _node_nextKey;
|
|
21
|
-
return node ? (_node_nextKey = node.nextKey) !== null && _node_nextKey !== void 0 ? _node_nextKey : null : null;
|
|
22
|
-
}
|
|
23
|
-
getFirstKey() {
|
|
24
|
-
return this.firstKey;
|
|
25
|
-
}
|
|
26
|
-
getLastKey() {
|
|
27
|
-
return this.lastKey;
|
|
28
|
-
}
|
|
29
|
-
getItem(key) {
|
|
30
|
-
var _this_keyMap_get;
|
|
31
|
-
return (_this_keyMap_get = this.keyMap.get(key)) !== null && _this_keyMap_get !== void 0 ? _this_keyMap_get : null;
|
|
32
|
-
}
|
|
33
|
-
at(idx) {
|
|
34
|
-
const keys = [
|
|
35
|
-
...this.getKeys()
|
|
36
|
-
];
|
|
37
|
-
return this.getItem(keys[idx]);
|
|
38
|
-
}
|
|
39
|
-
getChildren(key) {
|
|
40
|
-
let node = this.keyMap.get(key);
|
|
41
|
-
return (node === null || node === void 0 ? void 0 : node.childNodes) || [];
|
|
42
|
-
}
|
|
43
|
-
constructor(nodes) {
|
|
44
|
-
this.keyMap = /* @__PURE__ */ new Map();
|
|
45
|
-
this.firstKey = null;
|
|
46
|
-
this.lastKey = null;
|
|
47
|
-
this.iterable = nodes;
|
|
48
|
-
let visit = (node) => {
|
|
49
|
-
this.keyMap.set(node.key, node);
|
|
50
|
-
if (node.childNodes && node.type === "section") for (let child of node.childNodes) visit(child);
|
|
51
|
-
};
|
|
52
|
-
for (let node of nodes) visit(node);
|
|
53
|
-
let last = null;
|
|
54
|
-
let index = 0;
|
|
55
|
-
for (let [key, node] of this.keyMap) {
|
|
56
|
-
if (last) {
|
|
57
|
-
last.nextKey = key;
|
|
58
|
-
node.prevKey = last.key;
|
|
59
|
-
} else {
|
|
60
|
-
this.firstKey = key;
|
|
61
|
-
node.prevKey = void 0;
|
|
62
|
-
}
|
|
63
|
-
if (node.type === "item") node.index = index++;
|
|
64
|
-
last = node;
|
|
65
|
-
last.nextKey = void 0;
|
|
66
|
-
}
|
|
67
|
-
var _last_key;
|
|
68
|
-
this.lastKey = (_last_key = last === null || last === void 0 ? void 0 : last.key) !== null && _last_key !== void 0 ? _last_key : null;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
function $e72dd72e1c76a225$export$2f645645f7bca764(props) {
|
|
72
|
-
let { filter, layoutDelegate } = props;
|
|
73
|
-
let selectionState = $7af3f5b51489e0b5$export$253fe78d46329472(props);
|
|
74
|
-
let disabledKeys = useMemo(() => props.disabledKeys ? new Set(props.disabledKeys) : /* @__PURE__ */ new Set(), [
|
|
75
|
-
props.disabledKeys
|
|
76
|
-
]);
|
|
77
|
-
let factory = useCallback((nodes) => filter ? new $a02d57049d202695$export$d085fb9e920b5ca7(filter(nodes)) : new $a02d57049d202695$export$d085fb9e920b5ca7(nodes), [
|
|
78
|
-
filter
|
|
79
|
-
]);
|
|
80
|
-
let context = useMemo(() => ({
|
|
81
|
-
suppressTextValueWarning: props.suppressTextValueWarning
|
|
82
|
-
}), [
|
|
83
|
-
props.suppressTextValueWarning
|
|
84
|
-
]);
|
|
85
|
-
let collection = $7613b1592d41b092$export$6cd28814d92fa9c9(props, factory, context);
|
|
86
|
-
let selectionManager = useMemo(() => new $d496c0a20b6e58ec$export$6c8a5aaad13c9852(collection, selectionState, {
|
|
87
|
-
layoutDelegate
|
|
88
|
-
}), [
|
|
89
|
-
collection,
|
|
90
|
-
selectionState,
|
|
91
|
-
layoutDelegate
|
|
92
|
-
]);
|
|
93
|
-
$e72dd72e1c76a225$var$useFocusedKeyReset(collection, selectionManager);
|
|
94
|
-
return {
|
|
95
|
-
collection,
|
|
96
|
-
disabledKeys,
|
|
97
|
-
selectionManager
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
function $e72dd72e1c76a225$export$ba9d38c0f1bf2b36(state, filter) {
|
|
101
|
-
let collection = useMemo(() => filter ? state.collection.UNSTABLE_filter(filter) : state.collection, [
|
|
102
|
-
state.collection,
|
|
103
|
-
filter
|
|
104
|
-
]);
|
|
105
|
-
let selectionManager = state.selectionManager.withCollection(collection);
|
|
106
|
-
$e72dd72e1c76a225$var$useFocusedKeyReset(collection, selectionManager);
|
|
107
|
-
return {
|
|
108
|
-
collection,
|
|
109
|
-
selectionManager,
|
|
110
|
-
disabledKeys: state.disabledKeys
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
function $e72dd72e1c76a225$var$useFocusedKeyReset(collection, selectionManager) {
|
|
114
|
-
const cachedCollection = useRef(null);
|
|
115
|
-
useEffect(() => {
|
|
116
|
-
if (selectionManager.focusedKey != null && !collection.getItem(selectionManager.focusedKey) && cachedCollection.current) {
|
|
117
|
-
const startItem = cachedCollection.current.getItem(selectionManager.focusedKey);
|
|
118
|
-
const cachedItemNodes = [
|
|
119
|
-
...cachedCollection.current.getKeys()
|
|
120
|
-
].map((key) => {
|
|
121
|
-
const itemNode = cachedCollection.current.getItem(key);
|
|
122
|
-
return (itemNode === null || itemNode === void 0 ? void 0 : itemNode.type) === "item" ? itemNode : null;
|
|
123
|
-
}).filter((node) => node !== null);
|
|
124
|
-
const itemNodes = [
|
|
125
|
-
...collection.getKeys()
|
|
126
|
-
].map((key) => {
|
|
127
|
-
const itemNode = collection.getItem(key);
|
|
128
|
-
return (itemNode === null || itemNode === void 0 ? void 0 : itemNode.type) === "item" ? itemNode : null;
|
|
129
|
-
}).filter((node) => node !== null);
|
|
130
|
-
var _cachedItemNodes_length, _itemNodes_length;
|
|
131
|
-
const diff = ((_cachedItemNodes_length = cachedItemNodes === null || cachedItemNodes === void 0 ? void 0 : cachedItemNodes.length) !== null && _cachedItemNodes_length !== void 0 ? _cachedItemNodes_length : 0) - ((_itemNodes_length = itemNodes === null || itemNodes === void 0 ? void 0 : itemNodes.length) !== null && _itemNodes_length !== void 0 ? _itemNodes_length : 0);
|
|
132
|
-
var _startItem_index, _startItem_index1, _itemNodes_length1;
|
|
133
|
-
let index = Math.min(diff > 1 ? Math.max(((_startItem_index = startItem === null || startItem === void 0 ? void 0 : startItem.index) !== null && _startItem_index !== void 0 ? _startItem_index : 0) - diff + 1, 0) : (_startItem_index1 = startItem === null || startItem === void 0 ? void 0 : startItem.index) !== null && _startItem_index1 !== void 0 ? _startItem_index1 : 0, ((_itemNodes_length1 = itemNodes === null || itemNodes === void 0 ? void 0 : itemNodes.length) !== null && _itemNodes_length1 !== void 0 ? _itemNodes_length1 : 0) - 1);
|
|
134
|
-
let newNode = null;
|
|
135
|
-
let isReverseSearching = false;
|
|
136
|
-
while (index >= 0) {
|
|
137
|
-
if (!selectionManager.isDisabled(itemNodes[index].key)) {
|
|
138
|
-
newNode = itemNodes[index];
|
|
139
|
-
break;
|
|
140
|
-
}
|
|
141
|
-
if (index < itemNodes.length - 1 && !isReverseSearching) index++;
|
|
142
|
-
else {
|
|
143
|
-
isReverseSearching = true;
|
|
144
|
-
var _startItem_index2, _startItem_index3;
|
|
145
|
-
if (index > ((_startItem_index2 = startItem === null || startItem === void 0 ? void 0 : startItem.index) !== null && _startItem_index2 !== void 0 ? _startItem_index2 : 0)) index = (_startItem_index3 = startItem === null || startItem === void 0 ? void 0 : startItem.index) !== null && _startItem_index3 !== void 0 ? _startItem_index3 : 0;
|
|
146
|
-
index--;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
selectionManager.setFocusedKey(newNode ? newNode.key : null);
|
|
150
|
-
}
|
|
151
|
-
cachedCollection.current = collection;
|
|
152
|
-
}, [
|
|
153
|
-
collection,
|
|
154
|
-
selectionManager
|
|
155
|
-
]);
|
|
156
|
-
}
|
|
157
|
-
export {
|
|
158
|
-
$e72dd72e1c76a225$export$2f645645f7bca764 as $,
|
|
159
|
-
$e72dd72e1c76a225$export$ba9d38c0f1bf2b36 as a,
|
|
160
|
-
$a02d57049d202695$export$d085fb9e920b5ca7 as b
|
|
161
|
-
};
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { $ as $18f2051aff69b9bf$export$43bb16f9c6d9e3f7 } from "./context-D2KUdwNL.js";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
const $5b160d28a433310d$var$localeSymbol = Symbol.for("react-aria.i18n.locale");
|
|
4
|
-
const $5b160d28a433310d$var$stringsSymbol = Symbol.for("react-aria.i18n.strings");
|
|
5
|
-
let $5b160d28a433310d$var$cachedGlobalStrings = void 0;
|
|
6
|
-
class $5b160d28a433310d$export$c17fa47878dc55b6 {
|
|
7
|
-
/** Returns a localized string for the given key and locale. */
|
|
8
|
-
getStringForLocale(key, locale) {
|
|
9
|
-
let strings = this.getStringsForLocale(locale);
|
|
10
|
-
let string = strings[key];
|
|
11
|
-
if (!string) throw new Error(`Could not find intl message ${key} in ${locale} locale`);
|
|
12
|
-
return string;
|
|
13
|
-
}
|
|
14
|
-
/** Returns all localized strings for the given locale. */
|
|
15
|
-
getStringsForLocale(locale) {
|
|
16
|
-
let strings = this.strings[locale];
|
|
17
|
-
if (!strings) {
|
|
18
|
-
strings = $5b160d28a433310d$var$getStringsForLocale(locale, this.strings, this.defaultLocale);
|
|
19
|
-
this.strings[locale] = strings;
|
|
20
|
-
}
|
|
21
|
-
return strings;
|
|
22
|
-
}
|
|
23
|
-
static getGlobalDictionaryForPackage(packageName) {
|
|
24
|
-
if (typeof window === "undefined") return null;
|
|
25
|
-
let locale = window[$5b160d28a433310d$var$localeSymbol];
|
|
26
|
-
if ($5b160d28a433310d$var$cachedGlobalStrings === void 0) {
|
|
27
|
-
let globalStrings = window[$5b160d28a433310d$var$stringsSymbol];
|
|
28
|
-
if (!globalStrings) return null;
|
|
29
|
-
$5b160d28a433310d$var$cachedGlobalStrings = {};
|
|
30
|
-
for (let pkg in globalStrings) $5b160d28a433310d$var$cachedGlobalStrings[pkg] = new $5b160d28a433310d$export$c17fa47878dc55b6({
|
|
31
|
-
[locale]: globalStrings[pkg]
|
|
32
|
-
}, locale);
|
|
33
|
-
}
|
|
34
|
-
let dictionary = $5b160d28a433310d$var$cachedGlobalStrings === null || $5b160d28a433310d$var$cachedGlobalStrings === void 0 ? void 0 : $5b160d28a433310d$var$cachedGlobalStrings[packageName];
|
|
35
|
-
if (!dictionary) throw new Error(`Strings for package "${packageName}" were not included by LocalizedStringProvider. Please add it to the list passed to createLocalizedStringDictionary.`);
|
|
36
|
-
return dictionary;
|
|
37
|
-
}
|
|
38
|
-
constructor(messages, defaultLocale = "en-US") {
|
|
39
|
-
this.strings = Object.fromEntries(Object.entries(messages).filter(([, v]) => v));
|
|
40
|
-
this.defaultLocale = defaultLocale;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
function $5b160d28a433310d$var$getStringsForLocale(locale, strings, defaultLocale = "en-US") {
|
|
44
|
-
if (strings[locale]) return strings[locale];
|
|
45
|
-
let language = $5b160d28a433310d$var$getLanguage(locale);
|
|
46
|
-
if (strings[language]) return strings[language];
|
|
47
|
-
for (let key in strings) {
|
|
48
|
-
if (key.startsWith(language + "-")) return strings[key];
|
|
49
|
-
}
|
|
50
|
-
return strings[defaultLocale];
|
|
51
|
-
}
|
|
52
|
-
function $5b160d28a433310d$var$getLanguage(locale) {
|
|
53
|
-
if (Intl.Locale)
|
|
54
|
-
return new Intl.Locale(locale).language;
|
|
55
|
-
return locale.split("-")[0];
|
|
56
|
-
}
|
|
57
|
-
const $6db58dc88e78b024$var$pluralRulesCache = /* @__PURE__ */ new Map();
|
|
58
|
-
const $6db58dc88e78b024$var$numberFormatCache = /* @__PURE__ */ new Map();
|
|
59
|
-
class $6db58dc88e78b024$export$2f817fcdc4b89ae0 {
|
|
60
|
-
/** Formats a localized string for the given key with the provided variables. */
|
|
61
|
-
format(key, variables) {
|
|
62
|
-
let message = this.strings.getStringForLocale(key, this.locale);
|
|
63
|
-
return typeof message === "function" ? message(variables, this) : message;
|
|
64
|
-
}
|
|
65
|
-
plural(count, options, type = "cardinal") {
|
|
66
|
-
let opt = options["=" + count];
|
|
67
|
-
if (opt) return typeof opt === "function" ? opt() : opt;
|
|
68
|
-
let key = this.locale + ":" + type;
|
|
69
|
-
let pluralRules = $6db58dc88e78b024$var$pluralRulesCache.get(key);
|
|
70
|
-
if (!pluralRules) {
|
|
71
|
-
pluralRules = new Intl.PluralRules(this.locale, {
|
|
72
|
-
type
|
|
73
|
-
});
|
|
74
|
-
$6db58dc88e78b024$var$pluralRulesCache.set(key, pluralRules);
|
|
75
|
-
}
|
|
76
|
-
let selected = pluralRules.select(count);
|
|
77
|
-
opt = options[selected] || options.other;
|
|
78
|
-
return typeof opt === "function" ? opt() : opt;
|
|
79
|
-
}
|
|
80
|
-
number(value) {
|
|
81
|
-
let numberFormat = $6db58dc88e78b024$var$numberFormatCache.get(this.locale);
|
|
82
|
-
if (!numberFormat) {
|
|
83
|
-
numberFormat = new Intl.NumberFormat(this.locale);
|
|
84
|
-
$6db58dc88e78b024$var$numberFormatCache.set(this.locale, numberFormat);
|
|
85
|
-
}
|
|
86
|
-
return numberFormat.format(value);
|
|
87
|
-
}
|
|
88
|
-
select(options, value) {
|
|
89
|
-
let opt = options[value] || options.other;
|
|
90
|
-
return typeof opt === "function" ? opt() : opt;
|
|
91
|
-
}
|
|
92
|
-
constructor(locale, strings) {
|
|
93
|
-
this.locale = locale;
|
|
94
|
-
this.strings = strings;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
const $fca6afa0e843324b$var$cache = /* @__PURE__ */ new WeakMap();
|
|
98
|
-
function $fca6afa0e843324b$var$getCachedDictionary(strings) {
|
|
99
|
-
let dictionary = $fca6afa0e843324b$var$cache.get(strings);
|
|
100
|
-
if (!dictionary) {
|
|
101
|
-
dictionary = new $5b160d28a433310d$export$c17fa47878dc55b6(strings);
|
|
102
|
-
$fca6afa0e843324b$var$cache.set(strings, dictionary);
|
|
103
|
-
}
|
|
104
|
-
return dictionary;
|
|
105
|
-
}
|
|
106
|
-
function $fca6afa0e843324b$export$87b761675e8eaa10(strings, packageName) {
|
|
107
|
-
return packageName && $5b160d28a433310d$export$c17fa47878dc55b6.getGlobalDictionaryForPackage(packageName) || $fca6afa0e843324b$var$getCachedDictionary(strings);
|
|
108
|
-
}
|
|
109
|
-
function $fca6afa0e843324b$export$f12b703ca79dfbb1(strings, packageName) {
|
|
110
|
-
let { locale } = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7();
|
|
111
|
-
let dictionary = $fca6afa0e843324b$export$87b761675e8eaa10(strings, packageName);
|
|
112
|
-
return useMemo(() => new $6db58dc88e78b024$export$2f817fcdc4b89ae0(locale, dictionary), [
|
|
113
|
-
locale,
|
|
114
|
-
dictionary
|
|
115
|
-
]);
|
|
116
|
-
}
|
|
117
|
-
export {
|
|
118
|
-
$fca6afa0e843324b$export$f12b703ca79dfbb1 as $,
|
|
119
|
-
$5b160d28a433310d$export$c17fa47878dc55b6 as a,
|
|
120
|
-
$6db58dc88e78b024$export$2f817fcdc4b89ae0 as b
|
|
121
|
-
};
|