@overmap-ai/core 1.0.33-revamp-forms-builder.7 → 1.0.33-revamp-forms-builder.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import { BooleanField } from "../BooleanField";
2
2
  import { BaseField, ChildFieldOptions } from "../BaseField";
3
- import { GetInputProps, InputFieldLevelValidator, InputValidator } from "../typings";
3
+ import { ComponentProps, GetInputProps, InputFieldLevelValidator, InputValidator } from "../typings";
4
4
  import { ChangeEvent, ReactNode } from "react";
5
5
  import { FontFamilyIcon } from "@radix-ui/react-icons";
6
6
  import { ISerializedField, SerializedNumberField } from "../../typings.ts";
@@ -10,15 +10,6 @@ export interface NumberFieldOptions extends ChildFieldOptions<NumberFieldValue>
10
10
  minimum?: number;
11
11
  integers?: boolean;
12
12
  }
13
- export declare const emptyNumberField: {
14
- type: string;
15
- minimum: number;
16
- maximum: number;
17
- integers: boolean;
18
- label: string;
19
- required: boolean;
20
- description: string;
21
- };
22
13
  export declare class NumberField extends BaseField<NumberFieldValue, "number"> {
23
14
  static readonly fieldTypeName = "Number";
24
15
  static readonly fieldTypeDescription = "Allows specifying a number within a given range.";
@@ -42,3 +33,4 @@ export declare class NumberField extends BaseField<NumberFieldValue, "number"> {
42
33
  static deserialize(data: ISerializedField): NumberField;
43
34
  getInput(props: GetInputProps<this>): ReactNode;
44
35
  }
36
+ export declare const NumberInput: import("react").NamedExoticComponent<ComponentProps<NumberField>>;
@@ -1,4 +1,9 @@
1
- /// <reference types="react" />
2
- import { NumberField } from "./NumberField.tsx";
3
- import { ComponentProps } from "../typings.ts";
4
- export declare const NumberInput: import("react").NamedExoticComponent<ComponentProps<NumberField>>;
1
+ export declare const emptyNumberField: {
2
+ type: string;
3
+ minimum: number;
4
+ maximum: number;
5
+ integers: boolean;
6
+ label: string;
7
+ required: boolean;
8
+ description: string;
9
+ };
@@ -6716,6 +6716,115 @@ __publicField(_BooleanField, "fieldTypeName", "Checkbox");
6716
6716
  __publicField(_BooleanField, "fieldTypeDescription", "Perfect for both optional and required yes/no questions.");
6717
6717
  __publicField(_BooleanField, "Icon", CheckCircledIcon);
6718
6718
  let BooleanField = _BooleanField;
6719
+ class StringOrTextField extends BaseField {
6720
+ constructor(options) {
6721
+ const { minLength, maxLength = 5e3, ...base } = options;
6722
+ super(base);
6723
+ __publicField(this, "minLength");
6724
+ __publicField(this, "maxLength");
6725
+ this.minLength = minLength ? Math.max(minLength, 0) : void 0;
6726
+ this.maxLength = maxLength ? Math.max(maxLength, 0) : 5e3;
6727
+ }
6728
+ static getFieldCreationSchema(parentPath = "") {
6729
+ const path = parentPath && `${parentPath}.`;
6730
+ return [
6731
+ {
6732
+ field: (
6733
+ // min, max
6734
+ new NumberField({
6735
+ label: "Minimum length",
6736
+ description: "Minimum number of characters",
6737
+ required: false,
6738
+ identifier: `${path}minimum_length`,
6739
+ minimum: 0,
6740
+ maximum: 100,
6741
+ formValidators: [this._validateMin(parentPath)],
6742
+ integers: true
6743
+ })
6744
+ ),
6745
+ showDirectly: false
6746
+ },
6747
+ {
6748
+ field: new NumberField({
6749
+ label: "Maximum length",
6750
+ description: "Maximum number of characters",
6751
+ required: false,
6752
+ identifier: `${path}maximum_length`,
6753
+ minimum: 1,
6754
+ maximum: 5e3,
6755
+ // TODO: depends on short vs long text
6756
+ formValidators: [this._validateMax(parentPath)],
6757
+ // TODO: default: 500 (see: "Short text fields can hold up to 500 characters on a single line.")
6758
+ integers: true
6759
+ }),
6760
+ showDirectly: false
6761
+ }
6762
+ ];
6763
+ }
6764
+ getFieldValidators() {
6765
+ const validators = super.getFieldValidators();
6766
+ if (this.minLength) {
6767
+ validators.push((value) => {
6768
+ if (this.minLength && (!value || value.length < this.minLength)) {
6769
+ if (!this.required && !value)
6770
+ return null;
6771
+ return `Minimum ${this.minLength} character(s).`;
6772
+ }
6773
+ });
6774
+ }
6775
+ if (this.maxLength) {
6776
+ validators.push((value) => {
6777
+ if (typeof value === "string" && this.maxLength && value.length > this.maxLength) {
6778
+ return `Maximum ${this.maxLength} character(s).`;
6779
+ }
6780
+ });
6781
+ }
6782
+ return validators;
6783
+ }
6784
+ _serialize() {
6785
+ if (!this.identifier) {
6786
+ throw new Error("Field identifier must be set before serializing.");
6787
+ }
6788
+ return {
6789
+ ...super._serialize(),
6790
+ minimum_length: this.minLength,
6791
+ maximum_length: this.maxLength
6792
+ };
6793
+ }
6794
+ }
6795
+ /**
6796
+ * This function returns a function that validates that the value given for "minimum length" (when creating a new field) is less than or
6797
+ * equal to the value given for "maximum length".
6798
+ */
6799
+ __publicField(StringOrTextField, "_validateMin", (path) => (value, allValues) => {
6800
+ const field = valueIsFormikUserFormRevision(allValues) ? get(allValues, path) : allValues;
6801
+ if (typeof field.maximum_length === "number" && typeof value === "number" && field.maximum_length < value) {
6802
+ return "Minimum cannot be greater than maximum.";
6803
+ }
6804
+ return null;
6805
+ });
6806
+ /**
6807
+ * This function returns a function that validates that the value given for "maximum length" (when creating a new field) is greater than or
6808
+ * equal to the value given for "minimum length".
6809
+ */
6810
+ __publicField(StringOrTextField, "_validateMax", (path) => (value, allValues) => {
6811
+ if (typeof value !== "number")
6812
+ return null;
6813
+ const { minimum_length: minimumLength } = valueIsFormikUserFormRevision(allValues) ? get(allValues, path) : allValues;
6814
+ if (typeof minimumLength !== "number") {
6815
+ return null;
6816
+ }
6817
+ if (minimumLength > value) {
6818
+ return "Maximum cannot be less than minimum.";
6819
+ }
6820
+ return null;
6821
+ });
6822
+ const clickableLinkContainer = "_clickableLinkContainer_1ace7_1";
6823
+ const TextFieldInputCopy = "_TextFieldInputCopy_1ace7_5";
6824
+ const styles$5 = {
6825
+ clickableLinkContainer,
6826
+ TextFieldInputCopy
6827
+ };
6719
6828
  function getDefaultExportFromCjs(x) {
6720
6829
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
6721
6830
  }
@@ -8109,132 +8218,6 @@ const Tabs = Object.assign({}, {
8109
8218
  Trigger: TabsTrigger,
8110
8219
  Content: TabsContent
8111
8220
  });
8112
- const NumberInput$1 = memo(function NumberInput2(props) {
8113
- const [{ inputId, labelId, size, severity, helpText, label, fieldProps, field }, rest] = useFormikInput(props);
8114
- const color = useSeverityColor(severity);
8115
- return /* @__PURE__ */ jsx(InputWithLabelAndHelpText, { helpText, severity, children: /* @__PURE__ */ jsx(InputWithLabel, { size, severity, inputId, labelId, label, children: /* @__PURE__ */ jsx(
8116
- TextField$1.Input,
8117
- {
8118
- ...rest,
8119
- ...fieldProps,
8120
- type: "number",
8121
- id: inputId,
8122
- min: field.minimum,
8123
- max: field.maximum,
8124
- step: field.integers ? 1 : 0.1,
8125
- color
8126
- }
8127
- ) }) });
8128
- });
8129
- class StringOrTextField extends BaseField {
8130
- constructor(options) {
8131
- const { minLength, maxLength = 5e3, ...base } = options;
8132
- super(base);
8133
- __publicField(this, "minLength");
8134
- __publicField(this, "maxLength");
8135
- this.minLength = minLength ? Math.max(minLength, 0) : void 0;
8136
- this.maxLength = maxLength ? Math.max(maxLength, 0) : 5e3;
8137
- }
8138
- static getFieldCreationSchema(parentPath = "") {
8139
- const path = parentPath && `${parentPath}.`;
8140
- return [
8141
- {
8142
- field: (
8143
- // min, max
8144
- new NumberField({
8145
- label: "Minimum length",
8146
- description: "Minimum number of characters",
8147
- required: false,
8148
- identifier: `${path}minimum_length`,
8149
- minimum: 0,
8150
- maximum: 100,
8151
- formValidators: [this._validateMin(parentPath)],
8152
- integers: true
8153
- })
8154
- ),
8155
- showDirectly: false
8156
- },
8157
- {
8158
- field: new NumberField({
8159
- label: "Maximum length",
8160
- description: "Maximum number of characters",
8161
- required: false,
8162
- identifier: `${path}maximum_length`,
8163
- minimum: 1,
8164
- maximum: 5e3,
8165
- // TODO: depends on short vs long text
8166
- formValidators: [this._validateMax(parentPath)],
8167
- // TODO: default: 500 (see: "Short text fields can hold up to 500 characters on a single line.")
8168
- integers: true
8169
- }),
8170
- showDirectly: false
8171
- }
8172
- ];
8173
- }
8174
- getFieldValidators() {
8175
- const validators = super.getFieldValidators();
8176
- if (this.minLength) {
8177
- validators.push((value) => {
8178
- if (this.minLength && (!value || value.length < this.minLength)) {
8179
- if (!this.required && !value)
8180
- return null;
8181
- return `Minimum ${this.minLength} character(s).`;
8182
- }
8183
- });
8184
- }
8185
- if (this.maxLength) {
8186
- validators.push((value) => {
8187
- if (typeof value === "string" && this.maxLength && value.length > this.maxLength) {
8188
- return `Maximum ${this.maxLength} character(s).`;
8189
- }
8190
- });
8191
- }
8192
- return validators;
8193
- }
8194
- _serialize() {
8195
- if (!this.identifier) {
8196
- throw new Error("Field identifier must be set before serializing.");
8197
- }
8198
- return {
8199
- ...super._serialize(),
8200
- minimum_length: this.minLength,
8201
- maximum_length: this.maxLength
8202
- };
8203
- }
8204
- }
8205
- /**
8206
- * This function returns a function that validates that the value given for "minimum length" (when creating a new field) is less than or
8207
- * equal to the value given for "maximum length".
8208
- */
8209
- __publicField(StringOrTextField, "_validateMin", (path) => (value, allValues) => {
8210
- const field = valueIsFormikUserFormRevision(allValues) ? get(allValues, path) : allValues;
8211
- if (typeof field.maximum_length === "number" && typeof value === "number" && field.maximum_length < value) {
8212
- return "Minimum cannot be greater than maximum.";
8213
- }
8214
- return null;
8215
- });
8216
- /**
8217
- * This function returns a function that validates that the value given for "maximum length" (when creating a new field) is greater than or
8218
- * equal to the value given for "minimum length".
8219
- */
8220
- __publicField(StringOrTextField, "_validateMax", (path) => (value, allValues) => {
8221
- if (typeof value !== "number")
8222
- return null;
8223
- const { minimum_length: minimumLength } = valueIsFormikUserFormRevision(allValues) ? get(allValues, path) : allValues;
8224
- if (typeof minimumLength !== "number") {
8225
- return null;
8226
- }
8227
- if (minimumLength > value) {
8228
- return "Maximum cannot be less than minimum.";
8229
- }
8230
- return null;
8231
- });
8232
- const clickableLinkContainer = "_clickableLinkContainer_1ace7_1";
8233
- const TextFieldInputCopy = "_TextFieldInputCopy_1ace7_5";
8234
- const styles$5 = {
8235
- clickableLinkContainer,
8236
- TextFieldInputCopy
8237
- };
8238
8221
  const StringInput = memo(function StringInput2(props) {
8239
8222
  const [{ inputId, labelId, size, severity, helpText, label, fieldProps, field }, rest] = useFormikInput(props);
8240
8223
  const color = useSeverityColor(severity);
@@ -8927,7 +8910,7 @@ const convertBytesToLargestUnit = (bytes) => {
8927
8910
  });
8928
8911
  return formatter.format(sizeInUnit);
8929
8912
  };
8930
- const NumberInput = memo(function NumberInput22(props) {
8913
+ const NumberInput$1 = memo(function NumberInput2(props) {
8931
8914
  var _a2;
8932
8915
  const [{ inputId, labelId, size, severity, helpText, label, fieldProps, field }, rest] = useFormikInput(props);
8933
8916
  const { onChange } = fieldProps;
@@ -9161,7 +9144,7 @@ const _UploadField = class _UploadField extends BaseField {
9161
9144
  return new _UploadField(data);
9162
9145
  }
9163
9146
  getInput(props) {
9164
- return /* @__PURE__ */ jsx(NumberInput, { field: this, ...props });
9147
+ return /* @__PURE__ */ jsx(NumberInput$1, { field: this, ...props });
9165
9148
  }
9166
9149
  };
9167
9150
  __publicField(_UploadField, "fieldTypeName", "Upload");
@@ -9436,13 +9419,6 @@ function isConditionMet(condition, value) {
9436
9419
  }
9437
9420
  return valueToCompare === value;
9438
9421
  }
9439
- const emptyNumberField = {
9440
- ...emptyBaseField,
9441
- type: "number",
9442
- minimum: Number.MIN_SAFE_INTEGER,
9443
- maximum: Number.MAX_SAFE_INTEGER,
9444
- integers: false
9445
- };
9446
9422
  const _NumberField = class _NumberField extends BaseField {
9447
9423
  constructor(options) {
9448
9424
  const {
@@ -9542,7 +9518,7 @@ const _NumberField = class _NumberField extends BaseField {
9542
9518
  return new _NumberField(data);
9543
9519
  }
9544
9520
  getInput(props) {
9545
- return /* @__PURE__ */ jsx(NumberInput$1, { field: this, ...props });
9521
+ return /* @__PURE__ */ jsx(NumberInput, { field: this, ...props });
9546
9522
  }
9547
9523
  };
9548
9524
  __publicField(_NumberField, "fieldTypeName", "Number");
@@ -9563,6 +9539,30 @@ __publicField(_NumberField, "_validateMax", (path) => (value, allValues) => {
9563
9539
  return null;
9564
9540
  });
9565
9541
  let NumberField = _NumberField;
9542
+ const NumberInput = memo(function NumberInput22(props) {
9543
+ const [{ inputId, labelId, size, severity, helpText, label, fieldProps, field }, rest] = useFormikInput(props);
9544
+ const color = useSeverityColor(severity);
9545
+ return /* @__PURE__ */ jsx(InputWithLabelAndHelpText, { helpText, severity, children: /* @__PURE__ */ jsx(InputWithLabel, { size, severity, inputId, labelId, label, children: /* @__PURE__ */ jsx(
9546
+ TextField$1.Input,
9547
+ {
9548
+ ...rest,
9549
+ ...fieldProps,
9550
+ type: "number",
9551
+ id: inputId,
9552
+ min: field.minimum,
9553
+ max: field.maximum,
9554
+ step: field.integers ? 1 : 0.1,
9555
+ color
9556
+ }
9557
+ ) }) });
9558
+ });
9559
+ const emptyNumberField = {
9560
+ ...emptyBaseField,
9561
+ type: "number",
9562
+ minimum: Number.MIN_SAFE_INTEGER,
9563
+ maximum: Number.MAX_SAFE_INTEGER,
9564
+ integers: false
9565
+ };
9566
9566
  const hasKeys = (errors) => {
9567
9567
  return Object.keys(errors).length > 0;
9568
9568
  };
@@ -11022,7 +11022,7 @@ const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
11022
11022
  MultiStringField,
11023
11023
  MultiStringInput,
11024
11024
  NumberField,
11025
- NumberInput: NumberInput$1,
11025
+ NumberInput,
11026
11026
  PatchField,
11027
11027
  PatchFormProvider,
11028
11028
  SelectField,
@@ -11095,7 +11095,7 @@ export {
11095
11095
  MultiStringField,
11096
11096
  MultiStringInput,
11097
11097
  NumberField,
11098
- NumberInput$1 as NumberInput,
11098
+ NumberInput,
11099
11099
  OUTBOX_RETRY_DELAY,
11100
11100
  OrganizationAccessLevel,
11101
11101
  OrganizationAccessService,