@elementor/editor 0.1.0 → 0.2.1
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/CHANGELOG.md +11 -0
- package/dist/index.d.ts +2 -9
- package/dist/index.js +11 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- package/src/index.ts +0 -2
- package/src/init.tsx +8 -11
- package/src/contexts/__tests__/settings-context.test.tsx +0 -50
- package/src/contexts/settings-context.tsx +0 -28
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## [0.2.1](https://github.com/elementor/elementor-packages/compare/v0.2.0...v0.2.1) (2023-05-11)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **editor-app-bar:** make save options button disabled in site-settings [ED-10221] ([#30](https://github.com/elementor/elementor-packages/issues/30)) ([1991096](https://github.com/elementor/elementor-packages/commit/1991096115efeae7bc3648e4889899b85d7328d6))
|
package/dist/index.d.ts
CHANGED
|
@@ -7,13 +7,6 @@ declare const injectIntoTop: ({ filler, name, options }: Omit<{
|
|
|
7
7
|
options?: _elementor_locations.InjectionOptions | undefined;
|
|
8
8
|
}, "location">) => void;
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
urls: {
|
|
12
|
-
admin: string;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
declare function useSettings(): Settings;
|
|
10
|
+
declare function init(domElement: Element): void;
|
|
16
11
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export { Settings, init, injectIntoTop, useSettings };
|
|
12
|
+
export { init, injectIntoTop };
|
package/dist/index.js
CHANGED
|
@@ -31,8 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
33
|
init: () => init,
|
|
34
|
-
injectIntoTop: () => injectIntoTop
|
|
35
|
-
useSettings: () => useSettings
|
|
34
|
+
injectIntoTop: () => injectIntoTop
|
|
36
35
|
});
|
|
37
36
|
module.exports = __toCommonJS(src_exports);
|
|
38
37
|
|
|
@@ -42,7 +41,7 @@ var LOCATION_TOP = "editor/top";
|
|
|
42
41
|
var injectIntoTop = (0, import_locations.createInjectorFor)(LOCATION_TOP);
|
|
43
42
|
|
|
44
43
|
// src/init.tsx
|
|
45
|
-
var
|
|
44
|
+
var React3 = __toESM(require("react"));
|
|
46
45
|
var ReactDOM = __toESM(require("react-dom"));
|
|
47
46
|
var import_i18n = require("@wordpress/i18n");
|
|
48
47
|
|
|
@@ -58,37 +57,22 @@ var import_ui2 = require("@elementor/ui");
|
|
|
58
57
|
var import_store = require("@elementor/store");
|
|
59
58
|
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
60
59
|
|
|
61
|
-
// src/contexts/settings-context.tsx
|
|
62
|
-
var React2 = __toESM(require("react"));
|
|
63
|
-
var import_react = require("react");
|
|
64
|
-
var SettingsContext = (0, import_react.createContext)(null);
|
|
65
|
-
function SettingsProvider({ children, settings }) {
|
|
66
|
-
return /* @__PURE__ */ React2.createElement(SettingsContext.Provider, { value: { ...settings } }, children);
|
|
67
|
-
}
|
|
68
|
-
function useSettings() {
|
|
69
|
-
const context = (0, import_react.useContext)(SettingsContext);
|
|
70
|
-
if (!context) {
|
|
71
|
-
throw new Error("The `useSettings()` hook must be used within an `<SettingsProvider />`");
|
|
72
|
-
}
|
|
73
|
-
return context;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
60
|
// src/components/theme-provider.tsx
|
|
77
|
-
var
|
|
61
|
+
var React2 = __toESM(require("react"));
|
|
78
62
|
var import_ui = require("@elementor/ui");
|
|
79
63
|
|
|
80
64
|
// src/sync/use-color-scheme.ts
|
|
81
|
-
var
|
|
65
|
+
var import_react = require("react");
|
|
82
66
|
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
83
67
|
function useColorScheme() {
|
|
84
|
-
const [colorScheme, setColorScheme] = (0,
|
|
85
|
-
(0,
|
|
68
|
+
const [colorScheme, setColorScheme] = (0, import_react.useState)(() => getV1ColorScheme());
|
|
69
|
+
(0, import_react.useEffect)(() => {
|
|
86
70
|
return (0, import_editor_v1_adapters.listenTo)(
|
|
87
71
|
(0, import_editor_v1_adapters.v1ReadyEvent)(),
|
|
88
72
|
() => setColorScheme(getV1ColorScheme())
|
|
89
73
|
);
|
|
90
74
|
}, []);
|
|
91
|
-
(0,
|
|
75
|
+
(0, import_react.useEffect)(() => {
|
|
92
76
|
return (0, import_editor_v1_adapters.listenTo)(
|
|
93
77
|
(0, import_editor_v1_adapters.commandEndEvent)("document/elements/settings"),
|
|
94
78
|
(e) => {
|
|
@@ -109,19 +93,18 @@ function getV1ColorScheme() {
|
|
|
109
93
|
// src/components/theme-provider.tsx
|
|
110
94
|
function ThemeProvider({ children }) {
|
|
111
95
|
const colorScheme = useColorScheme();
|
|
112
|
-
return /* @__PURE__ */
|
|
96
|
+
return /* @__PURE__ */ React2.createElement(import_ui.ThemeProvider, { colorScheme }, children);
|
|
113
97
|
}
|
|
114
98
|
|
|
115
99
|
// src/init.tsx
|
|
116
|
-
function init(domElement
|
|
100
|
+
function init(domElement) {
|
|
117
101
|
const store = (0, import_store.createStore)();
|
|
118
102
|
(0, import_editor_v1_adapters2.dispatchReadyEvent)();
|
|
119
|
-
ReactDOM.render(/* @__PURE__ */
|
|
103
|
+
ReactDOM.render(/* @__PURE__ */ React3.createElement(import_store.StoreProvider, { store }, /* @__PURE__ */ React3.createElement(import_ui2.DirectionProvider, { rtl: (0, import_i18n.isRTL)() }, /* @__PURE__ */ React3.createElement(ThemeProvider, null, /* @__PURE__ */ React3.createElement(Shell, null)))), domElement);
|
|
120
104
|
}
|
|
121
105
|
// Annotate the CommonJS export names for ESM import in node:
|
|
122
106
|
0 && (module.exports = {
|
|
123
107
|
init,
|
|
124
|
-
injectIntoTop
|
|
125
|
-
useSettings
|
|
108
|
+
injectIntoTop
|
|
126
109
|
});
|
|
127
110
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/locations.ts","../src/init.tsx","../src/components/shell.tsx","../src/
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/locations.ts","../src/init.tsx","../src/components/shell.tsx","../src/components/theme-provider.tsx","../src/sync/use-color-scheme.ts"],"sourcesContent":["export { injectIntoTop } from './locations';\nexport { default as init } from './init';\n","import { createInjectorFor } from '@elementor/locations';\n\nexport const LOCATION_TOP = 'editor/top';\n\nexport const injectIntoTop = createInjectorFor( LOCATION_TOP );\n","import * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport { isRTL } from '@wordpress/i18n';\nimport Shell from './components/shell';\nimport { DirectionProvider } from '@elementor/ui';\nimport { StoreProvider, createStore } from '@elementor/store';\nimport { dispatchReadyEvent } from '@elementor/editor-v1-adapters';\nimport ThemeProvider from './components/theme-provider';\n\nexport default function init( domElement: Element ): void {\n\tconst store = createStore();\n\n\tdispatchReadyEvent();\n\n\tReactDOM.render( (\n\t\t<StoreProvider store={ store }>\n\t\t\t<DirectionProvider rtl={ isRTL() }>\n\t\t\t\t<ThemeProvider>\n\t\t\t\t\t<Shell />\n\t\t\t\t</ThemeProvider>\n\t\t\t</DirectionProvider>\n\t\t</StoreProvider>\n\t), domElement );\n}\n","import * as React from 'react';\nimport { Slot } from '@elementor/locations';\nimport { LOCATION_TOP } from '../locations';\n\nexport default function Shell() {\n\treturn (\n\t\t<Slot location={ LOCATION_TOP } />\n\t);\n}\n","import * as React from 'react';\nimport { ThemeProvider as ThemeProviderBase } from '@elementor/ui';\nimport { useColorScheme } from '../sync/use-color-scheme';\n\nexport default function ThemeProvider( { children }: { children: React.ReactNode } ) {\n\tconst colorScheme = useColorScheme();\n\n\treturn (\n\t\t<ThemeProviderBase colorScheme={ colorScheme }>\n\t\t\t{ children }\n\t\t</ThemeProviderBase>\n\t);\n}\n","import { useEffect, useState } from 'react';\nimport { commandEndEvent, CommandEvent, listenTo, v1ReadyEvent } from '@elementor/editor-v1-adapters';\n\nexport type ColorScheme = 'auto' | 'dark' | 'light';\n\nexport type ExtendedWindow = Window & {\n\telementor: {\n\t\tgetPreferences: ( key: 'ui_theme' ) => ColorScheme,\n\t}\n}\n\nexport function useColorScheme() {\n\tconst [ colorScheme, setColorScheme ] = useState<ColorScheme>( () => getV1ColorScheme() );\n\n\tuseEffect( () => {\n\t\treturn listenTo(\n\t\t\tv1ReadyEvent(),\n\t\t\t() => setColorScheme( getV1ColorScheme() )\n\t\t);\n\t}, [] );\n\n\tuseEffect( () => {\n\t\treturn listenTo(\n\t\t\tcommandEndEvent( 'document/elements/settings' ),\n\t\t\t( e ) => {\n\t\t\t\tconst event = e as CommandEvent<{\n\t\t\t\t\tsettings: {\n\t\t\t\t\t\tui_theme?: ColorScheme,\n\t\t\t\t\t},\n\t\t\t\t}>;\n\n\t\t\t\t// The User-Preferences settings object has a key named `ui_theme` that controls the color scheme.\n\t\t\t\tconst isColorScheme = event.args?.settings && 'ui_theme' in event.args.settings;\n\n\t\t\t\tif ( isColorScheme ) {\n\t\t\t\t\tsetColorScheme( getV1ColorScheme() );\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}, [] );\n\n\treturn colorScheme;\n}\n\nfunction getV1ColorScheme() {\n\treturn ( window as unknown as ExtendedWindow ).elementor?.getPreferences?.( 'ui_theme' ) || 'auto';\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,uBAAkC;AAE3B,IAAM,eAAe;AAErB,IAAM,oBAAgB,oCAAmB,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","ThemeProviderBase"]}
|
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ var LOCATION_TOP = "editor/top";
|
|
|
4
4
|
var injectIntoTop = createInjectorFor(LOCATION_TOP);
|
|
5
5
|
|
|
6
6
|
// src/init.tsx
|
|
7
|
-
import * as
|
|
7
|
+
import * as React3 from "react";
|
|
8
8
|
import * as ReactDOM from "react-dom";
|
|
9
9
|
import { isRTL } from "@wordpress/i18n";
|
|
10
10
|
|
|
@@ -20,23 +20,8 @@ import { DirectionProvider } from "@elementor/ui";
|
|
|
20
20
|
import { StoreProvider, createStore } from "@elementor/store";
|
|
21
21
|
import { dispatchReadyEvent } from "@elementor/editor-v1-adapters";
|
|
22
22
|
|
|
23
|
-
// src/contexts/settings-context.tsx
|
|
24
|
-
import * as React2 from "react";
|
|
25
|
-
import { createContext, useContext } from "react";
|
|
26
|
-
var SettingsContext = createContext(null);
|
|
27
|
-
function SettingsProvider({ children, settings }) {
|
|
28
|
-
return /* @__PURE__ */ React2.createElement(SettingsContext.Provider, { value: { ...settings } }, children);
|
|
29
|
-
}
|
|
30
|
-
function useSettings() {
|
|
31
|
-
const context = useContext(SettingsContext);
|
|
32
|
-
if (!context) {
|
|
33
|
-
throw new Error("The `useSettings()` hook must be used within an `<SettingsProvider />`");
|
|
34
|
-
}
|
|
35
|
-
return context;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
23
|
// src/components/theme-provider.tsx
|
|
39
|
-
import * as
|
|
24
|
+
import * as React2 from "react";
|
|
40
25
|
import { ThemeProvider as ThemeProviderBase } from "@elementor/ui";
|
|
41
26
|
|
|
42
27
|
// src/sync/use-color-scheme.ts
|
|
@@ -71,18 +56,17 @@ function getV1ColorScheme() {
|
|
|
71
56
|
// src/components/theme-provider.tsx
|
|
72
57
|
function ThemeProvider({ children }) {
|
|
73
58
|
const colorScheme = useColorScheme();
|
|
74
|
-
return /* @__PURE__ */
|
|
59
|
+
return /* @__PURE__ */ React2.createElement(ThemeProviderBase, { colorScheme }, children);
|
|
75
60
|
}
|
|
76
61
|
|
|
77
62
|
// src/init.tsx
|
|
78
|
-
function init(domElement
|
|
63
|
+
function init(domElement) {
|
|
79
64
|
const store = createStore();
|
|
80
65
|
dispatchReadyEvent();
|
|
81
|
-
ReactDOM.render(/* @__PURE__ */
|
|
66
|
+
ReactDOM.render(/* @__PURE__ */ React3.createElement(StoreProvider, { store }, /* @__PURE__ */ React3.createElement(DirectionProvider, { rtl: isRTL() }, /* @__PURE__ */ React3.createElement(ThemeProvider, null, /* @__PURE__ */ React3.createElement(Shell, null)))), domElement);
|
|
82
67
|
}
|
|
83
68
|
export {
|
|
84
69
|
init,
|
|
85
|
-
injectIntoTop
|
|
86
|
-
useSettings
|
|
70
|
+
injectIntoTop
|
|
87
71
|
};
|
|
88
72
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/locations.ts","../src/init.tsx","../src/components/shell.tsx","../src/
|
|
1
|
+
{"version":3,"sources":["../src/locations.ts","../src/init.tsx","../src/components/shell.tsx","../src/components/theme-provider.tsx","../src/sync/use-color-scheme.ts"],"sourcesContent":["import { createInjectorFor } from '@elementor/locations';\n\nexport const LOCATION_TOP = 'editor/top';\n\nexport const injectIntoTop = createInjectorFor( LOCATION_TOP );\n","import * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport { isRTL } from '@wordpress/i18n';\nimport Shell from './components/shell';\nimport { DirectionProvider } from '@elementor/ui';\nimport { StoreProvider, createStore } from '@elementor/store';\nimport { dispatchReadyEvent } from '@elementor/editor-v1-adapters';\nimport ThemeProvider from './components/theme-provider';\n\nexport default function init( domElement: Element ): void {\n\tconst store = createStore();\n\n\tdispatchReadyEvent();\n\n\tReactDOM.render( (\n\t\t<StoreProvider store={ store }>\n\t\t\t<DirectionProvider rtl={ isRTL() }>\n\t\t\t\t<ThemeProvider>\n\t\t\t\t\t<Shell />\n\t\t\t\t</ThemeProvider>\n\t\t\t</DirectionProvider>\n\t\t</StoreProvider>\n\t), domElement );\n}\n","import * as React from 'react';\nimport { Slot } from '@elementor/locations';\nimport { LOCATION_TOP } from '../locations';\n\nexport default function Shell() {\n\treturn (\n\t\t<Slot location={ LOCATION_TOP } />\n\t);\n}\n","import * as React from 'react';\nimport { ThemeProvider as ThemeProviderBase } from '@elementor/ui';\nimport { useColorScheme } from '../sync/use-color-scheme';\n\nexport default function ThemeProvider( { children }: { children: React.ReactNode } ) {\n\tconst colorScheme = useColorScheme();\n\n\treturn (\n\t\t<ThemeProviderBase colorScheme={ colorScheme }>\n\t\t\t{ children }\n\t\t</ThemeProviderBase>\n\t);\n}\n","import { useEffect, useState } from 'react';\nimport { commandEndEvent, CommandEvent, listenTo, v1ReadyEvent } from '@elementor/editor-v1-adapters';\n\nexport type ColorScheme = 'auto' | 'dark' | 'light';\n\nexport type ExtendedWindow = Window & {\n\telementor: {\n\t\tgetPreferences: ( key: 'ui_theme' ) => ColorScheme,\n\t}\n}\n\nexport function useColorScheme() {\n\tconst [ colorScheme, setColorScheme ] = useState<ColorScheme>( () => getV1ColorScheme() );\n\n\tuseEffect( () => {\n\t\treturn listenTo(\n\t\t\tv1ReadyEvent(),\n\t\t\t() => setColorScheme( getV1ColorScheme() )\n\t\t);\n\t}, [] );\n\n\tuseEffect( () => {\n\t\treturn listenTo(\n\t\t\tcommandEndEvent( 'document/elements/settings' ),\n\t\t\t( e ) => {\n\t\t\t\tconst event = e as CommandEvent<{\n\t\t\t\t\tsettings: {\n\t\t\t\t\t\tui_theme?: ColorScheme,\n\t\t\t\t\t},\n\t\t\t\t}>;\n\n\t\t\t\t// The User-Preferences settings object has a key named `ui_theme` that controls the color scheme.\n\t\t\t\tconst isColorScheme = event.args?.settings && 'ui_theme' in event.args.settings;\n\n\t\t\t\tif ( isColorScheme ) {\n\t\t\t\t\tsetColorScheme( getV1ColorScheme() );\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}, [] );\n\n\treturn col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AR,KAAuB,YAA4B;AACzD,QAAM,QAAQ,YAAY;AAE1B,qBAAmB;AAEnB,EAAS,gBACR,qCAAC,iBAAc,SACd,qCAAC,qBAAkB,KAAM,MAAM,KAC9B,qCAAC,qBACA,qCAAC,WAAM,CACR,CACD,CACD,GACE,UAAW;AACf;","names":["React","React"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Elementor Team",
|
|
6
6
|
"homepage": "https://elementor.com/",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
21
21
|
"url": "https://github.com/elementor/elementor-packages.git",
|
|
22
|
-
"directory": "packages/editor"
|
|
22
|
+
"directory": "packages/core/editor"
|
|
23
23
|
},
|
|
24
24
|
"bugs": {
|
|
25
25
|
"url": "https://github.com/elementor/elementor-packages/issues"
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@elementor/editor-v1-adapters": "^0.
|
|
36
|
-
"@elementor/locations": "^0.
|
|
37
|
-
"@elementor/store": "^0.
|
|
38
|
-
"@elementor/ui": "^1.4.
|
|
35
|
+
"@elementor/editor-v1-adapters": "^0.2.0",
|
|
36
|
+
"@elementor/locations": "^0.2.0",
|
|
37
|
+
"@elementor/store": "^0.2.0",
|
|
38
|
+
"@elementor/ui": "^1.4.50",
|
|
39
39
|
"@wordpress/i18n": "^4.31.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"elementor": {
|
|
46
46
|
"type": "app"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "3559bb26178072f23c08caab4114671a76bb9eb6"
|
|
49
49
|
}
|
package/src/index.ts
CHANGED
package/src/init.tsx
CHANGED
|
@@ -5,23 +5,20 @@ import Shell from './components/shell';
|
|
|
5
5
|
import { DirectionProvider } from '@elementor/ui';
|
|
6
6
|
import { StoreProvider, createStore } from '@elementor/store';
|
|
7
7
|
import { dispatchReadyEvent } from '@elementor/editor-v1-adapters';
|
|
8
|
-
import { SettingsProvider, Settings } from './contexts/settings-context';
|
|
9
8
|
import ThemeProvider from './components/theme-provider';
|
|
10
9
|
|
|
11
|
-
export default function init( domElement: Element
|
|
10
|
+
export default function init( domElement: Element ): void {
|
|
12
11
|
const store = createStore();
|
|
13
12
|
|
|
14
13
|
dispatchReadyEvent();
|
|
15
14
|
|
|
16
15
|
ReactDOM.render( (
|
|
17
|
-
<
|
|
18
|
-
<
|
|
19
|
-
<
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
</StoreProvider>
|
|
25
|
-
</SettingsProvider>
|
|
16
|
+
<StoreProvider store={ store }>
|
|
17
|
+
<DirectionProvider rtl={ isRTL() }>
|
|
18
|
+
<ThemeProvider>
|
|
19
|
+
<Shell />
|
|
20
|
+
</ThemeProvider>
|
|
21
|
+
</DirectionProvider>
|
|
22
|
+
</StoreProvider>
|
|
26
23
|
), domElement );
|
|
27
24
|
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { renderHook } from '@testing-library/react-hooks';
|
|
3
|
-
import { Settings, SettingsProvider, useSettings } from '../settings-context';
|
|
4
|
-
|
|
5
|
-
describe( '@elementor/editor - useSettings()', () => {
|
|
6
|
-
it( 'should return the value from the context', () => {
|
|
7
|
-
// Arrange.
|
|
8
|
-
const settings = {
|
|
9
|
-
urls: {
|
|
10
|
-
admin: 'https://localhost/wp-admin/',
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
// Act.
|
|
15
|
-
const { result } = renderHookWithSettings(
|
|
16
|
-
() => useSettings(),
|
|
17
|
-
settings
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
// Assert.
|
|
21
|
-
expect( result.current ).toEqual( settings );
|
|
22
|
-
} );
|
|
23
|
-
|
|
24
|
-
it( 'should throw when not rendered inside a <SettingsProvider />', () => {
|
|
25
|
-
// Arrange.
|
|
26
|
-
// Mock the `console.error` because `@testing-library/react-hooks` takes over the `console.error`
|
|
27
|
-
// which breaks `@wordpress/jest-console` assertions.
|
|
28
|
-
|
|
29
|
-
// eslint-disable-next-line no-console
|
|
30
|
-
console.error = jest.fn();
|
|
31
|
-
|
|
32
|
-
// Act.
|
|
33
|
-
const { result } = renderHook( () => useSettings() );
|
|
34
|
-
|
|
35
|
-
// Assert.
|
|
36
|
-
expect( result.error?.message ).toEqual( 'The `useSettings()` hook must be used within an `<SettingsProvider />`' );
|
|
37
|
-
} );
|
|
38
|
-
} );
|
|
39
|
-
|
|
40
|
-
function renderHookWithSettings( hook: () => unknown, settings: Settings ) {
|
|
41
|
-
return renderHook( hook, {
|
|
42
|
-
wrapper: ( { children } ) => {
|
|
43
|
-
return (
|
|
44
|
-
<SettingsProvider settings={ settings }>
|
|
45
|
-
{ children }
|
|
46
|
-
</SettingsProvider>
|
|
47
|
-
);
|
|
48
|
-
},
|
|
49
|
-
} );
|
|
50
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { createContext, PropsWithChildren, useContext } from 'react';
|
|
3
|
-
|
|
4
|
-
export interface Settings {
|
|
5
|
-
urls: {
|
|
6
|
-
admin: string,
|
|
7
|
-
},
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const SettingsContext = createContext<Settings | null>( null );
|
|
11
|
-
|
|
12
|
-
export function SettingsProvider( { children, settings }: PropsWithChildren<{ settings: Settings }> ) {
|
|
13
|
-
return (
|
|
14
|
-
<SettingsContext.Provider value={ { ...settings } }>
|
|
15
|
-
{ children }
|
|
16
|
-
</SettingsContext.Provider>
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function useSettings() {
|
|
21
|
-
const context = useContext( SettingsContext );
|
|
22
|
-
|
|
23
|
-
if ( ! context ) {
|
|
24
|
-
throw new Error( 'The `useSettings()` hook must be used within an `<SettingsProvider />`' );
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return context;
|
|
28
|
-
}
|