@servicetitan/dte-unlayer 0.158.0 → 0.159.0
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/api-core.js +22 -29
- package/dist/api-core.js.map +1 -1
- package/dist/api-custom-tools.js +23 -29
- package/dist/api-custom-tools.js.map +1 -1
- package/dist/business-calendar/BusinessCalendarDrawer.d.ts +19 -0
- package/dist/business-calendar/BusinessCalendarDrawer.d.ts.map +1 -0
- package/dist/business-calendar/BusinessCalendarDrawer.js +41 -0
- package/dist/business-calendar/BusinessCalendarDrawer.js.map +1 -0
- package/dist/business-calendar/business-calendar-requests.d.ts +25 -0
- package/dist/business-calendar/business-calendar-requests.d.ts.map +1 -0
- package/dist/business-calendar/business-calendar-requests.js +46 -0
- package/dist/business-calendar/business-calendar-requests.js.map +1 -0
- package/dist/business-calendar/business-calendar-state.d.ts +22 -0
- package/dist/business-calendar/business-calendar-state.d.ts.map +1 -0
- package/dist/business-calendar/business-calendar-state.js +74 -0
- package/dist/business-calendar/business-calendar-state.js.map +1 -0
- package/dist/business-calendar/useBusinessCalendarRequests.d.ts +15 -0
- package/dist/business-calendar/useBusinessCalendarRequests.d.ts.map +1 -0
- package/dist/business-calendar/useBusinessCalendarRequests.js +30 -0
- package/dist/business-calendar/useBusinessCalendarRequests.js.map +1 -0
- package/dist/display-conditions/ConditionGroup.js +15 -89
- package/dist/display-conditions/ConditionGroup.js.map +1 -1
- package/dist/display-conditions/ConditionGroupsSection.js +2 -70
- package/dist/display-conditions/ConditionGroupsSection.js.map +1 -1
- package/dist/display-conditions/ConditionRow.js +63 -205
- package/dist/display-conditions/ConditionRow.js.map +1 -1
- package/dist/display-conditions/DisplayConditionModal.js +40 -190
- package/dist/display-conditions/DisplayConditionModal.js.map +1 -1
- package/dist/display-conditions/LookupValueControl.js +42 -105
- package/dist/display-conditions/LookupValueControl.js.map +1 -1
- package/dist/display-conditions/SeparatorWithChip.js +1 -10
- package/dist/display-conditions/SeparatorWithChip.js.map +1 -1
- package/dist/display-conditions/constants.js +15 -20
- package/dist/display-conditions/constants.js.map +1 -1
- package/dist/display-conditions/displayConditionController.js +5 -8
- package/dist/display-conditions/displayConditionController.js.map +1 -1
- package/dist/display-conditions/lookupOptionsController.js +16 -16
- package/dist/display-conditions/lookupOptionsController.js.map +1 -1
- package/dist/display-conditions/nunjucks.js +98 -116
- package/dist/display-conditions/nunjucks.js.map +1 -1
- package/dist/display-conditions/schemaDataPoints.js +13 -11
- package/dist/display-conditions/schemaDataPoints.js.map +1 -1
- package/dist/display-conditions/types.js +23 -67
- package/dist/display-conditions/types.js.map +1 -1
- package/dist/display-conditions/useConditionForms.js +38 -56
- package/dist/display-conditions/useConditionForms.js.map +1 -1
- package/dist/display-conditions/useLookupOptions.js +24 -44
- package/dist/display-conditions/useLookupOptions.js.map +1 -1
- package/dist/e-sign-offset/ESignDateSignedOffsetModal.js +37 -150
- package/dist/e-sign-offset/ESignDateSignedOffsetModal.js.map +1 -1
- package/dist/e-sign-offset/ESignOffsetRuleRow.js +12 -73
- package/dist/e-sign-offset/ESignOffsetRuleRow.js.map +1 -1
- package/dist/e-sign-offset/eSignOffsetController.js +5 -8
- package/dist/e-sign-offset/eSignOffsetController.js.map +1 -1
- package/dist/editor-core-source.d.ts +2 -2
- package/dist/editor-core-source.d.ts.map +1 -1
- package/dist/editor-core-source.js +3 -3
- package/dist/editor-core-source.js.map +1 -1
- package/dist/editor-core.js +2 -2
- package/dist/editor-core.js.map +1 -1
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +56 -118
- package/dist/editor.js.map +1 -1
- package/dist/image-upload-error.js +3 -3
- package/dist/image-upload-error.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/loadScript.js +7 -8
- package/dist/loadScript.js.map +1 -1
- package/dist/log.js +2 -3
- package/dist/log.js.map +1 -1
- package/dist/merge-tags.js +18 -17
- package/dist/merge-tags.js.map +1 -1
- package/dist/shared/configs.js +1 -2
- package/dist/shared/configs.js.map +1 -1
- package/dist/shared/const.d.ts +70 -0
- package/dist/shared/const.d.ts.map +1 -1
- package/dist/shared/const.js +13 -4
- package/dist/shared/const.js.map +1 -1
- package/dist/shared/date-calc.js +47 -38
- package/dist/shared/date-calc.js.map +1 -1
- package/dist/shared/e-sign-offset.js +46 -63
- package/dist/shared/e-sign-offset.js.map +1 -1
- package/dist/shared/edit-icon.js +0 -1
- package/dist/shared/edit-icon.js.map +1 -1
- package/dist/shared/fonts.js +16 -17
- package/dist/shared/fonts.js.map +1 -1
- package/dist/shared/forms.js +16 -38
- package/dist/shared/forms.js.map +1 -1
- package/dist/shared/instance-id.js +6 -9
- package/dist/shared/instance-id.js.map +1 -1
- package/dist/shared/nunjucks-helpers.js +2 -5
- package/dist/shared/nunjucks-helpers.js.map +1 -1
- package/dist/shared/schema.js +52 -96
- package/dist/shared/schema.js.map +1 -1
- package/dist/shared/tools.js +6 -13
- package/dist/shared/tools.js.map +1 -1
- package/dist/store.d.ts +15 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +851 -548
- package/dist/store.js.map +1 -1
- package/dist/tools.js +133 -143
- package/dist/tools.js.map +1 -1
- package/dist/unlayer-interface.d.ts +15 -4
- package/dist/unlayer-interface.d.ts.map +1 -1
- package/dist/unlayer-interface.js +1 -2
- package/dist/unlayer-interface.js.map +1 -1
- package/dist/unlayer.js +86 -113
- package/dist/unlayer.js.map +1 -1
- package/dist/vendor/dte-shared/business-calendar-validation.utils.d.ts +25 -0
- package/dist/vendor/dte-shared/business-calendar-validation.utils.js +80 -0
- package/dist/vendor/dte-shared/components/business-calendar-section.d.ts +15 -0
- package/dist/vendor/dte-shared/components/business-calendar-section.js +14 -0
- package/dist/vendor/dte-shared/components/schedule-drawer.d.ts +18 -0
- package/dist/vendor/dte-shared/components/schedule-drawer.js +119 -0
- package/dist/vendor/dte-shared/components/schedule-picker.d.ts +8 -0
- package/dist/vendor/dte-shared/components/schedule-picker.js +88 -0
- package/dist/vendor/dte-shared/constants.d.ts +31 -0
- package/dist/vendor/dte-shared/constants.js +34 -0
- package/dist/vendor/dte-shared/field-schedule-editor-context.d.ts +31 -0
- package/dist/vendor/dte-shared/field-schedule-editor-context.js +110 -0
- package/dist/vendor/dte-shared/index.d.ts +8 -0
- package/dist/vendor/dte-shared/index.js +7 -0
- package/dist/vendor/dte-shared/schedule-bindings.utils.d.ts +22 -0
- package/dist/vendor/dte-shared/schedule-bindings.utils.js +31 -0
- package/dist/vendor/dte-shared/styles/schedule.css +19 -0
- package/dist/vendor/dte-shared/types.d.ts +129 -0
- package/dist/vendor/dte-shared/types.js +1 -0
- package/package.json +7 -1
- package/src/__tests__/business-calendar-drawer.test.tsx +183 -0
- package/src/__tests__/business-calendar-requests.test.ts +166 -0
- package/src/__tests__/business-calendar-state.test.tsx +142 -0
- package/src/__tests__/store.business-calendar.test.ts +185 -0
- package/src/__tests__/unlayer.e-sign-types.test.ts +30 -0
- package/src/business-calendar/BusinessCalendarDrawer.tsx +76 -0
- package/src/business-calendar/business-calendar-requests.ts +80 -0
- package/src/business-calendar/business-calendar-state.ts +113 -0
- package/src/business-calendar/useBusinessCalendarRequests.ts +49 -0
- package/src/editor-core-source.ts +2 -2
- package/src/editor.tsx +15 -0
- package/src/index.ts +10 -0
- package/src/shared/const.ts +59 -0
- package/src/store.ts +67 -5
- package/src/unlayer-interface.tsx +15 -4
- package/src/unlayer.tsx +5 -5
|
@@ -1,72 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Display condition types for the modal and Nunjucks generation.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
|
|
14
|
-
value: 'is_equal_to'
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
label: 'Is not equal to',
|
|
18
|
-
value: 'is_not_equal_to'
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
label: 'Starts with',
|
|
22
|
-
value: 'starts_with'
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
label: 'Ends with',
|
|
26
|
-
value: 'ends_with'
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
label: 'Is empty',
|
|
30
|
-
value: 'is_empty'
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
label: 'Is not empty',
|
|
34
|
-
value: 'is_not_empty'
|
|
35
|
-
}
|
|
3
|
+
*/
|
|
4
|
+
/** Operators for string-type fields. */
|
|
5
|
+
export const STRING_OPERATORS = [
|
|
6
|
+
{ label: 'Contains', value: 'contains' },
|
|
7
|
+
{ label: 'Does not contain', value: 'does_not_contain' },
|
|
8
|
+
{ label: 'Is equal to', value: 'is_equal_to' },
|
|
9
|
+
{ label: 'Is not equal to', value: 'is_not_equal_to' },
|
|
10
|
+
{ label: 'Starts with', value: 'starts_with' },
|
|
11
|
+
{ label: 'Ends with', value: 'ends_with' },
|
|
12
|
+
{ label: 'Is empty', value: 'is_empty' },
|
|
13
|
+
{ label: 'Is not empty', value: 'is_not_empty' },
|
|
36
14
|
];
|
|
37
|
-
/** Operators for number-type fields. */
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
label: '> (greater than)',
|
|
48
|
-
value: 'num_gt'
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
label: '< (less than)',
|
|
52
|
-
value: 'num_lt'
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
label: '>= (greater than or equal to)',
|
|
56
|
-
value: 'num_gte'
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
label: '<= (less than or equal to)',
|
|
60
|
-
value: 'num_lte'
|
|
61
|
-
}
|
|
15
|
+
/** Operators for number-type fields. */
|
|
16
|
+
export const NUMBER_OPERATORS = [
|
|
17
|
+
{ label: '== (equal to)', value: 'num_eq' },
|
|
18
|
+
{ label: '!= (not equal to)', value: 'num_neq' },
|
|
19
|
+
{ label: '> (greater than)', value: 'num_gt' },
|
|
20
|
+
{ label: '< (less than)', value: 'num_lt' },
|
|
21
|
+
{ label: '>= (greater than or equal to)', value: 'num_gte' },
|
|
22
|
+
{ label: '<= (less than or equal to)', value: 'num_lte' },
|
|
62
23
|
];
|
|
63
|
-
/** All operators combined for type definitions. */
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
];
|
|
67
|
-
/** Operators that do not require a value (empty/is not empty) */ export const VALUE_LESS_OPERATORS = [
|
|
68
|
-
'is_empty',
|
|
69
|
-
'is_not_empty'
|
|
70
|
-
];
|
|
71
|
-
|
|
24
|
+
/** All operators combined for type definitions. */
|
|
25
|
+
export const CONDITION_OPERATORS = [...STRING_OPERATORS, ...NUMBER_OPERATORS];
|
|
26
|
+
/** Operators that do not require a value (empty/is not empty) */
|
|
27
|
+
export const VALUE_LESS_OPERATORS = ['is_empty', 'is_not_empty'];
|
|
72
28
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/display-conditions/types.ts"],"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/display-conditions/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,wCAAwC;AACxC,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC5B,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE;IACxC,EAAE,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,kBAAkB,EAAE;IACxD,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,EAAE;IAC9C,EAAE,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,iBAAiB,EAAE;IACtD,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,EAAE;IAC9C,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE;IAC1C,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE;IACxC,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,cAAc,EAAE;CAC1C,CAAC;AAEX,wCAAwC;AACxC,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC5B,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,QAAQ,EAAE;IAC3C,EAAE,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,SAAS,EAAE;IAChD,EAAE,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,QAAQ,EAAE;IAC9C,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,QAAQ,EAAE;IAC3C,EAAE,KAAK,EAAE,+BAA+B,EAAE,KAAK,EAAE,SAAS,EAAE;IAC5D,EAAE,KAAK,EAAE,4BAA4B,EAAE,KAAK,EAAE,SAAS,EAAE;CACnD,CAAC;AAEX,mDAAmD;AACnD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,GAAG,gBAAgB,EAAE,GAAG,gBAAgB,CAAU,CAAC;AAMvF,iEAAiE;AACjE,MAAM,CAAC,MAAM,oBAAoB,GAAwB,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC"}
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
-
import { buildFormFieldKey, getConditionalFieldTypeFromFormItemType, parseFormFieldKey } from '../shared/forms';
|
|
2
|
+
import { buildFormFieldKey, getConditionalFieldTypeFromFormItemType, parseFormFieldKey, } from '../shared/forms';
|
|
3
3
|
/**
|
|
4
4
|
* Loads the host's forms and form fields for a condition-editing modal, so form fields can be
|
|
5
5
|
* picked as condition data points alongside schema fields.
|
|
6
|
-
*/
|
|
6
|
+
*/
|
|
7
|
+
export const useConditionForms = ({ onConditionFormSelect, onConditionalsOpen, }) => {
|
|
7
8
|
const [forms, setForms] = useState([]);
|
|
8
9
|
const [formFieldsByFormId, setFormFieldsByFormId] = useState({});
|
|
9
10
|
const [loadingFormIds, setLoadingFormIds] = useState([]);
|
|
10
11
|
const [isFormsListLoading, setIsFormsListLoading] = useState(false);
|
|
11
12
|
const formFieldsByFormIdRef = useRef({});
|
|
12
13
|
const loadingFormIdsRef = useRef([]);
|
|
13
|
-
const formFieldOptions = useMemo(()=>{
|
|
14
|
+
const formFieldOptions = useMemo(() => {
|
|
14
15
|
const nextOptions = [];
|
|
15
|
-
for (const form of forms){
|
|
16
|
+
for (const form of forms) {
|
|
16
17
|
const fields = formFieldsByFormId[form.id];
|
|
17
18
|
if (!fields) {
|
|
18
19
|
continue;
|
|
19
20
|
}
|
|
20
|
-
for (const field of fields){
|
|
21
|
+
for (const field of fields) {
|
|
21
22
|
const fieldType = getConditionalFieldTypeFromFormItemType(field.itemType);
|
|
22
23
|
if (!fieldType) {
|
|
23
24
|
continue;
|
|
@@ -26,55 +27,43 @@ import { buildFormFieldKey, getConditionalFieldTypeFromFormItemType, parseFormFi
|
|
|
26
27
|
fieldType,
|
|
27
28
|
formId: form.id,
|
|
28
29
|
fullKey: buildFormFieldKey(form.id, field.id),
|
|
29
|
-
title: field.header
|
|
30
|
+
title: field.header,
|
|
30
31
|
});
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
|
-
return nextOptions.sort((left, right)=>left.title.localeCompare(right.title));
|
|
34
|
-
}, [
|
|
35
|
-
|
|
36
|
-
formFieldsByFormId
|
|
37
|
-
]);
|
|
38
|
-
useEffect(()=>{
|
|
34
|
+
return nextOptions.sort((left, right) => left.title.localeCompare(right.title));
|
|
35
|
+
}, [forms, formFieldsByFormId]);
|
|
36
|
+
useEffect(() => {
|
|
39
37
|
formFieldsByFormIdRef.current = formFieldsByFormId;
|
|
40
|
-
}, [
|
|
41
|
-
|
|
42
|
-
]);
|
|
43
|
-
useEffect(()=>{
|
|
38
|
+
}, [formFieldsByFormId]);
|
|
39
|
+
useEffect(() => {
|
|
44
40
|
loadingFormIdsRef.current = loadingFormIds;
|
|
45
|
-
}, [
|
|
46
|
-
|
|
47
|
-
]);
|
|
48
|
-
const requestFormFields = useCallback((formId)=>{
|
|
41
|
+
}, [loadingFormIds]);
|
|
42
|
+
const requestFormFields = useCallback((formId) => {
|
|
49
43
|
if (!onConditionFormSelect) {
|
|
50
44
|
return;
|
|
51
45
|
}
|
|
52
|
-
if (formFieldsByFormIdRef.current[formId] ||
|
|
46
|
+
if (formFieldsByFormIdRef.current[formId] ||
|
|
47
|
+
loadingFormIdsRef.current.includes(formId)) {
|
|
53
48
|
return;
|
|
54
49
|
}
|
|
55
|
-
setLoadingFormIds(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
onConditionFormSelect(formId, (selectedFormId, fields)=>{
|
|
60
|
-
setFormFieldsByFormId((prev)=>({
|
|
61
|
-
...prev,
|
|
62
|
-
[selectedFormId]: fields
|
|
63
|
-
}));
|
|
64
|
-
setLoadingFormIds((prev)=>prev.filter((id)=>id !== selectedFormId));
|
|
50
|
+
setLoadingFormIds(prev => (prev.includes(formId) ? prev : [...prev, formId]));
|
|
51
|
+
onConditionFormSelect(formId, (selectedFormId, fields) => {
|
|
52
|
+
setFormFieldsByFormId(prev => ({ ...prev, [selectedFormId]: fields }));
|
|
53
|
+
setLoadingFormIds(prev => prev.filter(id => id !== selectedFormId));
|
|
65
54
|
});
|
|
66
|
-
}, [
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
var
|
|
72
|
-
|
|
73
|
-
}).filter((formId)=>formId != null)));
|
|
55
|
+
}, [onConditionFormSelect]);
|
|
56
|
+
/** Resets form data and requests the forms list plus fields of forms the groups already use. */
|
|
57
|
+
const loadForms = useCallback((groups) => {
|
|
58
|
+
const usedFormIds = Array.from(new Set(groups
|
|
59
|
+
.flatMap(group => group.conditions)
|
|
60
|
+
.map(condition => { var _a; return (_a = parseFormFieldKey(condition.dataPointKey)) === null || _a === void 0 ? void 0 : _a.formId; })
|
|
61
|
+
.filter((formId) => formId != null)));
|
|
74
62
|
/*
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
63
|
+
* Reset synchronously so `requestFormFields` below does not skip forms loaded by a
|
|
64
|
+
* previous open whose state is being cleared.
|
|
65
|
+
*/
|
|
66
|
+
formFieldsByFormIdRef.current = {};
|
|
78
67
|
loadingFormIdsRef.current = [];
|
|
79
68
|
setForms([]);
|
|
80
69
|
setFormFieldsByFormId({});
|
|
@@ -83,28 +72,21 @@ import { buildFormFieldKey, getConditionalFieldTypeFromFormItemType, parseFormFi
|
|
|
83
72
|
if (!onConditionalsOpen) {
|
|
84
73
|
return;
|
|
85
74
|
}
|
|
86
|
-
onConditionalsOpen(usedFormIds,
|
|
75
|
+
onConditionalsOpen(usedFormIds, nextForms => {
|
|
87
76
|
setForms(nextForms);
|
|
88
77
|
setIsFormsListLoading(false);
|
|
89
|
-
}, (formId, fields)=>{
|
|
90
|
-
setFormFieldsByFormId(
|
|
91
|
-
|
|
92
|
-
[formId]: fields
|
|
93
|
-
}));
|
|
94
|
-
setLoadingFormIds((prev)=>prev.filter((id)=>id !== formId));
|
|
78
|
+
}, (formId, fields) => {
|
|
79
|
+
setFormFieldsByFormId(prev => ({ ...prev, [formId]: fields }));
|
|
80
|
+
setLoadingFormIds(prev => prev.filter(id => id !== formId));
|
|
95
81
|
});
|
|
96
|
-
usedFormIds.forEach(
|
|
97
|
-
}, [
|
|
98
|
-
onConditionalsOpen,
|
|
99
|
-
requestFormFields
|
|
100
|
-
]);
|
|
82
|
+
usedFormIds.forEach(formId => requestFormFields(formId));
|
|
83
|
+
}, [onConditionalsOpen, requestFormFields]);
|
|
101
84
|
return {
|
|
102
85
|
formFieldOptions,
|
|
103
86
|
forms,
|
|
104
87
|
isFieldDataLoading: isFormsListLoading || loadingFormIds.length > 0,
|
|
105
88
|
loadForms,
|
|
106
|
-
requestFormFields
|
|
89
|
+
requestFormFields,
|
|
107
90
|
};
|
|
108
91
|
};
|
|
109
|
-
|
|
110
92
|
//# sourceMappingURL=useConditionForms.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/display-conditions/useConditionForms.ts"],"
|
|
1
|
+
{"version":3,"file":"useConditionForms.js","sourceRoot":"","sources":["../../src/display-conditions/useConditionForms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,EACH,iBAAiB,EAGjB,uCAAuC,EACvC,iBAAiB,GACpB,MAAM,iBAAiB,CAAC;AAkBzB;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAC9B,qBAAqB,EACrB,kBAAkB,GACK,EAAE,EAAE;IAC3B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAa,EAAE,CAAC,CAAC;IACnD,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAG,QAAQ,CACxD,EAAE,CACL,CAAC;IACF,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAW,EAAE,CAAC,CAAC;IACnE,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACpE,MAAM,qBAAqB,GAAG,MAAM,CAAkC,EAAE,CAAC,CAAC;IAC1E,MAAM,iBAAiB,GAAG,MAAM,CAAW,EAAE,CAAC,CAAC;IAE/C,MAAM,gBAAgB,GAAG,OAAO,CAAoB,GAAG,EAAE;QACrD,MAAM,WAAW,GAAsB,EAAE,CAAC;QAC1C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACvB,MAAM,MAAM,GAAG,kBAAkB,CAAC,IAAI,CAA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,CAAC;QAC5C,iBAAiB,CAAC,EAAE,CAAC,CAAC;QAEtB,IAAI,CAAC,kBAAkB,EAAE,CAAC;YACtB,OAAO;QACX,CAAC;QAED,kBAAkB,CACd,WAAW,EACX,SAAS,CAAC,EAAE;YACR,QAAQ,CAAC,SAAS,CAAC,CAAC;YACpB,qBAAqB,CAAC,KAAK,CAAC,CAAC;QACjC,CAAC,EACD,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE;YACf,qBAAqB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;YAC/D,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC,CAAC;QAChE,CAAC,CACJ,CAAC;QAEF,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC;IAC7D,CAAC,EACD,CAAC,kBAAkB,EAAE,iBAAiB,CAAC,CAC1C,CAAC;IAEF,OAAO;QACH,gBAAgB;QAChB,KAAK;QACL,kBAAkB,EAAE,kBAAkB,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC;QACnE,SAAS;QACT,iBAAiB;KACpB,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { generateId } from './constants';
|
|
3
|
-
import { emitLookupOptionsRequest, onLookupOptionsResponse } from './lookupOptionsController';
|
|
4
|
-
/** Time to wait for the host before falling back to free-text input. */
|
|
3
|
+
import { emitLookupOptionsRequest, onLookupOptionsResponse, } from './lookupOptionsController';
|
|
4
|
+
/** Time to wait for the host before falling back to free-text input. */
|
|
5
|
+
const LOOKUP_OPTIONS_TIMEOUT_MS = 10000;
|
|
5
6
|
/**
|
|
6
7
|
* Requests host-resolved dropdown options for a field's `fieldLookupSource`.
|
|
7
8
|
*
|
|
@@ -10,12 +11,13 @@ import { emitLookupOptionsRequest, onLookupOptionsResponse } from './lookupOptio
|
|
|
10
11
|
* searchable source (`searchable`, driven by `loadOptions` per keystroke).
|
|
11
12
|
* Stale responses (mismatched requestId) are ignored and the listener/timeout
|
|
12
13
|
* are cleaned up on unmount or source change.
|
|
13
|
-
*/
|
|
14
|
+
*/
|
|
15
|
+
export const useLookupOptions = (sourceKey) => {
|
|
14
16
|
const [status, setStatus] = useState('idle');
|
|
15
17
|
const [options, setOptions] = useState([]);
|
|
16
18
|
const latestRequestIdRef = useRef(null);
|
|
17
19
|
const sourceKeyRef = useRef(sourceKey);
|
|
18
|
-
useEffect(()=>{
|
|
20
|
+
useEffect(() => {
|
|
19
21
|
sourceKeyRef.current = sourceKey;
|
|
20
22
|
const normalizedSourceKey = sourceKey === null || sourceKey === void 0 ? void 0 : sourceKey.trim();
|
|
21
23
|
if (!normalizedSourceKey) {
|
|
@@ -28,14 +30,14 @@ import { emitLookupOptionsRequest, onLookupOptionsResponse } from './lookupOptio
|
|
|
28
30
|
latestRequestIdRef.current = requestId;
|
|
29
31
|
setStatus('loading');
|
|
30
32
|
setOptions([]);
|
|
31
|
-
const timeoutId = setTimeout(()=>{
|
|
33
|
+
const timeoutId = setTimeout(() => {
|
|
32
34
|
if (latestRequestIdRef.current !== requestId) {
|
|
33
35
|
return;
|
|
34
36
|
}
|
|
35
37
|
setStatus('fallback');
|
|
36
38
|
setOptions([]);
|
|
37
39
|
}, LOOKUP_OPTIONS_TIMEOUT_MS);
|
|
38
|
-
const unsubscribe = onLookupOptionsResponse(
|
|
40
|
+
const unsubscribe = onLookupOptionsResponse(response => {
|
|
39
41
|
// Ignore stale responses (different request, or superseded selection).
|
|
40
42
|
if (response.requestId !== requestId || latestRequestIdRef.current !== requestId) {
|
|
41
43
|
return;
|
|
@@ -49,32 +51,28 @@ import { emitLookupOptionsRequest, onLookupOptionsResponse } from './lookupOptio
|
|
|
49
51
|
if (response.options.length > 0) {
|
|
50
52
|
setOptions(response.options);
|
|
51
53
|
setStatus('static');
|
|
52
|
-
}
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
53
56
|
setOptions([]);
|
|
54
57
|
setStatus('fallback');
|
|
55
58
|
}
|
|
56
59
|
});
|
|
57
|
-
emitLookupOptionsRequest({
|
|
58
|
-
|
|
59
|
-
sourceKey: normalizedSourceKey
|
|
60
|
-
});
|
|
61
|
-
return ()=>{
|
|
60
|
+
emitLookupOptionsRequest({ requestId, sourceKey: normalizedSourceKey });
|
|
61
|
+
return () => {
|
|
62
62
|
clearTimeout(timeoutId);
|
|
63
63
|
unsubscribe();
|
|
64
64
|
};
|
|
65
|
-
}, [
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
var _sourceKeyRef_current;
|
|
70
|
-
const normalizedSourceKey = (_sourceKeyRef_current = sourceKeyRef.current) === null || _sourceKeyRef_current === void 0 ? void 0 : _sourceKeyRef_current.trim();
|
|
65
|
+
}, [sourceKey]);
|
|
66
|
+
const requestOptions = useCallback((payload) => {
|
|
67
|
+
var _a;
|
|
68
|
+
const normalizedSourceKey = (_a = sourceKeyRef.current) === null || _a === void 0 ? void 0 : _a.trim();
|
|
71
69
|
if (!normalizedSourceKey) {
|
|
72
70
|
return Promise.resolve([]);
|
|
73
71
|
}
|
|
74
|
-
return new Promise(
|
|
72
|
+
return new Promise(resolve => {
|
|
75
73
|
const requestId = generateId();
|
|
76
74
|
let settled = false;
|
|
77
|
-
const finish = (result)=>{
|
|
75
|
+
const finish = (result) => {
|
|
78
76
|
if (settled) {
|
|
79
77
|
return;
|
|
80
78
|
}
|
|
@@ -83,36 +81,18 @@ import { emitLookupOptionsRequest, onLookupOptionsResponse } from './lookupOptio
|
|
|
83
81
|
unsubscribe();
|
|
84
82
|
resolve(result);
|
|
85
83
|
};
|
|
86
|
-
const timeoutId = setTimeout(()=>finish([]), LOOKUP_OPTIONS_TIMEOUT_MS);
|
|
87
|
-
const unsubscribe = onLookupOptionsResponse(
|
|
84
|
+
const timeoutId = setTimeout(() => finish([]), LOOKUP_OPTIONS_TIMEOUT_MS);
|
|
85
|
+
const unsubscribe = onLookupOptionsResponse(response => {
|
|
88
86
|
if (response.requestId !== requestId) {
|
|
89
87
|
return;
|
|
90
88
|
}
|
|
91
89
|
finish(response.options);
|
|
92
90
|
});
|
|
93
|
-
emitLookupOptionsRequest({
|
|
94
|
-
requestId,
|
|
95
|
-
sourceKey: normalizedSourceKey,
|
|
96
|
-
...payload
|
|
97
|
-
});
|
|
91
|
+
emitLookupOptionsRequest({ requestId, sourceKey: normalizedSourceKey, ...payload });
|
|
98
92
|
});
|
|
99
93
|
}, []);
|
|
100
|
-
const loadOptions = useCallback((query)=>requestOptions({
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
requestOptions
|
|
104
|
-
]);
|
|
105
|
-
const resolveOptions = useCallback((keys)=>requestOptions({
|
|
106
|
-
keys
|
|
107
|
-
}), [
|
|
108
|
-
requestOptions
|
|
109
|
-
]);
|
|
110
|
-
return {
|
|
111
|
-
status,
|
|
112
|
-
options,
|
|
113
|
-
loadOptions,
|
|
114
|
-
resolveOptions
|
|
115
|
-
};
|
|
94
|
+
const loadOptions = useCallback((query) => requestOptions({ query }), [requestOptions]);
|
|
95
|
+
const resolveOptions = useCallback((keys) => requestOptions({ keys }), [requestOptions]);
|
|
96
|
+
return { status, options, loadOptions, resolveOptions };
|
|
116
97
|
};
|
|
117
|
-
|
|
118
98
|
//# sourceMappingURL=useLookupOptions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/display-conditions/useLookupOptions.ts"],"
|
|
1
|
+
{"version":3,"file":"useLookupOptions.js","sourceRoot":"","sources":["../../src/display-conditions/useLookupOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE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