@strapi/content-type-builder 5.50.0 → 5.50.1
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/admin/components/AIChat/Chat.js +2 -4
- package/dist/admin/components/AIChat/Chat.js.map +1 -1
- package/dist/admin/components/AIChat/Chat.mjs +2 -4
- package/dist/admin/components/AIChat/Chat.mjs.map +1 -1
- package/dist/admin/components/AIChat/UploadFigmaModal.js +1 -1
- package/dist/admin/components/AIChat/UploadFigmaModal.js.map +1 -1
- package/dist/admin/components/AIChat/UploadFigmaModal.mjs +1 -1
- package/dist/admin/components/AIChat/UploadFigmaModal.mjs.map +1 -1
- package/dist/admin/components/AIChat/components/Messages/Message.js +8 -3
- package/dist/admin/components/AIChat/components/Messages/Message.js.map +1 -1
- package/dist/admin/components/AIChat/components/Messages/Message.mjs +8 -3
- package/dist/admin/components/AIChat/components/Messages/Message.mjs.map +1 -1
- package/dist/admin/components/AIChat/lib/aiClient.js +8 -2
- package/dist/admin/components/AIChat/lib/aiClient.js.map +1 -1
- package/dist/admin/components/AIChat/lib/aiClient.mjs +8 -2
- package/dist/admin/components/AIChat/lib/aiClient.mjs.map +1 -1
- package/dist/admin/components/AIChat/lib/transforms/schemas/fromCTB.js +0 -3
- package/dist/admin/components/AIChat/lib/transforms/schemas/fromCTB.js.map +1 -1
- package/dist/admin/components/AIChat/lib/transforms/schemas/fromCTB.mjs +0 -3
- package/dist/admin/components/AIChat/lib/transforms/schemas/fromCTB.mjs.map +1 -1
- package/dist/admin/components/AIChat/lib/transforms/schemas/toCTB.js +9 -7
- package/dist/admin/components/AIChat/lib/transforms/schemas/toCTB.js.map +1 -1
- package/dist/admin/components/AIChat/lib/transforms/schemas/toCTB.mjs +9 -7
- package/dist/admin/components/AIChat/lib/transforms/schemas/toCTB.mjs.map +1 -1
- package/dist/admin/components/AIChat/providers/SchemaProvider.js +1 -1
- package/dist/admin/components/AIChat/providers/SchemaProvider.js.map +1 -1
- package/dist/admin/components/AIChat/providers/SchemaProvider.mjs +1 -1
- package/dist/admin/components/AIChat/providers/SchemaProvider.mjs.map +1 -1
- package/dist/admin/components/AllowedTypesSelect.js.map +1 -1
- package/dist/admin/components/AllowedTypesSelect.mjs.map +1 -1
- package/dist/admin/components/AttributeIcon.js +1 -1
- package/dist/admin/components/AttributeIcon.js.map +1 -1
- package/dist/admin/components/AttributeIcon.mjs +1 -1
- package/dist/admin/components/AttributeIcon.mjs.map +1 -1
- package/dist/admin/components/BooleanDefaultValueSelect.js +3 -2
- package/dist/admin/components/BooleanDefaultValueSelect.js.map +1 -1
- package/dist/admin/components/BooleanDefaultValueSelect.mjs +3 -2
- package/dist/admin/components/BooleanDefaultValueSelect.mjs.map +1 -1
- package/dist/admin/components/BooleanRadioGroup.js.map +1 -1
- package/dist/admin/components/BooleanRadioGroup.mjs.map +1 -1
- package/dist/admin/components/CTBSession/useCTBTracking.js +3 -3
- package/dist/admin/components/CTBSession/useCTBTracking.js.map +1 -1
- package/dist/admin/components/CTBSession/useCTBTracking.mjs +3 -3
- package/dist/admin/components/CTBSession/useCTBTracking.mjs.map +1 -1
- package/dist/admin/components/CheckboxWithNumberField.js +3 -2
- package/dist/admin/components/CheckboxWithNumberField.js.map +1 -1
- package/dist/admin/components/CheckboxWithNumberField.mjs +3 -2
- package/dist/admin/components/CheckboxWithNumberField.mjs.map +1 -1
- package/dist/admin/components/ComponentCard/ComponentCard.js.map +1 -1
- package/dist/admin/components/ComponentCard/ComponentCard.mjs.map +1 -1
- package/dist/admin/components/ContentTypeBuilderNav/ContentTypeBuilderNav.js +160 -162
- package/dist/admin/components/ContentTypeBuilderNav/ContentTypeBuilderNav.js.map +1 -1
- package/dist/admin/components/ContentTypeBuilderNav/ContentTypeBuilderNav.mjs +160 -162
- package/dist/admin/components/ContentTypeBuilderNav/ContentTypeBuilderNav.mjs.map +1 -1
- package/dist/admin/components/ContentTypeBuilderNav/useContentTypeBuilderMenu.js +1 -1
- package/dist/admin/components/ContentTypeBuilderNav/useContentTypeBuilderMenu.js.map +1 -1
- package/dist/admin/components/ContentTypeBuilderNav/useContentTypeBuilderMenu.mjs +1 -1
- package/dist/admin/components/ContentTypeBuilderNav/useContentTypeBuilderMenu.mjs.map +1 -1
- package/dist/admin/components/ContentTypeRadioGroup.js.map +1 -1
- package/dist/admin/components/ContentTypeRadioGroup.mjs.map +1 -1
- package/dist/admin/components/CustomRadioGroup/CustomRadioGroup.js +6 -5
- package/dist/admin/components/CustomRadioGroup/CustomRadioGroup.js.map +1 -1
- package/dist/admin/components/CustomRadioGroup/CustomRadioGroup.mjs +6 -5
- package/dist/admin/components/CustomRadioGroup/CustomRadioGroup.mjs.map +1 -1
- package/dist/admin/components/CustomRadioGroup/Styles.js.map +1 -1
- package/dist/admin/components/CustomRadioGroup/Styles.mjs.map +1 -1
- package/dist/admin/components/DataManager/DataManagerContext.js.map +1 -1
- package/dist/admin/components/DataManager/DataManagerContext.mjs.map +1 -1
- package/dist/admin/components/DataManager/DataManagerProvider.js +16 -4
- package/dist/admin/components/DataManager/DataManagerProvider.js.map +1 -1
- package/dist/admin/components/DataManager/DataManagerProvider.mjs +16 -4
- package/dist/admin/components/DataManager/DataManagerProvider.mjs.map +1 -1
- package/dist/admin/components/DataManager/reducer.js +2 -2
- package/dist/admin/components/DataManager/reducer.js.map +1 -1
- package/dist/admin/components/DataManager/reducer.mjs +2 -2
- package/dist/admin/components/DataManager/reducer.mjs.map +1 -1
- package/dist/admin/components/DataManager/useServerRestartWatcher.js.map +1 -1
- package/dist/admin/components/DataManager/useServerRestartWatcher.mjs.map +1 -1
- package/dist/admin/components/DataManager/utils/retrieveSpecificInfoFromComponents.js.map +1 -1
- package/dist/admin/components/DataManager/utils/retrieveSpecificInfoFromComponents.mjs.map +1 -1
- package/dist/admin/components/DraftAndPublishToggle.js.map +1 -1
- package/dist/admin/components/DraftAndPublishToggle.mjs.map +1 -1
- package/dist/admin/components/DynamicZoneList.js.map +1 -1
- package/dist/admin/components/DynamicZoneList.mjs.map +1 -1
- package/dist/admin/components/FormModal/FormModal.js +91 -71
- package/dist/admin/components/FormModal/FormModal.js.map +1 -1
- package/dist/admin/components/FormModal/FormModal.mjs +91 -70
- package/dist/admin/components/FormModal/FormModal.mjs.map +1 -1
- package/dist/admin/components/FormModal/attributes/ConditionForm.js +20 -17
- package/dist/admin/components/FormModal/attributes/ConditionForm.js.map +1 -1
- package/dist/admin/components/FormModal/attributes/ConditionForm.mjs +20 -17
- package/dist/admin/components/FormModal/attributes/ConditionForm.mjs.map +1 -1
- package/dist/admin/components/FormModal/attributes/validation/common.js.map +1 -1
- package/dist/admin/components/FormModal/attributes/validation/common.mjs.map +1 -1
- package/dist/admin/components/FormModal/forms/forms.js +4 -6
- package/dist/admin/components/FormModal/forms/forms.js.map +1 -1
- package/dist/admin/components/FormModal/forms/forms.mjs +4 -6
- package/dist/admin/components/FormModal/forms/forms.mjs.map +1 -1
- package/dist/admin/components/FormModal/forms/utils/getUsedAttributeNames.js.map +1 -1
- package/dist/admin/components/FormModal/forms/utils/getUsedAttributeNames.mjs.map +1 -1
- package/dist/admin/components/FormModal/reducer.js +9 -6
- package/dist/admin/components/FormModal/reducer.js.map +1 -1
- package/dist/admin/components/FormModal/reducer.mjs +9 -6
- package/dist/admin/components/FormModal/reducer.mjs.map +1 -1
- package/dist/admin/components/FormModal/utils/customFieldDefaultOptionsReducer.js +3 -3
- package/dist/admin/components/FormModal/utils/customFieldDefaultOptionsReducer.js.map +1 -1
- package/dist/admin/components/FormModal/utils/customFieldDefaultOptionsReducer.mjs +3 -3
- package/dist/admin/components/FormModal/utils/customFieldDefaultOptionsReducer.mjs.map +1 -1
- package/dist/admin/components/FormModal/utils/getFormInputNames.js +1 -1
- package/dist/admin/components/FormModal/utils/getFormInputNames.js.map +1 -1
- package/dist/admin/components/FormModal/utils/getFormInputNames.mjs +1 -1
- package/dist/admin/components/FormModal/utils/getFormInputNames.mjs.map +1 -1
- package/dist/admin/components/FormModal/utils/relations.js +2 -2
- package/dist/admin/components/FormModal/utils/relations.js.map +1 -1
- package/dist/admin/components/FormModal/utils/relations.mjs +2 -2
- package/dist/admin/components/FormModal/utils/relations.mjs.map +1 -1
- package/dist/admin/components/FormModalHeader.js.map +1 -1
- package/dist/admin/components/FormModalHeader.mjs.map +1 -1
- package/dist/admin/components/FormModalNavigation/FormModalNavigationContext.js.map +1 -1
- package/dist/admin/components/FormModalNavigation/FormModalNavigationContext.mjs.map +1 -1
- package/dist/admin/components/FormModalNavigation/FormModalNavigationProvider.js +13 -13
- package/dist/admin/components/FormModalNavigation/FormModalNavigationProvider.js.map +1 -1
- package/dist/admin/components/FormModalNavigation/FormModalNavigationProvider.mjs +13 -13
- package/dist/admin/components/FormModalNavigation/FormModalNavigationProvider.mjs.map +1 -1
- package/dist/admin/components/GenericInputs.js +24 -12
- package/dist/admin/components/GenericInputs.js.map +1 -1
- package/dist/admin/components/GenericInputs.mjs +24 -12
- package/dist/admin/components/GenericInputs.mjs.map +1 -1
- package/dist/admin/components/IconPicker/IconPicker.js.map +1 -1
- package/dist/admin/components/IconPicker/IconPicker.mjs.map +1 -1
- package/dist/admin/components/PluralName.js.map +1 -1
- package/dist/admin/components/PluralName.mjs.map +1 -1
- package/dist/admin/components/Relation/Relation.js +3 -3
- package/dist/admin/components/Relation/Relation.js.map +1 -1
- package/dist/admin/components/Relation/Relation.mjs +3 -3
- package/dist/admin/components/Relation/Relation.mjs.map +1 -1
- package/dist/admin/components/Relation/RelationField/RelationField.js +1 -1
- package/dist/admin/components/Relation/RelationField/RelationField.js.map +1 -1
- package/dist/admin/components/Relation/RelationField/RelationField.mjs +1 -1
- package/dist/admin/components/Relation/RelationField/RelationField.mjs.map +1 -1
- package/dist/admin/components/SelectCategory.js +6 -0
- package/dist/admin/components/SelectCategory.js.map +1 -1
- package/dist/admin/components/SelectCategory.mjs +6 -0
- package/dist/admin/components/SelectCategory.mjs.map +1 -1
- package/dist/admin/components/SelectComponent.js +1 -1
- package/dist/admin/components/SelectComponent.js.map +1 -1
- package/dist/admin/components/SelectComponent.mjs +1 -1
- package/dist/admin/components/SelectComponent.mjs.map +1 -1
- package/dist/admin/components/SingularName.js.map +1 -1
- package/dist/admin/components/SingularName.mjs.map +1 -1
- package/dist/admin/components/TabForm.js +50 -51
- package/dist/admin/components/TabForm.js.map +1 -1
- package/dist/admin/components/TabForm.mjs +51 -52
- package/dist/admin/components/TabForm.mjs.map +1 -1
- package/dist/admin/src/components/AIChat/components/Messages/Message.d.ts +1 -2
- package/dist/admin/src/components/AIChat/lib/aiClient.d.ts +1 -1
- package/dist/admin/src/components/AIChat/lib/transforms/schemas/fromCTB.d.ts +6 -2
- package/dist/admin/src/components/AIChat/lib/transforms/schemas/toCTB.d.ts +1 -1
- package/dist/admin/src/components/AIChat/lib/types/schema.d.ts +5 -5
- package/dist/admin/src/components/AllowedTypesSelect.d.ts +3 -3
- package/dist/admin/src/components/BooleanDefaultValueSelect.d.ts +3 -3
- package/dist/admin/src/components/BooleanRadioGroup.d.ts +2 -2
- package/dist/admin/src/components/CTBSession/useCTBTracking.d.ts +1 -1
- package/dist/admin/src/components/CheckboxWithNumberField.d.ts +6 -4
- package/dist/admin/src/components/ContentTypeRadioGroup.d.ts +3 -2
- package/dist/admin/src/components/CustomRadioGroup/CustomRadioGroup.d.ts +3 -2
- package/dist/admin/src/components/DataManager/DataManagerContext.d.ts +13 -11
- package/dist/admin/src/components/DataManager/reducer.d.ts +14 -10
- package/dist/admin/src/components/DataManager/utils/cleanData.d.ts +8 -8
- package/dist/admin/src/components/DataManager/utils/formatSchemas.d.ts +9 -3
- package/dist/admin/src/components/DataManager/utils/retrieveSpecificInfoFromComponents.d.ts +2 -1
- package/dist/admin/src/components/DraftAndPublishToggle.d.ts +1 -6
- package/dist/admin/src/components/DynamicZoneList.d.ts +2 -2
- package/dist/admin/src/components/FormModal/attributes/ConditionForm.d.ts +3 -2
- package/dist/admin/src/components/FormModal/attributes/validation/common.d.ts +3 -1
- package/dist/admin/src/components/FormModal/forms/forms.d.ts +59 -26
- package/dist/admin/src/components/FormModal/forms/utils/getUsedAttributeNames.d.ts +12 -2
- package/dist/admin/src/components/FormModal/reducer.d.ts +104 -32
- package/dist/admin/src/components/FormModal/utils/customFieldDefaultOptionsReducer.d.ts +11 -1
- package/dist/admin/src/components/FormModal/utils/getFormInputNames.d.ts +8 -1
- package/dist/admin/src/components/FormModal/utils/relations.d.ts +2 -2
- package/dist/admin/src/components/FormModalHeader.d.ts +5 -8
- package/dist/admin/src/components/FormModalNavigation/FormModalNavigationContext.d.ts +2 -2
- package/dist/admin/src/components/FormModalNavigation/FormModalNavigationProvider.d.ts +17 -1
- package/dist/admin/src/components/GenericInputs.d.ts +12 -7
- package/dist/admin/src/components/IconPicker/IconPicker.d.ts +2 -7
- package/dist/admin/src/components/PluralName.d.ts +6 -14
- package/dist/admin/src/components/Relation/Relation.d.ts +12 -3
- package/dist/admin/src/components/Relation/RelationField/RelationField.d.ts +3 -2
- package/dist/admin/src/components/SelectCategory.d.ts +3 -12
- package/dist/admin/src/components/SelectComponent.d.ts +8 -7
- package/dist/admin/src/components/SingularName.d.ts +5 -8
- package/dist/admin/src/components/TabForm.d.ts +38 -7
- package/dist/admin/src/types.d.ts +20 -12
- package/dist/admin/src/utils/conditions.d.ts +13 -4
- package/dist/admin/src/utils/formAPI.d.ts +38 -33
- package/dist/admin/src/utils/getRelationType.d.ts +1 -1
- package/dist/admin/src/utils/parseNumberInputValue.d.ts +1 -0
- package/dist/admin/utils/conditions.js +38 -28
- package/dist/admin/utils/conditions.js.map +1 -1
- package/dist/admin/utils/conditions.mjs +37 -28
- package/dist/admin/utils/conditions.mjs.map +1 -1
- package/dist/admin/utils/formAPI.js +9 -6
- package/dist/admin/utils/formAPI.js.map +1 -1
- package/dist/admin/utils/formAPI.mjs +9 -6
- package/dist/admin/utils/formAPI.mjs.map +1 -1
- package/dist/admin/utils/getRelationType.js +3 -0
- package/dist/admin/utils/getRelationType.js.map +1 -1
- package/dist/admin/utils/getRelationType.mjs +3 -0
- package/dist/admin/utils/getRelationType.mjs.map +1 -1
- package/dist/admin/utils/getYupInnerErrors.js +6 -4
- package/dist/admin/utils/getYupInnerErrors.js.map +1 -1
- package/dist/admin/utils/getYupInnerErrors.mjs +6 -4
- package/dist/admin/utils/getYupInnerErrors.mjs.map +1 -1
- package/dist/admin/utils/parseNumberInputValue.js +15 -0
- package/dist/admin/utils/parseNumberInputValue.js.map +1 -0
- package/dist/admin/utils/parseNumberInputValue.mjs +13 -0
- package/dist/admin/utils/parseNumberInputValue.mjs.map +1 -0
- package/dist/server/controllers/validation/relations.js +1 -1
- package/dist/server/controllers/validation/relations.js.map +1 -1
- package/dist/server/controllers/validation/relations.mjs +1 -1
- package/dist/server/controllers/validation/relations.mjs.map +1 -1
- package/dist/server/controllers/validation/types.js +4 -3
- package/dist/server/controllers/validation/types.js.map +1 -1
- package/dist/server/controllers/validation/types.mjs +4 -3
- package/dist/server/controllers/validation/types.mjs.map +1 -1
- package/package.json +7 -7
|
@@ -18,6 +18,11 @@ interface InputOption {
|
|
|
18
18
|
key: string;
|
|
19
19
|
value: string;
|
|
20
20
|
}
|
|
21
|
+
type ConditionField = {
|
|
22
|
+
name: string;
|
|
23
|
+
type: string;
|
|
24
|
+
enum?: string[];
|
|
25
|
+
};
|
|
21
26
|
interface CustomInputProps<TAttribute extends Schema.Attribute.AnyAttribute = Schema.Attribute.AnyAttribute> {
|
|
22
27
|
attribute?: TAttribute;
|
|
23
28
|
autoComplete?: string;
|
|
@@ -31,7 +36,7 @@ interface CustomInputProps<TAttribute extends Schema.Attribute.AnyAttribute = Sc
|
|
|
31
36
|
onChange: (payload: {
|
|
32
37
|
target: {
|
|
33
38
|
name: string;
|
|
34
|
-
value
|
|
39
|
+
value?: unknown;
|
|
35
40
|
type?: string;
|
|
36
41
|
};
|
|
37
42
|
}, shouldSetInitialValue?: boolean) => void;
|
|
@@ -41,10 +46,10 @@ interface CustomInputProps<TAttribute extends Schema.Attribute.AnyAttribute = Sc
|
|
|
41
46
|
required?: boolean;
|
|
42
47
|
step?: number;
|
|
43
48
|
type: string;
|
|
44
|
-
value?:
|
|
49
|
+
value?: unknown;
|
|
45
50
|
autoFocus?: boolean;
|
|
46
51
|
attributeName?: string;
|
|
47
|
-
conditionFields?:
|
|
52
|
+
conditionFields?: ConditionField[];
|
|
48
53
|
}
|
|
49
54
|
interface GenericInputProps<TAttribute extends Schema.Attribute.AnyAttribute = Schema.Attribute.AnyAttribute> {
|
|
50
55
|
attribute?: TAttribute;
|
|
@@ -59,7 +64,7 @@ interface GenericInputProps<TAttribute extends Schema.Attribute.AnyAttribute = S
|
|
|
59
64
|
onChange: (payload: {
|
|
60
65
|
target: {
|
|
61
66
|
name: string;
|
|
62
|
-
value
|
|
67
|
+
value?: unknown;
|
|
63
68
|
type?: string;
|
|
64
69
|
};
|
|
65
70
|
}, shouldSetInitialValue?: boolean) => void;
|
|
@@ -69,17 +74,17 @@ interface GenericInputProps<TAttribute extends Schema.Attribute.AnyAttribute = S
|
|
|
69
74
|
required?: boolean;
|
|
70
75
|
step?: number;
|
|
71
76
|
type: string;
|
|
72
|
-
value?:
|
|
77
|
+
value?: unknown;
|
|
73
78
|
isNullable?: boolean;
|
|
74
79
|
autoFocus?: boolean;
|
|
75
80
|
attributeName?: string;
|
|
76
|
-
conditionFields?:
|
|
81
|
+
conditionFields?: ConditionField[];
|
|
77
82
|
}
|
|
78
83
|
/**
|
|
79
84
|
* we've memoized this component because we use a context to store all the data in our form in the content-manager.
|
|
80
85
|
* This then causes _every_ component to re-render because there are no selects incurring performance issues
|
|
81
86
|
* in content-types as the content-type gets more complicated.
|
|
82
87
|
*/
|
|
83
|
-
declare const MemoizedGenericInput: React.MemoExoticComponent<({ autoComplete, customInputs, description, disabled, intlLabel, labelAction, error, name, onChange, onDelete, options, placeholder, required, step, type, value: defaultValue, isNullable, autoFocus, attribute, attributeName, conditionFields, ...rest }: GenericInputProps) => import("react/jsx-runtime").JSX.Element>;
|
|
88
|
+
declare const MemoizedGenericInput: React.MemoExoticComponent<({ autoComplete, customInputs, description, disabled, intlLabel, labelAction, error, name, onChange, onDelete, options, placeholder, required, step, type, value: defaultValue, isNullable: _isNullable, autoFocus, attribute, attributeName, conditionFields, ...rest }: GenericInputProps) => import("react/jsx-runtime").JSX.Element>;
|
|
84
89
|
export type { GenericInputProps, CustomInputProps };
|
|
85
90
|
export { MemoizedGenericInput as GenericInput };
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import type { IntlLabel } from '../../types';
|
|
1
|
+
import type { FormChangeHandler, IntlLabel } from '../../types';
|
|
2
2
|
export interface IconPickerProps {
|
|
3
3
|
intlLabel: IntlLabel;
|
|
4
4
|
name: string;
|
|
5
|
-
onChange:
|
|
6
|
-
target: {
|
|
7
|
-
name: string;
|
|
8
|
-
value: string;
|
|
9
|
-
};
|
|
10
|
-
}) => void;
|
|
5
|
+
onChange: FormChangeHandler<string>;
|
|
11
6
|
value?: string;
|
|
12
7
|
}
|
|
13
8
|
export declare const IconPicker: ({ intlLabel, name, onChange, value }: IconPickerProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,21 +1,13 @@
|
|
|
1
|
-
import type { IntlLabel } from '../types';
|
|
2
|
-
interface Description {
|
|
3
|
-
id: string;
|
|
4
|
-
defaultMessage: string;
|
|
5
|
-
values?: Record<string, any>;
|
|
6
|
-
}
|
|
1
|
+
import type { FormChangeHandler, IntlLabel } from '../types';
|
|
7
2
|
interface PluralNameProps {
|
|
8
|
-
description?:
|
|
3
|
+
description?: IntlLabel;
|
|
9
4
|
error?: string;
|
|
10
5
|
intlLabel: IntlLabel;
|
|
11
|
-
modifiedData:
|
|
6
|
+
modifiedData: {
|
|
7
|
+
displayName?: string;
|
|
8
|
+
};
|
|
12
9
|
name: string;
|
|
13
|
-
onChange:
|
|
14
|
-
target: {
|
|
15
|
-
name: string;
|
|
16
|
-
value: string;
|
|
17
|
-
};
|
|
18
|
-
}) => void;
|
|
10
|
+
onChange: FormChangeHandler<string>;
|
|
19
11
|
value?: string;
|
|
20
12
|
}
|
|
21
13
|
export declare const PluralName: ({ description, error, intlLabel, modifiedData, name, onChange, value, }: PluralNameProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
+
import type { FormChangeHandler } from '../../types';
|
|
2
|
+
import type { Schema } from '@strapi/types';
|
|
1
3
|
interface RelationProps {
|
|
2
|
-
formErrors: Record<string,
|
|
4
|
+
formErrors: Record<string, {
|
|
5
|
+
id?: string;
|
|
6
|
+
} | undefined>;
|
|
3
7
|
mainBoxHeader: string;
|
|
4
|
-
modifiedData:
|
|
5
|
-
|
|
8
|
+
modifiedData: {
|
|
9
|
+
name?: string;
|
|
10
|
+
relation?: Schema.Attribute.RelationKind.Any;
|
|
11
|
+
target?: string;
|
|
12
|
+
targetAttribute?: string | null;
|
|
13
|
+
};
|
|
14
|
+
onChange: FormChangeHandler;
|
|
6
15
|
naturePickerType: string;
|
|
7
16
|
targetUid: string;
|
|
8
17
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import type { FormChangeHandler } from '../../../types';
|
|
1
2
|
import type { Internal } from '@strapi/types';
|
|
2
3
|
interface RelationFormBoxProps {
|
|
3
4
|
disabled?: boolean;
|
|
4
|
-
error?:
|
|
5
|
+
error?: string | null;
|
|
5
6
|
header?: string;
|
|
6
7
|
isMain?: boolean;
|
|
7
8
|
name: string;
|
|
8
|
-
onChange:
|
|
9
|
+
onChange: FormChangeHandler;
|
|
9
10
|
oneThatIsCreatingARelationWithAnother?: string;
|
|
10
11
|
target?: Internal.UID.ContentType;
|
|
11
12
|
value?: string;
|
|
@@ -1,18 +1,9 @@
|
|
|
1
|
+
import type { FormChangeHandler, IntlLabel } from '../types';
|
|
1
2
|
interface SelectCategoryProps {
|
|
2
3
|
error?: string | null;
|
|
3
|
-
intlLabel:
|
|
4
|
-
id: string;
|
|
5
|
-
defaultMessage: string;
|
|
6
|
-
values?: Record<string, any>;
|
|
7
|
-
};
|
|
4
|
+
intlLabel: IntlLabel;
|
|
8
5
|
name: string;
|
|
9
|
-
onChange:
|
|
10
|
-
target: {
|
|
11
|
-
name: string;
|
|
12
|
-
value: any;
|
|
13
|
-
type: string;
|
|
14
|
-
};
|
|
15
|
-
}) => void;
|
|
6
|
+
onChange: FormChangeHandler<string, 'select-category'>;
|
|
16
7
|
value?: string;
|
|
17
8
|
isCreating?: boolean;
|
|
18
9
|
dynamicZoneTarget?: string | null;
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
+
import type { FormChangeHandler, IntlLabel } from '../types';
|
|
1
2
|
import type { Internal } from '@strapi/types';
|
|
3
|
+
type ComponentToCreate = {
|
|
4
|
+
displayName?: string;
|
|
5
|
+
category?: string;
|
|
6
|
+
};
|
|
2
7
|
interface SelectComponentProps {
|
|
3
|
-
componentToCreate?:
|
|
8
|
+
componentToCreate?: ComponentToCreate | null;
|
|
4
9
|
error?: string | null;
|
|
5
|
-
intlLabel:
|
|
6
|
-
id: string;
|
|
7
|
-
defaultMessage: string;
|
|
8
|
-
values?: Record<string, any>;
|
|
9
|
-
};
|
|
10
|
+
intlLabel: IntlLabel;
|
|
10
11
|
isAddingAComponentToAnotherComponent: boolean;
|
|
11
12
|
isCreating: boolean;
|
|
12
13
|
isCreatingComponentWhileAddingAField: boolean;
|
|
13
14
|
name: string;
|
|
14
|
-
onChange:
|
|
15
|
+
onChange: FormChangeHandler<string, 'select-category'>;
|
|
15
16
|
targetUid: Internal.UID.Schema;
|
|
16
17
|
value: string;
|
|
17
18
|
forTarget: string;
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import type { IntlLabel } from '../types';
|
|
1
|
+
import type { FormChangeHandler, IntlLabel } from '../types';
|
|
2
2
|
interface SingularNameProps {
|
|
3
3
|
description?: IntlLabel | null;
|
|
4
4
|
error?: string | null;
|
|
5
5
|
intlLabel: IntlLabel;
|
|
6
|
-
modifiedData:
|
|
6
|
+
modifiedData: {
|
|
7
|
+
displayName?: string;
|
|
8
|
+
};
|
|
7
9
|
name: string;
|
|
8
|
-
onChange:
|
|
9
|
-
target: {
|
|
10
|
-
name: string;
|
|
11
|
-
value: string;
|
|
12
|
-
};
|
|
13
|
-
}) => void;
|
|
10
|
+
onChange: FormChangeHandler<string>;
|
|
14
11
|
value?: string | null;
|
|
15
12
|
}
|
|
16
13
|
export declare const SingularName: ({ description, error, intlLabel, modifiedData, name, onChange, value, }: SingularNameProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,9 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
1
|
+
import { GenericInput } from './GenericInputs';
|
|
2
|
+
import type { AnyAttribute, IntlLabel } from '../types';
|
|
3
|
+
type FormInput = Partial<React.ComponentProps<typeof GenericInput>> & {
|
|
4
|
+
name: string;
|
|
5
|
+
type: string;
|
|
6
|
+
size?: number;
|
|
7
|
+
};
|
|
8
|
+
type FormSection = {
|
|
9
|
+
sectionTitle?: IntlLabel | null;
|
|
10
|
+
intlLabel?: IntlLabel;
|
|
11
|
+
items: FormInput[];
|
|
12
|
+
};
|
|
13
|
+
type FormError = {
|
|
14
|
+
id?: string;
|
|
15
|
+
};
|
|
16
|
+
type GenericInputProps = Record<string, unknown> & {
|
|
17
|
+
attributeName?: string;
|
|
18
|
+
contentTypeSchema?: {
|
|
19
|
+
attributes?: AnyAttribute[];
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
type ModifiedData = Record<string, unknown> & {
|
|
23
|
+
name?: string;
|
|
24
|
+
};
|
|
25
|
+
type TabFormChangeHandler = (value: {
|
|
26
|
+
target: {
|
|
27
|
+
name: string;
|
|
28
|
+
value?: unknown;
|
|
29
|
+
type?: string;
|
|
30
|
+
};
|
|
31
|
+
}) => void;
|
|
32
|
+
type TabFormProps = {
|
|
33
|
+
form: FormSection[];
|
|
34
|
+
formErrors: Record<string, FormError>;
|
|
35
|
+
genericInputProps: GenericInputProps;
|
|
36
|
+
modifiedData: ModifiedData;
|
|
37
|
+
onChange: TabFormChangeHandler;
|
|
38
|
+
};
|
|
8
39
|
export declare const TabForm: ({ form, formErrors, genericInputProps, modifiedData, onChange, }: TabFormProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
40
|
export {};
|
|
@@ -1,23 +1,32 @@
|
|
|
1
1
|
import type { Schema, Struct, UID } from '@strapi/types';
|
|
2
|
+
import type { PrimitiveType } from 'react-intl';
|
|
2
3
|
export type IntlLabel = {
|
|
3
4
|
id: string;
|
|
4
5
|
defaultMessage: string;
|
|
5
|
-
values?: Record<string,
|
|
6
|
+
values?: Record<string, PrimitiveType>;
|
|
6
7
|
};
|
|
8
|
+
export type FormChange<TValue = unknown, TType extends string = string> = {
|
|
9
|
+
target: {
|
|
10
|
+
name: string;
|
|
11
|
+
value?: TValue;
|
|
12
|
+
type?: TType;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export type FormChangeHandler<TValue = unknown, TType extends string = string> = (value: FormChange<TValue, TType>) => void;
|
|
7
16
|
export type DifferentAttributesKind = 'Populatable' | 'NonPopulatable' | 'Any';
|
|
8
17
|
export type Status = 'UNCHANGED' | 'CHANGED' | 'REMOVED' | 'NEW';
|
|
9
|
-
type
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
18
|
+
export type AttributeConditionValue = string | number | boolean;
|
|
19
|
+
export type AttributeConditionRule = [{
|
|
20
|
+
var: string;
|
|
21
|
+
}, AttributeConditionValue];
|
|
22
|
+
export type AttributeConditions = {
|
|
23
|
+
visible?: Record<string, AttributeConditionRule>;
|
|
13
24
|
};
|
|
14
25
|
export type Base = {
|
|
15
26
|
name: string;
|
|
16
27
|
status?: Status;
|
|
17
|
-
customField?:
|
|
18
|
-
conditions?:
|
|
19
|
-
visible?: Record<string, any>;
|
|
20
|
-
};
|
|
28
|
+
customField?: string;
|
|
29
|
+
conditions?: AttributeConditions;
|
|
21
30
|
};
|
|
22
31
|
export type Relation = Base & {
|
|
23
32
|
type: 'relation';
|
|
@@ -26,7 +35,7 @@ export type Relation = Base & {
|
|
|
26
35
|
targetAttribute?: string | null;
|
|
27
36
|
configurable?: boolean;
|
|
28
37
|
private?: boolean;
|
|
29
|
-
pluginOptions?: Record<string,
|
|
38
|
+
pluginOptions?: Record<string, unknown>;
|
|
30
39
|
};
|
|
31
40
|
export type Media = Base & {
|
|
32
41
|
type: 'media';
|
|
@@ -35,7 +44,7 @@ export type Media = Base & {
|
|
|
35
44
|
configurable?: boolean;
|
|
36
45
|
private?: boolean;
|
|
37
46
|
allowedTypes?: string[];
|
|
38
|
-
pluginOptions?: Record<string,
|
|
47
|
+
pluginOptions?: Record<string, unknown>;
|
|
39
48
|
};
|
|
40
49
|
export type AnyAttribute = Base & (Schema.Attribute.BigInteger | Schema.Attribute.Boolean | Schema.Attribute.Blocks | Schema.Attribute.Component<UID.Component, boolean> | Schema.Attribute.DateTime | Schema.Attribute.Date | Schema.Attribute.Decimal | Schema.Attribute.DynamicZone | Schema.Attribute.Email | Schema.Attribute.Enumeration<string[]> | Schema.Attribute.Float | Schema.Attribute.Integer | Schema.Attribute.JSON | Schema.Attribute.Password | Schema.Attribute.RichText | Schema.Attribute.String | Schema.Attribute.Text | Schema.Attribute.Time | Schema.Attribute.Timestamp | Schema.Attribute.UID | Media | Relation);
|
|
41
50
|
export type Component = Omit<Struct.ComponentSchema, 'attributes'> & {
|
|
@@ -51,4 +60,3 @@ export type ContentType = Omit<Struct.ContentTypeSchema, 'attributes'> & {
|
|
|
51
60
|
};
|
|
52
61
|
export type Components = Record<string, Component>;
|
|
53
62
|
export type ContentTypes = Record<string, ContentType>;
|
|
54
|
-
export {};
|
|
@@ -1,17 +1,26 @@
|
|
|
1
|
-
import type { AnyAttribute } from '../types';
|
|
1
|
+
import type { AnyAttribute, AttributeConditionValue, AttributeConditions, ContentTypes } from '../types';
|
|
2
2
|
interface DependentRow {
|
|
3
3
|
contentTypeUid: string;
|
|
4
4
|
contentType: string;
|
|
5
5
|
attribute: string;
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
type VisibleConditionEntry = {
|
|
8
|
+
operator: string;
|
|
9
|
+
fieldVar: {
|
|
10
|
+
var: string;
|
|
11
|
+
};
|
|
12
|
+
value: AttributeConditionValue;
|
|
13
|
+
};
|
|
14
|
+
export declare const getVisibleConditionEntries: (condition?: AttributeConditions | null) => VisibleConditionEntry[];
|
|
15
|
+
export declare const getFirstVisibleConditionEntry: (condition?: AttributeConditions | null) => VisibleConditionEntry;
|
|
16
|
+
export declare const checkDependentRows: (contentTypes: ContentTypes, fieldName: string) => DependentRow[];
|
|
17
|
+
export declare const formatCondition: (condition: AttributeConditions, availableFields: Array<{
|
|
9
18
|
name: string;
|
|
10
19
|
type: string;
|
|
11
20
|
}>, attributeName: string) => string;
|
|
12
21
|
export declare const getAvailableConditionFields: (attributes: AnyAttribute[], currentFieldName: string) => {
|
|
13
22
|
name: string;
|
|
14
|
-
type: "string" | "boolean" | "time" | "text" | "media" | "date" | "email" | "password" | "decimal" | "
|
|
23
|
+
type: "string" | "boolean" | "time" | "text" | "media" | "date" | "email" | "password" | "decimal" | "relation" | "biginteger" | "blocks" | "component" | "datetime" | "dynamiczone" | "enumeration" | "float" | "integer" | "json" | "richtext" | "timestamp" | "uid";
|
|
15
24
|
enum: string[] | undefined;
|
|
16
25
|
}[];
|
|
17
26
|
export {};
|
|
@@ -1,43 +1,48 @@
|
|
|
1
|
-
|
|
1
|
+
import * as yup from 'yup';
|
|
2
|
+
type YupObjectShape = Parameters<ReturnType<typeof yup.object>['shape']>[0];
|
|
3
|
+
type YupObjectSchema = ReturnType<typeof yup.object>;
|
|
4
|
+
type FormSection = unknown;
|
|
5
|
+
type FormExtensionHandler = (props?: unknown) => FormSection[];
|
|
6
|
+
type FormValidator = (args: unknown[]) => YupObjectShape;
|
|
7
|
+
type ContentTypeSchemaMutation = (data: Record<string, unknown>, initialData: Record<string, unknown>) => Record<string, unknown>;
|
|
8
|
+
type ExtensionForm = {
|
|
9
|
+
advanced: FormExtensionHandler[];
|
|
10
|
+
base: FormExtensionHandler[];
|
|
11
|
+
};
|
|
12
|
+
type ExtensionDefinition = {
|
|
13
|
+
validators: FormValidator[];
|
|
14
|
+
form: ExtensionForm;
|
|
15
|
+
};
|
|
16
|
+
type ExtensionInput = {
|
|
17
|
+
validator?: FormValidator;
|
|
18
|
+
form: {
|
|
19
|
+
advanced: FormExtensionHandler;
|
|
20
|
+
base: FormExtensionHandler;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export type FormAPI = {
|
|
2
24
|
components: {
|
|
3
|
-
inputs: Record<string,
|
|
25
|
+
inputs: Record<string, unknown>;
|
|
4
26
|
add: ({ id, component }: {
|
|
5
27
|
id: string;
|
|
6
|
-
component:
|
|
28
|
+
component: unknown;
|
|
7
29
|
}) => void;
|
|
8
30
|
};
|
|
9
31
|
types: {
|
|
10
32
|
attribute: {
|
|
11
|
-
[key: string]:
|
|
12
|
-
validators: any[];
|
|
13
|
-
form: {
|
|
14
|
-
advanced: any[];
|
|
15
|
-
base: any[];
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
contentType: {
|
|
20
|
-
validators: any[];
|
|
21
|
-
form: {
|
|
22
|
-
advanced: any[];
|
|
23
|
-
base: any[];
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
component: {
|
|
27
|
-
validators: any[];
|
|
28
|
-
form: {
|
|
29
|
-
advanced: any[];
|
|
30
|
-
base: any[];
|
|
31
|
-
};
|
|
33
|
+
[key: string]: ExtensionDefinition;
|
|
32
34
|
};
|
|
35
|
+
contentType: ExtensionDefinition;
|
|
36
|
+
component: ExtensionDefinition;
|
|
33
37
|
};
|
|
34
|
-
contentTypeSchemaMutations:
|
|
35
|
-
addContentTypeSchemaMutation: (cb:
|
|
36
|
-
extendContentType: (data:
|
|
37
|
-
extendFields: (fields:
|
|
38
|
-
getAdvancedForm: (target:
|
|
39
|
-
makeCustomFieldValidator: (attributeShape:
|
|
40
|
-
makeValidator: (target:
|
|
41
|
-
mutateContentTypeSchema: (data: Record<string, unknown>, initialData: Record<string, unknown>) =>
|
|
42
|
-
}
|
|
38
|
+
contentTypeSchemaMutations: ContentTypeSchemaMutation[];
|
|
39
|
+
addContentTypeSchemaMutation: (cb: ContentTypeSchemaMutation) => void;
|
|
40
|
+
extendContentType: (data: ExtensionInput) => void;
|
|
41
|
+
extendFields: (fields: string[], data: ExtensionInput) => void;
|
|
42
|
+
getAdvancedForm: (target: string[], props?: unknown) => FormSection[];
|
|
43
|
+
makeCustomFieldValidator: (attributeShape: YupObjectSchema, validator: FormValidator | undefined, ...validatorArgs: unknown[]) => YupObjectSchema;
|
|
44
|
+
makeValidator: (target: string[], initShape: YupObjectSchema, ...args: unknown[]) => YupObjectSchema;
|
|
45
|
+
mutateContentTypeSchema: (data: Record<string, unknown>, initialData: Record<string, unknown>) => Record<string, unknown>;
|
|
46
|
+
};
|
|
43
47
|
export declare const formsAPI: FormAPI;
|
|
48
|
+
export {};
|
|
@@ -3,4 +3,4 @@ import type { Schema } from '@strapi/types';
|
|
|
3
3
|
*
|
|
4
4
|
* Retrieves the relation type
|
|
5
5
|
*/
|
|
6
|
-
export declare const getRelationType: (relation
|
|
6
|
+
export declare const getRelationType: (relation?: Schema.Attribute.RelationKind.Any, targetAttribute?: string | null) => "oneToOne" | "oneToMany" | "manyToOne" | "manyToMany" | Schema.Attribute.RelationKind.Morph | "oneWay" | "manyWay" | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const parseNumberInputValue: (value: string | number | null | undefined) => number;
|
|
@@ -1,46 +1,55 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const isRecord = (value)=>typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
4
|
+
const isFieldVar = (value)=>isRecord(value) && typeof value.var === 'string';
|
|
5
|
+
const isAttributeConditionValue = (value)=>typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean';
|
|
6
|
+
const getVisibleConditionEntries = (condition)=>{
|
|
7
|
+
const visible = condition?.visible;
|
|
8
|
+
if (!isRecord(visible)) {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
return Object.entries(visible).reduce((entries, [operator, rule])=>{
|
|
12
|
+
if (!Array.isArray(rule)) {
|
|
13
|
+
return entries;
|
|
14
|
+
}
|
|
15
|
+
const [fieldVar, value] = rule;
|
|
16
|
+
if (!isFieldVar(fieldVar) || !isAttributeConditionValue(value)) {
|
|
17
|
+
return entries;
|
|
18
|
+
}
|
|
19
|
+
entries.push({
|
|
20
|
+
operator,
|
|
21
|
+
fieldVar,
|
|
22
|
+
value
|
|
23
|
+
});
|
|
24
|
+
return entries;
|
|
25
|
+
}, []);
|
|
26
|
+
};
|
|
27
|
+
const getFirstVisibleConditionEntry = (condition)=>getVisibleConditionEntries(condition)[0] ?? null;
|
|
3
28
|
const checkDependentRows = (contentTypes, fieldName)=>{
|
|
4
29
|
const dependentRows = [];
|
|
5
30
|
Object.entries(contentTypes).forEach(([contentTypeUid, contentType])=>{
|
|
6
|
-
if (contentType.attributes) {
|
|
31
|
+
if (contentType.attributes !== undefined) {
|
|
7
32
|
// Handle both array and object formats of attributes
|
|
8
33
|
const attributes = Array.isArray(contentType.attributes) ? contentType.attributes.reduce((acc, attr, index)=>{
|
|
9
34
|
acc[index.toString()] = attr;
|
|
10
35
|
return acc;
|
|
11
36
|
}, {}) : contentType.attributes;
|
|
12
37
|
Object.entries(attributes).forEach(([attrName, attr])=>{
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}
|
|
38
|
+
getVisibleConditionEntries(attr.conditions).forEach(({ fieldVar })=>{
|
|
39
|
+
// Check if this condition references our field
|
|
40
|
+
if (fieldVar.var === fieldName) {
|
|
41
|
+
dependentRows.push({
|
|
42
|
+
contentTypeUid,
|
|
43
|
+
contentType: contentType.info.displayName,
|
|
44
|
+
attribute: attr.name || attrName
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
});
|
|
26
48
|
});
|
|
27
49
|
}
|
|
28
50
|
});
|
|
29
51
|
return dependentRows;
|
|
30
52
|
};
|
|
31
|
-
const formatCondition = (condition, availableFields, attributeName)=>{
|
|
32
|
-
if (!condition?.visible) {
|
|
33
|
-
return '';
|
|
34
|
-
}
|
|
35
|
-
const [[operator, conditions]] = Object.entries(condition.visible);
|
|
36
|
-
const [fieldVar, value] = conditions;
|
|
37
|
-
const dependsOnField = availableFields.find((field)=>field.name === fieldVar.var);
|
|
38
|
-
const dependsOnFieldName = dependsOnField ? dependsOnField.name : fieldVar.var;
|
|
39
|
-
const operatorText = operator === '==' ? 'is' : 'is not';
|
|
40
|
-
const valueText = String(value);
|
|
41
|
-
const actionText = operator === '==' ? 'Show' : 'Hide';
|
|
42
|
-
return `If ${dependsOnFieldName} ${operatorText} ${valueText}, then ${actionText} ${attributeName}`;
|
|
43
|
-
};
|
|
44
53
|
const getAvailableConditionFields = (attributes, currentFieldName)=>{
|
|
45
54
|
return attributes.filter((attr)=>{
|
|
46
55
|
// Only include boolean and enum fields
|
|
@@ -56,6 +65,7 @@ const getAvailableConditionFields = (attributes, currentFieldName)=>{
|
|
|
56
65
|
};
|
|
57
66
|
|
|
58
67
|
exports.checkDependentRows = checkDependentRows;
|
|
59
|
-
exports.formatCondition = formatCondition;
|
|
60
68
|
exports.getAvailableConditionFields = getAvailableConditionFields;
|
|
69
|
+
exports.getFirstVisibleConditionEntry = getFirstVisibleConditionEntry;
|
|
70
|
+
exports.getVisibleConditionEntries = getVisibleConditionEntries;
|
|
61
71
|
//# sourceMappingURL=conditions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conditions.js","sources":["../../../admin/src/utils/conditions.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"conditions.js","sources":["../../../admin/src/utils/conditions.ts"],"sourcesContent":["import type {\n AnyAttribute,\n AttributeConditionValue,\n AttributeConditions,\n ContentTypes,\n} from '../types';\n\ninterface DependentRow {\n contentTypeUid: string;\n contentType: string;\n attribute: string;\n}\n\ntype VisibleConditionEntry = {\n operator: string;\n fieldVar: { var: string };\n value: AttributeConditionValue;\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst isFieldVar = (value: unknown): value is { var: string } =>\n isRecord(value) && typeof value.var === 'string';\n\nconst isAttributeConditionValue = (value: unknown): value is AttributeConditionValue =>\n typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean';\n\nexport const getVisibleConditionEntries = (\n condition?: AttributeConditions | null\n): VisibleConditionEntry[] => {\n const visible = condition?.visible;\n\n if (!isRecord(visible)) {\n return [];\n }\n\n return Object.entries(visible).reduce<VisibleConditionEntry[]>((entries, [operator, rule]) => {\n if (!Array.isArray(rule)) {\n return entries;\n }\n\n const [fieldVar, value] = rule;\n\n if (!isFieldVar(fieldVar) || !isAttributeConditionValue(value)) {\n return entries;\n }\n\n entries.push({ operator, fieldVar, value });\n\n return entries;\n }, []);\n};\n\nexport const getFirstVisibleConditionEntry = (condition?: AttributeConditions | null) =>\n getVisibleConditionEntries(condition)[0] ?? null;\n\nexport const checkDependentRows = (\n contentTypes: ContentTypes,\n fieldName: string\n): DependentRow[] => {\n const dependentRows: DependentRow[] = [];\n\n Object.entries(contentTypes).forEach(([contentTypeUid, contentType]) => {\n if (contentType.attributes !== undefined) {\n // Handle both array and object formats of attributes\n const attributes = Array.isArray(contentType.attributes)\n ? contentType.attributes.reduce<Record<string, AnyAttribute>>((acc, attr, index) => {\n acc[index.toString()] = attr;\n return acc;\n }, {})\n : contentType.attributes;\n\n Object.entries(attributes).forEach(([attrName, attr]) => {\n getVisibleConditionEntries(attr.conditions).forEach(({ fieldVar }) => {\n // Check if this condition references our field\n if (fieldVar.var === fieldName) {\n dependentRows.push({\n contentTypeUid,\n contentType: contentType.info.displayName,\n attribute: attr.name || attrName,\n });\n }\n });\n });\n }\n });\n return dependentRows;\n};\n\nexport const formatCondition = (\n condition: AttributeConditions,\n availableFields: Array<{ name: string; type: string }>,\n attributeName: string\n): string => {\n const conditionEntry = getFirstVisibleConditionEntry(condition);\n\n if (conditionEntry === null) {\n return '';\n }\n\n const { operator, fieldVar, value } = conditionEntry;\n\n const dependsOnField = availableFields.find((field) => field.name === fieldVar.var);\n const dependsOnFieldName = dependsOnField ? dependsOnField.name : fieldVar.var;\n\n const operatorText = operator === '==' ? 'is' : 'is not';\n const valueText = String(value);\n const actionText = operator === '==' ? 'Show' : 'Hide';\n\n return `If ${dependsOnFieldName} ${operatorText} ${valueText}, then ${actionText} ${attributeName}`;\n};\n\nexport const getAvailableConditionFields = (\n attributes: AnyAttribute[],\n currentFieldName: string\n) => {\n return attributes\n .filter((attr) => {\n // Only include boolean and enum fields\n const isCorrectType = attr.type === 'boolean' || attr.type === 'enumeration';\n // Exclude the current field to prevent self-referential conditions\n const isNotCurrentField = attr.name !== currentFieldName;\n return isCorrectType && isNotCurrentField;\n })\n .map((attr) => ({\n name: attr.name,\n type: attr.type,\n enum: attr.type === 'enumeration' ? attr.enum : undefined,\n }));\n};\n"],"names":["isRecord","value","Array","isArray","isFieldVar","var","isAttributeConditionValue","getVisibleConditionEntries","condition","visible","Object","entries","reduce","operator","rule","fieldVar","push","getFirstVisibleConditionEntry","checkDependentRows","contentTypes","fieldName","dependentRows","forEach","contentTypeUid","contentType","attributes","undefined","acc","attr","index","toString","attrName","conditions","info","displayName","attribute","name","getAvailableConditionFields","currentFieldName","filter","isCorrectType","type","isNotCurrentField","map","enum"],"mappings":"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"}
|