@premiate/strapi-plugin-maplibre-field 1.2.0 → 1.2.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/CHANGELOG.md +49 -0
- package/dist/_chunks/{index-Dzpog-Qf.mjs → index-B0Nr95wz.mjs} +2 -2
- package/dist/_chunks/{index-Bp7DLorc.mjs → index-CBxydRKp.mjs} +1 -1
- package/dist/_chunks/{index-zNvHsRuo.js → index-CDY4Awnh.js} +1 -1
- package/dist/_chunks/{index-DjK7O741.js → index-ysvid6md.js} +2 -2
- package/dist/admin/de-B0QBc7M2.js +27 -0
- package/dist/admin/de-BMK0skCB.mjs +27 -0
- package/dist/admin/en-C8iInpNv.mjs +27 -0
- package/dist/admin/en-CA0XtbN7.js +27 -0
- package/dist/admin/es-BU6JgkbZ.js +25 -0
- package/dist/admin/es-DZO4NHjt.mjs +25 -0
- package/dist/admin/fr-B8NDboqe.mjs +27 -0
- package/dist/admin/fr-DIBfzRbg.js +27 -0
- package/dist/admin/index-B-3vqPUe.mjs +1836 -0
- package/dist/admin/index-B0LVK-NK.js +170 -0
- package/dist/admin/index-BaGweGhM.js +1856 -0
- package/dist/admin/index-DjL4deZ6.mjs +171 -0
- package/dist/admin/index.js +3 -2
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/it-B-lr3jhh.js +27 -0
- package/dist/admin/it-DFH6n6E1.mjs +27 -0
- package/dist/server/index.js +8 -3
- package/dist/server/index.mjs +6 -2
- package/dist/server/src/index.d.ts +9 -4
- package/package.json +12 -9
- package/dist/admin/src/components/Initializer.d.ts +0 -6
- package/dist/admin/src/components/MapInput/SearchBox.d.ts +0 -22
- package/dist/admin/src/components/MapInput/basemap-control.d.ts +0 -8
- package/dist/admin/src/components/MapInput/index.d.ts +0 -19
- package/dist/admin/src/components/MapInput/layer-control.d.ts +0 -18
- package/dist/admin/src/components/PluginIcon.d.ts +0 -2
- package/dist/admin/src/hooks/usePluginConfig.d.ts +0 -2
- package/dist/admin/src/mutations/mutateEditViewHook.d.ts +0 -30
- package/dist/admin/src/services/geocoder-service.d.ts +0 -31
- package/dist/admin/src/services/poi-service.d.ts +0 -160
- package/dist/admin/src/utils/getTrad.d.ts +0 -2
- package/dist/admin/src/utils/pluginId.d.ts +0 -2
- package/dist/admin/src/utils/prefixPluginTranslations.d.ts +0 -3
- package/dist/server/src/bootstrap.d.ts +0 -2
- package/dist/server/src/config/index.d.ts +0 -62
- package/dist/server/src/config/schema.d.ts +0 -53
- package/dist/server/src/controllers/config.d.ts +0 -9
- package/dist/server/src/controllers/index.d.ts +0 -10
- package/dist/server/src/destroy.d.ts +0 -2
- package/dist/server/src/register.d.ts +0 -5
- package/dist/server/src/routes/admin.d.ts +0 -12
- package/dist/server/src/routes/index.d.ts +0 -14
- package/dist/server/src/types/config.d.ts +0 -26
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const React = require("react");
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const icons = require("@strapi/icons");
|
|
5
|
+
const designSystem = require("@strapi/design-system");
|
|
6
|
+
const styledComponents = require("styled-components");
|
|
7
|
+
const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
|
|
8
|
+
const v = glob[path];
|
|
9
|
+
if (v) {
|
|
10
|
+
return typeof v === "function" ? v() : Promise.resolve(v);
|
|
11
|
+
}
|
|
12
|
+
return new Promise((_, reject) => {
|
|
13
|
+
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
|
|
14
|
+
reject.bind(
|
|
15
|
+
null,
|
|
16
|
+
new Error(
|
|
17
|
+
"Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
|
|
18
|
+
)
|
|
19
|
+
)
|
|
20
|
+
);
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
const name$1 = "@premiate/strapi-plugin-maplibre-field";
|
|
24
|
+
const strapi = { "name": "maplibre-field" };
|
|
25
|
+
const pluginPkg = {
|
|
26
|
+
name: name$1,
|
|
27
|
+
strapi
|
|
28
|
+
};
|
|
29
|
+
const pluginId = pluginPkg.name.replace(/^(@[^/]+\/)?strapi-plugin-/i, "");
|
|
30
|
+
const getTrad = (id) => `${pluginId}.${id}`;
|
|
31
|
+
const Initializer = ({ setPlugin }) => {
|
|
32
|
+
const ref = React.useRef(false);
|
|
33
|
+
React.useEffect(() => {
|
|
34
|
+
if (!ref.current) {
|
|
35
|
+
setPlugin("maplibre-field");
|
|
36
|
+
ref.current = true;
|
|
37
|
+
}
|
|
38
|
+
}, [setPlugin]);
|
|
39
|
+
return null;
|
|
40
|
+
};
|
|
41
|
+
const IconBox = styledComponents.styled(designSystem.Flex)`
|
|
42
|
+
/* Hard code color values */
|
|
43
|
+
/* to stay consistent between themes */
|
|
44
|
+
background-color: #f0f0ff; /* primary100 */
|
|
45
|
+
border: 1px solid #d9d8ff; /* primary200 */
|
|
46
|
+
|
|
47
|
+
svg > path {
|
|
48
|
+
fill: #4945ff; /* primary600 */
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
51
|
+
const PluginIcon = () => {
|
|
52
|
+
return /* @__PURE__ */ jsxRuntime.jsx(IconBox, { justifyContent: "center", alignItems: "center", width: 7, height: 6, hasRadius: true, "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx(icons.PinMap, {}) });
|
|
53
|
+
};
|
|
54
|
+
const mutateLayouts = (layouts) => {
|
|
55
|
+
return layouts.map((row) => {
|
|
56
|
+
return row.map((field) => {
|
|
57
|
+
const hasMapFieldEnabled = field.attribute?.pluginOptions?.["maplibre-field"]?.enabled;
|
|
58
|
+
if (!hasMapFieldEnabled) {
|
|
59
|
+
return field;
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
...field,
|
|
63
|
+
size: 12,
|
|
64
|
+
// Full width (12 columns out of 12)
|
|
65
|
+
attribute: {
|
|
66
|
+
...field.attribute,
|
|
67
|
+
customField: `plugin::${pluginId}.map`
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
const mutateEditViewHook = (editLayout) => {
|
|
74
|
+
if (!editLayout) {
|
|
75
|
+
return editLayout;
|
|
76
|
+
}
|
|
77
|
+
if (!Array.isArray(editLayout.layout)) {
|
|
78
|
+
return editLayout;
|
|
79
|
+
}
|
|
80
|
+
const mutatedLayout = mutateLayouts(editLayout.layout);
|
|
81
|
+
return {
|
|
82
|
+
...editLayout,
|
|
83
|
+
layout: mutatedLayout
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
const prefixPluginTranslations = (trad, pluginId2) => {
|
|
87
|
+
if (!pluginId2) {
|
|
88
|
+
throw new TypeError("pluginId can't be empty");
|
|
89
|
+
}
|
|
90
|
+
return Object.keys(trad).reduce((acc, current) => {
|
|
91
|
+
acc[`${pluginId2}.${current}`] = trad[current];
|
|
92
|
+
return acc;
|
|
93
|
+
}, {});
|
|
94
|
+
};
|
|
95
|
+
const name = pluginPkg.strapi.name;
|
|
96
|
+
const index = {
|
|
97
|
+
register(app) {
|
|
98
|
+
app.customFields.register({
|
|
99
|
+
name: "map",
|
|
100
|
+
pluginId,
|
|
101
|
+
type: "json",
|
|
102
|
+
intlLabel: {
|
|
103
|
+
id: getTrad("label"),
|
|
104
|
+
defaultMessage: "Map"
|
|
105
|
+
},
|
|
106
|
+
intlDescription: {
|
|
107
|
+
id: getTrad("description"),
|
|
108
|
+
defaultMessage: "A map custom field using MapLibre"
|
|
109
|
+
},
|
|
110
|
+
icon: PluginIcon,
|
|
111
|
+
components: {
|
|
112
|
+
Input: async () => Promise.resolve().then(() => require(
|
|
113
|
+
/* webpackChunkName: "input-component" */
|
|
114
|
+
"./index-BaGweGhM.js"
|
|
115
|
+
))
|
|
116
|
+
},
|
|
117
|
+
options: {
|
|
118
|
+
advanced: [
|
|
119
|
+
{
|
|
120
|
+
sectionTitle: null,
|
|
121
|
+
items: [
|
|
122
|
+
{
|
|
123
|
+
name: "options.pluginOptions.i18n.localized",
|
|
124
|
+
type: "checkbox",
|
|
125
|
+
intlLabel: {
|
|
126
|
+
id: getTrad("i18n.localized.label"),
|
|
127
|
+
defaultMessage: "Enable localization for this field"
|
|
128
|
+
},
|
|
129
|
+
intlDescription: {
|
|
130
|
+
id: getTrad("i18n.localized.description"),
|
|
131
|
+
defaultMessage: "The field can have different values in each language"
|
|
132
|
+
},
|
|
133
|
+
defaultValue: false
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
app.registerPlugin({
|
|
141
|
+
id: pluginId,
|
|
142
|
+
initializer: Initializer,
|
|
143
|
+
isReady: false,
|
|
144
|
+
name
|
|
145
|
+
});
|
|
146
|
+
},
|
|
147
|
+
bootstrap(app) {
|
|
148
|
+
app.registerHook("Admin/CM/pages/EditView/mutate-edit-view-layout", mutateEditViewHook);
|
|
149
|
+
},
|
|
150
|
+
async registerTrads({ locales }) {
|
|
151
|
+
const importedTrads = await Promise.all(
|
|
152
|
+
locales.map((locale) => {
|
|
153
|
+
return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => Promise.resolve().then(() => require("./de-B0QBc7M2.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-CA0XtbN7.js")), "./translations/es.json": () => Promise.resolve().then(() => require("./es-BU6JgkbZ.js")), "./translations/fr.json": () => Promise.resolve().then(() => require("./fr-DIBfzRbg.js")), "./translations/it.json": () => Promise.resolve().then(() => require("./it-B-lr3jhh.js")) }), `./translations/${locale}.json`, 3).then(({ default: data }) => {
|
|
154
|
+
return {
|
|
155
|
+
data: prefixPluginTranslations(data, pluginId),
|
|
156
|
+
locale
|
|
157
|
+
};
|
|
158
|
+
}).catch(() => {
|
|
159
|
+
return {
|
|
160
|
+
data: {},
|
|
161
|
+
locale
|
|
162
|
+
};
|
|
163
|
+
});
|
|
164
|
+
})
|
|
165
|
+
);
|
|
166
|
+
return Promise.resolve(importedTrads);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
exports.getTrad = getTrad;
|
|
170
|
+
exports.index = index;
|