@formio/js 5.1.0-dev.6109.79f22ad → 5.1.0-dev.6112.1314654
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 +7 -0
- package/dist/formio.builder.css +1 -0
- package/dist/formio.builder.min.css +1 -1
- package/dist/formio.form.css +1 -0
- package/dist/formio.form.js +119 -152
- package/dist/formio.form.min.css +1 -1
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.css +1 -0
- package/dist/formio.full.js +126 -159
- package/dist/formio.full.min.css +1 -1
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.js +66 -55
- package/dist/formio.min.js +1 -1
- package/dist/formio.utils.js +76 -76
- package/dist/formio.utils.min.js +1 -1
- package/lib/cjs/Element.d.ts +2 -1
- package/lib/cjs/Element.js +18 -39
- package/lib/cjs/EventEmitter.js +2 -25
- package/lib/cjs/Form.js +2 -25
- package/lib/cjs/PDF.js +1 -1
- package/lib/cjs/PDFBuilder.d.ts +1 -0
- package/lib/cjs/PDFBuilder.js +10 -11
- package/lib/cjs/Webform.d.ts +2 -2
- package/lib/cjs/Webform.js +10 -10
- package/lib/cjs/WebformBuilder.d.ts +1 -1
- package/lib/cjs/WebformBuilder.js +45 -21
- package/lib/cjs/Wizard.d.ts +1 -2
- package/lib/cjs/Wizard.js +18 -24
- package/lib/cjs/WizardBuilder.js +1 -1
- package/lib/cjs/components/Components.js +7 -1
- package/lib/cjs/components/_classes/component/Component.d.ts +0 -1
- package/lib/cjs/components/_classes/component/Component.js +70 -64
- package/lib/cjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
- package/lib/cjs/components/_classes/component/editForm/Component.edit.data.d.ts +7 -0
- package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +1 -0
- package/lib/cjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
- package/lib/cjs/components/_classes/componentModal/ComponentModal.js +1 -1
- package/lib/cjs/components/_classes/input/Input.d.ts +1 -1
- package/lib/cjs/components/_classes/input/Input.js +3 -3
- package/lib/cjs/components/_classes/list/ListComponent.js +1 -1
- package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +1 -0
- package/lib/cjs/components/_classes/nested/NestedComponent.js +19 -9
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
- package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +1 -1
- package/lib/cjs/components/address/Address.js +2 -2
- package/lib/cjs/components/alert/Alert.js +1 -1
- package/lib/cjs/components/button/Button.js +1 -1
- package/lib/cjs/components/checkbox/Checkbox.js +1 -1
- package/lib/cjs/components/container/Container.js +1 -1
- package/lib/cjs/components/currency/Currency.js +1 -1
- package/lib/cjs/components/datagrid/DataGrid.js +5 -1
- package/lib/cjs/components/datamap/DataMap.js +7 -2
- package/lib/cjs/components/datetime/DateTime.d.ts +1 -1
- package/lib/cjs/components/datetime/DateTime.js +15 -13
- package/lib/cjs/components/day/Day.js +2 -2
- package/lib/cjs/components/editgrid/EditGrid.d.ts +0 -1
- package/lib/cjs/components/editgrid/EditGrid.js +1 -9
- package/lib/cjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
- package/lib/cjs/components/fieldset/Fieldset.js +1 -0
- package/lib/cjs/components/file/File.js +1 -1
- package/lib/cjs/components/form/Form.js +14 -2
- package/lib/cjs/components/form/editForm/Form.edit.form.js +4 -3
- package/lib/cjs/components/number/Number.js +1 -1
- package/lib/cjs/components/panel/Panel.js +1 -1
- package/lib/cjs/components/radio/Radio.d.ts +9 -0
- package/lib/cjs/components/radio/Radio.js +20 -10
- package/lib/cjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +1 -1
- package/lib/cjs/components/select/Select.js +7 -3
- package/lib/cjs/components/select/editForm/Select.edit.data.js +1 -1
- package/lib/cjs/components/selectboxes/SelectBoxes.d.ts +6 -0
- package/lib/cjs/components/selectboxes/SelectBoxes.js +1 -1
- package/lib/cjs/components/signature/Signature.js +1 -1
- package/lib/cjs/components/survey/Survey.js +1 -1
- package/lib/cjs/components/tags/Tags.js +1 -1
- package/lib/cjs/components/textarea/TextArea.js +9 -4
- package/lib/cjs/components/textfield/TextField.js +13 -31
- package/lib/cjs/components/time/Time.js +1 -1
- package/lib/cjs/formio.form.js +5 -5
- package/lib/cjs/providers/storage/uploadAdapter.js +1 -1
- package/lib/cjs/providers/storage/url.js +7 -3
- package/lib/cjs/translations/en.d.ts +1 -232
- package/lib/cjs/translations/en.js +4 -2
- package/lib/cjs/utils/Evaluator.d.ts +20 -6
- package/lib/cjs/utils/Evaluator.js +38 -15
- package/lib/cjs/utils/builder.js +5 -5
- package/lib/cjs/utils/conditionOperators/IsEqualTo.js +3 -3
- package/lib/cjs/utils/formUtils.d.ts +2 -2
- package/lib/cjs/utils/index.d.ts +169 -2
- package/lib/cjs/utils/index.js +22 -2
- package/lib/cjs/utils/utils.d.ts +22 -37
- package/lib/cjs/utils/utils.js +63 -138
- package/lib/cjs/widgets/CalendarWidget.d.ts +1 -8
- package/lib/cjs/widgets/CalendarWidget.js +17 -43
- package/lib/mjs/Element.d.ts +2 -1
- package/lib/mjs/Element.js +11 -9
- package/lib/mjs/EventEmitter.js +2 -2
- package/lib/mjs/Form.js +1 -1
- package/lib/mjs/PDF.js +1 -1
- package/lib/mjs/PDFBuilder.d.ts +1 -0
- package/lib/mjs/PDFBuilder.js +9 -10
- package/lib/mjs/Webform.d.ts +2 -2
- package/lib/mjs/Webform.js +8 -8
- package/lib/mjs/WebformBuilder.d.ts +1 -1
- package/lib/mjs/WebformBuilder.js +36 -13
- package/lib/mjs/Wizard.d.ts +1 -2
- package/lib/mjs/Wizard.js +17 -23
- package/lib/mjs/WizardBuilder.js +1 -1
- package/lib/mjs/components/Components.js +7 -1
- package/lib/mjs/components/_classes/component/Component.d.ts +0 -1
- package/lib/mjs/components/_classes/component/Component.js +42 -13
- package/lib/mjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
- package/lib/mjs/components/_classes/component/editForm/Component.edit.data.d.ts +7 -0
- package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +1 -0
- package/lib/mjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
- package/lib/mjs/components/_classes/componentModal/ComponentModal.js +1 -1
- package/lib/mjs/components/_classes/input/Input.d.ts +1 -1
- package/lib/mjs/components/_classes/input/Input.js +3 -3
- package/lib/mjs/components/_classes/list/ListComponent.js +1 -1
- package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +1 -0
- package/lib/mjs/components/_classes/nested/NestedComponent.js +19 -9
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
- package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +1 -1
- package/lib/mjs/components/address/Address.js +2 -2
- package/lib/mjs/components/alert/Alert.js +1 -1
- package/lib/mjs/components/button/Button.js +1 -1
- package/lib/mjs/components/checkbox/Checkbox.js +1 -1
- package/lib/mjs/components/container/Container.js +1 -1
- package/lib/mjs/components/currency/Currency.js +1 -1
- package/lib/mjs/components/datagrid/DataGrid.js +5 -1
- package/lib/mjs/components/datamap/DataMap.js +7 -2
- package/lib/mjs/components/datetime/DateTime.d.ts +1 -1
- package/lib/mjs/components/datetime/DateTime.js +15 -13
- package/lib/mjs/components/day/Day.js +2 -2
- package/lib/mjs/components/editgrid/EditGrid.d.ts +0 -1
- package/lib/mjs/components/editgrid/EditGrid.js +1 -9
- package/lib/mjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
- package/lib/mjs/components/fieldset/Fieldset.js +1 -0
- package/lib/mjs/components/file/File.js +1 -1
- package/lib/mjs/components/form/Form.js +13 -2
- package/lib/mjs/components/form/editForm/Form.edit.form.js +3 -2
- package/lib/mjs/components/number/Number.js +1 -1
- package/lib/mjs/components/panel/Panel.js +1 -1
- package/lib/mjs/components/radio/Radio.d.ts +9 -0
- package/lib/mjs/components/radio/Radio.js +20 -10
- package/lib/mjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +1 -1
- package/lib/mjs/components/select/Select.js +7 -3
- package/lib/mjs/components/select/editForm/Select.edit.data.js +1 -1
- package/lib/mjs/components/selectboxes/SelectBoxes.d.ts +6 -0
- package/lib/mjs/components/selectboxes/SelectBoxes.js +1 -1
- package/lib/mjs/components/signature/Signature.js +1 -1
- package/lib/mjs/components/survey/Survey.js +1 -1
- package/lib/mjs/components/tags/Tags.js +1 -1
- package/lib/mjs/components/textarea/TextArea.js +9 -4
- package/lib/mjs/components/textfield/TextField.js +7 -2
- package/lib/mjs/components/time/Time.js +1 -1
- package/lib/mjs/formio.form.js +3 -3
- package/lib/mjs/providers/storage/uploadAdapter.js +1 -1
- package/lib/mjs/providers/storage/url.js +7 -3
- package/lib/mjs/translations/en.d.ts +1 -232
- package/lib/mjs/translations/en.js +8 -47
- package/lib/mjs/utils/Evaluator.d.ts +20 -6
- package/lib/mjs/utils/Evaluator.js +31 -13
- package/lib/mjs/utils/builder.js +1 -1
- package/lib/mjs/utils/conditionOperators/IsEqualTo.js +1 -1
- package/lib/mjs/utils/formUtils.d.ts +2 -2
- package/lib/mjs/utils/index.d.ts +169 -2
- package/lib/mjs/utils/index.js +18 -1
- package/lib/mjs/utils/utils.d.ts +22 -37
- package/lib/mjs/utils/utils.js +57 -113
- package/lib/mjs/widgets/CalendarWidget.d.ts +1 -8
- package/lib/mjs/widgets/CalendarWidget.js +17 -43
- package/package.json +5 -3
- package/lib/cjs/i18n.d.ts +0 -13
- package/lib/cjs/i18n.js +0 -19
- package/lib/cjs/utils/i18n.d.ts +0 -19
- package/lib/cjs/utils/i18n.js +0 -120
- package/lib/mjs/i18n.d.ts +0 -13
- package/lib/mjs/i18n.js +0 -14
- package/lib/mjs/utils/i18n.d.ts +0 -19
- package/lib/mjs/utils/i18n.js +0 -112
package/lib/mjs/utils/index.d.ts
CHANGED
|
@@ -1,3 +1,170 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from "./utils";
|
|
2
|
+
export * from "./formUtils";
|
|
2
3
|
export default FormioUtils;
|
|
3
|
-
|
|
4
|
+
declare const FormioUtils: {
|
|
5
|
+
Evaluator: import("./Evaluator").DefaultEvaluator;
|
|
6
|
+
interpolate: typeof interpolate;
|
|
7
|
+
ConditionOperators: {
|
|
8
|
+
[x: string]: typeof import("./conditionOperators/IsEqualTo").default | typeof import("./conditionOperators/DateGreaterThan").default;
|
|
9
|
+
};
|
|
10
|
+
_: any;
|
|
11
|
+
moment: typeof moment;
|
|
12
|
+
flattenComponents: typeof import("@formio/core/lib/utils/formUtil").flattenComponents;
|
|
13
|
+
guid: typeof import("@formio/core/lib/utils/formUtil").guid;
|
|
14
|
+
uniqueName: typeof import("@formio/core/lib/utils/formUtil").uniqueName;
|
|
15
|
+
MODEL_TYPES_OF_KNOWN_COMPONENTS: {
|
|
16
|
+
nestedArray: string[];
|
|
17
|
+
nestedDataArray: string[];
|
|
18
|
+
dataObject: string[];
|
|
19
|
+
object: string[];
|
|
20
|
+
map: string[];
|
|
21
|
+
content: string[];
|
|
22
|
+
string: string[];
|
|
23
|
+
number: string[];
|
|
24
|
+
boolean: string[];
|
|
25
|
+
none: string[];
|
|
26
|
+
any: string[];
|
|
27
|
+
};
|
|
28
|
+
getModelType: typeof import("@formio/core/lib/utils/formUtil").getModelType;
|
|
29
|
+
getComponentPath: any;
|
|
30
|
+
setComponentScope: typeof import("@formio/core/lib/utils/formUtil").setComponentScope;
|
|
31
|
+
resetComponentScope: typeof import("@formio/core/lib/utils/formUtil").resetComponentScope;
|
|
32
|
+
isComponentNestedDataType: typeof import("@formio/core/lib/utils/formUtil").isComponentNestedDataType;
|
|
33
|
+
componentPath: typeof import("@formio/core/lib/utils/formUtil").componentPath;
|
|
34
|
+
getComponentPaths: typeof import("@formio/core/lib/utils/formUtil").getComponentPaths;
|
|
35
|
+
componentMatches: typeof import("@formio/core/lib/utils/formUtil").componentMatches;
|
|
36
|
+
getBestMatch: typeof import("@formio/core/lib/utils/formUtil").getBestMatch;
|
|
37
|
+
getComponentFromPath: typeof import("@formio/core/lib/utils/formUtil").getComponentFromPath;
|
|
38
|
+
getComponentValue: typeof import("@formio/core/lib/utils/formUtil").getComponentValue;
|
|
39
|
+
findComponents: typeof import("@formio/core/lib/utils/formUtil").findComponents;
|
|
40
|
+
eachComponentDataAsync: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined) => Promise<void>;
|
|
41
|
+
eachComponentData: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined) => void;
|
|
42
|
+
getComponentKey: typeof import("@formio/core/lib/utils/formUtil").getComponentKey;
|
|
43
|
+
getContextualRowPath: typeof import("@formio/core/lib/utils/formUtil").getContextualRowPath;
|
|
44
|
+
getContextualRowData: typeof import("@formio/core/lib/utils/formUtil").getContextualRowData;
|
|
45
|
+
componentInfo: typeof import("@formio/core/lib/utils/formUtil").componentInfo;
|
|
46
|
+
eachComponent: typeof import("@formio/core/lib/utils/formUtil").eachComponent;
|
|
47
|
+
eachComponentAsync: typeof import("@formio/core/lib/utils/formUtil").eachComponentAsync;
|
|
48
|
+
getComponentData: typeof import("@formio/core/lib/utils/formUtil").getComponentData;
|
|
49
|
+
getComponentActualValue: any;
|
|
50
|
+
isLayoutComponent: typeof import("@formio/core/lib/utils/formUtil").isLayoutComponent;
|
|
51
|
+
matchComponent: typeof import("@formio/core/lib/utils/formUtil").matchComponent;
|
|
52
|
+
getComponent: typeof import("@formio/core/lib/utils/formUtil").getComponent;
|
|
53
|
+
searchComponents: typeof import("@formio/core/lib/utils/formUtil").searchComponents;
|
|
54
|
+
removeComponent: typeof import("@formio/core/lib/utils/formUtil").removeComponent;
|
|
55
|
+
hasCondition: typeof import("@formio/core/lib/utils/formUtil").hasCondition;
|
|
56
|
+
parseFloatExt: typeof import("@formio/core/lib/utils/formUtil").parseFloatExt;
|
|
57
|
+
formatAsCurrency: typeof import("@formio/core/lib/utils/formUtil").formatAsCurrency;
|
|
58
|
+
escapeRegExCharacters: typeof import("@formio/core/lib/utils/formUtil").escapeRegExCharacters;
|
|
59
|
+
getValue: typeof import("@formio/core/lib/utils/formUtil").getValue;
|
|
60
|
+
getStrings: typeof import("@formio/core/lib/utils/formUtil").getStrings;
|
|
61
|
+
generateFormChange: typeof import("@formio/core/lib/utils/formUtil").generateFormChange;
|
|
62
|
+
applyFormChanges: typeof import("@formio/core/lib/utils/formUtil").applyFormChanges;
|
|
63
|
+
findComponent: typeof import("@formio/core/lib/utils/formUtil").findComponent;
|
|
64
|
+
getEmptyValue: typeof import("@formio/core/lib/utils/formUtil").getEmptyValue;
|
|
65
|
+
isComponentDataEmpty: typeof import("@formio/core/lib/utils/formUtil").isComponentDataEmpty;
|
|
66
|
+
isSelectResourceWithObjectValue: typeof import("@formio/core/lib/utils/formUtil").isSelectResourceWithObjectValue;
|
|
67
|
+
compareSelectResourceWithObjectTypeValues: typeof import("@formio/core/lib/utils/formUtil").compareSelectResourceWithObjectTypeValues;
|
|
68
|
+
getItemTemplateKeys: typeof import("@formio/core/lib/utils/formUtil").getItemTemplateKeys;
|
|
69
|
+
evaluate(func: string | object | Function, args: any, ret: string, interpolate: boolean, options?: import("@formio/core").EvaluatorOptions): any;
|
|
70
|
+
getRandomComponentId(): string;
|
|
71
|
+
getPropertyValue(style: CSSStyleDeclaration, prop: string): number;
|
|
72
|
+
getElementRect(element: HTMLElement): {
|
|
73
|
+
x: number;
|
|
74
|
+
y: number;
|
|
75
|
+
width: number;
|
|
76
|
+
height: number;
|
|
77
|
+
};
|
|
78
|
+
getScriptPlugin(property: string): any;
|
|
79
|
+
boolValue(value: string | boolean): boolean;
|
|
80
|
+
isMongoId(text: string): boolean;
|
|
81
|
+
checkCalculated(component: import("@formio/core").Component, submission: import("@formio/core").Submission, rowData: any): void;
|
|
82
|
+
checkSimpleConditional(component: any, condition: any, row: any, data: any, instance: any): boolean;
|
|
83
|
+
checkCustomConditional(component: import("@formio/core").Component, custom: string, row: any, data: any, form: import("@formio/core").Form, variable: string, onError: any, instance: any): any;
|
|
84
|
+
checkJsonConditional(component: import("@formio/core").Component, json: import("@formio/core").JSONConditional, row: any, data: any, form: import("@formio/core").Form, onError: any): boolean;
|
|
85
|
+
checkCondition(component: import("@formio/core").Component, row: any, data: any, form: import("@formio/core").Form, instance: any): boolean;
|
|
86
|
+
checkTrigger(component: import("@formio/core").Component, trigger: any, row: import("@formio/core").DataObject, data: import("@formio/core").DataObject, form: import("@formio/core").Form, instance: any): boolean;
|
|
87
|
+
setActionProperty(component: import("@formio/core").Component, action: any, result: string, row: import("@formio/core").DataObject, data: import("@formio/core").DataObject, instance: any): import("@formio/core").Component;
|
|
88
|
+
removeHTML(str: string): string;
|
|
89
|
+
unescapeHTML(str: string): string;
|
|
90
|
+
convertStringToHTMLElement(str: string, selector: string): HTMLElement;
|
|
91
|
+
getDateSetting(date: string | Date): import("dayjs").Dayjs | null;
|
|
92
|
+
isValidDate(date: string | Date): boolean;
|
|
93
|
+
currentTimezone(): string;
|
|
94
|
+
offsetDate(date: Date, timezone: string): {
|
|
95
|
+
date: Date;
|
|
96
|
+
abbr: string;
|
|
97
|
+
};
|
|
98
|
+
shouldHandleTimezone(timezone: string): boolean;
|
|
99
|
+
dayjsDate(value: string | Date, format: string, timezone: string, options: object): import("dayjs").Dayjs;
|
|
100
|
+
formatDate(value: string | Date, format: string, timezone: string, flatPickrInputFormat: string): string;
|
|
101
|
+
formatOffset(formatFn: Function, date: string | Date, format: string, timezone: string): string;
|
|
102
|
+
getLocaleDateFormatInfo(locale: Intl.LocalesArgument): object;
|
|
103
|
+
convertFormatToFlatpickr(format: string): string;
|
|
104
|
+
convertFormatToDayjs(format: string): string;
|
|
105
|
+
convertFormatToMask(format: string): string;
|
|
106
|
+
getInputMask(mask: string, placeholderChar: string): any[];
|
|
107
|
+
unmaskValue(value: string, mask: string, placeholderChar: string): string;
|
|
108
|
+
matchInputMask(value: string, inputMask: string): boolean;
|
|
109
|
+
getNumberSeparators(lang?: string): {
|
|
110
|
+
delimiter: string;
|
|
111
|
+
decimalSeparator: string;
|
|
112
|
+
};
|
|
113
|
+
getNumberDecimalLimit(component: import("@formio/core").Component, defaultLimit: number): number;
|
|
114
|
+
getCurrencyAffixes({ currency, decimalLimit, decimalSeparator, lang, }: {
|
|
115
|
+
currency: string;
|
|
116
|
+
decimalLimit: number;
|
|
117
|
+
decimalSeparator: string;
|
|
118
|
+
lang: string;
|
|
119
|
+
}): {
|
|
120
|
+
prefix: string;
|
|
121
|
+
suffix: string;
|
|
122
|
+
};
|
|
123
|
+
fieldData(data: import("@formio/core").DataObject, component: import("@formio/core").Component): any;
|
|
124
|
+
delay(fn: Function, delay?: number, ...args: any[]): any;
|
|
125
|
+
iterateKey(key: string): string;
|
|
126
|
+
uniqueKey(map: Record<string, string>, base: string): string;
|
|
127
|
+
bootstrapVersion(options: {
|
|
128
|
+
bootstrap: string;
|
|
129
|
+
}): number;
|
|
130
|
+
unfold(e: any): any;
|
|
131
|
+
withSwitch(a: any, b: any): Functions[];
|
|
132
|
+
observeOverload(callback: Function, options?: {
|
|
133
|
+
limit: number;
|
|
134
|
+
delay: number;
|
|
135
|
+
}): Function;
|
|
136
|
+
getContextComponents(context: any, excludeNested: boolean, excludedTypes?: string[]): any[];
|
|
137
|
+
getContextButtons(context: any): any[];
|
|
138
|
+
translateHTMLTemplate(template: string, translate: Function): string;
|
|
139
|
+
sanitize(string: string, options: any): string;
|
|
140
|
+
fastCloneDeep(obj: any): any;
|
|
141
|
+
isInputComponent(componentJson: import("@formio/core").Component): boolean;
|
|
142
|
+
getArrayFromComponentPath(pathStr: string): string[];
|
|
143
|
+
isChildOf(child: any, parent: any): boolean;
|
|
144
|
+
getStringFromComponentPath(path: number[]): string;
|
|
145
|
+
round(number: number, precision: number): string;
|
|
146
|
+
getIEBrowserVersion(): number | null;
|
|
147
|
+
getBrowserInfo(): object;
|
|
148
|
+
getComponentPathWithoutIndicies(path?: string): string;
|
|
149
|
+
getDataParentComponent(componentInstance: Component): any;
|
|
150
|
+
isPromise(value: any): boolean;
|
|
151
|
+
getFocusableElements(element: HTMLElement): NodeList<HTMLElement>;
|
|
152
|
+
getComponentSavedTypes(fullSchema: import("@formio/core").Component): string[] | null;
|
|
153
|
+
hasEncodedTimezone(value: string): boolean;
|
|
154
|
+
firstNonNil: any;
|
|
155
|
+
componentValueTypes: {
|
|
156
|
+
number: string;
|
|
157
|
+
string: string;
|
|
158
|
+
boolean: string;
|
|
159
|
+
array: string;
|
|
160
|
+
object: string;
|
|
161
|
+
date: string;
|
|
162
|
+
any: string;
|
|
163
|
+
};
|
|
164
|
+
interpolateErrors: (component: Component, errors: FieldError[], interpolateFn: Function) => [];
|
|
165
|
+
};
|
|
166
|
+
import { Evaluator } from './Evaluator';
|
|
167
|
+
import { registerEvaluator } from './Evaluator';
|
|
168
|
+
import { interpolate } from './Evaluator';
|
|
169
|
+
import moment from 'moment';
|
|
170
|
+
export { FormioUtils as Utils, Evaluator, registerEvaluator };
|
package/lib/mjs/utils/index.js
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as utils from './utils';
|
|
2
|
+
import * as formUtils from './formUtils';
|
|
3
|
+
import { Evaluator, registerEvaluator, interpolate } from './Evaluator';
|
|
4
|
+
import ConditionOperators from './conditionOperators';
|
|
5
|
+
import _ from 'lodash';
|
|
6
|
+
import moment from 'moment';
|
|
7
|
+
const FormioUtils = {
|
|
8
|
+
...utils,
|
|
9
|
+
...formUtils,
|
|
10
|
+
Evaluator,
|
|
11
|
+
interpolate,
|
|
12
|
+
ConditionOperators,
|
|
13
|
+
_,
|
|
14
|
+
moment
|
|
15
|
+
};
|
|
2
16
|
if (typeof global === 'object') {
|
|
3
17
|
global.FormioUtils = FormioUtils;
|
|
4
18
|
}
|
|
5
19
|
export { FormioUtils as Utils };
|
|
20
|
+
export { Evaluator, registerEvaluator };
|
|
21
|
+
export * from './utils';
|
|
22
|
+
export * from './formUtils';
|
|
6
23
|
export default FormioUtils;
|
package/lib/mjs/utils/utils.d.ts
CHANGED
|
@@ -164,9 +164,9 @@ export function guid(): string;
|
|
|
164
164
|
/**
|
|
165
165
|
* Return a translated date setting.
|
|
166
166
|
* @param {string|Date} date - The date to translate.
|
|
167
|
-
* @returns {(null|
|
|
167
|
+
* @returns {(null|dayjs.Dayjs)} - The translated date.
|
|
168
168
|
*/
|
|
169
|
-
export function getDateSetting(date: string | Date): (null |
|
|
169
|
+
export function getDateSetting(date: string | Date): (null | dayjs.Dayjs);
|
|
170
170
|
/**
|
|
171
171
|
* Returns true if the date is a valid date. False otherwise.
|
|
172
172
|
* @param {Date|string} date - The date to check for validity.
|
|
@@ -182,56 +182,45 @@ export function currentTimezone(): string;
|
|
|
182
182
|
* Get an offset date provided a date object and timezone object.
|
|
183
183
|
* @param {Date} date - The date to offset.
|
|
184
184
|
* @param {string} timezone - The timezone to offset the date to.
|
|
185
|
-
* @returns {Date} - The offset date.
|
|
185
|
+
* @returns {{date: Date, abbr: string}} - The offset date.
|
|
186
186
|
*/
|
|
187
|
-
export function offsetDate(date: Date, timezone: string):
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
*/
|
|
192
|
-
export function zonesLoaded(): boolean;
|
|
187
|
+
export function offsetDate(date: Date, timezone: string): {
|
|
188
|
+
date: Date;
|
|
189
|
+
abbr: string;
|
|
190
|
+
};
|
|
193
191
|
/**
|
|
194
|
-
* Returns if we should
|
|
192
|
+
* Returns if we should handle a timezone difference.
|
|
195
193
|
* @param {string} timezone - The timezone to check if we should load the zones.
|
|
196
|
-
* @returns {boolean} - TRUE if we should
|
|
197
|
-
*/
|
|
198
|
-
export function shouldLoadZones(timezone: string): boolean;
|
|
199
|
-
/**
|
|
200
|
-
* Externally load the timezone data.
|
|
201
|
-
* @param {string} url - The URL to load the timezone data from.
|
|
202
|
-
* @param {string} timezone - The timezone to load.
|
|
203
|
-
* @returns {Promise<any> | *} - Resolves when the zones for this timezone are loaded.
|
|
194
|
+
* @returns {boolean} - TRUE if we should handle timezones; FALSE otherwise.
|
|
204
195
|
*/
|
|
205
|
-
export function
|
|
196
|
+
export function shouldHandleTimezone(timezone: string): boolean;
|
|
206
197
|
/**
|
|
207
|
-
* Get the
|
|
208
|
-
* @param {string|Date} value - The value to convert into a
|
|
198
|
+
* Get the Dayjs date object for translating dates with timezones.
|
|
199
|
+
* @param {string|Date} value - The value to convert into a dayjs date.
|
|
209
200
|
* @param {string} format - The format to convert the date to.
|
|
210
201
|
* @param {string} timezone - The timezone to convert the date to.
|
|
211
202
|
* @param {object} options - The options object
|
|
212
|
-
* @returns {
|
|
203
|
+
* @returns {dayjs.Dayjs} - The dayjs date object.
|
|
213
204
|
*/
|
|
214
|
-
export function
|
|
205
|
+
export function dayjsDate(value: string | Date, format: string, timezone: string, options: object): dayjs.Dayjs;
|
|
215
206
|
/**
|
|
216
207
|
* Format a date provided a value, format, and timezone object.
|
|
217
|
-
* @param {string} timezonesUrl - The URL to load the timezone data from.
|
|
218
208
|
* @param {string|Date} value - The value to format.
|
|
219
209
|
* @param {string} format - The format to format the date to.
|
|
220
210
|
* @param {string} timezone - The timezone to format the date to.
|
|
221
211
|
* @param {string} flatPickrInputFormat - The format to use for flatpickr input.
|
|
222
212
|
* @returns {string} - The formatted date.
|
|
223
213
|
*/
|
|
224
|
-
export function formatDate(
|
|
214
|
+
export function formatDate(value: string | Date, format: string, timezone: string, flatPickrInputFormat: string): string;
|
|
225
215
|
/**
|
|
226
216
|
* Pass a format function to format within a timezone.
|
|
227
|
-
* @param {string} timezonesUrl - The URL to load the timezone data from.
|
|
228
217
|
* @param {Function} formatFn - The format function to use.
|
|
229
218
|
* @param {Date|string} date - The date to format.
|
|
230
219
|
* @param {string} format - The format to format the date to.
|
|
231
220
|
* @param {string} timezone - The timezone to format the date to.
|
|
232
221
|
* @returns {string} - The formatted date.
|
|
233
222
|
*/
|
|
234
|
-
export function formatOffset(
|
|
223
|
+
export function formatOffset(formatFn: Function, date: Date | string, format: string, timezone: string): string;
|
|
235
224
|
/**
|
|
236
225
|
* Returns the local date format information.
|
|
237
226
|
* @param {Intl.LocalesArgument} locale - The locale to get the date format for.
|
|
@@ -249,7 +238,7 @@ export function convertFormatToFlatpickr(format: string): string;
|
|
|
249
238
|
* @param {string} format - The format to convert.
|
|
250
239
|
* @returns {string} - The converted format.
|
|
251
240
|
*/
|
|
252
|
-
export function
|
|
241
|
+
export function convertFormatToDayjs(format: string): string;
|
|
253
242
|
/**
|
|
254
243
|
* Convert the format from the angular-datepicker module to mask format.
|
|
255
244
|
* @param {string} format - The format to convert.
|
|
@@ -414,15 +403,15 @@ export function fastCloneDeep(obj: any): any;
|
|
|
414
403
|
/**
|
|
415
404
|
* Returns if the component is an input component.
|
|
416
405
|
* @param {import('@formio/core').Component} componentJson - The JSON of a component.
|
|
417
|
-
* @returns {
|
|
406
|
+
* @returns {boolean} - TRUE if the component is an input component; FALSE otherwise.
|
|
418
407
|
*/
|
|
419
|
-
export function isInputComponent(componentJson: import('@formio/core').Component):
|
|
408
|
+
export function isInputComponent(componentJson: import('@formio/core').Component): boolean;
|
|
420
409
|
/**
|
|
421
410
|
* Takes a component path, and returns a component path array.
|
|
422
411
|
* @param {string} pathStr - The path string to convert to an array.
|
|
423
|
-
* @returns {
|
|
412
|
+
* @returns {Array<string>} - The array of paths.
|
|
424
413
|
*/
|
|
425
|
-
export function getArrayFromComponentPath(pathStr: string):
|
|
414
|
+
export function getArrayFromComponentPath(pathStr: string): Array<string>;
|
|
426
415
|
/**
|
|
427
416
|
* Returns true if the component is a child of the parent.
|
|
428
417
|
* @param {any} child - The child component to check.
|
|
@@ -499,7 +488,6 @@ export function getComponentSavedTypes(fullSchema: import('@formio/core').Compon
|
|
|
499
488
|
* @returns {boolean} if value has encoded timezone
|
|
500
489
|
*/
|
|
501
490
|
export function hasEncodedTimezone(value: string): boolean;
|
|
502
|
-
export * from "./formUtils";
|
|
503
491
|
/**
|
|
504
492
|
* Map values through unfold and return first non-nil value.
|
|
505
493
|
* @param {Array<T>} collection - The collection to map through unfold.;
|
|
@@ -516,7 +504,4 @@ export namespace componentValueTypes {
|
|
|
516
504
|
let any: string;
|
|
517
505
|
}
|
|
518
506
|
export function interpolateErrors(component: Component, errors: FieldError[], interpolateFn: Function): [];
|
|
519
|
-
import
|
|
520
|
-
import { Evaluator } from './Evaluator';
|
|
521
|
-
export const interpolate: typeof Evaluator.interpolate;
|
|
522
|
-
export { jsonLogic, ConditionOperators, moment, Evaluator, _ };
|
|
507
|
+
import dayjs from "dayjs";
|
package/lib/mjs/utils/utils.js
CHANGED
|
@@ -1,31 +1,18 @@
|
|
|
1
|
-
/* global jQuery */
|
|
2
1
|
import _ from 'lodash';
|
|
3
|
-
import jsonLogic from 'json-logic-js';
|
|
4
2
|
import moment from 'moment-timezone/moment-timezone';
|
|
5
3
|
import jtz from 'jstimezonedetect';
|
|
6
|
-
import { lodashOperators } from './jsonlogic/operators';
|
|
7
4
|
import dompurify from 'dompurify';
|
|
5
|
+
import dayjs from "dayjs";
|
|
6
|
+
import utc from 'dayjs/plugin/utc';
|
|
7
|
+
import timezone from 'dayjs/plugin/timezone';
|
|
8
|
+
import advancedFormat from 'dayjs/plugin/advancedFormat';
|
|
9
|
+
import { jsonLogic, convertShowToBoolean } from '@formio/core';
|
|
8
10
|
import { getValue } from './formUtils';
|
|
9
11
|
import { Evaluator } from './Evaluator';
|
|
10
12
|
import ConditionOperators from './conditionOperators';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
// Configure JsonLogic
|
|
15
|
-
lodashOperators.forEach((name) => jsonLogic.add_operation(`_${name}`, _[name]));
|
|
16
|
-
// Retrieve Any Date
|
|
17
|
-
jsonLogic.add_operation('getDate', (date) => {
|
|
18
|
-
return moment(date).toISOString();
|
|
19
|
-
});
|
|
20
|
-
// Set Relative Minimum Date
|
|
21
|
-
jsonLogic.add_operation('relativeMinDate', (relativeMinDate) => {
|
|
22
|
-
return moment().subtract(relativeMinDate, 'days').toISOString();
|
|
23
|
-
});
|
|
24
|
-
// Set Relative Maximum Date
|
|
25
|
-
jsonLogic.add_operation('relativeMaxDate', (relativeMaxDate) => {
|
|
26
|
-
return moment().add(relativeMaxDate, 'days').toISOString();
|
|
27
|
-
});
|
|
28
|
-
export { jsonLogic, ConditionOperators, moment };
|
|
13
|
+
dayjs.extend(timezone);
|
|
14
|
+
dayjs.extend(advancedFormat);
|
|
15
|
+
dayjs.extend(utc);
|
|
29
16
|
/**
|
|
30
17
|
* Evaluate a method.
|
|
31
18
|
* @param {Function|string|object} func - The function to evaluate.
|
|
@@ -211,7 +198,15 @@ export function checkSimpleConditional(component, condition, row, data, instance
|
|
|
211
198
|
return true;
|
|
212
199
|
}
|
|
213
200
|
const splittedConditionPath = conditionComponentPath.split('.');
|
|
214
|
-
const
|
|
201
|
+
const checkParentTypeInTree = (instance, componentType) => {
|
|
202
|
+
if (!instance?.parent) {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
return instance?.parent.type === componentType || checkParentTypeInTree(instance.parent, componentType);
|
|
206
|
+
};
|
|
207
|
+
const conditionalPaths = checkParentTypeInTree(instance, 'datagrid') || checkParentTypeInTree(instance, 'editgrid')
|
|
208
|
+
? []
|
|
209
|
+
: getConditionalPathsRecursive(splittedConditionPath, data);
|
|
215
210
|
if (conditionalPaths.length > 0) {
|
|
216
211
|
return conditionalPaths.map((path) => {
|
|
217
212
|
const value = getComponentActualValue(path, data, row);
|
|
@@ -325,7 +320,7 @@ function getRow(component, row, instance, conditional) {
|
|
|
325
320
|
}
|
|
326
321
|
const dataParent = getDataParentComponent(instance);
|
|
327
322
|
if (dataParent) {
|
|
328
|
-
const parentPath = dataParent.paths?.
|
|
323
|
+
const parentPath = dataParent.paths?.localPath;
|
|
329
324
|
const isTriggerCondtionComponentPath = condition.when || !condition.conditions
|
|
330
325
|
? condition.when?.startsWith(dataParent.paths?.localPath)
|
|
331
326
|
: _.some(condition.conditions, cond => cond.component.startsWith(dataParent.paths?.localPath));
|
|
@@ -505,7 +500,7 @@ export function guid() {
|
|
|
505
500
|
/**
|
|
506
501
|
* Return a translated date setting.
|
|
507
502
|
* @param {string|Date} date - The date to translate.
|
|
508
|
-
* @returns {(null|
|
|
503
|
+
* @returns {(null|dayjs.Dayjs)} - The translated date.
|
|
509
504
|
*/
|
|
510
505
|
export function getDateSetting(date) {
|
|
511
506
|
if (_.isNil(date) || _.isNaN(date) || date === '') {
|
|
@@ -525,13 +520,13 @@ export function getDateSetting(date) {
|
|
|
525
520
|
try {
|
|
526
521
|
const value = Evaluator.evaluator(`return ${date};`, 'moment')(moment);
|
|
527
522
|
if (typeof value === 'string') {
|
|
528
|
-
dateSetting =
|
|
523
|
+
dateSetting = dayjs(value);
|
|
529
524
|
}
|
|
530
525
|
else if (typeof value.toDate === 'function') {
|
|
531
|
-
dateSetting =
|
|
526
|
+
dateSetting = dayjs(value.toDate().toUTCString());
|
|
532
527
|
}
|
|
533
528
|
else if (value instanceof Date) {
|
|
534
|
-
dateSetting =
|
|
529
|
+
dateSetting = dayjs(value);
|
|
535
530
|
}
|
|
536
531
|
}
|
|
537
532
|
catch (e) {
|
|
@@ -559,17 +554,17 @@ export function isValidDate(date) {
|
|
|
559
554
|
* @returns {string} - The current timezone.
|
|
560
555
|
*/
|
|
561
556
|
export function currentTimezone() {
|
|
562
|
-
if (
|
|
563
|
-
return
|
|
557
|
+
if (dayjs.currentTimezone) {
|
|
558
|
+
return dayjs.currentTimezone;
|
|
564
559
|
}
|
|
565
|
-
|
|
566
|
-
return
|
|
560
|
+
dayjs.currentTimezone = jtz.determine().name();
|
|
561
|
+
return dayjs.currentTimezone;
|
|
567
562
|
}
|
|
568
563
|
/**
|
|
569
564
|
* Get an offset date provided a date object and timezone object.
|
|
570
565
|
* @param {Date} date - The date to offset.
|
|
571
566
|
* @param {string} timezone - The timezone to offset the date to.
|
|
572
|
-
* @returns {Date} - The offset date.
|
|
567
|
+
* @returns {{date: Date, abbr: string}} - The offset date.
|
|
573
568
|
*/
|
|
574
569
|
export function offsetDate(date, timezone) {
|
|
575
570
|
if (timezone === 'UTC') {
|
|
@@ -578,134 +573,89 @@ export function offsetDate(date, timezone) {
|
|
|
578
573
|
abbr: 'UTC'
|
|
579
574
|
};
|
|
580
575
|
}
|
|
581
|
-
const dateMoment =
|
|
576
|
+
const dateMoment = dayjs(date).tz(timezone);
|
|
582
577
|
return {
|
|
583
578
|
date: new Date(date.getTime() + ((dateMoment.utcOffset() + date.getTimezoneOffset()) * 60000)),
|
|
584
579
|
abbr: dateMoment.format('z')
|
|
585
580
|
};
|
|
586
581
|
}
|
|
587
582
|
/**
|
|
588
|
-
* Returns if
|
|
589
|
-
* @returns {boolean} - TRUE if the zones are loaded; FALSE otherwise.
|
|
590
|
-
*/
|
|
591
|
-
export function zonesLoaded() {
|
|
592
|
-
return moment.zonesLoaded;
|
|
593
|
-
}
|
|
594
|
-
/**
|
|
595
|
-
* Returns if we should load the zones.
|
|
583
|
+
* Returns if we should handle a timezone difference.
|
|
596
584
|
* @param {string} timezone - The timezone to check if we should load the zones.
|
|
597
|
-
* @returns {boolean} - TRUE if we should
|
|
585
|
+
* @returns {boolean} - TRUE if we should handle timezones; FALSE otherwise.
|
|
598
586
|
*/
|
|
599
|
-
export function
|
|
600
|
-
|
|
601
|
-
return false;
|
|
602
|
-
}
|
|
603
|
-
return true;
|
|
587
|
+
export function shouldHandleTimezone(timezone) {
|
|
588
|
+
return !(timezone === currentTimezone() || timezone === 'UTC');
|
|
604
589
|
}
|
|
605
590
|
/**
|
|
606
|
-
*
|
|
607
|
-
* @param {string}
|
|
608
|
-
* @param {string} timezone - The timezone to load.
|
|
609
|
-
* @returns {Promise<any> | *} - Resolves when the zones for this timezone are loaded.
|
|
610
|
-
*/
|
|
611
|
-
export function loadZones(url, timezone) {
|
|
612
|
-
if (timezone && !shouldLoadZones(timezone)) {
|
|
613
|
-
// Return non-resolving promise.
|
|
614
|
-
return new Promise(_.noop);
|
|
615
|
-
}
|
|
616
|
-
if (moment.zonesPromise) {
|
|
617
|
-
return moment.zonesPromise;
|
|
618
|
-
}
|
|
619
|
-
return moment.zonesPromise = fetch(url)
|
|
620
|
-
.then(resp => resp.json().then(zones => {
|
|
621
|
-
moment.tz.load(zones);
|
|
622
|
-
moment.zonesLoaded = true;
|
|
623
|
-
// Trigger a global event that the timezones have finished loading.
|
|
624
|
-
if (document && document.createEvent && document.body && document.body.dispatchEvent) {
|
|
625
|
-
var event = document.createEvent('Event');
|
|
626
|
-
event.initEvent('zonesLoaded', true, true);
|
|
627
|
-
document.body.dispatchEvent(event);
|
|
628
|
-
}
|
|
629
|
-
}));
|
|
630
|
-
}
|
|
631
|
-
/**
|
|
632
|
-
* Get the moment date object for translating dates with timezones.
|
|
633
|
-
* @param {string|Date} value - The value to convert into a moment date.
|
|
591
|
+
* Get the Dayjs date object for translating dates with timezones.
|
|
592
|
+
* @param {string|Date} value - The value to convert into a dayjs date.
|
|
634
593
|
* @param {string} format - The format to convert the date to.
|
|
635
594
|
* @param {string} timezone - The timezone to convert the date to.
|
|
636
595
|
* @param {object} options - The options object
|
|
637
|
-
* @returns {
|
|
596
|
+
* @returns {dayjs.Dayjs} - The dayjs date object.
|
|
638
597
|
*/
|
|
639
|
-
export function
|
|
640
|
-
const
|
|
598
|
+
export function dayjsDate(value, format, timezone, options) {
|
|
599
|
+
const dayjsDate = dayjs(value);
|
|
641
600
|
if (!timezone) {
|
|
642
|
-
return
|
|
601
|
+
return dayjsDate;
|
|
643
602
|
}
|
|
644
603
|
if (timezone === 'UTC') {
|
|
645
604
|
timezone = 'Etc/UTC';
|
|
646
605
|
}
|
|
647
|
-
if ((timezone !== currentTimezone() || (format && format.match(/\s(z$|z\s)/))) && (
|
|
648
|
-
return
|
|
606
|
+
if ((timezone !== currentTimezone() || (format && format.match(/\s(z$|z\s)/))) && (shouldHandleTimezone(timezone) || options?.email)) {
|
|
607
|
+
return dayjsDate.tz(timezone);
|
|
649
608
|
}
|
|
650
|
-
return
|
|
609
|
+
return dayjsDate;
|
|
651
610
|
}
|
|
652
611
|
/**
|
|
653
612
|
* Format a date provided a value, format, and timezone object.
|
|
654
|
-
* @param {string} timezonesUrl - The URL to load the timezone data from.
|
|
655
613
|
* @param {string|Date} value - The value to format.
|
|
656
614
|
* @param {string} format - The format to format the date to.
|
|
657
615
|
* @param {string} timezone - The timezone to format the date to.
|
|
658
616
|
* @param {string} flatPickrInputFormat - The format to use for flatpickr input.
|
|
659
617
|
* @returns {string} - The formatted date.
|
|
660
618
|
*/
|
|
661
|
-
export function formatDate(
|
|
662
|
-
const
|
|
619
|
+
export function formatDate(value, format, timezone, flatPickrInputFormat) {
|
|
620
|
+
const dayjsDate = dayjs(value, flatPickrInputFormat || undefined);
|
|
663
621
|
if (timezone === currentTimezone()) {
|
|
664
622
|
// See if our format contains a "z" timezone character.
|
|
665
623
|
if (format.match(/\s(z$|z\s)/)) {
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
return momentDate.tz(timezone).format(convertFormatToMoment(format));
|
|
624
|
+
if (shouldHandleTimezone(timezone)) {
|
|
625
|
+
return dayjsDate.tz(timezone).format(convertFormatToDayjs(format));
|
|
669
626
|
}
|
|
670
627
|
else {
|
|
671
|
-
return
|
|
628
|
+
return dayjsDate.format(convertFormatToDayjs(format.replace(/\s(z$|z\s)/, '')));
|
|
672
629
|
}
|
|
673
630
|
}
|
|
674
631
|
// Return the standard format.
|
|
675
|
-
return
|
|
632
|
+
return dayjsDate.format(convertFormatToDayjs(format));
|
|
676
633
|
}
|
|
677
634
|
if (timezone === 'UTC') {
|
|
678
|
-
const offset = offsetDate(
|
|
679
|
-
return `${
|
|
635
|
+
const offset = offsetDate(dayjsDate.toDate(), 'UTC');
|
|
636
|
+
return `${dayjs(offset.date).format(convertFormatToDayjs(format))} UTC`;
|
|
680
637
|
}
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
if (moment.zonesLoaded && timezone) {
|
|
684
|
-
return momentDate.tz(timezone).format(`${convertFormatToMoment(format)} z`);
|
|
685
|
-
}
|
|
686
|
-
else {
|
|
687
|
-
return momentDate.format(convertFormatToMoment(format));
|
|
638
|
+
if (shouldHandleTimezone(timezone)) {
|
|
639
|
+
return dayjsDate.tz(timezone).format(`${convertFormatToDayjs(format)} z`);
|
|
688
640
|
}
|
|
641
|
+
return dayjsDate.format(convertFormatToDayjs(format));
|
|
689
642
|
}
|
|
690
643
|
/**
|
|
691
644
|
* Pass a format function to format within a timezone.
|
|
692
|
-
* @param {string} timezonesUrl - The URL to load the timezone data from.
|
|
693
645
|
* @param {Function} formatFn - The format function to use.
|
|
694
646
|
* @param {Date|string} date - The date to format.
|
|
695
647
|
* @param {string} format - The format to format the date to.
|
|
696
648
|
* @param {string} timezone - The timezone to format the date to.
|
|
697
649
|
* @returns {string} - The formatted date.
|
|
698
650
|
*/
|
|
699
|
-
export function formatOffset(
|
|
651
|
+
export function formatOffset(formatFn, date, format, timezone) {
|
|
700
652
|
if (timezone === currentTimezone()) {
|
|
701
653
|
return formatFn(date, format);
|
|
702
654
|
}
|
|
703
655
|
if (timezone === 'UTC') {
|
|
704
656
|
return `${formatFn(offsetDate(date, 'UTC').date, format)} UTC`;
|
|
705
657
|
}
|
|
706
|
-
|
|
707
|
-
loadZones(timezonesUrl);
|
|
708
|
-
if (moment.zonesLoaded) {
|
|
658
|
+
if (shouldHandleTimezone(timezone)) {
|
|
709
659
|
const offset = offsetDate(date, timezone);
|
|
710
660
|
return `${formatFn(offset.date, format)} ${offset.abbr}`;
|
|
711
661
|
}
|
|
@@ -762,7 +712,7 @@ export function convertFormatToFlatpickr(format) {
|
|
|
762
712
|
* @param {string} format - The format to convert.
|
|
763
713
|
* @returns {string} - The converted format.
|
|
764
714
|
*/
|
|
765
|
-
export function
|
|
715
|
+
export function convertFormatToDayjs(format) {
|
|
766
716
|
return format
|
|
767
717
|
// Year conversion.
|
|
768
718
|
.replace(/y/g, 'Y')
|
|
@@ -1063,9 +1013,6 @@ export function bootstrapVersion(options) {
|
|
|
1063
1013
|
if (options.bootstrap) {
|
|
1064
1014
|
return options.bootstrap;
|
|
1065
1015
|
}
|
|
1066
|
-
if ((typeof jQuery === 'function') && (typeof jQuery().collapse === 'function')) {
|
|
1067
|
-
return parseInt(jQuery.fn.collapse.Constructor.VERSION.split('.')[0], 10);
|
|
1068
|
-
}
|
|
1069
1016
|
if (window.bootstrap && window.bootstrap.Collapse) {
|
|
1070
1017
|
return parseInt(window.bootstrap.Collapse.VERSION.split('.')[0], 10);
|
|
1071
1018
|
}
|
|
@@ -1311,11 +1258,10 @@ export function sanitize(string, options) {
|
|
|
1311
1258
|
export function fastCloneDeep(obj) {
|
|
1312
1259
|
return obj ? JSON.parse(JSON.stringify(obj)) : obj;
|
|
1313
1260
|
}
|
|
1314
|
-
export { Evaluator, interpolate };
|
|
1315
1261
|
/**
|
|
1316
1262
|
* Returns if the component is an input component.
|
|
1317
1263
|
* @param {import('@formio/core').Component} componentJson - The JSON of a component.
|
|
1318
|
-
* @returns {
|
|
1264
|
+
* @returns {boolean} - TRUE if the component is an input component; FALSE otherwise.
|
|
1319
1265
|
*/
|
|
1320
1266
|
export function isInputComponent(componentJson) {
|
|
1321
1267
|
if (componentJson.input === false || componentJson.input === true) {
|
|
@@ -1339,7 +1285,7 @@ export function isInputComponent(componentJson) {
|
|
|
1339
1285
|
/**
|
|
1340
1286
|
* Takes a component path, and returns a component path array.
|
|
1341
1287
|
* @param {string} pathStr - The path string to convert to an array.
|
|
1342
|
-
* @returns {
|
|
1288
|
+
* @returns {Array<string>} - The array of paths.
|
|
1343
1289
|
*/
|
|
1344
1290
|
export function getArrayFromComponentPath(pathStr) {
|
|
1345
1291
|
if (!pathStr || !_.isString(pathStr)) {
|
|
@@ -1513,8 +1459,6 @@ export function getFocusableElements(element) {
|
|
|
1513
1459
|
textarea:not([disabled]), button:not([disabled]), [href]`;
|
|
1514
1460
|
return element.querySelectorAll(focusableSelector);
|
|
1515
1461
|
}
|
|
1516
|
-
// Export lodash to save space with other libraries.
|
|
1517
|
-
export { _ };
|
|
1518
1462
|
export const componentValueTypes = {
|
|
1519
1463
|
number: 'number',
|
|
1520
1464
|
string: 'string',
|