PluginProbe
Gutenberg / 22.9.0
Gutenberg v22.9.0
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / build / scripts / react-i18n / index.js

index.js in Gutenberg 22.9.0, at build/scripts/react-i18n/index.js

98 lines 3.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 "use strict";
2 var wp;
3 (wp ||= {}).reactI18n = (() => {
4 var __create = Object.create;
5 var __defProp = Object.defineProperty;
6 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7 var __getOwnPropNames = Object.getOwnPropertyNames;
8 var __getProtoOf = Object.getPrototypeOf;
9 var __hasOwnProp = Object.prototype.hasOwnProperty;
10 var __commonJS = (cb, mod) => function __require() {
11 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12 };
13 var __export = (target, all) => {
14 for (var name in all)
15 __defProp(target, name, { get: all[name], enumerable: true });
16 };
17 var __copyProps = (to, from, except, desc) => {
18 if (from && typeof from === "object" || typeof from === "function") {
19 for (let key of __getOwnPropNames(from))
20 if (!__hasOwnProp.call(to, key) && key !== except)
21 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
22 }
23 return to;
24 };
25 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
26 // If the importer is in node compatibility mode or this is not an ESM
27 // file that has been converted to a CommonJS file using a Babel-
28 // compatible transform (i.e. "__esModule" has not been set), then set
29 // "default" to the CommonJS "module.exports" for node compatibility.
30 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
31 mod
32 ));
33 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
35 // package-external:@wordpress/element
36 var require_element = __commonJS({
37 "package-external:@wordpress/element"(exports, module) {
38 module.exports = window.wp.element;
39 }
40 });
41
42 // package-external:@wordpress/i18n
43 var require_i18n = __commonJS({
44 "package-external:@wordpress/i18n"(exports, module) {
45 module.exports = window.wp.i18n;
46 }
47 });
48
49 // vendor-external:react/jsx-runtime
50 var require_jsx_runtime = __commonJS({
51 "vendor-external:react/jsx-runtime"(exports, module) {
52 module.exports = window.ReactJSXRuntime;
53 }
54 });
55
56 // packages/react-i18n/build-module/index.mjs
57 var index_exports = {};
58 __export(index_exports, {
59 I18nProvider: () => I18nProvider,
60 useI18n: () => useI18n,
61 withI18n: () => withI18n
62 });
63 var import_element = __toESM(require_element(), 1);
64 var import_i18n = __toESM(require_i18n(), 1);
65 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
66 function makeContextValue(i18n) {
67 return {
68 __: i18n.__.bind(i18n),
69 _x: i18n._x.bind(i18n),
70 _n: i18n._n.bind(i18n),
71 _nx: i18n._nx.bind(i18n),
72 isRTL: i18n.isRTL.bind(i18n),
73 hasTranslation: i18n.hasTranslation.bind(i18n)
74 };
75 }
76 var I18nContext = (0, import_element.createContext)(makeContextValue(import_i18n.defaultI18n));
77 I18nContext.displayName = "I18nContext";
78 function I18nProvider(props) {
79 const { children, i18n = import_i18n.defaultI18n } = props;
80 const [update, forceUpdate] = (0, import_element.useReducer)(() => [], []);
81 (0, import_element.useEffect)(() => i18n.subscribe(forceUpdate), [i18n]);
82 const value = (0, import_element.useMemo)(() => makeContextValue(i18n), [i18n, update]);
83 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(I18nContext.Provider, { value, children });
84 }
85 var useI18n = () => (0, import_element.useContext)(I18nContext);
86 function withI18n(InnerComponent) {
87 const EnhancedComponent = (props) => {
88 const i18nProps = useI18n();
89 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(InnerComponent, { ...props, ...i18nProps });
90 };
91 const innerComponentName = InnerComponent.displayName || InnerComponent.name || "Component";
92 EnhancedComponent.displayName = `WithI18n(${innerComponentName})`;
93 return EnhancedComponent;
94 }
95 return __toCommonJS(index_exports);
96 })();
97 //# sourceMappingURL=index.js.map
98