@overmap-ai/forms 1.0.32-react-flow-david-fixes.4 → 1.0.32-react-flow-david-fixes.6
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.
- package/dist/form/conditions/UploadFieldCondition/UploadFieldCondition.d.ts +2 -2
- package/dist/form/fields/FieldSection/FieldSection.d.ts +3 -3
- package/dist/form/fields/UploadField/UploadField.d.ts +7 -7
- package/dist/form/fields/typings.d.ts +1 -1
- package/dist/form/schema/FieldSchema.d.ts +2 -2
- package/dist/form/typings.d.ts +1 -1
- package/dist/forms.js +73 -58
- package/dist/forms.umd.cjs +73 -58
- package/package.json +1 -1
|
@@ -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('../../modifiers').FieldConditionModifierConfig<File[], boolean, boolean, File[], boolean, boolean>;
|
|
12
|
-
notEquals: import('../../modifiers').FieldConditionModifierConfig<File[], boolean, boolean, File[], boolean, boolean>;
|
|
11
|
+
equals: import('../../modifiers').FieldConditionModifierConfig<(File | Promise<File>)[], boolean, boolean, File[], boolean, boolean>;
|
|
12
|
+
notEquals: import('../../modifiers').FieldConditionModifierConfig<(File | Promise<File>)[], boolean, boolean, File[], boolean, boolean>;
|
|
13
13
|
};
|
|
14
14
|
constructor(options: UploadFieldConditionOptions);
|
|
15
15
|
static deserialize(serializedCondition: SerializedUploadCondition, field: UploadField): UploadFieldCondition;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { FormBuilderValues } from '../../builder';
|
|
3
|
-
import { Condition, ConditionManager } from '../../conditions
|
|
3
|
+
import { Condition, ConditionManager } from '../../conditions';
|
|
4
4
|
import { FieldValues } from '../../typings';
|
|
5
5
|
import { BaseFormElement, FormElementOptions } from '../BaseFormElement';
|
|
6
|
-
import { ComponentProps, Field,
|
|
6
|
+
import { ComponentProps, Field, FieldsManager } from '../typings';
|
|
7
7
|
import { FieldSectionConditions, SerializedFieldSection } from './typings';
|
|
8
8
|
export interface FieldSectionOptions extends FormElementOptions {
|
|
9
9
|
label?: string | null;
|
|
@@ -11,7 +11,7 @@ export interface FieldSectionOptions extends FormElementOptions {
|
|
|
11
11
|
conditions?: FieldSectionConditions;
|
|
12
12
|
fields: Field[];
|
|
13
13
|
}
|
|
14
|
-
export declare class FieldSection extends BaseFormElement<"section", FieldSection> implements ConditionManager<Condition>,
|
|
14
|
+
export declare class FieldSection extends BaseFormElement<"section", FieldSection> implements ConditionManager<Condition>, FieldsManager<Field> {
|
|
15
15
|
static readonly fieldTypeName = "Section";
|
|
16
16
|
static readonly fieldTypeDescription = "Sections can be useful for grouping fields together. They can also be conditionally shown or hidden.";
|
|
17
17
|
readonly type = "section";
|
|
@@ -4,12 +4,12 @@ import { MultiSelectField } from '../MultiSelectField';
|
|
|
4
4
|
import { NumberField } from '../NumberField';
|
|
5
5
|
import { ComponentProps, FieldValidator } from '../typings';
|
|
6
6
|
import { SerializedUploadField } from './typings';
|
|
7
|
-
export interface UploadFieldOptions extends FieldOptions<File[]> {
|
|
7
|
+
export interface UploadFieldOptions extends FieldOptions<(Promise<File> | File)[]> {
|
|
8
8
|
extensions?: string[];
|
|
9
9
|
maximum_size?: number | string;
|
|
10
10
|
maximum_files?: number | string;
|
|
11
11
|
}
|
|
12
|
-
export declare class UploadField extends BaseField<"upload", File[], never[], UploadField> {
|
|
12
|
+
export declare class UploadField extends BaseField<"upload", (Promise<File> | File)[], never[], UploadField> {
|
|
13
13
|
readonly type = "upload";
|
|
14
14
|
static readonly fieldTypeName = "Upload";
|
|
15
15
|
static readonly fieldTypeDescription = "Allows a file to be uploaded.";
|
|
@@ -18,8 +18,8 @@ export declare class UploadField extends BaseField<"upload", File[], never[], Up
|
|
|
18
18
|
maxFiles: number;
|
|
19
19
|
readonly onlyValidateAfterTouched = false;
|
|
20
20
|
constructor(options: UploadFieldOptions);
|
|
21
|
-
isBlank(value: File[] | undefined): boolean;
|
|
22
|
-
isEqual(value1: File[] | undefined, value2: File[] | undefined): boolean;
|
|
21
|
+
isBlank(value: (Promise<File> | File)[] | undefined): boolean;
|
|
22
|
+
isEqual(value1: (Promise<File> | File)[] | undefined, value2: (Promise<File> | File)[] | undefined): boolean;
|
|
23
23
|
static getFieldCreationSchema(parentPath?: string): ({
|
|
24
24
|
field: NumberField;
|
|
25
25
|
showDirectly: boolean;
|
|
@@ -27,13 +27,13 @@ export declare class UploadField extends BaseField<"upload", File[], never[], Up
|
|
|
27
27
|
field: MultiSelectField;
|
|
28
28
|
showDirectly: boolean;
|
|
29
29
|
})[];
|
|
30
|
-
getFieldValidators(): FieldValidator<File[]>[];
|
|
30
|
+
getFieldValidators(): FieldValidator<(Promise<File> | File)[]>[];
|
|
31
31
|
serialize(): SerializedUploadField;
|
|
32
32
|
getOptions(): UploadFieldOptions;
|
|
33
33
|
duplicate(identifier: string): UploadField;
|
|
34
34
|
setOptions(options: Partial<UploadFieldOptions>): void;
|
|
35
35
|
static deserialize(data: SerializedUploadField): UploadField;
|
|
36
|
-
serializeValue(_value: File[]): never[];
|
|
37
|
-
deserializeValue(_value: never[]): File[];
|
|
36
|
+
serializeValue(_value: (Promise<File> | File)[]): never[];
|
|
37
|
+
deserializeValue(_value: never[]): (Promise<File> | File)[];
|
|
38
38
|
render(props: ComponentProps): ReactNode;
|
|
39
39
|
}
|
|
@@ -32,7 +32,7 @@ export type SerializedFieldValue = SerializedValueOfField<BooleanField> | Serial
|
|
|
32
32
|
export type Field = BooleanField | CheckboxListField | DateField | MultiSelectField | MultiStringField | NumberField | RadioField | ScanField | SelectField | StringField | TextField | UploadField;
|
|
33
33
|
export type SerializedField = SerializedTextField | SerializedBooleanField | SerializedNumberField | SerializedDateField | SerializedStringField | SerializedSelectField | SerializedFieldSection | SerializedMultiStringField | SerializedMultiSelectField | SerializedUploadField | SerializedScanField | SerializedRadioField | SerializedCheckboxListField;
|
|
34
34
|
export type SerializedOnlyField = Exclude<SerializedField, SerializedFieldSection>;
|
|
35
|
-
export interface
|
|
35
|
+
export interface FieldsManager<TField extends AnyFormElement> {
|
|
36
36
|
readonly fields: TField[];
|
|
37
37
|
getFields(): TField[];
|
|
38
38
|
addField(field: TField): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FieldSection,
|
|
1
|
+
import { FieldSection, FieldsManager, SerializedFieldSection } from '../fields';
|
|
2
2
|
import { Observable } from '../observable/Observable';
|
|
3
|
-
export declare class FieldSchema extends Observable<FieldSchema> implements
|
|
3
|
+
export declare class FieldSchema extends Observable<FieldSchema> implements FieldsManager<FieldSection> {
|
|
4
4
|
fields: FieldSection[];
|
|
5
5
|
constructor(fields: FieldSection[]);
|
|
6
6
|
serialize(): SerializedFieldSection[];
|
package/dist/form/typings.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Field, FieldSection, FieldValue, SerializedFieldValue } from './fields';
|
|
2
|
-
export type FieldValues = Record<string, FieldValue |
|
|
2
|
+
export type FieldValues = Record<string, FieldValue | undefined>;
|
|
3
3
|
export type SerializedFieldValues = Record<string, SerializedFieldValue>;
|
|
4
4
|
export type Severity = "danger" | "warning" | "info" | "success";
|
|
5
5
|
export interface SchemaMeta {
|
package/dist/forms.js
CHANGED
|
@@ -32180,6 +32180,18 @@ DisplayFile.displayName = "DisplayFile";
|
|
|
32180
32180
|
function areFilesEqual(file1, file2) {
|
|
32181
32181
|
return file1.name === file2.name && file1.size === file2.size && file1.type === file2.type;
|
|
32182
32182
|
}
|
|
32183
|
+
function seprateFilesFromPromises(filesOrPromises) {
|
|
32184
|
+
const files = [];
|
|
32185
|
+
const promises = [];
|
|
32186
|
+
for (const fileOrPromise of filesOrPromises) {
|
|
32187
|
+
if (fileOrPromise instanceof Promise) {
|
|
32188
|
+
promises.push(fileOrPromise);
|
|
32189
|
+
} else {
|
|
32190
|
+
files.push(fileOrPromise);
|
|
32191
|
+
}
|
|
32192
|
+
}
|
|
32193
|
+
return [files, promises];
|
|
32194
|
+
}
|
|
32183
32195
|
const _UploadField = class _UploadField extends BaseField {
|
|
32184
32196
|
constructor(options) {
|
|
32185
32197
|
const { extensions, maximum_files, maximum_size, ...base } = options;
|
|
@@ -32199,8 +32211,12 @@ const _UploadField = class _UploadField extends BaseField {
|
|
|
32199
32211
|
isEqual(value1, value2) {
|
|
32200
32212
|
if (value1 === void 0 && value2 === void 0) return true;
|
|
32201
32213
|
if (value1 === void 0 || value2 === void 0) return false;
|
|
32202
|
-
|
|
32203
|
-
|
|
32214
|
+
const [files1, promises1] = seprateFilesFromPromises(value1);
|
|
32215
|
+
const [files2, promises2] = seprateFilesFromPromises(value2);
|
|
32216
|
+
if (!files1.every((file1) => files2.some((file2) => areFilesEqual(file1, file2)))) return false;
|
|
32217
|
+
if (!files2.every((file2) => files1.some((file1) => areFilesEqual(file1, file2)))) return false;
|
|
32218
|
+
if (!promises1.every((promise1) => promises2.some((promise2) => promise1 === promise2))) return false;
|
|
32219
|
+
if (!promises2.every((promise2) => promises1.some((promise1) => promise1 === promise2))) return false;
|
|
32204
32220
|
return true;
|
|
32205
32221
|
}
|
|
32206
32222
|
static getFieldCreationSchema(parentPath = "") {
|
|
@@ -32220,7 +32236,6 @@ const _UploadField = class _UploadField extends BaseField {
|
|
|
32220
32236
|
},
|
|
32221
32237
|
{
|
|
32222
32238
|
field: new NumberField({
|
|
32223
|
-
// TODO: Default value
|
|
32224
32239
|
label: "What is the maximum size of each file?",
|
|
32225
32240
|
description: `Maximum file size in megabytes (between 1MB–${maxFileSizeMB}MB).`,
|
|
32226
32241
|
required: false,
|
|
@@ -32270,7 +32285,7 @@ const _UploadField = class _UploadField extends BaseField {
|
|
|
32270
32285
|
const maxFileSizeInB = maxFileSizeInMB * 1e3 * 1e3;
|
|
32271
32286
|
const maxFiles = this.maxFiles || 1;
|
|
32272
32287
|
validators.push((value) => {
|
|
32273
|
-
if (value && value.some((file) => file.size > maxFileSizeInB)) {
|
|
32288
|
+
if (value && value.some((file) => file instanceof File && file.size > maxFileSizeInB)) {
|
|
32274
32289
|
return `Files must be at most ${maxFileSizeInMB}MB.`;
|
|
32275
32290
|
}
|
|
32276
32291
|
});
|
|
@@ -32358,6 +32373,60 @@ const fieldIcons = {
|
|
|
32358
32373
|
const maxFileSizeMB = 50;
|
|
32359
32374
|
const maxFileSizeKB = maxFileSizeMB * 1e3;
|
|
32360
32375
|
const maxFileSizeB = maxFileSizeKB * 1e3;
|
|
32376
|
+
class BaseCondition extends Observable {
|
|
32377
|
+
constructor(config) {
|
|
32378
|
+
const { id, field, conditionValue, conditionModifier } = config;
|
|
32379
|
+
super();
|
|
32380
|
+
__publicField(this, "id");
|
|
32381
|
+
__publicField(this, "conditionValue");
|
|
32382
|
+
__publicField(this, "conditionModifier");
|
|
32383
|
+
__publicField(this, "field");
|
|
32384
|
+
__publicField(this, "getConditionValue", () => {
|
|
32385
|
+
return this.conditionValue;
|
|
32386
|
+
});
|
|
32387
|
+
__publicField(this, "setConditionValue", (conditionValue) => {
|
|
32388
|
+
const modifier = this.modifiers[this.conditionModifier];
|
|
32389
|
+
if (conditionValue !== void 0 && !modifier.isConditionValueValid(conditionValue)) return;
|
|
32390
|
+
this.conditionValue = conditionValue;
|
|
32391
|
+
this.notify(this);
|
|
32392
|
+
});
|
|
32393
|
+
__publicField(this, "getConditionModifier", () => {
|
|
32394
|
+
return this.conditionModifier;
|
|
32395
|
+
});
|
|
32396
|
+
__publicField(this, "setConditionModifier", (modifier) => {
|
|
32397
|
+
const foundModifier = this.modifiers[modifier];
|
|
32398
|
+
const filterValue = this.getConditionValue();
|
|
32399
|
+
if (filterValue && !foundModifier.isConditionValueValid(filterValue)) {
|
|
32400
|
+
this.conditionValue = void 0;
|
|
32401
|
+
}
|
|
32402
|
+
this.conditionModifier = modifier;
|
|
32403
|
+
this.notify(this);
|
|
32404
|
+
});
|
|
32405
|
+
__publicField(this, "getConditionModifiers", () => {
|
|
32406
|
+
return Object.entries(this.modifiers);
|
|
32407
|
+
});
|
|
32408
|
+
__publicField(this, "apply", (value) => {
|
|
32409
|
+
const modifier = this.modifiers[this.conditionModifier];
|
|
32410
|
+
const conditionValue = this.getConditionValue();
|
|
32411
|
+
if (conditionValue === void 0 || !modifier.isConditionValueValid(conditionValue)) return true;
|
|
32412
|
+
if (!modifier.isValueValid(value)) return false;
|
|
32413
|
+
return modifier.modifier.modifierFn(value, conditionValue);
|
|
32414
|
+
});
|
|
32415
|
+
this.id = id;
|
|
32416
|
+
this.field = field;
|
|
32417
|
+
this.conditionValue = conditionValue;
|
|
32418
|
+
this.conditionModifier = conditionModifier;
|
|
32419
|
+
}
|
|
32420
|
+
serialize() {
|
|
32421
|
+
return {
|
|
32422
|
+
id: this.id,
|
|
32423
|
+
type: this.field.type,
|
|
32424
|
+
fieldId: this.field.identifier,
|
|
32425
|
+
conditionValue: this.modifiers[this.conditionModifier].modifier.serialize(this.conditionValue),
|
|
32426
|
+
conditionModifier: this.conditionModifier
|
|
32427
|
+
};
|
|
32428
|
+
}
|
|
32429
|
+
}
|
|
32361
32430
|
class ConditionModifier {
|
|
32362
32431
|
constructor(config) {
|
|
32363
32432
|
__publicField(this, "id");
|
|
@@ -32664,60 +32733,6 @@ const StringArrayNotEqualsConditionModifier = ConditionModifier.create({
|
|
|
32664
32733
|
deserialize: (filterValue) => filterValue
|
|
32665
32734
|
});
|
|
32666
32735
|
const createConditionModifierConfig = (conifg) => conifg;
|
|
32667
|
-
class BaseCondition extends Observable {
|
|
32668
|
-
constructor(config) {
|
|
32669
|
-
const { id, field, conditionValue, conditionModifier } = config;
|
|
32670
|
-
super();
|
|
32671
|
-
__publicField(this, "id");
|
|
32672
|
-
__publicField(this, "conditionValue");
|
|
32673
|
-
__publicField(this, "conditionModifier");
|
|
32674
|
-
__publicField(this, "field");
|
|
32675
|
-
__publicField(this, "getConditionValue", () => {
|
|
32676
|
-
return this.conditionValue;
|
|
32677
|
-
});
|
|
32678
|
-
__publicField(this, "setConditionValue", (conditionValue) => {
|
|
32679
|
-
const modifier = this.modifiers[this.conditionModifier];
|
|
32680
|
-
if (conditionValue !== void 0 && !modifier.isConditionValueValid(conditionValue)) return;
|
|
32681
|
-
this.conditionValue = conditionValue;
|
|
32682
|
-
this.notify(this);
|
|
32683
|
-
});
|
|
32684
|
-
__publicField(this, "getConditionModifier", () => {
|
|
32685
|
-
return this.conditionModifier;
|
|
32686
|
-
});
|
|
32687
|
-
__publicField(this, "setConditionModifier", (modifier) => {
|
|
32688
|
-
const foundModifier = this.modifiers[modifier];
|
|
32689
|
-
const filterValue = this.getConditionValue();
|
|
32690
|
-
if (filterValue && !foundModifier.isConditionValueValid(filterValue)) {
|
|
32691
|
-
this.conditionValue = void 0;
|
|
32692
|
-
}
|
|
32693
|
-
this.conditionModifier = modifier;
|
|
32694
|
-
this.notify(this);
|
|
32695
|
-
});
|
|
32696
|
-
__publicField(this, "getConditionModifiers", () => {
|
|
32697
|
-
return Object.entries(this.modifiers);
|
|
32698
|
-
});
|
|
32699
|
-
__publicField(this, "apply", (value) => {
|
|
32700
|
-
const modifier = this.modifiers[this.conditionModifier];
|
|
32701
|
-
const conditionValue = this.getConditionValue();
|
|
32702
|
-
if (conditionValue === void 0 || !modifier.isConditionValueValid(conditionValue)) return true;
|
|
32703
|
-
if (!modifier.isValueValid(value)) return false;
|
|
32704
|
-
return modifier.modifier.modifierFn(value, conditionValue);
|
|
32705
|
-
});
|
|
32706
|
-
this.id = id;
|
|
32707
|
-
this.field = field;
|
|
32708
|
-
this.conditionValue = conditionValue;
|
|
32709
|
-
this.conditionModifier = conditionModifier;
|
|
32710
|
-
}
|
|
32711
|
-
serialize() {
|
|
32712
|
-
return {
|
|
32713
|
-
id: this.id,
|
|
32714
|
-
type: this.field.type,
|
|
32715
|
-
fieldId: this.field.identifier,
|
|
32716
|
-
conditionValue: this.modifiers[this.conditionModifier].modifier.serialize(this.conditionValue),
|
|
32717
|
-
conditionModifier: this.conditionModifier
|
|
32718
|
-
};
|
|
32719
|
-
}
|
|
32720
|
-
}
|
|
32721
32736
|
const formId = "form-builder";
|
|
32722
32737
|
const fieldsToChoose = [
|
|
32723
32738
|
["string", "text"],
|
package/dist/forms.umd.cjs
CHANGED
|
@@ -32182,6 +32182,18 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
32182
32182
|
function areFilesEqual(file1, file2) {
|
|
32183
32183
|
return file1.name === file2.name && file1.size === file2.size && file1.type === file2.type;
|
|
32184
32184
|
}
|
|
32185
|
+
function seprateFilesFromPromises(filesOrPromises) {
|
|
32186
|
+
const files = [];
|
|
32187
|
+
const promises = [];
|
|
32188
|
+
for (const fileOrPromise of filesOrPromises) {
|
|
32189
|
+
if (fileOrPromise instanceof Promise) {
|
|
32190
|
+
promises.push(fileOrPromise);
|
|
32191
|
+
} else {
|
|
32192
|
+
files.push(fileOrPromise);
|
|
32193
|
+
}
|
|
32194
|
+
}
|
|
32195
|
+
return [files, promises];
|
|
32196
|
+
}
|
|
32185
32197
|
const _UploadField = class _UploadField extends BaseField {
|
|
32186
32198
|
constructor(options2) {
|
|
32187
32199
|
const { extensions, maximum_files, maximum_size, ...base } = options2;
|
|
@@ -32201,8 +32213,12 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
32201
32213
|
isEqual(value1, value2) {
|
|
32202
32214
|
if (value1 === void 0 && value2 === void 0) return true;
|
|
32203
32215
|
if (value1 === void 0 || value2 === void 0) return false;
|
|
32204
|
-
|
|
32205
|
-
|
|
32216
|
+
const [files1, promises1] = seprateFilesFromPromises(value1);
|
|
32217
|
+
const [files2, promises2] = seprateFilesFromPromises(value2);
|
|
32218
|
+
if (!files1.every((file1) => files2.some((file2) => areFilesEqual(file1, file2)))) return false;
|
|
32219
|
+
if (!files2.every((file2) => files1.some((file1) => areFilesEqual(file1, file2)))) return false;
|
|
32220
|
+
if (!promises1.every((promise1) => promises2.some((promise2) => promise1 === promise2))) return false;
|
|
32221
|
+
if (!promises2.every((promise2) => promises1.some((promise1) => promise1 === promise2))) return false;
|
|
32206
32222
|
return true;
|
|
32207
32223
|
}
|
|
32208
32224
|
static getFieldCreationSchema(parentPath = "") {
|
|
@@ -32222,7 +32238,6 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
32222
32238
|
},
|
|
32223
32239
|
{
|
|
32224
32240
|
field: new NumberField({
|
|
32225
|
-
// TODO: Default value
|
|
32226
32241
|
label: "What is the maximum size of each file?",
|
|
32227
32242
|
description: `Maximum file size in megabytes (between 1MB–${maxFileSizeMB}MB).`,
|
|
32228
32243
|
required: false,
|
|
@@ -32272,7 +32287,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
32272
32287
|
const maxFileSizeInB = maxFileSizeInMB * 1e3 * 1e3;
|
|
32273
32288
|
const maxFiles = this.maxFiles || 1;
|
|
32274
32289
|
validators.push((value) => {
|
|
32275
|
-
if (value && value.some((file) => file.size > maxFileSizeInB)) {
|
|
32290
|
+
if (value && value.some((file) => file instanceof File && file.size > maxFileSizeInB)) {
|
|
32276
32291
|
return `Files must be at most ${maxFileSizeInMB}MB.`;
|
|
32277
32292
|
}
|
|
32278
32293
|
});
|
|
@@ -32360,6 +32375,60 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
32360
32375
|
const maxFileSizeMB = 50;
|
|
32361
32376
|
const maxFileSizeKB = maxFileSizeMB * 1e3;
|
|
32362
32377
|
const maxFileSizeB = maxFileSizeKB * 1e3;
|
|
32378
|
+
class BaseCondition extends Observable {
|
|
32379
|
+
constructor(config) {
|
|
32380
|
+
const { id, field, conditionValue, conditionModifier } = config;
|
|
32381
|
+
super();
|
|
32382
|
+
__publicField(this, "id");
|
|
32383
|
+
__publicField(this, "conditionValue");
|
|
32384
|
+
__publicField(this, "conditionModifier");
|
|
32385
|
+
__publicField(this, "field");
|
|
32386
|
+
__publicField(this, "getConditionValue", () => {
|
|
32387
|
+
return this.conditionValue;
|
|
32388
|
+
});
|
|
32389
|
+
__publicField(this, "setConditionValue", (conditionValue) => {
|
|
32390
|
+
const modifier = this.modifiers[this.conditionModifier];
|
|
32391
|
+
if (conditionValue !== void 0 && !modifier.isConditionValueValid(conditionValue)) return;
|
|
32392
|
+
this.conditionValue = conditionValue;
|
|
32393
|
+
this.notify(this);
|
|
32394
|
+
});
|
|
32395
|
+
__publicField(this, "getConditionModifier", () => {
|
|
32396
|
+
return this.conditionModifier;
|
|
32397
|
+
});
|
|
32398
|
+
__publicField(this, "setConditionModifier", (modifier) => {
|
|
32399
|
+
const foundModifier = this.modifiers[modifier];
|
|
32400
|
+
const filterValue = this.getConditionValue();
|
|
32401
|
+
if (filterValue && !foundModifier.isConditionValueValid(filterValue)) {
|
|
32402
|
+
this.conditionValue = void 0;
|
|
32403
|
+
}
|
|
32404
|
+
this.conditionModifier = modifier;
|
|
32405
|
+
this.notify(this);
|
|
32406
|
+
});
|
|
32407
|
+
__publicField(this, "getConditionModifiers", () => {
|
|
32408
|
+
return Object.entries(this.modifiers);
|
|
32409
|
+
});
|
|
32410
|
+
__publicField(this, "apply", (value) => {
|
|
32411
|
+
const modifier = this.modifiers[this.conditionModifier];
|
|
32412
|
+
const conditionValue = this.getConditionValue();
|
|
32413
|
+
if (conditionValue === void 0 || !modifier.isConditionValueValid(conditionValue)) return true;
|
|
32414
|
+
if (!modifier.isValueValid(value)) return false;
|
|
32415
|
+
return modifier.modifier.modifierFn(value, conditionValue);
|
|
32416
|
+
});
|
|
32417
|
+
this.id = id;
|
|
32418
|
+
this.field = field;
|
|
32419
|
+
this.conditionValue = conditionValue;
|
|
32420
|
+
this.conditionModifier = conditionModifier;
|
|
32421
|
+
}
|
|
32422
|
+
serialize() {
|
|
32423
|
+
return {
|
|
32424
|
+
id: this.id,
|
|
32425
|
+
type: this.field.type,
|
|
32426
|
+
fieldId: this.field.identifier,
|
|
32427
|
+
conditionValue: this.modifiers[this.conditionModifier].modifier.serialize(this.conditionValue),
|
|
32428
|
+
conditionModifier: this.conditionModifier
|
|
32429
|
+
};
|
|
32430
|
+
}
|
|
32431
|
+
}
|
|
32363
32432
|
class ConditionModifier {
|
|
32364
32433
|
constructor(config) {
|
|
32365
32434
|
__publicField(this, "id");
|
|
@@ -32666,60 +32735,6 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
32666
32735
|
deserialize: (filterValue) => filterValue
|
|
32667
32736
|
});
|
|
32668
32737
|
const createConditionModifierConfig = (conifg) => conifg;
|
|
32669
|
-
class BaseCondition extends Observable {
|
|
32670
|
-
constructor(config) {
|
|
32671
|
-
const { id, field, conditionValue, conditionModifier } = config;
|
|
32672
|
-
super();
|
|
32673
|
-
__publicField(this, "id");
|
|
32674
|
-
__publicField(this, "conditionValue");
|
|
32675
|
-
__publicField(this, "conditionModifier");
|
|
32676
|
-
__publicField(this, "field");
|
|
32677
|
-
__publicField(this, "getConditionValue", () => {
|
|
32678
|
-
return this.conditionValue;
|
|
32679
|
-
});
|
|
32680
|
-
__publicField(this, "setConditionValue", (conditionValue) => {
|
|
32681
|
-
const modifier = this.modifiers[this.conditionModifier];
|
|
32682
|
-
if (conditionValue !== void 0 && !modifier.isConditionValueValid(conditionValue)) return;
|
|
32683
|
-
this.conditionValue = conditionValue;
|
|
32684
|
-
this.notify(this);
|
|
32685
|
-
});
|
|
32686
|
-
__publicField(this, "getConditionModifier", () => {
|
|
32687
|
-
return this.conditionModifier;
|
|
32688
|
-
});
|
|
32689
|
-
__publicField(this, "setConditionModifier", (modifier) => {
|
|
32690
|
-
const foundModifier = this.modifiers[modifier];
|
|
32691
|
-
const filterValue = this.getConditionValue();
|
|
32692
|
-
if (filterValue && !foundModifier.isConditionValueValid(filterValue)) {
|
|
32693
|
-
this.conditionValue = void 0;
|
|
32694
|
-
}
|
|
32695
|
-
this.conditionModifier = modifier;
|
|
32696
|
-
this.notify(this);
|
|
32697
|
-
});
|
|
32698
|
-
__publicField(this, "getConditionModifiers", () => {
|
|
32699
|
-
return Object.entries(this.modifiers);
|
|
32700
|
-
});
|
|
32701
|
-
__publicField(this, "apply", (value) => {
|
|
32702
|
-
const modifier = this.modifiers[this.conditionModifier];
|
|
32703
|
-
const conditionValue = this.getConditionValue();
|
|
32704
|
-
if (conditionValue === void 0 || !modifier.isConditionValueValid(conditionValue)) return true;
|
|
32705
|
-
if (!modifier.isValueValid(value)) return false;
|
|
32706
|
-
return modifier.modifier.modifierFn(value, conditionValue);
|
|
32707
|
-
});
|
|
32708
|
-
this.id = id;
|
|
32709
|
-
this.field = field;
|
|
32710
|
-
this.conditionValue = conditionValue;
|
|
32711
|
-
this.conditionModifier = conditionModifier;
|
|
32712
|
-
}
|
|
32713
|
-
serialize() {
|
|
32714
|
-
return {
|
|
32715
|
-
id: this.id,
|
|
32716
|
-
type: this.field.type,
|
|
32717
|
-
fieldId: this.field.identifier,
|
|
32718
|
-
conditionValue: this.modifiers[this.conditionModifier].modifier.serialize(this.conditionValue),
|
|
32719
|
-
conditionModifier: this.conditionModifier
|
|
32720
|
-
};
|
|
32721
|
-
}
|
|
32722
|
-
}
|
|
32723
32738
|
const formId = "form-builder";
|
|
32724
32739
|
const fieldsToChoose = [
|
|
32725
32740
|
["string", "text"],
|