@overmap-ai/core 1.0.51-bulk-form-submission.4 → 1.0.51-fix-document-urls.1

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.
@@ -5,8 +5,8 @@ var __publicField = (obj, key, value) => {
5
5
  return value;
6
6
  };
7
7
  (function(global2, factory) {
8
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react"), require("react/jsx-runtime"), require("@overmap-ai/blocks"), require("dependency-graph"), require("@redux-offline/redux-offline"), require("@redux-offline/redux-offline/lib/defaults"), require("localforage"), require("redux-persist-migrate"), require("@reduxjs/toolkit"), require("superagent"), require("react-redux"), require("file-saver"), require("uuid"), require("color"), require("jwt-decode"), require("@redux-offline/redux-offline/lib/constants"), require("idb"), require("formik"), require("lodash.get"), require("linkify-react"), require("@hello-pangea/dnd"), require("xlsx"), require("react-pdf"), require("react-pdf/dist/Page/AnnotationLayer.css"), require("react-pdf/dist/Page/TextLayer.css"), require("react-dom"), require("react-sketch-canvas"), require("lodash.set"), require("lodash.clonedeep")) : typeof define === "function" && define.amd ? define(["exports", "react", "react/jsx-runtime", "@overmap-ai/blocks", "dependency-graph", "@redux-offline/redux-offline", "@redux-offline/redux-offline/lib/defaults", "localforage", "redux-persist-migrate", "@reduxjs/toolkit", "superagent", "react-redux", "file-saver", "uuid", "color", "jwt-decode", "@redux-offline/redux-offline/lib/constants", "idb", "formik", "lodash.get", "linkify-react", "@hello-pangea/dnd", "xlsx", "react-pdf", "react-pdf/dist/Page/AnnotationLayer.css", "react-pdf/dist/Page/TextLayer.css", "react-dom", "react-sketch-canvas", "lodash.set", "lodash.clonedeep"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2["overmap-core"] = {}, global2.React, global2.jsxRuntime, global2.blocks, global2.dependencyGraph, global2.reduxOffline, global2.offlineConfig, global2.localforage, global2.createMigration, global2.toolkit, global2.request, global2.reactRedux, global2.saveAs, global2.uuid, global2.ColorCls, global2.jwtDecode, global2.constants, global2.idb, global2.formik, global2.get, global2.Linkify, global2.dnd, global2.xlsx, global2.reactPdf, null, null, global2.ReactDOM, global2.reactSketchCanvas, global2.set, global2.cloneDeep));
9
- })(this, function(exports2, React, jsxRuntime, blocks, dependencyGraph, reduxOffline, offlineConfig, localforage, createMigration, toolkit, request, reactRedux, saveAs, uuid, ColorCls, jwtDecode, constants, idb, formik, get, Linkify, dnd, xlsx, reactPdf, AnnotationLayer_css, TextLayer_css, ReactDOM, reactSketchCanvas, set, cloneDeep) {
8
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react"), require("react/jsx-runtime"), require("@overmap-ai/blocks"), require("dependency-graph"), require("@redux-offline/redux-offline"), require("@redux-offline/redux-offline/lib/defaults"), require("localforage"), require("redux-persist-migrate"), require("@reduxjs/toolkit"), require("superagent"), require("react-redux"), require("file-saver"), require("uuid"), require("color"), require("jwt-decode"), require("@redux-offline/redux-offline/lib/constants"), require("idb"), require("formik"), require("lodash.get"), require("linkify-react"), require("@hello-pangea/dnd"), require("qr-scanner"), require("xlsx"), require("react-pdf"), require("react-pdf/dist/Page/AnnotationLayer.css"), require("react-pdf/dist/Page/TextLayer.css"), require("react-dom"), require("react-sketch-canvas"), require("lodash.set"), require("lodash.clonedeep")) : typeof define === "function" && define.amd ? define(["exports", "react", "react/jsx-runtime", "@overmap-ai/blocks", "dependency-graph", "@redux-offline/redux-offline", "@redux-offline/redux-offline/lib/defaults", "localforage", "redux-persist-migrate", "@reduxjs/toolkit", "superagent", "react-redux", "file-saver", "uuid", "color", "jwt-decode", "@redux-offline/redux-offline/lib/constants", "idb", "formik", "lodash.get", "linkify-react", "@hello-pangea/dnd", "qr-scanner", "xlsx", "react-pdf", "react-pdf/dist/Page/AnnotationLayer.css", "react-pdf/dist/Page/TextLayer.css", "react-dom", "react-sketch-canvas", "lodash.set", "lodash.clonedeep"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2["overmap-core"] = {}, global2.React, global2.jsxRuntime, global2.blocks, global2.dependencyGraph, global2.reduxOffline, global2.offlineConfig, global2.localforage, global2.createMigration, global2.toolkit, global2.request, global2.reactRedux, global2.saveAs, global2.uuid, global2.ColorCls, global2.jwtDecode, global2.constants, global2.idb, global2.formik, global2.get, global2.Linkify, global2.dnd, global2.QrScannerAPI, global2.xlsx, global2.reactPdf, null, null, global2.ReactDOM, global2.reactSketchCanvas, global2.set, global2.cloneDeep));
9
+ })(this, function(exports2, React, jsxRuntime, blocks, dependencyGraph, reduxOffline, offlineConfig, localforage, createMigration, toolkit, request, reactRedux, saveAs, uuid, ColorCls, jwtDecode, constants, idb, formik, get, Linkify, dnd, QrScannerAPI, xlsx, reactPdf, AnnotationLayer_css, TextLayer_css, ReactDOM, reactSketchCanvas, set, cloneDeep) {
10
10
  var _a;
11
11
  "use strict";
12
12
  function _interopNamespaceDefault(e) {
@@ -4059,9 +4059,18 @@ var __publicField = (obj, key, value) => {
4059
4059
  }
4060
4060
  }
4061
4061
  for (const document2 of action.payload) {
4062
+ const existingDocument = state.documents[document2.offline_id];
4063
+ if (document2.organization !== void 0 && document2.organization !== existingDocument.organization) {
4064
+ throw new Error("organization cannot be updated");
4065
+ }
4066
+ if (document2.project !== void 0 && document2.project !== existingDocument.project) {
4067
+ throw new Error("project cannot be updated");
4068
+ }
4062
4069
  state.documents[document2.offline_id] = {
4063
- ...state.documents[document2.offline_id],
4070
+ ...existingDocument,
4064
4071
  ...document2
4072
+ // Without the cast, TypeScript doesn't realize that we have guaranteed that the document doesn't
4073
+ // have both a project and an organization.
4065
4074
  };
4066
4075
  }
4067
4076
  },
@@ -7988,17 +7997,28 @@ var __publicField = (obj, key, value) => {
7988
7997
  }
7989
7998
  }
