@yext/visual-editor 2.0.0-beta.11 → 2.0.0-beta.13
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/{SectionLibraryVisualEditorProvider-DJMXab-H.js → SectionLibraryVisualEditorProvider-64whofF8.js} +5861 -5761
- package/dist/cli/assets/directory-locator-source/components/sections/locator/Filters.test.tsx +1 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/Filters.tsx +9 -8
- package/dist/cli/assets/directory-locator-source/components/sections/locator/Locator.test.tsx +1 -1
- package/dist/cli/assets/directory-locator-source/components/sections/locator/Locator.tsx +104 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/LocatorFields.test.ts +66 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/LocatorRadius.test.ts +700 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/LocatorResultCard.tsx +29 -1
- package/dist/cli/assets/directory-locator-source/components/sections/locator/LocatorWrapper.test.ts +370 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/LocatorWrapper.tsx +270 -39
- package/dist/cli/assets/directory-locator-source/components/sections/locator/Map.tsx +91 -12
- package/dist/cli/assets/directory-locator-source/components/sections/locator/Results.tsx +11 -6
- package/dist/cli/assets/directory-locator-source/components/sections/locator/distanceUnits.ts +7 -0
- package/dist/cli/assets/directory-locator-source/sectionLibrarySupport.ts +4 -0
- package/dist/cli/yextve.js +3 -3
- package/dist/{createYextFieldTransforms-B7vqqb3m.d.ts → createYextFieldTransforms-w-U4b5Zf.d.ts} +27 -17
- package/dist/index.d.ts +36 -11
- package/dist/locales/platform/cs/visual-editor.json +10 -0
- package/dist/locales/platform/da/visual-editor.json +10 -0
- package/dist/locales/platform/de/visual-editor.json +10 -0
- package/dist/locales/platform/en/visual-editor.json +10 -0
- package/dist/locales/platform/en-GB/visual-editor.json +10 -0
- package/dist/locales/platform/es/visual-editor.json +10 -0
- package/dist/locales/platform/et/visual-editor.json +10 -0
- package/dist/locales/platform/fi/visual-editor.json +10 -0
- package/dist/locales/platform/fr/visual-editor.json +10 -0
- package/dist/locales/platform/hr/visual-editor.json +10 -0
- package/dist/locales/platform/hu/visual-editor.json +10 -0
- package/dist/locales/platform/it/visual-editor.json +10 -0
- package/dist/locales/platform/ja/visual-editor.json +10 -0
- package/dist/locales/platform/lt/visual-editor.json +10 -0
- package/dist/locales/platform/lv/visual-editor.json +10 -0
- package/dist/locales/platform/nb/visual-editor.json +10 -0
- package/dist/locales/platform/nl/visual-editor.json +10 -0
- package/dist/locales/platform/pl/visual-editor.json +10 -0
- package/dist/locales/platform/pt/visual-editor.json +10 -0
- package/dist/locales/platform/ro/visual-editor.json +10 -0
- package/dist/locales/platform/sk/visual-editor.json +10 -0
- package/dist/locales/platform/sv/visual-editor.json +10 -0
- package/dist/locales/platform/tr/visual-editor.json +10 -0
- package/dist/locales/platform/zh/visual-editor.json +10 -0
- package/dist/locales/platform/zh-TW/visual-editor.json +10 -0
- package/dist/plugin/plugin.js +2 -1
- package/dist/plugin/vite-plugin/layout-generation/modelProxy.d.ts +1 -1
- package/dist/section-library-support.js +67 -67
- package/dist/sectionLibrarySupport.d.ts +2 -2
- package/dist/{visual-editor-DTE5kxrA.js → visual-editor-B84T0Hz5.js} +84 -74
- package/dist/{visual-editor-6mKs9VUe.js → visual-editor-B8eVGZjZ.js} +26 -16
- package/dist/{visual-editor-Bs3wAslG.js → visual-editor-BTv1Bren.js} +62 -52
- package/dist/{visual-editor-DkHhrFsX.js → visual-editor-BWJvQ6QT.js} +110 -100
- package/dist/{visual-editor-D7VeTRK_.js → visual-editor-BWk-Ri1i.js} +73 -63
- package/dist/{visual-editor-LXMNWXry.js → visual-editor-BdM7VUac.js} +76 -66
- package/dist/{visual-editor-ClC6hoz3.js → visual-editor-BmM2bYhg.js} +82 -72
- package/dist/{visual-editor-qJW0uCiQ.js → visual-editor-BuRftlWt.js} +89 -79
- package/dist/{visual-editor-DjTEbi-1.js → visual-editor-BxnbtD_z.js} +63 -53
- package/dist/{visual-editor-CcfUKpnd.js → visual-editor-C4Nretnd.js} +59 -49
- package/dist/{visual-editor-Duishbsa.js → visual-editor-CFE4ijeV.js} +54 -44
- package/dist/{visual-editor-DtL-Zuv_.js → visual-editor-CMfDvLU2.js} +86 -76
- package/dist/{visual-editor-BK6fTU7k.js → visual-editor-CauX7_Ur.js} +27 -17
- package/dist/{visual-editor-QpGupjY5.js → visual-editor-D5d9meOo.js} +93 -83
- package/dist/{visual-editor-gEaWoNRu.js → visual-editor-D9U8TxD-.js} +51 -41
- package/dist/{visual-editor-CtQwadxQ.js → visual-editor-DBZwjDQd.js} +47 -37
- package/dist/{visual-editor-_TatCCAS.js → visual-editor-DI6rS2dP.js} +116 -106
- package/dist/{visual-editor-sOPDMkOR.js → visual-editor-DOioJ5CW.js} +84 -74
- package/dist/{visual-editor-zKhC7_0C.js → visual-editor-D_EvXM08.js} +71 -61
- package/dist/{visual-editor-BruRrJYN.js → visual-editor-DguhAL12.js} +10 -0
- package/dist/{visual-editor-CHWtMtlu.js → visual-editor-DmsRSmAI.js} +90 -80
- package/dist/{visual-editor-vomNdlNO.js → visual-editor-DnNNHiLS.js} +86 -76
- package/dist/{visual-editor-C9TLeAzP.js → visual-editor-DvksDrGT.js} +59 -49
- package/dist/{visual-editor-tPb7n5l8.js → visual-editor-XsBMHUSs.js} +66 -56
- package/dist/{visual-editor-gjpr-NAN.js → visual-editor-kiT3ocKi.js} +60 -50
- package/dist/visual-editor.css +1 -1
- package/dist/visual-editor.js +7003 -6609
- package/package.json +3 -3
package/dist/cli/assets/directory-locator-source/components/sections/locator/Filters.test.tsx
CHANGED
|
@@ -106,6 +106,7 @@ const renderFilterModal = (
|
|
|
106
106
|
isOpenNowSelected={false}
|
|
107
107
|
showDistanceOptions={false}
|
|
108
108
|
selectedDistanceOption={null}
|
|
109
|
+
distanceUnit="kilometer"
|
|
109
110
|
handleCloseModalClick={vi.fn()}
|
|
110
111
|
handleOpenNowClick={vi.fn()}
|
|
111
112
|
handleDistanceClick={vi.fn()}
|
|
@@ -18,12 +18,12 @@ import { useCollapse } from "react-collapsed";
|
|
|
18
18
|
import { useTranslation } from "react-i18next";
|
|
19
19
|
import { FaChevronUp, FaDotCircle, FaRegCircle, FaTimes } from "react-icons/fa";
|
|
20
20
|
import { type TranslatableString } from "../../../types/types.ts";
|
|
21
|
-
import { getPreferredDistanceUnit } from "../../../utils/i18n/distance.ts";
|
|
22
21
|
import { msg } from "../../../utils/i18n/platform.ts";
|
|
23
22
|
import { LocatorEntityType } from "../../../utils/locatorEntityTypes.ts";
|
|
24
23
|
import { resolveComponentData } from "../../../utils/resolveComponentData.tsx";
|
|
25
24
|
import { Body } from "../../atoms/body.tsx";
|
|
26
25
|
import { translateDistanceUnit } from "./Results.tsx";
|
|
26
|
+
import type { DistanceUnit } from "./distanceUnits.ts";
|
|
27
27
|
|
|
28
28
|
export const LOCATION_FIELD = "builtin.location";
|
|
29
29
|
export const COUNTRY_CODE_FIELD = "address.countryCode";
|
|
@@ -36,12 +36,10 @@ interface FilterModalProps {
|
|
|
36
36
|
isOpenNowSelected: boolean; // whether the Open Now filter is currently selected by the user
|
|
37
37
|
showDistanceOptions: boolean; // whether to show the Distance filter option
|
|
38
38
|
selectedDistanceOption: number | null;
|
|
39
|
+
distanceUnit: DistanceUnit;
|
|
39
40
|
handleCloseModalClick: () => void;
|
|
40
41
|
handleOpenNowClick: (selected: boolean) => void;
|
|
41
|
-
handleDistanceClick: (
|
|
42
|
-
distance: number,
|
|
43
|
-
distanceUnit: "mile" | "kilometer"
|
|
44
|
-
) => void;
|
|
42
|
+
handleDistanceClick: (distance: number, distanceUnit: DistanceUnit) => void;
|
|
45
43
|
handleClearFiltersClick: () => void;
|
|
46
44
|
accentColorCssValue: string;
|
|
47
45
|
closeButtonRef: React.Ref<HTMLButtonElement>;
|
|
@@ -54,6 +52,7 @@ export const FilterModal = ({
|
|
|
54
52
|
isOpenNowSelected,
|
|
55
53
|
showDistanceOptions,
|
|
56
54
|
selectedDistanceOption,
|
|
55
|
+
distanceUnit,
|
|
57
56
|
handleCloseModalClick,
|
|
58
57
|
handleOpenNowClick,
|
|
59
58
|
handleDistanceClick,
|
|
@@ -136,6 +135,7 @@ export const FilterModal = ({
|
|
|
136
135
|
<DistanceFilter
|
|
137
136
|
onChange={handleDistanceClick}
|
|
138
137
|
selectedDistanceOption={selectedDistanceOption}
|
|
138
|
+
unit={distanceUnit}
|
|
139
139
|
accentColorCssValue={accentColorCssValue}
|
|
140
140
|
/>
|
|
141
141
|
)}
|
|
@@ -212,17 +212,19 @@ const OpenNowFilter = ({ isSelected, onChange }: OpenNowFilterProps) => {
|
|
|
212
212
|
};
|
|
213
213
|
|
|
214
214
|
interface DistanceFilterProps {
|
|
215
|
-
onChange: (distance: number, unit:
|
|
215
|
+
onChange: (distance: number, unit: DistanceUnit) => void;
|
|
216
216
|
selectedDistanceOption: number | null;
|
|
217
|
+
unit: DistanceUnit;
|
|
217
218
|
accentColorCssValue: string;
|
|
218
219
|
}
|
|
219
220
|
|
|
220
221
|
const DistanceFilter = ({
|
|
221
222
|
onChange,
|
|
222
223
|
selectedDistanceOption,
|
|
224
|
+
unit,
|
|
223
225
|
accentColorCssValue,
|
|
224
226
|
}: DistanceFilterProps) => {
|
|
225
|
-
const { t
|
|
227
|
+
const { t } = useTranslation();
|
|
226
228
|
const { isExpanded, getToggleProps, getCollapseProps } = useCollapse({
|
|
227
229
|
defaultExpanded: true,
|
|
228
230
|
});
|
|
@@ -230,7 +232,6 @@ const DistanceFilter = ({
|
|
|
230
232
|
? "w-3 text-gray-400"
|
|
231
233
|
: "w-3 text-gray-400 transform rotate-180";
|
|
232
234
|
const distanceOptions = [5, 10, 25, 50];
|
|
233
|
-
const unit = getPreferredDistanceUnit(i18n.language);
|
|
234
235
|
|
|
235
236
|
return (
|
|
236
237
|
<div className="flex flex-col gap-4">
|
package/dist/cli/assets/directory-locator-source/components/sections/locator/Locator.test.tsx
CHANGED
|
@@ -1471,7 +1471,7 @@ describe("Locator", async () => {
|
|
|
1471
1471
|
String(input).includes("/search/filtersearch")
|
|
1472
1472
|
)
|
|
1473
1473
|
).toBe(false);
|
|
1474
|
-
expect(screen.
|
|
1474
|
+
expect(await screen.findByText(/Custom Search Area/)).toBeInTheDocument();
|
|
1475
1475
|
} finally {
|
|
1476
1476
|
window.history.replaceState(window.history.state, "", originalUrl);
|
|
1477
1477
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getPreferredDistanceUnit } from "../../../utils/i18n/distance.ts";
|
|
1
2
|
import { FieldLabel, setDeep } from "@puckeditor/core";
|
|
2
3
|
import { type MultiSelectorValue } from "../../../fields/MultiSelectorField.tsx";
|
|
3
4
|
import { YextAutoField } from "../../../fields/YextAutoField.tsx";
|
|
@@ -30,10 +31,17 @@ import {
|
|
|
30
31
|
} from "./LocatorResultCard.tsx";
|
|
31
32
|
import { ResultCardPropsField } from "./Results.tsx";
|
|
32
33
|
import { LocatorWrapper } from "./LocatorWrapper.tsx";
|
|
34
|
+
import {
|
|
35
|
+
BROWSER_LANGUAGE,
|
|
36
|
+
KILOMETER,
|
|
37
|
+
MILE,
|
|
38
|
+
type DefaultDistanceUnit,
|
|
39
|
+
} from "./distanceUnits.ts";
|
|
33
40
|
import {
|
|
34
41
|
DEFAULT_LOCATION_STYLE,
|
|
35
42
|
DEFAULT_MAKI_ICON_NAME,
|
|
36
43
|
DEFAULT_PIN_ICON_WIDTH,
|
|
44
|
+
DEFAULT_RADIUS,
|
|
37
45
|
LOCATOR_PIN_ICON_FIELD,
|
|
38
46
|
MAX_PIN_ICON_WIDTH,
|
|
39
47
|
makiIconOptions,
|
|
@@ -42,6 +50,13 @@ const DEFAULT_TITLE = "Find a Location";
|
|
|
42
50
|
const DEFAULT_DISTANCE_DISPLAY = "distanceFromUser";
|
|
43
51
|
|
|
44
52
|
export interface LocatorProps {
|
|
53
|
+
/**
|
|
54
|
+
* Search the visible map area 500 ms after the user stops a pan or zoom.
|
|
55
|
+
* If enabled, hide the Search This Area button.
|
|
56
|
+
* @defaultValue false
|
|
57
|
+
*/
|
|
58
|
+
autoSearchOnMapMove?: boolean;
|
|
59
|
+
|
|
45
60
|
/**
|
|
46
61
|
* The visual theme for the map tiles, chosen from a predefined list of Mapbox styles.
|
|
47
62
|
* @defaultValue 'mapbox://styles/mapbox/streets-v12'
|
|
@@ -98,6 +113,17 @@ export interface LocatorProps {
|
|
|
98
113
|
keywordsDisplayName?: TranslatableString;
|
|
99
114
|
};
|
|
100
115
|
|
|
116
|
+
/**
|
|
117
|
+
* The default radius for nearby-location searches. Leave unset to use Search's
|
|
118
|
+
* suggested radius, or 25 in the configured default distance unit for coordinate searches.
|
|
119
|
+
* Visitor-selected distances and explicit map/URL search areas take precedence.
|
|
120
|
+
* Geographic boundary filters are unaffected.
|
|
121
|
+
*/
|
|
122
|
+
defaultSearchRadius?: {
|
|
123
|
+
value?: number;
|
|
124
|
+
unit: "mile" | "kilometer";
|
|
125
|
+
};
|
|
126
|
+
|
|
101
127
|
/**
|
|
102
128
|
* The starting location for the map.
|
|
103
129
|
*/
|
|
@@ -127,6 +153,10 @@ export interface LocatorProps {
|
|
|
127
153
|
/** Props to customize the locator result card component. */
|
|
128
154
|
props: LocatorResultCardProps;
|
|
129
155
|
}>;
|
|
156
|
+
/** Whether visitors can switch the locator between miles and kilometers. */
|
|
157
|
+
showDistanceUnitToggle?: boolean;
|
|
158
|
+
/** Unit used before a visitor selects one. Defaults to the page language. */
|
|
159
|
+
defaultDistanceUnit?: DefaultDistanceUnit;
|
|
130
160
|
/** Controls which distance value to display on each locator result card. */
|
|
131
161
|
distanceDisplay?: DistanceDisplayOption;
|
|
132
162
|
}
|
|
@@ -336,6 +366,37 @@ const locatorFields: YextFields<LocatorProps> = {
|
|
|
336
366
|
},
|
|
337
367
|
},
|
|
338
368
|
},
|
|
369
|
+
defaultSearchRadius: {
|
|
370
|
+
type: "optional",
|
|
371
|
+
label: msg("fields.defaultSearchRadius", "Default Search Radius"),
|
|
372
|
+
defaultCustomValue: ({ locale }) => ({
|
|
373
|
+
value: DEFAULT_RADIUS,
|
|
374
|
+
unit: getPreferredDistanceUnit(locale),
|
|
375
|
+
}),
|
|
376
|
+
field: {
|
|
377
|
+
type: "object",
|
|
378
|
+
objectFields: {
|
|
379
|
+
value: {
|
|
380
|
+
type: "number",
|
|
381
|
+
label: msg("fields.radius", "Radius"),
|
|
382
|
+
min: 0,
|
|
383
|
+
step: 1,
|
|
384
|
+
},
|
|
385
|
+
unit: {
|
|
386
|
+
type: "basicSelector",
|
|
387
|
+
generation: { required: true },
|
|
388
|
+
label: msg("fields.distanceUnit", "Distance Unit"),
|
|
389
|
+
options: [
|
|
390
|
+
{ label: msg("mile", "mile", { count: 2 }), value: "mile" },
|
|
391
|
+
{
|
|
392
|
+
label: msg("kilometer", "kilometer", { count: 2 }),
|
|
393
|
+
value: "kilometer",
|
|
394
|
+
},
|
|
395
|
+
],
|
|
396
|
+
},
|
|
397
|
+
},
|
|
398
|
+
},
|
|
399
|
+
},
|
|
339
400
|
mapStartingLocation: {
|
|
340
401
|
type: "object",
|
|
341
402
|
label: msg("fields.options.mapStartingLocation", "Map Starting Location"),
|
|
@@ -350,6 +411,17 @@ const locatorFields: YextFields<LocatorProps> = {
|
|
|
350
411
|
},
|
|
351
412
|
},
|
|
352
413
|
},
|
|
414
|
+
autoSearchOnMapMove: {
|
|
415
|
+
type: "radio",
|
|
416
|
+
label: msg(
|
|
417
|
+
"fields.autoSearchOnMapMove",
|
|
418
|
+
"Automatically Search on Map Movement"
|
|
419
|
+
),
|
|
420
|
+
options: [
|
|
421
|
+
{ label: msg("fields.options.yes", "Yes"), value: true },
|
|
422
|
+
{ label: msg("fields.options.no", "No"), value: false },
|
|
423
|
+
],
|
|
424
|
+
},
|
|
353
425
|
pageHeading: {
|
|
354
426
|
type: "object",
|
|
355
427
|
label: msg("fields.pageHeading", "Page Heading"),
|
|
@@ -386,9 +458,11 @@ const locatorFields: YextFields<LocatorProps> = {
|
|
|
386
458
|
props: DEFAULT_LOCATOR_RESULT_CARD_PROPS,
|
|
387
459
|
},
|
|
388
460
|
},
|
|
461
|
+
// Keep saved distance display values working without exposing the old selector.
|
|
389
462
|
distanceDisplay: {
|
|
390
463
|
type: "basicSelector",
|
|
391
464
|
label: msg("fields.distanceDisplay", "Distance Display"),
|
|
465
|
+
visible: false,
|
|
392
466
|
options: [
|
|
393
467
|
{
|
|
394
468
|
label: msg("fields.options.distanceFromUser", "Distance from User"),
|
|
@@ -408,6 +482,29 @@ const locatorFields: YextFields<LocatorProps> = {
|
|
|
408
482
|
},
|
|
409
483
|
],
|
|
410
484
|
},
|
|
485
|
+
showDistanceUnitToggle: {
|
|
486
|
+
type: "radio",
|
|
487
|
+
label: msg("fields.showDistanceUnitToggle", "Show Distance Unit Toggle"),
|
|
488
|
+
options: [
|
|
489
|
+
{ label: msg("fields.options.yes", "Yes"), value: true },
|
|
490
|
+
{ label: msg("fields.options.no", "No"), value: false },
|
|
491
|
+
],
|
|
492
|
+
},
|
|
493
|
+
defaultDistanceUnit: {
|
|
494
|
+
type: "basicSelector",
|
|
495
|
+
label: msg("fields.defaultDistanceUnit", "Default Distance Unit"),
|
|
496
|
+
options: [
|
|
497
|
+
{ label: msg("fields.options.miles", "Miles (mi)"), value: MILE },
|
|
498
|
+
{
|
|
499
|
+
label: msg("fields.options.kilometers", "Kilometers (km)"),
|
|
500
|
+
value: KILOMETER,
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
label: msg("fields.options.browserLanguage", "Browser language"),
|
|
504
|
+
value: BROWSER_LANGUAGE,
|
|
505
|
+
},
|
|
506
|
+
],
|
|
507
|
+
},
|
|
411
508
|
};
|
|
412
509
|
|
|
413
510
|
/**
|
|
@@ -453,6 +550,7 @@ export const LocatorComponent: YextComponentConfig<LocatorProps> = {
|
|
|
453
550
|
return toPuckFields<LocatorProps>(updatedFields);
|
|
454
551
|
},
|
|
455
552
|
defaultProps: {
|
|
553
|
+
autoSearchOnMapMove: false,
|
|
456
554
|
locationStyles: [],
|
|
457
555
|
resultCard: [],
|
|
458
556
|
filters: {
|
|
@@ -463,6 +561,8 @@ export const LocatorComponent: YextComponentConfig<LocatorProps> = {
|
|
|
463
561
|
title: { defaultValue: DEFAULT_TITLE },
|
|
464
562
|
},
|
|
465
563
|
distanceDisplay: DEFAULT_DISTANCE_DISPLAY,
|
|
564
|
+
showDistanceUnitToggle: false,
|
|
565
|
+
defaultDistanceUnit: BROWSER_LANGUAGE,
|
|
466
566
|
},
|
|
467
567
|
label: msg("components.locator", "Locator"),
|
|
468
568
|
/**
|
|
@@ -535,6 +635,10 @@ export const LocatorComponent: YextComponentConfig<LocatorProps> = {
|
|
|
535
635
|
data = setDeep(data, "props.resultCard", newResultCards);
|
|
536
636
|
}
|
|
537
637
|
|
|
638
|
+
if (data.props.defaultDistanceUnit === undefined) {
|
|
639
|
+
data = setDeep(data, "props.defaultDistanceUnit", BROWSER_LANGUAGE);
|
|
640
|
+
}
|
|
641
|
+
|
|
538
642
|
return data;
|
|
539
643
|
},
|
|
540
644
|
render: (props) => <LocatorWrapper {...props} />,
|
package/dist/cli/assets/directory-locator-source/components/sections/locator/LocatorFields.test.ts
CHANGED
|
@@ -21,6 +21,72 @@ const getKeywordsDisplayNameVisibility = (facetValues?: string[]) => {
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
describe("Locator fields", () => {
|
|
24
|
+
it.each([
|
|
25
|
+
{ entityTypes: ["ce_warehouse"] },
|
|
26
|
+
{ entityTypes: ["ce_warehouse", "location"] },
|
|
27
|
+
{ entityTypes: ["location", "ce_warehouse"] },
|
|
28
|
+
])(
|
|
29
|
+
"configures cards and styles for $entityTypes",
|
|
30
|
+
async ({ entityTypes }) => {
|
|
31
|
+
const params = {
|
|
32
|
+
metadata: {
|
|
33
|
+
streamDocument: {
|
|
34
|
+
_pageset: JSON.stringify({
|
|
35
|
+
typeConfig: {
|
|
36
|
+
locatorConfig: {
|
|
37
|
+
entityTypeScope: entityTypes.map((entityType) => ({
|
|
38
|
+
entityType,
|
|
39
|
+
})),
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
}),
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
} as any;
|
|
46
|
+
const customCard = {
|
|
47
|
+
props: {
|
|
48
|
+
entityType: "ce_warehouse",
|
|
49
|
+
primaryHeading: { field: "c_warehouseName" },
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
const customStyle = {
|
|
53
|
+
entityType: "ce_warehouse",
|
|
54
|
+
pinIcon: { type: "icon", iconName: "warehouse" },
|
|
55
|
+
};
|
|
56
|
+
const data = {
|
|
57
|
+
props: {
|
|
58
|
+
...LocatorComponent.defaultProps,
|
|
59
|
+
resultCard: [customCard],
|
|
60
|
+
locationStyles: [customStyle],
|
|
61
|
+
},
|
|
62
|
+
} as any;
|
|
63
|
+
const fields = LocatorComponent.resolveFields?.(data, params) as any;
|
|
64
|
+
expect(fields.resultCard).toMatchObject({
|
|
65
|
+
min: entityTypes.length,
|
|
66
|
+
max: entityTypes.length,
|
|
67
|
+
});
|
|
68
|
+
expect(fields.locationStyles).toMatchObject({
|
|
69
|
+
min: entityTypes.length,
|
|
70
|
+
max: entityTypes.length,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const resolved = (await LocatorComponent.resolveData?.(
|
|
74
|
+
data,
|
|
75
|
+
params
|
|
76
|
+
)) as any;
|
|
77
|
+
expect(
|
|
78
|
+
resolved.props.resultCard.map((card: any) => card.props.entityType)
|
|
79
|
+
).toEqual(entityTypes);
|
|
80
|
+
expect(
|
|
81
|
+
resolved.props.locationStyles.map((style: any) => style.entityType)
|
|
82
|
+
).toEqual(entityTypes);
|
|
83
|
+
expect(resolved.props.resultCard).toContainEqual(customCard);
|
|
84
|
+
expect(resolved.props.locationStyles).toContainEqual(
|
|
85
|
+
expect.objectContaining(customStyle)
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
|
|
24
90
|
it.each([
|
|
25
91
|
{
|
|
26
92
|
name: "shows the display name when Keywords is selected",
|