@mattisvensson/strapi-plugin-webatlas 0.12.2 → 0.13.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.
Files changed (32) hide show
  1. package/README.md +46 -1
  2. package/dist/admin/{SettingTitle-DXGCUfum.js → ContentBox-D4PGQ8eh.js} +1 -5
  3. package/dist/admin/{SettingTitle-C1_2epDJ.mjs → ContentBox-KyQN2KGV.mjs} +2 -6
  4. package/dist/admin/{RoutePicker-C6LpgVMi.mjs → RoutePicker-CgndSXoF.mjs} +1 -1
  5. package/dist/admin/{RoutePicker-DvzQH2CX.js → RoutePicker-CwoMMhf_.js} +1 -1
  6. package/dist/admin/WarningBox-AyYq0Onj.mjs +18 -0
  7. package/dist/admin/{WarningBox-BHlYlKQ8.js → WarningBox-FF1yYDXP.js} +0 -24
  8. package/dist/admin/{de-BWUGdpM0.js → de-Cl0vM1wA.js} +51 -4
  9. package/dist/admin/{de-Dnk_hvMW.mjs → de-DWs5ckOd.mjs} +51 -4
  10. package/dist/admin/{en-D5EqZSGy.mjs → en-CyhISGZi.mjs} +51 -4
  11. package/dist/admin/{en-DOk8P6X5.js → en-DSmtmPYk.js} +51 -4
  12. package/dist/admin/{index-CVrufPeL.mjs → index-BKhrfzjO.mjs} +65 -26
  13. package/dist/admin/{index-DuSnxRbO.mjs → index-Bv5Ri-ri.mjs} +44 -12
  14. package/dist/admin/{index-D7zg69uM.js → index-BxGPKxr_.js} +50 -18
  15. package/dist/admin/index-Ctm4TBT5.mjs +5308 -0
  16. package/dist/admin/{index-Y4uwBSjP.mjs → index-D2O7sLKs.mjs} +1 -1
  17. package/dist/admin/{index-DHNPW0YT.js → index-DTrsl_uN.js} +65 -26
  18. package/dist/admin/index-FvaXwOH0.mjs +174 -0
  19. package/dist/admin/index-JBUU7dE6.js +5308 -0
  20. package/dist/admin/{index-Dp_eCRFS.js → index-jOCO4_-k.js} +1 -1
  21. package/dist/admin/index-uOC1Clyv.js +174 -0
  22. package/dist/admin/index.js +1 -1
  23. package/dist/admin/index.mjs +1 -1
  24. package/dist/server/index.js +314 -51
  25. package/dist/server/index.mjs +315 -52
  26. package/dist/server/src/index.d.ts +16 -3
  27. package/package.json +1 -1
  28. package/dist/admin/WarningBox-CfIVF0O-.mjs +0 -42
  29. package/dist/admin/index-DC-2-FsX.mjs +0 -9622
  30. package/dist/admin/index-Dx4gvFWK.mjs +0 -147
  31. package/dist/admin/index-FuvoHpAT.js +0 -147
  32. package/dist/admin/index-RmZ3LQPu.js +0 -9622
