@overmap-ai/forms 1.0.32-react-flow-david-fixes.30 → 1.0.32-react-flow-david-fixes.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.
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { UploadField } from '../../fields';
2
+ import { UploadField, UUIDPromise } from '../../fields';
3
3
  import { BaseCondition, ConditionOptions, ConditionRenderProps } from '../BaseCondition';
4
4
  import { SerializedUploadCondition, UploadConditionModifiers } from './typings';
5
5
  export interface UploadFieldConditionOptions extends ConditionOptions<UploadField, boolean, UploadConditionModifiers> {
@@ -8,8 +8,8 @@ export declare class UploadFieldCondition extends BaseCondition<UploadField, boo
8
8
  readonly defaultConditionValue: undefined;
9
9
  readonly defaultConditionModifier = "equals";
10
10
  readonly modifiers: {
11
- equals: import('../..').FieldConditionModifierConfig<(File | Promise<File>)[], boolean, boolean, File[], boolean, boolean>;
12
- notEquals: import('../..').FieldConditionModifierConfig<(File | Promise<File>)[], boolean, boolean, File[], boolean, boolean>;
11
+ equals: import('../..').FieldConditionModifierConfig<(File | UUIDPromise<File>)[], boolean, boolean, File[], boolean, boolean>;
12
+ notEquals: import('../..').FieldConditionModifierConfig<(File | UUIDPromise<File>)[], boolean, boolean, File[], boolean, boolean>;
13
13
  };
14
14
  constructor(options: UploadFieldConditionOptions);
15
15
  static deserialize(serializedCondition: SerializedUploadCondition, field: UploadField): UploadFieldCondition;
@@ -0,0 +1,7 @@
1
+ export declare class UUIDPromise<T> extends Promise<T> {
2
+ readonly uuid: string;
3
+ constructor(uuid: string, executor: (...args: Parameters<ConstructorParameters<typeof Promise<T>>[0]>) => void);
4
+ static from<T>(uuid: string, promise: Promise<T>): UUIDPromise<T>;
5
+ then<TResult1 = T, TResult2 = never>(...args: Parameters<Promise<T>["then"]>): UUIDPromise<TResult1 | TResult2>;
6
+ catch<TResult2 = never>(...args: Parameters<Promise<T>["catch"]>): UUIDPromise<T | TResult2>;
7
+ }
@@ -4,12 +4,13 @@ import { FieldRenderProps } from '../BaseFormElement';
4
4
  import { MultiSelectField } from '../MultiSelectField';
5
5
  import { NumberField } from '../NumberField';
6
6
  import { SerializedUploadField } from './typings';
7
- export interface UploadFieldOptions extends FieldOptions<(Promise<File> | File)[]> {
7
+ import { UUIDPromise } from './UUIDPromise';
8
+ export interface UploadFieldOptions extends FieldOptions<(UUIDPromise<File> | File)[]> {
8
9
  extensions?: string[];
9
10
  maximum_size?: number | string;
10
11
  maximum_files?: number | string;
11
12
  }
12
- export declare class UploadField extends BaseField<"upload", (Promise<File> | File)[], never[], UploadField> {
13
+ export declare class UploadField extends BaseField<"upload", (UUIDPromise<File> | File)[], never[], UploadField> {
13
14
  readonly type = "upload";
14
15
  static readonly fieldTypeName = "Upload";
15
16
  static readonly fieldTypeDescription = "Allows a file to be uploaded.";
@@ -25,17 +26,17 @@ export declare class UploadField extends BaseField<"upload", (Promise<File> | Fi
25
26
  field: MultiSelectField;
26
27
  showDirectly: boolean;
27
28
  })[];
28
- getFieldValidators(): FieldValidator<(Promise<File> | File)[]>[];
29
+ getFieldValidators(): FieldValidator<(UUIDPromise<File> | File)[]>[];
29
30
  serialize(): SerializedUploadField;
30
31
  getOptions(): UploadFieldOptions;
31
32
  duplicate(identifier: string): UploadField;
32
33
  setOptions(options: Partial<UploadFieldOptions>): void;
33
34
  static deserialize(data: SerializedUploadField): UploadField;
34
- serializeValue(_value: (Promise<File> | File)[]): never[];
35
- deserializeValue(_value: never[]): (Promise<File> | File)[];
35
+ serializeValue(_value: (UUIDPromise<File> | File)[]): never[];
36
+ deserializeValue(_value: never[]): (UUIDPromise<File> | File)[];
36
37
  render(props: FieldRenderProps): ReactNode;
37
38
  isSerializedValueValid(value: unknown): value is never[];
38
- isValueValid(value: unknown): value is (Promise<File> | File)[];
39
- areValuesEqual(value1: (Promise<File> | File)[], value2: (Promise<File> | File)[]): boolean;
40
- blankValue(): (Promise<File> | File)[];
39
+ isValueValid(value: unknown): value is (UUIDPromise<File> | File)[];
40
+ areValuesEqual(value1: (UUIDPromise<File> | File)[], value2: (UUIDPromise<File> | File)[]): boolean;
41
+ blankValue(): (UUIDPromise<File> | File)[];
41
42
  }
@@ -1,3 +1,4 @@
1
1
  export * from './typings';
2
2
  export * from './UploadField';
3
3
  export * from './UploadInput';
4
+ export * from './UUIDPromise';
@@ -1,3 +1,4 @@
1
+ import { UUIDPromise } from './UUIDPromise';
1
2
  export declare const convertBytesToLargestUnit: (bytes: number) => string;
2
3
  export declare function areFilesEqual(file1: File, file2: File): boolean;
3
- export declare function seprateFilesFromPromises(filesOrPromises: (Promise<File> | File)[]): [File[], Promise<File>[]];
4
+ export declare function separateFilesFromPromises(filesOrPromises: (UUIDPromise<File> | File)[]): [File[], UUIDPromise<File>[]];
@@ -1,2 +1 @@
1
1
  export declare function isStringArray(value: unknown): value is string[];
2
- export declare function isFilePromiseArray(value: unknown): value is (Promise<File> | File)[];
@@ -1,5 +1,4 @@
1
- export { isFilePromiseArray } from './_utils';
2
- export { isStringArray } from './_utils';
1
+ export * from './_utils';
3
2
  export * from './BaseField';
4
3
  export * from './BaseFormElement';
5
4
  export * from './BaseOptionsField';
package/dist/forms.js CHANGED
@@ -42,10 +42,6 @@ function isStringArray(value) {
42
42
  if (!Array.isArray(value)) return false;
43
43
  return value.every((item) => typeof item === "string");
44
44
  }
45
- function isFilePromiseArray(value) {
46
- if (!Array.isArray(value)) return false;
47
- return value.every((item) => item instanceof Promise || item instanceof File);
48
- }
49
45
  class Observable {
50
46
  constructor() {
51
47
  __publicField(this, "observers", /* @__PURE__ */ new Set());
@@ -32257,6 +32253,24 @@ const ImageCard = memo(
32257
32253
  );
32258
32254
  })
32259
32255
  );
32256
+ class UUIDPromise extends Promise {
32257
+ constructor(uuid, executor) {
32258
+ super(executor);
32259
+ __publicField(this, "uuid");
32260
+ this.uuid = uuid;
32261
+ }
32262
+ static from(uuid, promise) {
32263
+ return new UUIDPromise(uuid, (resolve, reject) => {
32264
+ promise.then(resolve).catch(reject);
32265
+ });
32266
+ }
32267
+ then(...args) {
32268
+ return UUIDPromise.from(this.uuid, super.then(...args));
32269
+ }
32270
+ catch(...args) {
32271
+ return UUIDPromise.from(this.uuid, super.catch(...args));
32272
+ }
32273
+ }
32260
32274
  const convertBytesToLargestUnit = (bytes) => {
32261
32275
  const units = ["byte", "kilobyte", "megabyte"];
32262
32276
  let sizeInUnit = bytes;
@@ -32276,11 +32290,11 @@ const convertBytesToLargestUnit = (bytes) => {
32276
32290
  function areFilesEqual(file1, file2) {
32277
32291
  return file1.name === file2.name && file1.size === file2.size && file1.type === file2.type;
32278
32292
  }
32279
- function seprateFilesFromPromises(filesOrPromises) {
32293
+ function separateFilesFromPromises(filesOrPromises) {
32280
32294
  const files = [];
32281
32295
  const promises = [];
32282
32296
  for (const fileOrPromise of filesOrPromises) {
32283
- if (fileOrPromise instanceof Promise) {
32297
+ if (fileOrPromise instanceof UUIDPromise) {
32284
32298
  promises.push(fileOrPromise);
32285
32299
  } else {
32286
32300
  files.push(fileOrPromise);
@@ -32428,7 +32442,7 @@ const DisplayFile = memo((props) => {
32428
32442
  return { url: url2, name: name2, size };
32429
32443
  }, [resolvedFile]);
32430
32444
  useEffect(() => {
32431
- if (file instanceof Promise) {
32445
+ if (file instanceof UUIDPromise) {
32432
32446
  file.then(setResolvedFile).catch(console.error);
32433
32447
  } else {
32434
32448
  setResolvedFile(file);
@@ -32625,15 +32639,16 @@ const _UploadField = class _UploadField extends BaseField {
32625
32639
  return Array.isArray(value) && value.length === 0;
32626
32640
  }
32627
32641
  isValueValid(value) {
32628
- return isFilePromiseArray(value);
32642
+ if (!Array.isArray(value)) return false;
32643
+ return value.every((item) => item instanceof UUIDPromise || item instanceof File);
32629
32644
  }
32630
32645
  areValuesEqual(value1, value2) {
32631
- const [files1, promises1] = seprateFilesFromPromises(value1);
32632
- const [files2, promises2] = seprateFilesFromPromises(value2);
32646
+ const [files1, promises1] = separateFilesFromPromises(value1);
32647
+ const [files2, promises2] = separateFilesFromPromises(value2);
32633
32648
  if (!files1.every((file1) => files2.some((file2) => areFilesEqual(file1, file2)))) return false;
32634
32649
  if (!files2.every((file2) => files1.some((file1) => areFilesEqual(file1, file2)))) return false;
32635
- if (!promises1.every((promise1) => promises2.some((promise2) => promise1 === promise2))) return false;
32636
- if (!promises2.every((promise2) => promises1.some((promise1) => promise1 === promise2))) return false;
32650
+ if (!promises1.every((promise1) => promises2.some((promise2) => promise1.uuid === promise2.uuid))) return false;
32651
+ if (!promises2.every((promise2) => promises1.some((promise1) => promise1.uuid === promise2.uuid))) return false;
32637
32652
  return true;
32638
32653
  }
32639
32654
  blankValue() {
@@ -36573,6 +36588,7 @@ export {
36573
36588
  TextFieldCondition,
36574
36589
  TextFieldConditionCell,
36575
36590
  TextInput,
36591
+ UUIDPromise,
36576
36592
  UploadField,
36577
36593
  UploadFieldCondition,
36578
36594
  UploadFieldConditionCell,
@@ -36596,7 +36612,6 @@ export {
36596
36612
  flattenFields,
36597
36613
  getFieldsMapping,
36598
36614
  initializeFieldValues,
36599
- isFilePromiseArray,
36600
36615
  isStringArray,
36601
36616
  maxFileSizeB,
36602
36617
  maxFileSizeKB,
@@ -44,10 +44,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
44
44
  if (!Array.isArray(value)) return false;
45
45
  return value.every((item) => typeof item === "string");
46
46
  }
47
- function isFilePromiseArray(value) {
48
- if (!Array.isArray(value)) return false;
49
- return value.every((item) => item instanceof Promise || item instanceof File);
50
- }
51
47
  class Observable {
52
48
  constructor() {
53
49
  __publicField(this, "observers", /* @__PURE__ */ new Set());
@@ -32259,6 +32255,24 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
32259
32255
  );
32260
32256
  })
32261
32257
  );
32258
+ class UUIDPromise extends Promise {
32259
+ constructor(uuid2, executor) {
32260
+ super(executor);
32261
+ __publicField(this, "uuid");
32262
+ this.uuid = uuid2;
32263
+ }
32264
+ static from(uuid2, promise) {
32265
+ return new UUIDPromise(uuid2, (resolve, reject) => {
32266
+ promise.then(resolve).catch(reject);
32267
+ });
32268
+ }
32269
+ then(...args) {
32270
+ return UUIDPromise.from(this.uuid, super.then(...args));
32271
+ }
32272
+ catch(...args) {
32273
+ return UUIDPromise.from(this.uuid, super.catch(...args));
32274
+ }
32275
+ }
32262
32276
  const convertBytesToLargestUnit = (bytes) => {
32263
32277
  const units = ["byte", "kilobyte", "megabyte"];
32264
32278
  let sizeInUnit = bytes;
@@ -32278,11 +32292,11 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
32278
32292
  function areFilesEqual(file1, file2) {
32279
32293
  return file1.name === file2.name && file1.size === file2.size && file1.type === file2.type;
32280
32294
  }
32281
- function seprateFilesFromPromises(filesOrPromises) {
32295
+ function separateFilesFromPromises(filesOrPromises) {
32282
32296
  const files = [];
32283
32297
  const promises = [];
32284
32298
  for (const fileOrPromise of filesOrPromises) {
32285
- if (fileOrPromise instanceof Promise) {
32299
+ if (fileOrPromise instanceof UUIDPromise) {
32286
32300
  promises.push(fileOrPromise);
32287
32301
  } else {
32288
32302
  files.push(fileOrPromise);
@@ -32430,7 +32444,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
32430
32444
  return { url: url2, name: name2, size };
32431
32445
  }, [resolvedFile]);
32432
32446
  React.useEffect(() => {
32433
- if (file instanceof Promise) {
32447
+ if (file instanceof UUIDPromise) {
32434
32448
  file.then(setResolvedFile).catch(console.error);
32435
32449
  } else {
32436
32450
  setResolvedFile(file);
@@ -32627,15 +32641,16 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
32627
32641
  return Array.isArray(value) && value.length === 0;
32628
32642
  }
32629
32643
  isValueValid(value) {
32630
- return isFilePromiseArray(value);
32644
+ if (!Array.isArray(value)) return false;
32645
+ return value.every((item) => item instanceof UUIDPromise || item instanceof File);
32631
32646
  }
32632
32647
  areValuesEqual(value1, value2) {
32633
- const [files1, promises1] = seprateFilesFromPromises(value1);
32634
- const [files2, promises2] = seprateFilesFromPromises(value2);
32648
+ const [files1, promises1] = separateFilesFromPromises(value1);
32649
+ const [files2, promises2] = separateFilesFromPromises(value2);
32635
32650
  if (!files1.every((file1) => files2.some((file2) => areFilesEqual(file1, file2)))) return false;
32636
32651
  if (!files2.every((file2) => files1.some((file1) => areFilesEqual(file1, file2)))) return false;
32637
- if (!promises1.every((promise1) => promises2.some((promise2) => promise1 === promise2))) return false;
32638
- if (!promises2.every((promise2) => promises1.some((promise1) => promise1 === promise2))) return false;
32652
+ if (!promises1.every((promise1) => promises2.some((promise2) => promise1.uuid === promise2.uuid))) return false;
32653
+ if (!promises2.every((promise2) => promises1.some((promise1) => promise1.uuid === promise2.uuid))) return false;
32639
32654
  return true;
32640
32655
  }
32641
32656
  blankValue() {
@@ -36574,6 +36589,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
36574
36589
  exports2.TextFieldCondition = TextFieldCondition;
36575
36590
  exports2.TextFieldConditionCell = TextFieldConditionCell;
36576
36591
  exports2.TextInput = TextInput;
36592
+ exports2.UUIDPromise = UUIDPromise;
36577
36593
  exports2.UploadField = UploadField;
36578
36594
  exports2.UploadFieldCondition = UploadFieldCondition;
36579
36595
  exports2.UploadFieldConditionCell = UploadFieldConditionCell;
@@ -36597,7 +36613,6 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
36597
36613
  exports2.flattenFields = flattenFields;
36598
36614
  exports2.getFieldsMapping = getFieldsMapping;
36599
36615
  exports2.initializeFieldValues = initializeFieldValues;
36600
- exports2.isFilePromiseArray = isFilePromiseArray;
36601
36616
  exports2.isStringArray = isStringArray;
36602
36617
  exports2.maxFileSizeB = maxFileSizeB;
36603
36618
  exports2.maxFileSizeKB = maxFileSizeKB;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@overmap-ai/forms",
3
- "version": "1.0.32-react-flow-david-fixes.30",
3
+ "version": "1.0.32-react-flow-david-fixes.32",
4
4
  "license": "UNLICENSED",
5
5
  "main": "dist/forms.umd.cjs",
6
6
  "module": "dist/forms.js",