@overmap-ai/core 1.0.38-component-fields.7 → 1.0.38-component-fields.9
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/dist/forms/builder/FieldSectionWithActions.d.ts +1 -0
- package/dist/forms/builder/FieldsEditor.d.ts +5 -1
- package/dist/forms/builder/FormBuilder.d.ts +10 -2
- package/dist/overmap-core.js +52 -11
- package/dist/overmap-core.js.map +1 -1
- package/dist/overmap-core.umd.cjs +52 -11
- package/dist/overmap-core.umd.cjs.map +1 -1
- package/dist/store/slices/userFormSlice.d.ts +1 -0
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ interface FieldSectionWithActionsProps {
|
|
|
5
5
|
field: SerializedFieldSection;
|
|
6
6
|
index: number;
|
|
7
7
|
dropState: DropState;
|
|
8
|
+
fieldsOnly: boolean;
|
|
8
9
|
}
|
|
9
10
|
export declare const FieldSectionWithActions: import("react").MemoExoticComponent<(props: FieldSectionWithActionsProps) => import("react/jsx-runtime").JSX.Element>;
|
|
10
11
|
export {};
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
2
|
+
interface FieldsEditorProps {
|
|
3
|
+
fieldsOnly: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare const FieldsEditor: import("react").MemoExoticComponent<(props: FieldsEditorProps) => import("react/jsx-runtime").JSX.Element>;
|
|
6
|
+
export {};
|
|
@@ -9,8 +9,16 @@ interface FormBuilderProps {
|
|
|
9
9
|
initialTitle?: string;
|
|
10
10
|
/** @default true */
|
|
11
11
|
showExplainerText?: boolean;
|
|
12
|
-
/** @default
|
|
13
|
-
|
|
12
|
+
/** @default true */
|
|
13
|
+
showFormTitle?: boolean;
|
|
14
|
+
/** Show and edit non-section fields only. Functionally, these fields will be in a single section with no label
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
fieldsOnly?: boolean;
|
|
18
|
+
/** Show the Edit and Preview tabs at the top of the component. If false, the preview is entirely inaccessible.
|
|
19
|
+
* @default true
|
|
20
|
+
*/
|
|
21
|
+
showTabs?: boolean;
|
|
14
22
|
}
|
|
15
23
|
export declare const FormBuilder: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<FormBuilderProps & import("react").RefAttributes<HTMLDivElement>>>;
|
|
16
24
|
export {};
|
package/dist/overmap-core.js
CHANGED
|
@@ -3269,6 +3269,28 @@ const selectLatestRevisionsForComponentTypeForms = restructureCreateSelectorWith
|
|
|
3269
3269
|
}
|
|
3270
3270
|
)
|
|
3271
3271
|
);
|
|
3272
|
+
const selectLatestRevisionsFromComponentTypeIds = restructureCreateSelectorWithArgs(
|
|
3273
|
+
createSelector(
|
|
3274
|
+
[
|
|
3275
|
+
selectUserFormMapping,
|
|
3276
|
+
selectRevisionMapping,
|
|
3277
|
+
(_state, componentTypeIds) => componentTypeIds
|
|
3278
|
+
],
|
|
3279
|
+
(userForms, revisions, componentTypeIds) => {
|
|
3280
|
+
const componentTypeIdsSet = new Set(componentTypeIds);
|
|
3281
|
+
const ret = {};
|
|
3282
|
+
for (const form of Object.values(userForms)) {
|
|
3283
|
+
if (form.component_type && componentTypeIdsSet.has(form.component_type)) {
|
|
3284
|
+
if (!ret[form.component_type]) {
|
|
3285
|
+
ret[form.component_type] = [];
|
|
3286
|
+
}
|
|
3287
|
+
ret[form.component_type].push(_selectLatestFormRevision(revisions, form.offline_id));
|
|
3288
|
+
}
|
|
3289
|
+
}
|
|
3290
|
+
return ret;
|
|
3291
|
+
}
|
|
3292
|
+
)
|
|
3293
|
+
);
|
|
3272
3294
|
const selectLatestRevisionByFormId = createSelector([selectRevisionMapping], (revisions) => {
|
|
3273
3295
|
const latestRevisions = {};
|
|
3274
3296
|
for (const revision of Object.values(revisions)) {
|
|
@@ -11215,7 +11237,7 @@ const FieldWithActions = memo((props) => {
|
|
|
11215
11237
|
FieldWithActions.displayName = "FieldWithActions";
|
|
11216
11238
|
const FieldSectionWithActions = memo((props) => {
|
|
11217
11239
|
var _a2;
|
|
11218
|
-
const { field, index: sectionIndex, dropState } = props;
|
|
11240
|
+
const { field, index: sectionIndex, dropState, fieldsOnly } = props;
|
|
11219
11241
|
const isDropDisabled = (_a2 = dropState[field.identifier]) == null ? void 0 : _a2.disabled;
|
|
11220
11242
|
const { setFieldValue, values } = useFormikContext();
|
|
11221
11243
|
const alertDialog = useAlertDialog();
|
|
@@ -11355,7 +11377,7 @@ const FieldSectionWithActions = memo((props) => {
|
|
|
11355
11377
|
mb: "4",
|
|
11356
11378
|
children: /* @__PURE__ */ jsxs(Flex, { gap: "3", justify: "between", align: "center", children: [
|
|
11357
11379
|
/* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "2", grow: "1", children: [
|
|
11358
|
-
/* @__PURE__ */ jsx(FieldBuilder, { ...editSectionProps }),
|
|
11380
|
+
!fieldsOnly && /* @__PURE__ */ jsx(FieldBuilder, { ...editSectionProps }),
|
|
11359
11381
|
/* @__PURE__ */ jsx(
|
|
11360
11382
|
Droppable,
|
|
11361
11383
|
{
|
|
@@ -11399,7 +11421,7 @@ const FieldSectionWithActions = memo((props) => {
|
|
|
11399
11421
|
}
|
|
11400
11422
|
)
|
|
11401
11423
|
] }),
|
|
11402
|
-
/* @__PURE__ */ jsx(
|
|
11424
|
+
!fieldsOnly && /* @__PURE__ */ jsx(
|
|
11403
11425
|
FieldActions,
|
|
11404
11426
|
{
|
|
11405
11427
|
index: sectionIndex,
|
|
@@ -11476,7 +11498,8 @@ const findSection = (fields, sectionId) => {
|
|
|
11476
11498
|
return [section, i];
|
|
11477
11499
|
}
|
|
11478
11500
|
};
|
|
11479
|
-
const FieldsEditor = memo(() => {
|
|
11501
|
+
const FieldsEditor = memo((props) => {
|
|
11502
|
+
const { fieldsOnly } = props;
|
|
11480
11503
|
const { values, setFieldValue } = useFormikContext();
|
|
11481
11504
|
const [dropState, dispatch] = useReducer(reducer, values.fields, initializer);
|
|
11482
11505
|
const { reorderSection, reorderField } = useFieldReordering();
|
|
@@ -11529,8 +11552,16 @@ const FieldsEditor = memo(() => {
|
|
|
11529
11552
|
gap: "0",
|
|
11530
11553
|
children: [
|
|
11531
11554
|
values.fields.map((field, index2) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
11532
|
-
/* @__PURE__ */ jsx(
|
|
11533
|
-
|
|
11555
|
+
/* @__PURE__ */ jsx(
|
|
11556
|
+
FieldSectionWithActions,
|
|
11557
|
+
{
|
|
11558
|
+
field,
|
|
11559
|
+
index: index2,
|
|
11560
|
+
dropState,
|
|
11561
|
+
fieldsOnly
|
|
11562
|
+
}
|
|
11563
|
+
),
|
|
11564
|
+
!fieldsOnly && /* @__PURE__ */ jsxs(
|
|
11534
11565
|
Button,
|
|
11535
11566
|
{
|
|
11536
11567
|
className: styles$1.addSectionButton,
|
|
@@ -11558,7 +11589,16 @@ const previewSubmit = () => {
|
|
|
11558
11589
|
};
|
|
11559
11590
|
const FormBuilder = memo(
|
|
11560
11591
|
forwardRef((props, ref) => {
|
|
11561
|
-
const {
|
|
11592
|
+
const {
|
|
11593
|
+
onCancel,
|
|
11594
|
+
onSave,
|
|
11595
|
+
revision,
|
|
11596
|
+
initialTitle,
|
|
11597
|
+
showExplainerText = true,
|
|
11598
|
+
showFormTitle = true,
|
|
11599
|
+
fieldsOnly = false,
|
|
11600
|
+
showTabs = true
|
|
11601
|
+
} = props;
|
|
11562
11602
|
const { showError } = useToast();
|
|
11563
11603
|
const validate = useCallback(
|
|
11564
11604
|
(form) => {
|
|
@@ -11621,7 +11661,7 @@ const FormBuilder = memo(
|
|
|
11621
11661
|
});
|
|
11622
11662
|
const previewSchema = useMemo(() => formRevisionToSchema(formik.values), [formik.values]);
|
|
11623
11663
|
return /* @__PURE__ */ jsx(Tabs.Root, { ref, defaultValue: "edit", children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "2", children: [
|
|
11624
|
-
/* @__PURE__ */ jsxs(Tabs.List, { className: styles$7.tabsList, children: [
|
|
11664
|
+
showTabs && /* @__PURE__ */ jsxs(Tabs.List, { className: styles$7.tabsList, children: [
|
|
11625
11665
|
/* @__PURE__ */ jsx(Tabs.Trigger, { className: styles$7.tabTrigger, value: "edit", children: /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "2", children: [
|
|
11626
11666
|
/* @__PURE__ */ jsx(Pencil1Icon, {}),
|
|
11627
11667
|
"Edit"
|
|
@@ -11642,7 +11682,7 @@ const FormBuilder = memo(
|
|
|
11642
11682
|
] }),
|
|
11643
11683
|
/* @__PURE__ */ jsx(Flex, { asChild: true, direction: "column", gap: "2", mt: "3", children: /* @__PURE__ */ jsxs("form", { id: formId, onSubmit: formik.handleSubmit, children: [
|
|
11644
11684
|
/* @__PURE__ */ jsxs(FormikProvider, { value: formik, children: [
|
|
11645
|
-
|
|
11685
|
+
showFormTitle && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
11646
11686
|
/* @__PURE__ */ jsx(
|
|
11647
11687
|
PatchField,
|
|
11648
11688
|
{
|
|
@@ -11688,7 +11728,7 @@ const FormBuilder = memo(
|
|
|
11688
11728
|
}
|
|
11689
11729
|
)
|
|
11690
11730
|
] }),
|
|
11691
|
-
/* @__PURE__ */ jsx(FieldsEditor, {}),
|
|
11731
|
+
/* @__PURE__ */ jsx(FieldsEditor, { fieldsOnly }),
|
|
11692
11732
|
/* @__PURE__ */ jsx(Text, { severity: "danger", size: "1", children: typeof formik.errors.fields === "string" && formik.errors.fields })
|
|
11693
11733
|
] }),
|
|
11694
11734
|
/* @__PURE__ */ jsxs(Flex, { className: styles$7.floatingButtonContainer, align: "center", justify: "end", gap: "2", children: [
|
|
@@ -11697,7 +11737,7 @@ const FormBuilder = memo(
|
|
|
11697
11737
|
] })
|
|
11698
11738
|
] }) })
|
|
11699
11739
|
] }),
|
|
11700
|
-
/* @__PURE__ */ jsx(Tabs.Content, { value: "preview", children: /* @__PURE__ */ jsx(FormRenderer, { schema: previewSchema, onSubmit: previewSubmit, hideTitle:
|
|
11740
|
+
/* @__PURE__ */ jsx(Tabs.Content, { value: "preview", children: /* @__PURE__ */ jsx(FormRenderer, { schema: previewSchema, onSubmit: previewSubmit, hideTitle: !showFormTitle }) })
|
|
11701
11741
|
] }) });
|
|
11702
11742
|
})
|
|
11703
11743
|
);
|
|
@@ -12063,6 +12103,7 @@ export {
|
|
|
12063
12103
|
selectLatestRetryTime,
|
|
12064
12104
|
selectLatestRevisionByFormId,
|
|
12065
12105
|
selectLatestRevisionsForComponentTypeForms,
|
|
12106
|
+
selectLatestRevisionsFromComponentTypeIds,
|
|
12066
12107
|
selectMainWorkspace,
|
|
12067
12108
|
selectMapStyle,
|
|
12068
12109
|
selectNumberOfComponentTypesMatchingCaseInsensitiveName,
|