@arquimedes.co/eureka-forms 3.0.68-test → 3.0.68
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 +33 -1
- package/dist/@Types/AvailabilityFormStep.d.ts +48 -0
- package/dist/@Types/AvailabilityFormStep.js +24 -0
- package/dist/@Types/BankAccountFormStep.d.ts +67 -0
- package/dist/@Types/BankAccountFormStep.js +14 -0
- package/dist/@Types/BookingFormStep.d.ts +187 -0
- package/dist/@Types/BookingFormStep.js +44 -0
- package/dist/@Types/CalendarFormStep.d.ts +209 -0
- package/dist/@Types/CalendarFormStep.js +55 -0
- package/dist/@Types/CommunicationChannelFormStep.d.ts +51 -0
- package/dist/@Types/CommunicationChannelFormStep.js +15 -0
- package/dist/@Types/ConsentFormStep.d.ts +36 -0
- package/dist/@Types/ConsentFormStep.js +8 -0
- package/dist/@Types/EntityFormFormStep.d.ts +66 -0
- package/dist/@Types/EntityFormFormStep.js +20 -0
- package/dist/@Types/EventFormStep.d.ts +52 -0
- package/dist/@Types/EventFormStep.js +13 -0
- package/dist/@Types/ExternalReferenceFormStep.d.ts +74 -0
- package/dist/@Types/ExternalReferenceFormStep.js +20 -0
- package/dist/@Types/FormStep.d.ts +7 -2
- package/dist/@Types/FormStep.js +2 -1
- package/dist/@Types/LocationFormStep.d.ts +159 -0
- package/dist/@Types/LocationFormStep.js +46 -0
- package/dist/@Types/NumericFormSteps.d.ts +108 -0
- package/dist/@Types/NumericFormSteps.js +20 -0
- package/dist/@Types/PredefinedSelectorFormStep.d.ts +51 -0
- package/dist/@Types/PredefinedSelectorFormStep.js +39 -0
- package/dist/@Types/StepRef.d.ts +135 -0
- package/dist/@Types/StepRef.js +49 -0
- package/dist/App/App.stories.d.ts +10 -0
- package/dist/App/App.stories.js +189 -0
- package/dist/App/AppHooks.js +8 -0
- package/dist/App/AppHooks.test.js +8 -0
- package/dist/Form/Form.js +7 -6
- package/dist/Form/FormFunctions.d.ts +17 -0
- package/dist/Form/FormFunctions.js +22 -0
- package/dist/Form/FormFunctions.test.js +28 -1
- package/dist/FormSteps/AvailabilityStep/AvailabilityStep.d.ts +7 -0
- package/dist/FormSteps/AvailabilityStep/AvailabilityStep.js +14 -0
- package/dist/FormSteps/AvailabilityStep/MaterialAvailabilityStep/MaterialAvailabilityStep.d.ts +8 -0
- package/dist/FormSteps/AvailabilityStep/MaterialAvailabilityStep/MaterialAvailabilityStep.js +32 -0
- package/dist/FormSteps/BookingStep/BookingStep.d.ts +17 -0
- package/dist/FormSteps/BookingStep/BookingStep.js +14 -0
- package/dist/FormSteps/BookingStep/MaterialBookingStep/MaterialBookingStep.d.ts +7 -0
- package/dist/FormSteps/BookingStep/MaterialBookingStep/MaterialBookingStep.js +32 -0
- package/dist/FormSteps/CheckBoxStep/CheckBoxStep.mobileLabel.test.js +20 -12
- package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.js +6 -13
- package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.module.css +2 -13
- package/dist/FormSteps/ClassifierSelectorStep/ClassifierSelectorStep.lateClassifiers.test.d.ts +1 -0
- package/dist/FormSteps/ClassifierSelectorStep/ClassifierSelectorStep.lateClassifiers.test.js +70 -0
- package/dist/FormSteps/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.js +3 -1
- package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.js +26 -26
- package/dist/FormSteps/EntityValueStep/entityValueDependencyValue.d.ts +12 -0
- package/dist/FormSteps/EntityValueStep/entityValueDependencyValue.js +35 -0
- package/dist/FormSteps/EntityValueStep/entityValueDependencyValue.test.d.ts +1 -0
- package/dist/FormSteps/EntityValueStep/entityValueDependencyValue.test.js +31 -0
- package/dist/FormSteps/EntityValueStep/entityValuePickerWatchedSteps.d.ts +27 -0
- package/dist/FormSteps/EntityValueStep/entityValuePickerWatchedSteps.js +64 -0
- package/dist/FormSteps/EntityValueStep/entityValuePickerWatchedSteps.test.d.ts +1 -0
- package/dist/FormSteps/EntityValueStep/entityValuePickerWatchedSteps.test.js +95 -0
- package/dist/FormSteps/LocationStep/LocationStep.d.ts +10 -0
- package/dist/FormSteps/LocationStep/LocationStep.js +14 -0
- package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.d.ts +3 -0
- package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.js +54 -0
- package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.module.css +18 -0
- package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.d.ts +3 -0
- package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.js +170 -0
- package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.module.css +96 -0
- package/dist/FormSteps/NumberStep/NumberStep.d.ts +10 -0
- package/dist/FormSteps/NumberStep/NumberStep.js +14 -0
- package/dist/FormSteps/Step.js +16 -0
- package/dist/FormSteps/StepFunctions.js +14 -0
- package/dist/FormSteps/StepFunctions.test.js +54 -0
- package/dist/FormSteps/StepHooks.d.ts +21 -0
- package/dist/FormSteps/StepHooks.js +55 -8
- package/dist/FormSteps/StepHooks.test.d.ts +1 -0
- package/dist/FormSteps/StepHooks.test.js +92 -0
- package/dist/FormSteps/isStepHiddenByCondition.test.d.ts +1 -0
- package/dist/FormSteps/isStepHiddenByCondition.test.js +42 -0
- package/dist/Icons/AddIcon.d.ts +3 -0
- package/dist/Icons/AddIcon.js +7 -0
- package/dist/Icons/EditIcon.d.ts +3 -0
- package/dist/Icons/EditIcon.js +7 -0
- package/dist/Icons/RemoveIcon.d.ts +3 -0
- package/dist/Icons/RemoveIcon.js +7 -0
- package/dist/Icons/ViewDayIcon.d.ts +3 -0
- package/dist/Icons/ViewDayIcon.js +7 -0
- package/dist/Icons/ViewWeekIcon.d.ts +3 -0
- package/dist/Icons/ViewWeekIcon.js +7 -0
- package/dist/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.d.ts +19 -0
- package/dist/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.js +80 -0
- package/dist/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.module.css +88 -0
- package/dist/Shared/ErkAddressAutocomplete/googlePlaces.d.ts +29 -0
- package/dist/Shared/ErkAddressAutocomplete/googlePlaces.js +139 -0
- package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.d.ts +25 -0
- package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.js +112 -0
- package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.module.css +88 -0
- package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.test.d.ts +1 -0
- package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.test.js +73 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.d.ts +31 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.js +228 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.module.css +608 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.stories.d.ts +28 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.stories.js +117 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.stories.test.d.ts +1 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.stories.test.js +49 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.test.d.ts +1 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.test.js +107 -0
- package/dist/Shared/ErkDatePicker/ErkDatePicker.js +1 -3
- package/dist/Shared/ErkDateRangePicker/ErkDateRangePicker.d.ts +2 -3
- package/dist/Shared/ErkDateRangePicker/ErkDateRangePicker.js +1 -2
- package/dist/Shared/ErkIconButton/ErkIconButton.d.ts +17 -0
- package/dist/Shared/ErkIconButton/ErkIconButton.js +11 -0
- package/dist/Shared/ErkIconButton/ErkIconButton.module.css +41 -0
- package/dist/Shared/ErkLocationField/ErkLocationField.d.ts +24 -0
- package/dist/Shared/ErkLocationField/ErkLocationField.js +128 -0
- package/dist/Shared/ErkLocationField/ErkLocationField.module.css +164 -0
- package/dist/Shared/ErkLocationField/ErkLocationField.test.d.ts +1 -0
- package/dist/Shared/ErkLocationField/ErkLocationField.test.js +82 -0
- package/dist/Shared/ErkLocationField/addressFields.d.ts +12 -0
- package/dist/Shared/ErkLocationField/addressFields.js +34 -0
- package/dist/Shared/ErkLocationField/locationRestrictions.d.ts +6 -0
- package/dist/Shared/ErkLocationField/locationRestrictions.js +51 -0
- package/dist/Shared/ErkLocationInput/ErkLocationInput.d.ts +15 -0
- package/dist/Shared/ErkLocationInput/ErkLocationInput.js +502 -0
- package/dist/Shared/ErkLocationInput/ErkLocationInput.module.css +128 -0
- package/dist/Shared/ErkNumberField/ErkNumberField.d.ts +42 -0
- package/dist/Shared/ErkNumberField/ErkNumberField.js +169 -0
- package/dist/Utils/AxiosWidget.js +9 -1
- package/dist/constants/FormStepTypes.d.ts +5 -1
- package/dist/constants/FormStepTypes.js +4 -0
- package/dist/index.lib.d.ts +4 -2
- package/dist/index.lib.js +3 -1
- package/package.json +2 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NumberStepType, } from '../@Types/FormStep';
|
|
1
2
|
import FormStepTypes, { ApiSelectorOptionTypes, ClassifierOptionTypes, EntityValueDataTypes, EntityValueOptionTypes, OptionTypes, } from '../constants/FormStepTypes';
|
|
2
3
|
import CBRFormStepTypes from '../constants/CBRFormStepTypes';
|
|
3
4
|
import AYFFormStepTypes from '../constants/AYFFormStepTypes';
|
|
@@ -87,6 +88,8 @@ function recursivelyCheckOpenSize(idStep, steps, values) {
|
|
|
87
88
|
return size;
|
|
88
89
|
}
|
|
89
90
|
case FormStepTypes.DATEPICKER:
|
|
91
|
+
case FormStepTypes.LOCATION:
|
|
92
|
+
case FormStepTypes.NUMBER:
|
|
90
93
|
case FormStepTypes.TEXTINPUT: {
|
|
91
94
|
return step.size;
|
|
92
95
|
}
|
|
@@ -175,6 +178,17 @@ export const calcDefaultValue = (step) => {
|
|
|
175
178
|
return getRawText();
|
|
176
179
|
else
|
|
177
180
|
return '';
|
|
181
|
+
case FormStepTypes.LOCATION:
|
|
182
|
+
return step.defaultValue ?? null;
|
|
183
|
+
case FormStepTypes.NUMBER: {
|
|
184
|
+
const numStep = step;
|
|
185
|
+
if (numStep.numberType === NumberStepType.MONEY ||
|
|
186
|
+
numStep.numberType === NumberStepType.MEASURE ||
|
|
187
|
+
numStep.numberType === NumberStepType.UNIT_PRICE) {
|
|
188
|
+
return numStep.defaultValue ?? null;
|
|
189
|
+
}
|
|
190
|
+
return numStep.defaultValue ?? '';
|
|
191
|
+
}
|
|
178
192
|
case FormStepTypes.RATING:
|
|
179
193
|
case FormStepTypes.DATEPICKER:
|
|
180
194
|
case FormStepTypes.DATEPICKER_RANGE:
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as Steps from '../@Types/FormStep';
|
|
1
2
|
import AYFFormStepTypes from '../constants/AYFFormStepTypes';
|
|
2
3
|
import CBRFormStepTypes from '../constants/CBRFormStepTypes';
|
|
3
4
|
import FormStepTypes, { ApiSelectorOptionTypes, ClassifierOptionTypes, EntityValueOptionTypes, OptionTypes, } from '../constants/FormStepTypes';
|
|
@@ -527,6 +528,13 @@ describe('StepFunctions', function () {
|
|
|
527
528
|
const defaultValue = calcDefaultValue(step);
|
|
528
529
|
expect(defaultValue).toBe(null);
|
|
529
530
|
});
|
|
531
|
+
test('Location step type', async () => {
|
|
532
|
+
const step = {
|
|
533
|
+
type: FormStepTypes.LOCATION,
|
|
534
|
+
};
|
|
535
|
+
const defaultValue = calcDefaultValue(step);
|
|
536
|
+
expect(defaultValue).toBe(null);
|
|
537
|
+
});
|
|
530
538
|
test('Mapper, FileUpload, CBRFormStep types', async () => {
|
|
531
539
|
const step1 = {
|
|
532
540
|
type: FormStepTypes.MAPPER,
|
|
@@ -558,6 +566,52 @@ describe('StepFunctions', function () {
|
|
|
558
566
|
const defaultValue = calcDefaultValue(step);
|
|
559
567
|
expect(defaultValue).toBeUndefined();
|
|
560
568
|
});
|
|
569
|
+
test('Number step type without defaultValue', async () => {
|
|
570
|
+
const step1 = {
|
|
571
|
+
type: FormStepTypes.NUMBER,
|
|
572
|
+
numberType: Steps.NumberStepType.INTEGER,
|
|
573
|
+
};
|
|
574
|
+
const step2 = {
|
|
575
|
+
type: FormStepTypes.NUMBER,
|
|
576
|
+
numberType: Steps.NumberStepType.DECIMAL,
|
|
577
|
+
};
|
|
578
|
+
const step3 = {
|
|
579
|
+
type: FormStepTypes.NUMBER,
|
|
580
|
+
numberType: Steps.NumberStepType.PERCENTAGE,
|
|
581
|
+
};
|
|
582
|
+
const step4 = {
|
|
583
|
+
type: FormStepTypes.NUMBER,
|
|
584
|
+
numberType: Steps.NumberStepType.MONEY,
|
|
585
|
+
};
|
|
586
|
+
const step5 = {
|
|
587
|
+
type: FormStepTypes.NUMBER,
|
|
588
|
+
numberType: Steps.NumberStepType.MEASURE,
|
|
589
|
+
};
|
|
590
|
+
const step6 = {
|
|
591
|
+
type: FormStepTypes.NUMBER,
|
|
592
|
+
numberType: Steps.NumberStepType.UNIT_PRICE,
|
|
593
|
+
};
|
|
594
|
+
expect(calcDefaultValue(step1)).toBe('');
|
|
595
|
+
expect(calcDefaultValue(step2)).toBe('');
|
|
596
|
+
expect(calcDefaultValue(step3)).toBe('');
|
|
597
|
+
expect(calcDefaultValue(step4)).toBe(null);
|
|
598
|
+
expect(calcDefaultValue(step5)).toBe(null);
|
|
599
|
+
expect(calcDefaultValue(step6)).toBe(null);
|
|
600
|
+
});
|
|
601
|
+
test('Number step type with defaultValue', async () => {
|
|
602
|
+
const step1 = {
|
|
603
|
+
type: FormStepTypes.NUMBER,
|
|
604
|
+
numberType: Steps.NumberStepType.INTEGER,
|
|
605
|
+
defaultValue: 42,
|
|
606
|
+
};
|
|
607
|
+
const step2 = {
|
|
608
|
+
type: FormStepTypes.NUMBER,
|
|
609
|
+
numberType: Steps.NumberStepType.MONEY,
|
|
610
|
+
defaultValue: { value: 100, currency: 'USD' },
|
|
611
|
+
};
|
|
612
|
+
expect(calcDefaultValue(step1)).toBe(42);
|
|
613
|
+
expect(calcDefaultValue(step2)).toEqual({ value: 100, currency: 'USD' });
|
|
614
|
+
});
|
|
561
615
|
});
|
|
562
616
|
describe('iterateNestedSteps', function () {
|
|
563
617
|
test('should iterate over nested steps', async () => {
|
|
@@ -34,6 +34,13 @@ export interface StepDependency {
|
|
|
34
34
|
handleStepDep: (value: any) => void;
|
|
35
35
|
}
|
|
36
36
|
export declare const useStepDependency: (step: GBaseStep, defaultValue?: any) => StepDependency;
|
|
37
|
+
/**
|
|
38
|
+
* Whether `idStep` is currently kept off the form by its own visibility condition. A step that is not
|
|
39
|
+
* shown cannot be answered, so nothing may wait for it: a required entity filter pointing at it does
|
|
40
|
+
* not apply, and it never reads as a missing dependency. When the condition cannot be decided yet (a
|
|
41
|
+
* step it reads is not in the store) the step counts as shown, keeping the conservative behaviour.
|
|
42
|
+
*/
|
|
43
|
+
export declare const isStepHiddenByCondition: (idStep: string, form: Form, dependencies: DependencyStore) => boolean;
|
|
37
44
|
export declare const selectStepDependencies: ((state: RootState, _step: GBaseStep, form: Form) => {
|
|
38
45
|
invalids: string[];
|
|
39
46
|
emptyDep: boolean;
|
|
@@ -67,6 +74,20 @@ export declare const selectStepDependencies: ((state: RootState, _step: GBaseSte
|
|
|
67
74
|
memoize: typeof import("reselect").weakMapMemoize;
|
|
68
75
|
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
69
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* The steps `idStep` depends on, transitively: every dependency's own dependencies come before it,
|
|
79
|
+
* and every id is answered exactly once. `idStep` itself is never listed — a step is not a
|
|
80
|
+
* dependency of itself, even when a draft points it back at itself.
|
|
81
|
+
*
|
|
82
|
+
* A saved form is a DAG: the backend recomputes and validates `step.dependencies` on save. The
|
|
83
|
+
* editor's live preview renders unsaved drafts though, where a filter or a path hop can still point
|
|
84
|
+
* at the step that holds it, or close a cycle with another step. The walk must therefore terminate
|
|
85
|
+
* on any graph, cyclic included: a step is marked visited before it is walked and is never walked
|
|
86
|
+
* or listed twice, so every edge is followed at most once.
|
|
87
|
+
*
|
|
88
|
+
* Exported for the unit test; it is internal to this module and not part of the package's surface.
|
|
89
|
+
*/
|
|
90
|
+
export declare const calcDeepDependencies: (idStep: string, form: Form) => string[];
|
|
70
91
|
export interface UseFormStepOptions<ValueType> {
|
|
71
92
|
defaultValue: ValueType;
|
|
72
93
|
/** If true, will not trigger onChange until the user has finished typing */
|
|
@@ -8,6 +8,7 @@ import { useController } from 'react-hook-form';
|
|
|
8
8
|
import ConditionTypes from '../constants/ConditionTypes';
|
|
9
9
|
import FormStepTypes, { ApiSelectorOptionTypes, ClassifierOptionTypes, EntityValueOptionTypes, } from '../constants/FormStepTypes';
|
|
10
10
|
import { SizeChangeContext } from './Utils/@StepFiller/StepFillerContext';
|
|
11
|
+
import { entityValuePickerBlockingSteps } from './EntityValueStep/entityValuePickerWatchedSteps';
|
|
11
12
|
const selectIsDependency = createSelector([
|
|
12
13
|
(state) => state.site.dependencies,
|
|
13
14
|
(_state, step) => step,
|
|
@@ -47,6 +48,20 @@ export const useStepDependency = (step, defaultValue) => {
|
|
|
47
48
|
originalValue: originalValue ?? defaultValue ?? calcDefaultValue(step),
|
|
48
49
|
};
|
|
49
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* Whether `idStep` is currently kept off the form by its own visibility condition. A step that is not
|
|
53
|
+
* shown cannot be answered, so nothing may wait for it: a required entity filter pointing at it does
|
|
54
|
+
* not apply, and it never reads as a missing dependency. When the condition cannot be decided yet (a
|
|
55
|
+
* step it reads is not in the store) the step counts as shown, keeping the conservative behaviour.
|
|
56
|
+
*/
|
|
57
|
+
export const isStepHiddenByCondition = (idStep, form, dependencies) => {
|
|
58
|
+
const target = form.steps[idStep];
|
|
59
|
+
if (!target?.condition)
|
|
60
|
+
return false;
|
|
61
|
+
if (recursivelyCalcConditionSteps(target.condition).some((id) => dependencies[id] === undefined))
|
|
62
|
+
return false;
|
|
63
|
+
return !evaluateCondition(target.condition, dependencies);
|
|
64
|
+
};
|
|
50
65
|
export const selectStepDependencies = createSelector([
|
|
51
66
|
(state) => state.site.dependencies,
|
|
52
67
|
(_state, step) => step,
|
|
@@ -56,6 +71,8 @@ export const selectStepDependencies = createSelector([
|
|
|
56
71
|
let emptyDep = false;
|
|
57
72
|
/** Show deep error changes even if not in dependencies */
|
|
58
73
|
for (const idDep of calcDeepDependencies(step.id, form)) {
|
|
74
|
+
if (isStepHiddenByCondition(idDep, form, dependencies))
|
|
75
|
+
continue;
|
|
59
76
|
const dependency = dependencies[idDep];
|
|
60
77
|
if (dependency?.value === null && form.steps[idDep]) {
|
|
61
78
|
invalids.push(idDep);
|
|
@@ -65,15 +82,45 @@ export const selectStepDependencies = createSelector([
|
|
|
65
82
|
}
|
|
66
83
|
return { invalids, emptyDep };
|
|
67
84
|
});
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
85
|
+
/**
|
|
86
|
+
* The steps `idStep` depends on, transitively: every dependency's own dependencies come before it,
|
|
87
|
+
* and every id is answered exactly once. `idStep` itself is never listed — a step is not a
|
|
88
|
+
* dependency of itself, even when a draft points it back at itself.
|
|
89
|
+
*
|
|
90
|
+
* A saved form is a DAG: the backend recomputes and validates `step.dependencies` on save. The
|
|
91
|
+
* editor's live preview renders unsaved drafts though, where a filter or a path hop can still point
|
|
92
|
+
* at the step that holds it, or close a cycle with another step. The walk must therefore terminate
|
|
93
|
+
* on any graph, cyclic included: a step is marked visited before it is walked and is never walked
|
|
94
|
+
* or listed twice, so every edge is followed at most once.
|
|
95
|
+
*
|
|
96
|
+
* Exported for the unit test; it is internal to this module and not part of the package's surface.
|
|
97
|
+
*/
|
|
98
|
+
export const calcDeepDependencies = (idStep, form) => {
|
|
99
|
+
const deps = [];
|
|
100
|
+
/** `idStep` starts out visited so a cycle back to it stops there and never lists it. */
|
|
101
|
+
const visited = new Set([idStep]);
|
|
102
|
+
const walk = (id) => {
|
|
103
|
+
const step = form.steps[id];
|
|
104
|
+
if (!step)
|
|
105
|
+
return;
|
|
106
|
+
/**
|
|
107
|
+
* An entity picker also gives up (its options resolve to null) while a path hop or a
|
|
108
|
+
* required STEP filter holds no value. Those are in `step.dependencies` once the form has
|
|
109
|
+
* been saved, but not in an unsaved draft, so they are added here to read as a missing
|
|
110
|
+
* dependency instead of as a failed load.
|
|
111
|
+
*/
|
|
112
|
+
const idDeps = step.type === FormStepTypes.ENTITYVALUEPICKER
|
|
113
|
+
? [...(step.dependencies ?? []), ...entityValuePickerBlockingSteps(step)]
|
|
114
|
+
: step.dependencies;
|
|
115
|
+
for (const dep of idDeps ?? []) {
|
|
116
|
+
if (visited.has(dep))
|
|
117
|
+
continue;
|
|
118
|
+
visited.add(dep);
|
|
119
|
+
walk(dep);
|
|
120
|
+
deps.push(dep);
|
|
75
121
|
}
|
|
76
|
-
}
|
|
122
|
+
};
|
|
123
|
+
walk(idStep);
|
|
77
124
|
return deps;
|
|
78
125
|
};
|
|
79
126
|
export const useFormStep = (step, { rules, debounce, sizeChange, defaultValue }) => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
|
+
import FormStepTypes, { EntityValueDataTypes } from '../constants/FormStepTypes';
|
|
3
|
+
import { calcDeepDependencies } from './StepHooks';
|
|
4
|
+
const form = (steps) => ({
|
|
5
|
+
steps: Object.entries(steps).reduce((acc, [id, step]) => ({
|
|
6
|
+
...acc,
|
|
7
|
+
[id]: { id, idSection: 'section', type: FormStepTypes.TEXTINPUT, ...step },
|
|
8
|
+
}), {}),
|
|
9
|
+
});
|
|
10
|
+
const picker = (step) => ({
|
|
11
|
+
type: FormStepTypes.ENTITYVALUEPICKER,
|
|
12
|
+
idEntity: 'entity',
|
|
13
|
+
path: [],
|
|
14
|
+
filters: [],
|
|
15
|
+
options: {},
|
|
16
|
+
...step,
|
|
17
|
+
});
|
|
18
|
+
const stepFilter = (idStep, required) => ({
|
|
19
|
+
idProperty: 'prop-' + idStep,
|
|
20
|
+
type: EntityValueDataTypes.STEP,
|
|
21
|
+
idStep,
|
|
22
|
+
any: false,
|
|
23
|
+
required,
|
|
24
|
+
});
|
|
25
|
+
describe('calcDeepDependencies', () => {
|
|
26
|
+
test('walks a linear chain deepest first, listing each id once', () => {
|
|
27
|
+
const deps = calcDeepDependencies('a', form({
|
|
28
|
+
a: { dependencies: ['b'] },
|
|
29
|
+
b: { dependencies: ['c'] },
|
|
30
|
+
c: {},
|
|
31
|
+
}));
|
|
32
|
+
expect(deps).toEqual(['c', 'b']);
|
|
33
|
+
});
|
|
34
|
+
test('lists a dependency shared by two branches once', () => {
|
|
35
|
+
const deps = calcDeepDependencies('a', form({
|
|
36
|
+
a: { dependencies: ['b', 'c'] },
|
|
37
|
+
b: { dependencies: ['d'] },
|
|
38
|
+
c: { dependencies: ['d'] },
|
|
39
|
+
d: {},
|
|
40
|
+
}));
|
|
41
|
+
expect(deps).toEqual(['d', 'b', 'c']);
|
|
42
|
+
});
|
|
43
|
+
test('terminates on an A -> B -> A cycle without listing the step itself', () => {
|
|
44
|
+
const deps = calcDeepDependencies('a', form({
|
|
45
|
+
a: { dependencies: ['b'] },
|
|
46
|
+
b: { dependencies: ['a'] },
|
|
47
|
+
}));
|
|
48
|
+
expect(deps).toEqual(['b']);
|
|
49
|
+
});
|
|
50
|
+
test('terminates on a cycle reached deeper in the walk', () => {
|
|
51
|
+
const deps = calcDeepDependencies('a', form({
|
|
52
|
+
a: { dependencies: ['b'] },
|
|
53
|
+
b: { dependencies: ['c'] },
|
|
54
|
+
c: { dependencies: ['b'] },
|
|
55
|
+
}));
|
|
56
|
+
expect(deps).toEqual(['c', 'b']);
|
|
57
|
+
});
|
|
58
|
+
test('terminates on a step that depends on itself', () => {
|
|
59
|
+
const deps = calcDeepDependencies('a', form({
|
|
60
|
+
a: { dependencies: ['b'] },
|
|
61
|
+
b: { dependencies: ['b'] },
|
|
62
|
+
}));
|
|
63
|
+
expect(deps).toEqual(['b']);
|
|
64
|
+
});
|
|
65
|
+
/**
|
|
66
|
+
* A draft an entity picker points back at itself with a required STEP filter: the filter is not
|
|
67
|
+
* in the saved `dependencies` yet, so it only reaches the walk through
|
|
68
|
+
* `entityValuePickerBlockingSteps`.
|
|
69
|
+
*/
|
|
70
|
+
test('terminates on a self reference through a required STEP filter of an entity picker', () => {
|
|
71
|
+
const deps = calcDeepDependencies('a', form({
|
|
72
|
+
a: { dependencies: ['picker'] },
|
|
73
|
+
picker: picker({ filters: [stepFilter('picker', true)] }),
|
|
74
|
+
}));
|
|
75
|
+
expect(deps).toEqual(['picker']);
|
|
76
|
+
});
|
|
77
|
+
test('terminates on a cycle closed by a required STEP filter of an entity picker', () => {
|
|
78
|
+
const deps = calcDeepDependencies('a', form({
|
|
79
|
+
a: { dependencies: ['picker'] },
|
|
80
|
+
picker: picker({ filters: [stepFilter('other', true)] }),
|
|
81
|
+
other: { dependencies: ['picker'] },
|
|
82
|
+
}));
|
|
83
|
+
expect(deps).toEqual(['other', 'picker']);
|
|
84
|
+
});
|
|
85
|
+
test('keeps a dependency whose step the draft has already deleted', () => {
|
|
86
|
+
const deps = calcDeepDependencies('a', form({ a: { dependencies: ['gone'] } }));
|
|
87
|
+
expect(deps).toEqual(['gone']);
|
|
88
|
+
});
|
|
89
|
+
test('answers nothing for a step the form does not hold', () => {
|
|
90
|
+
expect(calcDeepDependencies('missing', form({}))).toEqual([]);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
|
+
import { isStepHiddenByCondition } from './StepHooks';
|
|
3
|
+
// A Selector shown only while the Proyecto picker holds a specific value — the shape the editor saves.
|
|
4
|
+
const PROYECTO = 'ENTITYVALUEPICKER-proyecto';
|
|
5
|
+
const condition = {
|
|
6
|
+
type: 'EXPRESSION',
|
|
7
|
+
expression: 'AND',
|
|
8
|
+
conditions: [
|
|
9
|
+
{ type: 'FORM_STEP', stepType: 'ENTITYVALUEPICKER', idStep: PROYECTO, operator: 'EXISTS' },
|
|
10
|
+
{ type: 'FORM_STEP', stepType: 'ENTITYVALUEPICKER', idStep: PROYECTO, operator: 'EQUAL', values: ['kai'] },
|
|
11
|
+
],
|
|
12
|
+
};
|
|
13
|
+
const form = {
|
|
14
|
+
steps: {
|
|
15
|
+
[PROYECTO]: { id: PROYECTO, type: 'ENTITYVALUEPICKER' },
|
|
16
|
+
'SELECTOR-piso': { id: 'SELECTOR-piso', type: 'SELECTOR', condition },
|
|
17
|
+
'SELECTOR-libre': { id: 'SELECTOR-libre', type: 'SELECTOR' },
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
const dependency = (value) => ({
|
|
21
|
+
idOriginal: PROYECTO,
|
|
22
|
+
dependents: [],
|
|
23
|
+
value,
|
|
24
|
+
type: 'ENTITYVALUEPICKER',
|
|
25
|
+
});
|
|
26
|
+
describe('isStepHiddenByCondition', () => {
|
|
27
|
+
test('a step without condition is never hidden', () => {
|
|
28
|
+
expect(isStepHiddenByCondition('SELECTOR-libre', form, {})).toBe(false);
|
|
29
|
+
});
|
|
30
|
+
test('a step whose condition evaluates false is hidden', () => {
|
|
31
|
+
expect(isStepHiddenByCondition('SELECTOR-piso', form, { [PROYECTO]: dependency({ _id: 'otro' }) })).toBe(true);
|
|
32
|
+
});
|
|
33
|
+
test('a step whose condition evaluates true is shown', () => {
|
|
34
|
+
expect(isStepHiddenByCondition('SELECTOR-piso', form, { [PROYECTO]: dependency({ _id: 'kai' }) })).toBe(false);
|
|
35
|
+
});
|
|
36
|
+
test('an undecidable condition (its step is not in the store) counts as shown', () => {
|
|
37
|
+
expect(isStepHiddenByCondition('SELECTOR-piso', form, {})).toBe(false);
|
|
38
|
+
});
|
|
39
|
+
test('a step unknown to the form counts as shown', () => {
|
|
40
|
+
expect(isStepHiddenByCondition('MAPPER-x-espacio', form, {})).toBe(false);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useIconProps } from './@ErkIcon';
|
|
3
|
+
function AddIcon(props) {
|
|
4
|
+
const iconProps = useIconProps(props);
|
|
5
|
+
return (_jsx("svg", { ...iconProps, viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" }) }));
|
|
6
|
+
}
|
|
7
|
+
export default AddIcon;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useIconProps } from './@ErkIcon';
|
|
3
|
+
function EditIcon(props) {
|
|
4
|
+
const iconProps = useIconProps(props);
|
|
5
|
+
return (_jsx("svg", { ...iconProps, version: "1.1", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z" }) }));
|
|
6
|
+
}
|
|
7
|
+
export default EditIcon;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useIconProps } from './@ErkIcon';
|
|
3
|
+
function RemoveIcon(props) {
|
|
4
|
+
const iconProps = useIconProps(props);
|
|
5
|
+
return (_jsx("svg", { ...iconProps, viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M19 13H5v-2h14v2z" }) }));
|
|
6
|
+
}
|
|
7
|
+
export default RemoveIcon;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useIconProps } from './@ErkIcon';
|
|
3
|
+
function ViewDayIcon(props) {
|
|
4
|
+
const iconProps = useIconProps(props);
|
|
5
|
+
return (_jsx("svg", { ...iconProps, viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M2 21h19v-2H2v2zm0-4h19v-8H2v8zm0-10h19V5H2v2z" }) }));
|
|
6
|
+
}
|
|
7
|
+
export default ViewDayIcon;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useIconProps } from './@ErkIcon';
|
|
3
|
+
function ViewWeekIcon(props) {
|
|
4
|
+
const iconProps = useIconProps(props);
|
|
5
|
+
return (_jsx("svg", { ...iconProps, viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M6 5H3c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h3c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1zm14 0h-3c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h3c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1zm-7 0h-3c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h3c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1z" }) }));
|
|
6
|
+
}
|
|
7
|
+
export default ViewWeekIcon;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { LocationStepValue } from '../../@Types/LocationFormStep';
|
|
3
|
+
export interface ErkAddressAutocompleteProps {
|
|
4
|
+
value?: LocationStepValue | null;
|
|
5
|
+
onChange: (value: LocationStepValue) => void;
|
|
6
|
+
/** ISO-2 para acotar las sugerencias (ej. ['co']). */
|
|
7
|
+
regionCodes?: string[];
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
error?: boolean;
|
|
10
|
+
required?: boolean;
|
|
11
|
+
readOnly?: boolean;
|
|
12
|
+
inputRef?: React.Ref<HTMLInputElement>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Buscador de direcciones con el `Autocomplete` de Base UI + Google Places.
|
|
16
|
+
* Emite un `LocationStepValue` (source GOOGLE_PLACES) con el desglose estructurado.
|
|
17
|
+
*/
|
|
18
|
+
declare function ErkAddressAutocomplete({ value, onChange, regionCodes, placeholder, error, required, readOnly, inputRef, }: ErkAddressAutocompleteProps): JSX.Element;
|
|
19
|
+
export default ErkAddressAutocomplete;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { Autocomplete } from '@base-ui/react/autocomplete';
|
|
4
|
+
import { fetchAddressSuggestions, loadPlaces, newSessionToken, resolvePrediction, } from './googlePlaces';
|
|
5
|
+
import styles from './ErkAddressAutocomplete.module.css';
|
|
6
|
+
/**
|
|
7
|
+
* Buscador de direcciones con el `Autocomplete` de Base UI + Google Places.
|
|
8
|
+
* Emite un `LocationStepValue` (source GOOGLE_PLACES) con el desglose estructurado.
|
|
9
|
+
*/
|
|
10
|
+
function ErkAddressAutocomplete({ value, onChange, regionCodes = ['co'], placeholder = 'Buscar dirección…', error = false, required = false, readOnly = false, inputRef, }) {
|
|
11
|
+
const apiKey = import.meta.env.VITE_GOOGLE_MAPS_API_KEY ?? '';
|
|
12
|
+
const [ready, setReady] = useState(false);
|
|
13
|
+
const [inputValue, setInputValue] = useState(value?.address ?? value?.name ?? '');
|
|
14
|
+
const [options, setOptions] = useState([]);
|
|
15
|
+
const [loading, setLoading] = useState(false);
|
|
16
|
+
const [hasSearched, setHasSearched] = useState(false);
|
|
17
|
+
const debounceRef = useRef(undefined);
|
|
18
|
+
const sessionTokenRef = useRef(undefined);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (readOnly)
|
|
21
|
+
return;
|
|
22
|
+
let active = true;
|
|
23
|
+
void loadPlaces(apiKey)
|
|
24
|
+
.then(() => {
|
|
25
|
+
if (!active)
|
|
26
|
+
return;
|
|
27
|
+
sessionTokenRef.current = newSessionToken();
|
|
28
|
+
setReady(true);
|
|
29
|
+
})
|
|
30
|
+
.catch(() => {
|
|
31
|
+
if (active)
|
|
32
|
+
setReady(false);
|
|
33
|
+
});
|
|
34
|
+
return () => {
|
|
35
|
+
active = false;
|
|
36
|
+
};
|
|
37
|
+
}, [apiKey, readOnly]);
|
|
38
|
+
const handleInput = useCallback((text) => {
|
|
39
|
+
setInputValue(text);
|
|
40
|
+
if (debounceRef.current)
|
|
41
|
+
clearTimeout(debounceRef.current);
|
|
42
|
+
if (!ready || !text || text.length < 3) {
|
|
43
|
+
setOptions([]);
|
|
44
|
+
setHasSearched(false);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
setLoading(true);
|
|
48
|
+
debounceRef.current = setTimeout(() => {
|
|
49
|
+
void (async () => {
|
|
50
|
+
try {
|
|
51
|
+
setOptions(await fetchAddressSuggestions(text, {
|
|
52
|
+
sessionToken: sessionTokenRef.current,
|
|
53
|
+
regionCodes,
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
setOptions([]);
|
|
58
|
+
}
|
|
59
|
+
finally {
|
|
60
|
+
setLoading(false);
|
|
61
|
+
setHasSearched(true);
|
|
62
|
+
}
|
|
63
|
+
})();
|
|
64
|
+
}, 300);
|
|
65
|
+
}, [ready, regionCodes]);
|
|
66
|
+
const handleSelect = useCallback(async (prediction) => {
|
|
67
|
+
try {
|
|
68
|
+
const stepValue = await resolvePrediction(prediction);
|
|
69
|
+
setInputValue(stepValue.address ?? stepValue.name ?? prediction.label);
|
|
70
|
+
setOptions([]);
|
|
71
|
+
onChange(stepValue);
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
// Cada selección cierra la sesión de billing de Google.
|
|
75
|
+
sessionTokenRef.current = newSessionToken();
|
|
76
|
+
}
|
|
77
|
+
}, [onChange]);
|
|
78
|
+
return (_jsxs(Autocomplete.Root, { items: options, mode: "none", value: inputValue, onValueChange: handleInput, disabled: readOnly, children: [_jsx(Autocomplete.Input, { ref: inputRef, placeholder: placeholder, required: required, readOnly: readOnly, className: error ? `${styles.input} ${styles.inputError}` : styles.input }), _jsx(Autocomplete.Portal, { children: _jsx(Autocomplete.Positioner, { className: styles.positioner, sideOffset: 4, children: _jsxs(Autocomplete.Popup, { className: styles.popup, children: [loading && _jsx("div", { className: styles.status, children: "Buscando\u2026" }), _jsx(Autocomplete.Empty, { className: styles.status, children: hasSearched ? 'No se encontraron resultados' : 'Escribe para buscar…' }), _jsx(Autocomplete.List, { className: styles.list, children: (option) => (_jsxs(Autocomplete.Item, { value: option, className: styles.item, onClick: () => void handleSelect(option), children: [_jsx("span", { className: styles.optionLabel, children: option.label }), option.description && (_jsx("span", { className: styles.optionDescription, children: option.description }))] }, option.placeId)) })] }) }) })] }));
|
|
79
|
+
}
|
|
80
|
+
export default ErkAddressAutocomplete;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
.input {
|
|
2
|
+
width: 100%;
|
|
3
|
+
box-sizing: border-box;
|
|
4
|
+
height: 31px;
|
|
5
|
+
padding: 6px 12px;
|
|
6
|
+
font-size: 1rem;
|
|
7
|
+
font-family: inherit;
|
|
8
|
+
color: var(--eureka-text, #293241);
|
|
9
|
+
background-color: var(--eureka-bg, #fff);
|
|
10
|
+
border: 1px solid var(--eureka-outline, #b8b8b8);
|
|
11
|
+
border-radius: 10px;
|
|
12
|
+
outline: none;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.input::placeholder {
|
|
16
|
+
color: var(--eureka-text, #293241);
|
|
17
|
+
opacity: 0.5;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.input:hover:not(:disabled):not(:read-only) {
|
|
21
|
+
border-color: var(--eureka-primary, #3d5a7f);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.input:focus:not(:read-only) {
|
|
25
|
+
border-color: var(--eureka-primary, #3d5a7f);
|
|
26
|
+
border-width: 2px;
|
|
27
|
+
padding: 5px 11px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.input:disabled {
|
|
31
|
+
opacity: 0.5;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.inputError {
|
|
35
|
+
border-color: var(--eureka-error, #e53935);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.positioner {
|
|
39
|
+
z-index: 1400;
|
|
40
|
+
width: var(--anchor-width);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.popup {
|
|
44
|
+
box-sizing: border-box;
|
|
45
|
+
max-height: 320px;
|
|
46
|
+
overflow-y: auto;
|
|
47
|
+
padding: 4px;
|
|
48
|
+
background-color: var(--eureka-bg, #fff);
|
|
49
|
+
border: 1px solid var(--eureka-outline, #b8b8b8);
|
|
50
|
+
border-radius: 10px;
|
|
51
|
+
box-shadow: 0 4px 16px rgb(0 0 0 / 12%);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.list {
|
|
55
|
+
display: flex;
|
|
56
|
+
flex-direction: column;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.status {
|
|
60
|
+
padding: 10px 12px;
|
|
61
|
+
font-size: 0.875rem;
|
|
62
|
+
color: var(--eureka-text, #666);
|
|
63
|
+
opacity: 0.7;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.item {
|
|
67
|
+
display: flex;
|
|
68
|
+
flex-direction: column;
|
|
69
|
+
gap: 2px;
|
|
70
|
+
padding: 8px 12px;
|
|
71
|
+
border-radius: 8px;
|
|
72
|
+
cursor: pointer;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.item[data-highlighted],
|
|
76
|
+
.item:hover {
|
|
77
|
+
background-color: var(--eureka-primary, #3d5a7f);
|
|
78
|
+
color: #fff;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.optionLabel {
|
|
82
|
+
font-size: 0.9375rem;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.optionDescription {
|
|
86
|
+
font-size: 0.8125rem;
|
|
87
|
+
opacity: 0.7;
|
|
88
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { LocationAddressDetail, LocationStepValue } from '../../@Types/LocationFormStep';
|
|
2
|
+
/** Asegura el script cargado y las clases de Places listas. Idempotente. */
|
|
3
|
+
export declare function loadPlaces(apiKey: string): Promise<void>;
|
|
4
|
+
/** Token de sesión nuevo (mejora el billing/relevancia de Google). */
|
|
5
|
+
export declare function newSessionToken(): any;
|
|
6
|
+
/** Reverse-geocoding para el modo GPS: coordenadas → dirección estructurada. */
|
|
7
|
+
export declare function reverseGeocode(apiKey: string, lat: number, lng: number): Promise<{
|
|
8
|
+
address?: string;
|
|
9
|
+
addressDetail: LocationAddressDetail;
|
|
10
|
+
}>;
|
|
11
|
+
export interface AddressPrediction {
|
|
12
|
+
placeId: string;
|
|
13
|
+
label: string;
|
|
14
|
+
description: string;
|
|
15
|
+
toPlace: () => any;
|
|
16
|
+
}
|
|
17
|
+
export interface FetchSuggestionsOptions {
|
|
18
|
+
sessionToken?: any;
|
|
19
|
+
/** ISO-2, ej. ['co'] */
|
|
20
|
+
regionCodes?: string[];
|
|
21
|
+
}
|
|
22
|
+
export declare function fetchAddressSuggestions(input: string, options?: FetchSuggestionsOptions): Promise<AddressPrediction[]>;
|
|
23
|
+
/**
|
|
24
|
+
* Descompone los `addressComponents` de un Place en el shape estructurado del step.
|
|
25
|
+
* Acepta el formato nuevo (`longText`/`shortText`) y el legacy (`long_name`/`short_name`).
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseAddressComponents(components: any[] | null | undefined): LocationAddressDetail;
|
|
28
|
+
/** Resuelve una predicción a un `LocationStepValue` completo (fetchFields + parse). */
|
|
29
|
+
export declare function resolvePrediction(prediction: AddressPrediction): Promise<LocationStepValue>;
|