@frameless/strapi-plugin-flo-legal-embed 2.0.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.
- package/LICENSE.md +288 -0
- package/README.md +34 -0
- package/dist/_chunks/en-DA9_CZNh.js +9 -0
- package/dist/_chunks/en-DL8lkwfI.mjs +9 -0
- package/dist/_chunks/index-BsjCjaop.mjs +421 -0
- package/dist/_chunks/index-Doljqns2.js +141 -0
- package/dist/_chunks/index-DuaW1Ojp.mjs +142 -0
- package/dist/_chunks/index-IrSgMm3Q.js +438 -0
- package/dist/_chunks/nl--quOP7M_.mjs +9 -0
- package/dist/_chunks/nl-WRqysNLk.js +9 -0
- package/dist/admin/index.js +3 -0
- package/dist/admin/index.mjs +4 -0
- package/dist/server/index.js +86 -0
- package/dist/server/index.mjs +87 -0
- package/package.json +102 -0
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Field, TextInput, Combobox, ComboboxOption } from "@strapi/design-system";
|
|
3
|
+
import { useIntl } from "react-intl";
|
|
4
|
+
import { useNotification, useFetchClient } from "@strapi/strapi/admin";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import React__default, { useEffect } from "react";
|
|
7
|
+
import { P as PLUGIN_ID, R as RESOLVE_CONFIG, g as getTranslation } from "./index-DuaW1Ojp.mjs";
|
|
8
|
+
var withSelector = { exports: {} };
|
|
9
|
+
var useSyncExternalStoreWithSelector_production = {};
|
|
10
|
+
/**
|
|
11
|
+
* @license React
|
|
12
|
+
* use-sync-external-store-with-selector.production.js
|
|
13
|
+
*
|
|
14
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
15
|
+
*
|
|
16
|
+
* This source code is licensed under the MIT license found in the
|
|
17
|
+
* LICENSE file in the root directory of this source tree.
|
|
18
|
+
*/
|
|
19
|
+
var hasRequiredUseSyncExternalStoreWithSelector_production;
|
|
20
|
+
function requireUseSyncExternalStoreWithSelector_production() {
|
|
21
|
+
if (hasRequiredUseSyncExternalStoreWithSelector_production) return useSyncExternalStoreWithSelector_production;
|
|
22
|
+
hasRequiredUseSyncExternalStoreWithSelector_production = 1;
|
|
23
|
+
var React2 = React__default;
|
|
24
|
+
function is(x, y) {
|
|
25
|
+
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
26
|
+
}
|
|
27
|
+
var objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore = React2.useSyncExternalStore, useRef = React2.useRef, useEffect2 = React2.useEffect, useMemo = React2.useMemo, useDebugValue = React2.useDebugValue;
|
|
28
|
+
useSyncExternalStoreWithSelector_production.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
|
|
29
|
+
var instRef = useRef(null);
|
|
30
|
+
if (null === instRef.current) {
|
|
31
|
+
var inst = { hasValue: false, value: null };
|
|
32
|
+
instRef.current = inst;
|
|
33
|
+
} else inst = instRef.current;
|
|
34
|
+
instRef = useMemo(
|
|
35
|
+
function() {
|
|
36
|
+
function memoizedSelector(nextSnapshot) {
|
|
37
|
+
if (!hasMemo) {
|
|
38
|
+
hasMemo = true;
|
|
39
|
+
memoizedSnapshot = nextSnapshot;
|
|
40
|
+
nextSnapshot = selector(nextSnapshot);
|
|
41
|
+
if (void 0 !== isEqual && inst.hasValue) {
|
|
42
|
+
var currentSelection = inst.value;
|
|
43
|
+
if (isEqual(currentSelection, nextSnapshot))
|
|
44
|
+
return memoizedSelection = currentSelection;
|
|
45
|
+
}
|
|
46
|
+
return memoizedSelection = nextSnapshot;
|
|
47
|
+
}
|
|
48
|
+
currentSelection = memoizedSelection;
|
|
49
|
+
if (objectIs(memoizedSnapshot, nextSnapshot)) return currentSelection;
|
|
50
|
+
var nextSelection = selector(nextSnapshot);
|
|
51
|
+
if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
|
|
52
|
+
return memoizedSnapshot = nextSnapshot, currentSelection;
|
|
53
|
+
memoizedSnapshot = nextSnapshot;
|
|
54
|
+
return memoizedSelection = nextSelection;
|
|
55
|
+
}
|
|
56
|
+
var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
|
|
57
|
+
return [
|
|
58
|
+
function() {
|
|
59
|
+
return memoizedSelector(getSnapshot());
|
|
60
|
+
},
|
|
61
|
+
null === maybeGetServerSnapshot ? void 0 : function() {
|
|
62
|
+
return memoizedSelector(maybeGetServerSnapshot());
|
|
63
|
+
}
|
|
64
|
+
];
|
|
65
|
+
},
|
|
66
|
+
[getSnapshot, getServerSnapshot, selector, isEqual]
|
|
67
|
+
);
|
|
68
|
+
var value = useSyncExternalStore(subscribe, instRef[0], instRef[1]);
|
|
69
|
+
useEffect2(
|
|
70
|
+
function() {
|
|
71
|
+
inst.hasValue = true;
|
|
72
|
+
inst.value = value;
|
|
73
|
+
},
|
|
74
|
+
[value]
|
|
75
|
+
);
|
|
76
|
+
useDebugValue(value);
|
|
77
|
+
return value;
|
|
78
|
+
};
|
|
79
|
+
return useSyncExternalStoreWithSelector_production;
|
|
80
|
+
}
|
|
81
|
+
var useSyncExternalStoreWithSelector_development = {};
|
|
82
|
+
/**
|
|
83
|
+
* @license React
|
|
84
|
+
* use-sync-external-store-with-selector.development.js
|
|
85
|
+
*
|
|
86
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
87
|
+
*
|
|
88
|
+
* This source code is licensed under the MIT license found in the
|
|
89
|
+
* LICENSE file in the root directory of this source tree.
|
|
90
|
+
*/
|
|
91
|
+
var hasRequiredUseSyncExternalStoreWithSelector_development;
|
|
92
|
+
function requireUseSyncExternalStoreWithSelector_development() {
|
|
93
|
+
if (hasRequiredUseSyncExternalStoreWithSelector_development) return useSyncExternalStoreWithSelector_development;
|
|
94
|
+
hasRequiredUseSyncExternalStoreWithSelector_development = 1;
|
|
95
|
+
"production" !== process.env.NODE_ENV && function() {
|
|
96
|
+
function is(x, y) {
|
|
97
|
+
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
98
|
+
}
|
|
99
|
+
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
100
|
+
var React2 = React__default, objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore = React2.useSyncExternalStore, useRef = React2.useRef, useEffect2 = React2.useEffect, useMemo = React2.useMemo, useDebugValue = React2.useDebugValue;
|
|
101
|
+
useSyncExternalStoreWithSelector_development.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
|
|
102
|
+
var instRef = useRef(null);
|
|
103
|
+
if (null === instRef.current) {
|
|
104
|
+
var inst = { hasValue: false, value: null };
|
|
105
|
+
instRef.current = inst;
|
|
106
|
+
} else inst = instRef.current;
|
|
107
|
+
instRef = useMemo(
|
|
108
|
+
function() {
|
|
109
|
+
function memoizedSelector(nextSnapshot) {
|
|
110
|
+
if (!hasMemo) {
|
|
111
|
+
hasMemo = true;
|
|
112
|
+
memoizedSnapshot = nextSnapshot;
|
|
113
|
+
nextSnapshot = selector(nextSnapshot);
|
|
114
|
+
if (void 0 !== isEqual && inst.hasValue) {
|
|
115
|
+
var currentSelection = inst.value;
|
|
116
|
+
if (isEqual(currentSelection, nextSnapshot))
|
|
117
|
+
return memoizedSelection = currentSelection;
|
|
118
|
+
}
|
|
119
|
+
return memoizedSelection = nextSnapshot;
|
|
120
|
+
}
|
|
121
|
+
currentSelection = memoizedSelection;
|
|
122
|
+
if (objectIs(memoizedSnapshot, nextSnapshot))
|
|
123
|
+
return currentSelection;
|
|
124
|
+
var nextSelection = selector(nextSnapshot);
|
|
125
|
+
if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
|
|
126
|
+
return memoizedSnapshot = nextSnapshot, currentSelection;
|
|
127
|
+
memoizedSnapshot = nextSnapshot;
|
|
128
|
+
return memoizedSelection = nextSelection;
|
|
129
|
+
}
|
|
130
|
+
var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
|
|
131
|
+
return [
|
|
132
|
+
function() {
|
|
133
|
+
return memoizedSelector(getSnapshot());
|
|
134
|
+
},
|
|
135
|
+
null === maybeGetServerSnapshot ? void 0 : function() {
|
|
136
|
+
return memoizedSelector(maybeGetServerSnapshot());
|
|
137
|
+
}
|
|
138
|
+
];
|
|
139
|
+
},
|
|
140
|
+
[getSnapshot, getServerSnapshot, selector, isEqual]
|
|
141
|
+
);
|
|
142
|
+
var value = useSyncExternalStore(subscribe, instRef[0], instRef[1]);
|
|
143
|
+
useEffect2(
|
|
144
|
+
function() {
|
|
145
|
+
inst.hasValue = true;
|
|
146
|
+
inst.value = value;
|
|
147
|
+
},
|
|
148
|
+
[value]
|
|
149
|
+
);
|
|
150
|
+
useDebugValue(value);
|
|
151
|
+
return value;
|
|
152
|
+
};
|
|
153
|
+
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
154
|
+
}();
|
|
155
|
+
return useSyncExternalStoreWithSelector_development;
|
|
156
|
+
}
|
|
157
|
+
if (process.env.NODE_ENV === "production") {
|
|
158
|
+
withSelector.exports = requireUseSyncExternalStoreWithSelector_production();
|
|
159
|
+
} else {
|
|
160
|
+
withSelector.exports = requireUseSyncExternalStoreWithSelector_development();
|
|
161
|
+
}
|
|
162
|
+
var withSelectorExports = withSelector.exports;
|
|
163
|
+
var ContextKey = /* @__PURE__ */ Symbol.for(`react-redux-context`);
|
|
164
|
+
var gT = typeof globalThis !== "undefined" ? globalThis : (
|
|
165
|
+
/* fall back to a per-module scope (pre-8.1 behaviour) if `globalThis` is not available */
|
|
166
|
+
{}
|
|
167
|
+
);
|
|
168
|
+
function getContext() {
|
|
169
|
+
if (!React.createContext) return {};
|
|
170
|
+
const contextMap = gT[ContextKey] ??= /* @__PURE__ */ new Map();
|
|
171
|
+
let realContext = contextMap.get(React.createContext);
|
|
172
|
+
if (!realContext) {
|
|
173
|
+
realContext = React.createContext(
|
|
174
|
+
null
|
|
175
|
+
);
|
|
176
|
+
if (process.env.NODE_ENV !== "production") {
|
|
177
|
+
realContext.displayName = "ReactRedux";
|
|
178
|
+
}
|
|
179
|
+
contextMap.set(React.createContext, realContext);
|
|
180
|
+
}
|
|
181
|
+
return realContext;
|
|
182
|
+
}
|
|
183
|
+
var ReactReduxContext = /* @__PURE__ */ getContext();
|
|
184
|
+
function createReduxContextHook(context = ReactReduxContext) {
|
|
185
|
+
return function useReduxContext2() {
|
|
186
|
+
const contextValue = React.useContext(context);
|
|
187
|
+
if (process.env.NODE_ENV !== "production" && !contextValue) {
|
|
188
|
+
throw new Error(
|
|
189
|
+
"could not find react-redux context value; please ensure the component is wrapped in a <Provider>"
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
return contextValue;
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
var useReduxContext = /* @__PURE__ */ createReduxContextHook();
|
|
196
|
+
function createStoreHook(context = ReactReduxContext) {
|
|
197
|
+
const useReduxContext2 = context === ReactReduxContext ? useReduxContext : (
|
|
198
|
+
// @ts-ignore
|
|
199
|
+
createReduxContextHook(context)
|
|
200
|
+
);
|
|
201
|
+
const useStore2 = () => {
|
|
202
|
+
const { store } = useReduxContext2();
|
|
203
|
+
return store;
|
|
204
|
+
};
|
|
205
|
+
Object.assign(useStore2, {
|
|
206
|
+
withTypes: () => useStore2
|
|
207
|
+
});
|
|
208
|
+
return useStore2;
|
|
209
|
+
}
|
|
210
|
+
var useStore = /* @__PURE__ */ createStoreHook();
|
|
211
|
+
function createDispatchHook(context = ReactReduxContext) {
|
|
212
|
+
const useStore2 = context === ReactReduxContext ? useStore : createStoreHook(context);
|
|
213
|
+
const useDispatch2 = () => {
|
|
214
|
+
const store = useStore2();
|
|
215
|
+
return store.dispatch;
|
|
216
|
+
};
|
|
217
|
+
Object.assign(useDispatch2, {
|
|
218
|
+
withTypes: () => useDispatch2
|
|
219
|
+
});
|
|
220
|
+
return useDispatch2;
|
|
221
|
+
}
|
|
222
|
+
var useDispatch = /* @__PURE__ */ createDispatchHook();
|
|
223
|
+
var refEquality = (a, b) => a === b;
|
|
224
|
+
function createSelectorHook(context = ReactReduxContext) {
|
|
225
|
+
const useReduxContext2 = context === ReactReduxContext ? useReduxContext : createReduxContextHook(context);
|
|
226
|
+
const useSelector2 = (selector, equalityFnOrOptions = {}) => {
|
|
227
|
+
const { equalityFn = refEquality } = typeof equalityFnOrOptions === "function" ? { equalityFn: equalityFnOrOptions } : equalityFnOrOptions;
|
|
228
|
+
if (process.env.NODE_ENV !== "production") {
|
|
229
|
+
if (!selector) {
|
|
230
|
+
throw new Error(`You must pass a selector to useSelector`);
|
|
231
|
+
}
|
|
232
|
+
if (typeof selector !== "function") {
|
|
233
|
+
throw new Error(`You must pass a function as a selector to useSelector`);
|
|
234
|
+
}
|
|
235
|
+
if (typeof equalityFn !== "function") {
|
|
236
|
+
throw new Error(
|
|
237
|
+
`You must pass a function as an equality function to useSelector`
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
const reduxContext = useReduxContext2();
|
|
242
|
+
const { store, subscription, getServerState } = reduxContext;
|
|
243
|
+
const firstRun = React.useRef(true);
|
|
244
|
+
const wrappedSelector = React.useCallback(
|
|
245
|
+
{
|
|
246
|
+
[selector.name](state) {
|
|
247
|
+
const selected = selector(state);
|
|
248
|
+
if (process.env.NODE_ENV !== "production") {
|
|
249
|
+
const { devModeChecks = {} } = typeof equalityFnOrOptions === "function" ? {} : equalityFnOrOptions;
|
|
250
|
+
const { identityFunctionCheck, stabilityCheck } = reduxContext;
|
|
251
|
+
const {
|
|
252
|
+
identityFunctionCheck: finalIdentityFunctionCheck,
|
|
253
|
+
stabilityCheck: finalStabilityCheck
|
|
254
|
+
} = {
|
|
255
|
+
stabilityCheck,
|
|
256
|
+
identityFunctionCheck,
|
|
257
|
+
...devModeChecks
|
|
258
|
+
};
|
|
259
|
+
if (finalStabilityCheck === "always" || finalStabilityCheck === "once" && firstRun.current) {
|
|
260
|
+
const toCompare = selector(state);
|
|
261
|
+
if (!equalityFn(selected, toCompare)) {
|
|
262
|
+
let stack = void 0;
|
|
263
|
+
try {
|
|
264
|
+
throw new Error();
|
|
265
|
+
} catch (e) {
|
|
266
|
+
({ stack } = e);
|
|
267
|
+
}
|
|
268
|
+
console.warn(
|
|
269
|
+
"Selector " + (selector.name || "unknown") + " returned a different result when called with the same parameters. This can lead to unnecessary rerenders.\nSelectors that return a new reference (such as an object or an array) should be memoized: https://redux.js.org/usage/deriving-data-selectors#optimizing-selectors-with-memoization",
|
|
270
|
+
{
|
|
271
|
+
state,
|
|
272
|
+
selected,
|
|
273
|
+
selected2: toCompare,
|
|
274
|
+
stack
|
|
275
|
+
}
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (finalIdentityFunctionCheck === "always" || finalIdentityFunctionCheck === "once" && firstRun.current) {
|
|
280
|
+
if (selected === state) {
|
|
281
|
+
let stack = void 0;
|
|
282
|
+
try {
|
|
283
|
+
throw new Error();
|
|
284
|
+
} catch (e) {
|
|
285
|
+
({ stack } = e);
|
|
286
|
+
}
|
|
287
|
+
console.warn(
|
|
288
|
+
"Selector " + (selector.name || "unknown") + " returned the root state when called. This can lead to unnecessary rerenders.\nSelectors that return the entire state are almost certainly a mistake, as they will cause a rerender whenever *anything* in state changes.",
|
|
289
|
+
{ stack }
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
if (firstRun.current) firstRun.current = false;
|
|
294
|
+
}
|
|
295
|
+
return selected;
|
|
296
|
+
}
|
|
297
|
+
}[selector.name],
|
|
298
|
+
[selector]
|
|
299
|
+
);
|
|
300
|
+
const selectedState = withSelectorExports.useSyncExternalStoreWithSelector(
|
|
301
|
+
subscription.addNestedSub,
|
|
302
|
+
store.getState,
|
|
303
|
+
getServerState || store.getState,
|
|
304
|
+
wrappedSelector,
|
|
305
|
+
equalityFn
|
|
306
|
+
);
|
|
307
|
+
React.useDebugValue(selectedState);
|
|
308
|
+
return selectedState;
|
|
309
|
+
};
|
|
310
|
+
Object.assign(useSelector2, {
|
|
311
|
+
withTypes: () => useSelector2
|
|
312
|
+
});
|
|
313
|
+
return useSelector2;
|
|
314
|
+
}
|
|
315
|
+
var useSelector = /* @__PURE__ */ createSelectorHook();
|
|
316
|
+
const usePluginConfig = () => {
|
|
317
|
+
const dispatch = useDispatch();
|
|
318
|
+
const { toggleNotification } = useNotification();
|
|
319
|
+
const { formatMessage } = useIntl();
|
|
320
|
+
const { isLoading, config, checks } = useSelector(
|
|
321
|
+
(state) => state[`${PLUGIN_ID}_config`]
|
|
322
|
+
);
|
|
323
|
+
const client = useFetchClient();
|
|
324
|
+
useEffect(() => {
|
|
325
|
+
if (!isLoading && config !== null) {
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
const abortController = new AbortController();
|
|
329
|
+
const fetchData = async () => {
|
|
330
|
+
try {
|
|
331
|
+
const endpoint = `/${PLUGIN_ID}/config`;
|
|
332
|
+
const { data } = await client.get(endpoint, {
|
|
333
|
+
signal: abortController.signal
|
|
334
|
+
});
|
|
335
|
+
return data ?? null;
|
|
336
|
+
} catch (err) {
|
|
337
|
+
console.error(err);
|
|
338
|
+
if (!abortController.signal.aborted) {
|
|
339
|
+
toggleNotification({
|
|
340
|
+
type: "warning",
|
|
341
|
+
message: formatMessage({
|
|
342
|
+
id: getTranslation("notification.error"),
|
|
343
|
+
defaultMessage: "An error occurred while fetching data"
|
|
344
|
+
})
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
return null;
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
fetchData().then((data) => dispatch({ type: RESOLVE_CONFIG, data }));
|
|
351
|
+
return () => abortController.abort();
|
|
352
|
+
}, [client, config, dispatch, isLoading, toggleNotification, formatMessage]);
|
|
353
|
+
return { config, checks, isLoading };
|
|
354
|
+
};
|
|
355
|
+
const FloLegalCombobox = ({
|
|
356
|
+
value,
|
|
357
|
+
onChange,
|
|
358
|
+
name,
|
|
359
|
+
required,
|
|
360
|
+
type,
|
|
361
|
+
placeholder,
|
|
362
|
+
disabled,
|
|
363
|
+
error,
|
|
364
|
+
label,
|
|
365
|
+
hint
|
|
366
|
+
}) => {
|
|
367
|
+
const { config, checks, isLoading } = usePluginConfig();
|
|
368
|
+
const { formatMessage } = useIntl();
|
|
369
|
+
const generateFloLegalData = (params) => new URLSearchParams({ ...params }).toString();
|
|
370
|
+
if (!config?.api_url || !config?.token) {
|
|
371
|
+
return /* @__PURE__ */ jsxs(
|
|
372
|
+
Field.Root,
|
|
373
|
+
{
|
|
374
|
+
name,
|
|
375
|
+
error,
|
|
376
|
+
hint: formatMessage({
|
|
377
|
+
id: getTranslation("flo-legal-embed.disabled.hint"),
|
|
378
|
+
defaultMessage: "Ensure FLO_LEGAL_API_URL and FLO_LEGAL_API_TOKEN are configured to enable this field."
|
|
379
|
+
}),
|
|
380
|
+
children: [
|
|
381
|
+
/* @__PURE__ */ jsx(Field.Label, { children: label }),
|
|
382
|
+
/* @__PURE__ */ jsx(
|
|
383
|
+
TextInput,
|
|
384
|
+
{
|
|
385
|
+
name,
|
|
386
|
+
value: "",
|
|
387
|
+
placeholder: formatMessage({
|
|
388
|
+
id: getTranslation("flo-legal-embed.disabled.placeholder"),
|
|
389
|
+
defaultMessage: "This field is disabled until necessary settings are configured."
|
|
390
|
+
}),
|
|
391
|
+
disabled: true
|
|
392
|
+
}
|
|
393
|
+
),
|
|
394
|
+
/* @__PURE__ */ jsx(Field.Hint, {}),
|
|
395
|
+
/* @__PURE__ */ jsx(Field.Error, {})
|
|
396
|
+
]
|
|
397
|
+
}
|
|
398
|
+
);
|
|
399
|
+
}
|
|
400
|
+
return /* @__PURE__ */ jsxs(Field.Root, { name, error, hint, required, children: [
|
|
401
|
+
/* @__PURE__ */ jsx(Field.Label, { children: label }),
|
|
402
|
+
/* @__PURE__ */ jsx(
|
|
403
|
+
Combobox,
|
|
404
|
+
{
|
|
405
|
+
placeholder,
|
|
406
|
+
"aria-label": label,
|
|
407
|
+
disabled,
|
|
408
|
+
required,
|
|
409
|
+
value: value ?? "",
|
|
410
|
+
loading: isLoading,
|
|
411
|
+
onChange: (val) => onChange({ target: { name, value: val, type } }),
|
|
412
|
+
children: checks.map(({ identifier, name: name2 }) => /* @__PURE__ */ jsx(ComboboxOption, { value: generateFloLegalData({ identifier }), children: name2 }, identifier))
|
|
413
|
+
}
|
|
414
|
+
),
|
|
415
|
+
/* @__PURE__ */ jsx(Field.Hint, {}),
|
|
416
|
+
/* @__PURE__ */ jsx(Field.Error, {})
|
|
417
|
+
] });
|
|
418
|
+
};
|
|
419
|
+
export {
|
|
420
|
+
FloLegalCombobox
|
|
421
|
+
};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
+
const designSystem = require("@strapi/design-system");
|
|
4
|
+
const icons = require("@strapi/icons");
|
|
5
|
+
const immer = require("immer");
|
|
6
|
+
const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
|
|
7
|
+
const v = glob[path];
|
|
8
|
+
if (v) {
|
|
9
|
+
return typeof v === "function" ? v() : Promise.resolve(v);
|
|
10
|
+
}
|
|
11
|
+
return new Promise((_, reject) => {
|
|
12
|
+
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
|
|
13
|
+
reject.bind(
|
|
14
|
+
null,
|
|
15
|
+
new Error(
|
|
16
|
+
"Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
|
|
17
|
+
)
|
|
18
|
+
)
|
|
19
|
+
);
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
const FloLegalIcon = () => /* @__PURE__ */ jsxRuntime.jsx(
|
|
23
|
+
designSystem.Flex,
|
|
24
|
+
{
|
|
25
|
+
justifyContent: "center",
|
|
26
|
+
alignItems: "center",
|
|
27
|
+
width: 7,
|
|
28
|
+
height: 6,
|
|
29
|
+
background: "primary100",
|
|
30
|
+
borderColor: "primary200",
|
|
31
|
+
borderWidth: "1px",
|
|
32
|
+
borderStyle: "solid",
|
|
33
|
+
hasRadius: true,
|
|
34
|
+
"aria-hidden": true,
|
|
35
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.ManyWays, { color: "primary600" })
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
const PLUGIN_ID = "flo-legal-embed";
|
|
39
|
+
const RESOLVE_CONFIG = `${PLUGIN_ID}/resolve-config`;
|
|
40
|
+
const initialState = {
|
|
41
|
+
isLoading: true,
|
|
42
|
+
config: null,
|
|
43
|
+
checks: []
|
|
44
|
+
};
|
|
45
|
+
const configReducer = immer.produce(
|
|
46
|
+
// eslint-disable-next-line consistent-return
|
|
47
|
+
(state = initialState, action) => {
|
|
48
|
+
switch (action.type) {
|
|
49
|
+
case RESOLVE_CONFIG: {
|
|
50
|
+
const { data } = action;
|
|
51
|
+
state.isLoading = false;
|
|
52
|
+
state.config = data?.config ?? null;
|
|
53
|
+
state.checks = data?.checks ?? [];
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
default:
|
|
57
|
+
return state;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
const reducers = {
|
|
62
|
+
[`${PLUGIN_ID}_config`]: configReducer
|
|
63
|
+
};
|
|
64
|
+
const getTranslation = (id) => `${PLUGIN_ID}.${id}`;
|
|
65
|
+
const prefixPluginTranslations = (translate, pluginId) => {
|
|
66
|
+
return Object.keys(translate).reduce((acc, current) => {
|
|
67
|
+
acc[`${pluginId}.${current}`] = translate[current];
|
|
68
|
+
return acc;
|
|
69
|
+
}, {});
|
|
70
|
+
};
|
|
71
|
+
const index = {
|
|
72
|
+
register(app) {
|
|
73
|
+
app.addReducers(reducers);
|
|
74
|
+
app.customFields.register({
|
|
75
|
+
name: PLUGIN_ID,
|
|
76
|
+
pluginId: PLUGIN_ID,
|
|
77
|
+
type: "string",
|
|
78
|
+
icon: FloLegalIcon,
|
|
79
|
+
intlLabel: {
|
|
80
|
+
id: getTranslation("flo-legal-embed.label"),
|
|
81
|
+
defaultMessage: "Choose an Embedded Flo Legal Form"
|
|
82
|
+
},
|
|
83
|
+
intlDescription: {
|
|
84
|
+
id: getTranslation("flo-legal-embed.description"),
|
|
85
|
+
defaultMessage: "Saves the unique identifier of the selected decision tree in the database."
|
|
86
|
+
},
|
|
87
|
+
components: {
|
|
88
|
+
Input: async () => {
|
|
89
|
+
const { FloLegalCombobox } = await Promise.resolve().then(() => require("./index-IrSgMm3Q.js"));
|
|
90
|
+
return { default: FloLegalCombobox };
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
options: {
|
|
94
|
+
advanced: [
|
|
95
|
+
{
|
|
96
|
+
sectionTitle: {
|
|
97
|
+
id: "global.settings",
|
|
98
|
+
defaultMessage: "Settings"
|
|
99
|
+
},
|
|
100
|
+
items: [
|
|
101
|
+
{
|
|
102
|
+
name: "required",
|
|
103
|
+
type: "checkbox",
|
|
104
|
+
intlLabel: {
|
|
105
|
+
id: "form.attribute.item.requiredField",
|
|
106
|
+
defaultMessage: "Required field"
|
|
107
|
+
},
|
|
108
|
+
description: {
|
|
109
|
+
id: "form.attribute.item.requiredField.description",
|
|
110
|
+
defaultMessage: "You won't be able to create an entry if this field is empty"
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
},
|
|
119
|
+
async registerTrads({ locales }) {
|
|
120
|
+
const importedTranslations = await Promise.all(
|
|
121
|
+
locales.map((locale) => {
|
|
122
|
+
return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => Promise.resolve().then(() => require("./en-DA9_CZNh.js")), "./translations/nl.json": () => Promise.resolve().then(() => require("./nl-WRqysNLk.js")) }), `./translations/${locale}.json`, 3).then(({ default: data }) => {
|
|
123
|
+
return {
|
|
124
|
+
data: prefixPluginTranslations(data, PLUGIN_ID),
|
|
125
|
+
locale
|
|
126
|
+
};
|
|
127
|
+
}).catch(() => {
|
|
128
|
+
return {
|
|
129
|
+
data: {},
|
|
130
|
+
locale
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
})
|
|
134
|
+
);
|
|
135
|
+
return Promise.resolve(importedTranslations);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
exports.PLUGIN_ID = PLUGIN_ID;
|
|
139
|
+
exports.RESOLVE_CONFIG = RESOLVE_CONFIG;
|
|
140
|
+
exports.getTranslation = getTranslation;
|
|
141
|
+
exports.index = index;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Flex } from "@strapi/design-system";
|
|
3
|
+
import { ManyWays } from "@strapi/icons";
|
|
4
|
+
import { produce } from "immer";
|
|
5
|
+
const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
|
|
6
|
+
const v = glob[path];
|
|
7
|
+
if (v) {
|
|
8
|
+
return typeof v === "function" ? v() : Promise.resolve(v);
|
|
9
|
+
}
|
|
10
|
+
return new Promise((_, reject) => {
|
|
11
|
+
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
|
|
12
|
+
reject.bind(
|
|
13
|
+
null,
|
|
14
|
+
new Error(
|
|
15
|
+
"Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
|
|
16
|
+
)
|
|
17
|
+
)
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
const FloLegalIcon = () => /* @__PURE__ */ jsx(
|
|
22
|
+
Flex,
|
|
23
|
+
{
|
|
24
|
+
justifyContent: "center",
|
|
25
|
+
alignItems: "center",
|
|
26
|
+
width: 7,
|
|
27
|
+
height: 6,
|
|
28
|
+
background: "primary100",
|
|
29
|
+
borderColor: "primary200",
|
|
30
|
+
borderWidth: "1px",
|
|
31
|
+
borderStyle: "solid",
|
|
32
|
+
hasRadius: true,
|
|
33
|
+
"aria-hidden": true,
|
|
34
|
+
children: /* @__PURE__ */ jsx(ManyWays, { color: "primary600" })
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
const PLUGIN_ID = "flo-legal-embed";
|
|
38
|
+
const RESOLVE_CONFIG = `${PLUGIN_ID}/resolve-config`;
|
|
39
|
+
const initialState = {
|
|
40
|
+
isLoading: true,
|
|
41
|
+
config: null,
|
|
42
|
+
checks: []
|
|
43
|
+
};
|
|
44
|
+
const configReducer = produce(
|
|
45
|
+
// eslint-disable-next-line consistent-return
|
|
46
|
+
(state = initialState, action) => {
|
|
47
|
+
switch (action.type) {
|
|
48
|
+
case RESOLVE_CONFIG: {
|
|
49
|
+
const { data } = action;
|
|
50
|
+
state.isLoading = false;
|
|
51
|
+
state.config = data?.config ?? null;
|
|
52
|
+
state.checks = data?.checks ?? [];
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
default:
|
|
56
|
+
return state;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
const reducers = {
|
|
61
|
+
[`${PLUGIN_ID}_config`]: configReducer
|
|
62
|
+
};
|
|
63
|
+
const getTranslation = (id) => `${PLUGIN_ID}.${id}`;
|
|
64
|
+
const prefixPluginTranslations = (translate, pluginId) => {
|
|
65
|
+
return Object.keys(translate).reduce((acc, current) => {
|
|
66
|
+
acc[`${pluginId}.${current}`] = translate[current];
|
|
67
|
+
return acc;
|
|
68
|
+
}, {});
|
|
69
|
+
};
|
|
70
|
+
const index = {
|
|
71
|
+
register(app) {
|
|
72
|
+
app.addReducers(reducers);
|
|
73
|
+
app.customFields.register({
|
|
74
|
+
name: PLUGIN_ID,
|
|
75
|
+
pluginId: PLUGIN_ID,
|
|
76
|
+
type: "string",
|
|
77
|
+
icon: FloLegalIcon,
|
|
78
|
+
intlLabel: {
|
|
79
|
+
id: getTranslation("flo-legal-embed.label"),
|
|
80
|
+
defaultMessage: "Choose an Embedded Flo Legal Form"
|
|
81
|
+
},
|
|
82
|
+
intlDescription: {
|
|
83
|
+
id: getTranslation("flo-legal-embed.description"),
|
|
84
|
+
defaultMessage: "Saves the unique identifier of the selected decision tree in the database."
|
|
85
|
+
},
|
|
86
|
+
components: {
|
|
87
|
+
Input: async () => {
|
|
88
|
+
const { FloLegalCombobox } = await import("./index-BsjCjaop.mjs");
|
|
89
|
+
return { default: FloLegalCombobox };
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
options: {
|
|
93
|
+
advanced: [
|
|
94
|
+
{
|
|
95
|
+
sectionTitle: {
|
|
96
|
+
id: "global.settings",
|
|
97
|
+
defaultMessage: "Settings"
|
|
98
|
+
},
|
|
99
|
+
items: [
|
|
100
|
+
{
|
|
101
|
+
name: "required",
|
|
102
|
+
type: "checkbox",
|
|
103
|
+
intlLabel: {
|
|
104
|
+
id: "form.attribute.item.requiredField",
|
|
105
|
+
defaultMessage: "Required field"
|
|
106
|
+
},
|
|
107
|
+
description: {
|
|
108
|
+
id: "form.attribute.item.requiredField.description",
|
|
109
|
+
defaultMessage: "You won't be able to create an entry if this field is empty"
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
},
|
|
118
|
+
async registerTrads({ locales }) {
|
|
119
|
+
const importedTranslations = await Promise.all(
|
|
120
|
+
locales.map((locale) => {
|
|
121
|
+
return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => import("./en-DL8lkwfI.mjs"), "./translations/nl.json": () => import("./nl--quOP7M_.mjs") }), `./translations/${locale}.json`, 3).then(({ default: data }) => {
|
|
122
|
+
return {
|
|
123
|
+
data: prefixPluginTranslations(data, PLUGIN_ID),
|
|
124
|
+
locale
|
|
125
|
+
};
|
|
126
|
+
}).catch(() => {
|
|
127
|
+
return {
|
|
128
|
+
data: {},
|
|
129
|
+
locale
|
|
130
|
+
};
|
|
131
|
+
});
|
|
132
|
+
})
|
|
133
|
+
);
|
|
134
|
+
return Promise.resolve(importedTranslations);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
export {
|
|
138
|
+
PLUGIN_ID as P,
|
|
139
|
+
RESOLVE_CONFIG as R,
|
|
140
|
+
getTranslation as g,
|
|
141
|
+
index as i
|
|
142
|
+
};
|