@overmap-ai/core 1.0.34-image-preview.0 → 1.0.34-image-preview.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.
@@ -1,12 +1,9 @@
1
1
  /// <reference types="react" />
2
- import { FieldTypeIdentifier } from "../typings";
3
2
  interface FieldActionsProps {
4
3
  index: number;
5
4
  sectionIndex?: number;
6
- type: FieldTypeIdentifier;
7
5
  remove: () => void;
8
6
  duplicate: () => void;
9
- addAfter?: (type: FieldTypeIdentifier) => void;
10
7
  move: (direction: "up" | "down") => void;
11
8
  }
12
9
  export declare const FieldActions: import("react").MemoExoticComponent<(props: FieldActionsProps) => import("react/jsx-runtime").JSX.Element>;
@@ -8,7 +8,7 @@ var _a;
8
8
  import * as React from "react";
9
9
  import React__default, { useState, useEffect, useRef, memo, useMemo, forwardRef, createElement, useCallback, createContext, useContext, Children, isValidElement, cloneElement, Fragment, useLayoutEffect, useReducer } from "react";
10
10
  import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
11
- import { unsafeShowToast, AlertDialogProvider, ToastProvider, DefaultTheme, Flex, Text, useSeverityColor, Checkbox, TextArea, Select, useToast, IconButton, Badge, MultiSelect, Button, ButtonList, divButtonProps, Tooltip, DropdownItemMenu, DropdownMenu, DropdownMenuItemGroup, DropdownMenuSubMenuGroup, Popover, Input, useAlertDialog } from "@overmap-ai/blocks";
11
+ import { unsafeShowToast, AlertDialogProvider, ToastProvider, DefaultTheme, Flex, Text, useSeverityColor, Checkbox, TextArea, Select, useToast, IconButton, Badge, MultiSelect, Button, ButtonList, divButtonProps, Tooltip, DropdownItemMenu, Popover, Input, useAlertDialog } from "@overmap-ai/blocks";
12
12
  import { DepGraph } from "dependency-graph";
13
13
  import { offline as offline$1 } from "@redux-offline/redux-offline";
14
14
  import offlineConfig from "@redux-offline/redux-offline/lib/defaults";
@@ -10258,6 +10258,98 @@ const styles$1 = {
10258
10258
  typeBadge: typeBadge$1,
10259
10259
  addSectionButton
10260
10260
  };
