@overmap-ai/core 1.0.31-revamp-forms-builder.2 → 1.0.32

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 (45) hide show
  1. package/dist/forms/builder/FieldActions.d.ts +7 -8
  2. package/dist/forms/builder/FieldBuilder.d.ts +18 -5
  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 +5 -1
  7. package/dist/forms/builder/constants.d.ts +1 -0
  8. package/dist/forms/builder/utils.d.ts +1 -13
  9. package/dist/forms/fields/BaseField/BaseField.d.ts +5 -15
  10. package/dist/forms/fields/BaseField/hooks.d.ts +1 -2
  11. package/dist/forms/fields/BaseField/layouts.d.ts +2 -7
  12. package/dist/forms/fields/BooleanField/BooleanField.d.ts +0 -6
  13. package/dist/forms/fields/CustomField/CustomField.d.ts +0 -6
  14. package/dist/forms/fields/DateField/DateField.d.ts +0 -6
  15. package/dist/forms/fields/FieldSection/FieldSection.d.ts +6 -12
  16. package/dist/forms/fields/MultiStringField/MultiStringField.d.ts +0 -8
  17. package/dist/forms/fields/NumberField/NumberField.d.ts +3 -18
  18. package/dist/forms/fields/SelectField/BaseSelectField.d.ts +1 -4
  19. package/dist/forms/fields/SelectField/MultiSelectField.d.ts +0 -7
  20. package/dist/forms/fields/SelectField/SelectField.d.ts +0 -7
  21. package/dist/forms/fields/StringOrTextFields/StringField/StringField.d.ts +0 -8
  22. package/dist/forms/fields/StringOrTextFields/StringOrTextField.d.ts +5 -8
  23. package/dist/forms/fields/StringOrTextFields/TextField/TextField.d.ts +0 -7
  24. package/dist/forms/fields/UploadField/UploadField.d.ts +1 -16
  25. package/dist/forms/fields/constants.d.ts +0 -75
  26. package/dist/forms/fields/typings.d.ts +1 -4
  27. package/dist/forms/fields/utils.d.ts +1 -3
  28. package/dist/forms/renderer/PatchForm/Field.d.ts +1 -3
  29. package/dist/forms/renderer/PatchForm/Provider.d.ts +1 -2
  30. package/dist/forms/utils.d.ts +1 -2
  31. package/dist/overmap-core.js +1191 -1492
  32. package/dist/overmap-core.js.map +1 -1
  33. package/dist/overmap-core.umd.cjs +1191 -1492
  34. package/dist/overmap-core.umd.cjs.map +1 -1
  35. package/dist/sdk/services/MainService.d.ts +1 -0
  36. package/dist/sdk/services/OrganizationService.d.ts +3 -1
  37. package/dist/sdk/services/ProjectService.d.ts +1 -0
  38. package/dist/store/slices/organizationAccessSlice.d.ts +1 -5
  39. package/dist/store/slices/organizationSlice.d.ts +1 -0
  40. package/dist/store/slices/projectSlice.d.ts +6 -1
  41. package/dist/style.css +0 -2
  42. package/dist/typings/models/organizations.d.ts +10 -0
  43. package/dist/typings/models/projects.d.ts +1 -0
  44. package/package.json +2 -2
  45. package/dist/forms/builder/componentConstants.d.ts +0 -8
@@ -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("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) {
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) {
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 = "browser";
375
+ var title$1 = "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,
431
+ title: title$1,
432
432
  browser,
433
433
  env,
434
434
  argv,
@@ -2354,8 +2354,7 @@ var __publicField = (obj, key, value) => {
2354
2354
  const selectFavouriteProjects = (state) => state.userReducer.currentUser.profile.favourite_project_ids;
2355
2355
  const userReducer = userSlice.reducer;
2356
2356
  const initialState$a = {
2357
- organizationAccesses: {},
2358
- activeOrganizationAccessId: null
2357
+ organizationAccesses: {}
2359
2358
  };
2360
2359
  const organizationAccessSlice = toolkit.createSlice({
2361
2360
  name: "organizationAccess",
@@ -2391,31 +2390,25 @@ var __publicField = (obj, key, value) => {
2391
2390
  `Tried to remove organization access with ID that doesn't exist: ${action.payload.offline_id}`
2392
2391
  );
2393
2392
  }
2394
- },
2395
- setActiveOrganizationAccessId: (state, action) => {
2396
- state.activeOrganizationAccessId = action.payload;
2397
2393
  }
2398
2394
  }
2399
2395
  });
2400
- const {
2401
- setOrganizationAccesses,
2402
- updateOrganizationAccess,
2403
- removeOrganizationAccess,
2404
- setActiveOrganizationAccessId
2405
- } = organizationAccessSlice.actions;
2396
+ const { setOrganizationAccesses, updateOrganizationAccess, removeOrganizationAccess } = organizationAccessSlice.actions;
2406
2397
  const selectOrganizationAccesses = (state) => {
2407
2398
  return state.organizationAccessReducer.organizationAccesses;
2408
2399
  };
2409
2400
  const selectOrganizationAccess = (organizationAccessId) => (state) => {
2410
2401
  return state.organizationAccessReducer.organizationAccesses[organizationAccessId];
2411
2402
  };
