@overmap-ai/core 1.0.32 → 1.0.33-revamp-forms-builder.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/forms/builder/FieldActions.d.ts +8 -7
  2. package/dist/forms/builder/FieldBuilder.d.ts +5 -18
  3. package/dist/forms/builder/FieldSectionWithActions.d.ts +2 -2
  4. package/dist/forms/builder/FieldWithActions.d.ts +1 -1
  5. package/dist/forms/builder/FieldsEditor.d.ts +1 -1
  6. package/dist/forms/builder/FormBuilder.d.ts +1 -5
  7. package/dist/forms/builder/componentConstants.d.ts +8 -0
  8. package/dist/forms/builder/utils.d.ts +13 -1
  9. package/dist/forms/fields/BaseField/BaseField.d.ts +15 -5
  10. package/dist/forms/fields/BaseField/hooks.d.ts +2 -1
  11. package/dist/forms/fields/BaseField/layouts.d.ts +7 -2
  12. package/dist/forms/fields/BooleanField/BooleanField.d.ts +6 -0
  13. package/dist/forms/fields/CustomField/CustomField.d.ts +6 -0
  14. package/dist/forms/fields/DateField/DateField.d.ts +6 -0
  15. package/dist/forms/fields/FieldSection/FieldSection.d.ts +12 -6
  16. package/dist/forms/fields/MultiStringField/MultiStringField.d.ts +8 -0
  17. package/dist/forms/fields/NumberField/NumberField.d.ts +18 -3
  18. package/dist/forms/fields/SelectField/BaseSelectField.d.ts +4 -1
  19. package/dist/forms/fields/SelectField/MultiSelectField.d.ts +7 -0
  20. package/dist/forms/fields/SelectField/SelectField.d.ts +7 -0
  21. package/dist/forms/fields/StringOrTextFields/StringField/StringField.d.ts +8 -0
  22. package/dist/forms/fields/StringOrTextFields/StringOrTextField.d.ts +8 -5
  23. package/dist/forms/fields/StringOrTextFields/TextField/TextField.d.ts +7 -0
  24. package/dist/forms/fields/UploadField/UploadField.d.ts +16 -1
  25. package/dist/forms/fields/constants.d.ts +75 -0
  26. package/dist/forms/fields/typings.d.ts +4 -1
  27. package/dist/forms/fields/utils.d.ts +3 -1
  28. package/dist/forms/renderer/PatchForm/Field.d.ts +3 -1
  29. package/dist/forms/renderer/PatchForm/Provider.d.ts +2 -1
  30. package/dist/forms/utils.d.ts +2 -1
  31. package/dist/overmap-core.js +1395 -1028
  32. package/dist/overmap-core.js.map +1 -1
  33. package/dist/overmap-core.umd.cjs +1391 -1024
  34. package/dist/overmap-core.umd.cjs.map +1 -1
  35. package/dist/style.css +2 -0
  36. package/package.json +2 -2
  37. package/dist/forms/builder/constants.d.ts +0 -1
@@ -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("uuid"), require("color"), require("jwt-decode"), require("@redux-offline/redux-offline/lib/constants"), require("idb"), require("formik"), require("linkify-react"), require("@hello-pangea/dnd"), require("lodash.get"), require("lodash.set"), require("lodash.clonedeep"), require("react-dom")) : 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", "uuid", "color", "jwt-decode", "@redux-offline/redux-offline/lib/constants", "idb", "formik", "linkify-react", "@hello-pangea/dnd", "lodash.get", "lodash.set", "lodash.clonedeep", "react-dom"], 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.uuid, global2.ColorCls, global2.jwtDecode, global2.constants, global2.idb, global2.formik, global2.Linkify, global2.dnd, global2.get, global2.set, global2.cloneDeep, global2.ReactDOM));
9
- })(this, function(exports2, React, jsxRuntime, blocks, dependencyGraph, reduxOffline, offlineConfig, localforage, createMigration, toolkit, request, reactRedux, uuid, ColorCls, jwtDecode, constants, idb, formik, Linkify, dnd, get, set, cloneDeep, ReactDOM) {
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("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("lodash.set"), require("lodash.clonedeep"), require("react-dom")) : 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", "uuid", "color", "jwt-decode", "@redux-offline/redux-offline/lib/constants", "idb", "formik", "lodash.get", "linkify-react", "@hello-pangea/dnd", "lodash.set", "lodash.clonedeep", "react-dom"], 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.uuid, global2.ColorCls, global2.jwtDecode, global2.constants, global2.idb, global2.formik, global2.get, global2.Linkify, global2.dnd, global2.set, global2.cloneDeep, global2.ReactDOM));
9
+ })(this, function(exports2, React, jsxRuntime, blocks, dependencyGraph, reduxOffline, offlineConfig, localforage, createMigration, toolkit, request, reactRedux, uuid, ColorCls, jwtDecode, constants, idb, formik, get, Linkify, dnd, set, cloneDeep, ReactDOM) {
10
10
  var _a;
11
11
  "use strict";
12
12
  function _interopNamespaceDefault(e) {
@@ -372,7 +372,7 @@ var __publicField = (obj, key, value) => {
372
372
  Item.prototype.run = function() {
373
373
  this.fun.apply(null, this.array);
374
374
  };
375
- var title$1 = "browser";
375
+ var title = "browser";
376
376
  var platform = "browser";
377
377
  var browser = true;
378
378
  var env = {};
@@ -428,7 +428,7 @@ var __publicField = (obj, key, value) => {
428
428
  }
429
429
  var browser$1 = {
430
430
  nextTick,
431
- title: title$1,
431
+ title,
432
432
  browser,
433
433
  env,
434
434
  argv,
@@ -4391,7 +4391,7 @@ var __publicField = (obj, key, value) => {
4391
4391
  });
4392
4392
  return promise;
4393
4393
  }
4394
- async refreshStore(replace2) {
4394
+ async refreshStore(replace) {
4395
4395
  const { store } = this.client;
4396
4396
  const result = await this.enqueueRequest({
4397
4397
  description: "Get components",
@@ -4400,7 +4400,7 @@ var __publicField = (obj, key, value) => {
4400
4400
  blockers: [],
4401
4401
  blocks: []
4402
4402
  });
4403
- if (replace2) {
4403
+ if (replace) {
4404
4404
  store.dispatch(setComponents(result));
4405
4405
  } else {
4406
4406
  store.dispatch(addComponentsInBatches(result));
@@ -6113,6 +6113,11 @@ var __publicField = (obj, key, value) => {
6113
6113
  };
6114
6114
  }
6115
6115
  }
6116
+ const emptyBaseField = {
6117
+ label: "",
6118
+ required: false,
6119
+ description: ""
6120
+ };
6116
6121
  class BaseField extends BaseFormElement {
6117
6122
  constructor(options) {
6118
6123
  const { label, required, fieldValidators = [], formValidators = [], ...base } = options;
@@ -6177,25 +6182,29 @@ var __publicField = (obj, key, value) => {
6177
6182
  __publicField(BaseField, "fieldTypeName");
6178
6183
  __publicField(BaseField, "fieldTypeDescription");
6179
6184
  const description$1 = "_description_17zed_1";
6180
- const styles$4 = {
6185
+ const styles$5 = {
6181
6186
  description: description$1
6182
6187
  };
6183
6188
  const InputWithLabel = (props) => {
6184
- const { label, children, severity, inputId, labelId, flexProps } = props;
6189
+ const { label, children, size, severity, inputId, labelId, flexProps } = props;
6185
6190
  return /* @__PURE__ */ jsxRuntime.jsx(blocks.Flex, { direction: "column", gap: "1", asChild: true, ...flexProps, children: /* @__PURE__ */ jsxRuntime.jsxs("label", { htmlFor: inputId, children: [
6186
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { severity, id: labelId, children: label }),
6191
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size, severity, id: labelId, children: label }),
6187
6192
  children
6188
6193
  ] }) });
6189
6194
  };
6190
- const InputWithLabelAndHelpText = (props) => {
6195
+ const InputWithHelpText = (props) => {
6191
6196
  const { helpText, children, severity } = props;
6192
6197
  return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "1", children: [
6193
6198
  children,
6194
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Flex, { direction: "column", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "1", severity, className: styles$4.description, children: helpText }) })
6199
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Flex, { direction: "column", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "1", severity, className: styles$5.description, children: helpText }) })
6195
6200
  ] });
6196
6201
  };