10261
+ const forMobile = (mobile, display) => ({
10262
+ initial: mobile ? display : "none",
10263
+ sm: mobile ? "none" : display
10264
+ });
10265
+ const FieldActions = memo((props) => {
10266
+ const { index: index2, sectionIndex, remove: remove2, duplicate, move } = props;
10267
+ const { values } = useFormikContext();
10268
+ const actions = useMemo(() => {
10269
+ const actions2 = [
10270
+ {
10271
+ Icon: CopyIcon,
10272
+ key: "duplicate",
10273
+ text: "Duplicate",
10274
+ buttonProps: { onClick: duplicate }
10275
+ },
10276
+ {
10277
+ Icon: TrashIcon,
10278
+ buttonProps: { onClick: remove2 },
10279
+ key: "delete",
10280
+ text: "Delete"
10281
+ }
10282
+ ];
10283
+ if (sectionIndex === void 0 && index2 !== values.fields.length - 1 || sectionIndex !== void 0 && (sectionIndex < values.fields.length - 1 || index2 !== values.fields[sectionIndex].fields.length - 1)) {
10284
+ actions2.unshift({
10285
+ Icon: ArrowDownIcon,
10286
+ key: "moveDown",
10287
+ text: "Move down",
10288
+ buttonProps: {
10289
+ onClick: () => {
10290
+ move("down");
10291
+ }
10292
+ }
10293
+ });
10294
+ }
10295
+ if (sectionIndex === void 0 && index2 !== 0 || sectionIndex !== void 0 && (sectionIndex !== 0 || index2 !== 0)) {
10296
+ actions2.unshift({
10297
+ Icon: ArrowUpIcon,
10298
+ key: "moveUp",
10299
+ text: "Move up",
10300
+ buttonProps: {
10301
+ onClick: () => {
10302
+ move("up");
10303
+ }
10304
+ }
10305
+ });
10306
+ }
10307
+ return actions2;
10308
+ }, [duplicate, index2, move, remove2, sectionIndex, values.fields]);
10309
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
10310
+ /* @__PURE__ */ jsx(Flex, { display: forMobile(false, "flex"), direction: "column", gap: "4", children: actions.map((Action) => /* @__PURE__ */ jsx(
10311
+ IconButton,
10312
+ {
10313
+ type: "button",
10314
+ variant: "ghost",
10315
+ severity: Action.key.startsWith("move") ? "info" : "primary",
10316
+ "aria-label": Action.text,
10317
+ ...Action.buttonProps,
10318
+ children: /* @__PURE__ */ jsx(Action.Icon, {})
10319
+ },
10320
+ Action.key
10321
+ )) }),
10322
+ /* @__PURE__ */ jsx(Box, { display: forMobile(true, "block"), children: /* @__PURE__ */ jsx(
10323
+ DropdownItemMenu,
10324
+ {
10325
+ trigger: /* @__PURE__ */ jsx(IconButton, { variant: "ghost", "aria-label": "Actions menu", children: /* @__PURE__ */ jsx(DotsVerticalIcon, {}) }),
10326
+ items: actions.map((Action) => {
10327
+ var _a2;
10328
+ return {
10329
+ content: /* @__PURE__ */ jsxs(Flex, { gap: "2", align: "center", children: [
10330
+ /* @__PURE__ */ jsx(Action.Icon, {}),
10331
+ Action.text
10332
+ ] }, Action.key),
10333
+ onSelect: (_a2 = Action.buttonProps) == null ? void 0 : _a2.onClick
10334
+ };
10335
+ })
10336
+ }
10337
+ ) })
10338
+ ] });
10339
+ });
10340
+ FieldActions.displayName = "FieldActions";
10341
+ const popoverInputsContainer = "_popoverInputsContainer_ny0l1_1";
10342
+ const typeBadge = "_typeBadge_ny0l1_5";
10343
+ const previewInput = "_previewInput_ny0l1_10";
10344
+ const directInput = "_directInput_ny0l1_14";
10345
+ const grow = "_grow_ny0l1_18";
10346
+ const styles = {
10347
+ popoverInputsContainer,
10348
+ typeBadge,
10349
+ previewInput,
10350
+ directInput,
10351
+ grow
10352
+ };
10261
10353
  const formId = "form-builder";
10262
10354
  const fieldsToChoose = [
10263
10355
  ["string", "text"],
@@ -10288,147 +10380,6 @@ const useFieldTypeItems = (onSelect = () => null) => {
10288
10380
  });
10289
10381
  }, [onSelect]);
10290
10382
  };
