@opencrvs/toolkit 1.8.0-rc.fe799b0 → 1.8.0-rc.feaeeb7
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.
@@ -0,0 +1,18 @@
|
|
1
|
+
import { FieldValue } from './FieldValue';
|
2
|
+
export type DefaultValue = FieldValue | MetaFieldsDotted | Record<string, MetaFieldsDotted | FieldValue>;
|
3
|
+
export declare function isTemplateVariable(value: DefaultValue): value is MetaFieldsDotted;
|
4
|
+
export declare function isFieldValue(value: DefaultValue): value is FieldValue;
|
5
|
+
export declare function isFieldValueWithoutTemplates(value: DefaultValue): value is FieldValue;
|
6
|
+
export declare function isDefaultValue(value: any): value is DefaultValue;
|
7
|
+
export interface MetaFields {
|
8
|
+
$user: {
|
9
|
+
province: string;
|
10
|
+
district: string;
|
11
|
+
};
|
12
|
+
}
|
13
|
+
type DottedKeys<T, Prefix extends string = ''> = {
|
14
|
+
[K in keyof T]: T[K] extends Record<string, string> ? DottedKeys<T[K], `${Prefix}${K & string}.`> : `${Prefix}${K & string}`;
|
15
|
+
}[keyof T];
|
16
|
+
export type MetaFieldsDotted = DottedKeys<MetaFields>;
|
17
|
+
export {};
|
18
|
+
//# sourceMappingURL=TemplateConfig.d.ts.map
|
@@ -28,6 +28,7 @@ export * from './FieldTypeMapping';
|
|
28
28
|
export * from './Conditional';
|
29
29
|
export * from './AdvancedSearchConfig';
|
30
30
|
export * from './test.utils';
|
31
|
+
export * from './TemplateConfig';
|
31
32
|
export * from '../conditionals/conditionals';
|
32
33
|
export * from '../conditionals/validate';
|
33
34
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/events/index.js
CHANGED
@@ -139,10 +139,13 @@ __export(events_exports, {
|
|
139
139
|
isCheckboxFieldType: () => isCheckboxFieldType,
|
140
140
|
isCountryFieldType: () => isCountryFieldType,
|
141
141
|
isDateFieldType: () => isDateFieldType,
|
142
|
+
isDefaultValue: () => isDefaultValue,
|
142
143
|
isDividerFieldType: () => isDividerFieldType,
|
143
144
|
isEmailFieldType: () => isEmailFieldType,
|
144
145
|
isFacilityFieldType: () => isFacilityFieldType,
|
145
146
|
isFieldEnabled: () => isFieldEnabled,
|
147
|
+
isFieldValue: () => isFieldValue,
|
148
|
+
isFieldValueWithoutTemplates: () => isFieldValueWithoutTemplates,
|
146
149
|
isFieldVisible: () => isFieldVisible,
|
147
150
|
isFileFieldType: () => isFileFieldType,
|
148
151
|
isFileFieldWithOptionType: () => isFileFieldWithOptionType,
|
@@ -154,6 +157,7 @@ __export(events_exports, {
|
|
154
157
|
isRadioGroupFieldType: () => isRadioGroupFieldType,
|
155
158
|
isSelectFieldType: () => isSelectFieldType,
|
156
159
|
isSignatureFieldType: () => isSignatureFieldType,
|
160
|
+
isTemplateVariable: () => isTemplateVariable,
|
157
161
|
isTextAreaFieldType: () => isTextAreaFieldType,
|
158
162
|
isTextFieldType: () => isTextFieldType,
|
159
163
|
isUndeclaredDraft: () => isUndeclaredDraft,
|
@@ -3657,3 +3661,33 @@ var eventQueryDataGenerator = (overrides = {}) => ({
|
|
3657
3661
|
},
|
3658
3662
|
trackingId: overrides.trackingId ?? "M3F8YQ"
|
3659
3663
|
});
|
3664
|
+
|
3665
|
+
// ../commons/src/events/TemplateConfig.ts
|
3666
|
+
function isTemplateVariable(value) {
|
3667
|
+
return typeof value === "string" && value.startsWith("$");
|
3668
|
+
}
|
3669
|
+
function isFieldValue(value) {
|
3670
|
+
return FieldValue.safeParse(value).success;
|
3671
|
+
}
|
3672
|
+
function isFieldValueWithoutTemplates(value) {
|
3673
|
+
if (isTemplateVariable(value)) {
|
3674
|
+
return false;
|
3675
|
+
}
|
3676
|
+
if (typeof value === "object" && Object.values(value).some((val) => isTemplateVariable(val))) {
|
3677
|
+
return false;
|
3678
|
+
}
|
3679
|
+
return true;
|
3680
|
+
}
|
3681
|
+
function isDefaultValue(value) {
|
3682
|
+
if (!value) return false;
|
3683
|
+
if (isFieldValue(value)) {
|
3684
|
+
return true;
|
3685
|
+
}
|
3686
|
+
if (isTemplateVariable(value)) {
|
3687
|
+
return true;
|
3688
|
+
}
|
3689
|
+
if (typeof value === "object" && Object.values(value).every((v) => typeof v === "object" && v !== null)) {
|
3690
|
+
return Object.values(value).every((v) => isDefaultValue(v));
|
3691
|
+
}
|
3692
|
+
return false;
|
3693
|
+
}
|