PluginProbe
Gutenberg / 24.1.0
Gutenberg v24.1.0
24.1.0 24.0.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 All 404 releases
gutenberg / build / scripts / react-i18n / index.js

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

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