2412
- const selectActiveOrganizationAccess = (state) => {
2413
- const activeOrganizationAccessId = state.organizationAccessReducer.activeOrganizationAccessId;
2414
- if (!activeOrganizationAccessId) {
2415
- return null;
2403
+ const selectActiveOrganizationAccess = toolkit.createSelector(
2404
+ [selectCurrentUser, selectOrganizationAccesses],
2405
+ (currentUser, organizationAccesses) => {
2406
+ const activeOrganizationAccess = Object.values(organizationAccesses).find(
2407
+ (organizationAccess) => organizationAccess.user === currentUser.id
2408
+ );
2409
+ return activeOrganizationAccess ?? null;
2416
2410
  }
2417
- return state.organizationAccessReducer.organizationAccesses[activeOrganizationAccessId] ?? null;
2418
- };
2411
+ );
2419
2412
  const selectOrganizationAccessForUser = (user) => (state) => {
2420
2413
  return Object.values(state.organizationAccessReducer.organizationAccesses).find(
2421
2414
  (organizationAccess) => organizationAccess.user === user.id
@@ -2464,6 +2457,10 @@ var __publicField = (obj, key, value) => {
2464
2457
  const selectOrganizations = (state) => {
2465
2458
  return Object.values(state.organizationReducer.organizations);
2466
2459
  };
2460
+ const selectOrganizationsWithAccess = toolkit.createSelector(
2461
+ [selectOrganizations],
2462
+ (organizations) => Object.values(organizations).filter((organization) => organization.has_access)
2463
+ );
2467
2464
  const selectActiveOrganization = (state) => {
2468
2465
  const id = selectActiveOrganizationId(state);
2469
2466
  if (!id) {
@@ -2685,6 +2682,13 @@ var __publicField = (obj, key, value) => {
2685
2682
  deleteProject: (state, action) => {
2686
2683
  delete state.projects[action.payload.id];
2687
2684
  state.recentProjectIds = state.recentProjectIds.filter((id) => id !== action.payload.id);
2685
+ },
2686
+ acceptProjectInvite: (state, action) => {
2687
+ if (action.payload in state.projects) {
2688
+ state.projects[action.payload].invited = false;
2689
+ } else {
2690
+ throw new Error("Accept project invite: user is not in this project");
2691
+ }
2688
2692
  }
2689
2693
  }
2690
2694
  });
@@ -2694,7 +2698,8 @@ var __publicField = (obj, key, value) => {
2694
2698
  updateOrCreateProjects: addOrReplaceProjects,
2695
2699
  setActiveProjectId,
2696
2700
  setCreateProjectType,
2697
- deleteProject
2701
+ deleteProject,
2702
+ acceptProjectInvite
2698
2703
  } = projectSlice.actions;
2699
2704
  const selectProjects = (state) => state.projectReducer.projects;
2700
2705
  const selectActiveProjectId = (state) => state.projectReducer.activeProjectId;
@@ -2708,6 +2713,21 @@ var __publicField = (obj, key, value) => {
2708
2713
  const selectRecentProjects = (state) => {
2709
2714
  return state.projectReducer.recentProjectIds;
2710
2715
  };
2716
+ const selectSortedProjects = toolkit.createSelector(
2717
+ [selectActiveProject, selectProjects],
2718
+ (activeProject, projects) => {
2719
+ return Object.values(projects).sort((projectA, projectB) => {
2720
+ if (activeProject) {
2721
+ if (activeProject.id === projectA.id) {
2722
+ return -1;
2723
+ } else if (activeProject.id === projectB.id) {
2724
+ return 1;
2725
+ }
2726
+ }
2727
+ return projectA.name.toLowerCase().localeCompare(projectB.name.toLowerCase(), void 0, { numeric: true });
2728
+ });
2729
+ }
2730
+ );
2711
2731
  const selectCreateProjectType = (state) => state.projectReducer.createProjectType;
2712
2732
  const projectReducer = projectSlice.reducer;
2713
2733
  const selectProjectUsersIds = toolkit.createSelector(
@@ -2718,6 +2738,10 @@ var __publicField = (obj, key, value) => {
2718
2738
  [selectProjectUsersIds, selectUsersAsMapping],
2719
2739
  (projectUserIds, users) => projectUserIds.reduce((accum, userId) => ({ ...accum, [userId]: users[userId] }), {})
2720
2740
  );
2741
+ const selectProjectsWithAccess = toolkit.createSelector(
2742
+ [selectProjects],
2743
+ (projects) => Object.values(projects).filter((project) => !project.invited)
2744
+ );
2721
2745
  const selectSortedProjectUsers = toolkit.createSelector(
2722
2746
  [selectCurrentUser, selectProjectUsersAsMapping, selectProjectAccessUserMapping],
2723
2747
  (currentUser, userMapping, projectAccessMapping) => {
@@ -4045,7 +4069,6 @@ var __publicField = (obj, key, value) => {
4045
4069
  store.dispatch(setLoggedIn(false));
4046
4070
  store.dispatch(clearTokens());
4047
4071
  store.dispatch(setActiveProjectId(null));
4048
- store.dispatch(setActiveOrganizationAccessId(null));
4049
4072
  store.dispatch(setActiveWorkspaceId(null));
4050
4073
  store.dispatch({ type: constants.RESET_STATE });
4051
4074
  store.dispatch({ type: resetStore });
@@ -4368,7 +4391,7 @@ var __publicField = (obj, key, value) => {
4368
4391
  });
4369
4392
  return promise;
4370
4393
  }
4371
- async refreshStore(replace) {
4394
+ async refreshStore(replace2) {
4372
4395
  const { store } = this.client;
4373
4396
  const result = await this.enqueueRequest({
4374
4397
  description: "Get components",
@@ -4377,7 +4400,7 @@ var __publicField = (obj, key, value) => {
4377
4400
  blockers: [],
4378
4401
  blocks: []
4379
4402
  });
4380
- if (replace) {
4403
+ if (replace2) {
4381
4404
  store.dispatch(setComponents(result));
4382
4405
  } else {
4383
4406
  store.dispatch(addComponentsInBatches(result));
@@ -4852,14 +4875,16 @@ var __publicField = (obj, key, value) => {
4852
4875
  // Don't accept updateStore in ComponentService.list. Just return the offline objects and promise. Here, if
4853
4876
  // overwrite, use setComponents. Otherwise, use bulkAddComponents.
4854
4877
  async _processInitialData(data, overwrite) {
4855
- var _a2, _b;
4878
+ var _a2, _b, _c;
4856
4879
  const workspaces = {};
4857
4880
  const projects = [];
4858
4881
  const categories = [];
4859
4882
  const projectsData = data.projects;
4860
4883
  const { store } = this.client;
4861
- const oldProjectId = store.getState().projectReducer.activeProjectId;
4862
- let currentProjectId = oldProjectId ?? ((_a2 = projectsData[0]) == null ? void 0 : _a2.id);
4884
+ const oldProjectId = (_a2 = projectsData.find(
4885
+ (projectData) => projectData.id === store.getState().projectReducer.activeProjectId && !projectData.invited
4886
+ )) == null ? void 0 : _a2.id;
4887
+ let currentProjectId = oldProjectId ?? ((_b = projectsData.find((projectData) => !projectData.invited)) == null ? void 0 : _b.id);
4863
4888
  store.dispatch(setActiveProjectId(currentProjectId ?? null));
4864
4889
  let isProjectIdValid = false;
4865
4890
  for (const projectData of projectsData) {
@@ -4868,9 +4893,10 @@ var __publicField = (obj, key, value) => {
4868
4893
  name: projectData.name,
4869
4894
  owner_organization: projectData.organization_owner,
4870
4895
  owner_user: projectData.user_owner,
4871
- bounds: projectData.bounds
4896
+ bounds: projectData.bounds,
4897
+ invited: projectData.invited || false
4872
4898
  });
4873
- if (currentProjectId === projectData.id) {
4899
+ if (currentProjectId === projectData.id && !projectData.invited) {
4874
4900
  isProjectIdValid = true;
4875
4901
  for (const workspaceData of projectData.workspaces) {
4876
4902
  const workspace = { ...workspaceData, project: projectData.id };
@@ -4885,40 +4911,44 @@ var __publicField = (obj, key, value) => {
4885
4911
  }
4886
4912
  }
4887
4913
  store.dispatch(setCurrentUser(data.user));
4914
+ store.dispatch(addUsers(data.project_owners));
4888
4915
  const organizationsData = data.organizations;
4889
4916
  store.dispatch(setOrganizations(organizationsData));
4890
- const firstOrg = organizationsData[0];
4917
+ const validProjects = projects.filter((project) => !project.invited);
4918
+ const activeOrganizationId = store.getState().organizationReducer.activeOrganizationId;
4919
+ const firstOrg = organizationsData.find((organization) => organization.has_access);
4891
4920
  const currProjObj = projects.find((project) => project.id === currentProjectId);
4892
4921
  const isOrgProject = !!(currProjObj == null ? void 0 : currProjObj.owner_organization);
4893
- const userIsInProjectOrg = isOrgProject && organizationsData.some((organization) => organization.id === currProjObj.owner_organization);
4922
+ const userIsInProjectOrg = isOrgProject && organizationsData.some(
4923
+ (organization) => organization.has_access && organization.id === currProjObj.owner_organization
4924
+ );
4894
4925
  let currentOrgId = null;
4895
- if (userIsInProjectOrg) {
4926
+ if (activeOrganizationId) {
4927
+ currentOrgId = activeOrganizationId;
4928
+ } else if (userIsInProjectOrg) {
4896
4929
  currentOrgId = currProjObj.owner_organization;
4897
4930
  } else if (firstOrg) {
4898
4931
  currentOrgId = firstOrg.id;
4899
4932
  }
4900
4933
  if (currentOrgId) {
4901
- store.dispatch(setActiveOrganizationId(currentOrgId));
4902
- const orgUsersResultPromise = this.fetchOrganizationUsers(currentOrgId);
4903
- const organizationAccessRefreshPromise = this.client.organizationAccess.refreshStore();
4904
- const orgUsersResult = await orgUsersResultPromise;
4905
- await organizationAccessRefreshPromise;
4906
- store.dispatch(addUsers(orgUsersResult));
4934
+ await this.client.organizations.fetchInitialOrganizationData(currentOrgId, false);
4907
4935
  }
4908
4936
  if (!isProjectIdValid) {
4909
- if (projects.length !== 0) {
4910
- currentProjectId = projects[0].id;
4937
+ if (validProjects.length !== 0) {
4938
+ currentProjectId = validProjects[0].id;
4911
4939
  store.dispatch(setActiveProjectId(currentProjectId));
4912
- const projectData = projectsData[0];
4913
- for (const workspaceData of projectData.workspaces) {
4914
- const workspace = { ...workspaceData, project: projectData.id };
4915
- if (workspace.categories) {
4916
- for (const category of workspace.categories) {
4917
- categories.push(category);
4940
+ const projectData = projectsData.find((projectData2) => projectData2.id === currentProjectId);
4941
+ if (projectData) {
4942
+ for (const workspaceData of projectData.workspaces) {
4943
+ const workspace = { ...workspaceData, project: projectData.id };
4944
+ if (workspace.categories) {
4945
+ for (const category of workspace.categories) {
4946
+ categories.push(category);
4947
+ }
4918
4948
  }
4949
+ delete workspace.categories;
4950
+ workspaces[workspace.offline_id] = workspace;
4919
4951
  }
4920
- delete workspace.categories;
4921
- workspaces[workspace.offline_id] = workspace;
4922
4952
  }
4923
4953
  } else {
4924
4954
  currentProjectId = null;
@@ -4935,7 +4965,7 @@ var __publicField = (obj, key, value) => {
4935
4965
  let currentWorkspaceId;
4936
4966
  const oldWorkspaceId = this.client.store.getState().workspaceReducer.activeWorkspaceId;
4937
4967
  if (overwrite || !oldWorkspaceId) {
4938
- currentWorkspaceId = (_b = Object.values(workspaces).at(0)) == null ? void 0 : _b.offline_id;
4968
+ currentWorkspaceId = (_c = Object.values(workspaces).at(0)) == null ? void 0 : _c.offline_id;
4939
4969
  } else {
4940
4970
  currentWorkspaceId = oldWorkspaceId;
4941
4971
  }
@@ -4956,7 +4986,6 @@ var __publicField = (obj, key, value) => {
4956
4986
  void this.client.userForms.refreshStore().then(() => {
4957
4987
  void this.client.userFormSubmissions.refreshStore().then();
4958
4988
  });
4959
- void this.client.emailDomains.refreshStore().then();
4960
4989
  }
4961
4990
  if (currentProjectId) {
4962
4991
  const [_offlineAttachments, promise] = this.client.attachments.fetchAll(currentProjectId);
@@ -5246,6 +5275,17 @@ var __publicField = (obj, key, value) => {
5246
5275
  blocks: []
5247
5276
  });
5248
5277
  }
5278
+ async acceptInvite(projectId) {
5279
+ return this.enqueueRequest({
5280
+ description: "Accept project invite",
5281
+ method: HttpMethod.PATCH,
5282
+ url: `/projects/${projectId}/accept-invite/`,
5283
+ blockers: [projectId.toString()],
5284
+ blocks: [projectId.toString()]
5285
+ }).then(() => {
5286
+ this.client.store.dispatch(acceptProjectInvite(projectId));
5287
+ });
5288
+ }
5249
5289
  }
5250
5290
  class UserFormService extends BaseApiService {
5251
5291
  add(state, initialRevision, url, ownerUser, ownerOrganization) {
@@ -5657,16 +5697,8 @@ var __publicField = (obj, key, value) => {
5657
5697
  blockers: [],
5658
5698
  blocks: []
5659
5699
  });
5660
- const currentUser = state.userReducer.currentUser;
5661
5700
  const organizationAccesses = result;
5662
- const activeOrganizationAccess = organizationAccesses.find(
5663
- (organizationAccess) => organizationAccess.user === currentUser.id
5664
- );
5665
- if (!activeOrganizationAccess) {
5666
- throw new Error("Current user does not have an organization access instance");
5667
- }
5668
5701
  store.dispatch(setOrganizationAccesses(organizationAccesses));
5669
- store.dispatch(setActiveOrganizationAccessId(activeOrganizationAccess.offline_id));
5670
5702
  }
5671
5703
  }
5672
5704
  const cachedRequestPromises = {};
@@ -5934,6 +5966,37 @@ var __publicField = (obj, key, value) => {
5934
5966
  }
5935
5967
  }
5936
5968
  class OrganizationService extends BaseApiService {
5969
+ async fetchInitialOrganizationData(organizationId, showLoading) {
5970
+ if (showLoading) {
5971
+ this.client.store.dispatch(setIsFetchingInitialData(true));
5972
+ }
5973
+ return this.enqueueRequest({
5974
+ description: "Get initial organization data",
5975
+ method: HttpMethod.GET,
5976
+ url: `/organizations/${organizationId}/initial-data/`,
5977
+ payload: {},
5978
+ isAuthNeeded: true,
5979
+ blockers: [],
5980
+ blocks: [organizationId.toString()]
5981
+ }).then((result) => {
5982
+ this._processInitialOrganizationData(result, showLoading);
5983
+ return result;
5984
+ });
5985
+ }
5986
+ _processInitialOrganizationData(data, showLoading) {
5987
+ const { store } = this.client;
5988
+ const activeOrganization = data.organization;
5989
+ const organizationAccesses = data.organization_accesses;
5990
+ const emailDomains = data.email_domains;
5991
+ const users = data.users;
5992
+ store.dispatch(addUsers(users));
5993
+ store.dispatch(setActiveOrganizationId(activeOrganization.id));
5994
+ store.dispatch(setOrganizationAccesses(organizationAccesses));
5995
+ store.dispatch(setEmailDomains(emailDomains));
5996
+ if (showLoading) {
5997
+ store.dispatch(setIsFetchingInitialData(false));
5998
+ }
5999
+ }
5937
6000
  async create(name) {
5938
6001
  const result = await this.enqueueRequest({
5939
6002
  description: "Create organization",
@@ -6050,11 +6113,6 @@ var __publicField = (obj, key, value) => {
6050
6113
  };
6051
6114
  }
6052
6115
  }
6053
- const emptyBaseField = {
6054
- label: "",
6055
- required: false,
6056
- description: ""
6057
- };
6058
6116
  class BaseField extends BaseFormElement {
6059
6117
  constructor(options) {
6060
6118
  const { label, required, fieldValidators = [], formValidators = [], ...base } = options;
@@ -6119,29 +6177,25 @@ var __publicField = (obj, key, value) => {
6119
6177
  __publicField(BaseField, "fieldTypeName");
6120
6178
  __publicField(BaseField, "fieldTypeDescription");
6121
6179
  const description$1 = "_description_17zed_1";
6122
- const styles$5 = {
6180
+ const styles$4 = {
6123
6181
  description: description$1
6124
6182
  };
6125
6183
  const InputWithLabel = (props) => {
6126
- const { label, children, size, severity, inputId, labelId, flexProps } = props;
6184
+ const { label, children, severity, inputId, labelId, flexProps } = props;
6127
6185
  return /* @__PURE__ */ jsxRuntime.jsx(blocks.Flex, { direction: "column", gap: "1", asChild: true, ...flexProps, children: /* @__PURE__ */ jsxRuntime.jsxs("label", { htmlFor: inputId, children: [
6128
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size, severity, id: labelId, children: label }),
6186
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { severity, id: labelId, children: label }),
6129
6187
  children
6130
6188
  ] }) });
6131
6189
  };
6132
- const InputWithHelpText = (props) => {
6190
+ const InputWithLabelAndHelpText = (props) => {
6133
6191
  const { helpText, children, severity } = props;
6134
6192
  return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "1", children: [
6135
6193
  children,
6136
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Flex, { direction: "column", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "1", severity, className: styles$5.description, children: helpText }) })
6194
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Flex, { direction: "column", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "1", severity, className: styles$4.description, children: helpText }) })
6137
6195
  ] });
6138
6196
  };
6139
- const InputWithLabelAndHelpText = (props) => {
6140
- const { children, ...restProps } = props;
6141
- return /* @__PURE__ */ jsxRuntime.jsx(InputWithHelpText, { ...restProps, children });
6142
- };
6143
6197
  const useFormikInput = (props) => {
6144
- const { id, field, formId: formId2, size, ...rest } = props;
6198
+ const { id, field, formId: formId2, ...rest } = props;
6145
6199
  const [fieldProps, meta, helpers] = formik.useField(field.getId());
6146
6200
  const { touched } = meta;
6147
6201
  const helpText = meta.error ?? field.description;
@@ -6170,7 +6224,6 @@ var __publicField = (obj, key, value) => {
6170
6224
  return [
6171
6225
  {
6172
6226
  helpText,
6173
- size,
6174
6227
  severity,
6175
6228
  inputId,
6176
6229
  labelId,
@@ -6184,13 +6237,12 @@ var __publicField = (obj, key, value) => {
6184
6237
  };
6185
6238
  const truthyValues = [true, "true"];
6186
6239
  const BooleanInput = React.memo(function BooleanInput2(props) {
6187
- const [{ inputId, labelId, size, severity, helpText, label, fieldProps }, rest] = useFormikInput(props);
6240
+ const [{ inputId, labelId, severity, helpText, label, fieldProps }, rest] = useFormikInput(props);
6188
6241
  const color = blocks.useSeverityColor(severity);
6189
6242
  const value = truthyValues.includes(fieldProps.value);
6190
6243
  return /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText, severity, children: /* @__PURE__ */ jsxRuntime.jsx(
6191
6244
  InputWithLabel,
6192
6245
  {
6193
- size,
6194
6246
  severity,
6195
6247
  inputId,
6196
6248
  labelId,
@@ -6206,7 +6258,6 @@ var __publicField = (obj, key, value) => {
6206
6258
  value: value.toString(),
6207
6259
  checked: value,
6208
6260
  onCheckedChange: fieldProps.onChange,
6209
- alwaysShow: true,
6210
6261
  onChange: void 0,
6211
6262
  onBlur: void 0
6212
6263
  }
@@ -6228,42 +6279,6 @@ var __publicField = (obj, key, value) => {
6228
6279
  }
6229
6280
  return target;
6230
6281
  }
6231
- var _excluded$e = ["color"];
6232
- var ArrowDownIcon = /* @__PURE__ */ React.forwardRef(function(_ref, forwardedRef) {
6233
- var _ref$color = _ref.color, color = _ref$color === void 0 ? "currentColor" : _ref$color, props = _objectWithoutPropertiesLoose(_ref, _excluded$e);
6234
- return React.createElement("svg", Object.assign({
6235
- width: "15",
6236
- height: "15",
6237
- viewBox: "0 0 15 15",
6238
- fill: "none",
6239
- xmlns: "http://www.w3.org/2000/svg"
6240
- }, props, {
6241
- ref: forwardedRef
6242
- }), React.createElement("path", {
6243
- 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",
6244
- fill: color,
6245
- fillRule: "evenodd",
6246
- clipRule: "evenodd"
6247
- }));
6248
- });
6249
- var _excluded$j = ["color"];
6250
- var ArrowUpIcon = /* @__PURE__ */ React.forwardRef(function(_ref, forwardedRef) {
6251
- var _ref$color = _ref.color, color = _ref$color === void 0 ? "currentColor" : _ref$color, props = _objectWithoutPropertiesLoose(_ref, _excluded$j);
6252
- return React.createElement("svg", Object.assign({
6253
- width: "15",
6254
- height: "15",
6255
- viewBox: "0 0 15 15",
6256
- fill: "none",
6257
- xmlns: "http://www.w3.org/2000/svg"
6258
- }, props, {
6259
- ref: forwardedRef
6260
- }), React.createElement("path", {
6261
- 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",
6262
- fill: color,
6263
- fillRule: "evenodd",
6264
- clipRule: "evenodd"
6265
- }));
6266
- });
6267
6282
  var _excluded$I = ["color"];
6268
6283
  var CalendarIcon = /* @__PURE__ */ React.forwardRef(function(_ref, forwardedRef) {
6269
6284
  var _ref$color = _ref.color, color = _ref$color === void 0 ? "currentColor" : _ref$color, props = _objectWithoutPropertiesLoose(_ref, _excluded$I);
@@ -6372,6 +6387,24 @@ var __publicField = (obj, key, value) => {
6372
6387
  clipRule: "evenodd"
6373
6388
  }));
6374
6389
  });
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
+ });
6375
6408
  var _excluded$1W = ["color"];
6376
6409
  var DropdownMenuIcon = /* @__PURE__ */ React.forwardRef(function(_ref, forwardedRef) {
6377
6410
  var _ref$color = _ref.color, color = _ref$color === void 0 ? "currentColor" : _ref$color, props = _objectWithoutPropertiesLoose(_ref, _excluded$1W);
@@ -6406,9 +6439,9 @@ var __publicField = (obj, key, value) => {
6406
6439
  fill: color
6407
6440
  }));
6408
6441
  });
6409
- var _excluded$2l = ["color"];
6410
- var GearIcon = /* @__PURE__ */ React.forwardRef(function(_ref, forwardedRef) {
6411
- var _ref$color = _ref.color, color = _ref$color === void 0 ? "currentColor" : _ref$color, props = _objectWithoutPropertiesLoose(_ref, _excluded$2l);
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);
6412
6445
  return React.createElement("svg", Object.assign({
6413
6446
  width: "15",
6414
6447
  height: "15",
@@ -6418,15 +6451,15 @@ var __publicField = (obj, key, value) => {
6418
6451
  }, props, {
6419
6452
  ref: forwardedRef
6420
6453
  }), React.createElement("path", {
6421
- 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",
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",
6422
6455
  fill: color,
6423
6456
  fillRule: "evenodd",
6424
6457
  clipRule: "evenodd"
6425
6458
  }));
6426
6459
  });
6427
- var _excluded$2E = ["color"];
6428
- var InputIcon = /* @__PURE__ */ React.forwardRef(function(_ref, forwardedRef) {
6429
- var _ref$color = _ref.color, color = _ref$color === void 0 ? "currentColor" : _ref$color, props = _objectWithoutPropertiesLoose(_ref, _excluded$2E);
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);
6430
6463
  return React.createElement("svg", Object.assign({
6431
6464
  width: "15",
6432
6465
  height: "15",
@@ -6436,15 +6469,15 @@ var __publicField = (obj, key, value) => {
6436
6469
  }, props, {
6437
6470
  ref: forwardedRef
6438
6471
  }), React.createElement("path", {
6439
- 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",
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",
6440
6473
  fill: color,
6441
6474
  fillRule: "evenodd",
6442
6475
  clipRule: "evenodd"
6443
6476
  }));
6444
6477
  });
6445
- var _excluded$2Z = ["color"];
6446
- var ListBulletIcon = /* @__PURE__ */ React.forwardRef(function(_ref, forwardedRef) {
6447
- var _ref$color = _ref.color, color = _ref$color === void 0 ? "currentColor" : _ref$color, props = _objectWithoutPropertiesLoose(_ref, _excluded$2Z);
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);
6448
6481
  return React.createElement("svg", Object.assign({
6449
6482
  width: "15",
6450
6483
  height: "15",
@@ -6454,7 +6487,7 @@ var __publicField = (obj, key, value) => {
6454
6487
  }, props, {
6455
6488
  ref: forwardedRef
6456
6489
  }), React.createElement("path", {
6457
- 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",
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",
6458
6491
  fill: color,
6459
6492
  fillRule: "evenodd",
6460
6493
  clipRule: "evenodd"
@@ -6602,10 +6635,6 @@ var __publicField = (obj, key, value) => {
6602
6635
  clipRule: "evenodd"
6603
6636
  }));
6604
6637
  });
6605
- const emptyBooleanField = {
6606
- ...emptyBaseField,
6607
- type: "boolean"
6608
- };
6609
6638
  const _BooleanField = class _BooleanField extends BaseField {
6610
6639
  constructor(options) {
6611
6640
  super({ ...options, type: "boolean" });
@@ -8030,9 +8059,9 @@ var __publicField = (obj, key, value) => {
8030
8059
  Content: TabsContent
8031
8060
  });
8032
8061
  const NumberInput$1 = React.memo(function NumberInput2(props) {
8033
- const [{ inputId, labelId, size, severity, helpText, label, fieldProps, field }, rest] = useFormikInput(props);
8062
+ const [{ inputId, labelId, severity, helpText, label, fieldProps, field }, rest] = useFormikInput(props);
8034
8063
  const color = blocks.useSeverityColor(severity);
8035
- return /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText, severity, children: /* @__PURE__ */ jsxRuntime.jsx(InputWithLabel, { size, severity, inputId, labelId, label, children: /* @__PURE__ */ jsxRuntime.jsx(
8064
+ return /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText, severity, children: /* @__PURE__ */ jsxRuntime.jsx(InputWithLabel, { severity, inputId, labelId, label, children: /* @__PURE__ */ jsxRuntime.jsx(
8036
8065
  TextField$1.Input,
8037
8066
  {
8038
8067
  ...rest,
@@ -8046,6 +8075,144 @@ var __publicField = (obj, key, value) => {
8046
8075
  }
8047
8076
  ) }) });
8048
8077
  });
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;
8049
8216
  class StringOrTextField extends BaseField {
8050
8217
  constructor(options) {
8051
8218
  const { minLength, maxLength = 5e3, ...base } = options;
@@ -8055,40 +8222,31 @@ var __publicField = (obj, key, value) => {
8055
8222
  this.minLength = minLength ? Math.max(minLength, 0) : void 0;
8056
8223
  this.maxLength = maxLength ? Math.max(maxLength, 0) : 5e3;
8057
8224
  }
8058
- static getFieldCreationSchema(parentPath = "") {
8059
- const path = parentPath && `${parentPath}.`;
8225
+ static getFieldCreationSchema() {
8060
8226
  return [
8061
- {
8062
- field: (
8063
- // min, max
8064
- new NumberField({
8065
- label: "Minimum length",
8066
- description: "Minimum number of characters",
8067
- required: false,
8068
- identifier: `${path}minimum_length`,
8069
- minimum: 0,
8070
- maximum: 100,
8071
- formValidators: [this._validateMin(parentPath)],
8072
- integers: true
8073
- })
8074
- ),
8075
- showDirectly: false
8076
- },
8077
- {
8078
- field: new NumberField({
8079
- label: "Maximum length",
8080
- description: "Maximum number of characters",
8081
- required: false,
8082
- identifier: `${path}maximum_length`,
8083
- minimum: 1,
8084
- maximum: 5e3,
8085
- // TODO: depends on short vs long text
8086
- formValidators: [this._validateMax(parentPath)],
8087
- // TODO: default: 500 (see: "Short text fields can hold up to 500 characters on a single line.")
8088
- integers: true
8089
- }),
8090
- showDirectly: false
8091
- }
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
+ })
8092
8250
  ];
8093
8251
  }
8094
8252
  getFieldValidators() {
@@ -8123,24 +8281,23 @@ var __publicField = (obj, key, value) => {
8123
8281
  }
8124
8282
  }
8125
8283
  /**
8126
- * This function returns a function that validates that the value given for "minimum length" (when creating a new field) is less than or
8284
+ * This function validates that the value given for "minimum length" (when creating a new field) is less than or
8127
8285
  * equal to the value given for "maximum length".
8128
8286
  */
8129
- __publicField(StringOrTextField, "_validateMin", (path) => (value, allValues) => {
8130
- const field = valueIsFormikUserFormRevision(allValues) ? get(allValues, path) : allValues;
8131
- if (typeof field.maximum_length === "number" && typeof value === "number" && field.maximum_length < value) {
8287
+ __publicField(StringOrTextField, "_validateMin", (value, allValues) => {
8288
+ if (typeof allValues.maximum_length === "number" && typeof value === "number" && allValues.maximum_length < value) {
8132
8289
  return "Minimum cannot be greater than maximum.";
8133
8290
  }
8134
8291
  return null;
8135
8292
  });
8136
8293
  /**
8137
- * This function returns a function that validates that the value given for "maximum length" (when creating a new field) is greater than or
8294
+ * This function validates that the value given for "maximum length" (when creating a new field) is greater than or
8138
8295
  * equal to the value given for "minimum length".
8139
8296
  */
8140
- __publicField(StringOrTextField, "_validateMax", (path) => (value, allValues) => {
8297
+ __publicField(StringOrTextField, "_validateMax", (value, allValues) => {
8141
8298
  if (typeof value !== "number")
8142
8299
  return null;
8143
- const { minimum_length: minimumLength } = valueIsFormikUserFormRevision(allValues) ? get(allValues, path) : allValues;
8300
+ const { minimum_length: minimumLength } = allValues;
8144
8301
  if (typeof minimumLength !== "number") {
8145
8302
  return null;
8146
8303
  }
@@ -8151,20 +8308,20 @@ var __publicField = (obj, key, value) => {
8151
8308
  });
8152
8309
  const clickableLinkContainer = "_clickableLinkContainer_1ace7_1";
8153
8310
  const TextFieldInputCopy = "_TextFieldInputCopy_1ace7_5";
8154
- const styles$4 = {
8311
+ const styles$3 = {
8155
8312
  clickableLinkContainer,
8156
8313
  TextFieldInputCopy
8157
8314
  };
8158
8315
  const StringInput = React.memo(function StringInput2(props) {
8159
- const [{ inputId, labelId, size, severity, helpText, label, fieldProps, field }, rest] = useFormikInput(props);
8316
+ const [{ inputId, labelId, severity, helpText, label, fieldProps, field }, rest] = useFormikInput(props);
8160
8317
  const color = blocks.useSeverityColor(severity);
8161
- 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: [
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: [
8162
8319
  /* @__PURE__ */ jsxRuntime.jsx(
8163
8320
  "div",
8164
8321
  {
8165
8322
  className: classNames$1(
8166
8323
  "rt-TextFieldInput rt-r-size-2 rt-variant-surface",
8167
- styles$4.TextFieldInputCopy
8324
+ styles$3.TextFieldInputCopy
8168
8325
  ),
8169
8326
  children: /* @__PURE__ */ jsxRuntime.jsx(
8170
8327
  Linkify,
@@ -8181,12 +8338,6 @@ var __publicField = (obj, key, value) => {
8181
8338
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rt-TextFieldChrome" })
8182
8339
  ] }) }) });
8183
8340
  });
8184
- const emptyStringField = {
8185
- ...emptyBaseField,
8186
- type: "string",
8187
- maximum_length: 500,
8188
- input_type: "text"
8189
- };
8190
8341
  const _StringField = class _StringField extends StringOrTextField {
8191
8342
  constructor(options) {
8192
8343
  const { inputType = "text", ...rest } = options;
@@ -8214,14 +8365,9 @@ var __publicField = (obj, key, value) => {
8214
8365
  __publicField(_StringField, "Icon", InputIcon);
8215
8366
  let StringField = _StringField;
8216
8367
  const TextInput = React.memo(function TextInput2(props) {
8217
- const [{ inputId, labelId, size, severity, helpText, label, fieldProps }, rest] = useFormikInput(props);
8218
- 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 }) }) });
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 }) }) });
8219
8370
  });
8220
- const emptyTextField = {
8221
- ...emptyBaseField,
8222
- type: "text",
8223
- maximum_length: 5e3
8224
- };
8225
8371
  const _TextField = class _TextField extends StringOrTextField {
8226
8372
  constructor(options) {
8227
8373
  const maxLength = options.maxLength ? Math.min(5e3, options.maxLength) : 5e3;
@@ -8245,42 +8391,8 @@ var __publicField = (obj, key, value) => {
8245
8391
  __publicField(_TextField, "fieldTypeDescription", "Paragraph fields can hold up to 5000 characters and can have multiple lines.");
8246
8392
  __publicField(_TextField, "Icon", RowsIcon);
8247
8393
  let TextField = _TextField;
8248
- const DateInput = React.memo(function DateInput2(props) {
8249
- const [{ inputId, labelId, size, severity, helpText, label, fieldProps }, rest] = useFormikInput(props);
8250
- const color = blocks.useSeverityColor(severity);
8251
- const value = fieldProps.value ? fieldProps.value.split("T")[0] : "";
8252
- 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 }) }) });
8253
- });
8254
- const emptyDateField = {
8255
- ...emptyBaseField,
8256
- type: "date"
8257
- };
8258
- const _DateField = class _DateField extends BaseField {
8259
- constructor(options) {
8260
- super({ ...options, type: "date" });
8261
- __publicField(this, "onlyValidateAfterTouched", false);
8262
- }
8263
- serialize() {
8264
- return super._serialize();
8265
- }
8266
- getValueFromChangeEvent(event) {
8267
- return new Date(event.target.value).toISOString();
8268
- }
8269
- static deserialize(data) {
8270
- if (data.type !== "date")
8271
- throw new Error("Type mismatch.");
8272
- return new _DateField(data);
8273
- }
8274
- getInput(props) {
8275
- return /* @__PURE__ */ jsxRuntime.jsx(DateInput, { field: this, ...props });
8276
- }
8277
- };
8278
- __publicField(_DateField, "fieldTypeName", "Date");
8279
- __publicField(_DateField, "fieldTypeDescription", "Allows specifying a date.");
8280
- __publicField(_DateField, "Icon", CalendarIcon);
8281
- let DateField = _DateField;
8282
8394
  const SelectInput = React.memo(function SelectInput2(props) {
8283
- const [{ inputId, labelId, size, severity, helpText, label, fieldProps, field }, rest] = useFormikInput(props);
8395
+ const [{ inputId, labelId, severity, helpText, label, fieldProps, field }, rest] = useFormikInput(props);
8284
8396
  const { onChange, onBlur } = fieldProps;
8285
8397
  const options = React.useMemo(
8286
8398
  () => field.options.map((option) => ({ value: option.value, itemContent: option.label })),
@@ -8293,7 +8405,7 @@ var __publicField = (obj, key, value) => {
8293
8405
  },
8294
8406
  [onChange, onBlur]
8295
8407
  );
8296
- return /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText, severity, children: /* @__PURE__ */ jsxRuntime.jsx(InputWithLabel, { size, severity, inputId, labelId, label, children: /* @__PURE__ */ jsxRuntime.jsx(
8408
+ return /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText, severity, children: /* @__PURE__ */ jsxRuntime.jsx(InputWithLabel, { severity, inputId, labelId, label, children: /* @__PURE__ */ jsxRuntime.jsx(
8297
8409
  blocks.Select,
8298
8410
  {
8299
8411
  items: options,
@@ -8344,6 +8456,11 @@ var __publicField = (obj, key, value) => {
8344
8456
  result.splice(destination, 0, removed);
8345
8457
  return result;
8346
8458
  }
8459
+ function replace(list, index2, value) {
8460
+ const result = Array.from(list);
8461
+ result[index2] = value;
8462
+ return result;
8463
+ }
8347
8464
  function insert(list, index2, value) {
8348
8465
  const result = Array.from(list ?? []);
8349
8466
  result.splice(index2, 0, value);
@@ -8378,7 +8495,9 @@ var __publicField = (obj, key, value) => {
8378
8495
  return sections.filter((_, i) => i < index2).flatMap((field) => field.fields);
8379
8496
  };
8380
8497
  const getTakenFieldLabels = (fields) => {
8381
- return fields.flatMap((field) => [...field.fields.map((f) => f.label), field.label]).filter((id) => id !== null);
8498
+ return fields.flatMap(
8499
+ (field) => field.type === "section" ? [...field.fields.map((f) => f.label), field.label] : field.label
8500
+ ).filter((id) => id !== null);
8382
8501
  };
8383
8502
  const incrementFieldLabel = (label, takenLabels) => {
8384
8503
  let count = 1;
@@ -8388,90 +8507,8 @@ var __publicField = (obj, key, value) => {
8388
8507
  }
8389
8508
  return newLabel;
8390
8509
  };
8391
- const createNewField = (parentPath, index2, initialValues2, values, setFieldValue) => {
8392
- const { label } = initialValues2;
8393
- const newField = {
8394
- ...initialValues2,
8395
- identifier: makeIdentifier(null, label)
8396
- };
8397
- const parent = get(values, parentPath);
8398
- if (parent === void 0) {
8399
- throw new Error("Parent path must point to an existing field.");
8400
- }
8401
- if (!Array.isArray(parent)) {
8402
- throw new Error("Parent path must point to an array.");
8403
- }
8404
- const updatedFields = insert(parent, index2, newField);
8405
- void setFieldValue(parentPath, updatedFields).then();
8406
- };
8407
- const createNewEmptySection = (index2, values, setFieldValue) => {
8408
- const initialValues2 = {
8409
- ...emptySection(),
8410
- label: ""
8411
- };
8412
- createNewField("fields", index2, initialValues2, values, setFieldValue);
8413
- };
8414
- const useFieldReordering = () => {
8415
- const { showError } = blocks.useToast();
8416
- const reorderSection = React.useCallback(
8417
- (dropState, sectionId, sectionIndex, destinationIndex, values, setFieldValue) => {
8418
- const state = dropState[sectionId];
8419
- if (!state)
8420
- throw new Error("Could not find section context.");
8421
- let dest = typeof state.conditionIndex !== "undefined" ? (
8422
- // cannot move a section with a condition before the condition's field
8423
- Math.max(state.conditionIndex + 1, destinationIndex)
8424
- ) : destinationIndex;
8425
- for (const section of Object.values(dropState)) {
8426
- if (section.conditionIndex === sectionIndex) {
8427
- dest = Math.min(dest, section.index - 1);
8428
- }
8429
- }
8430
- if (dest !== destinationIndex) {
8431
- showError({
8432
- title: "Could not reorder sections",
8433
- description: "Sections with conditions must be below the fields they reference."
8434
- });
8435
- return;
8436
- }
8437
- void setFieldValue("fields", reorder(values.fields, sectionIndex, dest));
8438
- },
8439
- [showError]
8440
- );
8441
- const reorderField = React.useCallback(
8442
- (srcSection, srcSectionIndex, srcFieldIndex, destSection, destSectionIndex, destFieldIndex, setFieldValue) => {
8443
- var _a2;
8444
- if (!(srcSection == null ? void 0 : srcSection.fields) || !destSection)
8445
- throw new Error("Could not find section with fields.");
8446
- if (srcSection.identifier === destSection.identifier) {
8447
- void setFieldValue(
8448
- `fields.${srcSectionIndex}.fields`,
8449
- reorder(srcSection.fields, srcFieldIndex, destFieldIndex)
8450
- ).then();
8451
- } else {
8452
- const removed = srcSection.fields[srcFieldIndex];
8453
- if (!removed)
8454
- throw new Error("Could not find field to reorder.");
8455
- if (((_a2 = destSection.condition) == null ? void 0 : _a2.identifier) === removed.identifier) {
8456
- showError({
8457
- title: "Could not reorder field",
8458
- description: "Field must be above the section whose condition references it."
8459
- });
8460
- return;
8461
- }
8462
- void setFieldValue(`fields.${srcSectionIndex}.fields`, remove(srcSection.fields, srcFieldIndex)).then();
8463
- void setFieldValue(
8464
- `fields.${destSectionIndex}.fields`,
8465
- insert(destSection.fields, destFieldIndex, removed)
8466
- ).then();
8467
- }
8468
- },
8469
- [showError]
8470
- );
8471
- return { reorderSection, reorderField };
8472
- };
8473
8510
  const MultiStringInput = React.memo(function MultiStringInput2(props) {
8474
- const [{ inputId, labelId, size, severity, helpText, label, fieldProps }, rest] = useFormikInput(props);
8511
+ const [{ inputId, labelId, severity, helpText, label, fieldProps }, rest] = useFormikInput(props);
8475
8512
  const color = blocks.useSeverityColor(severity);
8476
8513
  const value = React.useMemo(
8477
8514
  () => Array.isArray(fieldProps.value) ? fieldProps.value : [],
@@ -8541,7 +8578,7 @@ var __publicField = (obj, key, value) => {
8541
8578
  [setValueAndTouched, value]
8542
8579
  );
8543
8580
  return /* @__PURE__ */ jsxRuntime.jsx(dnd.DragDropContext, { onDragEnd: handleDragEnd, children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "2", children: [
8544
- /* @__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: [
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: [
8545
8582
  /* @__PURE__ */ jsxRuntime.jsx(Box, { grow: "1", children: /* @__PURE__ */ jsxRuntime.jsx(
8546
8583
  TextField$1.Input,
8547
8584
  {
@@ -8612,12 +8649,6 @@ var __publicField = (obj, key, value) => {
8612
8649
  ] }) })
8613
8650
  ] }) });
8614
8651
  });
8615
- const emptyMultiStringField = {
8616
- ...emptyBaseField,
8617
- type: "multi-string",
8618
- minimum_length: 0,
8619
- maximum_length: null
8620
- };
8621
8652
  const _MultiStringField = class _MultiStringField extends BaseField {
8622
8653
  constructor(options) {
8623
8654
  const { minimum_length, maximum_length, ...rest } = options;
@@ -8692,28 +8723,19 @@ var __publicField = (obj, key, value) => {
8692
8723
  options: this.options
8693
8724
  };
8694
8725
  }
8695
- static getFieldCreationSchema(parentPath = "") {
8696
- const path = parentPath && `${parentPath}.`;
8726
+ static getFieldCreationSchema() {
8697
8727
  return [
8698
- {
8699
- field: new MultiStringField({
8700
- label: "Options",
8701
- description: "List possible options for the user to select from.",
8702
- required: true,
8703
- identifier: `${path}options`,
8704
- minimum_length: 2,
8705
- maximum_length: 20
8706
- }),
8707
- showDirectly: true
8708
- }
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
+ })
8709
8736
  ];
8710
8737
  }
8711
8738
  }
8712
- const emptySelectField = {
8713
- ...emptyBaseField,
8714
- type: "select",
8715
- options: []
8716
- };
8717
8739
  const _SelectField = class _SelectField extends BaseSelectField {
8718
8740
  constructor(options) {
8719
8741
  super({ ...options, type: "select" });
@@ -8747,7 +8769,7 @@ var __publicField = (obj, key, value) => {
8747
8769
  return [value];
8748
8770
  };
8749
8771
  const MultiSelectInput = React.memo(function MultiSelectInput2(props) {
8750
- const [{ inputId, labelId, size, severity, helpText, label, fieldProps, field }, rest] = useFormikInput(props);
8772
+ const [{ inputId, labelId, severity, helpText, label, fieldProps, field }, rest] = useFormikInput(props);
8751
8773
  const { onChange, onBlur } = fieldProps;
8752
8774
  const value = React.useMemo(() => parseValueToArray(fieldProps.value), [fieldProps.value]);
8753
8775
  const handleChange = React.useCallback(
@@ -8757,7 +8779,7 @@ var __publicField = (obj, key, value) => {
8757
8779
  },
8758
8780
  [onChange, onBlur]
8759
8781
  );
8760
- return /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText, severity, children: /* @__PURE__ */ jsxRuntime.jsx(InputWithLabel, { size, severity, inputId, labelId, label, children: /* @__PURE__ */ jsxRuntime.jsx(
8782
+ return /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText, severity, children: /* @__PURE__ */ jsxRuntime.jsx(InputWithLabel, { severity, inputId, labelId, label, children: /* @__PURE__ */ jsxRuntime.jsx(
8761
8783
  blocks.MultiSelect,
8762
8784
  {
8763
8785
  value,
@@ -8771,11 +8793,6 @@ var __publicField = (obj, key, value) => {
8771
8793
  }
8772
8794
  ) }) });
8773
8795
  });
8774
- const emptyMultiSelectField = {
8775
- ...emptyBaseField,
8776
- type: "multi-select",
8777
- options: []
8778
- };
8779
8796
  const _MultiSelectField = class _MultiSelectField extends BaseSelectField {
8780
8797
  constructor(options) {
8781
8798
  super({ ...options, type: "multi-select" });
@@ -8804,10 +8821,16 @@ var __publicField = (obj, key, value) => {
8804
8821
  __publicField(_MultiSelectField, "fieldTypeDescription", "Allows the user to select a multiple options from a list of options.");
8805
8822
  __publicField(_MultiSelectField, "Icon", CheckboxIcon);
8806
8823
  let MultiSelectField = _MultiSelectField;
8807
- const emptyCustomField = {
8808
- ...emptyBaseField,
8809
- type: "custom"
8810
- };
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
+ });
8811
8834
  class CustomField extends BaseField {
8812
8835
  constructor(options, Component) {
8813
8836
  super({ ...options, type: "custom" });
@@ -8827,8 +8850,13 @@ var __publicField = (obj, key, value) => {
8827
8850
  }
8828
8851
  __publicField(CustomField, "fieldTypeName", "Custom");
8829
8852
  __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
+ }
8830
8858
  const previewImage = "_previewImage_1ig84_1";
8831
- const styles$3 = {
8859
+ const styles$2 = {
8832
8860
  previewImage
8833
8861
  };
8834
8862
  const convertBytesToLargestUnit = (bytes) => {
@@ -8849,7 +8877,7 @@ var __publicField = (obj, key, value) => {
8849
8877
  };
8850
8878
  const NumberInput = React.memo(function NumberInput2(props) {
8851
8879
  var _a2;
8852
- const [{ inputId, labelId, size, severity, helpText, label, fieldProps, field }, rest] = useFormikInput(props);
8880
+ const [{ inputId, labelId, severity, helpText, label, fieldProps, field }, rest] = useFormikInput(props);
8853
8881
  const { onChange } = fieldProps;
8854
8882
  const color = blocks.useSeverityColor(severity);
8855
8883
  const input = React.useRef(null);
@@ -8879,7 +8907,7 @@ var __publicField = (obj, key, value) => {
8879
8907
  const singleButtonText = value ? "Select new file" : "Select a file";
8880
8908
  const buttonText = field.maxFiles > 1 ? multipleButtonText : singleButtonText;
8881
8909
  return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "2", children: [
8882
- /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText: updatedHelpText, severity, children: /* @__PURE__ */ jsxRuntime.jsxs(InputWithLabel, { size, severity, inputId, labelId, label, children: [
8910
+ /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText: updatedHelpText, severity, children: /* @__PURE__ */ jsxRuntime.jsxs(InputWithLabel, { severity, inputId, labelId, label, children: [
8883
8911
  /* @__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: [
8884
8912
  /* @__PURE__ */ jsxRuntime.jsx(UploadIcon, {}),
8885
8913
  " ",
@@ -8960,16 +8988,9 @@ var __publicField = (obj, key, value) => {
8960
8988
  error && /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "1", severity: "danger", children: error })
8961
8989
  ] })
8962
8990
  ] }),
8963
- url && /* @__PURE__ */ jsxRuntime.jsx("img", { className: styles$3.previewImage, src: url, alt: name })
8991
+ url && /* @__PURE__ */ jsxRuntime.jsx("img", { className: styles$2.previewImage, src: url, alt: name })
8964
8992
  ] }) });
8965
8993
  });
8966
- const emptyUploadField = {
8967
- ...emptyBaseField,
8968
- type: "upload",
8969
- extensions: [],
8970
- maximum_size: void 0,
8971
- maximum_files: 1
8972
- };
8973
8994
  const largestSupportedSize = 50;
8974
8995
  const _UploadField = class _UploadField extends BaseField {
8975
8996
  constructor(options) {
@@ -8989,65 +9010,55 @@ var __publicField = (obj, key, value) => {
8989
9010
  isBlank(value) {
8990
9011
  return super.isBlank(value) || value.length === 0;
8991
9012
  }
8992
- static getFieldCreationSchema(parentPath = "") {
8993
- const path = parentPath && `${parentPath}.`;
9013
+ static getFieldCreationSchema() {
8994
9014
  return [
8995
- {
8996
- field: new NumberField({
8997
- label: "How many files can be uploaded?",
8998
- description: "By default, only one file can be uploaded.",
8999
- required: false,
9000
- minimum: 1,
9001
- maximum: 10,
9002
- identifier: `${path}maximum_files`,
9003
- integers: true
9004
- }),
9005
- showDirectly: false
9006
- },
9007
- {
9008
- field: new NumberField({
9009
- // TODO: Default value
9010
- label: "What is the maximum size of each file?",
9011
- description: `Maximum file size in megabytes (between 1MB–${largestSupportedSize}MB).`,
9012
- required: false,
9013
- identifier: `${path}maximum_size`,
9014
- minimum: 1,
9015
- maximum: largestSupportedSize,
9016
- integers: true
9017
- }),
9018
- showDirectly: false
9019
- },
9020
- {
9021
- field: new MultiSelectField({
9022
- label: "Accepted file types",
9023
- description: "Types of allowed files to upload. If left blank, all files will be accepted.",
9024
- required: false,
9025
- identifier: `${path}extensions`,
9026
- options: [
9027
- {
9028
- value: "image/*",
9029
- label: "Images"
9030
- },
9031
- {
9032
- value: "audio/*",
9033
- label: "Audio files"
9034
- },
9035
- {
9036
- value: "video/*",
9037
- label: "Videos"
9038
- },
9039
- {
9040
- value: "text/*",
9041
- label: "Text files"
9042
- },
9043
- {
9044
- value: "application/*",
9045
- label: "Application files (includes PDFs and Word documents)"
9046
- }
9047
- ]
9048
- }),
9049
- showDirectly: false
9050
- }
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
+ })
9051
9062
  ];
9052
9063
  }
9053
9064
  getFieldValidators() {
@@ -9101,33 +9112,44 @@ var __publicField = (obj, key, value) => {
9101
9112
  "multi-string": MultiStringField,
9102
9113
  "multi-select": MultiSelectField
9103
9114
  };
9104
- const FieldTypeToEmptyFieldMapping = {
9105
- date: emptyDateField,
9106
- number: emptyNumberField,
9107
- boolean: emptyBooleanField,
9108
- select: emptySelectField,
9109
- string: emptyStringField,
9110
- text: emptyTextField,
9111
- custom: emptyCustomField,
9112
- upload: emptyUploadField,
9113
- // TODO: Underscore
9114
- "multi-string": emptyMultiStringField,
9115
- "multi-select": emptyMultiSelectField
9115
+ const deserializeField = (serializedField) => {
9116
+ const fieldType = serializedField.type;
9117
+ const fieldCls = FieldTypeToClsMapping[fieldType];
9118
+ return fieldCls.deserialize(serializedField);
9116
9119
  };
9117
- const FieldInputCloner = React.memo(function FieldInputCloner2({ field, ...props }) {
9118
- const [{ value: identifier }] = formik.useField(field.options.clonedFieldIdentifier);
9119
- const deserializedField = React.useMemo(() => {
9120
- const options = field.options.getFieldToClone(identifier);
9121
- if (!options)
9122
- return null;
9123
- return deserialize(options);
9124
- }, [field.options, identifier]);
9125
- return useFieldInput(deserializedField, props);
9126
- });
9127
- class FieldInputClonerField extends CustomField {
9128
- constructor(options) {
9129
- super(options, FieldInputCloner);
9120
+ const deserialize = (serialized) => {
9121
+ if (serialized.type === "section") {
9122
+ return FieldSection.deserialize(serialized);
9123
+ }
9124
+ return deserializeField(serialized);
9125
+ };
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;
9130
9151
  }
9152
+ return valueToCompare === value;
9131
9153
  }
9132
9154
  const useFieldInput = (field, props) => {
9133
9155
  return React.useMemo(() => {
@@ -9170,7 +9192,7 @@ var __publicField = (obj, key, value) => {
9170
9192
  return /* @__PURE__ */ jsxRuntime.jsx(Card, { children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "3", children: [
9171
9193
  /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", children: [
9172
9194
  /* @__PURE__ */ jsxRuntime.jsx(Heading, { as: "h3", size: "3", children: label }),
9173
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$5.description, children: description2 })
9195
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$4.description, children: description2 })
9174
9196
  ] }),
9175
9197
  inputs
9176
9198
  ] }) });
@@ -9189,89 +9211,85 @@ var __publicField = (obj, key, value) => {
9189
9211
  this.condition = null;
9190
9212
  }
9191
9213
  }
9192
- static getFieldCreationSchema(options, parentPath) {
9214
+ static getFieldCreationSchema(options) {
9193
9215
  if (options.length === 0)
9194
9216
  return [];
9195
- const path = parentPath ? `${parentPath}.` : "";
9196
9217
  return [
9197
- {
9198
- field: new BooleanField({
9199
- label: "Conditionally render section",
9200
- identifier: `${path}conditional`,
9201
- required: false
9202
- }),
9203
- showDirectly: true
9204
- },
9205
- {
9206
- // Declare a section that will hold options for the condition (if any).
9207
- field: new _FieldSection({
9208
- label: "Conditional settings",
9209
- identifier: `${path}conditional-settings`,
9210
- // This section will only be rendered if the above "Conditional" field is checked.
9211
- condition: {
9212
- identifier: `${path}conditional`,
9213
- value: true
9214
- },
9215
- // These are the options of the condition.
9216
- fields: [
9217
- // Declare a select field that will be used to select the field against which we will check the
9218
- // condition. This must be selected before the next field is rendered.
9219
- new SelectField({
9220
- label: "Field",
9221
- description: "The field to use for the condition.",
9222
- // The options (for the field against which we will check the condition) are all the labels of
9223
- // the fields in the previous section(s) (or fields declared before with no section) that
9224
- // support conditions. We pass in both the label and the identifier of each supported field. The
9225
- // identifier becomes the value of the option.
9226
- options: options.map((option) => {
9227
- if (!option.label)
9228
- return null;
9229
- if (option.type === "upload")
9230
- return null;
9231
- return {
9232
- label: option.label,
9233
- value: option.identifier
9234
- };
9235
- }).filter((option) => !!option),
9236
- identifier: `${path}condition.identifier`,
9237
- required: true
9238
- }),
9239
- // Declare a custom field that will be used to input a value for the condition. The value of the
9240
- // conditional field selected in the previous step must be equal to the value the user inputs into
9241
- // this field for the section to be rendered.
9242
- new FieldInputClonerField({
9243
- label: "Value",
9244
- identifier: `${path}condition.value`,
9245
- required: true,
9246
- clonedFieldIdentifier: `${path}condition.identifier`,
9247
- getFieldToClone(identifier) {
9248
- if (!identifier) {
9249
- return null;
9250
- }
9251
- const option = options.find((option2) => option2.identifier === identifier);
9252
- if (!option) {
9253
- console.error("Could not find field with identifier", identifier);
9254
- return null;
9255
- }
9256
- return {
9257
- ...option,
9258
- // Override some options to make it make sense in the context and to make it work with the framework.
9259
- label: "Value",
9260
- identifier: `${path}condition.value`,
9261
- description: "The value to compare against.",
9262
- required: option.type !== "boolean"
9263
- };
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;
9264
9268
  }
9265
- })
9266
- ]
9267
- }),
9268
- showDirectly: false
9269
- }
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;
9273
+ }
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
+ })
9270
9286
  ];
9271
9287
  }
9272
9288
  static deserialize(data) {
9273
9289
  if (data.type !== "section")
9274
9290
  throw new Error("Invalid type");
9291
+ if (!Array.isArray(data.fields))
9292
+ throw new Error(`Invalid fields: ${data.fields} (not an array)`);
9275
9293
  const fields = data.fields.map(deserializeField);
9276
9294
  return new _FieldSection({ ...data, fields });
9277
9295
  }
@@ -9305,227 +9323,58 @@ var __publicField = (obj, key, value) => {
9305
9323
  __publicField(_FieldSection, "fieldTypeName", "Section");
9306
9324
  __publicField(_FieldSection, "fieldTypeDescription", "Sections can be useful for grouping fields together. They can also be conditionally shown or hidden.");
9307
9325
  let FieldSection = _FieldSection;
9308
- const deserializeField = (serializedField) => {
9309
- const fieldType = serializedField.type;
9310
- const fieldCls = FieldTypeToClsMapping[fieldType];
9311
- return fieldCls.deserialize(serializedField);
9326
+ const hasKeys = (errors) => {
9327
+ return Object.keys(errors).length > 0;
9312
9328
  };
9313
- const deserialize = (serialized) => {
9314
- if (serialized.type === "section") {
9315
- return FieldSection.deserialize(serialized);
9329
+ const validateForm = (schema, form) => {
9330
+ const errors = {};
9331
+ for (const field of schema.fields) {
9332
+ if (field instanceof FieldSection) {
9333
+ if (field.condition) {
9334
+ const { identifier } = field.condition;
9335
+ if (!isConditionMet(field.condition, get(form, identifier))) {
9336
+ continue;
9337
+ }
9338
+ }
9339
+ Object.assign(errors, field.getErrors(form));
9340
+ } else {
9341
+ if (!(field instanceof BaseField)) {
9342
+ throw new Error("Invalid field type");
9343
+ }
9344
+ const id = field.getId();
9345
+ const error = field.getError(get(form, id), form);
9346
+ if (error)
9347
+ set(errors, id, error);
9348
+ }
9316
9349
  }
9317
- return deserializeField(serialized);
9350
+ if (hasKeys(errors))
9351
+ return errors;
9318
9352
  };
9319
- function formRevisionToSchema(formRevision, meta = {}) {
9320
- const { readonly = false } = meta;
9321
- return {
9322
- title: formRevision.title,
9323
- description: formRevision.description,
9324
- fields: formRevision.fields.map((serializedField) => deserialize(serializedField)),
9325
- meta: { readonly }
9326
- };
9327
- }
9328
- function valueIsFile(v) {
9329
- return Array.isArray(v) && v.some((v2) => v2 instanceof File || v2 instanceof Promise);
9330
- }
9331
- const valueIsFormikUserFormRevision = (form) => {
9332
- return "fields" in form;
9353
+ const uncontrolledValues = [null, void 0];
9354
+ const initialFormValues = (fields, values) => {
9355
+ return fields.reduce(
9356
+ (acc, field) => {
9357
+ if (field instanceof FieldSection) {
9358
+ return { ...acc, ...initialFormValues(field.fields, values) };
9359
+ }
9360
+ if (uncontrolledValues.includes(get(acc, field.getId()))) {
9361
+ set(acc, field.getId(), "");
9362
+ }
9363
+ return acc;
9364
+ },
9365
+ // TODO: Had to do this because of this error:
9366
+ // > Uncaught TypeError: can't define property "description":
9367
+ // > Object is not extensible"
9368
+ // This means that we can't mutate `acc` because it's frozen for some
9369
+ // unknown reason.
9370
+ cloneDeep(values)
9371
+ );
9333
9372
  };
9334
- function isConditionMet(condition, value) {
9335
- if (!condition)
9336
- return true;
9337
- if (valueIsFile(value) || valueIsFile(condition.value))
9338
- throw new Error("Conditions do not support file uploads");
9339
- const valueAsPrimitive = Array.isArray(value) ? value.map((v) => typeof v === "string" ? v : v.value) : value;
9340
- const valueToCompare = Array.isArray(condition.value) ? condition.value.map((v) => typeof v === "string" ? v : v.value) : condition.value;
9341
- if (Array.isArray(valueToCompare) && Array.isArray(valueAsPrimitive)) {
9342
- for (const v of valueToCompare) {
9343
- if (!valueAsPrimitive.includes(v))
9344
- return false;
9345
- }
9346
- return true;
9347
- }
9348
- return valueToCompare === value;
9349
- }
9350
- const emptyNumberField = {
9351
- ...emptyBaseField,
9352
- type: "number",
9353
- minimum: Number.MIN_SAFE_INTEGER,
9354
- maximum: Number.MAX_SAFE_INTEGER,
9355
- integers: false
9373
+ const defaultHandleSubmit = () => {
9374
+ throw new Error("onSubmit must be provided if form is not readonly.");
9356
9375
  };
9357
- const _NumberField = class _NumberField extends BaseField {
9358
- constructor(options) {
9359
- const {
9360
- minimum = Number.MIN_SAFE_INTEGER,
9361
- maximum = Number.MAX_SAFE_INTEGER,
9362
- integers = false,
9363
- ...base
9364
- } = options;
9365
- super({ ...base, type: "number" });
9366
- __publicField(this, "minimum");
9367
- __publicField(this, "maximum");
9368
- __publicField(this, "integers");
9369
- this.minimum = minimum;
9370
- this.maximum = maximum;
9371
- this.integers = integers;
9372
- }
9373
- getValueFromChangeEvent(event) {
9374
- const number = Number.parseFloat(event.target.value);
9375
- if (Number.isNaN(number))
9376
- return "";
9377
- return number;
9378
- }
9379
- static getFieldCreationSchema(parentPath = "") {
9380
- const path = parentPath && `${parentPath}.`;
9381
- return [
9382
- {
9383
- field: new _NumberField({
9384
- label: "Minimum",
9385
- description: "Minimum value",
9386
- integers: true,
9387
- required: false,
9388
- identifier: `${path}minimum`,
9389
- formValidators: [this._validateMin(parentPath)]
9390
- }),
9391
- showDirectly: false
9392
- },
9393
- {
9394
- field: new _NumberField({
9395
- label: "Maximum",
9396
- description: "Maximum value",
9397
- integers: true,
9398
- required: false,
9399
- identifier: `${path}maximum`,
9400
- formValidators: [this._validateMax(parentPath)]
9401
- }),
9402
- showDirectly: false
9403
- },
9404
- {
9405
- field: new BooleanField({
9406
- label: "Integers",
9407
- description: "Whole numbers only",
9408
- required: false,
9409
- identifier: `${path}integers`
9410
- }),
9411
- showDirectly: false
9412
- }
9413
- ];
9414
- }
9415
- getFieldValidators() {
9416
- const validators = super.getFieldValidators();
9417
- const min = this.minimum;
9418
- const max = this.maximum;
9419
- if (typeof min === "number") {
9420
- validators.push((value) => {
9421
- if (typeof value === "number" && value < min) {
9422
- return `Must be at least ${this.minimum}.`;
9423
- }
9424
- });
9425
- }
9426
- if (typeof max === "number") {
9427
- validators.push((value) => {
9428
- if (typeof value === "number" && value > max) {
9429
- return `Must be at most ${this.maximum}.`;
9430
- }
9431
- });
9432
- }
9433
- if (this.integers) {
9434
- validators.push((value) => {
9435
- if (typeof value === "number" && !Number.isInteger(value)) {
9436
- return "Must be a whole number.";
9437
- }
9438
- });
9439
- }
9440
- return validators;
9441
- }
9442
- serialize() {
9443
- return {
9444
- ...super._serialize(),
9445
- minimum: this.minimum,
9446
- maximum: this.maximum,
9447
- integers: this.integers
9448
- };
9449
- }
9450
- static deserialize(data) {
9451
- if (data.type !== "number")
9452
- throw new Error("Type mismatch.");
9453
- return new _NumberField(data);
9454
- }
9455
- getInput(props) {
9456
- return /* @__PURE__ */ jsxRuntime.jsx(NumberInput$1, { field: this, ...props });
9457
- }
9458
- };
9459
- __publicField(_NumberField, "fieldTypeName", "Number");
9460
- __publicField(_NumberField, "fieldTypeDescription", "Allows specifying a number within a given range.");
9461
- __publicField(_NumberField, "Icon", FontFamilyIcon);
9462
- __publicField(_NumberField, "_validateMin", (path) => (value, allValues) => {
9463
- const field = valueIsFormikUserFormRevision(allValues) ? get(allValues, path) : allValues;
9464
- if (typeof field.maximum === "number" && typeof value === "number" && field.maximum < value) {
9465
- return "Minimum cannot be greater than minimum.";
9466
- }
9467
- return null;
9468
- });
9469
- __publicField(_NumberField, "_validateMax", (path) => (value, allValues) => {
9470
- const field = valueIsFormikUserFormRevision(allValues) ? get(allValues, path) : allValues;
9471
- if (typeof field.minimum === "number" && typeof value === "number" && field.minimum > value) {
9472
- return "Maximum cannot be less than minimum.";
9473
- }
9474
- return null;
9475
- });
9476
- let NumberField = _NumberField;
9477
- const hasKeys = (errors) => {
9478
- return Object.keys(errors).length > 0;
9479
- };
9480
- const validateForm = (schema, form) => {
9481
- const errors = {};
9482
- for (const field of schema.fields) {
9483
- if (field instanceof FieldSection) {
9484
- if (field.condition) {
9485
- const { identifier } = field.condition;
9486
- if (!isConditionMet(field.condition, get(form, identifier))) {
9487
- continue;
9488
- }
9489
- }
9490
- Object.assign(errors, field.getErrors(form));
9491
- } else {
9492
- if (!(field instanceof BaseField)) {
9493
- throw new Error("Invalid field type");
9494
- }
9495
- const id = field.getId();
9496
- const error = field.getError(get(form, id), form);
9497
- if (error)
9498
- set(errors, id, error);
9499
- }
9500
- }
9501
- if (hasKeys(errors))
9502
- return errors;
9503
- };
9504
- const uncontrolledValues = [null, void 0];
9505
- const initialFormValues = (fields, values) => {
9506
- return fields.reduce(
9507
- (acc, field) => {
9508
- if (field instanceof FieldSection) {
9509
- return { ...acc, ...initialFormValues(field.fields, values) };
9510
- }
9511
- if (uncontrolledValues.includes(get(acc, field.getId()))) {
9512
- set(acc, field.getId(), "");
9513
- }
9514
- return acc;
9515
- },
9516
- // TODO: Had to do this because of this error:
9517
- // > Uncaught TypeError: can't define property "description":
9518
- // > Object is not extensible"
9519
- // This means that we can't mutate `acc` because it's frozen for some
9520
- // unknown reason.
9521
- cloneDeep(values)
9522
- );
9523
- };
9524
- const defaultHandleSubmit = () => {
9525
- throw new Error("onSubmit must be provided if form is not readonly.");
9526
- };
9527
- const FormRenderer = React.memo(
9528
- React.forwardRef((props, ref) => {
9376
+ const FormRenderer = React.memo(
9377
+ React.forwardRef((props, ref) => {
9529
9378
  const {
9530
9379
  schema,
9531
9380
  values = {},
@@ -9556,7 +9405,7 @@ var __publicField = (obj, key, value) => {
9556
9405
  [schema.title]
9557
9406
  );
9558
9407
  const Description = React.useMemo(
9559
- () => typeof schema.description === "string" ? /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$5.description, children: schema.description }) : schema.description,
9408
+ () => typeof schema.description === "string" ? /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$4.description, children: schema.description }) : schema.description,
9560
9409
  [schema.description]
9561
9410
  );
9562
9411
  const inputs = useFieldInputs(schema.fields, { formId: formId2, disabled: readonly });
@@ -9572,23 +9421,10 @@ var __publicField = (obj, key, value) => {
9572
9421
  !hideDescription && Description
9573
9422
  ] }) }),
9574
9423
  inputs,
9575
- !readonly && /* @__PURE__ */ jsxRuntime.jsxs(
9576
- blocks.Flex,
9577
- {
9578
- justify: "end",
9579
- gap: "2",
9580
- align: "center",
9581
- style: {
9582
- position: "sticky",
9583
- bottom: "0px",
9584
- paddingBottom: "10px"
9585
- },
9586
- children: [
9587
- cancelText && /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "button", variant: "soft", onClick: onCancel, children: cancelText }),
9588
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "submit", disabled: !formik$1.isValid, children: submitText })
9589
- ]
9590
- }
9591
- )
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
+ ] })
9592
9428
  ] }) }) });
9593
9429
  })
9594
9430
  );
@@ -9633,7 +9469,7 @@ var __publicField = (obj, key, value) => {
9633
9469
  );
9634
9470
  const favoriteIcon = "_favoriteIcon_1bixi_1";
9635
9471
  const regularIcon = "_regularIcon_1bixi_9";
9636
- const styles$2 = {
9472
+ const styles$1 = {
9637
9473
  favoriteIcon,
9638
9474
  regularIcon
9639
9475
  };
@@ -9745,7 +9581,7 @@ var __publicField = (obj, key, value) => {
9745
9581
  /* @__PURE__ */ jsxRuntime.jsx(
9746
9582
  blocks.IconButton,
9747
9583
  {
9748
- className: classNames$1(form.favorite ? styles$2.favoriteIcon : styles$2.regularIcon),
9584
+ className: classNames$1(form.favorite ? styles$1.favoriteIcon : styles$1.regularIcon),
9749
9585
  variant: "ghost",
9750
9586
  onClick: handleFavoriteClick,
9751
9587
  "aria-label": form.favorite ? "Favorite form" : "Standard form",
@@ -9771,7 +9607,7 @@ var __publicField = (obj, key, value) => {
9771
9607
  };
9772
9608
  const submissionsContainer = "_submissionsContainer_9iirt_1";
9773
9609
  const stopHorizontalOverflow = "_stopHorizontalOverflow_9iirt_6";
9774
- const styles$1 = {
9610
+ const styles = {
9775
9611
  submissionsContainer,
9776
9612
  stopHorizontalOverflow
9777
9613
  };
@@ -9802,7 +9638,7 @@ var __publicField = (obj, key, value) => {
9802
9638
  }
9803
9639
  }, [submission, onSubmissionClick]);
9804
9640
  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: [
9805
- /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { gap: "2", align: "center", className: styles$1.stopHorizontalOverflow, children: [
9641
+ /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { gap: "2", align: "center", className: styles.stopHorizontalOverflow, children: [
9806
9642
  /* @__PURE__ */ jsxRuntime.jsx(Avatar, { src: creatorProfileSrc, size: "1", fallback: creatorProfileFallback }),
9807
9643
  /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "2", noWrap: true, children: labelType === "creator" ? (createdBy || currentUser).username : revision.title })
9808
9644
  ] }),
@@ -9846,7 +9682,7 @@ var __publicField = (obj, key, value) => {
9846
9682
  return /* @__PURE__ */ jsxRuntime.jsx(
9847
9683
  blocks.ButtonList.Root,
9848
9684
  {
9849
- className: classNames$1(styles$1.submissionsContainer, className),
9685
+ className: classNames$1(styles.submissionsContainer, className),
9850
9686
  size: "small",
9851
9687
  variant,
9852
9688
  before: !compact && /* @__PURE__ */ jsxRuntime.jsxs(blocks.Text, { severity: "info", children: [
@@ -9870,22 +9706,23 @@ var __publicField = (obj, key, value) => {
9870
9706
  );
9871
9707
  });
9872
9708
  const PatchField = React.memo((props) => {
9709
+ console.log("PatchField props:", props);
9873
9710
  const { name, render } = props;
9874
9711
  const { submitForm } = formik.useFormikContext();
9875
9712
  const [fieldProps, _meta, helpers] = formik.useField(name);
9876
- return React.useMemo(() => {
9713
+ const ret = React.useMemo(() => {
9877
9714
  const setValue = (value) => {
9878
9715
  void helpers.setValue(value, false);
9879
9716
  };
9880
9717
  return render({
9881
9718
  value: fieldProps.value,
9882
- meta: _meta,
9883
9719
  setValue,
9884
9720
  patchValue: () => {
9885
9721
  void submitForm();
9886
9722
  }
9887
9723
  });
9888
- }, [render, fieldProps.value, _meta, submitForm, helpers]);
9724
+ }, [submitForm, helpers, fieldProps.value, render]);
9725
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: ret });
9889
9726
  });
9890
9727
  PatchField.displayName = "PatchField";
9891
9728
  const PatchFormProvider = React.memo(
@@ -9934,437 +9771,365 @@ var __publicField = (obj, key, value) => {
9934
9771
  return /* @__PURE__ */ jsxRuntime.jsx(formik.FormikProvider, { value: formik$1, children: /* @__PURE__ */ jsxRuntime.jsx("form", { ...rest, ref, onSubmit: formik$1.handleSubmit, children }) });
9935
9772
  })
9936
9773
  );
9937
- const formId = "form-builder";
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
+ });
9938
9791
  const fieldsToChoose = [
9939
9792
  ["string", "text"],
9940
9793
  ["select", "multi-select", "upload"],
9941
9794
  ["boolean", "date", "number", "multi-string"]
9942
9795
  ];
9943
- const CompleteFieldTypeToClsMapping = {
9944
- ...FieldTypeToClsMapping,
9945
- section: FieldSection
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
+ };
9946
9821
  };
9947
- const useFieldTypeItems = (onSelect = () => null) => {
9948
- return React.useMemo(() => {
9949
- return fieldsToChoose.map((fieldGroup) => {
9950
- return fieldGroup.map((identifier) => {
9951
- const field = FieldTypeToClsMapping[identifier];
9952
- const Icon = field.Icon;
9953
- return {
9954
- content: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { align: "center", gap: "2", children: [
9955
- /* @__PURE__ */ jsxRuntime.jsx(Icon, {}),
9956
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { children: field.fieldTypeName })
9957
- ] }, identifier),
9958
- value: identifier,
9959
- onSelect: () => {
9960
- onSelect(identifier);
9961
- }
9962
- };
9963
- });
9964
- });
9965
- }, [onSelect]);
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
+ ];
9966
9844
  };
9967
- const FieldTypeDropdown = React.memo((props) => {
9968
- const { setFieldType, children } = props;
9969
- const fieldTypeItems = useFieldTypeItems(setFieldType);
9970
- return /* @__PURE__ */ jsxRuntime.jsx(blocks.DropdownItemMenu, { trigger: children, items: fieldTypeItems.flat() });
9971
- });
9972
- FieldTypeDropdown.displayName = "FieldTypeDropdown";
9973
- const forMobile = (mobile, display) => ({
9974
- initial: mobile ? display : "none",
9975
- sm: mobile ? "none" : display
9976
- });
9977
- const FieldActions = React.memo((props) => {
9978
- const { index: index2, sectionIndex, type, remove: remove2, duplicate, addAfter, move } = props;
9979
- if (type !== "section" && !addAfter) {
9980
- throw new Error("addAfter is required for non-section fields");
9981
- }
9982
- const { values } = formik.useFormikContext();
9983
- const fieldTypeItems = useFieldTypeItems(addAfter);
9984
- const [actions, mobileActions] = React.useMemo(() => {
9985
- const getActions = (isMobile) => {
9986
- const actions2 = [
9987
- {
9988
- Icon: TrashIcon,
9989
- buttonProps: { onClick: remove2 },
9990
- key: "delete",
9991
- text: "Delete"
9992
- },
9993
- {
9994
- Icon: CopyIcon,
9995
- key: "duplicate",
9996
- text: "Duplicate",
9997
- buttonProps: { onClick: duplicate }
9998
- }
9999
- ];
10000
- if (type !== "section") {
10001
- actions2.push({
10002
- // We want to show a dropdown with field types if "Add after" is clicked
10003
- isComponent: true,
10004
- 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, {}) }) }),
10005
- Icon: PlusIcon,
10006
- key: "add",
10007
- text: "Add after"
10008
- });
10009
- }
10010
- if (sectionIndex === void 0 && index2 !== 0 || sectionIndex !== void 0 && (sectionIndex !== 0 || index2 !== 0)) {
10011
- actions2.push({
10012
- Icon: ArrowUpIcon,
10013
- key: "moveUp",
10014
- text: "Move up",
10015
- buttonProps: {
10016
- onClick: () => {
10017
- move("up");
10018
- }
10019
- }
10020
- });
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.");
10021
9855
  }
10022
- if (sectionIndex === void 0 && index2 !== values.fields.length - 1 || sectionIndex !== void 0 && (sectionIndex < values.fields.length - 1 || index2 !== values.fields[sectionIndex].fields.length - 1)) {
10023
- actions2.push({
10024
- Icon: ArrowDownIcon,
10025
- key: "moveDown",
10026
- text: "Move down",
10027
- buttonProps: {
10028
- onClick: () => {
10029
- move("down");
10030
- }
10031
- }
10032
- });
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()}.`);
10033
9860
  }
10034
- return actions2;
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
10035
9868
  };
10036
- return [getActions(false), getActions(true)];
10037
- }, [addAfter, duplicate, fieldTypeItems, index2, move, remove2, sectionIndex, type, values.fields]);
10038
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
10039
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Flex, { gap: "4", display: forMobile(false, "flex"), children: actions.map((Action) => {
10040
- if (Action.isComponent) {
10041
- return Action.Component;
10042
- }
10043
- return /* @__PURE__ */ jsxRuntime.jsx(
10044
- blocks.IconButton,
10045
- {
10046
- type: "button",
10047
- variant: "ghost",
10048
- severity: Action.key.startsWith("move") ? "info" : "primary",
10049
- "aria-label": Action.text,
10050
- ...Action.buttonProps,
10051
- children: /* @__PURE__ */ jsxRuntime.jsx(Action.Icon, {})
10052
- },
10053
- Action.key
10054
- );
10055
- }) }),
10056
- /* @__PURE__ */ jsxRuntime.jsx(Box, { display: forMobile(true, "block"), children: /* @__PURE__ */ jsxRuntime.jsxs(
10057
- blocks.DropdownMenu,
10058
- {
10059
- trigger: /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { variant: "ghost", "aria-label": "Actions menu", children: /* @__PURE__ */ jsxRuntime.jsx(DotsVerticalIcon, {}) }),
10060
- children: [
10061
- /* @__PURE__ */ jsxRuntime.jsx(
10062
- blocks.DropdownMenuItemGroup,
10063
- {
10064
- items: mobileActions.filter((Action) => !Action.isComponent).map((Action) => {
10065
- var _a2;
10066
- return {
10067
- content: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { gap: "2", align: "center", children: [
10068
- /* @__PURE__ */ jsxRuntime.jsx(Action.Icon, {}),
10069
- Action.text
10070
- ] }, Action.key),
10071
- value: Action.key,
10072
- onSelect: (_a2 = Action.buttonProps) == null ? void 0 : _a2.onClick
10073
- };
10074
- })
10075
- }
10076
- ),
10077
- /* @__PURE__ */ jsxRuntime.jsx(
10078
- blocks.DropdownMenuSubMenuGroup,
10079
- {
10080
- items: mobileActions.filter((Action) => Action.isComponent).map((Action) => ({
10081
- content: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { gap: "2", align: "center", children: [
10082
- /* @__PURE__ */ jsxRuntime.jsx(Action.Icon, {}),
10083
- Action.text
10084
- ] }, Action.key),
10085
- subContent: Action.Component,
10086
- triggerIndicator: null
10087
- }))
10088
- }
10089
- )
10090
- ]
10091
- }
10092
- ) })
10093
- ] });
10094
- });
10095
- FieldActions.displayName = "FieldActions";
10096
- const description = "_description_17zed_1";
10097
- const styles = {
10098
- description
10099
- };
10100
- const FieldSettingsPopover = React.memo((props) => {
10101
- const { popoverInputs, hasError } = props;
9869
+ }, [formik$1.values.fields, fieldType, fieldCls, defaultField == null ? void 0 : defaultField.label, conditionalSourceFields]);
10102
9870
  return /* @__PURE__ */ jsxRuntime.jsx(
10103
- blocks.Popover,
9871
+ FormRenderer,
10104
9872
  {
10105
- size: "1",
10106
- trigger: /* @__PURE__ */ jsxRuntime.jsxs(
10107
- blocks.Button,
10108
- {
10109
- variant: "soft",
10110
- size: "small",
10111
- "aria-label": "settings",
10112
- ...hasError && { severity: "danger" },
10113
- hoverEffects: ["spin90Clockwise"],
10114
- children: [
10115
- /* @__PURE__ */ jsxRuntime.jsx(GearIcon, {}),
10116
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { children: "Settings" })
10117
- ]
10118
- },
10119
- "settings"
10120
- ),
10121
- children: () => /* @__PURE__ */ jsxRuntime.jsx(blocks.Flex, { direction: "column", style: { maxWidth: "240px" }, children: popoverInputs })
9873
+ schema,
9874
+ values: defaultField,
9875
+ onSubmit: handleCreateField,
9876
+ cancelText: defaultField ? void 0 : "Back",
9877
+ onCancel: handleCancel,
9878
+ onDirtyChange: handleDirtyChange
10122
9879
  }
10123
9880
  );
10124
9881
  });
10125
- FieldSettingsPopover.displayName = "FieldSettingsPopover";
10126
- const FieldBuilder = React.memo((props) => {
10127
- var _a2, _b, _c, _d, _e, _f;
10128
- const { parentPath, index: index2, initial, conditionalSourceFields } = props;
10129
- const RADIX_SM_MIN_WIDTH = 576;
10130
- const [isLargeScreen, setIsLargeScreen] = React.useState(
10131
- window.matchMedia(`(min-width: ${RADIX_SM_MIN_WIDTH}px)`).matches
10132
- );
10133
- React.useEffect(() => {
10134
- const mediaQuery = window.matchMedia(`(min-width: ${RADIX_SM_MIN_WIDTH}px)`);
10135
- const handleMediaQueryChange = (event) => {
10136
- setIsLargeScreen(event.matches);
10137
- };
10138
- mediaQuery.addEventListener("change", handleMediaQueryChange);
10139
- return () => {
10140
- mediaQuery.removeEventListener("change", handleMediaQueryChange);
10141
- };
10142
- }, []);
10143
- const { values, setFieldValue, errors } = formik.useFormikContext();
10144
- const fieldTypeItems = useFieldTypeItems();
10145
- const isSection = React.useCallback((field) => {
10146
- return field.type === "section";
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);
10147
9898
  }, []);
10148
- React.useEffect(() => {
10149
- if (isSection(initial) && !initial.conditional) {
10150
- void setFieldValue(`${parentPath}.${index2}.condition`, null).then();
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
+ });
10151
9910
  }
10152
- }, [index2, initial, isSection, parentPath, setFieldValue]);
10153
- const conditionLabel = React.useMemo(
10154
- () => {
10155
- var _a3, _b2;
10156
- return isSection(initial) ? (_b2 = findFieldByIdentifier(values.fields, (_a3 = initial.condition) == null ? void 0 : _a3.identifier)) == null ? void 0 : _b2.label : void 0;
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);
10157
9938
  },
10158
- [initial, isSection, values.fields]
9939
+ [type, values, parentPath, editing, setFieldValue, setIsOpen, index2]
10159
9940
  );
10160
- const conditionComparison = isSection(initial) ? Array.isArray((_a2 = initial.condition) == null ? void 0 : _a2.value) ? "contains all of" : "equals" : void 0;
10161
- let conditionValue = void 0;
10162
- if (isSection(initial)) {
10163
- if (valueIsFile((_b = initial.condition) == null ? void 0 : _b.value)) {
10164
- throw new Error("File values are not supported for conditions.");
10165
- }
10166
- 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();
10167
- }
10168
- const type = initial.type;
10169
- const fieldCls = CompleteFieldTypeToClsMapping[type];
10170
- const [directlyShownFields, popoverFields] = React.useMemo(() => {
10171
- let directlyShownFields2 = [];
10172
- let popoverFields2 = [];
10173
- if (fieldCls === FieldSection) {
10174
- if (conditionalSourceFields === void 0) {
10175
- throw new Error("Conditional source fields must be provided when changing sections.");
10176
- }
10177
- const fieldObject = fieldCls.getFieldCreationSchema(conditionalSourceFields, `${parentPath}.${index2}`);
10178
- directlyShownFields2 = directlyShownFields2.concat(
10179
- fieldObject.filter((field) => field.showDirectly).map((field) => field.field)
10180
- );
10181
- popoverFields2 = popoverFields2.concat(
10182
- fieldObject.filter((field) => !field.showDirectly).map((field) => field.field)
10183
- );
10184
- } else {
10185
- if (!(fieldCls.prototype instanceof BaseField)) {
10186
- throw new Error(`Field must be an instance of BaseField. Got ${fieldCls.toString()}.`);
10187
- }
10188
- const fieldObject = fieldCls.getFieldCreationSchema(
10189
- `${parentPath}.${index2}`
10190
- );
10191
- if (isLargeScreen) {
10192
- directlyShownFields2 = [
10193
- ...directlyShownFields2,
10194
- ...fieldObject.filter((field) => field.showDirectly).map((field) => field.field)
10195
- ];
10196
- popoverFields2 = [
10197
- ...popoverFields2,
10198
- ...fieldObject.filter((field) => !field.showDirectly).map((field) => field.field)
10199
- ];
10200
- } else {
10201
- popoverFields2 = [...popoverFields2, ...fieldObject.map((field) => field.field)];
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
10202
9957
  }
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
10203
9968
  }
10204
- return [directlyShownFields2, popoverFields2];
10205
- }, [fieldCls, conditionalSourceFields, parentPath, index2, isLargeScreen]);
10206
- const directlyShownInputs = useFieldInputs(directlyShownFields, {
10207
- formId,
10208
- disabled: false,
10209
- ...fieldCls === FieldSection && { size: "2" }
10210
- });
10211
- const popoverInputs = useFieldInputs(popoverFields, {
10212
- formId,
10213
- disabled: false
10214
- });
10215
- let showPopoverInputs = popoverFields.length > 0;
10216
- if (isSection(initial) && popoverFields.length > 0) {
10217
- showPopoverInputs = initial.conditional;
10218
- }
10219
- const popoverHasErrors = popoverFields.some((field) => {
10220
- const error = get(errors, fieldCls === FieldSection ? `${parentPath}.${index2}.condition` : field.getId());
10221
- return error && (typeof error !== "object" || hasKeys(error));
10222
- });
10223
- return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { align: "center", grow: "1", children: [
10224
- /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", children: [
10225
- fieldCls === FieldSection && /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "1", children: [
10226
- directlyShownFields.length > 0 && directlyShownInputs,
10227
- /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { align: "center", gap: "2", children: [
10228
- showPopoverInputs && /* @__PURE__ */ jsxRuntime.jsx(FieldSettingsPopover, { popoverInputs, hasError: popoverHasErrors }),
10229
- isSection(initial) && initial.conditional && /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "1", severity: popoverHasErrors ? "danger" : "primary", children: /* @__PURE__ */ jsxRuntime.jsxs(Em, { children: [
10230
- "Display only if ",
10231
- /* @__PURE__ */ jsxRuntime.jsx(Strong, { children: conditionLabel }),
10232
- " ",
10233
- conditionComparison,
10234
- " ",
10235
- /* @__PURE__ */ jsxRuntime.jsx(Strong, { children: conditionValue })
10236
- ] }) })
10237
- ] })
10238
- ] }),
10239
- fieldCls !== FieldSection && /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "2", children: [
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 }
10038
+ }
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: [
10240
10054
  /* @__PURE__ */ jsxRuntime.jsx(
10241
- PatchField,
10055
+ blocks.IconButton,
10242
10056
  {
10243
- name: `${parentPath}.${index2}.required`,
10244
- render: ({ setValue, value }) => /* @__PURE__ */ jsxRuntime.jsx(
10245
- blocks.Checkbox,
10246
- {
10247
- checked: value,
10248
- onCheckedChange: setValue,
10249
- label: /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "2", children: "Required field" }),
10250
- alwaysShow: true
10251
- }
10252
- )
10057
+ type: "button",
10058
+ variant: "ghost",
10059
+ "aria-label": action.text,
10060
+ ...action.buttonProps,
10061
+ children: /* @__PURE__ */ jsxRuntime.jsx(action.Icon, {})
10253
10062
  }
10254
10063
  ),
10255
- /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { align: "center", gap: "3", children: [
10256
- /* @__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 }),
10257
- showPopoverInputs && /* @__PURE__ */ jsxRuntime.jsx(FieldSettingsPopover, { popoverInputs, hasError: popoverHasErrors })
10258
- ] })
10259
- ] }),
10260
- /* @__PURE__ */ jsxRuntime.jsx(
10261
- PatchField,
10262
- {
10263
- name: `${parentPath}.${index2}.label`,
10264
- render: ({ setValue, value }) => /* @__PURE__ */ jsxRuntime.jsx(
10265
- blocks.Input,
10266
- {
10267
- className: styles.Input,
10268
- placeholder: `Enter a ${type === "section" ? "section" : "field"} label`,
10269
- value,
10270
- onChange: (event) => {
10271
- setValue(event.target.value);
10272
- },
10273
- maxLength: 200,
10274
- showInputLength: false,
10275
- variant: "ghost",
10276
- size: "large"
10277
- }
10278
- )
10279
- }
10280
- ),
10281
- /* @__PURE__ */ jsxRuntime.jsx(
10282
- PatchField,
10283
- {
10284
- name: `${parentPath}.${index2}.description`,
10285
- render: ({ setValue, value }) => /* @__PURE__ */ jsxRuntime.jsx(
10286
- blocks.TextArea,
10287
- {
10288
- style: { minHeight: "max-content" },
10289
- placeholder: `Enter a ${type === "section" ? "section" : "field"} description`,
10290
- value,
10291
- onChange: (event) => {
10292
- setValue(event.target.value);
10293
- },
10294
- resize: "vertical",
10295
- maxLength: 1e3,
10296
- showInputLength: false,
10297
- variant: "ghost"
10298
- }
10299
- )
10300
- }
10301
- )
10302
- ] }),
10303
- fieldCls !== FieldSection && directlyShownFields.length > 0 && directlyShownInputs
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
+ ) })
10304
10095
  ] });
10305
10096
  });
10306
- FieldBuilder.displayName = "FieldBuilder";
10307
- const FieldWithActions = React.memo((props) => {
10097
+ const formId = "form-builder";
10098
+ const FieldWithActions = React.memo(function FieldWithActions2(props) {
10308
10099
  const { field, index: index2, sectionIndex, takenLabels, remove: remove2 } = props;
10309
- const { setFieldValue, values } = formik.useFormikContext();
10310
- const { reorderField } = useFieldReordering();
10311
- const parentPath = `fields.${sectionIndex}.fields`;
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
+ );
10312
10109
  const editFieldProps = React.useMemo(
10313
10110
  () => ({
10314
10111
  index: index2,
10315
- parentPath,
10316
- initial: field
10112
+ parentPath: `fields.${sectionIndex}.fields`,
10113
+ initial: field,
10114
+ editing: true
10317
10115
  }),
10318
- [field, index2, parentPath]
10116
+ [field, index2, sectionIndex]
10319
10117
  );
10320
- const duplicateField = React.useCallback(() => {
10321
- const label = field.label ?? "Unlabelled field";
10322
- const duplicatedField = {
10323
- ...field,
10324
- label: incrementFieldLabel(label, takenLabels)
10325
- };
10326
- createNewField(parentPath, index2 + 1, duplicatedField, values, setFieldValue);
10327
- }, [field, takenLabels, parentPath, index2, values, setFieldValue]);
10328
- const createFieldAfter = React.useCallback(
10329
- (type) => {
10330
- if (type === "section") {
10331
- throw new Error("Section type unexpected");
10332
- }
10333
- createNewField(
10334
- parentPath,
10335
- index2 + 1,
10336
- FieldTypeToEmptyFieldMapping[type],
10337
- values,
10338
- setFieldValue
10339
- );
10340
- },
10341
- [parentPath, index2, values, setFieldValue]
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]
10342
10125
  );
10343
- const moveField = React.useCallback(
10344
- (direction) => {
10345
- const srcSectionIndex = sectionIndex;
10346
- const srcSection = values.fields[srcSectionIndex];
10347
- let destSectionIndex = sectionIndex;
10348
- let destFieldIndex = direction === "up" ? index2 - 1 : index2 + 1;
10349
- if (direction === "up" && index2 === 0) {
10350
- destSectionIndex = sectionIndex - 1;
10351
- destFieldIndex = values.fields[destSectionIndex].fields.length;
10352
- } else if (direction === "down" && index2 === srcSection.fields.length - 1) {
10353
- destSectionIndex = sectionIndex + 1;
10354
- destFieldIndex = 0;
10355
- }
10356
- const destSection = values.fields[destSectionIndex];
10357
- reorderField(
10358
- srcSection,
10359
- srcSectionIndex,
10360
- index2,
10361
- destSection,
10362
- destSectionIndex,
10363
- destFieldIndex,
10364
- setFieldValue
10365
- );
10366
- },
10367
- [sectionIndex, values.fields, index2, reorderField, setFieldValue]
10126
+ const insertAfterProps = React.useMemo(
10127
+ () => ({
10128
+ parentPath: `fields.${sectionIndex}.fields`,
10129
+ index: index2 + 1,
10130
+ initial: void 0
10131
+ }),
10132
+ [index2, sectionIndex]
10368
10133
  );
10369
10134
  return /* @__PURE__ */ jsxRuntime.jsx(dnd.Draggable, { draggableId: field.identifier, index: index2, children: (draggableProvided) => /* @__PURE__ */ jsxRuntime.jsx(
10370
10135
  Card,
@@ -10372,38 +10137,30 @@ var __publicField = (obj, key, value) => {
10372
10137
  ref: draggableProvided.innerRef,
10373
10138
  ...draggableProvided.draggableProps,
10374
10139
  ...draggableProvided.dragHandleProps,
10375
- style: {
10376
- ...draggableProvided.draggableProps.style,
10377
- backgroundColor: "var(--accent-1)",
10378
- borderColor: "var(--accent-3)"
10379
- },
10380
10140
  mb: "4",
10381
10141
  children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { gap: "4", justify: "between", align: "center", children: [
10382
- /* @__PURE__ */ jsxRuntime.jsx(FieldBuilder, { ...editFieldProps }),
10142
+ input,
10383
10143
  /* @__PURE__ */ jsxRuntime.jsx(
10384
10144
  FieldActions,
10385
10145
  {
10386
- index: index2,
10387
- sectionIndex,
10388
- type: field.type,
10389
10146
  remove: remove2,
10390
- duplicate: duplicateField,
10391
- addAfter: createFieldAfter,
10392
- move: moveField
10147
+ editProps: editFieldProps,
10148
+ duplicateProps: duplicateFieldProps,
10149
+ insertAfterProps,
10150
+ dragHandleProps: draggableProvided.dragHandleProps
10393
10151
  }
10394
10152
  )
10395
10153
  ] })
10396
10154
  }
10397
10155
  ) });
10398
10156
  });
10399
- FieldWithActions.displayName = "FieldWithActions";
10400
- const FieldSectionWithActions = React.memo((props) => {
10401
- var _a2;
10157
+ const FieldSectionWithActions = React.memo(function FieldSectionWithActions2(props) {
10158
+ var _a2, _b, _c, _d, _e, _f, _g;
10402
10159
  const { field, index: sectionIndex, dropState } = props;
10403
10160
  const isDropDisabled = (_a2 = dropState[field.identifier]) == null ? void 0 : _a2.disabled;
10161
+ const [isAddFieldDialogOpen, setIsAddFieldDialogOpen] = React.useState(false);
10404
10162
  const { setFieldValue, values } = formik.useFormikContext();
10405
10163
  const alertDialog = blocks.useAlertDialog();
10406
- const { reorderSection } = useFieldReordering();
10407
10164
  const takenFieldLabels = getTakenFieldLabels(values.fields);
10408
10165
  const removeSectionConditions = React.useCallback(
10409
10166
  (sectionsToUpdate, allSections) => {
@@ -10490,113 +10247,152 @@ var __publicField = (obj, key, value) => {
10490
10247
  alertDialog,
10491
10248
  removeSectionConditions
10492
10249
  ]);
10493
- const moveSection = React.useCallback(
10494
- (direction) => {
10495
- const destinationIndex = direction === "up" ? sectionIndex - 1 : sectionIndex + 1;
10496
- reorderSection(dropState, field.identifier, sectionIndex, destinationIndex, values, setFieldValue);
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: "" };
10497
10263
  },
10498
- [sectionIndex, reorderSection, dropState, field.identifier, values, setFieldValue]
10264
+ [takenFieldLabels]
10499
10265
  );
10500
10266
  const editSectionProps = React.useMemo(
10501
10267
  () => ({
10502
10268
  index: sectionIndex,
10503
10269
  parentPath: "fields",
10504
10270
  initial: field,
10271
+ editing: true,
10505
10272
  conditionalSourceFields: makeConditionalSourceFields(values.fields, sectionIndex)
10506
10273
  }),
10507
10274
  [field, sectionIndex, values.fields]
10508
10275
  );
10509
- const duplicateSection = React.useCallback(() => {
10510
- const fieldLabel = field.label ?? "Untitled section";
10511
- const newSectionLabel = incrementFieldLabel(fieldLabel, takenFieldLabels);
10512
- const newFields = field.fields.map((f) => {
10513
- const newLabel = incrementFieldLabel(f.label, takenFieldLabels);
10514
- return {
10515
- ...f,
10516
- label: newLabel,
10517
- identifier: makeIdentifier(null, newLabel)
10518
- };
10519
- });
10520
- const duplicatedField = { ...field, label: newSectionLabel, fields: newFields };
10521
- createNewField("fields", sectionIndex + 1, duplicatedField, values, setFieldValue);
10522
- }, [field, takenFieldLabels, sectionIndex, values, setFieldValue]);
10523
- const handleCreateField = React.useCallback(
10524
- (type) => {
10525
- createNewField(
10526
- `fields.${sectionIndex}.fields`,
10527
- field.fields.length,
10528
- FieldTypeToEmptyFieldMapping[type],
10529
- values,
10530
- setFieldValue
10531
- );
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;
10532
10306
  },
10533
- [sectionIndex, field.fields.length, values, setFieldValue]
10307
+ [(_b = field.condition) == null ? void 0 : _b.identifier, values.fields]
10534
10308
  );
10535
- return /* @__PURE__ */ jsxRuntime.jsx(dnd.Draggable, { draggableId: field.identifier, index: sectionIndex, children: (draggableProvided) => {
10536
- return /* @__PURE__ */ jsxRuntime.jsx(
10537
- Card,
10538
- {
10539
- ref: draggableProvided.innerRef,
10540
- ...draggableProvided.draggableProps,
10541
- ...draggableProvided.dragHandleProps,
10542
- mb: "4",
10543
- children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { gap: "3", justify: "between", align: "center", children: [
10544
- /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "2", grow: "1", children: [
10545
- /* @__PURE__ */ jsxRuntime.jsx(FieldBuilder, { ...editSectionProps }),
10546
- /* @__PURE__ */ jsxRuntime.jsx(
10547
- dnd.Droppable,
10548
- {
10549
- droppableId: field.identifier,
10550
- type: "SECTION",
10551
- isDropDisabled,
10552
- children: (droppableProvided) => /* @__PURE__ */ jsxRuntime.jsxs(
10553
- blocks.Flex,
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,
10554
10358
  {
10555
- ref: droppableProvided.innerRef,
10556
- ...droppableProvided.droppableProps,
10557
- direction: "column",
10558
- gap: "0",
10359
+ type: "button",
10360
+ variant: "outline",
10361
+ onClick: () => {
10362
+ setIsAddFieldDialogOpen(true);
10363
+ },
10559
10364
  children: [
10560
- field.fields.map((child, i) => /* @__PURE__ */ jsxRuntime.jsx(
10561
- FieldWithActions,
10562
- {
10563
- field: child,
10564
- index: i,
10565
- sectionIndex,
10566
- remove: () => {
10567
- removeField(i);
10568
- },
10569
- takenLabels: takenFieldLabels
10570
- },
10571
- child.identifier
10572
- )),
10573
- droppableProvided.placeholder,
10574
- /* @__PURE__ */ jsxRuntime.jsx(FieldTypeDropdown, { setFieldType: handleCreateField, children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Button, { type: "button", variant: "soft", children: [
10575
- /* @__PURE__ */ jsxRuntime.jsx(PlusIcon, {}),
10576
- " Add field"
10577
- ] }) })
10365
+ /* @__PURE__ */ jsxRuntime.jsx(PlusIcon, {}),
10366
+ " Add a field"
10578
10367
  ]
10579
10368
  }
10369
+ ),
10370
+ /* @__PURE__ */ jsxRuntime.jsx(
10371
+ FieldBuilder,
10372
+ {
10373
+ ...insertFieldAtEndOfSection,
10374
+ isOpen: isAddFieldDialogOpen,
10375
+ setIsOpen: setIsAddFieldDialogOpen
10376
+ }
10580
10377
  )
10581
- }
10582
- )
10583
- ] }),
10584
- /* @__PURE__ */ jsxRuntime.jsx(
10585
- FieldActions,
10586
- {
10587
- index: sectionIndex,
10588
- type: field.type,
10589
- remove: removeSection,
10590
- duplicate: duplicateSection,
10591
- move: moveSection
10378
+ ]
10592
10379
  }
10593
- )
10594
- ] })
10595
- }
10596
- );
10597
- } });
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
+ ) });
10598
10395
  });
10599
- FieldSectionWithActions.displayName = "FieldSectionWithActions";
10600
10396
  const reducer = (state, action) => {
10601
10397
  var _a2;
10602
10398
  const next = { ...state };
@@ -10658,40 +10454,11 @@ var __publicField = (obj, key, value) => {
10658
10454
  return [section, i];
10659
10455
  }
10660
10456
  };
10661
- const BasicFieldSection = React.memo((props) => {
10662
- const { field, provided } = props;
10663
- return /* @__PURE__ */ jsxRuntime.jsx(
10664
- Card,
10665
- {
10666
- ref: provided == null ? void 0 : provided.innerRef,
10667
- ...provided == null ? void 0 : provided.draggableProps,
10668
- ...provided == null ? void 0 : provided.dragHandleProps,
10669
- style: { ...provided == null ? void 0 : provided.draggableProps.style, height: "80px" },
10670
- children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "2", children: [
10671
- /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "row", gap: "2", children: [
10672
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "4", children: field.label }),
10673
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Badge, { style: { width: "fit-content" }, children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Text, { children: [
10674
- field.fields.length,
10675
- " Fields"
10676
- ] }) })
10677
- ] }),
10678
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Flex, { direction: "row", gap: "2", children: field.fields.map((child) => {
10679
- const childInfo = FieldTypeToClsMapping[child.type];
10680
- const Icon = childInfo.Icon;
10681
- return /* @__PURE__ */ jsxRuntime.jsx(blocks.Flex, { gap: "3", children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Badge, { style: { width: "fit-content" }, children: [
10682
- /* @__PURE__ */ jsxRuntime.jsx(Icon, {}),
10683
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { children: childInfo.fieldTypeName })
10684
- ] }) }, child.identifier);
10685
- }) })
10686
- ] })
10687
- }
10688
- );
10689
- });
10690
- BasicFieldSection.displayName = "BasicFieldSection";
10691
- const FieldsEditor = React.memo(() => {
10457
+ const FieldsEditor = React.memo(function FieldsEditor2() {
10692
10458
  const { values, setFieldValue } = formik.useFormikContext();
10693
10459
  const [dropState, dispatch] = React.useReducer(reducer, values.fields, initializer);
10694
- const { reorderSection, reorderField } = useFieldReordering();
10460
+ const [isAddSectionDialogOpen, setIsAddSectionDialogOpen] = React.useState(false);
10461
+ const { showInfo } = blocks.useToast();
10695
10462
  React.useEffect(() => {
10696
10463
  dispatch({ type: "update", state: initializer(values.fields) });
10697
10464
  }, [dispatch, values.fields]);
@@ -10707,30 +10474,58 @@ var __publicField = (obj, key, value) => {
10707
10474
  if (!destination || reason === "CANCEL")
10708
10475
  return;
10709
10476
  if (type === "ROOT") {
10710
- reorderSection(dropState, draggableId, source.index, destination.index, values, setFieldValue);
10711
- return;
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));
10712
10496
  }
10713
10497
  if (type !== "SECTION")
10714
10498
  throw new Error("Unexpected droppable type.");
10715
10499
  const [sourceSection, srcIndex] = findSection(values.fields, source.droppableId) ?? [];
10716
10500
  const [destinationSection, destIndex] = findSection(values.fields, destination.droppableId) ?? [];
10717
- reorderField(
10718
- sourceSection,
10719
- srcIndex,
10720
- source.index,
10721
- destinationSection,
10722
- destIndex,
10723
- destination.index,
10724
- setFieldValue
10725
- );
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
+ }
10726
10518
  },
10727
- [values, reorderField, setFieldValue, reorderSection, dropState]
10519
+ [values.fields, setFieldValue, dropState, showInfo]
10728
10520
  );
10729
- const handleCreateEmptySection = React.useCallback(
10730
- (index2) => {
10731
- createNewEmptySection(index2 + 1, values, setFieldValue);
10732
- },
10733
- [values, setFieldValue]
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]
10734
10529
  );
10735
10530
  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(
10736
10531
  blocks.Flex,
@@ -10740,200 +10535,123 @@ var __publicField = (obj, key, value) => {
10740
10535
  direction: "column",
10741
10536
  gap: "0",
10742
10537
  children: [
10743
- values.fields.map((field, index2) => /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
10744
- /* @__PURE__ */ jsxRuntime.jsx(FieldSectionWithActions, { field, index: index2, dropState }),
10745
- /* @__PURE__ */ jsxRuntime.jsxs(
10746
- blocks.Button,
10747
- {
10748
- type: "button",
10749
- variant: "surface",
10750
- severity: "info",
10751
- onClick: () => {
10752
- handleCreateEmptySection(index2);
10753
- },
10754
- style: { marginBottom: "4px" },
10755
- children: [
10756
- /* @__PURE__ */ jsxRuntime.jsx(PlusIcon, {}),
10757
- " Add section"
10758
- ]
10759
- }
10760
- )
10761
- ] }, field.identifier)),
10762
- droppableProvided.placeholder
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
+ )
10763
10570
  ]
10764
10571
  }
10765
10572
  ) }) });
10766
10573
  });
10767
- FieldsEditor.displayName = "FieldsEditor";
10768
10574
  const initialValues = {
10769
10575
  title: "",
10770
10576
  description: "",
10771
- fields: [{ ...emptySection(makeIdentifier(null, "")), label: "" }]
10772
- };
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." };
10773
10595
  const previewSubmit = () => {
10774
10596
  alert("This is a form preview, your data will not be saved.");
10775
10597
  };
10776
10598
  const FormBuilder = React.memo(
10777
10599
  React.forwardRef((props, ref) => {
10778
10600
  const { onCancel, onSave, revision } = props;
10779
- const { showError } = blocks.useToast();
10780
- const validate = React.useCallback(
10781
- (form) => {
10782
- const errors = {};
10783
- if (!form.title) {
10784
- errors.title = "Title is required.";
10785
- }
10786
- if (form.fields.length === 0) {
10787
- errors.fields = "At least one field is required.";
10788
- }
10789
- let fieldsToValidate = [];
10790
- for (const [sectionIndex, section] of form.fields.entries()) {
10791
- const fieldCls = CompleteFieldTypeToClsMapping.section;
10792
- const sectionSettings = fieldCls.getFieldCreationSchema(
10793
- makeConditionalSourceFields(form.fields, sectionIndex),
10794
- `fields.${sectionIndex}`
10795
- ).map((field) => field.field);
10796
- fieldsToValidate = [...fieldsToValidate, ...sectionSettings];
10797
- for (const [fieldIndex, field] of section.fields.entries()) {
10798
- const fieldCls2 = CompleteFieldTypeToClsMapping[field.type];
10799
- const fieldSettings = fieldCls2.getFieldCreationSchema(`fields.${sectionIndex}.fields.${fieldIndex}`).map((field2) => field2.field);
10800
- fieldsToValidate = [...fieldsToValidate, ...fieldSettings];
10801
- }
10802
- }
10803
- const fieldErrors = validateForm(
10804
- {
10805
- title: "Validate form builder",
10806
- fields: fieldsToValidate,
10807
- meta: { readonly: true }
10808
- },
10809
- form
10810
- );
10811
- if (fieldErrors) {
10812
- errors.fields = fieldErrors.fields;
10813
- }
10814
- if (hasKeys(errors)) {
10815
- showError({
10816
- title: "Some form settings are invalid",
10817
- description: "Please check settings highlighted in red."
10818
- });
10819
- return errors;
10820
- }
10821
- },
10822
- [showError]
10823
- );
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
+ }, []);
10824
10614
  const formik$1 = formik.useFormik({
10825
10615
  initialValues: wrapRootFieldsWithFieldSection(revision) ?? initialValues,
10826
10616
  validate,
10827
- // onSubmit: (form) => console.log("SUBMITTED", form),
10828
- onSubmit: (form) => {
10829
- onSave(form);
10830
- },
10831
- // only validate the entire form on submit
10617
+ onSubmit: onSave,
10618
+ // only validate the entire for on submit
10832
10619
  validateOnChange: false,
10833
10620
  validateOnBlur: false
10834
10621
  });
10835
10622
  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
+ );
10836
10629
  return /* @__PURE__ */ jsxRuntime.jsx(Tabs.Root, { ref, defaultValue: "edit", children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "2", children: [
10837
- /* @__PURE__ */ jsxRuntime.jsxs(
10838
- Tabs.List,
10839
- {
10840
- style: {
10841
- display: "flex",
10842
- position: "sticky",
10843
- top: 0,
10844
- zIndex: 2e3,
10845
- backgroundColor: "var(--color-background)"
10846
- },
10847
- children: [
10848
- /* @__PURE__ */ jsxRuntime.jsx(Tabs.Trigger, { style: { flex: 1 }, value: "edit", children: "Edit" }),
10849
- /* @__PURE__ */ jsxRuntime.jsx(Tabs.Trigger, { style: { flex: 1 }, value: "preview", children: "Preview" })
10850
- ]
10851
- }
10852
- ),
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
+ ] }),
10853
10634
  /* @__PURE__ */ jsxRuntime.jsxs(Tabs.Content, { value: "edit", children: [
10635
+ FormBuilderHeading,
10854
10636
  /* @__PURE__ */ jsxRuntime.jsxs(blocks.Text, { children: [
10855
- "Create your form using various field types. Sections can be",
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",
10856
10638
  " ",
10857
- /* @__PURE__ */ jsxRuntime.jsx("strong", { children: "conditionally rendered" }),
10858
- " based on",
10639
+ /* @__PURE__ */ jsxRuntime.jsx("em", { children: "Preview" }),
10640
+ " tab, but",
10859
10641
  " ",
10860
- /* @__PURE__ */ jsxRuntime.jsx("strong", { children: "answers to fields in preceding sections. " })
10642
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { children: "field values entered on this page will not be saved." })
10861
10643
  ] }),
10862
10644
  /* @__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: [
10863
10645
  /* @__PURE__ */ jsxRuntime.jsxs(formik.FormikProvider, { value: formik$1, children: [
10864
- /* @__PURE__ */ jsxRuntime.jsx(
10865
- PatchField,
10866
- {
10867
- name: "title",
10868
- render: ({ setValue, value, meta }) => /* @__PURE__ */ jsxRuntime.jsx(InputWithHelpText, { severity: "danger", helpText: meta.error ?? null, children: /* @__PURE__ */ jsxRuntime.jsx(
10869
- blocks.Input,
10870
- {
10871
- style: {
10872
- // var(--accent-a11) for red and var(--accent-1) for gray
10873
- border: meta.error ? "1px solid #ff9592" : "1px solid #5a6169",
10874
- paddingLeft: "8px",
10875
- fontWeight: "bold"
10876
- },
10877
- placeholder: "Form title",
10878
- value,
10879
- onChange: (event) => {
10880
- setValue(event.target.value);
10881
- },
10882
- maxLength: 100,
10883
- showInputLength: false,
10884
- variant: "ghost",
10885
- size: "large"
10886
- }
10887
- ) })
10888
- }
10889
- ),
10890
- /* @__PURE__ */ jsxRuntime.jsx(
10891
- PatchField,
10892
- {
10893
- name: "description",
10894
- render: ({ setValue, value }) => /* @__PURE__ */ jsxRuntime.jsx(
10895
- blocks.TextArea,
10896
- {
10897
- style: {
10898
- minHeight: "max-content",
10899
- border: "1px solid #5a6169",
10900
- paddingLeft: "8px",
10901
- paddingTop: "8px"
10902
- },
10903
- placeholder: "Explain the purpose of this form",
10904
- value,
10905
- onChange: (event) => {
10906
- setValue(event.target.value);
10907
- },
10908
- resize: "vertical",
10909
- maxLength: 1e3,
10910
- showInputLength: false,
10911
- variant: "ghost"
10912
- }
10913
- )
10914
- }
10915
- ),
10646
+ titleInput,
10647
+ descriptionInput,
10916
10648
  /* @__PURE__ */ jsxRuntime.jsx(FieldsEditor, {}),
10917
10649
  /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { severity: "danger", size: "1", children: typeof formik$1.errors.fields === "string" && formik$1.errors.fields })
10918
10650
  ] }),
10919
- /* @__PURE__ */ jsxRuntime.jsxs(
10920
- blocks.Flex,
10921
- {
10922
- justify: "end",
10923
- align: "center",
10924
- gap: "2",
10925
- style: {
10926
- position: "sticky",
10927
- bottom: 0,
10928
- paddingBottom: "10px",
10929
- paddingRight: "10px"
10930
- },
10931
- children: [
10932
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "button", variant: "solid", severity: "info", onClick: onCancel, children: "Cancel" }),
10933
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "submit", children: "Save form" })
10934
- ]
10935
- }
10936
- )
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
+ ] })
10937
10655
  ] }) })
10938
10656
  ] }),
10939
10657
  /* @__PURE__ */ jsxRuntime.jsx(Tabs.Content, { value: "preview", children: /* @__PURE__ */ jsxRuntime.jsx(FormRenderer, { schema: previewSchema, onSubmit: previewSubmit }) })
@@ -10954,7 +10672,6 @@ var __publicField = (obj, key, value) => {
10954
10672
  FormRenderer,
10955
10673
  FormSubmissionBrowser,
10956
10674
  FormSubmissionViewer,
10957
- InputWithHelpText,
10958
10675
  InputWithLabel,
10959
10676
  InputWithLabelAndHelpText,
10960
10677
  MultiSelectField,
@@ -10973,22 +10690,12 @@ var __publicField = (obj, key, value) => {
10973
10690
  TextInput,
10974
10691
  deserialize,
10975
10692
  deserializeField,
10976
- emptyBaseField,
10977
- emptyBooleanField,
10978
- emptyDateField,
10979
- emptyMultiSelectField,
10980
- emptyMultiStringField,
10981
- emptyNumberField,
10982
- emptySelectField,
10983
- emptyStringField,
10984
- emptyTextField,
10985
10693
  formRevisionToSchema,
10986
10694
  isConditionMet,
10987
10695
  useFieldInput,
10988
10696
  useFieldInputs,
10989
10697
  useFormikInput,
10990
- valueIsFile,
10991
- valueIsFormikUserFormRevision
10698
+ valueIsFile
10992
10699
  }, Symbol.toStringTag, { value: "Module" }));
10993
10700
  exports2.APIError = APIError;
10994
10701
  exports2.AttachmentService = AttachmentService;
@@ -11020,7 +10727,6 @@ var __publicField = (obj, key, value) => {
11020
10727
  exports2.FormSubmissionViewer = FormSubmissionViewer;
11021
10728
  exports2.GREEN = GREEN;
11022
10729
  exports2.HttpMethod = HttpMethod;
11023
- exports2.InputWithHelpText = InputWithHelpText;
11024
10730
  exports2.InputWithLabel = InputWithLabel;
11025
10731
  exports2.InputWithLabelAndHelpText = InputWithLabelAndHelpText;
11026
10732
  exports2.IssueCommentService = IssueCommentService;
@@ -11064,6 +10770,7 @@ var __publicField = (obj, key, value) => {
11064
10770
  exports2.WorkspaceService = WorkspaceService;
11065
10771
  exports2.YELLOW = YELLOW;
11066
10772
  exports2._setLatestRetryTime = _setLatestRetryTime;
10773
+ exports2.acceptProjectInvite = acceptProjectInvite;
11067
10774
  exports2.addAttachment = addAttachment;
11068
10775
  exports2.addAttachments = addAttachments;
11069
10776
  exports2.addCategory = addCategory;
@@ -11134,15 +10841,6 @@ var __publicField = (obj, key, value) => {
11134
10841
  exports2.emailDomainsReducer = emailDomainsReducer;
11135
10842
  exports2.emailDomainsSlice = emailDomainsSlice;
11136
10843
  exports2.emailRegex = emailRegex;
11137
- exports2.emptyBaseField = emptyBaseField;
11138
- exports2.emptyBooleanField = emptyBooleanField;
11139
- exports2.emptyDateField = emptyDateField;
11140
- exports2.emptyMultiSelectField = emptyMultiSelectField;
11141
- exports2.emptyMultiStringField = emptyMultiStringField;
11142
- exports2.emptyNumberField = emptyNumberField;
11143
- exports2.emptySelectField = emptySelectField;
11144
- exports2.emptyStringField = emptyStringField;
11145
- exports2.emptyTextField = emptyTextField;
11146
10844
  exports2.enqueue = enqueue;
11147
10845
  exports2.enqueueRequest = enqueueRequest;
11148
10846
  exports2.errorColor = errorColor;
@@ -11310,6 +11008,7 @@ var __publicField = (obj, key, value) => {
11310
11008
  exports2.selectOrganizationUsersAsMapping = selectOrganizationUsersAsMapping;
11311
11009
  exports2.selectOrganizationUsersIds = selectOrganizationUsersIds;
11312
11010
  exports2.selectOrganizations = selectOrganizations;
11011
+ exports2.selectOrganizationsWithAccess = selectOrganizationsWithAccess;
11313
11012
  exports2.selectPermittedWorkspaceIds = selectPermittedWorkspaceIds;
11314
11013
  exports2.selectPhotoAttachmentsOfIssue = selectPhotoAttachmentsOfIssue;
11315
11014
  exports2.selectProjectAccess = selectProjectAccess;
@@ -11321,6 +11020,7 @@ var __publicField = (obj, key, value) => {
11321
11020
  exports2.selectProjectUsersAsMapping = selectProjectUsersAsMapping;
11322
11021
  exports2.selectProjectUsersIds = selectProjectUsersIds;
11323
11022
  exports2.selectProjects = selectProjects;
11023
+ exports2.selectProjectsWithAccess = selectProjectsWithAccess;
11324
11024
  exports2.selectRecentIssueIds = selectRecentIssueIds;
11325
11025
  exports2.selectRecentIssuesAsSearchResults = selectRecentIssuesAsSearchResults;
11326
11026
  exports2.selectRecentProjects = selectRecentProjects;
@@ -11330,6 +11030,7 @@ var __publicField = (obj, key, value) => {
11330
11030
  exports2.selectSortedEmailDomains = selectSortedEmailDomains;
11331
11031
  exports2.selectSortedOrganizationUsers = selectSortedOrganizationUsers;
11332
11032
  exports2.selectSortedProjectUsers = selectSortedProjectUsers;
11033
+ exports2.selectSortedProjects = selectSortedProjects;
11333
11034
  exports2.selectStageMapping = selectStageMapping;
11334
11035
  exports2.selectStages = selectStages;
11335
11036
  exports2.selectStagesFromComponentType = selectStagesFromComponentType;
@@ -11351,7 +11052,6 @@ var __publicField = (obj, key, value) => {
11351
11052
  exports2.selectWorkspaceMapping = selectWorkspaceMapping;
11352
11053
  exports2.selectWorkspaces = selectWorkspaces;
11353
11054
  exports2.setActiveIssueId = setActiveIssueId;
11354
- exports2.setActiveOrganizationAccessId = setActiveOrganizationAccessId;
11355
11055
  exports2.setActiveOrganizationId = setActiveOrganizationId;
11356
11056
  exports2.setActiveProjectFileId = setActiveProjectFileId;
11357
11057
  exports2.setActiveProjectId = setActiveProjectId;
@@ -11426,7 +11126,6 @@ var __publicField = (obj, key, value) => {
11426
11126
  exports2.userReducer = userReducer;
11427
11127
  exports2.userSlice = userSlice;
11428
11128
  exports2.valueIsFile = valueIsFile;
11429
- exports2.valueIsFormikUserFormRevision = valueIsFormikUserFormRevision;
11430
11129
  exports2.warningColor = warningColor;
11431
11130
  exports2.workspaceReducer = workspaceReducer;
11432
11131
  exports2.workspaceSlice = workspaceSlice;