6202
+ const InputWithLabelAndHelpText = (props) => {
6203
+ const { children, ...restProps } = props;
6204
+ return /* @__PURE__ */ jsxRuntime.jsx(InputWithHelpText, { ...restProps, children });
6205
+ };
6197
6206
  const useFormikInput = (props) => {
6198
- const { id, field, formId: formId2, ...rest } = props;
6207
+ const { id, field, formId: formId2, size, ...rest } = props;
6199
6208
  const [fieldProps, meta, helpers] = formik.useField(field.getId());
6200
6209
  const { touched } = meta;
6201
6210
  const helpText = meta.error ?? field.description;
@@ -6224,6 +6233,7 @@ var __publicField = (obj, key, value) => {
6224
6233
  return [
6225
6234
  {
6226
6235
  helpText,
6236
+ size,
6227
6237
  severity,
6228
6238
  inputId,
6229
6239
  labelId,
@@ -6237,12 +6247,13 @@ var __publicField = (obj, key, value) => {
6237
6247
  };
6238
6248
  const truthyValues = [true, "true"];
6239
6249
  const BooleanInput = React.memo(function BooleanInput2(props) {
6240
- const [{ inputId, labelId, severity, helpText, label, fieldProps }, rest] = useFormikInput(props);
6250
+ const [{ inputId, labelId, size, severity, helpText, label, fieldProps }, rest] = useFormikInput(props);
6241
6251
  const color = blocks.useSeverityColor(severity);
6242
6252
  const value = truthyValues.includes(fieldProps.value);
6243
6253
  return /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText, severity, children: /* @__PURE__ */ jsxRuntime.jsx(
6244
6254
  InputWithLabel,
6245
6255
  {
6256
+ size,
6246
6257
  severity,
6247
6258
  inputId,
6248
6259
  labelId,
@@ -6258,6 +6269,7 @@ var __publicField = (obj, key, value) => {
6258
6269
  value: value.toString(),
6259
6270
  checked: value,
6260
6271
  onCheckedChange: fieldProps.onChange,
6272
+ alwaysShow: true,
6261
6273
  onChange: void 0,
6262
6274
  onBlur: void 0
6263
6275
  }
@@ -6279,6 +6291,42 @@ var __publicField = (obj, key, value) => {
6279
6291
  }
6280
6292
  return target;
6281
6293
  }
6294
+ var _excluded$e = ["color"];
6295
+ var ArrowDownIcon = /* @__PURE__ */ React.forwardRef(function(_ref, forwardedRef) {
6296
+ var _ref$color = _ref.color, color = _ref$color === void 0 ? "currentColor" : _ref$color, props = _objectWithoutPropertiesLoose(_ref, _excluded$e);
6297
+ return React.createElement("svg", Object.assign({
6298
+ width: "15",
6299
+ height: "15",
6300
+ viewBox: "0 0 15 15",
6301
+ fill: "none",
6302
+ xmlns: "http://www.w3.org/2000/svg"
6303
+ }, props, {
6304
+ ref: forwardedRef
6305
+ }), React.createElement("path", {
6306
+ d: "M7.5 2C7.77614 2 8 2.22386 8 2.5L8 11.2929L11.1464 8.14645C11.3417 7.95118 11.6583 7.95118 11.8536 8.14645C12.0488 8.34171 12.0488 8.65829 11.8536 8.85355L7.85355 12.8536C7.75979 12.9473 7.63261 13 7.5 13C7.36739 13 7.24021 12.9473 7.14645 12.8536L3.14645 8.85355C2.95118 8.65829 2.95118 8.34171 3.14645 8.14645C3.34171 7.95118 3.65829 7.95118 3.85355 8.14645L7 11.2929L7 2.5C7 2.22386 7.22386 2 7.5 2Z",
6307
+ fill: color,
6308
+ fillRule: "evenodd",
6309
+ clipRule: "evenodd"
6310
+ }));
6311
+ });
6312
+ var _excluded$j = ["color"];
6313
+ var ArrowUpIcon = /* @__PURE__ */ React.forwardRef(function(_ref, forwardedRef) {
6314
+ var _ref$color = _ref.color, color = _ref$color === void 0 ? "currentColor" : _ref$color, props = _objectWithoutPropertiesLoose(_ref, _excluded$j);
6315
+ return React.createElement("svg", Object.assign({
6316
+ width: "15",
6317
+ height: "15",
6318
+ viewBox: "0 0 15 15",
6319
+ fill: "none",
6320
+ xmlns: "http://www.w3.org/2000/svg"
6321
+ }, props, {
6322
+ ref: forwardedRef
6323
+ }), React.createElement("path", {
6324
+ d: "M7.14645 2.14645C7.34171 1.95118 7.65829 1.95118 7.85355 2.14645L11.8536 6.14645C12.0488 6.34171 12.0488 6.65829 11.8536 6.85355C11.6583 7.04882 11.3417 7.04882 11.1464 6.85355L8 3.70711L8 12.5C8 12.7761 7.77614 13 7.5 13C7.22386 13 7 12.7761 7 12.5L7 3.70711L3.85355 6.85355C3.65829 7.04882 3.34171 7.04882 3.14645 6.85355C2.95118 6.65829 2.95118 6.34171 3.14645 6.14645L7.14645 2.14645Z",
6325
+ fill: color,
6326
+ fillRule: "evenodd",
6327
+ clipRule: "evenodd"
6328
+ }));
6329
+ });
6282
6330
  var _excluded$I = ["color"];
6283
6331
  var CalendarIcon = /* @__PURE__ */ React.forwardRef(function(_ref, forwardedRef) {
6284
6332
  var _ref$color = _ref.color, color = _ref$color === void 0 ? "currentColor" : _ref$color, props = _objectWithoutPropertiesLoose(_ref, _excluded$I);
@@ -6387,24 +6435,6 @@ var __publicField = (obj, key, value) => {
6387
6435
  clipRule: "evenodd"
6388
6436
  }));
6389
6437
  });
6390
- var _excluded$1R = ["color"];
6391
- var DragHandleDots2Icon = /* @__PURE__ */ React.forwardRef(function(_ref, forwardedRef) {
6392
- var _ref$color = _ref.color, color = _ref$color === void 0 ? "currentColor" : _ref$color, props = _objectWithoutPropertiesLoose(_ref, _excluded$1R);
6393
- return React.createElement("svg", Object.assign({
6394
- width: "15",
6395
- height: "15",
6396
- viewBox: "0 0 15 15",
6397
- fill: "none",
6398
- xmlns: "http://www.w3.org/2000/svg"
6399
- }, props, {
6400
- ref: forwardedRef
6401
- }), React.createElement("path", {
6402
- d: "M5.5 4.625C6.12132 4.625 6.625 4.12132 6.625 3.5C6.625 2.87868 6.12132 2.375 5.5 2.375C4.87868 2.375 4.375 2.87868 4.375 3.5C4.375 4.12132 4.87868 4.625 5.5 4.625ZM9.5 4.625C10.1213 4.625 10.625 4.12132 10.625 3.5C10.625 2.87868 10.1213 2.375 9.5 2.375C8.87868 2.375 8.375 2.87868 8.375 3.5C8.375 4.12132 8.87868 4.625 9.5 4.625ZM10.625 7.5C10.625 8.12132 10.1213 8.625 9.5 8.625C8.87868 8.625 8.375 8.12132 8.375 7.5C8.375 6.87868 8.87868 6.375 9.5 6.375C10.1213 6.375 10.625 6.87868 10.625 7.5ZM5.5 8.625C6.12132 8.625 6.625 8.12132 6.625 7.5C6.625 6.87868 6.12132 6.375 5.5 6.375C4.87868 6.375 4.375 6.87868 4.375 7.5C4.375 8.12132 4.87868 8.625 5.5 8.625ZM10.625 11.5C10.625 12.1213 10.1213 12.625 9.5 12.625C8.87868 12.625 8.375 12.1213 8.375 11.5C8.375 10.8787 8.87868 10.375 9.5 10.375C10.1213 10.375 10.625 10.8787 10.625 11.5ZM5.5 12.625C6.12132 12.625 6.625 12.1213 6.625 11.5C6.625 10.8787 6.12132 10.375 5.5 10.375C4.87868 10.375 4.375 10.8787 4.375 11.5C4.375 12.1213 4.87868 12.625 5.5 12.625Z",
6403
- fill: color,
6404
- fillRule: "evenodd",
6405
- clipRule: "evenodd"
6406
- }));
6407
- });
6408
6438
  var _excluded$1W = ["color"];
6409
6439
  var DropdownMenuIcon = /* @__PURE__ */ React.forwardRef(function(_ref, forwardedRef) {
6410
6440
  var _ref$color = _ref.color, color = _ref$color === void 0 ? "currentColor" : _ref$color, props = _objectWithoutPropertiesLoose(_ref, _excluded$1W);
@@ -6439,9 +6469,9 @@ var __publicField = (obj, key, value) => {
6439
6469
  fill: color
6440
6470
  }));
6441
6471
  });
6442
- var _excluded$2E = ["color"];
6443
- var InputIcon = /* @__PURE__ */ React.forwardRef(function(_ref, forwardedRef) {
6444
- var _ref$color = _ref.color, color = _ref$color === void 0 ? "currentColor" : _ref$color, props = _objectWithoutPropertiesLoose(_ref, _excluded$2E);
6472
+ var _excluded$2l = ["color"];
6473
+ var GearIcon = /* @__PURE__ */ React.forwardRef(function(_ref, forwardedRef) {
6474
+ var _ref$color = _ref.color, color = _ref$color === void 0 ? "currentColor" : _ref$color, props = _objectWithoutPropertiesLoose(_ref, _excluded$2l);
6445
6475
  return React.createElement("svg", Object.assign({
6446
6476
  width: "15",
6447
6477
  height: "15",
@@ -6451,15 +6481,15 @@ var __publicField = (obj, key, value) => {
6451
6481
  }, props, {
6452
6482
  ref: forwardedRef
6453
6483
  }), React.createElement("path", {
6454
- d: "M6.5 1C6.22386 1 6 1.22386 6 1.5C6 1.77614 6.22386 2 6.5 2C7.12671 2 7.45718 2.20028 7.65563 2.47812C7.8781 2.78957 8 3.28837 8 4V11C8 11.7116 7.8781 12.2104 7.65563 12.5219C7.45718 12.7997 7.12671 13 6.5 13C6.22386 13 6 13.2239 6 13.5C6 13.7761 6.22386 14 6.5 14C7.37329 14 8.04282 13.7003 8.46937 13.1031C8.47976 13.0886 8.48997 13.0739 8.5 13.0591C8.51003 13.0739 8.52024 13.0886 8.53063 13.1031C8.95718 13.7003 9.62671 14 10.5 14C10.7761 14 11 13.7761 11 13.5C11 13.2239 10.7761 13 10.5 13C9.87329 13 9.54282 12.7997 9.34437 12.5219C9.1219 12.2104 9 11.7116 9 11V4C9 3.28837 9.1219 2.78957 9.34437 2.47812C9.54282 2.20028 9.87329 2 10.5 2C10.7761 2 11 1.77614 11 1.5C11 1.22386 10.7761 1 10.5 1C9.62671 1 8.95718 1.29972 8.53063 1.89688C8.52024 1.91143 8.51003 1.92611 8.5 1.9409C8.48997 1.92611 8.47976 1.91143 8.46937 1.89688C8.04282 1.29972 7.37329 1 6.5 1ZM14 5H11V4H14C14.5523 4 15 4.44772 15 5V10C15 10.5523 14.5523 11 14 11H11V10H14V5ZM6 4V5H1L1 10H6V11H1C0.447715 11 0 10.5523 0 10V5C0 4.44772 0.447715 4 1 4H6Z",
6484
+ d: "M7.07095 0.650238C6.67391 0.650238 6.32977 0.925096 6.24198 1.31231L6.0039 2.36247C5.6249 2.47269 5.26335 2.62363 4.92436 2.81013L4.01335 2.23585C3.67748 2.02413 3.23978 2.07312 2.95903 2.35386L2.35294 2.95996C2.0722 3.2407 2.0232 3.6784 2.23493 4.01427L2.80942 4.92561C2.62307 5.2645 2.47227 5.62594 2.36216 6.00481L1.31209 6.24287C0.924883 6.33065 0.650024 6.6748 0.650024 7.07183V7.92897C0.650024 8.32601 0.924883 8.67015 1.31209 8.75794L2.36228 8.99603C2.47246 9.375 2.62335 9.73652 2.80979 10.0755L2.2354 10.9867C2.02367 11.3225 2.07267 11.7602 2.35341 12.041L2.95951 12.6471C3.24025 12.9278 3.67795 12.9768 4.01382 12.7651L4.92506 12.1907C5.26384 12.377 5.62516 12.5278 6.0039 12.6379L6.24198 13.6881C6.32977 14.0753 6.67391 14.3502 7.07095 14.3502H7.92809C8.32512 14.3502 8.66927 14.0753 8.75705 13.6881L8.99505 12.6383C9.37411 12.5282 9.73573 12.3773 10.0748 12.1909L10.986 12.7653C11.3218 12.977 11.7595 12.928 12.0403 12.6473L12.6464 12.0412C12.9271 11.7604 12.9761 11.3227 12.7644 10.9869L12.1902 10.076C12.3768 9.73688 12.5278 9.37515 12.638 8.99596L13.6879 8.75794C14.0751 8.67015 14.35 8.32601 14.35 7.92897V7.07183C14.35 6.6748 14.0751 6.33065 13.6879 6.24287L12.6381 6.00488C12.528 5.62578 12.3771 5.26414 12.1906 4.92507L12.7648 4.01407C12.9766 3.6782 12.9276 3.2405 12.6468 2.95975L12.0407 2.35366C11.76 2.07292 11.3223 2.02392 10.9864 2.23565L10.0755 2.80989C9.73622 2.62328 9.37437 2.47229 8.99505 2.36209L8.75705 1.31231C8.66927 0.925096 8.32512 0.650238 7.92809 0.650238H7.07095ZM4.92053 3.81251C5.44724 3.44339 6.05665 3.18424 6.71543 3.06839L7.07095 1.50024H7.92809L8.28355 3.06816C8.94267 3.18387 9.5524 3.44302 10.0794 3.81224L11.4397 2.9547L12.0458 3.56079L11.1882 4.92117C11.5573 5.44798 11.8164 6.0575 11.9321 6.71638L13.5 7.07183V7.92897L11.932 8.28444C11.8162 8.94342 11.557 9.55301 11.1878 10.0798L12.0453 11.4402L11.4392 12.0462L10.0787 11.1886C9.55192 11.5576 8.94241 11.8166 8.28355 11.9323L7.92809 13.5002H7.07095L6.71543 11.932C6.0569 11.8162 5.44772 11.5572 4.92116 11.1883L3.56055 12.046L2.95445 11.4399L3.81213 10.0794C3.4431 9.55266 3.18403 8.94326 3.06825 8.2845L1.50002 7.92897V7.07183L3.06818 6.71632C3.18388 6.05765 3.44283 5.44833 3.81171 4.92165L2.95398 3.561L3.56008 2.95491L4.92053 3.81251ZM9.02496 7.50008C9.02496 8.34226 8.34223 9.02499 7.50005 9.02499C6.65786 9.02499 5.97513 8.34226 5.97513 7.50008C5.97513 6.65789 6.65786 5.97516 7.50005 5.97516C8.34223 5.97516 9.02496 6.65789 9.02496 7.50008ZM9.92496 7.50008C9.92496 8.83932 8.83929 9.92499 7.50005 9.92499C6.1608 9.92499 5.07513 8.83932 5.07513 7.50008C5.07513 6.16084 6.1608 5.07516 7.50005 5.07516C8.83929 5.07516 9.92496 6.16084 9.92496 7.50008Z",
6455
6485
  fill: color,
6456
6486
  fillRule: "evenodd",
6457
6487
  clipRule: "evenodd"
6458
6488
  }));
6459
6489
  });
6460
- var _excluded$2Z = ["color"];
6461
- var ListBulletIcon = /* @__PURE__ */ React.forwardRef(function(_ref, forwardedRef) {
6462
- var _ref$color = _ref.color, color = _ref$color === void 0 ? "currentColor" : _ref$color, props = _objectWithoutPropertiesLoose(_ref, _excluded$2Z);
6490
+ var _excluded$2E = ["color"];
6491
+ var InputIcon = /* @__PURE__ */ React.forwardRef(function(_ref, forwardedRef) {
6492
+ var _ref$color = _ref.color, color = _ref$color === void 0 ? "currentColor" : _ref$color, props = _objectWithoutPropertiesLoose(_ref, _excluded$2E);
6463
6493
  return React.createElement("svg", Object.assign({
6464
6494
  width: "15",
6465
6495
  height: "15",
@@ -6469,15 +6499,15 @@ var __publicField = (obj, key, value) => {
6469
6499
  }, props, {
6470
6500
  ref: forwardedRef
6471
6501
  }), React.createElement("path", {
6472
- d: "M1.5 5.25C1.91421 5.25 2.25 4.91421 2.25 4.5C2.25 4.08579 1.91421 3.75 1.5 3.75C1.08579 3.75 0.75 4.08579 0.75 4.5C0.75 4.91421 1.08579 5.25 1.5 5.25ZM4 4.5C4 4.22386 4.22386 4 4.5 4H13.5C13.7761 4 14 4.22386 14 4.5C14 4.77614 13.7761 5 13.5 5H4.5C4.22386 5 4 4.77614 4 4.5ZM4.5 7C4.22386 7 4 7.22386 4 7.5C4 7.77614 4.22386 8 4.5 8H13.5C13.7761 8 14 7.77614 14 7.5C14 7.22386 13.7761 7 13.5 7H4.5ZM4.5 10C4.22386 10 4 10.2239 4 10.5C4 10.7761 4.22386 11 4.5 11H13.5C13.7761 11 14 10.7761 14 10.5C14 10.2239 13.7761 10 13.5 10H4.5ZM2.25 7.5C2.25 7.91421 1.91421 8.25 1.5 8.25C1.08579 8.25 0.75 7.91421 0.75 7.5C0.75 7.08579 1.08579 6.75 1.5 6.75C1.91421 6.75 2.25 7.08579 2.25 7.5ZM1.5 11.25C1.91421 11.25 2.25 10.9142 2.25 10.5C2.25 10.0858 1.91421 9.75 1.5 9.75C1.08579 9.75 0.75 10.0858 0.75 10.5C0.75 10.9142 1.08579 11.25 1.5 11.25Z",
6502
+ d: "M6.5 1C6.22386 1 6 1.22386 6 1.5C6 1.77614 6.22386 2 6.5 2C7.12671 2 7.45718 2.20028 7.65563 2.47812C7.8781 2.78957 8 3.28837 8 4V11C8 11.7116 7.8781 12.2104 7.65563 12.5219C7.45718 12.7997 7.12671 13 6.5 13C6.22386 13 6 13.2239 6 13.5C6 13.7761 6.22386 14 6.5 14C7.37329 14 8.04282 13.7003 8.46937 13.1031C8.47976 13.0886 8.48997 13.0739 8.5 13.0591C8.51003 13.0739 8.52024 13.0886 8.53063 13.1031C8.95718 13.7003 9.62671 14 10.5 14C10.7761 14 11 13.7761 11 13.5C11 13.2239 10.7761 13 10.5 13C9.87329 13 9.54282 12.7997 9.34437 12.5219C9.1219 12.2104 9 11.7116 9 11V4C9 3.28837 9.1219 2.78957 9.34437 2.47812C9.54282 2.20028 9.87329 2 10.5 2C10.7761 2 11 1.77614 11 1.5C11 1.22386 10.7761 1 10.5 1C9.62671 1 8.95718 1.29972 8.53063 1.89688C8.52024 1.91143 8.51003 1.92611 8.5 1.9409C8.48997 1.92611 8.47976 1.91143 8.46937 1.89688C8.04282 1.29972 7.37329 1 6.5 1ZM14 5H11V4H14C14.5523 4 15 4.44772 15 5V10C15 10.5523 14.5523 11 14 11H11V10H14V5ZM6 4V5H1L1 10H6V11H1C0.447715 11 0 10.5523 0 10V5C0 4.44772 0.447715 4 1 4H6Z",
6473
6503
  fill: color,
6474
6504
  fillRule: "evenodd",
6475
6505
  clipRule: "evenodd"
6476
6506
  }));
6477
6507
  });
6478
- var _excluded$3n = ["color"];
6479
- var Pencil1Icon = /* @__PURE__ */ React.forwardRef(function(_ref, forwardedRef) {
6480
- var _ref$color = _ref.color, color = _ref$color === void 0 ? "currentColor" : _ref$color, props = _objectWithoutPropertiesLoose(_ref, _excluded$3n);
6508
+ var _excluded$2Z = ["color"];
6509
+ var ListBulletIcon = /* @__PURE__ */ React.forwardRef(function(_ref, forwardedRef) {
6510
+ var _ref$color = _ref.color, color = _ref$color === void 0 ? "currentColor" : _ref$color, props = _objectWithoutPropertiesLoose(_ref, _excluded$2Z);
6481
6511
  return React.createElement("svg", Object.assign({
6482
6512
  width: "15",
6483
6513
  height: "15",
@@ -6487,7 +6517,7 @@ var __publicField = (obj, key, value) => {
6487
6517
  }, props, {
6488
6518
  ref: forwardedRef
6489
6519
  }), React.createElement("path", {
6490
- d: "M11.8536 1.14645C11.6583 0.951184 11.3417 0.951184 11.1465 1.14645L3.71455 8.57836C3.62459 8.66832 3.55263 8.77461 3.50251 8.89155L2.04044 12.303C1.9599 12.491 2.00189 12.709 2.14646 12.8536C2.29103 12.9981 2.50905 13.0401 2.69697 12.9596L6.10847 11.4975C6.2254 11.4474 6.3317 11.3754 6.42166 11.2855L13.8536 3.85355C14.0488 3.65829 14.0488 3.34171 13.8536 3.14645L11.8536 1.14645ZM4.42166 9.28547L11.5 2.20711L12.7929 3.5L5.71455 10.5784L4.21924 11.2192L3.78081 10.7808L4.42166 9.28547Z",
6520
+ d: "M1.5 5.25C1.91421 5.25 2.25 4.91421 2.25 4.5C2.25 4.08579 1.91421 3.75 1.5 3.75C1.08579 3.75 0.75 4.08579 0.75 4.5C0.75 4.91421 1.08579 5.25 1.5 5.25ZM4 4.5C4 4.22386 4.22386 4 4.5 4H13.5C13.7761 4 14 4.22386 14 4.5C14 4.77614 13.7761 5 13.5 5H4.5C4.22386 5 4 4.77614 4 4.5ZM4.5 7C4.22386 7 4 7.22386 4 7.5C4 7.77614 4.22386 8 4.5 8H13.5C13.7761 8 14 7.77614 14 7.5C14 7.22386 13.7761 7 13.5 7H4.5ZM4.5 10C4.22386 10 4 10.2239 4 10.5C4 10.7761 4.22386 11 4.5 11H13.5C13.7761 11 14 10.7761 14 10.5C14 10.2239 13.7761 10 13.5 10H4.5ZM2.25 7.5C2.25 7.91421 1.91421 8.25 1.5 8.25C1.08579 8.25 0.75 7.91421 0.75 7.5C0.75 7.08579 1.08579 6.75 1.5 6.75C1.91421 6.75 2.25 7.08579 2.25 7.5ZM1.5 11.25C1.91421 11.25 2.25 10.9142 2.25 10.5C2.25 10.0858 1.91421 9.75 1.5 9.75C1.08579 9.75 0.75 10.0858 0.75 10.5C0.75 10.9142 1.08579 11.25 1.5 11.25Z",
6491
6521
  fill: color,
6492
6522
  fillRule: "evenodd",
6493
6523
  clipRule: "evenodd"
@@ -6635,6 +6665,10 @@ var __publicField = (obj, key, value) => {
6635
6665
  clipRule: "evenodd"
6636
6666
  }));
6637
6667
  });
6668
+ const emptyBooleanField = {
6669
+ ...emptyBaseField,
6670
+ type: "boolean"
6671
+ };
6638
6672
  const _BooleanField = class _BooleanField extends BaseField {
6639
6673
  constructor(options) {
6640
6674
  super({ ...options, type: "boolean" });
@@ -8059,9 +8093,9 @@ var __publicField = (obj, key, value) => {
8059
8093
  Content: TabsContent
8060
8094
  });
8061
8095
  const NumberInput$1 = React.memo(function NumberInput2(props) {
8062
- const [{ inputId, labelId, severity, helpText, label, fieldProps, field }, rest] = useFormikInput(props);
8096
+ const [{ inputId, labelId, size, severity, helpText, label, fieldProps, field }, rest] = useFormikInput(props);
8063
8097
  const color = blocks.useSeverityColor(severity);
8064
- return /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText, severity, children: /* @__PURE__ */ jsxRuntime.jsx(InputWithLabel, { severity, inputId, labelId, label, children: /* @__PURE__ */ jsxRuntime.jsx(
8098
+ return /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText, severity, children: /* @__PURE__ */ jsxRuntime.jsx(InputWithLabel, { size, severity, inputId, labelId, label, children: /* @__PURE__ */ jsxRuntime.jsx(
8065
8099
  TextField$1.Input,
8066
8100
  {
8067
8101
  ...rest,
@@ -8075,144 +8109,6 @@ var __publicField = (obj, key, value) => {
8075
8109
  }
8076
8110
  ) }) });
8077
8111
  });
8078
- const _NumberField = class _NumberField extends BaseField {
8079
- constructor(options) {
8080
- const {
8081
- minimum = Number.MIN_SAFE_INTEGER,
8082
- maximum = Number.MAX_SAFE_INTEGER,
8083
- integers = false,
8084
- ...base
8085
- } = options;
8086
- super({ ...base, type: "number" });
8087
- __publicField(this, "minimum");
8088
- __publicField(this, "maximum");
8089
- __publicField(this, "integers");
8090
- this.minimum = minimum;
8091
- this.maximum = maximum;
8092
- this.integers = integers;
8093
- }
8094
- getValueFromChangeEvent(event) {
8095
- const number = Number.parseFloat(event.target.value);
8096
- if (Number.isNaN(number))
8097
- return "";
8098
- return number;
8099
- }
8100
- static getFieldCreationSchema() {
8101
- return [
8102
- new _NumberField({
8103
- label: "Minimum",
8104
- description: "Minimum value",
8105
- integers: true,
8106
- required: false,
8107
- identifier: "minimum",
8108
- formValidators: [this._validateMin]
8109
- }),
8110
- new _NumberField({
8111
- label: "Maximum",
8112
- description: "Maximum value",
8113
- integers: true,
8114
- required: false,
8115
- identifier: "maximum",
8116
- formValidators: [this._validateMax]
8117
- }),
8118
- new BooleanField({
8119
- label: "Integers",
8120
- description: "Whole numbers only",
8121
- required: false,
8122
- identifier: "integers"
8123
- })
8124
- ];
8125
- }
8126
- getFieldValidators() {
8127
- const validators = super.getFieldValidators();
8128
- const min = this.minimum;
8129
- const max = this.maximum;
8130
- if (typeof min === "number") {
8131
- validators.push((value) => {
8132
- if (typeof value === "number" && value < min) {
8133
- return `Must be at least ${this.minimum}.`;
8134
- }
8135
- });
8136
- }
8137
- if (typeof max === "number") {
8138
- validators.push((value) => {
8139
- if (typeof value === "number" && value > max) {
8140
- return `Must be at most ${this.maximum}.`;
8141
- }
8142
- });
8143
- }
8144
- if (this.integers) {
8145
- validators.push((value) => {
8146
- if (typeof value === "number" && !Number.isInteger(value)) {
8147
- return "Must be a whole number.";
8148
- }
8149
- });
8150
- }
8151
- return validators;
8152
- }
8153
- serialize() {
8154
- return {
8155
- ...super._serialize(),
8156
- minimum: this.minimum,
8157
- maximum: this.maximum,
8158
- integers: this.integers
8159
- };
8160
- }
8161
- static deserialize(data) {
8162
- if (data.type !== "number")
8163
- throw new Error("Type mismatch.");
8164
- return new _NumberField(data);
8165
- }
8166
- getInput(props) {
8167
- return /* @__PURE__ */ jsxRuntime.jsx(NumberInput$1, { field: this, ...props });
8168
- }
8169
- };
8170
- __publicField(_NumberField, "fieldTypeName", "Number");
8171
- __publicField(_NumberField, "fieldTypeDescription", "Allows specifying a number within a given range.");
8172
- __publicField(_NumberField, "Icon", FontFamilyIcon);
8173
- __publicField(_NumberField, "_validateMin", (value, allValues) => {
8174
- if (typeof allValues.maximum === "number" && typeof value === "number" && allValues.maximum < value) {
8175
- return "Minimum cannot be greater than minimum.";
8176
- }
8177
- return null;
8178
- });
8179
- __publicField(_NumberField, "_validateMax", (value, allValues) => {
8180
- if (typeof allValues.minimum === "number" && typeof value === "number" && allValues.minimum > value) {
8181
- return "Maximum cannot be less than minimum.";
8182
- }
8183
- return null;
8184
- });
8185
- let NumberField = _NumberField;
8186
- const DateInput = React.memo(function DateInput2(props) {
8187
- const [{ inputId, labelId, severity, helpText, label, fieldProps }, rest] = useFormikInput(props);
8188
- const color = blocks.useSeverityColor(severity);
8189
- const value = fieldProps.value ? fieldProps.value.split("T")[0] : "";
8190
- return /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText, severity, children: /* @__PURE__ */ jsxRuntime.jsx(InputWithLabel, { severity, inputId, labelId, label, children: /* @__PURE__ */ jsxRuntime.jsx(TextField$1.Input, { ...rest, ...fieldProps, type: "date", id: inputId, color, value }) }) });
8191
- });
8192
- const _DateField = class _DateField extends BaseField {
8193
- constructor(options) {
8194
- super({ ...options, type: "date" });
8195
- __publicField(this, "onlyValidateAfterTouched", false);
8196
- }
8197
- serialize() {
8198
- return super._serialize();
8199
- }
8200
- getValueFromChangeEvent(event) {
8201
- return new Date(event.target.value).toISOString();
8202
- }
8203
- static deserialize(data) {
8204
- if (data.type !== "date")
8205
- throw new Error("Type mismatch.");
8206
- return new _DateField(data);
8207
- }
8208
- getInput(props) {
8209
- return /* @__PURE__ */ jsxRuntime.jsx(DateInput, { field: this, ...props });
8210
- }
8211
- };
8212
- __publicField(_DateField, "fieldTypeName", "Date");
8213
- __publicField(_DateField, "fieldTypeDescription", "Allows specifying a date.");
8214
- __publicField(_DateField, "Icon", CalendarIcon);
8215
- let DateField = _DateField;
8216
8112
  class StringOrTextField extends BaseField {
8217
8113
  constructor(options) {
8218
8114
  const { minLength, maxLength = 5e3, ...base } = options;
@@ -8222,31 +8118,40 @@ var __publicField = (obj, key, value) => {
8222
8118
  this.minLength = minLength ? Math.max(minLength, 0) : void 0;
8223
8119
  this.maxLength = maxLength ? Math.max(maxLength, 0) : 5e3;
8224
8120
  }
8225
- static getFieldCreationSchema() {
8121
+ static getFieldCreationSchema(parentPath = "") {
8122
+ const path = parentPath && `${parentPath}.`;
8226
8123
  return [
8227
- // min, max
8228
- new NumberField({
8229
- label: "Minimum length",
8230
- description: "Minimum number of characters",
8231
- required: false,
8232
- identifier: "minimum_length",
8233
- minimum: 0,
8234
- maximum: 100,
8235
- formValidators: [this._validateMin],
8236
- integers: true
8237
- }),
8238
- new NumberField({
8239
- label: "Maximum length",
8240
- description: "Maximum number of characters",
8241
- required: false,
8242
- identifier: "maximum_length",
8243
- minimum: 1,
8244
- maximum: 5e3,
8245
- // TODO: depends on short vs long text
8246
- formValidators: [this._validateMax],
8247
- // TODO: default: 500 (see: "Short text fields can hold up to 500 characters on a single line.")
8248
- integers: true
8249
- })
8124
+ {
8125
+ field: (
8126
+ // min, max
8127
+ new NumberField({
8128
+ label: "Minimum length",
8129
+ description: "Minimum number of characters",
8130
+ required: false,
8131
+ identifier: `${path}minimum_length`,
8132
+ minimum: 0,
8133
+ maximum: 100,
8134
+ formValidators: [this._validateMin(parentPath)],
8135
+ integers: true
8136
+ })
8137
+ ),
8138
+ showDirectly: false
8139
+ },
8140
+ {
8141
+ field: new NumberField({
8142
+ label: "Maximum length",
8143
+ description: "Maximum number of characters",
8144
+ required: false,
8145
+ identifier: `${path}maximum_length`,
8146
+ minimum: 1,
8147
+ maximum: 5e3,
8148
+ // TODO: depends on short vs long text
8149
+ formValidators: [this._validateMax(parentPath)],
8150
+ // TODO: default: 500 (see: "Short text fields can hold up to 500 characters on a single line.")
8151
+ integers: true
8152
+ }),
8153
+ showDirectly: false
8154
+ }
8250
8155
  ];
8251
8156
  }
8252
8157
  getFieldValidators() {
@@ -8281,23 +8186,24 @@ var __publicField = (obj, key, value) => {
8281
8186
  }
8282
8187
  }
8283
8188
  /**
8284
- * This function validates that the value given for "minimum length" (when creating a new field) is less than or
8189
+ * This function returns a function that validates that the value given for "minimum length" (when creating a new field) is less than or
8285
8190
  * equal to the value given for "maximum length".
8286
8191
  */
8287
- __publicField(StringOrTextField, "_validateMin", (value, allValues) => {
8288
- if (typeof allValues.maximum_length === "number" && typeof value === "number" && allValues.maximum_length < value) {
8192
+ __publicField(StringOrTextField, "_validateMin", (path) => (value, allValues) => {
8193
+ const field = valueIsFormikUserFormRevision(allValues) ? get(allValues, path) : allValues;
8194
+ if (typeof field.maximum_length === "number" && typeof value === "number" && field.maximum_length < value) {
8289
8195
  return "Minimum cannot be greater than maximum.";
8290
8196
  }
8291
8197
  return null;
8292
8198
  });
8293
8199
  /**
8294
- * This function validates that the value given for "maximum length" (when creating a new field) is greater than or
8200
+ * This function returns a function that validates that the value given for "maximum length" (when creating a new field) is greater than or
8295
8201
  * equal to the value given for "minimum length".
8296
8202
  */
8297
- __publicField(StringOrTextField, "_validateMax", (value, allValues) => {
8203
+ __publicField(StringOrTextField, "_validateMax", (path) => (value, allValues) => {
8298
8204
  if (typeof value !== "number")
8299
8205
  return null;
8300
- const { minimum_length: minimumLength } = allValues;
8206
+ const { minimum_length: minimumLength } = valueIsFormikUserFormRevision(allValues) ? get(allValues, path) : allValues;
8301
8207
  if (typeof minimumLength !== "number") {
8302
8208
  return null;
8303
8209
  }
@@ -8308,20 +8214,20 @@ var __publicField = (obj, key, value) => {
8308
8214
  });
8309
8215
  const clickableLinkContainer = "_clickableLinkContainer_1ace7_1";
8310
8216
  const TextFieldInputCopy = "_TextFieldInputCopy_1ace7_5";
8311
- const styles$3 = {
8217
+ const styles$4 = {
8312
8218
  clickableLinkContainer,
8313
8219
  TextFieldInputCopy
8314
8220
  };
8315
8221
  const StringInput = React.memo(function StringInput2(props) {
8316
- const [{ inputId, labelId, severity, helpText, label, fieldProps, field }, rest] = useFormikInput(props);
8222
+ const [{ inputId, labelId, size, severity, helpText, label, fieldProps, field }, rest] = useFormikInput(props);
8317
8223
  const color = blocks.useSeverityColor(severity);
8318
- return /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText, severity, children: /* @__PURE__ */ jsxRuntime.jsx(InputWithLabel, { severity, inputId, labelId, label, children: !rest.disabled ? /* @__PURE__ */ jsxRuntime.jsx(TextField$1.Input, { ...rest, ...fieldProps, type: field.inputType, id: inputId, color }) : /* @__PURE__ */ jsxRuntime.jsxs(TextField$1.Root, { className: styles$3.clickableLinkContainer, children: [
8224
+ return /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText, severity, children: /* @__PURE__ */ jsxRuntime.jsx(InputWithLabel, { size, severity, inputId, labelId, label, children: !rest.disabled ? /* @__PURE__ */ jsxRuntime.jsx(TextField$1.Input, { ...rest, ...fieldProps, type: field.inputType, id: inputId, color }) : /* @__PURE__ */ jsxRuntime.jsxs(TextField$1.Root, { className: styles$4.clickableLinkContainer, children: [
8319
8225
  /* @__PURE__ */ jsxRuntime.jsx(
8320
8226
  "div",
8321
8227
  {
8322
8228
  className: classNames$1(
8323
8229
  "rt-TextFieldInput rt-r-size-2 rt-variant-surface",
8324
- styles$3.TextFieldInputCopy
8230
+ styles$4.TextFieldInputCopy
8325
8231
  ),
8326
8232
  children: /* @__PURE__ */ jsxRuntime.jsx(
8327
8233
  Linkify,
@@ -8338,6 +8244,12 @@ var __publicField = (obj, key, value) => {
8338
8244
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rt-TextFieldChrome" })
8339
8245
  ] }) }) });
8340
8246
  });
8247
+ const emptyStringField = {
8248
+ ...emptyBaseField,
8249
+ type: "string",
8250
+ maximum_length: 500,
8251
+ input_type: "text"
8252
+ };
8341
8253
  const _StringField = class _StringField extends StringOrTextField {
8342
8254
  constructor(options) {
8343
8255
  const { inputType = "text", ...rest } = options;
@@ -8365,9 +8277,14 @@ var __publicField = (obj, key, value) => {
8365
8277
  __publicField(_StringField, "Icon", InputIcon);
8366
8278
  let StringField = _StringField;
8367
8279
  const TextInput = React.memo(function TextInput2(props) {
8368
- const [{ inputId, labelId, severity, helpText, label, fieldProps }, rest] = useFormikInput(props);
8369
- return /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText, severity, children: /* @__PURE__ */ jsxRuntime.jsx(InputWithLabel, { severity, inputId, labelId, label, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.TextArea, { ...rest, ...fieldProps, resize: "vertical", id: inputId, severity }) }) });
8280
+ const [{ inputId, labelId, size, severity, helpText, label, fieldProps }, rest] = useFormikInput(props);
8281
+ return /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText, severity, children: /* @__PURE__ */ jsxRuntime.jsx(InputWithLabel, { size, severity, inputId, labelId, label, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.TextArea, { ...rest, ...fieldProps, resize: "vertical", id: inputId, severity }) }) });
8370
8282
  });
8283
+ const emptyTextField = {
8284
+ ...emptyBaseField,
8285
+ type: "text",
8286
+ maximum_length: 5e3
8287
+ };
8371
8288
  const _TextField = class _TextField extends StringOrTextField {
8372
8289
  constructor(options) {
8373
8290
  const maxLength = options.maxLength ? Math.min(5e3, options.maxLength) : 5e3;
@@ -8391,8 +8308,42 @@ var __publicField = (obj, key, value) => {
8391
8308
  __publicField(_TextField, "fieldTypeDescription", "Paragraph fields can hold up to 5000 characters and can have multiple lines.");
8392
8309
  __publicField(_TextField, "Icon", RowsIcon);
8393
8310
  let TextField = _TextField;
8311
+ const DateInput = React.memo(function DateInput2(props) {
8312
+ const [{ inputId, labelId, size, severity, helpText, label, fieldProps }, rest] = useFormikInput(props);
8313
+ const color = blocks.useSeverityColor(severity);
8314
+ const value = fieldProps.value ? fieldProps.value.split("T")[0] : "";
8315
+ return /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText, severity, children: /* @__PURE__ */ jsxRuntime.jsx(InputWithLabel, { size, severity, inputId, labelId, label, children: /* @__PURE__ */ jsxRuntime.jsx(TextField$1.Input, { ...rest, ...fieldProps, type: "date", id: inputId, color, value }) }) });
8316
+ });
8317
+ const emptyDateField = {
8318
+ ...emptyBaseField,
8319
+ type: "date"
8320
+ };
8321
+ const _DateField = class _DateField extends BaseField {
8322
+ constructor(options) {
8323
+ super({ ...options, type: "date" });
8324
+ __publicField(this, "onlyValidateAfterTouched", false);
8325
+ }
8326
+ serialize() {
8327
+ return super._serialize();
8328
+ }
8329
+ getValueFromChangeEvent(event) {
8330
+ return new Date(event.target.value).toISOString();
8331
+ }
8332
+ static deserialize(data) {
8333
+ if (data.type !== "date")
8334
+ throw new Error("Type mismatch.");
8335
+ return new _DateField(data);
8336
+ }
8337
+ getInput(props) {
8338
+ return /* @__PURE__ */ jsxRuntime.jsx(DateInput, { field: this, ...props });
8339
+ }
8340
+ };
8341
+ __publicField(_DateField, "fieldTypeName", "Date");
8342
+ __publicField(_DateField, "fieldTypeDescription", "Allows specifying a date.");
8343
+ __publicField(_DateField, "Icon", CalendarIcon);
8344
+ let DateField = _DateField;
8394
8345
  const SelectInput = React.memo(function SelectInput2(props) {
8395
- const [{ inputId, labelId, severity, helpText, label, fieldProps, field }, rest] = useFormikInput(props);
8346
+ const [{ inputId, labelId, size, severity, helpText, label, fieldProps, field }, rest] = useFormikInput(props);
8396
8347
  const { onChange, onBlur } = fieldProps;
8397
8348
  const options = React.useMemo(
8398
8349
  () => field.options.map((option) => ({ value: option.value, itemContent: option.label })),
@@ -8405,7 +8356,7 @@ var __publicField = (obj, key, value) => {
8405
8356
  },
8406
8357
  [onChange, onBlur]
8407
8358
  );
8408
- return /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText, severity, children: /* @__PURE__ */ jsxRuntime.jsx(InputWithLabel, { severity, inputId, labelId, label, children: /* @__PURE__ */ jsxRuntime.jsx(
8359
+ return /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText, severity, children: /* @__PURE__ */ jsxRuntime.jsx(InputWithLabel, { size, severity, inputId, labelId, label, children: /* @__PURE__ */ jsxRuntime.jsx(
8409
8360
  blocks.Select,
8410
8361
  {
8411
8362
  items: options,
@@ -8456,11 +8407,6 @@ var __publicField = (obj, key, value) => {
8456
8407
  result.splice(destination, 0, removed);
8457
8408
  return result;
8458
8409
  }
8459
- function replace(list, index2, value) {
8460
- const result = Array.from(list);
8461
- result[index2] = value;
8462
- return result;
8463
- }
8464
8410
  function insert(list, index2, value) {
8465
8411
  const result = Array.from(list ?? []);
8466
8412
  result.splice(index2, 0, value);
@@ -8495,9 +8441,7 @@ var __publicField = (obj, key, value) => {
8495
8441
  return sections.filter((_, i) => i < index2).flatMap((field) => field.fields);
8496
8442
  };
8497
8443
  const getTakenFieldLabels = (fields) => {
8498
- return fields.flatMap(
8499
- (field) => field.type === "section" ? [...field.fields.map((f) => f.label), field.label] : field.label
8500
- ).filter((id) => id !== null);
8444
+ return fields.flatMap((field) => [...field.fields.map((f) => f.label), field.label]).filter((id) => id !== null);
8501
8445
  };
8502
8446
  const incrementFieldLabel = (label, takenLabels) => {
8503
8447
  let count = 1;
@@ -8507,8 +8451,90 @@ var __publicField = (obj, key, value) => {
8507
8451
  }
8508
8452
  return newLabel;
8509
8453
  };
8454
+ const createNewField = (parentPath, index2, initialValues2, values, setFieldValue) => {
8455
+ const { label } = initialValues2;
8456
+ const newField = {
8457
+ ...initialValues2,
8458
+ identifier: makeIdentifier(null, label)
8459
+ };
8460
+ const parent = get(values, parentPath);
8461
+ if (parent === void 0) {
8462
+ throw new Error("Parent path must point to an existing field.");
8463
+ }
8464
+ if (!Array.isArray(parent)) {
8465
+ throw new Error("Parent path must point to an array.");
8466
+ }
8467
+ const updatedFields = insert(parent, index2, newField);
8468
+ void setFieldValue(parentPath, updatedFields).then();
8469
+ };
8470
+ const createNewEmptySection = (index2, values, setFieldValue) => {
8471
+ const initialValues2 = {
8472
+ ...emptySection(),
8473
+ label: ""
8474
+ };
8475
+ createNewField("fields", index2, initialValues2, values, setFieldValue);
8476
+ };
8477
+ const useFieldReordering = () => {
8478
+ const { showError } = blocks.useToast();
8479
+ const reorderSection = React.useCallback(
8480
+ (dropState, sectionId, sectionIndex, destinationIndex, values, setFieldValue) => {
8481
+ const state = dropState[sectionId];
8482
+ if (!state)
8483
+ throw new Error("Could not find section context.");
8484
+ let dest = typeof state.conditionIndex !== "undefined" ? (
8485
+ // cannot move a section with a condition before the condition's field
8486
+ Math.max(state.conditionIndex + 1, destinationIndex)
8487
+ ) : destinationIndex;
8488
+ for (const section of Object.values(dropState)) {
8489
+ if (section.conditionIndex === sectionIndex) {
8490
+ dest = Math.min(dest, section.index - 1);
8491
+ }
8492
+ }
8493
+ if (dest !== destinationIndex) {
8494
+ showError({
8495
+ title: "Could not reorder sections",
8496
+ description: "Sections with conditions must be below the fields they reference."
8497
+ });
8498
+ return;
8499
+ }
8500
+ void setFieldValue("fields", reorder(values.fields, sectionIndex, dest));
8501
+ },
8502
+ [showError]
8503
+ );
8504
+ const reorderField = React.useCallback(
8505
+ (srcSection, srcSectionIndex, srcFieldIndex, destSection, destSectionIndex, destFieldIndex, setFieldValue) => {
8506
+ var _a2;
8507
+ if (!(srcSection == null ? void 0 : srcSection.fields) || !destSection)
8508
+ throw new Error("Could not find section with fields.");
8509
+ if (srcSection.identifier === destSection.identifier) {
8510
+ void setFieldValue(
8511
+ `fields.${srcSectionIndex}.fields`,
8512
+ reorder(srcSection.fields, srcFieldIndex, destFieldIndex)
8513
+ ).then();
8514
+ } else {
8515
+ const removed = srcSection.fields[srcFieldIndex];
8516
+ if (!removed)
8517
+ throw new Error("Could not find field to reorder.");
8518
+ if (((_a2 = destSection.condition) == null ? void 0 : _a2.identifier) === removed.identifier) {
8519
+ showError({
8520
+ title: "Could not reorder field",
8521
+ description: "Field must be above the section whose condition references it."
8522
+ });
8523
+ return;
8524
+ }
8525
+ void setFieldValue(`fields.${srcSectionIndex}.fields`, remove(srcSection.fields, srcFieldIndex)).then();
8526
+ void setFieldValue(
8527
+ `fields.${destSectionIndex}.fields`,
8528
+ insert(destSection.fields, destFieldIndex, removed)
8529
+ ).then();
8530
+ }
8531
+ },
8532
+ [showError]
8533
+ );
8534
+ return { reorderSection, reorderField };
8535
+ };
8510
8536
  const MultiStringInput = React.memo(function MultiStringInput2(props) {
8511
- const [{ inputId, labelId, severity, helpText, label, fieldProps }, rest] = useFormikInput(props);
8537
+ const [{ inputId, labelId, size, severity, helpText, label, fieldProps }, rest] = useFormikInput(props);
8512
8538
  const color = blocks.useSeverityColor(severity);
8513
8539
  const value = React.useMemo(
8514
8540
  () => Array.isArray(fieldProps.value) ? fieldProps.value : [],
@@ -8578,7 +8604,7 @@ var __publicField = (obj, key, value) => {
8578
8604
  [setValueAndTouched, value]
8579
8605
  );
8580
8606
  return /* @__PURE__ */ jsxRuntime.jsx(dnd.DragDropContext, { onDragEnd: handleDragEnd, children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "2", children: [
8581
- /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText: updatedHelpText, severity, children: /* @__PURE__ */ jsxRuntime.jsx(InputWithLabel, { severity, inputId, labelId, label, children: (!disabled || value.length === 0) && /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { gap: "2", children: [
8607
+ /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText: updatedHelpText, severity, children: /* @__PURE__ */ jsxRuntime.jsx(InputWithLabel, { size, severity, inputId, labelId, label, children: (!disabled || value.length === 0) && /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { gap: "2", children: [
8582
8608
  /* @__PURE__ */ jsxRuntime.jsx(Box, { grow: "1", children: /* @__PURE__ */ jsxRuntime.jsx(
8583
8609
  TextField$1.Input,
8584
8610
  {
@@ -8649,6 +8675,12 @@ var __publicField = (obj, key, value) => {
8649
8675
  ] }) })
8650
8676
  ] }) });
8651
8677
  });
8678
+ const emptyMultiStringField = {
8679
+ ...emptyBaseField,
8680
+ type: "multi-string",
8681
+ minimum_length: 0,
8682
+ maximum_length: null
8683
+ };
8652
8684
  const _MultiStringField = class _MultiStringField extends BaseField {
8653
8685
  constructor(options) {
8654
8686
  const { minimum_length, maximum_length, ...rest } = options;
@@ -8723,19 +8755,28 @@ var __publicField = (obj, key, value) => {
8723
8755
  options: this.options
8724
8756
  };
8725
8757
  }
8726
- static getFieldCreationSchema() {
8758
+ static getFieldCreationSchema(parentPath = "") {
8759
+ const path = parentPath && `${parentPath}.`;
8727
8760
  return [
8728
- new MultiStringField({
8729
- label: "Options",
8730
- description: "List possible options for the user to select from.",
8731
- required: true,
8732
- identifier: "options",
8733
- minimum_length: 2,
8734
- maximum_length: 20
8735
- })
8761
+ {
8762
+ field: new MultiStringField({
8763
+ label: "Options",
8764
+ description: "List possible options for the user to select from.",
8765
+ required: true,
8766
+ identifier: `${path}options`,
8767
+ minimum_length: 2,
8768
+ maximum_length: 20
8769
+ }),
8770
+ showDirectly: true
8771
+ }
8736
8772
  ];
8737
8773
  }
8738
8774
  }
8775
+ const emptySelectField = {
8776
+ ...emptyBaseField,
8777
+ type: "select",
8778
+ options: []
8779
+ };
8739
8780
  const _SelectField = class _SelectField extends BaseSelectField {
8740
8781
  constructor(options) {
8741
8782
  super({ ...options, type: "select" });
@@ -8769,7 +8810,7 @@ var __publicField = (obj, key, value) => {
8769
8810
  return [value];
8770
8811
  };
8771
8812
  const MultiSelectInput = React.memo(function MultiSelectInput2(props) {
8772
- const [{ inputId, labelId, severity, helpText, label, fieldProps, field }, rest] = useFormikInput(props);
8813
+ const [{ inputId, labelId, size, severity, helpText, label, fieldProps, field }, rest] = useFormikInput(props);
8773
8814
  const { onChange, onBlur } = fieldProps;
8774
8815
  const value = React.useMemo(() => parseValueToArray(fieldProps.value), [fieldProps.value]);
8775
8816
  const handleChange = React.useCallback(
@@ -8779,7 +8820,7 @@ var __publicField = (obj, key, value) => {
8779
8820
  },
8780
8821
  [onChange, onBlur]
8781
8822
  );
8782
- return /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText, severity, children: /* @__PURE__ */ jsxRuntime.jsx(InputWithLabel, { severity, inputId, labelId, label, children: /* @__PURE__ */ jsxRuntime.jsx(
8823
+ return /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText, severity, children: /* @__PURE__ */ jsxRuntime.jsx(InputWithLabel, { size, severity, inputId, labelId, label, children: /* @__PURE__ */ jsxRuntime.jsx(
8783
8824
  blocks.MultiSelect,
8784
8825
  {
8785
8826
  value,
@@ -8793,6 +8834,11 @@ var __publicField = (obj, key, value) => {
8793
8834
  }
8794
8835
  ) }) });
8795
8836
  });
8837
+ const emptyMultiSelectField = {
8838
+ ...emptyBaseField,
8839
+ type: "multi-select",
8840
+ options: []
8841
+ };
8796
8842
  const _MultiSelectField = class _MultiSelectField extends BaseSelectField {
8797
8843
  constructor(options) {
8798
8844
  super({ ...options, type: "multi-select" });
@@ -8821,16 +8867,10 @@ var __publicField = (obj, key, value) => {
8821
8867
  __publicField(_MultiSelectField, "fieldTypeDescription", "Allows the user to select a multiple options from a list of options.");
8822
8868
  __publicField(_MultiSelectField, "Icon", CheckboxIcon);
8823
8869
  let MultiSelectField = _MultiSelectField;
8824
- const FieldInputCloner = React.memo(function FieldInputCloner2({ field, ...props }) {
8825
- const [{ value: identifier }] = formik.useField(field.options.clonedFieldIdentifier);
8826
- const deserializedField = React.useMemo(() => {
8827
- const options = field.options.getFieldToClone(identifier);
8828
- if (!options)
8829
- return null;
8830
- return deserialize(options);
8831
- }, [field.options, identifier]);
8832
- return useFieldInput(deserializedField, props);
8833
- });
8870
+ const emptyCustomField = {
8871
+ ...emptyBaseField,
8872
+ type: "custom"
8873
+ };
8834
8874
  class CustomField extends BaseField {
8835
8875
  constructor(options, Component) {
8836
8876
  super({ ...options, type: "custom" });
@@ -8850,13 +8890,8 @@ var __publicField = (obj, key, value) => {
8850
8890
  }
8851
8891
  __publicField(CustomField, "fieldTypeName", "Custom");
8852
8892
  __publicField(CustomField, "fieldTypeDescription", "Allows re-rendering of field already in the form");
8853
- class FieldInputClonerField extends CustomField {
8854
- constructor(options) {
8855
- super(options, FieldInputCloner);
8856
- }
8857
- }
8858
8893
  const previewImage = "_previewImage_1ig84_1";
8859
- const styles$2 = {
8894
+ const styles$3 = {
8860
8895
  previewImage
8861
8896
  };
8862
8897
  const convertBytesToLargestUnit = (bytes) => {
@@ -8877,7 +8912,7 @@ var __publicField = (obj, key, value) => {
8877
8912
  };
8878
8913
  const NumberInput = React.memo(function NumberInput2(props) {
8879
8914
  var _a2;
8880
- const [{ inputId, labelId, severity, helpText, label, fieldProps, field }, rest] = useFormikInput(props);
8915
+ const [{ inputId, labelId, size, severity, helpText, label, fieldProps, field }, rest] = useFormikInput(props);
8881
8916
  const { onChange } = fieldProps;
8882
8917
  const color = blocks.useSeverityColor(severity);
8883
8918
  const input = React.useRef(null);
@@ -8907,7 +8942,7 @@ var __publicField = (obj, key, value) => {
8907
8942
  const singleButtonText = value ? "Select new file" : "Select a file";
8908
8943
  const buttonText = field.maxFiles > 1 ? multipleButtonText : singleButtonText;
8909
8944
  return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "2", children: [
8910
- /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText: updatedHelpText, severity, children: /* @__PURE__ */ jsxRuntime.jsxs(InputWithLabel, { severity, inputId, labelId, label, children: [
8945
+ /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText: updatedHelpText, severity, children: /* @__PURE__ */ jsxRuntime.jsxs(InputWithLabel, { size, severity, inputId, labelId, label, children: [
8911
8946
  /* @__PURE__ */ jsxRuntime.jsx(blocks.Flex, { direction: "row", gap: "2", children: /* @__PURE__ */ jsxRuntime.jsx(Box, { width: "max-content", asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Button, { ...rest, onClick: handleClick, children: [
8912
8947
  /* @__PURE__ */ jsxRuntime.jsx(UploadIcon, {}),
8913
8948
  " ",
@@ -8988,9 +9023,16 @@ var __publicField = (obj, key, value) => {
8988
9023
  error && /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "1", severity: "danger", children: error })
8989
9024
  ] })
8990
9025
  ] }),
8991
- url && /* @__PURE__ */ jsxRuntime.jsx("img", { className: styles$2.previewImage, src: url, alt: name })
9026
+ url && /* @__PURE__ */ jsxRuntime.jsx("img", { className: styles$3.previewImage, src: url, alt: name })
8992
9027
  ] }) });
8993
9028
  });
9029
+ const emptyUploadField = {
9030
+ ...emptyBaseField,
9031
+ type: "upload",
9032
+ extensions: [],
9033
+ maximum_size: void 0,
9034
+ maximum_files: 1
9035
+ };
8994
9036
  const largestSupportedSize = 50;
8995
9037
  const _UploadField = class _UploadField extends BaseField {
8996
9038
  constructor(options) {
@@ -9010,55 +9052,65 @@ var __publicField = (obj, key, value) => {
9010
9052
  isBlank(value) {
9011
9053
  return super.isBlank(value) || value.length === 0;
9012
9054
  }
9013
- static getFieldCreationSchema() {
9055
+ static getFieldCreationSchema(parentPath = "") {
9056
+ const path = parentPath && `${parentPath}.`;
9014
9057
  return [
9015
- new NumberField({
9016
- label: "How many files can be uploaded?",
9017
- description: "By default, only one file can be uploaded.",
9018
- required: false,
9019
- minimum: 1,
9020
- maximum: 10,
9021
- identifier: "maximum_files",
9022
- integers: true
9023
- }),
9024
- new NumberField({
9025
- // TODO: Default value
9026
- label: "What is the maximum size of each file?",
9027
- description: `Maximum file size in megabytes (between 1MB–${largestSupportedSize}MB).`,
9028
- required: false,
9029
- identifier: "maximum_size",
9030
- minimum: 1,
9031
- maximum: largestSupportedSize,
9032
- integers: true
9033
- }),
9034
- new MultiSelectField({
9035
- label: "Accepted file types",
9036
- description: "Types of allowed files to upload. If left blank, all files will be accepted.",
9037
- required: false,
9038
- identifier: "extensions",
9039
- options: [
9040
- {
9041
- value: "image/*",
9042
- label: "Images"
9043
- },
9044
- {
9045
- value: "audio/*",
9046
- label: "Audio files"
9047
- },
9048
- {
9049
- value: "video/*",
9050
- label: "Videos"
9051
- },
9052
- {
9053
- value: "text/*",
9054
- label: "Text files"
9055
- },
9056
- {
9057
- value: "application/*",
9058
- label: "Application files (includes PDFs and Word documents)"
9059
- }
9060
- ]
9061
- })
9058
+ {
9059
+ field: new NumberField({
9060
+ label: "How many files can be uploaded?",
9061
+ description: "By default, only one file can be uploaded.",
9062
+ required: false,
9063
+ minimum: 1,
9064
+ maximum: 10,
9065
+ identifier: `${path}maximum_files`,
9066
+ integers: true
9067
+ }),
9068
+ showDirectly: false
9069
+ },
9070
+ {
9071
+ field: new NumberField({
9072
+ // TODO: Default value
9073
+ label: "What is the maximum size of each file?",
9074
+ description: `Maximum file size in megabytes (between 1MB–${largestSupportedSize}MB).`,
9075
+ required: false,
9076
+ identifier: `${path}maximum_size`,
9077
+ minimum: 1,
9078
+ maximum: largestSupportedSize,
9079
+ integers: true
9080
+ }),
9081
+ showDirectly: false
9082
+ },
9083
+ {
9084
+ field: new MultiSelectField({
9085
+ label: "Accepted file types",
9086
+ description: "Types of allowed files to upload. If left blank, all files will be accepted.",
9087
+ required: false,
9088
+ identifier: `${path}extensions`,
9089
+ options: [
9090
+ {
9091
+ value: "image/*",
9092
+ label: "Images"
9093
+ },
9094
+ {
9095
+ value: "audio/*",
9096
+ label: "Audio files"
9097
+ },
9098
+ {
9099
+ value: "video/*",
9100
+ label: "Videos"
9101
+ },
9102
+ {
9103
+ value: "text/*",
9104
+ label: "Text files"
9105
+ },
9106
+ {
9107
+ value: "application/*",
9108
+ label: "Application files (includes PDFs and Word documents)"
9109
+ }
9110
+ ]
9111
+ }),
9112
+ showDirectly: false
9113
+ }
9062
9114
  ];
9063
9115
  }
9064
9116
  getFieldValidators() {
@@ -9112,44 +9164,33 @@ var __publicField = (obj, key, value) => {
9112
9164
  "multi-string": MultiStringField,
9113
9165
  "multi-select": MultiSelectField
9114
9166
  };
9115
- const deserializeField = (serializedField) => {
9116
- const fieldType = serializedField.type;
9117
- const fieldCls = FieldTypeToClsMapping[fieldType];
9118
- return fieldCls.deserialize(serializedField);
9119
- };
9120
- const deserialize = (serialized) => {
9121
- if (serialized.type === "section") {
9122
- return FieldSection.deserialize(serialized);
9123
- }
9124
- return deserializeField(serialized);
9167
+ const FieldTypeToEmptyFieldMapping = {
9168
+ date: emptyDateField,
9169
+ number: emptyNumberField,
9170
+ boolean: emptyBooleanField,
9171
+ select: emptySelectField,
9172
+ string: emptyStringField,
9173
+ text: emptyTextField,
9174
+ custom: emptyCustomField,
9175
+ upload: emptyUploadField,
9176
+ // TODO: Underscore
9177
+ "multi-string": emptyMultiStringField,
9178
+ "multi-select": emptyMultiSelectField
9125
9179
  };
9126
- function formRevisionToSchema(formRevision, meta = {}) {
9127
- const { readonly = false } = meta;
9128
- return {
9129
- title: formRevision.title,
9130
- description: formRevision.description,
9131
- fields: formRevision.fields.map((serializedField) => deserialize(serializedField)),
9132
- meta: { readonly }
9133
- };
9134
- }
9135
- function valueIsFile(v) {
9136
- return Array.isArray(v) && v.some((v2) => v2 instanceof File || v2 instanceof Promise);
9137
- }
9138
- function isConditionMet(condition, value) {
9139
- if (!condition)
9140
- return true;
9141
- if (valueIsFile(value) || valueIsFile(condition.value))
9142
- throw new Error("Conditions do not support file uploads");
9143
- const valueAsPrimitive = Array.isArray(value) ? value.map((v) => typeof v === "string" ? v : v.value) : value;
9144
- const valueToCompare = Array.isArray(condition.value) ? condition.value.map((v) => typeof v === "string" ? v : v.value) : condition.value;
9145
- if (Array.isArray(valueToCompare) && Array.isArray(valueAsPrimitive)) {
9146
- for (const v of valueToCompare) {
9147
- if (!valueAsPrimitive.includes(v))
9148
- return false;
9149
- }
9150
- return true;
9180
+ const FieldInputCloner = React.memo(function FieldInputCloner2({ field, ...props }) {
9181
+ const [{ value: identifier }] = formik.useField(field.options.clonedFieldIdentifier);
9182
+ const deserializedField = React.useMemo(() => {
9183
+ const options = field.options.getFieldToClone(identifier);
9184
+ if (!options)
9185
+ return null;
9186
+ return deserialize(options);
9187
+ }, [field.options, identifier]);
9188
+ return useFieldInput(deserializedField, props);
9189
+ });
9190
+ class FieldInputClonerField extends CustomField {
9191
+ constructor(options) {
9192
+ super(options, FieldInputCloner);
9151
9193
  }
9152
- return valueToCompare === value;
9153
9194
  }
9154
9195
  const useFieldInput = (field, props) => {
9155
9196
  return React.useMemo(() => {
@@ -9192,7 +9233,7 @@ var __publicField = (obj, key, value) => {
9192
9233
  return /* @__PURE__ */ jsxRuntime.jsx(Card, { children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "3", children: [
9193
9234
  /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", children: [
9194
9235
  /* @__PURE__ */ jsxRuntime.jsx(Heading, { as: "h3", size: "3", children: label }),
9195
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$4.description, children: description2 })
9236
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$5.description, children: description2 })
9196
9237
  ] }),
9197
9238
  inputs
9198
9239
  ] }) });
@@ -9211,85 +9252,89 @@ var __publicField = (obj, key, value) => {
9211
9252
  this.condition = null;
9212
9253
  }
9213
9254
  }
9214
- static getFieldCreationSchema(options) {
9255
+ static getFieldCreationSchema(options, parentPath) {
9215
9256
  if (options.length === 0)
9216
9257
  return [];
9258
+ const path = parentPath ? `${parentPath}.` : "";
9217
9259
  return [
9218
- new BooleanField({
9219
- label: "Conditional",
9220
- description: "Conditionally show or hide this section.",
9221
- identifier: "conditional",
9222
- required: false
9223
- }),
9224
- // Declare a section that will hold options for the condition (if any).
9225
- new _FieldSection({
9226
- label: "Conditional settings",
9227
- identifier: "conditional-settings",
9228
- // This section will only be rendered if the above "Conditional" field is checked.
9229
- condition: {
9230
- identifier: "conditional",
9231
- value: true
9232
- },
9233
- // These are the options of the condition.
9234
- fields: [
9235
- // Declare a select field that will be used to select the field against which we will check the
9236
- // condition. This must be selected before the next field is rendered.
9237
- new SelectField({
9238
- label: "Field",
9239
- description: "The field to use for the condition.",
9240
- // The options (for the field against which we will check the condition) are all the labels of
9241
- // the fields in the previous section(s) (or fields declared before with no section) that
9242
- // support conditions. We pass in both the label and the identifier of each supported field. The
9243
- // identifier becomes the value of the option.
9244
- options: options.map((option) => {
9245
- if (!option.label)
9246
- return null;
9247
- if (option.type === "upload")
9248
- return null;
9249
- return {
9250
- label: option.label,
9251
- value: option.identifier
9252
- };
9253
- }).filter((option) => !!option),
9254
- identifier: "condition.identifier",
9255
- required: true
9256
- }),
9257
- // Declare a custom field that will be used to input a value for the condition. The value of the
9258
- // conditional field selected in the previous step must be equal to the value the user inputs into
9259
- // this field for the section to be rendered.
9260
- new FieldInputClonerField({
9261
- label: "Value",
9262
- identifier: "condition.value",
9263
- required: true,
9264
- clonedFieldIdentifier: "condition.identifier",
9265
- getFieldToClone(identifier) {
9266
- if (!identifier) {
9267
- return null;
9268
- }
9269
- const option = options.find((option2) => option2.identifier === identifier);
9270
- if (!option) {
9271
- console.error("Could not find field with identifier", identifier);
9272
- return null;
9260
+ {
9261
+ field: new BooleanField({
9262
+ label: "Conditionally render section",
9263
+ identifier: `${path}conditional`,
9264
+ required: false
9265
+ }),
9266
+ showDirectly: true
9267
+ },
9268
+ {
9269
+ // Declare a section that will hold options for the condition (if any).
9270
+ field: new _FieldSection({
9271
+ label: "Conditional settings",
9272
+ identifier: `${path}conditional-settings`,
9273
+ // This section will only be rendered if the above "Conditional" field is checked.
9274
+ condition: {
9275
+ identifier: `${path}conditional`,
9276
+ value: true
9277
+ },
9278
+ // These are the options of the condition.
9279
+ fields: [
9280
+ // Declare a select field that will be used to select the field against which we will check the
9281
+ // condition. This must be selected before the next field is rendered.
9282
+ new SelectField({
9283
+ label: "Field",
9284
+ description: "The field to use for the condition.",
9285
+ // The options (for the field against which we will check the condition) are all the labels of
9286
+ // the fields in the previous section(s) (or fields declared before with no section) that
9287
+ // support conditions. We pass in both the label and the identifier of each supported field. The
9288
+ // identifier becomes the value of the option.
9289
+ options: options.map((option) => {
9290
+ if (!option.label)
9291
+ return null;
9292
+ if (option.type === "upload")
9293
+ return null;
9294
+ return {
9295
+ label: option.label,
9296
+ value: option.identifier
9297
+ };
9298
+ }).filter((option) => !!option),
9299
+ identifier: `${path}condition.identifier`,
9300
+ required: true
9301
+ }),
9302
+ // Declare a custom field that will be used to input a value for the condition. The value of the
9303
+ // conditional field selected in the previous step must be equal to the value the user inputs into
9304
+ // this field for the section to be rendered.
9305
+ new FieldInputClonerField({
9306
+ label: "Value",
9307
+ identifier: `${path}condition.value`,
9308
+ required: true,
9309
+ clonedFieldIdentifier: `${path}condition.identifier`,
9310
+ getFieldToClone(identifier) {
9311
+ if (!identifier) {
9312
+ return null;
9313
+ }
9314
+ const option = options.find((option2) => option2.identifier === identifier);
9315
+ if (!option) {
9316
+ console.error("Could not find field with identifier", identifier);
9317
+ return null;
9318
+ }
9319
+ return {
9320
+ ...option,
9321
+ // Override some options to make it make sense in the context and to make it work with the framework.
9322
+ label: "Value",
9323
+ identifier: `${path}condition.value`,
9324
+ description: "The value to compare against.",
9325
+ required: option.type !== "boolean"
9326
+ };
9273
9327
  }
9274
- return {
9275
- ...option,
9276
- // Override some options to make it make sense in the context and to make it work with the framework.
9277
- label: "Value",
9278
- identifier: "condition.value",
9279
- description: "The value to compare against.",
9280
- required: option.type !== "boolean"
9281
- };
9282
- }
9283
- })
9284
- ]
9285
- })
9328
+ })
9329
+ ]
9330
+ }),
9331
+ showDirectly: false
9332
+ }
9286
9333
  ];
9287
9334
  }
9288
9335
  static deserialize(data) {
9289
9336
  if (data.type !== "section")
9290
9337
  throw new Error("Invalid type");
9291
- if (!Array.isArray(data.fields))
9292
- throw new Error(`Invalid fields: ${data.fields} (not an array)`);
9293
9338
  const fields = data.fields.map(deserializeField);
9294
9339
  return new _FieldSection({ ...data, fields });
9295
9340
  }
@@ -9323,6 +9368,175 @@ var __publicField = (obj, key, value) => {
9323
9368
  __publicField(_FieldSection, "fieldTypeName", "Section");
9324
9369
  __publicField(_FieldSection, "fieldTypeDescription", "Sections can be useful for grouping fields together. They can also be conditionally shown or hidden.");
9325
9370
  let FieldSection = _FieldSection;
9371
+ const deserializeField = (serializedField) => {
9372
+ const fieldType = serializedField.type;
9373
+ const fieldCls = FieldTypeToClsMapping[fieldType];
9374
+ return fieldCls.deserialize(serializedField);
9375
+ };
9376
+ const deserialize = (serialized) => {
9377
+ if (serialized.type === "section") {
9378
+ return FieldSection.deserialize(serialized);
9379
+ }
9380
+ return deserializeField(serialized);
9381
+ };
9382
+ function formRevisionToSchema(formRevision, meta = {}) {
9383
+ const { readonly = false } = meta;
9384
+ return {
9385
+ title: formRevision.title,
9386
+ description: formRevision.description,
9387
+ fields: formRevision.fields.map((serializedField) => deserialize(serializedField)),
9388
+ meta: { readonly }
9389
+ };
9390
+ }
9391
+ function valueIsFile(v) {
9392
+ return Array.isArray(v) && v.some((v2) => v2 instanceof File || v2 instanceof Promise);
9393
+ }
9394
+ const valueIsFormikUserFormRevision = (form) => {
9395
+ return "fields" in form;
9396
+ };
9397
+ function isConditionMet(condition, value) {
9398
+ if (!condition)
9399
+ return true;
9400
+ if (valueIsFile(value) || valueIsFile(condition.value))
9401
+ throw new Error("Conditions do not support file uploads");
9402
+ const valueAsPrimitive = Array.isArray(value) ? value.map((v) => typeof v === "string" ? v : v.value) : value;
9403
+ const valueToCompare = Array.isArray(condition.value) ? condition.value.map((v) => typeof v === "string" ? v : v.value) : condition.value;
9404
+ if (Array.isArray(valueToCompare) && Array.isArray(valueAsPrimitive)) {
9405
+ for (const v of valueToCompare) {
9406
+ if (!valueAsPrimitive.includes(v))
9407
+ return false;
9408
+ }
9409
+ return true;
9410
+ }
9411
+ return valueToCompare === value;
9412
+ }
9413
+ const emptyNumberField = {
9414
+ ...emptyBaseField,
9415
+ type: "number",
9416
+ minimum: Number.MIN_SAFE_INTEGER,
9417
+ maximum: Number.MAX_SAFE_INTEGER,
9418
+ integers: false
9419
+ };
9420
+ const _NumberField = class _NumberField extends BaseField {
9421
+ constructor(options) {
9422
+ const {
9423
+ minimum = Number.MIN_SAFE_INTEGER,
9424
+ maximum = Number.MAX_SAFE_INTEGER,
9425
+ integers = false,
9426
+ ...base
9427
+ } = options;
9428
+ super({ ...base, type: "number" });
9429
+ __publicField(this, "minimum");
9430
+ __publicField(this, "maximum");
9431
+ __publicField(this, "integers");
9432
+ this.minimum = minimum;
9433
+ this.maximum = maximum;
9434
+ this.integers = integers;
9435
+ }
9436
+ getValueFromChangeEvent(event) {
9437
+ const number = Number.parseFloat(event.target.value);
9438
+ if (Number.isNaN(number))
9439
+ return "";
9440
+ return number;
9441
+ }
9442
+ static getFieldCreationSchema(parentPath = "") {
9443
+ const path = parentPath && `${parentPath}.`;
9444
+ return [
9445
+ {
9446
+ field: new _NumberField({
9447
+ label: "Minimum",
9448
+ description: "Minimum value",
9449
+ integers: true,
9450
+ required: false,
9451
+ identifier: `${path}minimum`,
9452
+ formValidators: [this._validateMin(parentPath)]
9453
+ }),
9454
+ showDirectly: false
9455
+ },
9456
+ {
9457
+ field: new _NumberField({
9458
+ label: "Maximum",
9459
+ description: "Maximum value",
9460
+ integers: true,
9461
+ required: false,
9462
+ identifier: `${path}maximum`,
9463
+ formValidators: [this._validateMax(parentPath)]
9464
+ }),
9465
+ showDirectly: false
9466
+ },
9467
+ {
9468
+ field: new BooleanField({
9469
+ label: "Integers",
9470
+ description: "Whole numbers only",
9471
+ required: false,
9472
+ identifier: `${path}integers`
9473
+ }),
9474
+ showDirectly: false
9475
+ }
9476
+ ];
9477
+ }
9478
+ getFieldValidators() {
9479
+ const validators = super.getFieldValidators();
9480
+ const min = this.minimum;
9481
+ const max = this.maximum;
9482
+ if (typeof min === "number") {
9483
+ validators.push((value) => {
9484
+ if (typeof value === "number" && value < min) {
9485
+ return `Must be at least ${this.minimum}.`;
9486
+ }
9487
+ });
9488
+ }
9489
+ if (typeof max === "number") {
9490
+ validators.push((value) => {
9491
+ if (typeof value === "number" && value > max) {
9492
+ return `Must be at most ${this.maximum}.`;
9493
+ }
9494
+ });
9495
+ }
9496
+ if (this.integers) {
9497
+ validators.push((value) => {
9498
+ if (typeof value === "number" && !Number.isInteger(value)) {
9499
+ return "Must be a whole number.";
9500
+ }
9501
+ });
9502
+ }
9503
+ return validators;
9504
+ }
9505
+ serialize() {
9506
+ return {
9507
+ ...super._serialize(),
9508
+ minimum: this.minimum,
9509
+ maximum: this.maximum,
9510
+ integers: this.integers
9511
+ };
9512
+ }
9513
+ static deserialize(data) {
9514
+ if (data.type !== "number")
9515
+ throw new Error("Type mismatch.");
9516
+ return new _NumberField(data);
9517
+ }
9518
+ getInput(props) {
9519
+ return /* @__PURE__ */ jsxRuntime.jsx(NumberInput$1, { field: this, ...props });
9520
+ }
9521
+ };
9522
+ __publicField(_NumberField, "fieldTypeName", "Number");
9523
+ __publicField(_NumberField, "fieldTypeDescription", "Allows specifying a number within a given range.");
9524
+ __publicField(_NumberField, "Icon", FontFamilyIcon);
9525
+ __publicField(_NumberField, "_validateMin", (path) => (value, allValues) => {
9526
+ const field = valueIsFormikUserFormRevision(allValues) ? get(allValues, path) : allValues;
9527
+ if (typeof field.maximum === "number" && typeof value === "number" && field.maximum < value) {
9528
+ return "Minimum cannot be greater than minimum.";
9529
+ }
9530
+ return null;
9531
+ });
9532
+ __publicField(_NumberField, "_validateMax", (path) => (value, allValues) => {
9533
+ const field = valueIsFormikUserFormRevision(allValues) ? get(allValues, path) : allValues;
9534
+ if (typeof field.minimum === "number" && typeof value === "number" && field.minimum > value) {
9535
+ return "Maximum cannot be less than minimum.";
9536
+ }
9537
+ return null;
9538
+ });
9539
+ let NumberField = _NumberField;
9326
9540
  const hasKeys = (errors) => {
9327
9541
  return Object.keys(errors).length > 0;
9328
9542
  };
@@ -9405,7 +9619,7 @@ var __publicField = (obj, key, value) => {
9405
9619
  [schema.title]
9406
9620
  );
9407
9621
  const Description = React.useMemo(
9408
- () => typeof schema.description === "string" ? /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$4.description, children: schema.description }) : schema.description,
9622
+ () => typeof schema.description === "string" ? /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$5.description, children: schema.description }) : schema.description,
9409
9623
  [schema.description]
9410
9624
  );
9411
9625
  const inputs = useFieldInputs(schema.fields, { formId: formId2, disabled: readonly });
@@ -9421,10 +9635,23 @@ var __publicField = (obj, key, value) => {
9421
9635
  !hideDescription && Description
9422
9636
  ] }) }),
9423
9637
  inputs,
9424
- !readonly && /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { justify: "end", gap: "2", children: [
9425
- cancelText && /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "button", variant: "soft", onClick: onCancel, children: cancelText }),
9426
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "submit", disabled: !formik$1.isValid, children: submitText })
9427
- ] })
9638
+ !readonly && /* @__PURE__ */ jsxRuntime.jsxs(
9639
+ blocks.Flex,
9640
+ {
9641
+ justify: "end",
9642
+ gap: "2",
9643
+ align: "center",
9644
+ style: {
9645
+ position: "sticky",
9646
+ bottom: "0px",
9647
+ paddingBottom: "10px"
9648
+ },
9649
+ children: [
9650
+ cancelText && /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "button", variant: "soft", onClick: onCancel, children: cancelText }),
9651
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "submit", disabled: !formik$1.isValid, children: submitText })
9652
+ ]
9653
+ }
9654
+ )
9428
9655
  ] }) }) });
9429
9656
  })
9430
9657
  );
@@ -9469,7 +9696,7 @@ var __publicField = (obj, key, value) => {
9469
9696
  );
9470
9697
  const favoriteIcon = "_favoriteIcon_1bixi_1";
9471
9698
  const regularIcon = "_regularIcon_1bixi_9";
9472
- const styles$1 = {
9699
+ const styles$2 = {
9473
9700
  favoriteIcon,
9474
9701
  regularIcon
9475
9702
  };
@@ -9581,7 +9808,7 @@ var __publicField = (obj, key, value) => {
9581
9808
  /* @__PURE__ */ jsxRuntime.jsx(
9582
9809
  blocks.IconButton,
9583
9810
  {
9584
- className: classNames$1(form.favorite ? styles$1.favoriteIcon : styles$1.regularIcon),
9811
+ className: classNames$1(form.favorite ? styles$2.favoriteIcon : styles$2.regularIcon),
9585
9812
  variant: "ghost",
9586
9813
  onClick: handleFavoriteClick,
9587
9814
  "aria-label": form.favorite ? "Favorite form" : "Standard form",
@@ -9607,7 +9834,7 @@ var __publicField = (obj, key, value) => {
9607
9834
  };
9608
9835
  const submissionsContainer = "_submissionsContainer_9iirt_1";
9609
9836
  const stopHorizontalOverflow = "_stopHorizontalOverflow_9iirt_6";
9610
- const styles = {
9837
+ const styles$1 = {
9611
9838
  submissionsContainer,
9612
9839
  stopHorizontalOverflow
9613
9840
  };
@@ -9638,7 +9865,7 @@ var __publicField = (obj, key, value) => {
9638
9865
  }
9639
9866
  }, [submission, onSubmissionClick]);
9640
9867
  const row = /* @__PURE__ */ jsxRuntime.jsx(blocks.ButtonList.Item, { onClick: handleClick, asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { grow: "1", width: "100%", p: "2", gap: "2", justify: "between", children: [
9641
- /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { gap: "2", align: "center", className: styles.stopHorizontalOverflow, children: [
9868
+ /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { gap: "2", align: "center", className: styles$1.stopHorizontalOverflow, children: [
9642
9869
  /* @__PURE__ */ jsxRuntime.jsx(Avatar, { src: creatorProfileSrc, size: "1", fallback: creatorProfileFallback }),
9643
9870
  /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "2", noWrap: true, children: labelType === "creator" ? (createdBy || currentUser).username : revision.title })
9644
9871
  ] }),
@@ -9682,7 +9909,7 @@ var __publicField = (obj, key, value) => {
9682
9909
  return /* @__PURE__ */ jsxRuntime.jsx(
9683
9910
  blocks.ButtonList.Root,
9684
9911
  {
9685
- className: classNames$1(styles.submissionsContainer, className),
9912
+ className: classNames$1(styles$1.submissionsContainer, className),
9686
9913
  size: "small",
9687
9914
  variant,
9688
9915
  before: !compact && /* @__PURE__ */ jsxRuntime.jsxs(blocks.Text, { severity: "info", children: [
@@ -9706,23 +9933,22 @@ var __publicField = (obj, key, value) => {
9706
9933
  );
9707
9934
  });
9708
9935
  const PatchField = React.memo((props) => {
9709
- console.log("PatchField props:", props);
9710
9936
  const { name, render } = props;
9711
9937
  const { submitForm } = formik.useFormikContext();
9712
9938
  const [fieldProps, _meta, helpers] = formik.useField(name);
9713
- const ret = React.useMemo(() => {
9939
+ return React.useMemo(() => {
9714
9940
  const setValue = (value) => {
9715
9941
  void helpers.setValue(value, false);
9716
9942
  };
9717
9943
  return render({
9718
9944
  value: fieldProps.value,
9945
+ meta: _meta,
9719
9946
  setValue,
9720
9947
  patchValue: () => {
9721
9948
  void submitForm();
9722
9949
  }
9723
9950
  });
9724
- }, [submitForm, helpers, fieldProps.value, render]);
9725
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: ret });
9951
+ }, [render, fieldProps.value, _meta, submitForm, helpers]);
9726
9952
  });
9727
9953
  PatchField.displayName = "PatchField";
9728
9954
  const PatchFormProvider = React.memo(
@@ -9771,365 +9997,437 @@ var __publicField = (obj, key, value) => {
9771
9997
  return /* @__PURE__ */ jsxRuntime.jsx(formik.FormikProvider, { value: formik$1, children: /* @__PURE__ */ jsxRuntime.jsx("form", { ...rest, ref, onSubmit: formik$1.handleSubmit, children }) });
9772
9998
  })
9773
9999
  );
9774
- const CompleteFieldTypeToClsMapping = {
9775
- ...FieldTypeToClsMapping,
9776
- section: FieldSection
9777
- };
9778
- const FieldToChoose = React.memo(function FieldToChoose2(props) {
9779
- const { field, setFieldType } = props;
9780
- const typeName = field.fieldTypeName;
9781
- const description2 = field.fieldTypeDescription;
9782
- const Icon = field.Icon;
9783
- return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { gap: "4", align: "center", children: [
9784
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "button", variant: "surface", onClick: setFieldType, style: { width: "135px" }, children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { gap: "3", align: "center", grow: "1", children: [
9785
- /* @__PURE__ */ jsxRuntime.jsx(Icon, {}),
9786
- typeName
9787
- ] }) }),
9788
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { children: description2 })
9789
- ] });
9790
- });
10000
+ const formId = "form-builder";
9791
10001
  const fieldsToChoose = [
9792
10002
  ["string", "text"],
9793
10003
  ["select", "multi-select", "upload"],
9794
10004
  ["boolean", "date", "number", "multi-string"]
9795
10005
  ];
9796
- const indexOfLastFieldGroup = fieldsToChoose.length - 1;
9797
- const ChooseFieldToAdd = React.memo(function ChooseFieldToAdd2(props) {
9798
- const { setFieldType } = props;
9799
- return /* @__PURE__ */ jsxRuntime.jsx(blocks.Flex, { direction: "column", gap: "3", children: fieldsToChoose.map((fieldGroup, index2) => /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "3", children: [
9800
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Flex, { direction: "column", gap: "2", children: fieldGroup.map((identifier) => /* @__PURE__ */ jsxRuntime.jsx(
9801
- FieldToChoose,
9802
- {
9803
- field: FieldTypeToClsMapping[identifier],
9804
- setFieldType: () => {
9805
- setFieldType(identifier);
9806
- }
9807
- },
9808
- identifier
9809
- )) }),
9810
- index2 < indexOfLastFieldGroup && /* @__PURE__ */ jsxRuntime.jsx(blocks.Separator, { size: "4" })
9811
- ] }, index2)) });
9812
- });
9813
- const validateNewFieldName = (takenLabels) => {
9814
- return (value) => {
9815
- if (!value || typeof value !== "string")
9816
- return;
9817
- if (takenLabels.includes(value.trim())) {
9818
- return "This name is already taken.";
9819
- }
9820
- };
10006
+ const CompleteFieldTypeToClsMapping = {
10007
+ ...FieldTypeToClsMapping,
10008
+ section: FieldSection
9821
10009
  };
9822
- const commonFields = (takenLabels, type) => {
9823
- const base = [
9824
- new StringField({
9825
- label: "Label",
9826
- required: true,
9827
- maxLength: 200,
9828
- identifier: "label",
9829
- fieldValidators: [validateNewFieldName(takenLabels)]
9830
- }),
9831
- new TextField({
9832
- label: "Description",
9833
- required: false,
9834
- maxLength: 1e3,
9835
- identifier: "description"
9836
- })
9837
- ];
9838
- if (type === "section")
9839
- return base;
9840
- return [
9841
- ...base,
9842
- new BooleanField({ label: "Required", description: null, required: false, identifier: "required" })
9843
- ];
10010
+ const useFieldTypeItems = (onSelect = () => null) => {
10011
+ return React.useMemo(() => {
10012
+ return fieldsToChoose.map((fieldGroup) => {
10013
+ return fieldGroup.map((identifier) => {
10014
+ const field = FieldTypeToClsMapping[identifier];
10015
+ const Icon = field.Icon;
10016
+ return {
10017
+ content: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { align: "center", gap: "2", children: [
10018
+ /* @__PURE__ */ jsxRuntime.jsx(Icon, {}),
10019
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { children: field.fieldTypeName })
10020
+ ] }, identifier),
10021
+ value: identifier,
10022
+ onSelect: () => {
10023
+ onSelect(identifier);
10024
+ }
10025
+ };
10026
+ });
10027
+ });
10028
+ }, [onSelect]);
9844
10029
  };
9845
- const FieldOptionsForm = React.memo(function FieldOptionsForm2(props) {
9846
- const { fieldType, handleCancel, handleCreateField, handleDirtyChange, defaultField, conditionalSourceFields } = props;
9847
- const fieldCls = CompleteFieldTypeToClsMapping[fieldType];
9848
- const formik$1 = formik.useFormikContext();
9849
- const schema = React.useMemo(() => {
9850
- const takenFieldLabels = getTakenFieldLabels(formik$1.values.fields).filter((id) => id !== (defaultField == null ? void 0 : defaultField.label));
9851
- let fields = commonFields(takenFieldLabels, fieldType);
9852
- if (fieldCls === FieldSection) {
9853
- if (conditionalSourceFields === void 0) {
9854
- throw new Error("Conditional source fields must be provided when changing sections.");
10030
+ const FieldTypeDropdown = React.memo((props) => {
10031
+ const { setFieldType, children } = props;
10032
+ const fieldTypeItems = useFieldTypeItems(setFieldType);
10033
+ return /* @__PURE__ */ jsxRuntime.jsx(blocks.DropdownItemMenu, { trigger: children, items: fieldTypeItems.flat() });
10034
+ });
10035
+ FieldTypeDropdown.displayName = "FieldTypeDropdown";
10036
+ const forMobile = (mobile, display) => ({
10037
+ initial: mobile ? display : "none",
10038
+ sm: mobile ? "none" : display
10039
+ });
10040
+ const FieldActions = React.memo((props) => {
10041
+ const { index: index2, sectionIndex, type, remove: remove2, duplicate, addAfter, move } = props;
10042
+ if (type !== "section" && !addAfter) {
10043
+ throw new Error("addAfter is required for non-section fields");
10044
+ }
10045
+ const { values } = formik.useFormikContext();
10046
+ const fieldTypeItems = useFieldTypeItems(addAfter);
10047
+ const [actions, mobileActions] = React.useMemo(() => {
10048
+ const getActions = (isMobile) => {
10049
+ const actions2 = [
10050
+ {
10051
+ Icon: TrashIcon,
10052
+ buttonProps: { onClick: remove2 },
10053
+ key: "delete",
10054
+ text: "Delete"
10055
+ },
10056
+ {
10057
+ Icon: CopyIcon,
10058
+ key: "duplicate",
10059
+ text: "Duplicate",
10060
+ buttonProps: { onClick: duplicate }
10061
+ }
10062
+ ];
10063
+ if (type !== "section") {
10064
+ actions2.push({
10065
+ // We want to show a dropdown with field types if "Add after" is clicked
10066
+ isComponent: true,
10067
+ Component: isMobile ? /* @__PURE__ */ jsxRuntime.jsx(blocks.DropdownMenuItemGroup, { items: fieldTypeItems.flat() }) : /* @__PURE__ */ jsxRuntime.jsx(FieldTypeDropdown, { setFieldType: addAfter, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", variant: "ghost", "aria-label": "Add after", children: /* @__PURE__ */ jsxRuntime.jsx(PlusIcon, {}) }) }),
10068
+ Icon: PlusIcon,
10069
+ key: "add",
10070
+ text: "Add after"
10071
+ });
9855
10072
  }
9856
- fields = fields.concat(fieldCls.getFieldCreationSchema(conditionalSourceFields));
9857
- } else {
9858
- if (!(fieldCls.prototype instanceof BaseField)) {
9859
- throw new Error(`Field must be an instance of BaseField. Got ${fieldCls.toString()}.`);
10073
+ if (sectionIndex === void 0 && index2 !== 0 || sectionIndex !== void 0 && (sectionIndex !== 0 || index2 !== 0)) {
10074
+ actions2.push({
10075
+ Icon: ArrowUpIcon,
10076
+ key: "moveUp",
10077
+ text: "Move up",
10078
+ buttonProps: {
10079
+ onClick: () => {
10080
+ move("up");
10081
+ }
10082
+ }
10083
+ });
9860
10084
  }
9861
- fields = [...fields, ...fieldCls.getFieldCreationSchema()];
9862
- }
9863
- return {
9864
- fields,
9865
- meta: { readonly: false },
9866
- // using the dialog title as the form title
9867
- title: null
10085
+ if (sectionIndex === void 0 && index2 !== values.fields.length - 1 || sectionIndex !== void 0 && (sectionIndex < values.fields.length - 1 || index2 !== values.fields[sectionIndex].fields.length - 1)) {
10086
+ actions2.push({
10087
+ Icon: ArrowDownIcon,
10088
+ key: "moveDown",
10089
+ text: "Move down",
10090
+ buttonProps: {
10091
+ onClick: () => {
10092
+ move("down");
10093
+ }
10094
+ }
10095
+ });
10096
+ }
10097
+ return actions2;
9868
10098
  };
9869
- }, [formik$1.values.fields, fieldType, fieldCls, defaultField == null ? void 0 : defaultField.label, conditionalSourceFields]);
10099
+ return [getActions(false), getActions(true)];
10100
+ }, [addAfter, duplicate, fieldTypeItems, index2, move, remove2, sectionIndex, type, values.fields]);
10101
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
10102
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Flex, { gap: "4", display: forMobile(false, "flex"), children: actions.map((Action) => {
10103
+ if (Action.isComponent) {
10104
+ return Action.Component;
10105
+ }
10106
+ return /* @__PURE__ */ jsxRuntime.jsx(
10107
+ blocks.IconButton,
10108
+ {
10109
+ type: "button",
10110
+ variant: "ghost",
10111
+ severity: Action.key.startsWith("move") ? "info" : "primary",
10112
+ "aria-label": Action.text,
10113
+ ...Action.buttonProps,
10114
+ children: /* @__PURE__ */ jsxRuntime.jsx(Action.Icon, {})
10115
+ },
10116
+ Action.key
10117
+ );
10118
+ }) }),
10119
+ /* @__PURE__ */ jsxRuntime.jsx(Box, { display: forMobile(true, "block"), children: /* @__PURE__ */ jsxRuntime.jsxs(
10120
+ blocks.DropdownMenu,
10121
+ {
10122
+ trigger: /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { variant: "ghost", "aria-label": "Actions menu", children: /* @__PURE__ */ jsxRuntime.jsx(DotsVerticalIcon, {}) }),
10123
+ children: [
10124
+ /* @__PURE__ */ jsxRuntime.jsx(
10125
+ blocks.DropdownMenuItemGroup,
10126
+ {
10127
+ items: mobileActions.filter((Action) => !Action.isComponent).map((Action) => {
10128
+ var _a2;
10129
+ return {
10130
+ content: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { gap: "2", align: "center", children: [
10131
+ /* @__PURE__ */ jsxRuntime.jsx(Action.Icon, {}),
10132
+ Action.text
10133
+ ] }, Action.key),
10134
+ value: Action.key,
10135
+ onSelect: (_a2 = Action.buttonProps) == null ? void 0 : _a2.onClick
10136
+ };
10137
+ })
10138
+ }
10139
+ ),
10140
+ /* @__PURE__ */ jsxRuntime.jsx(
10141
+ blocks.DropdownMenuSubMenuGroup,
10142
+ {
10143
+ items: mobileActions.filter((Action) => Action.isComponent).map((Action) => ({
10144
+ content: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { gap: "2", align: "center", children: [
10145
+ /* @__PURE__ */ jsxRuntime.jsx(Action.Icon, {}),
10146
+ Action.text
10147
+ ] }, Action.key),
10148
+ subContent: Action.Component,
10149
+ triggerIndicator: null
10150
+ }))
10151
+ }
10152
+ )
10153
+ ]
10154
+ }
10155
+ ) })
10156
+ ] });
10157
+ });
10158
+ FieldActions.displayName = "FieldActions";
10159
+ const description = "_description_17zed_1";
10160
+ const styles = {
10161
+ description
10162
+ };
10163
+ const FieldSettingsPopover = React.memo((props) => {
10164
+ const { popoverInputs, hasError } = props;
9870
10165
  return /* @__PURE__ */ jsxRuntime.jsx(
9871
- FormRenderer,
10166
+ blocks.Popover,
9872
10167
  {
9873
- schema,
9874
- values: defaultField,
9875
- onSubmit: handleCreateField,
9876
- cancelText: defaultField ? void 0 : "Back",
9877
- onCancel: handleCancel,
9878
- onDirtyChange: handleDirtyChange
10168
+ size: "1",
10169
+ trigger: /* @__PURE__ */ jsxRuntime.jsxs(
10170
+ blocks.Button,
10171
+ {
10172
+ variant: "soft",
10173
+ size: "small",
10174
+ "aria-label": "settings",
10175
+ ...hasError && { severity: "danger" },
10176
+ hoverEffects: ["spin90Clockwise"],
10177
+ children: [
10178
+ /* @__PURE__ */ jsxRuntime.jsx(GearIcon, {}),
10179
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { children: "Settings" })
10180
+ ]
10181
+ },
10182
+ "settings"
10183
+ ),
10184
+ children: () => /* @__PURE__ */ jsxRuntime.jsx(blocks.Flex, { direction: "column", style: { maxWidth: "240px" }, children: popoverInputs })
9879
10185
  }
9880
10186
  );
9881
10187
  });
9882
- const FieldBuilder = React.memo(function FieldBuilder2(props) {
9883
- const { parentPath, index: index2, isOpen, setIsOpen, initial, editing, conditionalSourceFields } = props;
9884
- const [fieldType, setFieldType] = React.useState();
9885
- const [formIsDirty, setFormIsDirty] = React.useState(false);
9886
- const type = (initial == null ? void 0 : initial.type) ?? fieldType;
9887
- const typeName = type ? CompleteFieldTypeToClsMapping[type].fieldTypeName : void 0;
9888
- const { setFieldValue, values } = formik.useFormikContext();
9889
- if (editing && !initial)
9890
- throw new Error("Initial field must be provided if editing is true.");
9891
- const openConfirmDiscardChangesDialog = blocks.useDiscardAlertDialog();
9892
- const showChooseField = !type && !editing && !initial;
9893
- const title2 = showChooseField ? "Choose a field type" : `${typeName} settings`;
9894
- const description2 = showChooseField ? "Select a field type to add to this section." : (typeName == null ? void 0 : typeName.toLowerCase()) === "section" ? "Customize your section" : `Customize your ${typeName == null ? void 0 : typeName.toLowerCase()} field.`;
9895
- const handleCancel = React.useCallback(() => {
9896
- setFieldType(void 0);
9897
- setFormIsDirty(false);
10188
+ FieldSettingsPopover.displayName = "FieldSettingsPopover";
10189
+ const FieldBuilder = React.memo((props) => {
10190
+ var _a2, _b, _c, _d, _e, _f;
10191
+ const { parentPath, index: index2, initial, conditionalSourceFields } = props;
10192
+ const RADIX_SM_MIN_WIDTH = 576;
10193
+ const [isLargeScreen, setIsLargeScreen] = React.useState(
10194
+ window.matchMedia(`(min-width: ${RADIX_SM_MIN_WIDTH}px)`).matches
10195
+ );
10196
+ React.useEffect(() => {
10197
+ const mediaQuery = window.matchMedia(`(min-width: ${RADIX_SM_MIN_WIDTH}px)`);
10198
+ const handleMediaQueryChange = (event) => {
10199
+ setIsLargeScreen(event.matches);
10200
+ };
10201
+ mediaQuery.addEventListener("change", handleMediaQueryChange);
10202
+ return () => {
10203
+ mediaQuery.removeEventListener("change", handleMediaQueryChange);
10204
+ };
9898
10205
  }, []);
9899
- const handleCloseDialog = React.useCallback(() => {
9900
- if (!formIsDirty) {
9901
- setFieldType(void 0);
9902
- setIsOpen(false);
9903
- } else {
9904
- openConfirmDiscardChangesDialog({
9905
- onDiscard: () => {
9906
- setFieldType(void 0);
9907
- setIsOpen(false);
9908
- }
9909
- });
10206
+ const { values, setFieldValue, errors } = formik.useFormikContext();
10207
+ const fieldTypeItems = useFieldTypeItems();
10208
+ const isSection = React.useCallback((field) => {
10209
+ return field.type === "section";
10210
+ }, []);
10211
+ React.useEffect(() => {
10212
+ if (isSection(initial) && !initial.conditional) {
10213
+ void setFieldValue(`${parentPath}.${index2}.condition`, null).then();
9910
10214
  }
9911
- }, [formIsDirty, openConfirmDiscardChangesDialog, setIsOpen]);
9912
- const handleCreateField = React.useCallback(
9913
- (form) => {
9914
- const { label } = form;
9915
- if (!type)
9916
- throw new Error("Field type must be selected before creating a field.");
9917
- if (!label || typeof label !== "string")
9918
- throw new Error("Label must be provided before creating a field.");
9919
- const field = deserialize({
9920
- type,
9921
- ...form,
9922
- identifier: makeIdentifier(form.identifier, label)
9923
- }).serialize();
9924
- const parent = get(values, parentPath);
9925
- if (parent === void 0) {
9926
- throw new Error("Parent path must point to an existing field.");
9927
- }
9928
- let newFields;
9929
- if (!Array.isArray(parent))
9930
- throw new Error("Parent path must point to an array.");
9931
- if (editing) {
9932
- newFields = replace(parent, index2, field);
9933
- } else {
9934
- newFields = insert(parent, index2, field);
9935
- }
9936
- void setFieldValue(parentPath, newFields).then();
9937
- setIsOpen(false);
10215
+ }, [index2, initial, isSection, parentPath, setFieldValue]);
10216
+ const conditionLabel = React.useMemo(
10217
+ () => {
10218
+ var _a3, _b2;
10219
+ return isSection(initial) ? (_b2 = findFieldByIdentifier(values.fields, (_a3 = initial.condition) == null ? void 0 : _a3.identifier)) == null ? void 0 : _b2.label : void 0;
9938
10220
  },
9939
- [type, values, parentPath, editing, setFieldValue, setIsOpen, index2]
10221
+ [initial, isSection, values.fields]
9940
10222
  );
9941
- const handleDirtyChange = React.useCallback((dirty) => {
9942
- setFormIsDirty(dirty);
9943
- }, []);
9944
- const dialogContent = React.useCallback(() => {
9945
- if (showChooseField) {
9946
- return /* @__PURE__ */ jsxRuntime.jsx(ChooseFieldToAdd, { setFieldType });
9947
- }
9948
- return /* @__PURE__ */ jsxRuntime.jsx(
9949
- FieldOptionsForm,
9950
- {
9951
- conditionalSourceFields,
9952
- handleCancel,
9953
- handleCreateField,
9954
- fieldType: type,
9955
- defaultField: initial,
9956
- handleDirtyChange
10223
+ const conditionComparison = isSection(initial) ? Array.isArray((_a2 = initial.condition) == null ? void 0 : _a2.value) ? "contains all of" : "equals" : void 0;
10224
+ let conditionValue = void 0;
10225
+ if (isSection(initial)) {
10226
+ if (valueIsFile((_b = initial.condition) == null ? void 0 : _b.value)) {
10227
+ throw new Error("File values are not supported for conditions.");
10228
+ }
10229
+ conditionValue = Array.isArray((_c = initial.condition) == null ? void 0 : _c.value) ? initial.condition.value.map((v) => typeof v === "string" ? v : v.label).join(", ") : (_e = (_d = initial.condition) == null ? void 0 : _d.value) == null ? void 0 : _e.toString();
10230
+ }
10231
+ const type = initial.type;
10232
+ const fieldCls = CompleteFieldTypeToClsMapping[type];
10233
+ const [directlyShownFields, popoverFields] = React.useMemo(() => {
10234
+ let directlyShownFields2 = [];
10235
+ let popoverFields2 = [];
10236
+ if (fieldCls === FieldSection) {
10237
+ if (conditionalSourceFields === void 0) {
10238
+ throw new Error("Conditional source fields must be provided when changing sections.");
9957
10239
  }
9958
- );
9959
- }, [conditionalSourceFields, handleCancel, handleCreateField, handleDirtyChange, initial, showChooseField, type]);
9960
- return /* @__PURE__ */ jsxRuntime.jsx(
9961
- blocks.Dialog,
9962
- {
9963
- title: title2,
9964
- description: description2,
9965
- content: dialogContent,
9966
- open: isOpen,
9967
- onOpenChange: handleCloseDialog
9968
- }
9969
- );
9970
- });
9971
- const forMobile = (mobile, display) => ({
9972
- initial: mobile ? display : "none",
9973
- sm: mobile ? "none" : display
9974
- });
9975
- const FieldActions = React.memo(function FieldActions2(props) {
9976
- const { remove: remove2, dragHandleProps, editProps, insertAfterProps, duplicateProps } = props;
9977
- const [isEditDialogOpen, setIsEditDialogOpen] = React.useState(false);
9978
- const [isDuplicateDialogOpen, setIsDuplicateDialogOpen] = React.useState(false);
9979
- const [isAddDialogOpen, setIsAddDialogOpen] = React.useState(false);
9980
- const actions = React.useMemo(
9981
- () => [
9982
- {
9983
- SelectedContent: FieldBuilder,
9984
- selectedContentProps: { ...editProps, isOpen: isEditDialogOpen, setIsOpen: setIsEditDialogOpen },
9985
- Icon: Pencil1Icon,
9986
- text: "Edit",
9987
- buttonProps: {
9988
- onClick: () => {
9989
- setIsEditDialogOpen(true);
9990
- }
9991
- }
9992
- },
9993
- {
9994
- Icon: TrashIcon,
9995
- buttonProps: {
9996
- onClick: remove2
9997
- },
9998
- text: "Delete"
9999
- },
10000
- {
10001
- SelectedContent: FieldBuilder,
10002
- selectedContentProps: {
10003
- ...duplicateProps,
10004
- isOpen: isDuplicateDialogOpen,
10005
- setIsOpen: setIsDuplicateDialogOpen
10006
- },
10007
- Icon: CopyIcon,
10008
- text: "Duplicate",
10009
- buttonProps: {
10010
- onClick: () => {
10011
- setIsDuplicateDialogOpen(true);
10012
- }
10013
- }
10014
- },
10015
- {
10016
- SelectedContent: FieldBuilder,
10017
- selectedContentProps: {
10018
- ...insertAfterProps,
10019
- isOpen: isAddDialogOpen,
10020
- setIsOpen: setIsAddDialogOpen
10021
- },
10022
- Icon: PlusIcon,
10023
- text: "Add after",
10024
- buttonProps: {
10025
- onClick: () => {
10026
- setIsAddDialogOpen(true);
10027
- }
10028
- }
10029
- },
10030
- {
10031
- // Wrapping icon in a div so that the asChild turns the button into a div
10032
- // so that the drag handle props are not applied to the icon
10033
- // Note: b/c the <button> does not handle the space-press event correctly
10034
- Icon: (props2) => /* @__PURE__ */ jsxRuntime.jsx("div", { ...props2, children: /* @__PURE__ */ jsxRuntime.jsx(DragHandleDots2Icon, {}) }),
10035
- text: "Reorder",
10036
- disableOnMobile: true,
10037
- buttonProps: { ...dragHandleProps, asChild: true }
10240
+ const fieldObject = fieldCls.getFieldCreationSchema(conditionalSourceFields, `${parentPath}.${index2}`);
10241
+ directlyShownFields2 = directlyShownFields2.concat(
10242
+ fieldObject.filter((field) => field.showDirectly).map((field) => field.field)
10243
+ );
10244
+ popoverFields2 = popoverFields2.concat(
10245
+ fieldObject.filter((field) => !field.showDirectly).map((field) => field.field)
10246
+ );
10247
+ } else {
10248
+ if (!(fieldCls.prototype instanceof BaseField)) {
10249
+ throw new Error(`Field must be an instance of BaseField. Got ${fieldCls.toString()}.`);
10038
10250
  }
10039
- ],
10040
- [
10041
- dragHandleProps,
10042
- duplicateProps,
10043
- editProps,
10044
- insertAfterProps,
10045
- isAddDialogOpen,
10046
- isDuplicateDialogOpen,
10047
- isEditDialogOpen,
10048
- remove2
10049
- ]
10050
- );
10051
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
10052
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Flex, { gap: "4", display: forMobile(false, "flex"), children: actions.map((action) => {
10053
- return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
10251
+ const fieldObject = fieldCls.getFieldCreationSchema(
10252
+ `${parentPath}.${index2}`
10253
+ );
10254
+ if (isLargeScreen) {
10255
+ directlyShownFields2 = [
10256
+ ...directlyShownFields2,
10257
+ ...fieldObject.filter((field) => field.showDirectly).map((field) => field.field)
10258
+ ];
10259
+ popoverFields2 = [
10260
+ ...popoverFields2,
10261
+ ...fieldObject.filter((field) => !field.showDirectly).map((field) => field.field)
10262
+ ];
10263
+ } else {
10264
+ popoverFields2 = [...popoverFields2, ...fieldObject.map((field) => field.field)];
10265
+ }
10266
+ }
10267
+ return [directlyShownFields2, popoverFields2];
10268
+ }, [fieldCls, conditionalSourceFields, parentPath, index2, isLargeScreen]);
10269
+ const directlyShownInputs = useFieldInputs(directlyShownFields, {
10270
+ formId,
10271
+ disabled: false,
10272
+ ...fieldCls === FieldSection && { size: "2" }
10273
+ });
10274
+ const popoverInputs = useFieldInputs(popoverFields, {
10275
+ formId,
10276
+ disabled: false
10277
+ });
10278
+ let showPopoverInputs = popoverFields.length > 0;
10279
+ if (isSection(initial) && popoverFields.length > 0) {
10280
+ showPopoverInputs = initial.conditional;
10281
+ }
10282
+ const popoverHasErrors = popoverFields.some((field) => {
10283
+ const error = get(errors, fieldCls === FieldSection ? `${parentPath}.${index2}.condition` : field.getId());
10284
+ return error && (typeof error !== "object" || hasKeys(error));
10285
+ });
10286
+ return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { align: "center", grow: "1", children: [
10287
+ /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", children: [
10288
+ fieldCls === FieldSection && /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "1", children: [
10289
+ directlyShownFields.length > 0 && directlyShownInputs,
10290
+ /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { align: "center", gap: "2", children: [
10291
+ showPopoverInputs && /* @__PURE__ */ jsxRuntime.jsx(FieldSettingsPopover, { popoverInputs, hasError: popoverHasErrors }),
10292
+ isSection(initial) && initial.conditional && /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "1", severity: popoverHasErrors ? "danger" : "primary", children: /* @__PURE__ */ jsxRuntime.jsxs(Em, { children: [
10293
+ "Display only if ",
10294
+ /* @__PURE__ */ jsxRuntime.jsx(Strong, { children: conditionLabel }),
10295
+ " ",
10296
+ conditionComparison,
10297
+ " ",
10298
+ /* @__PURE__ */ jsxRuntime.jsx(Strong, { children: conditionValue })
10299
+ ] }) })
10300
+ ] })
10301
+ ] }),
10302
+ fieldCls !== FieldSection && /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "2", children: [
10054
10303
  /* @__PURE__ */ jsxRuntime.jsx(
10055
- blocks.IconButton,
10304
+ PatchField,
10056
10305
  {
10057
- type: "button",
10058
- variant: "ghost",
10059
- "aria-label": action.text,
10060
- ...action.buttonProps,
10061
- children: /* @__PURE__ */ jsxRuntime.jsx(action.Icon, {})
10306
+ name: `${parentPath}.${index2}.required`,
10307
+ render: ({ setValue, value }) => /* @__PURE__ */ jsxRuntime.jsx(
10308
+ blocks.Checkbox,
10309
+ {
10310
+ checked: value,
10311
+ onCheckedChange: setValue,
10312
+ label: /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "2", children: "Required field" }),
10313
+ alwaysShow: true
10314
+ }
10315
+ )
10062
10316
  }
10063
10317
  ),
10064
- action.SelectedContent && /* @__PURE__ */ jsxRuntime.jsx(action.SelectedContent, { ...action.selectedContentProps })
10065
- ] }, action.text);
10066
- }) }),
10067
- /* @__PURE__ */ jsxRuntime.jsx(Box, { display: forMobile(true, "block"), children: /* @__PURE__ */ jsxRuntime.jsx(
10068
- blocks.DropdownItemMenu,
10069
- {
10070
- trigger: /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { variant: "ghost", "aria-label": "Actions menu", children: /* @__PURE__ */ jsxRuntime.jsx(DotsVerticalIcon, {}) }),
10071
- items: actions.map((action) => {
10072
- if (action.disableOnMobile)
10073
- return null;
10074
- return {
10075
- ...action.buttonProps,
10076
- onSelect: (event) => {
10077
- var _a2, _b;
10078
- (_b = (_a2 = action.buttonProps) == null ? void 0 : _a2.onClick) == null ? void 0 : _b.call(
10079
- _a2,
10080
- // TODO: Clean up types
10081
- event
10082
- );
10083
- },
10084
- content: /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
10085
- /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { gap: "2", align: "center", children: [
10086
- /* @__PURE__ */ jsxRuntime.jsx(action.Icon, {}),
10087
- action.text
10088
- ] }),
10089
- action.SelectedContent && /* @__PURE__ */ jsxRuntime.jsx(action.SelectedContent, { ...action.selectedContentProps })
10090
- ] }, action.text)
10091
- };
10092
- }).filter((x) => x !== null)
10093
- }
10094
- ) })
10318
+ /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { align: "center", gap: "3", children: [
10319
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Badge, { style: { width: "fit-content", height: "24px" }, children: (_f = fieldTypeItems.flat().find((item) => item.value === type)) == null ? void 0 : _f.content }),
10320
+ showPopoverInputs && /* @__PURE__ */ jsxRuntime.jsx(FieldSettingsPopover, { popoverInputs, hasError: popoverHasErrors })
10321
+ ] })
10322
+ ] }),
10323
+ /* @__PURE__ */ jsxRuntime.jsx(
10324
+ PatchField,
10325
+ {
10326
+ name: `${parentPath}.${index2}.label`,
10327
+ render: ({ setValue, value }) => /* @__PURE__ */ jsxRuntime.jsx(
10328
+ blocks.Input,
10329
+ {
10330
+ className: styles.Input,
10331
+ placeholder: `Enter a ${type === "section" ? "section" : "field"} label`,
10332
+ value,
10333
+ onChange: (event) => {
10334
+ setValue(event.target.value);
10335
+ },
10336
+ maxLength: 200,
10337
+ showInputLength: false,
10338
+ variant: "ghost",
10339
+ size: "large"
10340
+ }
10341
+ )
10342
+ }
10343
+ ),
10344
+ /* @__PURE__ */ jsxRuntime.jsx(
10345
+ PatchField,
10346
+ {
10347
+ name: `${parentPath}.${index2}.description`,
10348
+ render: ({ setValue, value }) => /* @__PURE__ */ jsxRuntime.jsx(
10349
+ blocks.TextArea,
10350
+ {
10351
+ style: { minHeight: "max-content" },
10352
+ placeholder: `Enter a ${type === "section" ? "section" : "field"} description`,
10353
+ value,
10354
+ onChange: (event) => {
10355
+ setValue(event.target.value);
10356
+ },
10357
+ resize: "vertical",
10358
+ maxLength: 1e3,
10359
+ showInputLength: false,
10360
+ variant: "ghost"
10361
+ }
10362
+ )
10363
+ }
10364
+ )
10365
+ ] }),
10366
+ fieldCls !== FieldSection && directlyShownFields.length > 0 && directlyShownInputs
10095
10367
  ] });
10096
10368
  });
10097
- const formId = "form-builder";
10098
- const FieldWithActions = React.memo(function FieldWithActions2(props) {
10369
+ FieldBuilder.displayName = "FieldBuilder";
10370
+ const FieldWithActions = React.memo((props) => {
10099
10371
  const { field, index: index2, sectionIndex, takenLabels, remove: remove2 } = props;
10100
- const deserializedField = React.useMemo(() => deserialize(field), [field]);
10101
- const input = useFieldInput(deserializedField, { formId, disabled: true });
10102
- const duplicateField = React.useCallback(
10103
- (field2) => {
10104
- const fieldLabel = field2.label ?? "Untitled field";
10105
- return { ...field2, label: incrementFieldLabel(fieldLabel, takenLabels), identifier: "" };
10106
- },
10107
- [takenLabels]
10108
- );
10372
+ const { setFieldValue, values } = formik.useFormikContext();
10373
+ const { reorderField } = useFieldReordering();
10374
+ const parentPath = `fields.${sectionIndex}.fields`;
10109
10375
  const editFieldProps = React.useMemo(
10110
10376
  () => ({
10111
10377
  index: index2,
10112
- parentPath: `fields.${sectionIndex}.fields`,
10113
- initial: field,
10114
- editing: true
10378
+ parentPath,
10379
+ initial: field
10115
10380
  }),
10116
- [field, index2, sectionIndex]
10381
+ [field, index2, parentPath]
10117
10382
  );
10118
- const duplicateFieldProps = React.useMemo(
10119
- () => ({
10120
- parentPath: `fields.${sectionIndex}.fields`,
10121
- index: index2 + 1,
10122
- initial: duplicateField(field)
10123
- }),
10124
- [duplicateField, field, index2, sectionIndex]
10383
+ const duplicateField = React.useCallback(() => {
10384
+ const label = field.label ?? "Unlabelled field";
10385
+ const duplicatedField = {
10386
+ ...field,
10387
+ label: incrementFieldLabel(label, takenLabels)
10388
+ };
10389
+ createNewField(parentPath, index2 + 1, duplicatedField, values, setFieldValue);
10390
+ }, [field, takenLabels, parentPath, index2, values, setFieldValue]);
10391
+ const createFieldAfter = React.useCallback(
10392
+ (type) => {
10393
+ if (type === "section") {
10394
+ throw new Error("Section type unexpected");
10395
+ }
10396
+ createNewField(
10397
+ parentPath,
10398
+ index2 + 1,
10399
+ FieldTypeToEmptyFieldMapping[type],
10400
+ values,
10401
+ setFieldValue
10402
+ );
10403
+ },
10404
+ [parentPath, index2, values, setFieldValue]
10125
10405
  );
10126
- const insertAfterProps = React.useMemo(
10127
- () => ({
10128
- parentPath: `fields.${sectionIndex}.fields`,
10129
- index: index2 + 1,
10130
- initial: void 0
10131
- }),
10132
- [index2, sectionIndex]
10406
+ const moveField = React.useCallback(
10407
+ (direction) => {
10408
+ const srcSectionIndex = sectionIndex;
10409
+ const srcSection = values.fields[srcSectionIndex];
10410
+ let destSectionIndex = sectionIndex;
10411
+ let destFieldIndex = direction === "up" ? index2 - 1 : index2 + 1;
10412
+ if (direction === "up" && index2 === 0) {
10413
+ destSectionIndex = sectionIndex - 1;
10414
+ destFieldIndex = values.fields[destSectionIndex].fields.length;
10415
+ } else if (direction === "down" && index2 === srcSection.fields.length - 1) {
10416
+ destSectionIndex = sectionIndex + 1;
10417
+ destFieldIndex = 0;
10418
+ }
10419
+ const destSection = values.fields[destSectionIndex];
10420
+ reorderField(
10421
+ srcSection,
10422
+ srcSectionIndex,
10423
+ index2,
10424
+ destSection,
10425
+ destSectionIndex,
10426
+ destFieldIndex,
10427
+ setFieldValue
10428
+ );
10429
+ },
10430
+ [sectionIndex, values.fields, index2, reorderField, setFieldValue]
10133
10431
  );
10134
10432
  return /* @__PURE__ */ jsxRuntime.jsx(dnd.Draggable, { draggableId: field.identifier, index: index2, children: (draggableProvided) => /* @__PURE__ */ jsxRuntime.jsx(
10135
10433
  Card,
@@ -10137,30 +10435,38 @@ var __publicField = (obj, key, value) => {
10137
10435
  ref: draggableProvided.innerRef,
10138
10436
  ...draggableProvided.draggableProps,
10139
10437
  ...draggableProvided.dragHandleProps,
10438
+ style: {
10439
+ ...draggableProvided.draggableProps.style,
10440
+ backgroundColor: "var(--accent-1)",
10441
+ borderColor: "var(--accent-3)"
10442
+ },
10140
10443
  mb: "4",
10141
10444
  children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { gap: "4", justify: "between", align: "center", children: [
10142
- input,
10445
+ /* @__PURE__ */ jsxRuntime.jsx(FieldBuilder, { ...editFieldProps }),
10143
10446
  /* @__PURE__ */ jsxRuntime.jsx(
10144
10447
  FieldActions,
10145
10448
  {
10449
+ index: index2,
10450
+ sectionIndex,
10451
+ type: field.type,
10146
10452
  remove: remove2,
10147
- editProps: editFieldProps,
10148
- duplicateProps: duplicateFieldProps,
10149
- insertAfterProps,
10150
- dragHandleProps: draggableProvided.dragHandleProps
10453
+ duplicate: duplicateField,
10454
+ addAfter: createFieldAfter,
10455
+ move: moveField
10151
10456
  }
10152
10457
  )
10153
10458
  ] })
10154
10459
  }
10155
10460
  ) });
10156
10461
  });
10157
- const FieldSectionWithActions = React.memo(function FieldSectionWithActions2(props) {
10158
- var _a2, _b, _c, _d, _e, _f, _g;
10462
+ FieldWithActions.displayName = "FieldWithActions";
10463
+ const FieldSectionWithActions = React.memo((props) => {
10464
+ var _a2;
10159
10465
  const { field, index: sectionIndex, dropState } = props;
10160
10466
  const isDropDisabled = (_a2 = dropState[field.identifier]) == null ? void 0 : _a2.disabled;
10161
- const [isAddFieldDialogOpen, setIsAddFieldDialogOpen] = React.useState(false);
10162
10467
  const { setFieldValue, values } = formik.useFormikContext();
10163
10468
  const alertDialog = blocks.useAlertDialog();
10469
+ const { reorderSection } = useFieldReordering();
10164
10470
  const takenFieldLabels = getTakenFieldLabels(values.fields);
10165
10471
  const removeSectionConditions = React.useCallback(
10166
10472
  (sectionsToUpdate, allSections) => {
@@ -10247,152 +10553,113 @@ var __publicField = (obj, key, value) => {
10247
10553
  alertDialog,
10248
10554
  removeSectionConditions
10249
10555
  ]);
10250
- const duplicateSection = React.useCallback(
10251
- (field2) => {
10252
- const fieldLabel = field2.label ?? "Untitled section";
10253
- const newSectionLabel = incrementFieldLabel(fieldLabel, takenFieldLabels);
10254
- const newFields = field2.fields.map((f) => {
10255
- const newLabel = incrementFieldLabel(f.label || "Untitled field", takenFieldLabels);
10256
- return {
10257
- ...f,
10258
- label: newLabel,
10259
- identifier: makeIdentifier(void 0, newLabel)
10260
- };
10261
- });
10262
- return { ...field2, label: newSectionLabel, fields: newFields, identifier: "" };
10556
+ const moveSection = React.useCallback(
10557
+ (direction) => {
10558
+ const destinationIndex = direction === "up" ? sectionIndex - 1 : sectionIndex + 1;
10559
+ reorderSection(dropState, field.identifier, sectionIndex, destinationIndex, values, setFieldValue);
10263
10560
  },
10264
- [takenFieldLabels]
10561
+ [sectionIndex, reorderSection, dropState, field.identifier, values, setFieldValue]
10265
10562
  );
10266
10563
  const editSectionProps = React.useMemo(
10267
10564
  () => ({
10268
10565
  index: sectionIndex,
10269
10566
  parentPath: "fields",
10270
10567
  initial: field,
10271
- editing: true,
10272
10568
  conditionalSourceFields: makeConditionalSourceFields(values.fields, sectionIndex)
10273
10569
  }),
10274
10570
  [field, sectionIndex, values.fields]
10275
10571
  );
10276
- const insertSectionProps = React.useMemo(
10277
- () => ({
10278
- index: sectionIndex + 1,
10279
- parentPath: "fields",
10280
- initial: emptySection(),
10281
- conditionalSourceFields: makeConditionalSourceFields(values.fields, sectionIndex + 1)
10282
- }),
10283
- [sectionIndex, values.fields]
10284
- );
10285
- const insertFieldAtEndOfSection = React.useMemo(
10286
- () => ({
10287
- parentPath: `fields.${sectionIndex}.fields`,
10288
- index: field.fields.length,
10289
- initial: void 0
10290
- }),
10291
- [field.fields.length, sectionIndex]
10292
- );
10293
- const duplicateSectionProps = React.useMemo(
10294
- () => ({
10295
- index: sectionIndex + 1,
10296
- parentPath: "fields",
10297
- initial: duplicateSection(field),
10298
- conditionalSourceFields: makeConditionalSourceFields(values.fields, sectionIndex + 1)
10299
- }),
10300
- [duplicateSection, field, sectionIndex, values.fields]
10301
- );
10302
- const conditionLabel = React.useMemo(
10303
- () => {
10304
- var _a3, _b2;
10305
- return (_b2 = findFieldByIdentifier(values.fields, (_a3 = field.condition) == null ? void 0 : _a3.identifier)) == null ? void 0 : _b2.label;
10572
+ const duplicateSection = React.useCallback(() => {
10573
+ const fieldLabel = field.label ?? "Untitled section";
10574
+ const newSectionLabel = incrementFieldLabel(fieldLabel, takenFieldLabels);
10575
+ const newFields = field.fields.map((f) => {
10576
+ const newLabel = incrementFieldLabel(f.label, takenFieldLabels);
10577
+ return {
10578
+ ...f,
10579
+ label: newLabel,
10580
+ identifier: makeIdentifier(null, newLabel)
10581
+ };
10582
+ });
10583
+ const duplicatedField = { ...field, label: newSectionLabel, fields: newFields };
10584
+ createNewField("fields", sectionIndex + 1, duplicatedField, values, setFieldValue);
10585
+ }, [field, takenFieldLabels, sectionIndex, values, setFieldValue]);
10586
+ const handleCreateField = React.useCallback(
10587
+ (type) => {
10588
+ createNewField(
10589
+ `fields.${sectionIndex}.fields`,
10590
+ field.fields.length,
10591
+ FieldTypeToEmptyFieldMapping[type],
10592
+ values,
10593
+ setFieldValue
10594
+ );
10306
10595
  },
10307
- [(_b = field.condition) == null ? void 0 : _b.identifier, values.fields]
10596
+ [sectionIndex, field.fields.length, values, setFieldValue]
10308
10597
  );
10309
- const conditionComparison = Array.isArray((_c = field.condition) == null ? void 0 : _c.value) ? "contains all of" : "equals";
10310
- if (valueIsFile((_d = field.condition) == null ? void 0 : _d.value))
10311
- throw new Error("File values are not supported for conditions.");
10312
- const conditionValue = Array.isArray((_e = field.condition) == null ? void 0 : _e.value) ? field.condition.value.map((v) => typeof v === "string" ? v : v.label).join(", ") : (_g = (_f = field.condition) == null ? void 0 : _f.value) == null ? void 0 : _g.toString();
10313
- return /* @__PURE__ */ jsxRuntime.jsx(dnd.Draggable, { draggableId: field.identifier, index: sectionIndex, children: (draggableProvided) => /* @__PURE__ */ jsxRuntime.jsx(
10314
- Card,
10315
- {
10316
- ref: draggableProvided.innerRef,
10317
- ...draggableProvided.draggableProps,
10318
- ...draggableProvided.dragHandleProps,
10319
- mb: "4",
10320
- children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { gap: "3", justify: "between", align: "center", children: [
10321
- /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "2", grow: "1", children: [
10322
- /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", children: [
10323
- /* @__PURE__ */ jsxRuntime.jsx(Heading, { as: "h3", size: "3", children: field.label }),
10324
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$4.description, children: field.description })
10325
- ] }),
10326
- field.condition && /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "1", children: /* @__PURE__ */ jsxRuntime.jsxs(Em, { children: [
10327
- "Display only if ",
10328
- /* @__PURE__ */ jsxRuntime.jsx(Strong, { children: conditionLabel }),
10329
- " ",
10330
- conditionComparison,
10331
- " ",
10332
- /* @__PURE__ */ jsxRuntime.jsx(Strong, { children: conditionValue })
10333
- ] }) }),
10334
- /* @__PURE__ */ jsxRuntime.jsx(dnd.Droppable, { droppableId: field.identifier, type: "SECTION", isDropDisabled, children: (droppableProvided) => /* @__PURE__ */ jsxRuntime.jsxs(
10335
- blocks.Flex,
10336
- {
10337
- ref: droppableProvided.innerRef,
10338
- ...droppableProvided.droppableProps,
10339
- direction: "column",
10340
- gap: "0",
10341
- children: [
10342
- field.fields.map((child, i) => /* @__PURE__ */ jsxRuntime.jsx(
10343
- FieldWithActions,
10344
- {
10345
- field: child,
10346
- index: i,
10347
- sectionIndex,
10348
- remove: () => {
10349
- removeField(i);
10350
- },
10351
- takenLabels: takenFieldLabels
10352
- },
10353
- child.identifier
10354
- )),
10355
- droppableProvided.placeholder,
10356
- /* @__PURE__ */ jsxRuntime.jsxs(
10357
- blocks.Button,
10598
+ return /* @__PURE__ */ jsxRuntime.jsx(dnd.Draggable, { draggableId: field.identifier, index: sectionIndex, children: (draggableProvided) => {
10599
+ return /* @__PURE__ */ jsxRuntime.jsx(
10600
+ Card,
10601
+ {
10602
+ ref: draggableProvided.innerRef,
10603
+ ...draggableProvided.draggableProps,
10604
+ ...draggableProvided.dragHandleProps,
10605
+ mb: "4",
10606
+ children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { gap: "3", justify: "between", align: "center", children: [
10607
+ /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "2", grow: "1", children: [
10608
+ /* @__PURE__ */ jsxRuntime.jsx(FieldBuilder, { ...editSectionProps }),
10609
+ /* @__PURE__ */ jsxRuntime.jsx(
10610
+ dnd.Droppable,
10611
+ {
10612
+ droppableId: field.identifier,
10613
+ type: "SECTION",
10614
+ isDropDisabled,
10615
+ children: (droppableProvided) => /* @__PURE__ */ jsxRuntime.jsxs(
10616
+ blocks.Flex,
10358
10617
  {
10359
- type: "button",
10360
- variant: "outline",
10361
- onClick: () => {
10362
- setIsAddFieldDialogOpen(true);
10363
- },
10618
+ ref: droppableProvided.innerRef,
10619
+ ...droppableProvided.droppableProps,
10620
+ direction: "column",
10621
+ gap: "0",
10364
10622
  children: [
10365
- /* @__PURE__ */ jsxRuntime.jsx(PlusIcon, {}),
10366
- " Add a field"
10623
+ field.fields.map((child, i) => /* @__PURE__ */ jsxRuntime.jsx(
10624
+ FieldWithActions,
10625
+ {
10626
+ field: child,
10627
+ index: i,
10628
+ sectionIndex,
10629
+ remove: () => {
10630
+ removeField(i);
10631
+ },
10632
+ takenLabels: takenFieldLabels
10633
+ },
10634
+ child.identifier
10635
+ )),
10636
+ droppableProvided.placeholder,
10637
+ /* @__PURE__ */ jsxRuntime.jsx(FieldTypeDropdown, { setFieldType: handleCreateField, children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Button, { type: "button", variant: "soft", children: [
10638
+ /* @__PURE__ */ jsxRuntime.jsx(PlusIcon, {}),
10639
+ " Add field"
10640
+ ] }) })
10367
10641
  ]
10368
10642
  }
10369
- ),
10370
- /* @__PURE__ */ jsxRuntime.jsx(
10371
- FieldBuilder,
10372
- {
10373
- ...insertFieldAtEndOfSection,
10374
- isOpen: isAddFieldDialogOpen,
10375
- setIsOpen: setIsAddFieldDialogOpen
10376
- }
10377
10643
  )
10378
- ]
10644
+ }
10645
+ )
10646
+ ] }),
10647
+ /* @__PURE__ */ jsxRuntime.jsx(
10648
+ FieldActions,
10649
+ {
10650
+ index: sectionIndex,
10651
+ type: field.type,
10652
+ remove: removeSection,
10653
+ duplicate: duplicateSection,
10654
+ move: moveSection
10379
10655
  }
10380
- ) })
10381
- ] }),
10382
- /* @__PURE__ */ jsxRuntime.jsx(
10383
- FieldActions,
10384
- {
10385
- remove: removeSection,
10386
- insertAfterProps: insertSectionProps,
10387
- dragHandleProps: draggableProvided.dragHandleProps,
10388
- editProps: editSectionProps,
10389
- duplicateProps: duplicateSectionProps
10390
- }
10391
- )
10392
- ] })
10393
- }
10394
- ) });
10656
+ )
10657
+ ] })
10658
+ }
10659
+ );
10660
+ } });
10395
10661
  });
10662
+ FieldSectionWithActions.displayName = "FieldSectionWithActions";
10396
10663
  const reducer = (state, action) => {
10397
10664
  var _a2;
10398
10665
  const next = { ...state };
@@ -10454,11 +10721,40 @@ var __publicField = (obj, key, value) => {
10454
10721
  return [section, i];
10455
10722
  }
10456
10723
  };
10457
- const FieldsEditor = React.memo(function FieldsEditor2() {
10724
+ const BasicFieldSection = React.memo((props) => {
10725
+ const { field, provided } = props;
10726
+ return /* @__PURE__ */ jsxRuntime.jsx(
10727
+ Card,
10728
+ {
10729
+ ref: provided == null ? void 0 : provided.innerRef,
10730
+ ...provided == null ? void 0 : provided.draggableProps,
10731
+ ...provided == null ? void 0 : provided.dragHandleProps,
10732
+ style: { ...provided == null ? void 0 : provided.draggableProps.style, height: "80px" },
10733
+ children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "2", children: [
10734
+ /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "row", gap: "2", children: [
10735
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "4", children: field.label }),
10736
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Badge, { style: { width: "fit-content" }, children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Text, { children: [
10737
+ field.fields.length,
10738
+ " Fields"
10739
+ ] }) })
10740
+ ] }),
10741
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Flex, { direction: "row", gap: "2", children: field.fields.map((child) => {
10742
+ const childInfo = FieldTypeToClsMapping[child.type];
10743
+ const Icon = childInfo.Icon;
10744
+ return /* @__PURE__ */ jsxRuntime.jsx(blocks.Flex, { gap: "3", children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Badge, { style: { width: "fit-content" }, children: [
10745
+ /* @__PURE__ */ jsxRuntime.jsx(Icon, {}),
10746
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { children: childInfo.fieldTypeName })
10747
+ ] }) }, child.identifier);
10748
+ }) })
10749
+ ] })
10750
+ }
10751
+ );
10752
+ });
10753
+ BasicFieldSection.displayName = "BasicFieldSection";
10754
+ const FieldsEditor = React.memo(() => {
10458
10755
  const { values, setFieldValue } = formik.useFormikContext();
10459
10756
  const [dropState, dispatch] = React.useReducer(reducer, values.fields, initializer);
10460
- const [isAddSectionDialogOpen, setIsAddSectionDialogOpen] = React.useState(false);
10461
- const { showInfo } = blocks.useToast();
10757
+ const { reorderSection, reorderField } = useFieldReordering();
10462
10758
  React.useEffect(() => {
10463
10759
  dispatch({ type: "update", state: initializer(values.fields) });
10464
10760
  }, [dispatch, values.fields]);
@@ -10474,58 +10770,30 @@ var __publicField = (obj, key, value) => {
10474
10770
  if (!destination || reason === "CANCEL")
10475
10771
  return;
10476
10772
  if (type === "ROOT") {
10477
- const state = dropState[draggableId];
10478
- if (!state)
10479
- throw new Error("Could not find section context.");
10480
- let dest = typeof state.conditionIndex !== "undefined" ? (
10481
- // cannot move a section with a condition before the condition's field
10482
- Math.max(state.conditionIndex + 1, destination.index)
10483
- ) : destination.index;
10484
- for (const section of Object.values(dropState)) {
10485
- if (section.conditionIndex === source.index) {
10486
- dest = Math.min(dest, section.index - 1);
10487
- }
10488
- }
10489
- if (dest != destination.index) {
10490
- showInfo({
10491
- title: "Reordered sections",
10492
- description: "Sections with conditions must be below the fields they reference."
10493
- });
10494
- }
10495
- return setFieldValue("fields", reorder(values.fields, source.index, dest));
10773
+ reorderSection(dropState, draggableId, source.index, destination.index, values, setFieldValue);
10774
+ return;
10496
10775
  }
10497
10776
  if (type !== "SECTION")
10498
10777
  throw new Error("Unexpected droppable type.");
10499
10778
  const [sourceSection, srcIndex] = findSection(values.fields, source.droppableId) ?? [];
10500
10779
  const [destinationSection, destIndex] = findSection(values.fields, destination.droppableId) ?? [];
10501
- if (!(sourceSection == null ? void 0 : sourceSection.fields) || !destinationSection)
10502
- throw new Error("Could not find section with fields.");
10503
- if (sourceSection.identifier === destinationSection.identifier) {
10504
- void setFieldValue(
10505
- `fields.${srcIndex}.fields`,
10506
- reorder(sourceSection.fields, source.index, destination.index)
10507
- ).then();
10508
- } else {
10509
- const removed = sourceSection.fields[source.index];
10510
- if (!removed)
10511
- throw new Error("Could not find field to reorder.");
10512
- void setFieldValue(`fields.${srcIndex}.fields`, remove(sourceSection.fields, source.index)).then();
10513
- void setFieldValue(
10514
- `fields.${destIndex}.fields`,
10515
- insert(destinationSection.fields, destination.index, removed)
10516
- ).then();
10517
- }
10780
+ reorderField(
10781
+ sourceSection,
10782
+ srcIndex,
10783
+ source.index,
10784
+ destinationSection,
10785
+ destIndex,
10786
+ destination.index,
10787
+ setFieldValue
10788
+ );
10518
10789
  },
10519
- [values.fields, setFieldValue, dropState, showInfo]
10790
+ [values, reorderField, setFieldValue, reorderSection, dropState]
10520
10791
  );
10521
- const makeFieldSectionProps = React.useMemo(
10522
- () => ({
10523
- index: values.fields.length,
10524
- parentPath: "fields",
10525
- initial: emptySection(),
10526
- conditionalSourceFields: makeConditionalSourceFields(values.fields, values.fields.length)
10527
- }),
10528
- [values.fields]
10792
+ const handleCreateEmptySection = React.useCallback(
10793
+ (index2) => {
10794
+ createNewEmptySection(index2 + 1, values, setFieldValue);
10795
+ },
10796
+ [values, setFieldValue]
10529
10797
  );
10530
10798
  return /* @__PURE__ */ jsxRuntime.jsx(dnd.DragDropContext, { onDragStart: handleDragStart, onDragEnd: handleDragEnd, children: /* @__PURE__ */ jsxRuntime.jsx(dnd.Droppable, { droppableId: "droppable", type: "ROOT", children: (droppableProvided) => /* @__PURE__ */ jsxRuntime.jsxs(
10531
10799
  blocks.Flex,
@@ -10535,123 +10803,200 @@ var __publicField = (obj, key, value) => {
10535
10803
  direction: "column",
10536
10804
  gap: "0",
10537
10805
  children: [
10538
- values.fields.map((field, index2) => /* @__PURE__ */ jsxRuntime.jsx(
10539
- FieldSectionWithActions,
10540
- {
10541
- field,
10542
- index: index2,
10543
- dropState
10544
- },
10545
- field.label
10546
- )),
10547
- droppableProvided.placeholder,
10548
- /* @__PURE__ */ jsxRuntime.jsxs(
10549
- blocks.Button,
10550
- {
10551
- type: "button",
10552
- variant: "outline",
10553
- onClick: () => {
10554
- setIsAddSectionDialogOpen(true);
10555
- },
10556
- children: [
10557
- /* @__PURE__ */ jsxRuntime.jsx(PlusIcon, {}),
10558
- " Add a section"
10559
- ]
10560
- }
10561
- ),
10562
- /* @__PURE__ */ jsxRuntime.jsx(
10563
- FieldBuilder,
10564
- {
10565
- ...makeFieldSectionProps,
10566
- isOpen: isAddSectionDialogOpen,
10567
- setIsOpen: setIsAddSectionDialogOpen
10568
- }
10569
- )
10806
+ values.fields.map((field, index2) => /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
10807
+ /* @__PURE__ */ jsxRuntime.jsx(FieldSectionWithActions, { field, index: index2, dropState }),
10808
+ /* @__PURE__ */ jsxRuntime.jsxs(
10809
+ blocks.Button,
10810
+ {
10811
+ type: "button",
10812
+ variant: "surface",
10813
+ severity: "info",
10814
+ onClick: () => {
10815
+ handleCreateEmptySection(index2);
10816
+ },
10817
+ style: { marginBottom: "4px" },
10818
+ children: [
10819
+ /* @__PURE__ */ jsxRuntime.jsx(PlusIcon, {}),
10820
+ " Add section"
10821
+ ]
10822
+ }
10823
+ )
10824
+ ] }, field.identifier)),
10825
+ droppableProvided.placeholder
10570
10826
  ]
10571
10827
  }
10572
10828
  ) }) });
10573
10829
  });
10830
+ FieldsEditor.displayName = "FieldsEditor";
10574
10831
  const initialValues = {
10575
10832
  title: "",
10576
10833
  description: "",
10577
- fields: []
10578
- };
10579
- const title = new StringField({
10580
- label: "Title",
10581
- minLength: 0,
10582
- maxLength: 100,
10583
- required: true,
10584
- identifier: "title"
10585
- });
10586
- const titleProps = { formId, placeholder: "Give your form a title." };
10587
- const description = new TextField({
10588
- label: "Description",
10589
- minLength: 0,
10590
- maxLength: 1e3,
10591
- required: false,
10592
- identifier: "description"
10593
- });
10594
- const descriptionProps = { formId, placeholder: "Explain the purpose of this form." };
10834
+ fields: [{ ...emptySection(makeIdentifier(null, "")), label: "" }]
10835
+ };
10595
10836
  const previewSubmit = () => {
10596
10837
  alert("This is a form preview, your data will not be saved.");
10597
10838
  };
10598
10839
  const FormBuilder = React.memo(
10599
10840
  React.forwardRef((props, ref) => {
10600
10841
  const { onCancel, onSave, revision } = props;
10601
- const { heading = revision ? "Edit form" : "Create a new form" } = props;
10602
- const validate = React.useCallback((form) => {
10603
- const errors = {};
10604
- if (!form.title) {
10605
- errors.title = "Title is required.";
10606
- }
10607
- if (!form.fields || form.fields.length === 0) {
10608
- errors.fields = "At least one field is required.";
10609
- }
10610
- if (hasKeys(errors)) {
10611
- return errors;
10612
- }
10613
- }, []);
10842
+ const { showError } = blocks.useToast();
10843
+ const validate = React.useCallback(
10844
+ (form) => {
10845
+ const errors = {};
10846
+ if (!form.title) {
10847
+ errors.title = "Title is required.";
10848
+ }
10849
+ if (form.fields.length === 0) {
10850
+ errors.fields = "At least one field is required.";
10851
+ }
10852
+ let fieldsToValidate = [];
10853
+ for (const [sectionIndex, section] of form.fields.entries()) {
10854
+ const fieldCls = CompleteFieldTypeToClsMapping.section;
10855
+ const sectionSettings = fieldCls.getFieldCreationSchema(
10856
+ makeConditionalSourceFields(form.fields, sectionIndex),
10857
+ `fields.${sectionIndex}`
10858
+ ).map((field) => field.field);
10859
+ fieldsToValidate = [...fieldsToValidate, ...sectionSettings];
10860
+ for (const [fieldIndex, field] of section.fields.entries()) {
10861
+ const fieldCls2 = CompleteFieldTypeToClsMapping[field.type];
10862
+ const fieldSettings = fieldCls2.getFieldCreationSchema(`fields.${sectionIndex}.fields.${fieldIndex}`).map((field2) => field2.field);
10863
+ fieldsToValidate = [...fieldsToValidate, ...fieldSettings];
10864
+ }
10865
+ }
10866
+ const fieldErrors = validateForm(
10867
+ {
10868
+ title: "Validate form builder",
10869
+ fields: fieldsToValidate,
10870
+ meta: { readonly: true }
10871
+ },
10872
+ form
10873
+ );
10874
+ if (fieldErrors) {
10875
+ errors.fields = fieldErrors.fields;
10876
+ }
10877
+ if (hasKeys(errors)) {
10878
+ showError({
10879
+ title: "Some form settings are invalid",
10880
+ description: "Please check settings highlighted in red."
10881
+ });
10882
+ return errors;
10883
+ }
10884
+ },
10885
+ [showError]
10886
+ );
10614
10887
  const formik$1 = formik.useFormik({
10615
10888
  initialValues: wrapRootFieldsWithFieldSection(revision) ?? initialValues,
10616
10889
  validate,
10617
- onSubmit: onSave,
10618
- // only validate the entire for on submit
10890
+ // onSubmit: (form) => console.log("SUBMITTED", form),
10891
+ onSubmit: (form) => {
10892
+ onSave(form);
10893
+ },
10894
+ // only validate the entire form on submit
10619
10895
  validateOnChange: false,
10620
10896
  validateOnBlur: false
10621
10897
  });
10622
10898
  const previewSchema = React.useMemo(() => formRevisionToSchema(formik$1.values), [formik$1.values]);
10623
- const titleInput = useFieldInput(title, titleProps);
10624
- const descriptionInput = useFieldInput(description, descriptionProps);
10625
- const FormBuilderHeading = React.useMemo(
10626
- () => typeof heading === "object" ? heading : /* @__PURE__ */ jsxRuntime.jsx(Heading, { children: heading }),
10627
- [heading]
10628
- );
10629
10899
  return /* @__PURE__ */ jsxRuntime.jsx(Tabs.Root, { ref, defaultValue: "edit", children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "2", children: [
10630
- /* @__PURE__ */ jsxRuntime.jsxs(Tabs.List, { children: [
10631
- /* @__PURE__ */ jsxRuntime.jsx(Tabs.Trigger, { value: "edit", children: "Edit" }),
10632
- /* @__PURE__ */ jsxRuntime.jsx(Tabs.Trigger, { value: "preview", children: "Preview" })
10633
- ] }),
10900
+ /* @__PURE__ */ jsxRuntime.jsxs(
10901
+ Tabs.List,
10902
+ {
10903
+ style: {
10904
+ display: "flex",
10905
+ position: "sticky",
10906
+ top: 0,
10907
+ zIndex: 2e3,
10908
+ backgroundColor: "var(--color-background)"
10909
+ },
10910
+ children: [
10911
+ /* @__PURE__ */ jsxRuntime.jsx(Tabs.Trigger, { style: { flex: 1 }, value: "edit", children: "Edit" }),
10912
+ /* @__PURE__ */ jsxRuntime.jsx(Tabs.Trigger, { style: { flex: 1 }, value: "preview", children: "Preview" })
10913
+ ]
10914
+ }
10915
+ ),
10634
10916
  /* @__PURE__ */ jsxRuntime.jsxs(Tabs.Content, { value: "edit", children: [
10635
- FormBuilderHeading,
10636
10917
  /* @__PURE__ */ jsxRuntime.jsxs(blocks.Text, { children: [
10637
- "Add a new form field by clicking a + button. Specify options for each field, then drag and drop to rearrange them. You can see what a submitted form might look like in the",
10918
+ "Create your form using various field types. Sections can be",
10638
10919
  " ",
10639
- /* @__PURE__ */ jsxRuntime.jsx("em", { children: "Preview" }),
10640
- " tab, but",
10920
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { children: "conditionally rendered" }),
10921
+ " based on",
10641
10922
  " ",
10642
- /* @__PURE__ */ jsxRuntime.jsx("strong", { children: "field values entered on this page will not be saved." })
10923
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { children: "answers to fields in preceding sections. " })
10643
10924
  ] }),
10644
10925
  /* @__PURE__ */ jsxRuntime.jsx(blocks.Flex, { asChild: true, direction: "column", gap: "2", mt: "3", children: /* @__PURE__ */ jsxRuntime.jsxs("form", { id: formId, onSubmit: formik$1.handleSubmit, children: [
10645
10926
  /* @__PURE__ */ jsxRuntime.jsxs(formik.FormikProvider, { value: formik$1, children: [
10646
- titleInput,
10647
- descriptionInput,
10927
+ /* @__PURE__ */ jsxRuntime.jsx(
10928
+ PatchField,
10929
+ {
10930
+ name: "title",
10931
+ render: ({ setValue, value, meta }) => /* @__PURE__ */ jsxRuntime.jsx(InputWithHelpText, { severity: "danger", helpText: meta.error ?? null, children: /* @__PURE__ */ jsxRuntime.jsx(
10932
+ blocks.Input,
10933
+ {
10934
+ style: {
10935
+ // var(--accent-a11) for red and var(--accent-1) for gray
10936
+ border: meta.error ? "1px solid #ff9592" : "1px solid #5a6169",
10937
+ paddingLeft: "8px",
10938
+ fontWeight: "bold"
10939
+ },
10940
+ placeholder: "Form title",
10941
+ value,
10942
+ onChange: (event) => {
10943
+ setValue(event.target.value);
10944
+ },
10945
+ maxLength: 100,
10946
+ showInputLength: false,
10947
+ variant: "ghost",
10948
+ size: "large"
10949
+ }
10950
+ ) })
10951
+ }
10952
+ ),
10953
+ /* @__PURE__ */ jsxRuntime.jsx(
10954
+ PatchField,
10955
+ {
10956
+ name: "description",
10957
+ render: ({ setValue, value }) => /* @__PURE__ */ jsxRuntime.jsx(
10958
+ blocks.TextArea,
10959
+ {
10960
+ style: {
10961
+ minHeight: "max-content",
10962
+ border: "1px solid #5a6169",
10963
+ paddingLeft: "8px",
10964
+ paddingTop: "8px"
10965
+ },
10966
+ placeholder: "Explain the purpose of this form",
10967
+ value,
10968
+ onChange: (event) => {
10969
+ setValue(event.target.value);
10970
+ },
10971
+ resize: "vertical",
10972
+ maxLength: 1e3,
10973
+ showInputLength: false,
10974
+ variant: "ghost"
10975
+ }
10976
+ )
10977
+ }
10978
+ ),
10648
10979
  /* @__PURE__ */ jsxRuntime.jsx(FieldsEditor, {}),
10649
10980
  /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { severity: "danger", size: "1", children: typeof formik$1.errors.fields === "string" && formik$1.errors.fields })
10650
10981
  ] }),
10651
- /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { justify: "end", gap: "2", children: [
10652
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "button", variant: "soft", onClick: onCancel, children: "Cancel" }),
10653
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "submit", disabled: !formik$1.isValid, children: "Save" })
10654
- ] })
10982
+ /* @__PURE__ */ jsxRuntime.jsxs(
10983
+ blocks.Flex,
10984
+ {
10985
+ justify: "end",
10986
+ align: "center",
10987
+ gap: "2",
10988
+ style: {
10989
+ position: "sticky",
10990
+ bottom: 0,
10991
+ paddingBottom: "10px",
10992
+ paddingRight: "10px"
10993
+ },
10994
+ children: [
10995
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "button", variant: "solid", severity: "info", onClick: onCancel, children: "Cancel" }),
10996
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "submit", children: "Save form" })
10997
+ ]
10998
+ }
10999
+ )
10655
11000
  ] }) })
10656
11001
  ] }),