7990
7999
  class DocumentService extends BaseApiService {
8000
+ // TODO: Support adding for project or organization
7991
8001
  add(document2) {
7992
8002
  const { store } = this.client;
7993
8003
  const currentUserId = store.getState().userReducer.currentUser.id;
7994
8004
  const activeProjectId = store.getState().projectReducer.activeProjectId;
7995
- const offlineDocument = offline({ ...document2, created_by: currentUserId });
7996
- store.dispatch(addDocuments([offlineDocument]));
8005
+ if (!activeProjectId) {
8006
+ throw new Error("No active project ID while creating document.");
8007
+ }
8008
+ const offlineDocument = offline(document2);
8009
+ const submittedDocument = {
8010
+ ...offlineDocument,
8011
+ created_by: currentUserId,
8012
+ project: activeProjectId,
8013
+ organization: null,
8014
+ children_documents: []
8015
+ };
8016
+ store.dispatch(addDocuments([submittedDocument]));
7997
8017
  const promise = this.enqueueRequest({
7998
8018
  description: "Create Document",
7999
8019
  method: HttpMethod.POST,
8000
- url: `/projects/${activeProjectId}/create-document/`,
8001
- payload: { ...offlineDocument },
8020
+ url: `/projects/${activeProjectId}/documents/`,
8021
+ payload: offlineDocument,
8002
8022
  queryParams: {
8003
8023
  parent_document: offlineDocument.parent_document ?? void 0
8004
8024
  },
@@ -8009,7 +8029,7 @@ var __publicField = (obj, key, value) => {
8009
8029
  promise.catch(() => {
8010
8030
  store.dispatch(removeDocuments([offlineDocument.offline_id]));
8011
8031
  });
8012
- return [offlineDocument, promise];
8032
+ return [submittedDocument, promise];
8013
8033
  }
8014
8034
  update(document2) {
8015
8035
  const { store } = this.client;
@@ -8109,15 +8129,25 @@ var __publicField = (obj, key, value) => {
8109
8129
  }
8110
8130
  async refreshStore() {
8111
8131
  const { store } = this.client;
8112
- const activeProjectId = store.getState().projectReducer.activeProjectId;
8113
- const result = await this.enqueueRequest({
8132
+ const state = store.getState();
8133
+ const activeProjectId = state.projectReducer.activeProjectId;
8134
+ const projectDocumentsPromise = this.enqueueRequest({
8114
8135
  description: "Get project documents",
8115
8136
  method: HttpMethod.GET,
8116
- url: `/documents/projects/${activeProjectId}/`,
8137
+ url: `/projects/${activeProjectId}/documents/`,
8138
+ blockers: [],
8139
+ blocks: []
8140
+ });
8141
+ const activeOrganizationId = state.organizationReducer.activeOrganizationId;
8142
+ const organizationDocumentsPromise = this.enqueueRequest({
8143
+ description: "Get organization documents",
8144
+ method: HttpMethod.GET,
8145
+ url: `/organizations/${activeOrganizationId}/documents/`,
8117
8146
  blockers: [],
8118
8147
  blocks: []
8119
8148
  });
8120
- store.dispatch(setDocuments(result));
8149
+ store.dispatch(setDocuments(await projectDocumentsPromise));
8150
+ store.dispatch(addDocuments(await organizationDocumentsPromise));
8121
8151
  }
8122
8152
  }
8123
8153
  class AgentService extends BaseApiService {
@@ -8222,7 +8252,7 @@ var __publicField = (obj, key, value) => {
8222
8252
  const patchfieldBorder = "_patchfieldBorder_1w0fq_73";
8223
8253
  const title = "_title_1w0fq_73";
8224
8254
  const error = "_error_1w0fq_89";
8225
- const styles$c = {
8255
+ const styles$d = {
8226
8256
  description: description$2,
8227
8257
  floatingButtonContainer: floatingButtonContainer$2,
8228
8258
  FullScreenImageContainer: FullScreenImageContainer$2,
@@ -8343,7 +8373,7 @@ var __publicField = (obj, key, value) => {
8343
8373
  const longIconButton$1 = "_longIconButton_10o76_36";
8344
8374
  const previewImage$1 = "_previewImage_10o76_42";
8345
8375
  const FullScreenImage$1 = "_FullScreenImage_10o76_12";
8346
- const styles$b = {
8376
+ const styles$c = {
8347
8377
  description: description$1,
8348
8378
  floatingButtonContainer: floatingButtonContainer$1,
8349
8379
  FullScreenImageContainer: FullScreenImageContainer$1,
@@ -8367,7 +8397,7 @@ var __publicField = (obj, key, value) => {
8367
8397
  /* @__PURE__ */ jsxRuntime.jsx(
8368
8398
  "button",
8369
8399
  {
8370
- className: styles$b.FullScreenImageContainer,
8400
+ className: styles$c.FullScreenImageContainer,
8371
8401
  type: "button",
8372
8402
  onClick: () => {
8373
8403
  setShowPreview(false);
@@ -8375,7 +8405,7 @@ var __publicField = (obj, key, value) => {
8375
8405
  children: /* @__PURE__ */ jsxRuntime.jsx(
8376
8406
  "img",
8377
8407
  {
8378
- className: styles$b.FullScreenImage,
8408
+ className: styles$c.FullScreenImage,
8379
8409
  src: url,
8380
8410
  alt: name,
8381
8411
  onClick: (e) => {
@@ -8385,11 +8415,11 @@ var __publicField = (obj, key, value) => {
8385
8415
  )
8386
8416
  }
8387
8417
  ),
8388
- /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { className: styles$b.TopBarContainer, align: "center", children: [
8418
+ /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { className: styles$c.TopBarContainer, align: "center", children: [
8389
8419
  /* @__PURE__ */ jsxRuntime.jsx(
8390
8420
  blocks.IconButton,
8391
8421
  {
8392
- className: styles$b.longIconButton,
8422
+ className: styles$c.longIconButton,
8393
8423
  variant: "soft",
8394
8424
  "aria-label": "Exit preview",
8395
8425
  onClick: () => {
@@ -8398,11 +8428,11 @@ var __publicField = (obj, key, value) => {
8398
8428
  children: /* @__PURE__ */ jsxRuntime.jsx(blocks.RiIcon, { icon: "RiArrowLeftLine" })
8399
8429
  }
8400
8430
  ),
8401
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$b.fileName, children: name }),
8431
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$c.fileName, children: name }),
8402
8432
  /* @__PURE__ */ jsxRuntime.jsx(
8403
8433
  blocks.IconButton,
8404
8434
  {
8405
- className: styles$b.longIconButton,
8435
+ className: styles$c.longIconButton,
8406
8436
  variant: "soft",
8407
8437
  "aria-label": `Download ${name}`,
8408
8438
  onClick: handleDownload,
@@ -8430,7 +8460,7 @@ var __publicField = (obj, key, value) => {
8430
8460
  /* @__PURE__ */ jsxRuntime.jsx(
8431
8461
  "img",
8432
8462
  {
8433
- className: styles$b.previewImage,
8463
+ className: styles$c.previewImage,
8434
8464
  src: resolvedImageURL,
8435
8465
  alt: resolvedImage.name,
8436
8466
  onClick: () => {
@@ -8458,7 +8488,7 @@ var __publicField = (obj, key, value) => {
8458
8488
  const { helpText, children, severity } = props;
8459
8489
  return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "1", children: [
8460
8490
  children,
8461
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Flex, { direction: "column", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "1", severity, className: styles$b.description, children: helpText }) })
8491
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Flex, { direction: "column", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "1", severity, className: styles$c.description, children: helpText }) })
8462
8492
  ] });
8463
8493
  };
8464
8494
  const InputWithLabelAndHelpText = (props) => {
@@ -8692,6 +8722,9 @@ var __publicField = (obj, key, value) => {
8692
8722
  function RiCalendarLine(props) {
8693
8723
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M9 1V3H15V1H17V3H21C21.5523 3 22 3.44772 22 4V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H7V1H9ZM20 11H4V19H20V11ZM7 5H4V9H20V5H17V7H15V5H9V7H7V5Z" }, "child": [] }] })(props);
8694
8724
  }
8725
+ function RiQrCodeLine(props) {
8726
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M16 17V16H13V13H16V15H18V17H17V19H15V21H13V18H15V17H16ZM21 21H17V19H19V17H21V21ZM3 3H11V11H3V3ZM5 5V9H9V5H5ZM13 3H21V11H13V3ZM15 5V9H19V5H15ZM3 13H11V21H3V13ZM5 15V19H9V15H5ZM18 13H21V15H18V13ZM6 6H8V8H6V6ZM6 16H8V18H6V16ZM16 6H18V8H16V6Z" }, "child": [] }] })(props);
8727
+ }
8695
8728
  function RiFileCopyLine(props) {
8696
8729
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M6.9998 6V3C6.9998 2.44772 7.44752 2 7.9998 2H19.9998C20.5521 2 20.9998 2.44772 20.9998 3V17C20.9998 17.5523 20.5521 18 19.9998 18H16.9998V20.9991C16.9998 21.5519 16.5499 22 15.993 22H4.00666C3.45059 22 3 21.5554 3 20.9991L3.0026 7.00087C3.0027 6.44811 3.45264 6 4.00942 6H6.9998ZM5.00242 8L5.00019 20H14.9998V8H5.00242ZM8.9998 6H16.9998V16H18.9998V4H8.9998V6Z" }, "child": [] }] })(props);
8697
8730
  }
@@ -9595,9 +9628,9 @@ var __publicField = (obj, key, value) => {
9595
9628
  return React__namespace.createElement("div", { ...insetProps, ref: forwardedRef, className: classNames("rt-Inset", className, withBreakpoints(side, "rt-r-side"), withBreakpoints(clip, "rt-r-clip"), withBreakpoints(p, "rt-r-p"), withBreakpoints(px, "rt-r-px"), withBreakpoints(py, "rt-r-py"), withBreakpoints(pt, "rt-r-pt"), withBreakpoints(pr, "rt-r-pr"), withBreakpoints(pb, "rt-r-pb"), withBreakpoints(pl, "rt-r-pl"), withMarginProps(marginProps)) });
9596
9629
  });
9597
9630
  Inset.displayName = "Inset";
9598
- const sizes$7 = ["1", "2", "3", "4", "5", "6", "7", "8", "9"];
9631
+ const sizes$8 = ["1", "2", "3", "4", "5", "6", "7", "8", "9"];
9599
9632
  const headingPropDefs = {
9600
- size: { type: "enum", values: sizes$7, default: "6", responsive: true },
9633
+ size: { type: "enum", values: sizes$8, default: "6", responsive: true },
9601
9634
  weight: { ...weightProp, default: "bold" },
9602
9635
  align: alignProp,
9603
9636
  trim: trimProp,
@@ -9610,9 +9643,9 @@ var __publicField = (obj, key, value) => {
9610
9643
  return React__namespace.createElement($5e63c961fc1ce211$export$8c6ed5c666ac1360, { "data-accent-color": color, ...headingProps, ref: forwardedRef, className: classNames("rt-Heading", className, withBreakpoints(size, "rt-r-size"), withBreakpoints(weight, "rt-r-weight"), withBreakpoints(align, "rt-r-ta"), withBreakpoints(trim, "rt-r-lt"), { "rt-high-contrast": highContrast }, withMarginProps(marginProps)) }, asChild ? children : React__namespace.createElement(Tag, null, children));
9611
9644
  });
9612
9645
  Heading.displayName = "Heading";
9613
- const sizes$6 = ["1", "2", "3", "4", "5", "6", "7", "8", "9"];
9646
+ const sizes$7 = ["1", "2", "3", "4", "5", "6", "7", "8", "9"];
9614
9647
  const textPropDefs = {
9615
- size: { type: "enum", values: sizes$6, default: void 0, responsive: true },
9648
+ size: { type: "enum", values: sizes$7, default: void 0, responsive: true },
9616
9649
  weight: weightProp,
9617
9650
  align: alignProp,
9618
9651
  trim: trimProp,
@@ -9625,6 +9658,21 @@ var __publicField = (obj, key, value) => {
9625
9658
  return React__namespace.createElement($5e63c961fc1ce211$export$8c6ed5c666ac1360, { "data-accent-color": color, ...textProps, ref: forwardedRef, className: classNames("rt-Text", className, withBreakpoints(size, "rt-r-size"), withBreakpoints(weight, "rt-r-weight"), withBreakpoints(align, "rt-r-ta"), withBreakpoints(trim, "rt-r-lt"), { "rt-high-contrast": highContrast }, withMarginProps(marginProps)) }, asChild ? children : React__namespace.createElement(Tag, null, children));
9626
9659
  });
9627
9660
  Text.displayName = "Text";
9661
+ const sizes$6 = ["1", "2", "3", "4", "5", "6", "7", "8", "9"];
9662
+ const variants$4 = ["solid", "soft", "outline", "ghost"];
9663
+ const codePropDefs = {
9664
+ size: { type: "enum", values: sizes$6, default: void 0, responsive: true },
9665
+ variant: { type: "enum", values: variants$4, default: "soft" },
9666
+ weight: weightProp,
9667
+ color: colorProp,
9668
+ highContrast: highContrastProp
9669
+ };
9670
+ const Code = React__namespace.forwardRef((props, forwardedRef) => {
9671
+ const { rest: marginRest, ...marginProps } = extractMarginProps(props);
9672
+ const { className, size = codePropDefs.size.default, variant = codePropDefs.variant.default, weight = codePropDefs.weight.default, color = codePropDefs.color.default, highContrast = codePropDefs.highContrast.default, ...codeProps } = marginRest;
9673
+ return React__namespace.createElement("code", { "data-accent-color": color, ...codeProps, ref: forwardedRef, className: classNames("rt-Code", className, withBreakpoints(size, "rt-r-size"), `rt-variant-${variant}`, withBreakpoints(weight, "rt-r-weight"), { "rt-high-contrast": highContrast }, withMarginProps(marginProps)) });
9674
+ });
9675
+ Code.displayName = "Code";
9628
9676
  const Em = React__namespace.forwardRef((props, forwardedRef) => React__namespace.createElement("em", { ...props, ref: forwardedRef, className: classNames("rt-Em", props.className) }));
9629
9677
  Em.displayName = "Em";
9630
9678
  const Strong = React__namespace.forwardRef((props, forwardedRef) => React__namespace.createElement("strong", { ...props, ref: forwardedRef, className: classNames("rt-Strong", props.className) }));
@@ -12015,7 +12063,7 @@ var __publicField = (obj, key, value) => {
12015
12063
  });
12016
12064
  const clickableLinkContainer = "_clickableLinkContainer_1ace7_1";
12017
12065
  const TextFieldInputCopy = "_TextFieldInputCopy_1ace7_5";
12018
- const styles$a = {
12066
+ const styles$b = {
12019
12067
  clickableLinkContainer,
12020
12068
  TextFieldInputCopy
12021
12069
  };
@@ -12044,13 +12092,13 @@ var __publicField = (obj, key, value) => {
12044
12092
  placeholder: field.placeholder,
12045
12093
  color
12046
12094
  }
12047
- ) : /* @__PURE__ */ jsxRuntime.jsxs(TextField$1.Root, { className: styles$a.clickableLinkContainer, children: [
12095
+ ) : /* @__PURE__ */ jsxRuntime.jsxs(TextField$1.Root, { className: styles$b.clickableLinkContainer, children: [
12048
12096
  /* @__PURE__ */ jsxRuntime.jsx(
12049
12097
  "div",
12050
12098
  {
12051
12099
  className: classNames$1(
12052
12100
  "rt-TextFieldInput rt-r-size-2 rt-variant-surface",
12053
- styles$a.TextFieldInputCopy
12101
+ styles$b.TextFieldInputCopy
12054
12102
  ),
12055
12103
  children: /* @__PURE__ */ jsxRuntime.jsx(
12056
12104
  Linkify,
@@ -12742,6 +12790,158 @@ var __publicField = (obj, key, value) => {
12742
12790
  __publicField(_MultiSelectField, "fieldTypeDescription", "Allows the user to select a multiple options from a list of options.");
12743
12791
  __publicField(_MultiSelectField, "Icon", RiCheckboxLine);
12744
12792
  let MultiSelectField = _MultiSelectField;
12793
+ const QrScannerWrapper = "_QrScannerWrapper_1puz3_1";
12794
+ const styles$a = {
12795
+ QrScannerWrapper
12796
+ };
12797
+ const QrInput = React.memo((props) => {
12798
+ const [{ inputId, labelId, label, helpText, size, severity, showInputOnly, field, fieldProps }, rest] = useFormikInput(props);
12799
+ const [showQrScanner, setShowQrScanner] = React.useState(false);
12800
+ const value = fieldProps.value;
12801
+ const handleQrScan = React.useCallback(
12802
+ (data) => {
12803
+ fieldProps.onChange({ target: { value: data } });
12804
+ setShowQrScanner(false);
12805
+ },
12806
+ [fieldProps]
12807
+ );
12808
+ const handleClearScanResult = React.useCallback(() => {
12809
+ fieldProps.onChange({ target: { value: "" } });
12810
+ }, [fieldProps]);
12811
+ const handleScanButtonClicked = React.useCallback(() => {
12812
+ setShowQrScanner(true);
12813
+ }, []);
12814
+ const handleQrScannerClose = React.useCallback(() => {
12815
+ setShowQrScanner(false);
12816
+ }, []);
12817
+ return /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText, severity, children: /* @__PURE__ */ jsxRuntime.jsxs(
12818
+ InputWithLabel,
12819
+ {
12820
+ size,
12821
+ severity,
12822
+ inputId,
12823
+ labelId,
12824
+ label: showInputOnly ? label : "",
12825
+ image: showInputOnly ? void 0 : field.image,
12826
+ flexProps: { direction: "column", justify: "start", align: "start", gap: "1" },
12827
+ children: [
12828
+ /* @__PURE__ */ jsxRuntime.jsx(
12829
+ blocks.Overlay,
12830
+ {
12831
+ open: showQrScanner,
12832
+ content: () => /* @__PURE__ */ jsxRuntime.jsx(QrScanner, { onQrScan: handleQrScan, onClose: handleQrScannerClose }),
12833
+ onOpenChange: setShowQrScanner
12834
+ }
12835
+ ),
12836
+ /* @__PURE__ */ jsxRuntime.jsxs(Flex, { width: "max-content", gap: "1", align: "center", children: [
12837
+ /* @__PURE__ */ jsxRuntime.jsxs(blocks.Button, { ...rest, variant: "soft", onClick: handleScanButtonClicked, children: [
12838
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.RiIcon, { icon: "RiQrCodeLine" }),
12839
+ "Scan"
12840
+ ] }),
12841
+ value && /* @__PURE__ */ jsxRuntime.jsx(Text, { color: "jade", size: "1", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.RiIcon, { icon: "RiCheckLine", style: { verticalAlign: "bottom" } }) })
12842
+ ] }),
12843
+ value && /* @__PURE__ */ jsxRuntime.jsx(Card, { children: /* @__PURE__ */ jsxRuntime.jsxs(Flex, { width: "max-content", gap: "2", align: "center", children: [
12844
+ /* @__PURE__ */ jsxRuntime.jsx(Code, { color: "gray", highContrast: true, children: value }),
12845
+ /* @__PURE__ */ jsxRuntime.jsx(
12846
+ blocks.IconButton,
12847
+ {
12848
+ severity: "info",
12849
+ variant: "ghost",
12850
+ "aria-label": "delete",
12851
+ size: "small",
12852
+ onClick: handleClearScanResult,
12853
+ children: /* @__PURE__ */ jsxRuntime.jsx(blocks.RiIcon, { icon: "RiCloseLine" })
12854
+ }
12855
+ )
12856
+ ] }) })
12857
+ ]
12858
+ }
12859
+ ) });
12860
+ });
12861
+ QrInput.displayName = "QrInput";
12862
+ const QrScanner = React.memo((props) => {
12863
+ const { onQrScan, onClose } = props;
12864
+ const videoRef = React.useRef(null);
12865
+ const [isScannerLoading, setIsScannerLoading] = React.useState(false);
12866
+ React.useEffect(() => {
12867
+ if (!videoRef.current)
12868
+ return;
12869
+ const qrScanner = new QrScannerAPI(
12870
+ videoRef.current,
12871
+ (result) => {
12872
+ const data = result.data;
12873
+ onQrScan(data);
12874
+ qrScanner.destroy();
12875
+ },
12876
+ {
12877
+ highlightCodeOutline: true,
12878
+ highlightScanRegion: true,
12879
+ maxScansPerSecond: 1
12880
+ }
12881
+ );
12882
+ setIsScannerLoading(true);
12883
+ qrScanner.start().then(() => {
12884
+ setIsScannerLoading(false);
12885
+ }).catch(() => {
12886
+ setIsScannerLoading(false);
12887
+ });
12888
+ }, [onQrScan]);
12889
+ return /* @__PURE__ */ jsxRuntime.jsxs(
12890
+ Flex,
12891
+ {
12892
+ className: styles$a.QrScannerWrapper,
12893
+ width: "100%",
12894
+ height: "100%",
12895
+ direction: "column",
12896
+ gap: "2",
12897
+ justify: "center",
12898
+ position: "relative",
12899
+ children: [
12900
+ /* @__PURE__ */ jsxRuntime.jsx(Flex, { width: "100%", position: "absolute", top: "0", p: "2", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { "aria-label": "close", variant: "soft", severity: "info", highContrast: true, onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.RiIcon, { icon: "RiCloseLine" }) }) }),
12901
+ /* @__PURE__ */ jsxRuntime.jsxs(Box, { style: { maxWidth: "100%", maxHeight: "100%" }, position: "relative", children: [
12902
+ /* @__PURE__ */ jsxRuntime.jsx("video", { ref: videoRef, style: { width: "100%", height: "100%" } }),
12903
+ isScannerLoading && /* @__PURE__ */ jsxRuntime.jsx(
12904
+ Flex,
12905
+ {
12906
+ position: "absolute",
12907
+ inset: "0",
12908
+ style: { background: "var(--color-background)" },
12909
+ justify: "center",
12910
+ align: "center",
12911
+ children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Spinner, {})
12912
+ }
12913
+ )
12914
+ ] })
12915
+ ]
12916
+ }
12917
+ );
12918
+ });
12919
+ QrScanner.displayName = "QrScanner";
12920
+ const emptyQrField = {
12921
+ ...emptyBaseField,
12922
+ type: "qr"
12923
+ };
12924
+ const _QrField = class _QrField extends BaseField {
12925
+ constructor(options) {
12926
+ super({ ...options, type: "qr" });
12927
+ __publicField(this, "onlyValidateAfterTouched", false);
12928
+ }
12929
+ serialize() {
12930
+ return super._serialize();
12931
+ }
12932
+ static deserialize(data) {
12933
+ if (data.type !== "qr")
12934
+ throw new Error("Type mismatch.");
12935
+ return new _QrField(data);
12936
+ }
12937
+ getInput(props) {
12938
+ return /* @__PURE__ */ jsxRuntime.jsx(QrInput, { ...props, field: this });
12939
+ }
12940
+ };
12941
+ __publicField(_QrField, "fieldTypeName", "QR");
12942
+ __publicField(_QrField, "fieldTypeDescription", "Used for scanning/reading QR codes.");
12943
+ __publicField(_QrField, "Icon", RiQrCodeLine);
12944
+ let QrField = _QrField;
12745
12945
  const FieldInputCloner = React.memo((props) => {
12746
12946
  const { field, ...rest } = props;
12747
12947
  const [{ value: identifier }] = formik.useField(field.options.clonedFieldIdentifier);
@@ -13999,6 +14199,7 @@ var __publicField = (obj, key, value) => {
13999
14199
  text: TextField,
14000
14200
  custom: CustomField,
14001
14201
  upload: UploadField,
14202
+ qr: QrField,
14002
14203
  // TODO: Underscore
14003
14204
  "multi-string": MultiStringField,
14004
14205
  "multi-select": MultiSelectField
@@ -14012,6 +14213,7 @@ var __publicField = (obj, key, value) => {
14012
14213
  text: emptyTextField,
14013
14214
  custom: emptyCustomField,
14014
14215
  upload: emptyUploadField,
14216
+ qr: emptyQrField,
14015
14217
  // TODO: Underscore
14016
14218
  "multi-string": emptyMultiStringField,
14017
14219
  "multi-select": emptyMultiSelectField
@@ -14099,7 +14301,7 @@ var __publicField = (obj, key, value) => {
14099
14301
  return /* @__PURE__ */ jsxRuntime.jsx(Card, { children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "3", children: [
14100
14302
  /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", children: [
14101
14303
  /* @__PURE__ */ jsxRuntime.jsx(Heading, { as: "h3", size: "3", children: label }),
14102
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$b.description, children: description2 })
14304
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$c.description, children: description2 })
14103
14305
  ] }),
14104
14306
  inputs
14105
14307
  ] }) });
@@ -14342,7 +14544,7 @@ var __publicField = (obj, key, value) => {
14342
14544
  [schema.title]
14343
14545
  );
14344
14546
  const Description = React.useMemo(
14345
- () => typeof schema.description === "string" ? /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$b.description, children: schema.description }) : schema.description,
14547
+ () => typeof schema.description === "string" ? /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$c.description, children: schema.description }) : schema.description,
14346
14548
  [schema.description]
14347
14549
  );
14348
14550
  const inputs = useFieldInputs(schema.fields, { formId: formId2, disabled: readonly });
@@ -14358,7 +14560,7 @@ var __publicField = (obj, key, value) => {
14358
14560
  !hideDescription && Description
14359
14561
  ] }) }),
14360
14562
  inputs,
14361
- !readonly && /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { className: styles$b.floatingButtonContainer, align: "center", justify: "end", gap: "2", children: [
14563
+ !readonly && /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { className: styles$c.floatingButtonContainer, align: "center", justify: "end", gap: "2", children: [
14362
14564
  cancelText && /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { severity: "info", ...buttonProps, type: "button", onClick: onCancel, children: cancelText }),
14363
14565
  /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { ...buttonProps, type: "submit", disabled: !formik$1.isValid, children: submitText })
14364
14566
  ] })
@@ -15706,12 +15908,12 @@ var __publicField = (obj, key, value) => {
15706
15908
  });
15707
15909
  const previewSchema = React.useMemo(() => formRevisionToSchema(formik$1.values), [formik$1.values]);
15708
15910
  return /* @__PURE__ */ jsxRuntime.jsx(Tabs.Root, { ref, defaultValue: "edit", children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "2", children: [
15709
- showTabs && /* @__PURE__ */ jsxRuntime.jsxs(Tabs.List, { className: classNames$1(styles$c.tabsList, tabsListClassName), children: [
15710
- /* @__PURE__ */ jsxRuntime.jsx(Tabs.Trigger, { className: styles$c.tabTrigger, value: "edit", children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { align: "center", gap: "2", children: [
15911
+ showTabs && /* @__PURE__ */ jsxRuntime.jsxs(Tabs.List, { className: classNames$1(styles$d.tabsList, tabsListClassName), children: [
15912
+ /* @__PURE__ */ jsxRuntime.jsx(Tabs.Trigger, { className: styles$d.tabTrigger, value: "edit", children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { align: "center", gap: "2", children: [
15711
15913
  /* @__PURE__ */ jsxRuntime.jsx(blocks.RiIcon, { icon: "RiPencilLine" }),
15712
15914
  "Edit"
15713
15915
  ] }) }),
15714
- /* @__PURE__ */ jsxRuntime.jsx(Tabs.Trigger, { className: styles$c.tabTrigger, value: "preview", children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { align: "center", gap: "2", children: [
15916
+ /* @__PURE__ */ jsxRuntime.jsx(Tabs.Trigger, { className: styles$d.tabTrigger, value: "preview", children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { align: "center", gap: "2", children: [
15715
15917
  /* @__PURE__ */ jsxRuntime.jsx(blocks.RiIcon, { icon: "RiEyeLine" }),
15716
15918
  "Preview"
15717
15919
  ] }) })
@@ -15735,8 +15937,8 @@ var __publicField = (obj, key, value) => {
15735
15937
  render: ({ setValue, value, meta }) => /* @__PURE__ */ jsxRuntime.jsx(InputWithHelpText, { severity: "danger", helpText: meta.error ?? null, children: /* @__PURE__ */ jsxRuntime.jsx(
15736
15938
  blocks.Input,
15737
15939
  {
15738
- className: classNames$1(styles$c.title, {
15739
- [styles$c.error]: meta.error
15940
+ className: classNames$1(styles$d.title, {
15941
+ [styles$d.error]: meta.error
15740
15942
  }),
15741
15943
  placeholder: "Form title",
15742
15944
  value,
@@ -15758,7 +15960,7 @@ var __publicField = (obj, key, value) => {
15758
15960
  render: ({ setValue, value }) => /* @__PURE__ */ jsxRuntime.jsx(
15759
15961
  blocks.TextArea,
15760
15962
  {
15761
- className: styles$c.description,
15963
+ className: styles$d.description,
15762
15964
  placeholder: "Explain the purpose of this form",
15763
15965
  value,
15764
15966
  onChange: (event) => {
@@ -15776,7 +15978,7 @@ var __publicField = (obj, key, value) => {
15776
15978
  /* @__PURE__ */ jsxRuntime.jsx(FieldsEditor, { fieldsOnly }),
15777
15979
  /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { severity: "danger", size: "1", children: typeof formik$1.errors.fields === "string" && formik$1.errors.fields })
15778
15980
  ] }),
15779
- /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { className: styles$c.floatingButtonContainer, align: "center", justify: "end", gap: "2", children: [
15981
+ /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { className: styles$d.floatingButtonContainer, align: "center", justify: "end", gap: "2", children: [
15780
15982
  onCancel && /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "button", variant: "solid", severity: "info", onClick: onCancel, children: "Cancel" }),
15781
15983
  /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "submit", children: "Save form" })
15782
15984
  ] })
@@ -15811,6 +16013,9 @@ var __publicField = (obj, key, value) => {
15811
16013
  NumberInput,
15812
16014
  PatchField,
15813
16015
  PatchFormProvider,
16016
+ QrField,
16017
+ QrInput,
16018
+ QrScanner,
15814
16019
  SelectField,
15815
16020
  SelectInput,
15816
16021
  StringField,
@@ -15825,6 +16030,7 @@ var __publicField = (obj, key, value) => {
15825
16030
  emptyMultiSelectField,
15826
16031
  emptyMultiStringField,
15827
16032
  emptyNumberField,
16033
+ emptyQrField,
15828
16034
  emptySelectField,
15829
16035
  emptyStringField,
15830
16036
  emptyTextField,
@@ -15914,6 +16120,9 @@ var __publicField = (obj, key, value) => {
15914
16120
  exports2.ProjectFileService = ProjectFileService;
15915
16121
  exports2.ProjectService = ProjectService;
15916
16122
  exports2.ProjectType = ProjectType;
16123
+ exports2.QrField = QrField;
16124
+ exports2.QrInput = QrInput;
16125
+ exports2.QrScanner = QrScanner;
15917
16126
  exports2.SDKContext = SDKContext;
15918
16127
  exports2.SDKProvider = SDKProvider;
15919
16128
  exports2.SUPPORTED_IMAGE_FILE_TYPES = SUPPORTED_IMAGE_FILE_TYPES;
@@ -16037,6 +16246,7 @@ var __publicField = (obj, key, value) => {
16037
16246
  exports2.emptyMultiSelectField = emptyMultiSelectField;
16038
16247
  exports2.emptyMultiStringField = emptyMultiStringField;
16039
16248
  exports2.emptyNumberField = emptyNumberField;
16249
+ exports2.emptyQrField = emptyQrField;
16040
16250
  exports2.emptySelectField = emptySelectField;
16041
16251
  exports2.emptyStringField = emptyStringField;
16042
16252
  exports2.emptyTextField = emptyTextField;