@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,27 @@
|
|
|
1
|
+
import { e as $bdb11010cef70236$export$f680877a34711e37 } from "./utils-CZt7LCbO.js";
|
|
2
|
+
import { $ as $313b98861ee5dd6c$export$d6875122194c7b44 } from "./useLabels-B7-lUnAF.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 && process.env.NODE_ENV !== "production") 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
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { e as $bdb11010cef70236$export$f680877a34711e37 } from "./utils-CZt7LCbO.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
|
+
};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { version, useMemo, useCallback, useRef, useEffect } from "react";
|
|
2
|
+
import { $ as $7af3f5b51489e0b5$export$253fe78d46329472, a as $7613b1592d41b092$export$6cd28814d92fa9c9, b as $d496c0a20b6e58ec$export$6c8a5aaad13c9852 } from "./Collection-n5d0zIgb.js";
|
|
3
|
+
function $cdc5a6778b766db2$export$a9d04c5684123369(value) {
|
|
4
|
+
const pieces = version.split(".");
|
|
5
|
+
const major = parseInt(pieces[0], 10);
|
|
6
|
+
if (major >= 19) return value;
|
|
7
|
+
return value ? "true" : void 0;
|
|
8
|
+
}
|
|
9
|
+
class $a02d57049d202695$export$d085fb9e920b5ca7 {
|
|
10
|
+
*[Symbol.iterator]() {
|
|
11
|
+
yield* this.iterable;
|
|
12
|
+
}
|
|
13
|
+
get size() {
|
|
14
|
+
return this.keyMap.size;
|
|
15
|
+
}
|
|
16
|
+
getKeys() {
|
|
17
|
+
return this.keyMap.keys();
|
|
18
|
+
}
|
|
19
|
+
getKeyBefore(key) {
|
|
20
|
+
let node = this.keyMap.get(key);
|
|
21
|
+
var _node_prevKey;
|
|
22
|
+
return node ? (_node_prevKey = node.prevKey) !== null && _node_prevKey !== void 0 ? _node_prevKey : null : null;
|
|
23
|
+
}
|
|
24
|
+
getKeyAfter(key) {
|
|
25
|
+
let node = this.keyMap.get(key);
|
|
26
|
+
var _node_nextKey;
|
|
27
|
+
return node ? (_node_nextKey = node.nextKey) !== null && _node_nextKey !== void 0 ? _node_nextKey : null : null;
|
|
28
|
+
}
|
|
29
|
+
getFirstKey() {
|
|
30
|
+
return this.firstKey;
|
|
31
|
+
}
|
|
32
|
+
getLastKey() {
|
|
33
|
+
return this.lastKey;
|
|
34
|
+
}
|
|
35
|
+
getItem(key) {
|
|
36
|
+
var _this_keyMap_get;
|
|
37
|
+
return (_this_keyMap_get = this.keyMap.get(key)) !== null && _this_keyMap_get !== void 0 ? _this_keyMap_get : null;
|
|
38
|
+
}
|
|
39
|
+
at(idx) {
|
|
40
|
+
const keys = [
|
|
41
|
+
...this.getKeys()
|
|
42
|
+
];
|
|
43
|
+
return this.getItem(keys[idx]);
|
|
44
|
+
}
|
|
45
|
+
getChildren(key) {
|
|
46
|
+
let node = this.keyMap.get(key);
|
|
47
|
+
return (node === null || node === void 0 ? void 0 : node.childNodes) || [];
|
|
48
|
+
}
|
|
49
|
+
constructor(nodes) {
|
|
50
|
+
this.keyMap = /* @__PURE__ */ new Map();
|
|
51
|
+
this.firstKey = null;
|
|
52
|
+
this.lastKey = null;
|
|
53
|
+
this.iterable = nodes;
|
|
54
|
+
let visit = (node) => {
|
|
55
|
+
this.keyMap.set(node.key, node);
|
|
56
|
+
if (node.childNodes && node.type === "section") for (let child of node.childNodes) visit(child);
|
|
57
|
+
};
|
|
58
|
+
for (let node of nodes) visit(node);
|
|
59
|
+
let last = null;
|
|
60
|
+
let index = 0;
|
|
61
|
+
for (let [key, node] of this.keyMap) {
|
|
62
|
+
if (last) {
|
|
63
|
+
last.nextKey = key;
|
|
64
|
+
node.prevKey = last.key;
|
|
65
|
+
} else {
|
|
66
|
+
this.firstKey = key;
|
|
67
|
+
node.prevKey = void 0;
|
|
68
|
+
}
|
|
69
|
+
if (node.type === "item") node.index = index++;
|
|
70
|
+
last = node;
|
|
71
|
+
last.nextKey = void 0;
|
|
72
|
+
}
|
|
73
|
+
var _last_key;
|
|
74
|
+
this.lastKey = (_last_key = last === null || last === void 0 ? void 0 : last.key) !== null && _last_key !== void 0 ? _last_key : null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function $e72dd72e1c76a225$export$2f645645f7bca764(props) {
|
|
78
|
+
let { filter, layoutDelegate } = props;
|
|
79
|
+
let selectionState = $7af3f5b51489e0b5$export$253fe78d46329472(props);
|
|
80
|
+
let disabledKeys = useMemo(() => props.disabledKeys ? new Set(props.disabledKeys) : /* @__PURE__ */ new Set(), [
|
|
81
|
+
props.disabledKeys
|
|
82
|
+
]);
|
|
83
|
+
let factory = useCallback((nodes) => filter ? new $a02d57049d202695$export$d085fb9e920b5ca7(filter(nodes)) : new $a02d57049d202695$export$d085fb9e920b5ca7(nodes), [
|
|
84
|
+
filter
|
|
85
|
+
]);
|
|
86
|
+
let context = useMemo(() => ({
|
|
87
|
+
suppressTextValueWarning: props.suppressTextValueWarning
|
|
88
|
+
}), [
|
|
89
|
+
props.suppressTextValueWarning
|
|
90
|
+
]);
|
|
91
|
+
let collection = $7613b1592d41b092$export$6cd28814d92fa9c9(props, factory, context);
|
|
92
|
+
let selectionManager = useMemo(() => new $d496c0a20b6e58ec$export$6c8a5aaad13c9852(collection, selectionState, {
|
|
93
|
+
layoutDelegate
|
|
94
|
+
}), [
|
|
95
|
+
collection,
|
|
96
|
+
selectionState,
|
|
97
|
+
layoutDelegate
|
|
98
|
+
]);
|
|
99
|
+
$e72dd72e1c76a225$var$useFocusedKeyReset(collection, selectionManager);
|
|
100
|
+
return {
|
|
101
|
+
collection,
|
|
102
|
+
disabledKeys,
|
|
103
|
+
selectionManager
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function $e72dd72e1c76a225$export$ba9d38c0f1bf2b36(state, filter) {
|
|
107
|
+
let collection = useMemo(() => filter ? state.collection.UNSTABLE_filter(filter) : state.collection, [
|
|
108
|
+
state.collection,
|
|
109
|
+
filter
|
|
110
|
+
]);
|
|
111
|
+
let selectionManager = state.selectionManager.withCollection(collection);
|
|
112
|
+
$e72dd72e1c76a225$var$useFocusedKeyReset(collection, selectionManager);
|
|
113
|
+
return {
|
|
114
|
+
collection,
|
|
115
|
+
selectionManager,
|
|
116
|
+
disabledKeys: state.disabledKeys
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function $e72dd72e1c76a225$var$useFocusedKeyReset(collection, selectionManager) {
|
|
120
|
+
const cachedCollection = useRef(null);
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
if (selectionManager.focusedKey != null && !collection.getItem(selectionManager.focusedKey) && cachedCollection.current) {
|
|
123
|
+
const startItem = cachedCollection.current.getItem(selectionManager.focusedKey);
|
|
124
|
+
const cachedItemNodes = [
|
|
125
|
+
...cachedCollection.current.getKeys()
|
|
126
|
+
].map((key) => {
|
|
127
|
+
const itemNode = cachedCollection.current.getItem(key);
|
|
128
|
+
return (itemNode === null || itemNode === void 0 ? void 0 : itemNode.type) === "item" ? itemNode : null;
|
|
129
|
+
}).filter((node) => node !== null);
|
|
130
|
+
const itemNodes = [
|
|
131
|
+
...collection.getKeys()
|
|
132
|
+
].map((key) => {
|
|
133
|
+
const itemNode = collection.getItem(key);
|
|
134
|
+
return (itemNode === null || itemNode === void 0 ? void 0 : itemNode.type) === "item" ? itemNode : null;
|
|
135
|
+
}).filter((node) => node !== null);
|
|
136
|
+
var _cachedItemNodes_length, _itemNodes_length;
|
|
137
|
+
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);
|
|
138
|
+
var _startItem_index, _startItem_index1, _itemNodes_length1;
|
|
139
|
+
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);
|
|
140
|
+
let newNode = null;
|
|
141
|
+
let isReverseSearching = false;
|
|
142
|
+
while (index >= 0) {
|
|
143
|
+
if (!selectionManager.isDisabled(itemNodes[index].key)) {
|
|
144
|
+
newNode = itemNodes[index];
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
if (index < itemNodes.length - 1 && !isReverseSearching) index++;
|
|
148
|
+
else {
|
|
149
|
+
isReverseSearching = true;
|
|
150
|
+
var _startItem_index2, _startItem_index3;
|
|
151
|
+
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;
|
|
152
|
+
index--;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
selectionManager.setFocusedKey(newNode ? newNode.key : null);
|
|
156
|
+
}
|
|
157
|
+
cachedCollection.current = collection;
|
|
158
|
+
}, [
|
|
159
|
+
collection,
|
|
160
|
+
selectionManager
|
|
161
|
+
]);
|
|
162
|
+
}
|
|
163
|
+
export {
|
|
164
|
+
$e72dd72e1c76a225$export$2f645645f7bca764 as $,
|
|
165
|
+
$e72dd72e1c76a225$export$ba9d38c0f1bf2b36 as a,
|
|
166
|
+
$cdc5a6778b766db2$export$a9d04c5684123369 as b,
|
|
167
|
+
$a02d57049d202695$export$d085fb9e920b5ca7 as c
|
|
168
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { $ as $18f2051aff69b9bf$export$43bb16f9c6d9e3f7 } from "./context-BbYZoHvX.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
|
+
};
|