10657
11002
  /* @__PURE__ */ jsxRuntime.jsx(Tabs.Content, { value: "preview", children: /* @__PURE__ */ jsxRuntime.jsx(FormRenderer, { schema: previewSchema, onSubmit: previewSubmit }) })
@@ -10672,6 +11017,7 @@ var __publicField = (obj, key, value) => {
10672
11017
  FormRenderer,
10673
11018
  FormSubmissionBrowser,
10674
11019
  FormSubmissionViewer,
11020
+ InputWithHelpText,
10675
11021
  InputWithLabel,
10676
11022
  InputWithLabelAndHelpText,
10677
11023
  MultiSelectField,
@@ -10690,12 +11036,22 @@ var __publicField = (obj, key, value) => {
10690
11036
  TextInput,
10691
11037
  deserialize,
10692
11038
  deserializeField,
11039
+ emptyBaseField,
11040
+ emptyBooleanField,
11041
+ emptyDateField,
11042
+ emptyMultiSelectField,
11043
+ emptyMultiStringField,
11044
+ emptyNumberField,
11045
+ emptySelectField,
11046
+ emptyStringField,
11047
+ emptyTextField,
10693
11048
  formRevisionToSchema,
10694
11049
  isConditionMet,
10695
11050
  useFieldInput,
10696
11051
  useFieldInputs,
10697
11052
  useFormikInput,
10698
- valueIsFile
11053
+ valueIsFile,
11054
+ valueIsFormikUserFormRevision
10699
11055
  }, Symbol.toStringTag, { value: "Module" }));
