@useinsider/guido 3.28.1-beta.70df1f2 → 3.28.1-beta.7539890
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/README.md +3 -0
- package/dist/@types/display-condition.js +45 -21
- package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.js +25 -19
- package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue2.js +72 -53
- package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.js +1 -1
- package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue2.js +60 -42
- package/dist/components/organisms/display-conditions/LogicBuilderConnector.vue.js +18 -0
- package/dist/components/organisms/display-conditions/LogicBuilderConnector.vue2.js +25 -0
- package/dist/components/organisms/display-conditions/LogicBuilderField.vue.js +28 -0
- package/dist/components/organisms/display-conditions/LogicBuilderField.vue2.js +28 -0
- package/dist/components/organisms/display-conditions/LogicBuilderGroup.vue.js +30 -0
- package/dist/components/organisms/display-conditions/LogicBuilderGroup.vue2.js +32 -0
- package/dist/components/organisms/display-conditions/LogicBuilderRow.vue.js +28 -0
- package/dist/components/organisms/display-conditions/LogicBuilderRow.vue2.js +60 -0
- package/dist/composables/useDisplayConditionAttributes.js +20 -0
- package/dist/composables/useDisplayConditions.js +83 -68
- package/dist/composables/useScrollToInvalid.js +15 -0
- package/dist/enums/display-condition.js +15 -6
- package/dist/enums/html-validator.js +1 -1
- package/dist/extensions/DisplayConditions/constants.js +19 -10
- package/dist/extensions/DisplayConditions/control.js +84 -64
- package/dist/extensions/DisplayConditions/display-conditions.css.js +58 -6
- package/dist/extensions/DisplayConditions/extension.js +18 -14
- package/dist/guido.css +1 -1
- package/dist/node_modules/valibot/dist/index.js +118 -102
- package/dist/package.json.js +1 -1
- package/dist/services/displayConditionApi.js +18 -19
- package/dist/src/@types/display-condition.d.ts +67 -0
- package/dist/src/components/organisms/display-conditions/LogicBuilderConnector.vue.d.ts +19 -0
- package/dist/src/components/organisms/display-conditions/LogicBuilderField.vue.d.ts +22 -0
- package/dist/src/components/organisms/display-conditions/LogicBuilderGroup.vue.d.ts +24 -0
- package/dist/src/components/organisms/display-conditions/LogicBuilderRow.vue.d.ts +25 -0
- package/dist/src/composables/useDisplayConditionAttributes.d.ts +4 -0
- package/dist/src/composables/useDisplayConditions.d.ts +1 -1
- package/dist/src/composables/useScrollToInvalid.d.ts +6 -0
- package/dist/src/enums/display-condition.d.ts +22 -0
- package/dist/src/extensions/DisplayConditions/constants.d.ts +2 -0
- package/dist/src/extensions/DisplayConditions/control.d.ts +1 -0
- package/dist/src/utils/displayConditionAttributes.d.ts +7 -0
- package/dist/src/utils/displayConditionBuilder.d.ts +29 -0
- package/dist/src/utils/displayConditionRules.d.ts +12 -0
- package/dist/src/utils/displayConditionSummary.d.ts +11 -0
- package/dist/src/utils/genericUtil.d.ts +5 -3
- package/dist/utils/displayConditionAttributes.js +22 -0
- package/dist/utils/displayConditionBuilder.js +50 -0
- package/dist/utils/displayConditionRules.js +91 -0
- package/dist/utils/displayConditionSummary.js +28 -0
- package/dist/utils/genericUtil.js +41 -40
- package/package.json +2 -2
|
@@ -1,6 +1,64 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
2
|
export declare const DisplayConditionSyntaxSchema: v.PicklistSchema<["liquid", "pongo"], undefined>;
|
|
3
3
|
export declare const DisplayConditionMethodSchema: v.PicklistSchema<["codeOnly", "logicBuilder"], undefined>;
|
|
4
|
+
export declare const AttributeTypeSchema: v.PicklistSchema<["string", "number", "boolean", "date", "strings"], undefined>;
|
|
5
|
+
export declare const LogicOperatorSchema: v.PicklistSchema<["and", "or"], undefined>;
|
|
6
|
+
export declare const RuleOperatorSchema: v.PicklistSchema<["is", "isNot", "contains", "notContains", "isOneOf", "isNotOneOf"], undefined>;
|
|
7
|
+
export declare const DisplayConditionAttributeSchema: v.ObjectSchema<{
|
|
8
|
+
readonly key: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>;
|
|
9
|
+
readonly label: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
10
|
+
readonly type: v.OptionalSchema<v.PicklistSchema<["string", "number", "boolean", "date", "strings"], undefined>, "string">;
|
|
11
|
+
readonly options: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
12
|
+
readonly label: v.StringSchema<undefined>;
|
|
13
|
+
readonly value: v.StringSchema<undefined>;
|
|
14
|
+
}, undefined>, undefined>, readonly []>;
|
|
15
|
+
}, undefined>;
|
|
16
|
+
export declare const RuleSchema: v.ObjectSchema<{
|
|
17
|
+
readonly attribute: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>;
|
|
18
|
+
readonly type: v.PicklistSchema<["string", "number", "boolean", "date", "strings"], undefined>;
|
|
19
|
+
readonly operator: v.PicklistSchema<["is", "isNot", "contains", "notContains", "isOneOf", "isNotOneOf"], undefined>;
|
|
20
|
+
readonly values: v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
|
|
21
|
+
}, undefined>;
|
|
22
|
+
export declare const RuleGroupSchema: v.ObjectSchema<{
|
|
23
|
+
readonly condition: v.PicklistSchema<["and", "or"], undefined>;
|
|
24
|
+
readonly rules: v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
|
|
25
|
+
readonly attribute: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>;
|
|
26
|
+
readonly type: v.PicklistSchema<["string", "number", "boolean", "date", "strings"], undefined>;
|
|
27
|
+
readonly operator: v.PicklistSchema<["is", "isNot", "contains", "notContains", "isOneOf", "isNotOneOf"], undefined>;
|
|
28
|
+
readonly values: v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
|
|
29
|
+
}, undefined>, undefined>, v.MinLengthAction<{
|
|
30
|
+
attribute: string;
|
|
31
|
+
type: "string" | "number" | "boolean" | "date" | "strings";
|
|
32
|
+
operator: "contains" | "is" | "isNot" | "notContains" | "isOneOf" | "isNotOneOf";
|
|
33
|
+
values: string[];
|
|
34
|
+
}[], 1, undefined>]>;
|
|
35
|
+
}, undefined>;
|
|
36
|
+
export declare const RuleTreeSchema: v.ObjectSchema<{
|
|
37
|
+
readonly version: v.LiteralSchema<1, undefined>;
|
|
38
|
+
readonly condition: v.PicklistSchema<["and", "or"], undefined>;
|
|
39
|
+
readonly groups: v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
|
|
40
|
+
readonly condition: v.PicklistSchema<["and", "or"], undefined>;
|
|
41
|
+
readonly rules: v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
|
|
42
|
+
readonly attribute: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>;
|
|
43
|
+
readonly type: v.PicklistSchema<["string", "number", "boolean", "date", "strings"], undefined>;
|
|
44
|
+
readonly operator: v.PicklistSchema<["is", "isNot", "contains", "notContains", "isOneOf", "isNotOneOf"], undefined>;
|
|
45
|
+
readonly values: v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
|
|
46
|
+
}, undefined>, undefined>, v.MinLengthAction<{
|
|
47
|
+
attribute: string;
|
|
48
|
+
type: "string" | "number" | "boolean" | "date" | "strings";
|
|
49
|
+
operator: "contains" | "is" | "isNot" | "notContains" | "isOneOf" | "isNotOneOf";
|
|
50
|
+
values: string[];
|
|
51
|
+
}[], 1, undefined>]>;
|
|
52
|
+
}, undefined>, undefined>, v.MinLengthAction<{
|
|
53
|
+
condition: "and" | "or";
|
|
54
|
+
rules: {
|
|
55
|
+
attribute: string;
|
|
56
|
+
type: "string" | "number" | "boolean" | "date" | "strings";
|
|
57
|
+
operator: "contains" | "is" | "isNot" | "notContains" | "isOneOf" | "isNotOneOf";
|
|
58
|
+
values: string[];
|
|
59
|
+
}[];
|
|
60
|
+
}[], 1, undefined>]>;
|
|
61
|
+
}, undefined>;
|
|
4
62
|
export declare const SavedDisplayConditionSchema: v.ObjectSchema<{
|
|
5
63
|
readonly id: v.NumberSchema<undefined>;
|
|
6
64
|
readonly name: v.StringSchema<undefined>;
|
|
@@ -33,11 +91,20 @@ export type DisplayConditionSyntax = v.InferOutput<typeof DisplayConditionSyntax
|
|
|
33
91
|
export type DisplayConditionMethod = v.InferOutput<typeof DisplayConditionMethodSchema>;
|
|
34
92
|
export type SavedDisplayCondition = v.InferOutput<typeof SavedDisplayConditionSchema>;
|
|
35
93
|
export type DisplayConditionListResponse = v.InferOutput<typeof DisplayConditionListResponseSchema>;
|
|
94
|
+
export type AttributeType = v.InferOutput<typeof AttributeTypeSchema>;
|
|
95
|
+
export type LogicOperator = v.InferOutput<typeof LogicOperatorSchema>;
|
|
96
|
+
export type RuleOperator = v.InferOutput<typeof RuleOperatorSchema>;
|
|
97
|
+
export type DisplayConditionAttribute = v.InferOutput<typeof DisplayConditionAttributeSchema>;
|
|
98
|
+
export type Rule = v.InferOutput<typeof RuleSchema>;
|
|
99
|
+
export type RuleGroup = v.InferOutput<typeof RuleGroupSchema>;
|
|
100
|
+
export type RuleTree = v.InferOutput<typeof RuleTreeSchema>;
|
|
36
101
|
export interface DisplayConditionDraft {
|
|
37
102
|
name: string;
|
|
38
103
|
description: string;
|
|
104
|
+
method: DisplayConditionMethod;
|
|
39
105
|
codeBefore: string;
|
|
40
106
|
codeAfter: string;
|
|
107
|
+
rules: RuleTree | null;
|
|
41
108
|
}
|
|
42
109
|
/** Mirrors Stripo's `DisplayCondition`; kept local so Vue code does not import the Stripo package. */
|
|
43
110
|
export interface AppliedDisplayCondition {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { LogicOperator } from '@@/Types/display-condition';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
id: string;
|
|
4
|
+
value: LogicOperator;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
};
|
|
7
|
+
declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<__VLS_Props>, {}, {}, {}, {}, import("vue/types/v3-component-options.js").ComponentOptionsMixin, import("vue/types/v3-component-options.js").ComponentOptionsMixin, {
|
|
8
|
+
input: (value: "and" | "or") => void;
|
|
9
|
+
}, string, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<__VLS_Props>>>, {}>;
|
|
10
|
+
export default _default;
|
|
11
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
12
|
+
type __VLS_TypePropsToOption<T> = {
|
|
13
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
14
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
15
|
+
} : {
|
|
16
|
+
type: import('vue').PropType<T[K]>;
|
|
17
|
+
required: true;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { DisplayConditionAttribute } from '@@/Types/display-condition';
|
|
2
|
+
import type { BuilderState } from '@@/Utils/displayConditionBuilder';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
value: BuilderState;
|
|
5
|
+
showErrors: boolean;
|
|
6
|
+
customAttributes: DisplayConditionAttribute[];
|
|
7
|
+
defaultAttributes: DisplayConditionAttribute[];
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
};
|
|
10
|
+
declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<__VLS_Props>, {}, {}, {}, {}, import("vue/types/v3-component-options.js").ComponentOptionsMixin, import("vue/types/v3-component-options.js").ComponentOptionsMixin, {
|
|
11
|
+
input: (value: BuilderState) => void;
|
|
12
|
+
}, string, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<__VLS_Props>>>, {}>;
|
|
13
|
+
export default _default;
|
|
14
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
15
|
+
type __VLS_TypePropsToOption<T> = {
|
|
16
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
17
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
18
|
+
} : {
|
|
19
|
+
type: import('vue').PropType<T[K]>;
|
|
20
|
+
required: true;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { DisplayConditionAttribute } from '@@/Types/display-condition';
|
|
2
|
+
import type { BuilderGroup } from '@@/Utils/displayConditionBuilder';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
group: BuilderGroup;
|
|
5
|
+
showErrors: boolean;
|
|
6
|
+
customAttributes: DisplayConditionAttribute[];
|
|
7
|
+
defaultAttributes: DisplayConditionAttribute[];
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
soleGroup?: boolean;
|
|
10
|
+
};
|
|
11
|
+
declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<__VLS_Props>, {}, {}, {}, {}, import("vue/types/v3-component-options.js").ComponentOptionsMixin, import("vue/types/v3-component-options.js").ComponentOptionsMixin, {
|
|
12
|
+
update: (group: BuilderGroup) => void;
|
|
13
|
+
remove: () => void;
|
|
14
|
+
}, string, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<__VLS_Props>>>, {}>;
|
|
15
|
+
export default _default;
|
|
16
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
17
|
+
type __VLS_TypePropsToOption<T> = {
|
|
18
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
19
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
20
|
+
} : {
|
|
21
|
+
type: import('vue').PropType<T[K]>;
|
|
22
|
+
required: true;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DisplayConditionAttribute } from '@@/Types/display-condition';
|
|
2
|
+
import type { BuilderRow, RowErrors } from '@@/Utils/displayConditionBuilder';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
row: BuilderRow;
|
|
5
|
+
errors: RowErrors;
|
|
6
|
+
customAttributes: DisplayConditionAttribute[];
|
|
7
|
+
defaultAttributes: DisplayConditionAttribute[];
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
removeDisabled?: boolean;
|
|
10
|
+
};
|
|
11
|
+
declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<__VLS_Props>, {}, {}, {}, {}, import("vue/types/v3-component-options.js").ComponentOptionsMixin, import("vue/types/v3-component-options.js").ComponentOptionsMixin, {
|
|
12
|
+
update: (row: BuilderRow) => void;
|
|
13
|
+
duplicate: () => void;
|
|
14
|
+
remove: () => void;
|
|
15
|
+
}, string, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<__VLS_Props>>>, {}>;
|
|
16
|
+
export default _default;
|
|
17
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
18
|
+
type __VLS_TypePropsToOption<T> = {
|
|
19
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
20
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
21
|
+
} : {
|
|
22
|
+
type: import('vue').PropType<T[K]>;
|
|
23
|
+
required: true;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DisplayConditionAttributes } from '@@/Utils/displayConditionAttributes';
|
|
2
|
+
import type { ComputedRef } from 'vue';
|
|
3
|
+
export declare const getDisplayConditionAttributes: (translate?: (key: string) => string) => DisplayConditionAttributes;
|
|
4
|
+
export declare const useDisplayConditionAttributes: () => ComputedRef<DisplayConditionAttributes>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DisplayConditionDraft, DisplayConditionOpenDetail, SavedDisplayCondition } from '@@/Types/display-condition';
|
|
2
|
-
export type DraftField =
|
|
2
|
+
export type DraftField = 'name' | 'description' | 'codeBefore' | 'codeAfter';
|
|
3
3
|
export type DraftErrors = Partial<Record<DraftField, string>>;
|
|
4
4
|
export type CreateIntent = 'inline' | 'save';
|
|
5
5
|
export declare const DISPLAY_CONDITIONS_TRANS_KEY = "email-editor.display-conditions";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
export declare const INVALID_FIELD_ATTR = "data-guido-invalid";
|
|
3
|
+
export declare const invalidFieldAttrs: (invalid: unknown) => Record<string, string>;
|
|
4
|
+
export declare const useScrollToInvalid: (container: Ref<HTMLElement | null | undefined>) => {
|
|
5
|
+
scrollToFirstInvalid: () => Promise<boolean>;
|
|
6
|
+
};
|
|
@@ -13,3 +13,25 @@ export declare const DISPLAY_CONDITION_LIMITS: {
|
|
|
13
13
|
readonly DESCRIPTION_MAX: 200;
|
|
14
14
|
readonly CODE_MAX: 65535;
|
|
15
15
|
};
|
|
16
|
+
export declare const DISPLAY_CONDITION_DEFAULT_ATTRIBUTES: readonly [{
|
|
17
|
+
readonly key: "email";
|
|
18
|
+
readonly labelKey: "condition.email";
|
|
19
|
+
}, {
|
|
20
|
+
readonly key: "name";
|
|
21
|
+
readonly labelKey: "condition.name";
|
|
22
|
+
}, {
|
|
23
|
+
readonly key: "surname";
|
|
24
|
+
readonly labelKey: "condition.surname";
|
|
25
|
+
}, {
|
|
26
|
+
readonly key: "phone_number";
|
|
27
|
+
readonly labelKey: "condition.phone-number";
|
|
28
|
+
}, {
|
|
29
|
+
readonly key: "uuid";
|
|
30
|
+
readonly labelKey: "condition.uuid";
|
|
31
|
+
}, {
|
|
32
|
+
readonly key: "language";
|
|
33
|
+
readonly labelKey: "condition.language";
|
|
34
|
+
}, {
|
|
35
|
+
readonly key: "country";
|
|
36
|
+
readonly labelKey: "condition.country";
|
|
37
|
+
}];
|
|
@@ -21,3 +21,5 @@ export declare const CONDITION_BUTTONS: {
|
|
|
21
21
|
export declare const BUILT_IN_CONDITION_CONTROLS: string[];
|
|
22
22
|
export declare const EMPTY_DESCRIPTION: string;
|
|
23
23
|
export declare const APPLIED_DESCRIPTION: string;
|
|
24
|
+
export declare const RULES_INTRO = "Show this block if recipient meet the condition below";
|
|
25
|
+
export declare const OPERATOR_LABELS: Record<string, string>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DisplayConditionAttribute } from '@@/Types/display-condition';
|
|
2
|
+
import type { DynamicContentList } from '@@/Types/generic';
|
|
3
|
+
export interface DisplayConditionAttributes {
|
|
4
|
+
custom: DisplayConditionAttribute[];
|
|
5
|
+
default: DisplayConditionAttribute[];
|
|
6
|
+
}
|
|
7
|
+
export declare const resolveDisplayConditionAttributes: (list: DynamicContentList | undefined | null, partnerName: string, translate: (key: string) => string) => DisplayConditionAttributes;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { AttributeType, DisplayConditionAttribute, LogicOperator, RuleOperator, RuleTree } from '@@/Types/display-condition';
|
|
2
|
+
export interface BuilderRow {
|
|
3
|
+
id: number;
|
|
4
|
+
attribute: string;
|
|
5
|
+
type: AttributeType;
|
|
6
|
+
operator: RuleOperator | '';
|
|
7
|
+
values: string[];
|
|
8
|
+
}
|
|
9
|
+
export interface BuilderGroup {
|
|
10
|
+
id: number;
|
|
11
|
+
condition: LogicOperator;
|
|
12
|
+
rows: BuilderRow[];
|
|
13
|
+
}
|
|
14
|
+
export interface BuilderState {
|
|
15
|
+
condition: LogicOperator;
|
|
16
|
+
groups: BuilderGroup[];
|
|
17
|
+
}
|
|
18
|
+
export type RowField = 'attribute' | 'operator' | 'value';
|
|
19
|
+
export type RowErrors = Partial<Record<RowField, true>>;
|
|
20
|
+
export declare const emptyRow: () => BuilderRow;
|
|
21
|
+
export declare const copyRow: (row: BuilderRow) => BuilderRow;
|
|
22
|
+
export declare const emptyGroup: () => BuilderGroup;
|
|
23
|
+
export declare const emptyBuilder: () => BuilderState;
|
|
24
|
+
export declare const builderFromTree: (tree: RuleTree) => BuilderState;
|
|
25
|
+
export declare const isMultiValue: (operator: RuleOperator | "") => boolean;
|
|
26
|
+
export declare const withAttribute: (row: BuilderRow, attribute: DisplayConditionAttribute) => BuilderRow;
|
|
27
|
+
export declare const withOperator: (row: BuilderRow, operator: RuleOperator) => BuilderRow;
|
|
28
|
+
export declare const findRowErrors: (row: BuilderRow) => RowErrors;
|
|
29
|
+
export declare const treeFromBuilder: (state: BuilderState) => RuleTree | null;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AttributeType, DisplayConditionSyntax, RuleOperator, RuleTree } from '@@/Types/display-condition';
|
|
2
|
+
export declare const OPERATORS_BY_TYPE: Record<AttributeType, RuleOperator[]>;
|
|
3
|
+
export declare const MULTI_VALUE_OPERATORS: readonly RuleOperator[];
|
|
4
|
+
export declare const LOGIC_BUILDER_AFTER_SCRIPT = "{% endif %}";
|
|
5
|
+
export declare const operatorsFor: (type: AttributeType) => RuleOperator[];
|
|
6
|
+
export declare const isValidRuleValue: (type: AttributeType, value: string) => boolean;
|
|
7
|
+
export declare const parseRuleTree: (raw: unknown) => RuleTree | null;
|
|
8
|
+
export declare const compileRuleTree: (tree: RuleTree, syntax: DisplayConditionSyntax, scope: string) => {
|
|
9
|
+
beforeScript: string;
|
|
10
|
+
afterScript: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const readLogicBuilderRules: (extraData: string | undefined) => RuleTree | null;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DisplayConditionAttribute, LogicOperator, RuleOperator, RuleTree } from '@@/Types/display-condition';
|
|
2
|
+
export declare const OPERATOR_TRANS_SUFFIX: Record<RuleOperator, string>;
|
|
3
|
+
export interface RuleSummaryGroup {
|
|
4
|
+
condition: LogicOperator;
|
|
5
|
+
lines: string[];
|
|
6
|
+
}
|
|
7
|
+
export interface RuleSummary {
|
|
8
|
+
condition: LogicOperator;
|
|
9
|
+
groups: RuleSummaryGroup[];
|
|
10
|
+
}
|
|
11
|
+
export declare const summarizeRuleTree: (tree: RuleTree, attributes: DisplayConditionAttribute[], operatorLabel: (operator: RuleOperator) => string) => RuleSummary;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import type { DynamicContent, DynamicContentCandidate, DynamicContentList, MergeTag } from '@@/Types/generic';
|
|
1
|
+
import type { DynamicContent, DynamicContentCandidate, DynamicContentList, DynamicContentNode, MergeTag } from '@@/Types/generic';
|
|
2
2
|
export declare const mergeTagToDynamicContent: (mergeTag: MergeTag) => DynamicContent;
|
|
3
3
|
export declare const dynamicContentToMergeTags: (dynamicContentList: DynamicContent[], liquidSyntax?: boolean) => MergeTag[];
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Collects one partner's deduped leaf attributes with both labels and their category path;
|
|
6
|
+
* category nodes (`children`/`select_items`) are walked, never collected.
|
|
7
7
|
*/
|
|
8
|
+
export declare const collectDynamicContentLeaves: (partnerNodes: DynamicContentNode[] | undefined) => DynamicContentCandidate[];
|
|
9
|
+
/** Flattens the ACTIVE (first) partner's tree; merging all partners would risk cross-partner label collisions. */
|
|
8
10
|
export declare const flattenDynamicContentCandidates: (list: DynamicContentList | undefined | null) => DynamicContentCandidate[];
|
|
9
11
|
export declare const flattenDynamicContentList: (list: DynamicContentList | undefined | null) => DynamicContent[];
|
|
10
12
|
/**
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DISPLAY_CONDITION_DEFAULT_ATTRIBUTES as n } from "../enums/display-condition.js";
|
|
2
|
+
import { DisplayConditionAttributeSchema as c } from "../@types/display-condition.js";
|
|
3
|
+
import { collectDynamicContentLeaves as m } from "./genericUtil.js";
|
|
4
|
+
import { safeParse as p } from "../node_modules/valibot/dist/index.js";
|
|
5
|
+
const l = new Set(n.map(({ key: o }) => o)), d = (o, s, i) => {
|
|
6
|
+
const a = s && o ? o[s] : void 0;
|
|
7
|
+
return {
|
|
8
|
+
custom: m(a).filter(({ value: t }) => !l.has(t)).flatMap(({ value: t, tagText: e }) => {
|
|
9
|
+
const r = p(c, { key: t, label: e });
|
|
10
|
+
return r.success ? [r.output] : [];
|
|
11
|
+
}),
|
|
12
|
+
default: n.map(({ key: t, labelKey: e }) => ({
|
|
13
|
+
key: t,
|
|
14
|
+
label: i(e),
|
|
15
|
+
type: "string",
|
|
16
|
+
options: []
|
|
17
|
+
}))
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
d as resolveDisplayConditionAttributes
|
|
22
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { isValidRuleValue as s, MULTI_VALUE_OPERATORS as u, operatorsFor as l } from "./displayConditionRules.js";
|
|
2
|
+
let a = 0;
|
|
3
|
+
const r = () => ++a, p = () => ({
|
|
4
|
+
id: r(),
|
|
5
|
+
attribute: "",
|
|
6
|
+
type: "string",
|
|
7
|
+
operator: "",
|
|
8
|
+
values: []
|
|
9
|
+
}), m = (t) => ({ ...t, id: r(), values: [...t.values] }), c = () => ({ id: r(), condition: "and", rows: [p()] }), g = () => ({ condition: "and", groups: [c()] }), b = (t) => ({
|
|
10
|
+
condition: t.condition,
|
|
11
|
+
groups: t.groups.map((e) => ({
|
|
12
|
+
id: r(),
|
|
13
|
+
condition: e.condition,
|
|
14
|
+
rows: e.rules.map((o) => ({ id: r(), ...o, values: [...o.values] }))
|
|
15
|
+
}))
|
|
16
|
+
}), d = (t) => t !== "" && u.includes(t), f = (t, e) => {
|
|
17
|
+
const o = t.operator && l(e.type).includes(t.operator) ? t.operator : "";
|
|
18
|
+
return { ...t, attribute: e.key, type: e.type, operator: o, values: [] };
|
|
19
|
+
}, h = (t, e) => ({
|
|
20
|
+
...t,
|
|
21
|
+
operator: e,
|
|
22
|
+
values: d(e) ? t.values : t.values.slice(0, 1)
|
|
23
|
+
}), v = (t) => {
|
|
24
|
+
const e = {}, o = t.values.filter((i) => i.trim());
|
|
25
|
+
return t.attribute || (e.attribute = !0), t.operator || (e.operator = !0), (!o.length || !o.every((i) => s(t.type, i))) && (e.value = !0), e;
|
|
26
|
+
}, R = (t) => t.groups.length > 0 && t.groups.every((o) => o.rows.length > 0 && o.rows.every((i) => !Object.keys(v(i)).length)) ? {
|
|
27
|
+
version: 1,
|
|
28
|
+
condition: t.condition,
|
|
29
|
+
groups: t.groups.map((o) => ({
|
|
30
|
+
condition: o.condition,
|
|
31
|
+
rules: o.rows.map((i) => ({
|
|
32
|
+
attribute: i.attribute,
|
|
33
|
+
type: i.type,
|
|
34
|
+
operator: i.operator,
|
|
35
|
+
values: i.values.filter((n) => n.trim()).map((n) => i.type === "number" ? n.trim() : n)
|
|
36
|
+
}))
|
|
37
|
+
}))
|
|
38
|
+
} : null;
|
|
39
|
+
export {
|
|
40
|
+
b as builderFromTree,
|
|
41
|
+
m as copyRow,
|
|
42
|
+
g as emptyBuilder,
|
|
43
|
+
c as emptyGroup,
|
|
44
|
+
p as emptyRow,
|
|
45
|
+
v as findRowErrors,
|
|
46
|
+
d as isMultiValue,
|
|
47
|
+
R as treeFromBuilder,
|
|
48
|
+
f as withAttribute,
|
|
49
|
+
h as withOperator
|
|
50
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { RuleTreeSchema as O } from "../@types/display-condition.js";
|
|
2
|
+
import { safeParse as $ } from "../node_modules/valibot/dist/index.js";
|
|
3
|
+
const N = {
|
|
4
|
+
string: ["is", "isNot", "contains", "notContains", "isOneOf", "isNotOneOf"],
|
|
5
|
+
number: ["is", "isNot", "isOneOf", "isNotOneOf"],
|
|
6
|
+
boolean: ["is", "isNot"],
|
|
7
|
+
date: ["is", "isNot", "isOneOf", "isNotOneOf"],
|
|
8
|
+
strings: ["contains", "notContains", "isOneOf", "isNotOneOf"]
|
|
9
|
+
}, L = ["isOneOf", "isNotOneOf"], k = "{% endif %}", g = /^-?\d+(\.\d+)?$/, R = /^\d{4}-\d{2}-\d{2}$/, T = /[{}]|[^\S ]/, U = (t) => N[t] ?? [], B = (t, n) => {
|
|
10
|
+
if (!n.trim() || T.test(n))
|
|
11
|
+
return !1;
|
|
12
|
+
switch (t) {
|
|
13
|
+
case "number":
|
|
14
|
+
return g.test(n.trim());
|
|
15
|
+
case "boolean":
|
|
16
|
+
return n === "true" || n === "false";
|
|
17
|
+
case "date":
|
|
18
|
+
return R.test(n);
|
|
19
|
+
default:
|
|
20
|
+
return !(n.includes('"') && n.includes("'"));
|
|
21
|
+
}
|
|
22
|
+
}, E = (t) => {
|
|
23
|
+
let n = t;
|
|
24
|
+
if (typeof t == "string")
|
|
25
|
+
try {
|
|
26
|
+
n = JSON.parse(t);
|
|
27
|
+
} catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const s = $(O, n);
|
|
31
|
+
return s.success ? s.output : null;
|
|
32
|
+
}, S = (t, n, s) => t === "number" ? String(Number(n.trim())) : t === "boolean" ? n === "true" ? "true" : "false" : s === "pongo" ? `"${n.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"` : n.includes('"') ? `'${n}'` : `"${n}"`, a = (t, n) => n.length === 1 ? n[0] : { kind: t, nodes: n }, _ = (t, n) => {
|
|
33
|
+
const { attribute: s, type: o, operator: u, values: i } = t, c = (e, l) => {
|
|
34
|
+
const f = S(o, l, n);
|
|
35
|
+
return {
|
|
36
|
+
kind: "cmp",
|
|
37
|
+
text: e === "contains" && n === "pongo" ? `${f} in ${s}` : `${s} ${e} ${f}`
|
|
38
|
+
};
|
|
39
|
+
}, r = o === "strings" ? "contains" : "==";
|
|
40
|
+
switch (u) {
|
|
41
|
+
case "isNot":
|
|
42
|
+
return c("!=", i[0]);
|
|
43
|
+
case "contains":
|
|
44
|
+
return c("contains", i[0]);
|
|
45
|
+
case "notContains":
|
|
46
|
+
return { kind: "not", node: c("contains", i[0]) };
|
|
47
|
+
case "isOneOf":
|
|
48
|
+
return a("any", i.map((e) => c(r, e)));
|
|
49
|
+
case "isNotOneOf":
|
|
50
|
+
return o === "strings" ? { kind: "not", node: a("any", i.map((e) => c("contains", e))) } : a("all", i.map((e) => c("!=", e)));
|
|
51
|
+
default:
|
|
52
|
+
return c("==", i[0]);
|
|
53
|
+
}
|
|
54
|
+
}, b = (t, n) => a(
|
|
55
|
+
t.condition === "and" ? "all" : "any",
|
|
56
|
+
t.groups.map((s) => a(
|
|
57
|
+
s.condition === "and" ? "all" : "any",
|
|
58
|
+
s.rules.map((o) => _(o, n))
|
|
59
|
+
))
|
|
60
|
+
), d = (t) => t === "all" ? " and " : " or ", p = (t) => t.kind === "cmp" ? t.text : t.kind === "not" ? `(${p(t.node)}) != true` : t.nodes.map((n) => n.kind !== "cmp" && n.kind !== t.kind && n.kind !== "not" ? `(${p(n)})` : p(n)).join(d(t.kind)), A = (t, n) => {
|
|
61
|
+
const s = [];
|
|
62
|
+
let o = 0;
|
|
63
|
+
const u = (r) => {
|
|
64
|
+
const e = `${n}_${o++}`, [l, f] = r.kind === "not" ? ["unless", "endunless"] : ["if", "endif"], m = i(r.kind === "not" ? r.node : r);
|
|
65
|
+
return s.push(`{% assign ${e} = false %}{% ${l} ${m} %}{% assign ${e} = true %}{% ${f} %}`), e;
|
|
66
|
+
}, i = (r) => r.kind === "cmp" ? r.text : r.kind === "not" ? u(r) : r.nodes.map((e) => e.kind === "cmp" ? e.text : e.kind === r.kind ? i(e) : u(e)).join(d(r.kind)), c = t.kind === "not" ? u(t) : i(t);
|
|
67
|
+
return `${s.join("")}{% if ${c} %}`;
|
|
68
|
+
}, C = (t, n, s) => {
|
|
69
|
+
const o = b(t, n);
|
|
70
|
+
return {
|
|
71
|
+
beforeScript: n === "pongo" ? `{% if ${p(o)} %}` : A(o, s),
|
|
72
|
+
afterScript: k
|
|
73
|
+
};
|
|
74
|
+
}, j = (t) => {
|
|
75
|
+
try {
|
|
76
|
+
const n = JSON.parse(t || "{}");
|
|
77
|
+
return (n == null ? void 0 : n.method) === "logicBuilder" ? E(n.rules) : null;
|
|
78
|
+
} catch {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
export {
|
|
83
|
+
k as LOGIC_BUILDER_AFTER_SCRIPT,
|
|
84
|
+
L as MULTI_VALUE_OPERATORS,
|
|
85
|
+
N as OPERATORS_BY_TYPE,
|
|
86
|
+
C as compileRuleTree,
|
|
87
|
+
B as isValidRuleValue,
|
|
88
|
+
U as operatorsFor,
|
|
89
|
+
E as parseRuleTree,
|
|
90
|
+
j as readLogicBuilderRules
|
|
91
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const m = {
|
|
2
|
+
is: "is",
|
|
3
|
+
isNot: "is-not",
|
|
4
|
+
contains: "contains",
|
|
5
|
+
notContains: "not-contains",
|
|
6
|
+
isOneOf: "is-one-of",
|
|
7
|
+
isNotOneOf: "is-not-one-of"
|
|
8
|
+
}, r = (i, e, c) => {
|
|
9
|
+
const a = new Map(e.map((n) => [n.key, n])), p = (n) => {
|
|
10
|
+
const o = a.get(n.attribute), d = (s) => {
|
|
11
|
+
var t;
|
|
12
|
+
return ((t = o == null ? void 0 : o.options.find((l) => l.value === s)) == null ? void 0 : t.label) ?? s;
|
|
13
|
+
};
|
|
14
|
+
return [
|
|
15
|
+
(o == null ? void 0 : o.label) ?? n.attribute,
|
|
16
|
+
c(n.operator),
|
|
17
|
+
n.values.map(d).join(", ")
|
|
18
|
+
].join(" ");
|
|
19
|
+
};
|
|
20
|
+
return {
|
|
21
|
+
condition: i.condition,
|
|
22
|
+
groups: i.groups.map((n) => ({ condition: n.condition, lines: n.rules.map(p) }))
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
m as OPERATOR_TRANS_SUFFIX,
|
|
27
|
+
r as summarizeRuleTree
|
|
28
|
+
};
|