@crediblemark/build 0.22.2 → 0.22.7
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/README.md +1 -5
- package/dist/ArrayField-EPM4TV3J.mjs +538 -0
- package/dist/ArrayField-ZD5UTLNU.css +1216 -0
- package/dist/{Editor-XZF6CWVW.css → Editor-E7FALXHL.css} +7 -7
- package/dist/{Editor-ZC67OU2A.mjs → Editor-L674TD7T.mjs} +16 -18
- package/dist/ObjectField-MW3SSNKI.mjs +87 -0
- package/dist/ObjectField-SQKROKJM.css +1216 -0
- package/dist/{Render-WCX4AXOX.css → Render-JDXVKZXN.css} +1 -1
- package/dist/{Render-JBFI6HYN.mjs → Render-WP5OOTBB.mjs} +4 -7
- package/dist/chunk-2JUMF5G3.mjs +1145 -0
- package/dist/{chunk-VGDMWS44.mjs → chunk-4PJ4QMWI.mjs} +4 -25
- package/dist/{chunk-3AJBFQU4.mjs → chunk-64A37UUC.mjs} +19 -53
- package/dist/{chunk-QF3GD5WQ.mjs → chunk-67TMLSKM.mjs} +1 -5
- package/dist/{chunk-GUJDGRSM.mjs → chunk-7LXZOPYT.mjs} +5 -29
- package/dist/chunk-AEKBE267.mjs +19 -0
- package/dist/chunk-AFVEAZTD.mjs +2 -0
- package/dist/{chunk-IJHL7BIR.mjs → chunk-AL77I3BV.mjs} +1 -6
- package/dist/chunk-BFHV72KK.mjs +31 -0
- package/dist/{chunk-PHGC6QYB.mjs → chunk-DEUK76GN.mjs} +0 -5
- package/dist/{chunk-4SQOX3ZQ.mjs → chunk-DVK7K7D6.mjs} +5 -27
- package/dist/{chunk-VKBVSWU3.mjs → chunk-JNHQNNGW.mjs} +3672 -5905
- package/dist/{chunk-HHBUU7WF.mjs → chunk-JNMMY5D7.mjs} +1 -5
- package/dist/chunk-K27LFPQL.mjs +339 -0
- package/dist/{chunk-VFD76OD5.mjs → chunk-NYBWAKLT.mjs} +1 -5
- package/dist/chunk-RDTXKOE7.mjs +60 -0
- package/dist/{chunk-CDMESQDA.mjs → chunk-SMAWAXVX.mjs} +1 -10
- package/dist/{chunk-DSXRK4QJ.mjs → chunk-T6RT6PV4.mjs} +13 -62
- package/dist/{chunk-U2NVBXAC.mjs → chunk-ZY24NW7X.mjs} +246 -358
- package/dist/{full-ABQQRJAO.css → full-MY4DABK6.css} +6 -6
- package/dist/{full-LJRK5736.mjs → full-SGY5HNVB.mjs} +10 -14
- package/dist/index.css +588 -294
- package/dist/index.d.mts +5 -8
- package/dist/index.d.ts +5 -8
- package/dist/index.js +5985 -5656
- package/dist/index.mjs +23 -25
- package/dist/internal.mjs +3 -8
- package/dist/{loaded-NE2PIHUQ.mjs → loaded-2GLOBOVP.mjs} +7 -10
- package/dist/{loaded-N7VXUR4O.mjs → loaded-AH3CPHD2.mjs} +7 -10
- package/dist/{loaded-DWCENJKQ.mjs → loaded-ARSKBJWP.mjs} +7 -10
- package/dist/{loaded-SMEIWWHS.css → loaded-E7C36OKZ.css} +1 -1
- package/dist/no-external.css +299 -294
- package/dist/no-external.d.mts +1 -1
- package/dist/no-external.d.ts +1 -1
- package/dist/no-external.js +5985 -5656
- package/dist/no-external.mjs +23 -25
- package/dist/rsc.css +1 -1
- package/dist/rsc.js +5 -79
- package/dist/rsc.mjs +6 -12
- package/package.json +41 -36
- package/dist/chunk-B4BOBGYB.mjs +0 -42
- package/dist/chunk-YH7AXYKP.mjs +0 -109
|
@@ -0,0 +1,1145 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EditorInner
|
|
3
|
+
} from "./chunk-4PJ4QMWI.mjs";
|
|
4
|
+
import {
|
|
5
|
+
IconButton,
|
|
6
|
+
LoadedRichTextMenuInner,
|
|
7
|
+
Loader
|
|
8
|
+
} from "./chunk-T6RT6PV4.mjs";
|
|
9
|
+
import {
|
|
10
|
+
ChevronDown,
|
|
11
|
+
CircleCheckBig,
|
|
12
|
+
Hash,
|
|
13
|
+
Link,
|
|
14
|
+
Lock,
|
|
15
|
+
LockOpen,
|
|
16
|
+
Search,
|
|
17
|
+
SlidersHorizontal,
|
|
18
|
+
Type,
|
|
19
|
+
useAppStore
|
|
20
|
+
} from "./chunk-ZY24NW7X.mjs";
|
|
21
|
+
import {
|
|
22
|
+
get_class_name_factory_default
|
|
23
|
+
} from "./chunk-BFHV72KK.mjs";
|
|
24
|
+
import {
|
|
25
|
+
generateId
|
|
26
|
+
} from "./chunk-7LXZOPYT.mjs";
|
|
27
|
+
|
|
28
|
+
// components/AutoField/store.ts
|
|
29
|
+
import { useContext as useContext2 } from "react";
|
|
30
|
+
import { useShallow as useShallow2 } from "zustand/react/shallow";
|
|
31
|
+
|
|
32
|
+
// lib/use-context-store.tsx
|
|
33
|
+
import { createContext, useContext, useState } from "react";
|
|
34
|
+
import { createStore, useStore } from "zustand";
|
|
35
|
+
import { subscribeWithSelector } from "zustand/middleware";
|
|
36
|
+
import { useShallow } from "zustand/react/shallow";
|
|
37
|
+
import { jsx } from "react/jsx-runtime";
|
|
38
|
+
function useContextStore(context, selector) {
|
|
39
|
+
const store = useContext(context);
|
|
40
|
+
if (!store) {
|
|
41
|
+
throw new Error("useContextStore must be used inside context");
|
|
42
|
+
}
|
|
43
|
+
return useStore(store, useShallow(selector));
|
|
44
|
+
}
|
|
45
|
+
function createStoreProvider(ContextComponent) {
|
|
46
|
+
const StoreProvider = ({
|
|
47
|
+
children,
|
|
48
|
+
value
|
|
49
|
+
}) => {
|
|
50
|
+
const [store] = useState(() => createStore(() => value));
|
|
51
|
+
return /* @__PURE__ */ jsx(ContextComponent.Provider, { value: store, children });
|
|
52
|
+
};
|
|
53
|
+
return StoreProvider;
|
|
54
|
+
}
|
|
55
|
+
function createContextStore(defaultValue) {
|
|
56
|
+
const ctx = createContext(
|
|
57
|
+
createStore(subscribeWithSelector(() => defaultValue))
|
|
58
|
+
);
|
|
59
|
+
return {
|
|
60
|
+
ctx,
|
|
61
|
+
Provider: createStoreProvider(ctx)
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// components/AutoField/store.ts
|
|
66
|
+
import { useStore as useStore2 } from "zustand";
|
|
67
|
+
var fieldContextStore = createContextStore({});
|
|
68
|
+
var useFieldStoreApi = () => useContext2(fieldContextStore.ctx);
|
|
69
|
+
function useFieldStore(selector) {
|
|
70
|
+
const store = useContext2(fieldContextStore.ctx);
|
|
71
|
+
if (!store) {
|
|
72
|
+
throw new Error("useContextStore must be used inside context");
|
|
73
|
+
}
|
|
74
|
+
return useStore2(store, useShallow2(selector));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// css-module:/home/crediblemark/Project/Credibuild/components/AutoField/styles.module.css#css-module
|
|
78
|
+
var styles_module_default = { "InputWrapper": "_InputWrapper_1q7gk_1", "Input-label": "_Input-label_1q7gk_5", "Input-labelIcon": "_Input-labelIcon_1q7gk_14", "Input-disabledIcon": "_Input-disabledIcon_1q7gk_21", "Input-input": "_Input-input_1q7gk_26", "Input": "_Input_1q7gk_1", "Input--readOnly": "_Input--readOnly_1q7gk_82", "Input-radioGroupItems": "_Input-radioGroupItems_1q7gk_93", "Input-radio": "_Input-radio_1q7gk_93", "Input-radioInner": "_Input-radioInner_1q7gk_110", "Input-radioInput": "_Input-radioInput_1q7gk_155" };
|
|
79
|
+
|
|
80
|
+
// components/AutoField/FieldLabel.tsx
|
|
81
|
+
import { useMemo } from "react";
|
|
82
|
+
import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
83
|
+
var getClassName = get_class_name_factory_default("Input", styles_module_default);
|
|
84
|
+
var FieldLabel = ({
|
|
85
|
+
children,
|
|
86
|
+
icon,
|
|
87
|
+
label,
|
|
88
|
+
el = "label",
|
|
89
|
+
readOnly,
|
|
90
|
+
className
|
|
91
|
+
}) => {
|
|
92
|
+
const El = el;
|
|
93
|
+
return /* @__PURE__ */ jsxs(El, { className, children: [
|
|
94
|
+
/* @__PURE__ */ jsxs("div", { className: getClassName("label"), children: [
|
|
95
|
+
icon ? /* @__PURE__ */ jsx2("div", { className: getClassName("labelIcon"), children: icon }) : /* @__PURE__ */ jsx2(Fragment, {}),
|
|
96
|
+
label,
|
|
97
|
+
readOnly && /* @__PURE__ */ jsx2("div", { className: getClassName("disabledIcon"), title: "Read-only", children: /* @__PURE__ */ jsx2(Lock, { size: "12" }) })
|
|
98
|
+
] }),
|
|
99
|
+
children
|
|
100
|
+
] });
|
|
101
|
+
};
|
|
102
|
+
var FieldLabelInternal = ({
|
|
103
|
+
children,
|
|
104
|
+
icon,
|
|
105
|
+
label,
|
|
106
|
+
el = "label",
|
|
107
|
+
readOnly
|
|
108
|
+
}) => {
|
|
109
|
+
const overrides = useAppStore((s) => s.overrides);
|
|
110
|
+
const Wrapper = useMemo(
|
|
111
|
+
() => overrides.fieldLabel || FieldLabel,
|
|
112
|
+
[overrides]
|
|
113
|
+
);
|
|
114
|
+
if (!label) {
|
|
115
|
+
return /* @__PURE__ */ jsx2(Fragment, { children });
|
|
116
|
+
}
|
|
117
|
+
return /* @__PURE__ */ jsx2(
|
|
118
|
+
Wrapper,
|
|
119
|
+
{
|
|
120
|
+
label,
|
|
121
|
+
icon,
|
|
122
|
+
className: getClassName({ readOnly }),
|
|
123
|
+
readOnly,
|
|
124
|
+
el,
|
|
125
|
+
children
|
|
126
|
+
}
|
|
127
|
+
);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
// lib/data/get-deep.ts
|
|
131
|
+
var getDeep = (node, path) => {
|
|
132
|
+
const pathParts = path.split(".");
|
|
133
|
+
return pathParts.reduce((acc, item) => {
|
|
134
|
+
if (!acc) return;
|
|
135
|
+
const [prop, indexStr] = item.replace("]", "").split("[");
|
|
136
|
+
const val = acc[prop];
|
|
137
|
+
if (indexStr && val) {
|
|
138
|
+
return val[parseInt(indexStr)];
|
|
139
|
+
}
|
|
140
|
+
return val;
|
|
141
|
+
}, node);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
// components/AutoField/context.tsx
|
|
145
|
+
import { createContext as createContext2, useContext as useContext3, useMemo as useMemo2 } from "react";
|
|
146
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
147
|
+
var NestedFieldContext = createContext2({});
|
|
148
|
+
var useNestedFieldContext = () => {
|
|
149
|
+
const context = useContext3(NestedFieldContext);
|
|
150
|
+
return {
|
|
151
|
+
...context,
|
|
152
|
+
readOnlyFields: context.readOnlyFields || {}
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
var NestedFieldProvider = ({
|
|
156
|
+
children,
|
|
157
|
+
name,
|
|
158
|
+
subName,
|
|
159
|
+
wildcardName = name,
|
|
160
|
+
readOnlyFields
|
|
161
|
+
}) => {
|
|
162
|
+
const subPath = `${name}.${subName}`;
|
|
163
|
+
const wildcardSubPath = `${wildcardName}.${subName}`;
|
|
164
|
+
const subReadOnlyFields = useMemo2(
|
|
165
|
+
() => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
|
|
166
|
+
const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
|
|
167
|
+
if (isLocal) {
|
|
168
|
+
const subPathPattern = new RegExp(
|
|
169
|
+
`^(${name}|${wildcardName}).`.replace(/\[/g, "\\[").replace(/\]/g, "\\]").replace(/\./g, "\\.").replace(/\*/g, "\\*")
|
|
170
|
+
);
|
|
171
|
+
const localName = readOnlyKey.replace(subPathPattern, "");
|
|
172
|
+
return {
|
|
173
|
+
...acc,
|
|
174
|
+
[localName]: readOnlyFields[readOnlyKey]
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
return acc;
|
|
178
|
+
}, {}),
|
|
179
|
+
[name, wildcardName, readOnlyFields, subPath, wildcardSubPath]
|
|
180
|
+
);
|
|
181
|
+
return /* @__PURE__ */ jsx3(
|
|
182
|
+
NestedFieldContext.Provider,
|
|
183
|
+
{
|
|
184
|
+
value: { readOnlyFields: subReadOnlyFields, localName: subName },
|
|
185
|
+
children
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
// components/Button/Button.tsx
|
|
191
|
+
import { useEffect, useState as useState2 } from "react";
|
|
192
|
+
|
|
193
|
+
// css-module:/home/crediblemark/Project/Credibuild/components/Button/Button.module.css#css-module
|
|
194
|
+
var Button_module_default = { "Button": "_Button_164uz_1", "Button--medium": "_Button--medium_164uz_29", "Button--large": "_Button--large_164uz_34", "Button-icon": "_Button-icon_164uz_38", "Button--primary": "_Button--primary_164uz_42", "Button--secondary": "_Button--secondary_164uz_63", "Button--flush": "_Button--flush_164uz_80", "Button--disabled": "_Button--disabled_164uz_84", "Button--fullWidth": "_Button--fullWidth_164uz_92", "Button-spinner": "_Button-spinner_164uz_97" };
|
|
195
|
+
|
|
196
|
+
// lib/filter-data-attrs.ts
|
|
197
|
+
var dataAttrRe = /^(data-.*)$/;
|
|
198
|
+
var filterDataAttrs = (props) => {
|
|
199
|
+
let filteredProps = {};
|
|
200
|
+
for (const prop in props) {
|
|
201
|
+
if (Object.prototype.hasOwnProperty.call(props, prop) && dataAttrRe.test(prop)) {
|
|
202
|
+
filteredProps[prop] = props[prop];
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return filteredProps;
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
// components/Button/Button.tsx
|
|
209
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
210
|
+
var getClassName2 = get_class_name_factory_default("Button", Button_module_default);
|
|
211
|
+
var Button = ({
|
|
212
|
+
children,
|
|
213
|
+
href,
|
|
214
|
+
onClick,
|
|
215
|
+
variant = "primary",
|
|
216
|
+
type,
|
|
217
|
+
disabled,
|
|
218
|
+
tabIndex,
|
|
219
|
+
newTab,
|
|
220
|
+
fullWidth,
|
|
221
|
+
icon,
|
|
222
|
+
size = "medium",
|
|
223
|
+
loading: loadingProp = false,
|
|
224
|
+
...props
|
|
225
|
+
}) => {
|
|
226
|
+
const [loading, setLoading] = useState2(loadingProp);
|
|
227
|
+
useEffect(() => setLoading(loadingProp), [loadingProp]);
|
|
228
|
+
const ElementType = href ? "a" : type ? "button" : "span";
|
|
229
|
+
const dataAttrs = filterDataAttrs(props);
|
|
230
|
+
const el = /* @__PURE__ */ jsxs2(
|
|
231
|
+
ElementType,
|
|
232
|
+
{
|
|
233
|
+
className: getClassName2({
|
|
234
|
+
primary: variant === "primary",
|
|
235
|
+
secondary: variant === "secondary",
|
|
236
|
+
disabled,
|
|
237
|
+
fullWidth,
|
|
238
|
+
[size]: true
|
|
239
|
+
}),
|
|
240
|
+
onClick: (e) => {
|
|
241
|
+
if (!onClick) return;
|
|
242
|
+
setLoading(true);
|
|
243
|
+
Promise.resolve(onClick(e)).then(() => {
|
|
244
|
+
setLoading(false);
|
|
245
|
+
});
|
|
246
|
+
},
|
|
247
|
+
type,
|
|
248
|
+
disabled: disabled || loading,
|
|
249
|
+
tabIndex,
|
|
250
|
+
target: newTab ? "_blank" : void 0,
|
|
251
|
+
rel: newTab ? "noreferrer" : void 0,
|
|
252
|
+
href,
|
|
253
|
+
...dataAttrs,
|
|
254
|
+
children: [
|
|
255
|
+
icon && /* @__PURE__ */ jsx4("div", { className: getClassName2("icon"), children: icon }),
|
|
256
|
+
children,
|
|
257
|
+
loading && /* @__PURE__ */ jsx4("div", { className: getClassName2("spinner"), children: /* @__PURE__ */ jsx4(Loader, { size: 14 }) })
|
|
258
|
+
]
|
|
259
|
+
}
|
|
260
|
+
);
|
|
261
|
+
return el;
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
// components/AutoField/index.tsx
|
|
265
|
+
import {
|
|
266
|
+
useCallback as useCallback4,
|
|
267
|
+
useEffect as useEffect6,
|
|
268
|
+
useMemo as useMemo5
|
|
269
|
+
} from "react";
|
|
270
|
+
|
|
271
|
+
// lib/use-safe-id.ts
|
|
272
|
+
import React2, { useState as useState3 } from "react";
|
|
273
|
+
var useSafeId = () => {
|
|
274
|
+
if (typeof React2.useId !== "undefined") {
|
|
275
|
+
return React2.useId();
|
|
276
|
+
}
|
|
277
|
+
const [id] = useState3(generateId());
|
|
278
|
+
return id;
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
// components/AutoField/AutoFieldInternal.tsx
|
|
282
|
+
import {
|
|
283
|
+
Suspense as Suspense2,
|
|
284
|
+
useCallback as useCallback3,
|
|
285
|
+
useContext as useContext4,
|
|
286
|
+
useMemo as useMemo4
|
|
287
|
+
} from "react";
|
|
288
|
+
import { useShallow as useShallow3 } from "zustand/react/shallow";
|
|
289
|
+
import { lazy as lazy2 } from "react";
|
|
290
|
+
|
|
291
|
+
// components/AutoField/lib/use-deep-field.ts
|
|
292
|
+
var useDeepField = (path) => {
|
|
293
|
+
return useFieldStore((s) => getDeep(s, path));
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
// components/AutoField/fields/RadioField/index.tsx
|
|
297
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
298
|
+
var getClassName3 = get_class_name_factory_default("Input", styles_module_default);
|
|
299
|
+
var RadioField = ({
|
|
300
|
+
field,
|
|
301
|
+
onChange,
|
|
302
|
+
readOnly,
|
|
303
|
+
id,
|
|
304
|
+
name = id,
|
|
305
|
+
label,
|
|
306
|
+
labelIcon,
|
|
307
|
+
Label
|
|
308
|
+
}) => {
|
|
309
|
+
const value = useDeepField(name);
|
|
310
|
+
if (field.type !== "radio" || !field.options) {
|
|
311
|
+
return null;
|
|
312
|
+
}
|
|
313
|
+
return /* @__PURE__ */ jsx5(
|
|
314
|
+
Label,
|
|
315
|
+
{
|
|
316
|
+
icon: labelIcon || /* @__PURE__ */ jsx5(CircleCheckBig, { size: 16 }),
|
|
317
|
+
label: label || name,
|
|
318
|
+
readOnly,
|
|
319
|
+
el: "div",
|
|
320
|
+
children: /* @__PURE__ */ jsx5("div", { className: getClassName3("radioGroupItems"), id, children: field.options.map((option) => /* @__PURE__ */ jsxs3(
|
|
321
|
+
"label",
|
|
322
|
+
{
|
|
323
|
+
className: getClassName3("radio"),
|
|
324
|
+
children: [
|
|
325
|
+
/* @__PURE__ */ jsx5(
|
|
326
|
+
"input",
|
|
327
|
+
{
|
|
328
|
+
type: "radio",
|
|
329
|
+
className: getClassName3("radioInput"),
|
|
330
|
+
value: JSON.stringify({ value: option.value }),
|
|
331
|
+
name,
|
|
332
|
+
onChange: (e) => {
|
|
333
|
+
onChange(JSON.parse(e.target.value).value);
|
|
334
|
+
},
|
|
335
|
+
disabled: readOnly,
|
|
336
|
+
checked: value === option.value
|
|
337
|
+
}
|
|
338
|
+
),
|
|
339
|
+
/* @__PURE__ */ jsx5("div", { className: getClassName3("radioInner"), children: option.label || option.value?.toString() })
|
|
340
|
+
]
|
|
341
|
+
},
|
|
342
|
+
option.label + option.value
|
|
343
|
+
)) })
|
|
344
|
+
}
|
|
345
|
+
);
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
// components/AutoField/fields/SelectField/index.tsx
|
|
349
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
350
|
+
var getClassName4 = get_class_name_factory_default("Input", styles_module_default);
|
|
351
|
+
var SelectField = ({
|
|
352
|
+
field,
|
|
353
|
+
onChange,
|
|
354
|
+
label,
|
|
355
|
+
labelIcon,
|
|
356
|
+
Label,
|
|
357
|
+
id,
|
|
358
|
+
name = id,
|
|
359
|
+
readOnly
|
|
360
|
+
}) => {
|
|
361
|
+
const value = useDeepField(name);
|
|
362
|
+
if (field.type !== "select" || !field.options) {
|
|
363
|
+
return null;
|
|
364
|
+
}
|
|
365
|
+
return /* @__PURE__ */ jsx6(
|
|
366
|
+
Label,
|
|
367
|
+
{
|
|
368
|
+
label: label || name,
|
|
369
|
+
icon: labelIcon || /* @__PURE__ */ jsx6(ChevronDown, { size: 16 }),
|
|
370
|
+
readOnly,
|
|
371
|
+
children: /* @__PURE__ */ jsx6(
|
|
372
|
+
"select",
|
|
373
|
+
{
|
|
374
|
+
id,
|
|
375
|
+
title: label || name,
|
|
376
|
+
className: getClassName4("input"),
|
|
377
|
+
disabled: readOnly,
|
|
378
|
+
onChange: (e) => {
|
|
379
|
+
onChange(JSON.parse(e.target.value).value);
|
|
380
|
+
},
|
|
381
|
+
value: JSON.stringify({ value }),
|
|
382
|
+
children: field.options.map((option) => /* @__PURE__ */ jsx6(
|
|
383
|
+
"option",
|
|
384
|
+
{
|
|
385
|
+
label: option.label,
|
|
386
|
+
value: JSON.stringify({ value: option.value })
|
|
387
|
+
},
|
|
388
|
+
option.label + JSON.stringify(option.value)
|
|
389
|
+
))
|
|
390
|
+
}
|
|
391
|
+
)
|
|
392
|
+
}
|
|
393
|
+
);
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
// components/AutoField/fields/ExternalField/index.tsx
|
|
397
|
+
import { useEffect as useEffect4 } from "react";
|
|
398
|
+
|
|
399
|
+
// components/ExternalInput/index.tsx
|
|
400
|
+
import {
|
|
401
|
+
useMemo as useMemo3,
|
|
402
|
+
useEffect as useEffect3,
|
|
403
|
+
useState as useState5,
|
|
404
|
+
useCallback,
|
|
405
|
+
isValidElement
|
|
406
|
+
} from "react";
|
|
407
|
+
|
|
408
|
+
// css-module:/home/crediblemark/Project/Credibuild/components/ExternalInput/styles.module.css#css-module
|
|
409
|
+
var styles_module_default2 = { "ExternalInput-actions": "_ExternalInput-actions_1gpb4_1", "ExternalInput-button": "_ExternalInput-button_1gpb4_5", "ExternalInput--dataSelected": "_ExternalInput--dataSelected_1gpb4_24", "ExternalInput--readOnly": "_ExternalInput--readOnly_1gpb4_31", "ExternalInput-detachButton": "_ExternalInput-detachButton_1gpb4_35", "ExternalInput": "_ExternalInput_1gpb4_1", "ExternalInputModal": "_ExternalInputModal_1gpb4_79", "ExternalInputModal-grid": "_ExternalInputModal-grid_1gpb4_89", "ExternalInputModal--filtersToggled": "_ExternalInputModal--filtersToggled_1gpb4_100", "ExternalInputModal-filters": "_ExternalInputModal-filters_1gpb4_105", "ExternalInputModal-masthead": "_ExternalInputModal-masthead_1gpb4_124", "ExternalInputModal-tableWrapper": "_ExternalInputModal-tableWrapper_1gpb4_133", "ExternalInputModal-table": "_ExternalInputModal-table_1gpb4_133", "ExternalInputModal-thead": "_ExternalInputModal-thead_1gpb4_149", "ExternalInputModal-th": "_ExternalInputModal-th_1gpb4_149", "ExternalInputModal-td": "_ExternalInputModal-td_1gpb4_164", "ExternalInputModal-tr": "_ExternalInputModal-tr_1gpb4_169", "ExternalInputModal-tbody": "_ExternalInputModal-tbody_1gpb4_176", "ExternalInputModal--hasData": "_ExternalInputModal--hasData_1gpb4_202", "ExternalInputModal-loadingBanner": "_ExternalInputModal-loadingBanner_1gpb4_206", "ExternalInputModal--isLoading": "_ExternalInputModal--isLoading_1gpb4_223", "ExternalInputModal-searchForm": "_ExternalInputModal-searchForm_1gpb4_227", "ExternalInputModal-search": "_ExternalInputModal-search_1gpb4_227", "ExternalInputModal-searchIcon": "_ExternalInputModal-searchIcon_1gpb4_264", "ExternalInputModal-searchIconText": "_ExternalInputModal-searchIconText_1gpb4_289", "ExternalInputModal-searchInput": "_ExternalInputModal-searchInput_1gpb4_299", "ExternalInputModal-searchActions": "_ExternalInputModal-searchActions_1gpb4_313", "ExternalInputModal-searchActionIcon": "_ExternalInputModal-searchActionIcon_1gpb4_326", "ExternalInputModal-footerContainer": "_ExternalInputModal-footerContainer_1gpb4_330", "ExternalInputModal-footer": "_ExternalInputModal-footer_1gpb4_330", "ExternalInputModal-field": "_ExternalInputModal-field_1gpb4_343" };
|
|
410
|
+
|
|
411
|
+
// components/Modal/index.tsx
|
|
412
|
+
import { useEffect as useEffect2, useState as useState4 } from "react";
|
|
413
|
+
|
|
414
|
+
// css-module:/home/crediblemark/Project/Credibuild/components/Modal/styles.module.css#css-module
|
|
415
|
+
var styles_module_default3 = { "Modal": "_Modal_b422s_1", "Modal--isOpen": "_Modal--isOpen_b422s_15", "Modal-inner": "_Modal-inner_b422s_19" };
|
|
416
|
+
|
|
417
|
+
// components/Modal/index.tsx
|
|
418
|
+
import { createPortal } from "react-dom";
|
|
419
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
420
|
+
var getClassName5 = get_class_name_factory_default("Modal", styles_module_default3);
|
|
421
|
+
var Modal = ({
|
|
422
|
+
children,
|
|
423
|
+
onClose,
|
|
424
|
+
isOpen
|
|
425
|
+
}) => {
|
|
426
|
+
const [rootEl, setRootEl] = useState4(null);
|
|
427
|
+
useEffect2(() => {
|
|
428
|
+
setRootEl(document.getElementById("credbuild-portal-root"));
|
|
429
|
+
}, []);
|
|
430
|
+
if (!rootEl) {
|
|
431
|
+
return /* @__PURE__ */ jsx7("div", {});
|
|
432
|
+
}
|
|
433
|
+
return createPortal(
|
|
434
|
+
/* @__PURE__ */ jsx7("div", { className: getClassName5({ isOpen }), onClick: onClose, children: /* @__PURE__ */ jsx7(
|
|
435
|
+
"div",
|
|
436
|
+
{
|
|
437
|
+
className: getClassName5("inner"),
|
|
438
|
+
onClick: (e) => e.stopPropagation(),
|
|
439
|
+
children
|
|
440
|
+
}
|
|
441
|
+
) }),
|
|
442
|
+
rootEl
|
|
443
|
+
);
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
// css-module:/home/crediblemark/Project/Credibuild/components/Heading/styles.module.css#css-module
|
|
447
|
+
var styles_module_default4 = { "Heading": "_Heading_1tpsl_1", "Heading--xxxxl": "_Heading--xxxxl_1tpsl_12", "Heading--xxxl": "_Heading--xxxl_1tpsl_18", "Heading--xxl": "_Heading--xxl_1tpsl_22", "Heading--xl": "_Heading--xl_1tpsl_26", "Heading--l": "_Heading--l_1tpsl_30", "Heading--m": "_Heading--m_1tpsl_34", "Heading--s": "_Heading--s_1tpsl_38", "Heading--xs": "_Heading--xs_1tpsl_42" };
|
|
448
|
+
|
|
449
|
+
// components/Heading/index.tsx
|
|
450
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
451
|
+
var getClassName6 = get_class_name_factory_default("Heading", styles_module_default4);
|
|
452
|
+
var Heading = ({ children, rank, size = "m" }) => {
|
|
453
|
+
const Tag = rank ? `h${rank}` : "span";
|
|
454
|
+
return /* @__PURE__ */ jsx8(
|
|
455
|
+
Tag,
|
|
456
|
+
{
|
|
457
|
+
className: getClassName6({
|
|
458
|
+
[size]: true
|
|
459
|
+
}),
|
|
460
|
+
children
|
|
461
|
+
}
|
|
462
|
+
);
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
// components/ExternalInput/index.tsx
|
|
466
|
+
import { Fragment as Fragment2, jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
467
|
+
var getClassName7 = get_class_name_factory_default("ExternalInput", styles_module_default2);
|
|
468
|
+
var getClassNameModal = get_class_name_factory_default("ExternalInputModal", styles_module_default2);
|
|
469
|
+
var dataCache = {};
|
|
470
|
+
var ExternalInput = ({
|
|
471
|
+
field,
|
|
472
|
+
onChange,
|
|
473
|
+
value = null,
|
|
474
|
+
name,
|
|
475
|
+
id,
|
|
476
|
+
readOnly
|
|
477
|
+
}) => {
|
|
478
|
+
const {
|
|
479
|
+
mapProp = (val) => val,
|
|
480
|
+
mapRow = (val) => val,
|
|
481
|
+
filterFields
|
|
482
|
+
} = field || {};
|
|
483
|
+
const { enabled: shouldCacheData } = field.cache ?? { enabled: true };
|
|
484
|
+
const [data, setData] = useState5([]);
|
|
485
|
+
const [isOpen, setOpen] = useState5(false);
|
|
486
|
+
const [isLoading, setIsLoading] = useState5(true);
|
|
487
|
+
const hasFilterFields = !!filterFields;
|
|
488
|
+
const [filters, setFilters] = useState5(field.initialFilters || {});
|
|
489
|
+
const [filtersToggled, setFiltersToggled] = useState5(hasFilterFields);
|
|
490
|
+
const mappedData = useMemo3(() => {
|
|
491
|
+
return data.map(mapRow);
|
|
492
|
+
}, [data, mapRow]);
|
|
493
|
+
const keys = useMemo3(() => {
|
|
494
|
+
const validKeys = /* @__PURE__ */ new Set();
|
|
495
|
+
for (const item of mappedData) {
|
|
496
|
+
for (const key of Object.keys(item)) {
|
|
497
|
+
if (typeof item[key] === "string" || typeof item[key] === "number" || isValidElement(item[key])) {
|
|
498
|
+
validKeys.add(key);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
return Array.from(validKeys);
|
|
503
|
+
}, [mappedData]);
|
|
504
|
+
const [searchQuery, setSearchQuery] = useState5(field.initialQuery || "");
|
|
505
|
+
const search = useCallback(
|
|
506
|
+
async (query, filters2) => {
|
|
507
|
+
setIsLoading(true);
|
|
508
|
+
const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
|
|
509
|
+
let listData;
|
|
510
|
+
if (shouldCacheData && dataCache[cacheKey]) {
|
|
511
|
+
listData = dataCache[cacheKey];
|
|
512
|
+
} else {
|
|
513
|
+
listData = await field.fetchList({ query, filters: filters2 });
|
|
514
|
+
}
|
|
515
|
+
if (listData) {
|
|
516
|
+
setData(listData);
|
|
517
|
+
setIsLoading(false);
|
|
518
|
+
if (shouldCacheData) {
|
|
519
|
+
dataCache[cacheKey] = listData;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
},
|
|
523
|
+
[id, field, shouldCacheData]
|
|
524
|
+
);
|
|
525
|
+
const Footer = useCallback(
|
|
526
|
+
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ jsxs4("span", { className: getClassNameModal("footer"), children: [
|
|
527
|
+
props.items.length,
|
|
528
|
+
" result",
|
|
529
|
+
props.items.length === 1 ? "" : "s"
|
|
530
|
+
] }),
|
|
531
|
+
[field]
|
|
532
|
+
);
|
|
533
|
+
useEffect3(() => {
|
|
534
|
+
search(searchQuery, filters);
|
|
535
|
+
}, [search, searchQuery, filters]);
|
|
536
|
+
return /* @__PURE__ */ jsxs4(
|
|
537
|
+
"div",
|
|
538
|
+
{
|
|
539
|
+
className: getClassName7({
|
|
540
|
+
dataSelected: !!value,
|
|
541
|
+
modalVisible: isOpen,
|
|
542
|
+
readOnly
|
|
543
|
+
}),
|
|
544
|
+
id,
|
|
545
|
+
children: [
|
|
546
|
+
/* @__PURE__ */ jsxs4("div", { className: getClassName7("actions"), children: [
|
|
547
|
+
/* @__PURE__ */ jsx9(
|
|
548
|
+
"button",
|
|
549
|
+
{
|
|
550
|
+
type: "button",
|
|
551
|
+
onClick: () => setOpen(true),
|
|
552
|
+
className: getClassName7("button"),
|
|
553
|
+
disabled: readOnly,
|
|
554
|
+
children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
555
|
+
/* @__PURE__ */ jsx9(Link, { size: "16" }),
|
|
556
|
+
/* @__PURE__ */ jsx9("span", { children: field.placeholder })
|
|
557
|
+
] })
|
|
558
|
+
}
|
|
559
|
+
),
|
|
560
|
+
value && /* @__PURE__ */ jsx9(
|
|
561
|
+
"button",
|
|
562
|
+
{
|
|
563
|
+
type: "button",
|
|
564
|
+
className: getClassName7("detachButton"),
|
|
565
|
+
onClick: () => {
|
|
566
|
+
onChange(null);
|
|
567
|
+
},
|
|
568
|
+
disabled: readOnly,
|
|
569
|
+
children: /* @__PURE__ */ jsx9(LockOpen, { size: 16 })
|
|
570
|
+
}
|
|
571
|
+
)
|
|
572
|
+
] }),
|
|
573
|
+
/* @__PURE__ */ jsx9(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ jsxs4(
|
|
574
|
+
"form",
|
|
575
|
+
{
|
|
576
|
+
className: getClassNameModal({
|
|
577
|
+
isLoading,
|
|
578
|
+
loaded: !isLoading,
|
|
579
|
+
hasData: mappedData.length > 0,
|
|
580
|
+
filtersToggled
|
|
581
|
+
}),
|
|
582
|
+
onSubmit: (e) => {
|
|
583
|
+
e.preventDefault();
|
|
584
|
+
e.stopPropagation();
|
|
585
|
+
search(searchQuery, filters);
|
|
586
|
+
},
|
|
587
|
+
children: [
|
|
588
|
+
/* @__PURE__ */ jsx9("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ jsxs4("div", { className: getClassNameModal("searchForm"), children: [
|
|
589
|
+
/* @__PURE__ */ jsxs4("label", { className: getClassNameModal("search"), children: [
|
|
590
|
+
/* @__PURE__ */ jsx9("span", { className: getClassNameModal("searchIconText"), children: "Search" }),
|
|
591
|
+
/* @__PURE__ */ jsx9("div", { className: getClassNameModal("searchIcon"), children: /* @__PURE__ */ jsx9(Search, { size: "18" }) }),
|
|
592
|
+
/* @__PURE__ */ jsx9(
|
|
593
|
+
"input",
|
|
594
|
+
{
|
|
595
|
+
className: getClassNameModal("searchInput"),
|
|
596
|
+
name: "q",
|
|
597
|
+
type: "search",
|
|
598
|
+
placeholder: field.placeholder,
|
|
599
|
+
onChange: (e) => {
|
|
600
|
+
setSearchQuery(e.currentTarget.value);
|
|
601
|
+
},
|
|
602
|
+
autoComplete: "off",
|
|
603
|
+
value: searchQuery
|
|
604
|
+
}
|
|
605
|
+
)
|
|
606
|
+
] }),
|
|
607
|
+
/* @__PURE__ */ jsxs4("div", { className: getClassNameModal("searchActions"), children: [
|
|
608
|
+
/* @__PURE__ */ jsx9(Button, { type: "submit", loading: isLoading, fullWidth: true, children: "Search" }),
|
|
609
|
+
hasFilterFields && /* @__PURE__ */ jsx9("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ jsx9(
|
|
610
|
+
IconButton,
|
|
611
|
+
{
|
|
612
|
+
type: "button",
|
|
613
|
+
title: "Toggle filters",
|
|
614
|
+
onClick: (e) => {
|
|
615
|
+
e.preventDefault();
|
|
616
|
+
e.stopPropagation();
|
|
617
|
+
setFiltersToggled(!filtersToggled);
|
|
618
|
+
},
|
|
619
|
+
children: /* @__PURE__ */ jsx9(SlidersHorizontal, { size: 20 })
|
|
620
|
+
}
|
|
621
|
+
) })
|
|
622
|
+
] })
|
|
623
|
+
] }) : /* @__PURE__ */ jsx9(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
|
|
624
|
+
/* @__PURE__ */ jsxs4("div", { className: getClassNameModal("grid"), children: [
|
|
625
|
+
hasFilterFields && /* @__PURE__ */ jsx9("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
|
|
626
|
+
const filterField = filterFields[fieldName];
|
|
627
|
+
return /* @__PURE__ */ jsx9(
|
|
628
|
+
"div",
|
|
629
|
+
{
|
|
630
|
+
className: getClassNameModal("field"),
|
|
631
|
+
children: /* @__PURE__ */ jsx9(FieldLabel, { label: filterField.label || fieldName, children: /* @__PURE__ */ jsx9(
|
|
632
|
+
AutoField,
|
|
633
|
+
{
|
|
634
|
+
field: filterField,
|
|
635
|
+
id: `external_field_${fieldName}_filter`,
|
|
636
|
+
value: filters[fieldName],
|
|
637
|
+
onChange: (value2) => {
|
|
638
|
+
setFilters((filters2) => {
|
|
639
|
+
const newFilters = {
|
|
640
|
+
...filters2,
|
|
641
|
+
[fieldName]: value2
|
|
642
|
+
};
|
|
643
|
+
search(searchQuery, newFilters);
|
|
644
|
+
return newFilters;
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
) })
|
|
649
|
+
},
|
|
650
|
+
fieldName
|
|
651
|
+
);
|
|
652
|
+
}) }),
|
|
653
|
+
/* @__PURE__ */ jsxs4("div", { className: getClassNameModal("tableWrapper"), children: [
|
|
654
|
+
/* @__PURE__ */ jsxs4("table", { className: getClassNameModal("table"), children: [
|
|
655
|
+
/* @__PURE__ */ jsx9("thead", { className: getClassNameModal("thead"), children: /* @__PURE__ */ jsx9("tr", { className: getClassNameModal("tr"), children: keys.map((key) => /* @__PURE__ */ jsx9(
|
|
656
|
+
"th",
|
|
657
|
+
{
|
|
658
|
+
className: getClassNameModal("th"),
|
|
659
|
+
style: { textAlign: "left" },
|
|
660
|
+
children: key
|
|
661
|
+
},
|
|
662
|
+
key
|
|
663
|
+
)) }) }),
|
|
664
|
+
/* @__PURE__ */ jsx9("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
|
|
665
|
+
return /* @__PURE__ */ jsx9(
|
|
666
|
+
"tr",
|
|
667
|
+
{
|
|
668
|
+
style: { whiteSpace: "nowrap" },
|
|
669
|
+
className: getClassNameModal("tr"),
|
|
670
|
+
onClick: () => {
|
|
671
|
+
onChange(mapProp(data[i]));
|
|
672
|
+
setOpen(false);
|
|
673
|
+
},
|
|
674
|
+
children: keys.map((key) => /* @__PURE__ */ jsx9("td", { className: getClassNameModal("td"), children: item[key] }, key))
|
|
675
|
+
},
|
|
676
|
+
i
|
|
677
|
+
);
|
|
678
|
+
}) })
|
|
679
|
+
] }),
|
|
680
|
+
/* @__PURE__ */ jsx9("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ jsx9(Loader, { size: 24 }) })
|
|
681
|
+
] })
|
|
682
|
+
] }),
|
|
683
|
+
/* @__PURE__ */ jsx9("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ jsx9(Footer, { items: mappedData }) })
|
|
684
|
+
]
|
|
685
|
+
}
|
|
686
|
+
) })
|
|
687
|
+
]
|
|
688
|
+
}
|
|
689
|
+
);
|
|
690
|
+
};
|
|
691
|
+
|
|
692
|
+
// components/AutoField/fields/ExternalField/index.tsx
|
|
693
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
694
|
+
var ExternalField = ({
|
|
695
|
+
field,
|
|
696
|
+
onChange,
|
|
697
|
+
id,
|
|
698
|
+
name = id,
|
|
699
|
+
label,
|
|
700
|
+
labelIcon,
|
|
701
|
+
Label,
|
|
702
|
+
readOnly
|
|
703
|
+
}) => {
|
|
704
|
+
const value = useDeepField(name);
|
|
705
|
+
const validField = field;
|
|
706
|
+
const deprecatedField = field;
|
|
707
|
+
useEffect4(() => {
|
|
708
|
+
if (deprecatedField.adaptor) {
|
|
709
|
+
console.error(
|
|
710
|
+
"Warning: The `adaptor` API is deprecated. Please use updated APIs on the `external` field instead. This will be a breaking change in a future release."
|
|
711
|
+
);
|
|
712
|
+
}
|
|
713
|
+
}, [deprecatedField.adaptor]);
|
|
714
|
+
if (field.type !== "external") {
|
|
715
|
+
return null;
|
|
716
|
+
}
|
|
717
|
+
return /* @__PURE__ */ jsx10(
|
|
718
|
+
Label,
|
|
719
|
+
{
|
|
720
|
+
label: label || name,
|
|
721
|
+
icon: labelIcon || /* @__PURE__ */ jsx10(Link, { size: 16 }),
|
|
722
|
+
el: "div",
|
|
723
|
+
children: /* @__PURE__ */ jsx10(
|
|
724
|
+
ExternalInput,
|
|
725
|
+
{
|
|
726
|
+
name,
|
|
727
|
+
field: {
|
|
728
|
+
...validField,
|
|
729
|
+
// DEPRECATED
|
|
730
|
+
placeholder: deprecatedField.adaptor?.name ? `Select from ${deprecatedField.adaptor.name}` : validField.placeholder || "Select data",
|
|
731
|
+
mapProp: deprecatedField.adaptor?.mapProp || validField.mapProp,
|
|
732
|
+
mapRow: validField.mapRow,
|
|
733
|
+
fetchList: deprecatedField.adaptor?.fetchList ? async () => await deprecatedField.adaptor.fetchList(
|
|
734
|
+
deprecatedField.adaptorParams
|
|
735
|
+
) : validField.fetchList
|
|
736
|
+
},
|
|
737
|
+
onChange,
|
|
738
|
+
value,
|
|
739
|
+
id,
|
|
740
|
+
readOnly
|
|
741
|
+
}
|
|
742
|
+
)
|
|
743
|
+
}
|
|
744
|
+
);
|
|
745
|
+
};
|
|
746
|
+
|
|
747
|
+
// components/AutoField/lib/use-local-value.ts
|
|
748
|
+
import { useCallback as useCallback2, useEffect as useEffect5, useState as useState6 } from "react";
|
|
749
|
+
|
|
750
|
+
// components/AutoField/lib/use-is-focused.ts
|
|
751
|
+
var useIsFocused = (path) => {
|
|
752
|
+
return useAppStore((s) => s.state.ui.field.focus === path);
|
|
753
|
+
};
|
|
754
|
+
|
|
755
|
+
// components/AutoField/lib/use-local-value.ts
|
|
756
|
+
var useLocalValue = (path, onChange) => {
|
|
757
|
+
const value = useDeepField(path);
|
|
758
|
+
const isFocused = useIsFocused(path);
|
|
759
|
+
const [localValue, setLocalValue] = useState6(value?.toString());
|
|
760
|
+
const onChangeLocal = useCallback2(
|
|
761
|
+
(val) => {
|
|
762
|
+
setLocalValue(val);
|
|
763
|
+
onChange(val);
|
|
764
|
+
},
|
|
765
|
+
[onChange]
|
|
766
|
+
);
|
|
767
|
+
useEffect5(() => {
|
|
768
|
+
if (!isFocused) {
|
|
769
|
+
setLocalValue(value);
|
|
770
|
+
}
|
|
771
|
+
}, [isFocused, value]);
|
|
772
|
+
return [localValue ?? "", onChangeLocal];
|
|
773
|
+
};
|
|
774
|
+
|
|
775
|
+
// components/AutoField/fields/DefaultField/index.tsx
|
|
776
|
+
import { Fragment as Fragment3, jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
777
|
+
var getClassName8 = get_class_name_factory_default("Input", styles_module_default);
|
|
778
|
+
var DefaultField = ({
|
|
779
|
+
field,
|
|
780
|
+
onChange,
|
|
781
|
+
readOnly,
|
|
782
|
+
id,
|
|
783
|
+
name = id,
|
|
784
|
+
label,
|
|
785
|
+
labelIcon,
|
|
786
|
+
Label
|
|
787
|
+
}) => {
|
|
788
|
+
const [localValue, onChangeLocal] = useLocalValue(name, onChange);
|
|
789
|
+
return /* @__PURE__ */ jsx11(
|
|
790
|
+
Label,
|
|
791
|
+
{
|
|
792
|
+
label: label || name,
|
|
793
|
+
icon: labelIcon || /* @__PURE__ */ jsxs5(Fragment3, { children: [
|
|
794
|
+
field.type === "text" && /* @__PURE__ */ jsx11(Type, { size: 16 }),
|
|
795
|
+
field.type === "number" && /* @__PURE__ */ jsx11(Hash, { size: 16 })
|
|
796
|
+
] }),
|
|
797
|
+
readOnly,
|
|
798
|
+
children: /* @__PURE__ */ jsx11(
|
|
799
|
+
"input",
|
|
800
|
+
{
|
|
801
|
+
className: getClassName8("input"),
|
|
802
|
+
autoComplete: "off",
|
|
803
|
+
type: field.type,
|
|
804
|
+
title: label || name,
|
|
805
|
+
name,
|
|
806
|
+
value: localValue,
|
|
807
|
+
onChange: (e) => {
|
|
808
|
+
if (field.type === "number") {
|
|
809
|
+
const numberValue = Number(e.currentTarget.value);
|
|
810
|
+
if (typeof field.min !== "undefined" && numberValue < field.min) {
|
|
811
|
+
return;
|
|
812
|
+
}
|
|
813
|
+
if (typeof field.max !== "undefined" && numberValue > field.max) {
|
|
814
|
+
return;
|
|
815
|
+
}
|
|
816
|
+
onChangeLocal(numberValue);
|
|
817
|
+
} else {
|
|
818
|
+
onChangeLocal(e.currentTarget.value);
|
|
819
|
+
}
|
|
820
|
+
},
|
|
821
|
+
readOnly,
|
|
822
|
+
tabIndex: readOnly ? -1 : void 0,
|
|
823
|
+
id,
|
|
824
|
+
min: field.type === "number" ? field.min : void 0,
|
|
825
|
+
max: field.type === "number" ? field.max : void 0,
|
|
826
|
+
placeholder: field.type === "text" || field.type === "number" ? field.placeholder : void 0,
|
|
827
|
+
step: field.type === "number" ? field.step : void 0
|
|
828
|
+
}
|
|
829
|
+
)
|
|
830
|
+
}
|
|
831
|
+
);
|
|
832
|
+
};
|
|
833
|
+
|
|
834
|
+
// components/AutoField/fields/TextareaField/index.tsx
|
|
835
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
836
|
+
var getClassName9 = get_class_name_factory_default("Input", styles_module_default);
|
|
837
|
+
var TextareaField = ({
|
|
838
|
+
field,
|
|
839
|
+
onChange,
|
|
840
|
+
readOnly,
|
|
841
|
+
id,
|
|
842
|
+
name = id,
|
|
843
|
+
label,
|
|
844
|
+
labelIcon,
|
|
845
|
+
Label
|
|
846
|
+
}) => {
|
|
847
|
+
const [localValue, onChangeLocal] = useLocalValue(name, onChange);
|
|
848
|
+
return /* @__PURE__ */ jsx12(
|
|
849
|
+
Label,
|
|
850
|
+
{
|
|
851
|
+
label: label || name,
|
|
852
|
+
icon: labelIcon || /* @__PURE__ */ jsx12(Type, { size: 16 }),
|
|
853
|
+
readOnly,
|
|
854
|
+
children: /* @__PURE__ */ jsx12(
|
|
855
|
+
"textarea",
|
|
856
|
+
{
|
|
857
|
+
id,
|
|
858
|
+
className: getClassName9("input"),
|
|
859
|
+
autoComplete: "off",
|
|
860
|
+
name,
|
|
861
|
+
value: typeof localValue === "undefined" ? "" : localValue,
|
|
862
|
+
onChange: (e) => onChangeLocal(e.currentTarget.value),
|
|
863
|
+
readOnly,
|
|
864
|
+
tabIndex: readOnly ? -1 : void 0,
|
|
865
|
+
rows: 5,
|
|
866
|
+
placeholder: field.type === "textarea" ? field.placeholder : void 0
|
|
867
|
+
}
|
|
868
|
+
)
|
|
869
|
+
}
|
|
870
|
+
);
|
|
871
|
+
};
|
|
872
|
+
|
|
873
|
+
// components/AutoField/fields/RichtextField/index.tsx
|
|
874
|
+
import { lazy, Suspense } from "react";
|
|
875
|
+
|
|
876
|
+
// components/RichTextEditor/components/EditorFallback.tsx
|
|
877
|
+
import { memo } from "react";
|
|
878
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
879
|
+
var EditorFallback = memo((props) => {
|
|
880
|
+
return /* @__PURE__ */ jsx13(
|
|
881
|
+
EditorInner,
|
|
882
|
+
{
|
|
883
|
+
...props,
|
|
884
|
+
editor: null,
|
|
885
|
+
menu: /* @__PURE__ */ jsx13(
|
|
886
|
+
LoadedRichTextMenuInner,
|
|
887
|
+
{
|
|
888
|
+
field: props.field,
|
|
889
|
+
editor: null,
|
|
890
|
+
editorState: null,
|
|
891
|
+
readOnly: props.readOnly ?? false
|
|
892
|
+
}
|
|
893
|
+
),
|
|
894
|
+
children: /* @__PURE__ */ jsx13(
|
|
895
|
+
"div",
|
|
896
|
+
{
|
|
897
|
+
className: "rich-text",
|
|
898
|
+
dangerouslySetInnerHTML: { __html: props.content },
|
|
899
|
+
contentEditable: true
|
|
900
|
+
}
|
|
901
|
+
)
|
|
902
|
+
}
|
|
903
|
+
);
|
|
904
|
+
});
|
|
905
|
+
EditorFallback.displayName = "EditorFallback";
|
|
906
|
+
|
|
907
|
+
// components/AutoField/fields/RichtextField/index.tsx
|
|
908
|
+
import { Fragment as Fragment4, jsx as jsx14 } from "react/jsx-runtime";
|
|
909
|
+
var Editor = lazy(
|
|
910
|
+
() => import("./Editor-L674TD7T.mjs").then((m) => ({
|
|
911
|
+
default: m.Editor
|
|
912
|
+
}))
|
|
913
|
+
);
|
|
914
|
+
var RichtextField = ({
|
|
915
|
+
onChange,
|
|
916
|
+
readOnly = false,
|
|
917
|
+
id,
|
|
918
|
+
name = id,
|
|
919
|
+
label,
|
|
920
|
+
labelIcon,
|
|
921
|
+
Label,
|
|
922
|
+
field
|
|
923
|
+
}) => {
|
|
924
|
+
const content = useDeepField(name);
|
|
925
|
+
const editorProps = {
|
|
926
|
+
onChange,
|
|
927
|
+
content,
|
|
928
|
+
readOnly,
|
|
929
|
+
field,
|
|
930
|
+
id,
|
|
931
|
+
name
|
|
932
|
+
};
|
|
933
|
+
return /* @__PURE__ */ jsx14(Fragment4, { children: /* @__PURE__ */ jsx14(
|
|
934
|
+
Label,
|
|
935
|
+
{
|
|
936
|
+
label: label || name,
|
|
937
|
+
icon: labelIcon || /* @__PURE__ */ jsx14(Type, { size: 16 }),
|
|
938
|
+
readOnly,
|
|
939
|
+
el: "div",
|
|
940
|
+
children: /* @__PURE__ */ jsx14(Suspense, { fallback: /* @__PURE__ */ jsx14(EditorFallback, { ...editorProps }), children: /* @__PURE__ */ jsx14(Editor, { ...editorProps }) })
|
|
941
|
+
}
|
|
942
|
+
) });
|
|
943
|
+
};
|
|
944
|
+
|
|
945
|
+
// components/AutoField/AutoFieldInternal.tsx
|
|
946
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
947
|
+
var ArrayField = lazy2(() => import("./ArrayField-EPM4TV3J.mjs").then((m) => ({ default: m.ArrayField })));
|
|
948
|
+
var ObjectField = lazy2(() => import("./ObjectField-MW3SSNKI.mjs").then((m) => ({ default: m.ObjectField })));
|
|
949
|
+
var getClassNameWrapper = get_class_name_factory_default("InputWrapper", styles_module_default);
|
|
950
|
+
var defaultFields = {
|
|
951
|
+
array: ArrayField,
|
|
952
|
+
external: ExternalField,
|
|
953
|
+
object: ObjectField,
|
|
954
|
+
select: SelectField,
|
|
955
|
+
textarea: TextareaField,
|
|
956
|
+
radio: RadioField,
|
|
957
|
+
text: DefaultField,
|
|
958
|
+
number: DefaultField,
|
|
959
|
+
richtext: RichtextField
|
|
960
|
+
};
|
|
961
|
+
function AutoFieldInternal(props) {
|
|
962
|
+
const dispatch = useAppStore((s) => s.dispatch);
|
|
963
|
+
const overrides = useAppStore((s) => s.overrides);
|
|
964
|
+
const readOnly = useAppStore(useShallow3((s) => s.selectedItem?.readOnly));
|
|
965
|
+
const nestedFieldContext = useContext4(NestedFieldContext);
|
|
966
|
+
const { id, Label = FieldLabelInternal } = props;
|
|
967
|
+
const field = props.field;
|
|
968
|
+
const label = field.label;
|
|
969
|
+
const labelIcon = field.labelIcon;
|
|
970
|
+
const defaultId = useSafeId();
|
|
971
|
+
const resolvedId = id || defaultId;
|
|
972
|
+
const render = useMemo4(
|
|
973
|
+
() => ({
|
|
974
|
+
...overrides.fieldTypes,
|
|
975
|
+
custom: overrides.fieldTypes?.custom,
|
|
976
|
+
array: overrides.fieldTypes?.array || defaultFields.array,
|
|
977
|
+
external: overrides.fieldTypes?.external || defaultFields.external,
|
|
978
|
+
object: overrides.fieldTypes?.object || defaultFields.object,
|
|
979
|
+
select: overrides.fieldTypes?.select || defaultFields.select,
|
|
980
|
+
textarea: overrides.fieldTypes?.textarea || defaultFields.textarea,
|
|
981
|
+
radio: overrides.fieldTypes?.radio || defaultFields.radio,
|
|
982
|
+
text: overrides.fieldTypes?.text || defaultFields.text,
|
|
983
|
+
number: overrides.fieldTypes?.number || defaultFields.number,
|
|
984
|
+
richtext: overrides.fieldTypes?.richtext || defaultFields.richtext
|
|
985
|
+
}),
|
|
986
|
+
[overrides]
|
|
987
|
+
);
|
|
988
|
+
const fieldValue = useFieldStore((s) => {
|
|
989
|
+
if (field.type === "custom" || overrides.fieldTypes?.[field.type]) {
|
|
990
|
+
return getDeep(s, props.name ?? resolvedId);
|
|
991
|
+
}
|
|
992
|
+
});
|
|
993
|
+
const mergedProps = useMemo4(
|
|
994
|
+
() => ({
|
|
995
|
+
...props,
|
|
996
|
+
field,
|
|
997
|
+
label,
|
|
998
|
+
labelIcon,
|
|
999
|
+
Label,
|
|
1000
|
+
id: resolvedId,
|
|
1001
|
+
value: fieldValue
|
|
1002
|
+
}),
|
|
1003
|
+
[props, field, label, labelIcon, Label, resolvedId, fieldValue]
|
|
1004
|
+
);
|
|
1005
|
+
const onFocus = useCallback3(
|
|
1006
|
+
(e) => {
|
|
1007
|
+
if (mergedProps.name && (e.target.nodeName === "INPUT" || e.target.nodeName === "TEXTAREA")) {
|
|
1008
|
+
e.stopPropagation();
|
|
1009
|
+
dispatch({
|
|
1010
|
+
type: "setUi",
|
|
1011
|
+
ui: {
|
|
1012
|
+
field: { focus: mergedProps.name }
|
|
1013
|
+
}
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
1016
|
+
},
|
|
1017
|
+
[dispatch, mergedProps.name]
|
|
1018
|
+
);
|
|
1019
|
+
const onBlur = useCallback3((e) => {
|
|
1020
|
+
if ("name" in e.target) {
|
|
1021
|
+
dispatch({
|
|
1022
|
+
type: "setUi",
|
|
1023
|
+
ui: {
|
|
1024
|
+
field: { focus: null }
|
|
1025
|
+
}
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
1028
|
+
}, [dispatch]);
|
|
1029
|
+
let Children = useMemo4(() => {
|
|
1030
|
+
if (field.type !== "custom" && field.type !== "slot") {
|
|
1031
|
+
return defaultFields[field.type];
|
|
1032
|
+
}
|
|
1033
|
+
return (_props) => null;
|
|
1034
|
+
}, [field.type]);
|
|
1035
|
+
const fieldKey = field.type === "custom" ? field.key : void 0;
|
|
1036
|
+
const fieldRender = field.render;
|
|
1037
|
+
let FieldComponent = useMemo4(() => {
|
|
1038
|
+
if (field.type === "custom" && !render[field.type]) {
|
|
1039
|
+
if (!fieldRender) {
|
|
1040
|
+
return null;
|
|
1041
|
+
}
|
|
1042
|
+
return fieldRender;
|
|
1043
|
+
} else if (field.type !== "slot") {
|
|
1044
|
+
return render[field.type];
|
|
1045
|
+
}
|
|
1046
|
+
}, [field.type, render, fieldRender]);
|
|
1047
|
+
const { visible = true } = props.field;
|
|
1048
|
+
if (!visible) {
|
|
1049
|
+
return null;
|
|
1050
|
+
}
|
|
1051
|
+
if (field.type === "slot") {
|
|
1052
|
+
return null;
|
|
1053
|
+
}
|
|
1054
|
+
if (!FieldComponent) {
|
|
1055
|
+
throw new Error(`Field type for ${field.type} did not exist.`);
|
|
1056
|
+
}
|
|
1057
|
+
return /* @__PURE__ */ jsx15(
|
|
1058
|
+
NestedFieldContext.Provider,
|
|
1059
|
+
{
|
|
1060
|
+
value: {
|
|
1061
|
+
readOnlyFields: nestedFieldContext.readOnlyFields || readOnly || {},
|
|
1062
|
+
localName: nestedFieldContext.localName ?? mergedProps.name
|
|
1063
|
+
},
|
|
1064
|
+
children: /* @__PURE__ */ jsx15(
|
|
1065
|
+
"div",
|
|
1066
|
+
{
|
|
1067
|
+
className: getClassNameWrapper(),
|
|
1068
|
+
onFocus,
|
|
1069
|
+
onBlur,
|
|
1070
|
+
onClick: (e) => {
|
|
1071
|
+
e.stopPropagation();
|
|
1072
|
+
},
|
|
1073
|
+
children: /* @__PURE__ */ jsx15(Suspense2, { fallback: null, children: /* @__PURE__ */ jsx15(FieldComponent, { ...mergedProps, children: /* @__PURE__ */ jsx15(Children, { ...mergedProps }) }) })
|
|
1074
|
+
}
|
|
1075
|
+
)
|
|
1076
|
+
}
|
|
1077
|
+
);
|
|
1078
|
+
}
|
|
1079
|
+
function AutoFieldPrivate2(props) {
|
|
1080
|
+
return /* @__PURE__ */ jsx15(AutoFieldInternal, { ...props });
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
// components/AutoField/index.tsx
|
|
1084
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
1085
|
+
var getClassName10 = get_class_name_factory_default("Input", styles_module_default);
|
|
1086
|
+
var getClassNameWrapper2 = get_class_name_factory_default("InputWrapper", styles_module_default);
|
|
1087
|
+
function AutoFieldPublicInternal({ value, ...props }) {
|
|
1088
|
+
const DefaultLabel = useMemo5(() => {
|
|
1089
|
+
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ jsx16(
|
|
1090
|
+
"div",
|
|
1091
|
+
{
|
|
1092
|
+
...labelProps,
|
|
1093
|
+
className: getClassName10({ readOnly: props.readOnly })
|
|
1094
|
+
}
|
|
1095
|
+
);
|
|
1096
|
+
return DefaultLabel2;
|
|
1097
|
+
}, [props.readOnly]);
|
|
1098
|
+
const fieldStore = useFieldStoreApi();
|
|
1099
|
+
const { id: propsId, onChange: propsOnChange } = props;
|
|
1100
|
+
const onChange = useCallback4(
|
|
1101
|
+
(value2) => {
|
|
1102
|
+
if (!propsId) return;
|
|
1103
|
+
fieldStore.setState({ [propsId]: value2 });
|
|
1104
|
+
propsOnChange(value2);
|
|
1105
|
+
},
|
|
1106
|
+
[fieldStore, propsOnChange, propsId]
|
|
1107
|
+
);
|
|
1108
|
+
useEffect6(() => {
|
|
1109
|
+
if (!props.id) return;
|
|
1110
|
+
fieldStore.setState({ [props.id]: value });
|
|
1111
|
+
}, [props.id, value, fieldStore]);
|
|
1112
|
+
return /* @__PURE__ */ jsx16(
|
|
1113
|
+
AutoFieldInternal,
|
|
1114
|
+
{
|
|
1115
|
+
...props,
|
|
1116
|
+
onChange,
|
|
1117
|
+
Label: DefaultLabel
|
|
1118
|
+
}
|
|
1119
|
+
);
|
|
1120
|
+
}
|
|
1121
|
+
function AutoField(props) {
|
|
1122
|
+
const id = useSafeId();
|
|
1123
|
+
if (props.field.type === "slot") {
|
|
1124
|
+
return null;
|
|
1125
|
+
}
|
|
1126
|
+
const providerValue = useMemo5(() => ({ [id]: props.value }), [id, props.value]);
|
|
1127
|
+
return /* @__PURE__ */ jsx16(fieldContextStore.Provider, { value: providerValue, children: /* @__PURE__ */ jsx16(AutoFieldPublicInternal, { ...props, id }) });
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
export {
|
|
1131
|
+
useSafeId,
|
|
1132
|
+
useContextStore,
|
|
1133
|
+
fieldContextStore,
|
|
1134
|
+
useFieldStoreApi,
|
|
1135
|
+
useFieldStore,
|
|
1136
|
+
FieldLabel,
|
|
1137
|
+
getDeep,
|
|
1138
|
+
useNestedFieldContext,
|
|
1139
|
+
NestedFieldProvider,
|
|
1140
|
+
Heading,
|
|
1141
|
+
Button,
|
|
1142
|
+
EditorFallback,
|
|
1143
|
+
AutoFieldPrivate2 as AutoFieldPrivate,
|
|
1144
|
+
AutoField
|
|
1145
|
+
};
|