10700
11056
  exports2.APIError = APIError;
10701
11057
  exports2.AttachmentService = AttachmentService;
@@ -10727,6 +11083,7 @@ var __publicField = (obj, key, value) => {
10727
11083
  exports2.FormSubmissionViewer = FormSubmissionViewer;
10728
11084
  exports2.GREEN = GREEN;
10729
11085
  exports2.HttpMethod = HttpMethod;
11086
+ exports2.InputWithHelpText = InputWithHelpText;
10730
11087
  exports2.InputWithLabel = InputWithLabel;
10731
11088
  exports2.InputWithLabelAndHelpText = InputWithLabelAndHelpText;
10732
11089
  exports2.IssueCommentService = IssueCommentService;
@@ -10841,6 +11198,15 @@ var __publicField = (obj, key, value) => {
10841
11198
  exports2.emailDomainsReducer = emailDomainsReducer;
10842
11199
  exports2.emailDomainsSlice = emailDomainsSlice;
10843
11200
  exports2.emailRegex = emailRegex;
11201
+ exports2.emptyBaseField = emptyBaseField;
11202
+ exports2.emptyBooleanField = emptyBooleanField;
11203
+ exports2.emptyDateField = emptyDateField;
11204
+ exports2.emptyMultiSelectField = emptyMultiSelectField;
11205
+ exports2.emptyMultiStringField = emptyMultiStringField;
11206
+ exports2.emptyNumberField = emptyNumberField;
11207
+ exports2.emptySelectField = emptySelectField;
11208
+ exports2.emptyStringField = emptyStringField;
11209
+ exports2.emptyTextField = emptyTextField;
10844
11210
  exports2.enqueue = enqueue;
10845
11211
  exports2.enqueueRequest = enqueueRequest;
10846
11212
  exports2.errorColor = errorColor;
@@ -11126,6 +11492,7 @@ var __publicField = (obj, key, value) => {
11126
11492
  exports2.userReducer = userReducer;
11127
11493
  exports2.userSlice = userSlice;
11128
11494
  exports2.valueIsFile = valueIsFile;
11495
+ exports2.valueIsFormikUserFormRevision = valueIsFormikUserFormRevision;
11129
11496
  exports2.warningColor = warningColor;
11130
11497
  exports2.workspaceReducer = workspaceReducer;
11131
11498
  exports2.workspaceSlice = workspaceSlice;