@@ -1,147 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useReducer, useState, useRef, useEffect } from "react";
3
- import { Field } from "@strapi/design-system";
4
- import { useNotification, Page } from "@strapi/strapi/admin";
5
- import { c as usePluginConfig, g as getTranslation, p as pluginPermissions } from "./index-CVrufPeL.mjs";
6
- import { u as useErrorMessage, F as FullLoader } from "./FullLoader-BTZzPY8g.mjs";
7
- import { useIntl } from "react-intl";
8
- import "@strapi/icons/symbols";
9
- import "@strapi/icons";
10
- import { P as PageWrapper, C as ContentBox, S as SettingTitle } from "./SettingTitle-C1_2epDJ.mjs";
11
- function reducer(newConfig, action) {
12
- switch (action.type) {
13
- case "SET_MAX_DEPTH":
14
- if (!newConfig) return null;
15
- return {
16
- ...newConfig,
17
- navigation: { ...newConfig.navigation, maxDepth: action.payload },
18
- selectedContentTypes: newConfig.selectedContentTypes || []
19
- };
20
- case "SET_CONFIG":
21
- return action.payload;
22
- default:
23
- throw new Error();
24
- }
25
- }
26
- const Settings = () => {
27
- const { config: fetchedConfig, setConfig, loading, fetchError } = usePluginConfig();
28
- const [config, dispatch] = useReducer(reducer, fetchedConfig);
29
- const { toggleNotification } = useNotification();
30
- const getErrorMessage = useErrorMessage();
31
- const { formatMessage } = useIntl();
32
- const [isSaving, setIsSaving] = useState(false);
33
- const initialConfig = useRef(fetchedConfig);
34
- useEffect(() => {
35
- initialConfig.current = fetchedConfig;
36
- if (fetchedConfig) dispatch({ type: "SET_CONFIG", payload: fetchedConfig });
37
- }, [fetchedConfig]);
38
- useEffect(() => {
39
- if (fetchError) {
40
- toggleNotification({
41
- type: "danger",
42
- message: getErrorMessage(
43
- fetchError,
44
- formatMessage({
45
- id: getTranslation("notification.error"),
46
- defaultMessage: "An error occurred"
47
- })
48
- )
49
- });
50
- }
51
- }, [fetchError, toggleNotification, getErrorMessage, formatMessage]);
52
- async function save() {
53
- if (!config) return;
54
- setIsSaving(true);
55
- try {
56
- await setConfig({ navigation: config.navigation });
57
- initialConfig.current = config;
58
- toggleNotification({
59
- type: "success",
60
- message: formatMessage({
61
- id: getTranslation("notification.settings.saved"),
62
- defaultMessage: "Settings saved successfully"
63
- })
64
- });
65
- setIsSaving(false);
66
- } catch (err) {
67
- setIsSaving(false);
68
- toggleNotification({
69
- type: "danger",
70
- message: getErrorMessage(
71
- err,
72
- formatMessage({
73
- id: getTranslation("notification.error"),
74
- defaultMessage: "An error occurred"
75
- })
76
- )
77
- });
78
- console.error(err);
79
- }
80
- }
81
- if (loading) {
82
- return /* @__PURE__ */ jsx(
83
- PageWrapper,
84
- {
85
- isSaving,
86
- subtitle: formatMessage({
87
- id: getTranslation("loading"),
88
- defaultMessage: "Loading..."
89
- }),
90
- disabledCondition: true,
91
- children: /* @__PURE__ */ jsx(FullLoader, { height: 200 })
92
- }
93
- );
94
- }
95
- return /* @__PURE__ */ jsx(Page.Protect, { permissions: pluginPermissions["settings.navigation"], children: /* @__PURE__ */ jsx(
96
- PageWrapper,
97
- {
98
- save,
99
- isSaving,
100
- subtitle: formatMessage({
101
- id: getTranslation("settings.page.navigation.subtitle"),
102
- defaultMessage: "Configure navigation settings"
103
- }),
104
- disabledCondition: JSON.stringify(config) === JSON.stringify(initialConfig.current),
105
- children: /* @__PURE__ */ jsx(
106
- ContentBox,
107
- {
108
- title: formatMessage({
109
- id: getTranslation("settings.page.navigation.navigation"),
110
- defaultMessage: "Navigation"
111
- }),
112
- children: /* @__PURE__ */ jsxs(Field.Root, { name: "maxNavDepth", children: [
113
- /* @__PURE__ */ jsx(Field.Label, { children: /* @__PURE__ */ jsx(SettingTitle, { children: formatMessage({
114
- id: getTranslation("settings.page.navigation.maxNavDepth.label"),
115
- defaultMessage: "Max depth of navigation tree"
116
- }) }) }),
117
- /* @__PURE__ */ jsx(
118
- Field.Input,
119
- {
120
- id: "maxNavDepth",
121
- type: "number",
122
- min: 0,
123
- step: 1,
124
- value: config?.navigation?.maxDepth !== void 0 ? config.navigation.maxDepth + 1 : "",
125
- onChange: (e) => dispatch({
126
- type: "SET_MAX_DEPTH",
127
- payload: Number(e.target.value) - 1
128
- }),
129
- onBlur: (e) => {
130
- if (e.target.value === "") return;
131
- dispatch({
132
- type: "SET_MAX_DEPTH",
133
- payload: Number(e.target.value) - 1
134
- });
135
- }
136
- }
137
- ),
138
- /* @__PURE__ */ jsx(Field.Hint, {})
139
- ] })
140
- }
141
- )
142
- }
143
- ) });
144
- };
145
- export {
146
- Settings as default
147
- };
@@ -1,147 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const jsxRuntime = require("react/jsx-runtime");
4
- const React = require("react");
5
- const designSystem = require("@strapi/design-system");
6
- const admin = require("@strapi/strapi/admin");
7
- const index = require("./index-DHNPW0YT.js");
8
- const FullLoader = require("./FullLoader-C4hXFaLP.js");
9
- const reactIntl = require("react-intl");
10
- require("@strapi/icons/symbols");
11
- require("@strapi/icons");
12
- const SettingTitle = require("./SettingTitle-DXGCUfum.js");
13
- function reducer(newConfig, action) {
14
- switch (action.type) {
15
- case "SET_MAX_DEPTH":
16
- if (!newConfig) return null;
17
- return {
18
- ...newConfig,
19
- navigation: { ...newConfig.navigation, maxDepth: action.payload },
20
- selectedContentTypes: newConfig.selectedContentTypes || []
21
- };
22
- case "SET_CONFIG":
23
- return action.payload;
24
- default:
25
- throw new Error();
26
- }
27
- }
28
- const Settings = () => {
29
- const { config: fetchedConfig, setConfig, loading, fetchError } = index.usePluginConfig();
30
- const [config, dispatch] = React.useReducer(reducer, fetchedConfig);
31
- const { toggleNotification } = admin.useNotification();
32
- const getErrorMessage = FullLoader.useErrorMessage();
33
- const { formatMessage } = reactIntl.useIntl();
34
- const [isSaving, setIsSaving] = React.useState(false);
35
- const initialConfig = React.useRef(fetchedConfig);
36
- React.useEffect(() => {
37
- initialConfig.current = fetchedConfig;
38
- if (fetchedConfig) dispatch({ type: "SET_CONFIG", payload: fetchedConfig });
39
- }, [fetchedConfig]);
40
- React.useEffect(() => {
41
- if (fetchError) {
42
- toggleNotification({
43
- type: "danger",
44
- message: getErrorMessage(
45
- fetchError,
46
- formatMessage({
47
- id: index.getTranslation("notification.error"),
48
- defaultMessage: "An error occurred"
49
- })
50
- )
51
- });
52
- }
53
- }, [fetchError, toggleNotification, getErrorMessage, formatMessage]);
54
- async function save() {
55
- if (!config) return;
56
- setIsSaving(true);
57
- try {
58
- await setConfig({ navigation: config.navigation });
59
- initialConfig.current = config;
60
- toggleNotification({
61
- type: "success",
62
- message: formatMessage({
63
- id: index.getTranslation("notification.settings.saved"),
64
- defaultMessage: "Settings saved successfully"
65
- })
66
- });
67
- setIsSaving(false);
68
- } catch (err) {
69
- setIsSaving(false);
70
- toggleNotification({
71
- type: "danger",
72
- message: getErrorMessage(
73
- err,
74
- formatMessage({
75
- id: index.getTranslation("notification.error"),
76
- defaultMessage: "An error occurred"
77
- })
78
- )
79
- });
80
- console.error(err);
81
- }
82
- }
83
- if (loading) {
84
- return /* @__PURE__ */ jsxRuntime.jsx(
85
- SettingTitle.PageWrapper,
86
- {
87
- isSaving,
88
- subtitle: formatMessage({
89
- id: index.getTranslation("loading"),
90
- defaultMessage: "Loading..."
91
- }),
92
- disabledCondition: true,
93
- children: /* @__PURE__ */ jsxRuntime.jsx(FullLoader.FullLoader, { height: 200 })
94
- }
95
- );
96
- }
97
- return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Protect, { permissions: index.pluginPermissions["settings.navigation"], children: /* @__PURE__ */ jsxRuntime.jsx(
98
- SettingTitle.PageWrapper,
99
- {
100
- save,
101
- isSaving,
102
- subtitle: formatMessage({
103
- id: index.getTranslation("settings.page.navigation.subtitle"),
104
- defaultMessage: "Configure navigation settings"
105
- }),
106
- disabledCondition: JSON.stringify(config) === JSON.stringify(initialConfig.current),
107
- children: /* @__PURE__ */ jsxRuntime.jsx(
108
- SettingTitle.ContentBox,
109
- {
110
- title: formatMessage({
111
- id: index.getTranslation("settings.page.navigation.navigation"),
112
- defaultMessage: "Navigation"
113
- }),
114
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: "maxNavDepth", children: [
115
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: /* @__PURE__ */ jsxRuntime.jsx(SettingTitle.SettingTitle, { children: formatMessage({
116
- id: index.getTranslation("settings.page.navigation.maxNavDepth.label"),
117
- defaultMessage: "Max depth of navigation tree"
118
- }) }) }),
119
- /* @__PURE__ */ jsxRuntime.jsx(
120
- designSystem.Field.Input,
121
- {
122
- id: "maxNavDepth",
123
- type: "number",
124
- min: 0,
125
- step: 1,
126
- value: config?.navigation?.maxDepth !== void 0 ? config.navigation.maxDepth + 1 : "",
127
- onChange: (e) => dispatch({
128
- type: "SET_MAX_DEPTH",
129
- payload: Number(e.target.value) - 1
130
- }),
131
- onBlur: (e) => {
132
- if (e.target.value === "") return;
133
- dispatch({
134
- type: "SET_MAX_DEPTH",
135
- payload: Number(e.target.value) - 1
136
- });
137
- }
138
- }
139
- ),
140
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
141
- ] })
142
- }
143
- )
144
- }
145
- ) });
146
- };
147
- exports.default = Settings;