10291
- const FieldTypeDropdown = memo((props) => {
10292
- const { setFieldType, children } = props;
10293
- const fieldTypeItems = useFieldTypeItems(setFieldType);
10294
- return /* @__PURE__ */ jsx(DropdownItemMenu, { trigger: children, items: fieldTypeItems.flat() });
10295
- });
10296
- FieldTypeDropdown.displayName = "FieldTypeDropdown";
10297
- const forMobile = (mobile, display) => ({
10298
- initial: mobile ? display : "none",
10299
- sm: mobile ? "none" : display
10300
- });
10301
- const FieldActions = memo((props) => {
10302
- const { index: index2, sectionIndex, type, remove: remove2, duplicate, addAfter, move } = props;
10303
- if (type !== "section" && !addAfter) {
10304
- throw new Error("addAfter is required for non-section fields");
10305
- }
10306
- const { values } = useFormikContext();
10307
- const fieldTypeItems = useFieldTypeItems(addAfter);
10308
- const [actions, mobileActions] = useMemo(() => {
10309
- const getActions = (isMobile) => {
10310
- const actions2 = [
10311
- {
10312
- Icon: TrashIcon,
10313
- buttonProps: { onClick: remove2 },
10314
- key: "delete",
10315
- text: "Delete"
10316
- },
10317
- {
10318
- Icon: CopyIcon,
10319
- key: "duplicate",
10320
- text: "Duplicate",
10321
- buttonProps: { onClick: duplicate }
10322
- }
10323
- ];
10324
- if (type !== "section") {
10325
- actions2.push({
10326
- // We want to show a dropdown with field types if "Add after" is clicked
10327
- isComponent: true,
10328
- Component: isMobile ? /* @__PURE__ */ jsx(DropdownMenuItemGroup, { items: fieldTypeItems.flat() }) : /* @__PURE__ */ jsx(FieldTypeDropdown, { setFieldType: addAfter, children: /* @__PURE__ */ jsx(IconButton, { type: "button", variant: "ghost", "aria-label": "Add after", children: /* @__PURE__ */ jsx(PlusIcon, {}) }) }),
10329
- Icon: PlusIcon,
10330
- key: "add",
10331
- text: "Add after"
10332
- });
10333
- }
10334
- if (sectionIndex === void 0 && index2 !== 0 || sectionIndex !== void 0 && (sectionIndex !== 0 || index2 !== 0)) {
10335
- actions2.push({
10336
- Icon: ArrowUpIcon,
10337
- key: "moveUp",
10338
- text: "Move up",
10339
- buttonProps: {
10340
- onClick: () => {
10341
- move("up");
10342
- }
10343
- }
10344
- });
10345
- }
10346
- if (sectionIndex === void 0 && index2 !== values.fields.length - 1 || sectionIndex !== void 0 && (sectionIndex < values.fields.length - 1 || index2 !== values.fields[sectionIndex].fields.length - 1)) {
10347
- actions2.push({
10348
- Icon: ArrowDownIcon,
10349
- key: "moveDown",
10350
- text: "Move down",
10351
- buttonProps: {
10352
- onClick: () => {
10353
- move("down");
10354
- }
10355
- }
10356
- });
10357
- }
10358
- return actions2;
10359
- };
10360
- return [getActions(false), getActions(true)];
10361
- }, [addAfter, duplicate, fieldTypeItems, index2, move, remove2, sectionIndex, type, values.fields]);
10362
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [
10363
- /* @__PURE__ */ jsx(Flex, { gap: "4", display: forMobile(false, "flex"), children: actions.map((Action) => {
10364
- if (Action.isComponent) {
10365
- return Action.Component;
10366
- }
10367
- return /* @__PURE__ */ jsx(
10368
- IconButton,
10369
- {
10370
- type: "button",
10371
- variant: "ghost",
10372
- severity: Action.key.startsWith("move") ? "info" : "primary",
10373
- "aria-label": Action.text,
10374
- ...Action.buttonProps,
10375
- children: /* @__PURE__ */ jsx(Action.Icon, {})
10376
- },
10377
- Action.key
10378
- );
10379
- }) }),
10380
- /* @__PURE__ */ jsx(Box, { display: forMobile(true, "block"), children: /* @__PURE__ */ jsxs(
10381
- DropdownMenu,
10382
- {
10383
- trigger: /* @__PURE__ */ jsx(IconButton, { variant: "ghost", "aria-label": "Actions menu", children: /* @__PURE__ */ jsx(DotsVerticalIcon, {}) }),
10384
- children: [
10385
- /* @__PURE__ */ jsx(
10386
- DropdownMenuItemGroup,
10387
- {
10388
- items: mobileActions.filter((Action) => !Action.isComponent).map((Action) => {
10389
- var _a2;
10390
- return {
10391
- content: /* @__PURE__ */ jsxs(Flex, { gap: "2", align: "center", children: [
10392
- /* @__PURE__ */ jsx(Action.Icon, {}),
10393
- Action.text
10394
- ] }, Action.key),
10395
- value: Action.key,
10396
- onSelect: (_a2 = Action.buttonProps) == null ? void 0 : _a2.onClick
10397
- };
10398
- })
10399
- }
10400
- ),
10401
- /* @__PURE__ */ jsx(
10402
- DropdownMenuSubMenuGroup,
10403
- {
10404
- items: mobileActions.filter((Action) => Action.isComponent).map((Action) => ({
10405
- content: /* @__PURE__ */ jsxs(Flex, { gap: "2", align: "center", children: [
10406
- /* @__PURE__ */ jsx(Action.Icon, {}),
10407
- Action.text
10408
- ] }, Action.key),
10409
- subContent: Action.Component,
10410
- triggerIndicator: null
10411
- }))
10412
- }
10413
- )
10414
- ]
10415
- }
10416
- ) })
10417
- ] });
10418
- });
10419
- FieldActions.displayName = "FieldActions";
10420
- const popoverInputsContainer = "_popoverInputsContainer_ny0l1_1";
10421
- const typeBadge = "_typeBadge_ny0l1_5";
10422
- const previewInput = "_previewInput_ny0l1_10";
10423
- const directInput = "_directInput_ny0l1_14";
10424
- const grow = "_grow_ny0l1_18";
10425
- const styles = {
10426
- popoverInputsContainer,
10427
- typeBadge,
10428
- previewInput,
10429
- directInput,
10430
- grow
10431
- };
10432
10383
  const FieldSettingsPopover = memo((props) => {
10433
10384
  const { popoverInputs, hasError } = props;
10434
10385
  return /* @__PURE__ */ jsx(
@@ -10671,21 +10622,6 @@ const FieldWithActions = memo((props) => {
10671
10622
  };
10672
10623
  createNewField(parentPath, index2 + 1, duplicatedField, values, setFieldValue);
10673
10624
  }, [field, takenLabels, parentPath, index2, values, setFieldValue]);
10674
- const createFieldAfter = useCallback(
10675
- (type) => {
10676
- if (type === "section") {
10677
- throw new Error("Section type unexpected");
10678
- }
10679
- createNewField(
10680
- parentPath,
10681
- index2 + 1,
10682
- FieldTypeToEmptyFieldMapping[type],
10683
- values,
10684
- setFieldValue
10685
- );
10686
- },
10687
- [parentPath, index2, values, setFieldValue]
10688
- );
10689
10625
  const moveField = useCallback(
10690
10626
  (direction) => {
10691
10627
  const srcSectionIndex = sectionIndex;
@@ -10731,10 +10667,8 @@ const FieldWithActions = memo((props) => {
10731
10667
  {
10732
10668
  index: index2,
10733
10669
  sectionIndex,
10734
- type: field.type,
10735
10670
  remove: remove2,
10736
10671
  duplicate: duplicateField,
10737
- addAfter: createFieldAfter,
10738
10672
  move: moveField
10739
10673
  }
10740
10674
  )
@@ -10743,6 +10677,12 @@ const FieldWithActions = memo((props) => {
10743
10677
  ) });
10744
10678
  });
10745
10679
  FieldWithActions.displayName = "FieldWithActions";
10680
+ const FieldTypeDropdown = memo((props) => {
10681
+ const { setFieldType, children } = props;
10682
+ const fieldTypeItems = useFieldTypeItems(setFieldType);
10683
+ return /* @__PURE__ */ jsx(DropdownItemMenu, { trigger: children, items: fieldTypeItems.flat() });
10684
+ });
10685
+ FieldTypeDropdown.displayName = "FieldTypeDropdown";
10746
10686
  const FieldSectionWithActions = memo((props) => {
10747
10687
  var _a2;
10748
10688
  const { field, index: sectionIndex, dropState } = props;
@@ -10931,7 +10871,6 @@ const FieldSectionWithActions = memo((props) => {
10931
10871
  FieldActions,
10932
10872
  {
10933
10873
  index: sectionIndex,
10934
- type: field.type,
10935
10874
  remove: removeSection,
10936
10875
  duplicate: duplicateSection,
10937
10876
  move: moveSection