@wayke-se/components-react 3.0.0-beta.9 → 3.1.0-beta.1

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.
Files changed (54) hide show
  1. package/README.md +12 -3
  2. package/dist-node/index.js +3233 -1031
  3. package/dist-node/index.js.map +1 -1
  4. package/dist-src/State/CentralStorage/useCentralStorage.js +7 -8
  5. package/dist-src/State/Path/PathProvider.js +1 -1
  6. package/dist-src/State/RelatedSearch/RelatedSearchProvider.js +1 -1
  7. package/dist-src/State/Search/SearchProvider.js +7 -10
  8. package/dist-src/components/ActionList/index.js +2 -3
  9. package/dist-src/components/Checklist/index.js +1 -1
  10. package/dist-src/components/ExtendContent/index.js +1 -1
  11. package/dist-src/components/Filter/index.js +10 -7
  12. package/dist-src/components/FilterPanel/checkListFacet.js +1 -1
  13. package/dist-src/components/FilterPanel/colorFacet.js +1 -1
  14. package/dist-src/components/FilterPanel/index.js +1 -1
  15. package/dist-src/components/FilterPanel/rangeFacet.js +14 -16
  16. package/dist-src/components/FinancialOptions/LoanModal.js +27 -29
  17. package/dist-src/components/FinancialOptions/leasing.js +6 -6
  18. package/dist-src/components/FinancialOptions/loan.js +5 -6
  19. package/dist-src/components/Gallery/index.js +11 -16
  20. package/dist-src/components/Grid/index.js +19 -5
  21. package/dist-src/components/InputSelect/index.js +1 -1
  22. package/dist-src/components/InsuranceOptions/InsuranceFree.js +1 -2
  23. package/dist-src/components/InsuranceOptions/InsuranceFreeModal.js +4 -5
  24. package/dist-src/components/InsuranceOptions/InsuranceModal.js +3 -3
  25. package/dist-src/components/Lightbox/index.js +1 -1
  26. package/dist-src/components/OpeningHours/index.js +9 -9
  27. package/dist-src/components/ProductCard/index.js +6 -3
  28. package/dist-src/components/RangeSlider/SliderWithLabel.js +1 -1
  29. package/dist-src/components/Result/index.js +7 -6
  30. package/dist-src/components/Video/EmbededVideo.js +1 -1
  31. package/dist-src/components/Video/QuickNavEmbeded.js +2 -2
  32. package/dist-src/components/Video/useThumbnail.js +1 -1
  33. package/dist-src/components/Video/utils.js +2 -2
  34. package/dist-src/hooks/useFetch.js +1 -1
  35. package/dist-src/hooks/useVimeoThumbnail.js +1 -1
  36. package/dist-src/layouts/searchItem/Branch.js +9 -10
  37. package/dist-src/layouts/searchItem/BranchModal.js +1 -1
  38. package/dist-src/layouts/searchItem/CheckList.js +16 -16
  39. package/dist-src/layouts/searchItem/ManufacturerPackagesOption.js +1 -2
  40. package/dist-src/layouts/searchItem/PackageOptionModal.js +7 -10
  41. package/dist-src/layouts/searchItem/PackageOptions.js +11 -14
  42. package/dist-src/layouts/searchItem/Property.js +4 -6
  43. package/dist-src/layouts/searchItem/Related.js +5 -6
  44. package/dist-src/layouts/searchItem/index.js +15 -17
  45. package/dist-src/utils/phonenumbers.js +1 -1
  46. package/dist-src/utils/regex.js +1 -1
  47. package/dist-src/utils/specification.js +9 -13
  48. package/dist-src/utils/vehicle-properties/property-tree-creator.js +5 -5
  49. package/dist-types/components/InputSearch/index.d.ts +5 -3
  50. package/dist-types/components/RangeSlider/handle.d.ts +2 -2
  51. package/dist-types/components/RangeSlider/track.d.ts +2 -2
  52. package/dist-web/index.js +232 -241
  53. package/dist-web/index.js.map +1 -1
  54. package/package.json +18 -24
@@ -34,11 +34,10 @@ import Property from './Property';
34
34
  import PdfDownloadContainer from '../../components/Pdf/index';
35
35
  import useSettings from '../../State/Settings/useSettings';
36
36
  const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, placeholderImage, modifyDocumentTitleItem, onClickSearchItem, }) => {
37
- var _a, _b, _c;
38
37
  const { ecomSettings } = useSettings();
39
38
  const ecomContext = useRef();
40
39
  const { loading, data: result } = useSearchItem(id);
41
- const { vehicle: centralStorageVehicle, loading: loadingCentralStorageVehicle } = useCentralStorage(result === null || result === void 0 ? void 0 : result.vehicle);
40
+ const { vehicle: centralStorageVehicle, loading: loadingCentralStorageVehicle } = useCentralStorage(result?.vehicle);
42
41
  useEffect(() => {
43
42
  if (ecomSettings) {
44
43
  ecomContext.current = new WaykeEcomWeb({
@@ -47,7 +46,7 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
47
46
  api: {
48
47
  address: ecomSettings.url,
49
48
  },
50
- bankIdThumbprint: ecomSettings === null || ecomSettings === void 0 ? void 0 : ecomSettings.bankIdThumbprint,
49
+ bankIdThumbprint: ecomSettings?.bankIdThumbprint,
51
50
  },
52
51
  logo: ecomSettings.serviceLogotypeUrl,
53
52
  logoX2: ecomSettings.serviceLogotypeUrl,
@@ -68,26 +67,25 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
68
67
  }
69
68
  }, []);
70
69
  useEffect(() => {
71
- var _a;
72
- if (((_a = result === null || result === void 0 ? void 0 : result.vehicle) === null || _a === void 0 ? void 0 : _a.data) && modifyDocumentTitleItem) {
70
+ if (result?.vehicle?.data && modifyDocumentTitleItem) {
73
71
  const { vehicle } = result;
74
72
  const { registrationNumber } = vehicle.data;
75
73
  document.title = `${registrationNumber} | ${vehicle.title} | ${vehicle.shortDescription}`;
76
74
  }
77
75
  }, [result]);
78
- const options = useMemo(() => { var _a, _b, _c; return (_c = (_b = (_a = result === null || result === void 0 ? void 0 : result.vehicle) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.options) === null || _c === void 0 ? void 0 : _c.filter(notEmpty).map((opt) => ({ title: opt })); }, [(_b = (_a = result === null || result === void 0 ? void 0 : result.vehicle) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.options]);
76
+ const options = useMemo(() => result?.vehicle?.data?.options?.filter(notEmpty).map((opt) => ({ title: opt })), [result?.vehicle?.data?.options]);
79
77
  const onShowMoreOptionsClick = useCallback(() => PubSub.publish('OptionsClick'), []);
80
78
  if (loading) {
81
79
  return React.createElement(PageLoading, null);
82
80
  }
83
- if (!((_c = result === null || result === void 0 ? void 0 : result.vehicle) === null || _c === void 0 ? void 0 : _c.data)) {
81
+ if (!result?.vehicle?.data) {
84
82
  return React.createElement(Page404, null);
85
83
  }
86
84
  const { vehicle } = result;
87
- const contact = centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.contact;
88
- const branch = centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.branch;
85
+ const contact = centralStorageVehicle?.contact;
86
+ const branch = centralStorageVehicle?.branch;
89
87
  const { title, shortDescription, media, description, price, financialOptions, manufacturer, ecommerce, packageOptions, publishedAt, documents, } = vehicle;
90
- const insuranceOptions = (centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.insuranceOptions)
88
+ const insuranceOptions = centralStorageVehicle?.insuranceOptions
91
89
  ? centralStorageVehicle.insuranceOptions
92
90
  : vehicle.insuranceOptions;
93
91
  const { fuelType, mileage, gearbox, modelYear, propertySet } = vehicle.data;
@@ -118,7 +116,7 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
118
116
  React.createElement(ButtonContent, null,
119
117
  React.createElement(IconChevronLeft, { block: true })),
120
118
  React.createElement(ButtonContent, null, "Tillbaka till bils\u00F6k"))))) : null,
121
- (manufacturer === null || manufacturer === void 0 ? void 0 : manufacturer.logotype) && (React.createElement(Repeat, null,
119
+ manufacturer?.logotype && (React.createElement(Repeat, null,
122
120
  React.createElement(LogoBox, { logo: manufacturer.logotype, alt: manufacturer.name }))),
123
121
  React.createElement(Repeat, null,
124
122
  React.createElement(RepeatSmall, null,
@@ -131,9 +129,9 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
131
129
  React.createElement(PriceTable, { price: price })),
132
130
  (financialOptions.length > 0 || insuranceOptions.length > 0) && (React.createElement(ProductPageAsideSection, { mobileOrder: 4 },
133
131
  financialOptions.length > 0 && (React.createElement(FinancialOptions, { id: id, financialOptions: financialOptions })),
134
- insuranceOptions.length > 0 && (React.createElement(InsuranceOptions, { id: id, branch: centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.branch, insuranceOptions: insuranceOptions })))),
132
+ insuranceOptions.length > 0 && (React.createElement(InsuranceOptions, { id: id, branch: centralStorageVehicle?.branch, insuranceOptions: insuranceOptions })))),
135
133
  React.createElement(ProductPageAsideSection, { mobileOrder: 5 },
136
- React.createElement(CheckList, { manufacturer: manufacturer, packageOptions: packageOptions, ecommerce: ecommerce, branch: branch, contact: centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.contact, loadingCentralStorageVehicle: loadingCentralStorageVehicle, toggleEcomModal: () => { var _a; return (_a = ecomContext.current) === null || _a === void 0 ? void 0 : _a.start(); } }))),
134
+ React.createElement(CheckList, { manufacturer: manufacturer, packageOptions: packageOptions, ecommerce: ecommerce, branch: branch, contact: centralStorageVehicle?.contact, loadingCentralStorageVehicle: loadingCentralStorageVehicle, toggleEcomModal: () => ecomContext.current?.start() }))),
137
135
  React.createElement(ProductPageMain, null,
138
136
  React.createElement(ProductPageAsideSection, { mobileOrder: 3 },
139
137
  React.createElement(Gallery, { media: media, placeholderImage: placeholderImage })),
@@ -148,8 +146,8 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
148
146
  description && (React.createElement(ProductPageMainSection, null,
149
147
  React.createElement(Blockquote, { author: contact && contact.name ? contact.name : null, date: publishedAt
150
148
  ? dateTimeFormat.format(publishedAt, dateTimeFormat.DayMonth)
151
- : undefined, avatar: (contact === null || contact === void 0 ? void 0 : contact.avatar) || undefined }, !!description && React.createElement("p", null, description)))),
152
- ((options === null || options === void 0 ? void 0 : options.length) || 0) > 0 && (React.createElement(ProductPageMainSection, null,
149
+ : undefined, avatar: contact?.avatar || undefined }, !!description && React.createElement("p", null, description)))),
150
+ (options?.length || 0) > 0 && (React.createElement(ProductPageMainSection, null,
153
151
  React.createElement(Repeat, null,
154
152
  React.createElement(H2, { noMargin: true }, "Utrustning")),
155
153
  React.createElement(Repeat, null,
@@ -169,9 +167,9 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
169
167
  React.createElement(ProductPageMainSection, null,
170
168
  React.createElement(Branch, { branch: branch, loading: loadingCentralStorageVehicle }),
171
169
  ecommerce && ecommerce.enabled && (React.createElement(Repeat, null,
172
- React.createElement(ButtonPrimary, { disabled: !!ecommerce.reserved, title: "K\u00F6p bilen online", onClick: () => { var _a; return (_a = ecomContext.current) === null || _a === void 0 ? void 0 : _a.start(); } }, "K\u00F6p bilen online")))),
170
+ React.createElement(ButtonPrimary, { disabled: !!ecommerce.reserved, title: "K\u00F6p bilen online", onClick: () => ecomContext.current?.start() }, "K\u00F6p bilen online")))),
173
171
  React.createElement(PackageOptions, { packageOptions: packageOptions }),
174
- React.createElement(ManufacturerPackageOption, { packageOption: manufacturer === null || manufacturer === void 0 ? void 0 : manufacturer.packageOption }))))),
172
+ React.createElement(ManufacturerPackageOption, { packageOption: manufacturer?.packageOption }))))),
175
173
  React.createElement(Related, { id: id, hashRoute: hashRoute, pathRoute: pathRoute, onClickSearchItem: onClickSearchItem })),
176
174
  false && (React.createElement(Modal, { title: "Modal", onClose: () => { } },
177
175
  React.createElement(Content, null,
@@ -4,7 +4,7 @@ const typedMetadata = metadata;
4
4
  export const formatPhonenumber = (text) => {
5
5
  try {
6
6
  const parsed = parsePhoneNumberFromString(text.replace('-', '').replace(/ /g, ''), typedMetadata);
7
- return (parsed === null || parsed === void 0 ? void 0 : parsed.formatNational()) || text;
7
+ return parsed?.formatNational() || text;
8
8
  }
9
9
  catch (e) {
10
10
  return text;
@@ -2,7 +2,7 @@ export const regexGuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a
2
2
  const regexEndGuid = /[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/;
3
3
  export const escapeRegExpString = (s) => s.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&');
4
4
  export const regexPathGuid = (path) => {
5
- if (!path) {
5
+ if (!path || path) {
6
6
  return regexEndGuid;
7
7
  }
8
8
  const r = new RegExp(`${escapeRegExpString(path)}${regexEndGuid.source}`, 'gi');
@@ -137,10 +137,7 @@ const specLabels = {
137
137
  },
138
138
  height: {
139
139
  label: 'Längd/höjd/bredd',
140
- formatData: (_, data) => {
141
- var _a, _b, _c;
142
- return `${((_a = data === null || data === void 0 ? void 0 : data.properties) === null || _a === void 0 ? void 0 : _a.length) || '-'} cm/${((_b = data === null || data === void 0 ? void 0 : data.properties) === null || _b === void 0 ? void 0 : _b.height) || '-'} cm/${((_c = data === null || data === void 0 ? void 0 : data.properties) === null || _c === void 0 ? void 0 : _c.width) || '-'} cm`;
143
- },
140
+ formatData: (_, data) => `${data?.properties?.length || '-'} cm/${data?.properties?.height || '-'} cm/${data?.properties?.width || '-'} cm`,
144
141
  },
145
142
  serviceWeight: {
146
143
  label: 'Tjänstevikt',
@@ -437,14 +434,13 @@ const All = [
437
434
  'annualBonus',
438
435
  ];
439
436
  const extractSpecData = (key, item) => {
440
- var _a, _b, _c, _d, _e, _f, _g, _h;
441
437
  const spec = specLabels[key];
442
438
  let data = null;
443
439
  if (!!item[key] || (item[key] || -1) > -1) {
444
440
  data = item[key];
445
441
  }
446
- else if (!!((_a = item === null || item === void 0 ? void 0 : item.properties) === null || _a === void 0 ? void 0 : _a[key]) ||
447
- (typeof ((_b = item === null || item === void 0 ? void 0 : item.properties) === null || _b === void 0 ? void 0 : _b[key]) === 'number' && (((_c = item === null || item === void 0 ? void 0 : item.properties) === null || _c === void 0 ? void 0 : _c[key]) || -1) > -1)) {
442
+ else if (!!item?.properties?.[key] ||
443
+ (typeof item?.properties?.[key] === 'number' && (item?.properties?.[key] || -1) > -1)) {
448
444
  data = item.properties[key];
449
445
  }
450
446
  if (!spec || !data) {
@@ -466,23 +462,23 @@ const extractSpecData = (key, item) => {
466
462
  }
467
463
  const modal = spec.modal ? { title: '', text: '' } : undefined;
468
464
  if (modal) {
469
- if ((_d = spec.modal) === null || _d === void 0 ? void 0 : _d.dynamicTitle) {
465
+ if (spec.modal?.dynamicTitle) {
470
466
  modal.title = spec.modal.dynamicTitle(item);
471
467
  }
472
- else if ((_e = spec.modal) === null || _e === void 0 ? void 0 : _e.title) {
468
+ else if (spec.modal?.title) {
473
469
  modal.title = spec.modal.title;
474
470
  }
475
- if ((_f = spec.modal) === null || _f === void 0 ? void 0 : _f.dynamicText) {
471
+ if (spec.modal?.dynamicText) {
476
472
  modal.text = spec.modal.dynamicText(item);
477
473
  }
478
- else if ((_g = spec.modal) === null || _g === void 0 ? void 0 : _g.text) {
474
+ else if (spec.modal?.text) {
479
475
  modal.text = spec.modal.text;
480
476
  }
481
- if ((_h = spec.modal) === null || _h === void 0 ? void 0 : _h.concatPropValue) {
477
+ if (spec.modal?.concatPropValue) {
482
478
  const concatObj = spec.modal.concatPropValue === key
483
479
  ? { value }
484
480
  : extractSpecData(spec.modal.concatPropValue, item);
485
- if (concatObj === null || concatObj === void 0 ? void 0 : concatObj.value) {
481
+ if (concatObj?.value) {
486
482
  modal.text = modal.text.replace('{insertValue}', concatObj.value);
487
483
  }
488
484
  else if (spec.modal.nonConcatablePropValue) {
@@ -1,13 +1,13 @@
1
1
  class PropertyTreeCreator {
2
2
  constructor(properties) {
3
- this.propertiesWithCategory = (propertyKey) => { var _a; return !!((_a = this.properties[propertyKey].category) === null || _a === void 0 ? void 0 : _a.id); };
3
+ this.propertiesWithCategory = (propertyKey) => !!this.properties[propertyKey].category?.id;
4
4
  this.propertiesWithoutCategory = (propertyKey) => !this.propertiesWithCategory(propertyKey);
5
5
  this.isList = (property) => property.type === PropertyTreeCreator.TEXT_LIST_TYPE;
6
6
  this.isNonList = (property) => !this.isList(property);
7
- this.hasCategoryWithId = (propertyKey, categoryId) => { var _a; return ((_a = this.properties[propertyKey].category) === null || _a === void 0 ? void 0 : _a.id) === categoryId; };
8
- this.propertiesWithSubCategory = (propertyKey) => { var _a, _b; return !!((_b = (_a = this.properties[propertyKey].category) === null || _a === void 0 ? void 0 : _a.subCategory) === null || _b === void 0 ? void 0 : _b.id); };
7
+ this.hasCategoryWithId = (propertyKey, categoryId) => this.properties[propertyKey].category?.id === categoryId;
8
+ this.propertiesWithSubCategory = (propertyKey) => !!this.properties[propertyKey].category?.subCategory?.id;
9
9
  this.propertiesWithoutSubCategory = (propertyKey) => !this.propertiesWithSubCategory(propertyKey);
10
- this.hasSubCategoryWithId = (propertyKey, categoryId) => { var _a, _b; return ((_b = (_a = this.properties[propertyKey].category) === null || _a === void 0 ? void 0 : _a.subCategory) === null || _b === void 0 ? void 0 : _b.id) === categoryId; };
10
+ this.hasSubCategoryWithId = (propertyKey, categoryId) => this.properties[propertyKey].category?.subCategory?.id === categoryId;
11
11
  this.properties = properties;
12
12
  }
13
13
  create() {
@@ -74,7 +74,7 @@ class PropertyTreeCreator {
74
74
  const categories = Object.keys(this.properties)
75
75
  .filter((key) => this.hasCategoryWithId(key, id))
76
76
  .filter(this.propertiesWithSubCategory)
77
- .map((key) => { var _a; return (_a = this.properties[key].category) === null || _a === void 0 ? void 0 : _a.subCategory; })
77
+ .map((key) => this.properties[key].category?.subCategory)
78
78
  .filter(PropertyTreeCreator.distinctCategories);
79
79
  return categories;
80
80
  }
@@ -1,9 +1,11 @@
1
1
  import React from 'react';
2
- declare const InputSearch: React.ForwardRefExoticComponent<Pick<React.ClassAttributes<HTMLInputElement> & React.InputHTMLAttributes<HTMLInputElement> & {
2
+ declare type InputProps = React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
3
+ declare type Props = InputProps & {
3
4
  placeholder: string;
4
5
  label: string;
5
- value?: string | undefined;
6
+ value?: string;
6
7
  id: string;
7
8
  onSearch: () => void;
8
- }, "label" | "key" | keyof React.InputHTMLAttributes<HTMLInputElement> | "onSearch"> & React.RefAttributes<HTMLDivElement>>;
9
+ };
10
+ declare const InputSearch: React.ForwardRefExoticComponent<Pick<Props, "label" | "key" | keyof React.InputHTMLAttributes<HTMLInputElement> | "onSearch"> & React.RefAttributes<HTMLDivElement>>;
9
11
  export default InputSearch;
@@ -1,9 +1,9 @@
1
- import React from 'react';
1
+ /// <reference types="react" />
2
2
  import { SliderItem, GetHandleProps } from 'react-compound-slider';
3
3
  interface IHandleProps {
4
4
  domain: number[];
5
5
  handle: SliderItem;
6
6
  getHandleProps: GetHandleProps;
7
7
  }
8
- export declare const Handle: React.SFC<IHandleProps>;
8
+ export declare const Handle: ({ domain: [min, max], handle: { id, value, percent }, getHandleProps, }: IHandleProps) => JSX.Element;
9
9
  export {};
@@ -1,9 +1,9 @@
1
- import React from 'react';
1
+ /// <reference types="react" />
2
2
  import { SliderItem, GetTrackProps } from 'react-compound-slider';
3
3
  interface ITrackProps {
4
4
  source: SliderItem;
5
5
  target: SliderItem;
6
6
  getTrackProps: GetTrackProps;
7
7
  }
8
- export declare const Track: React.SFC<ITrackProps>;
8
+ export declare const Track: ({ source, target, getTrackProps }: ITrackProps) => JSX.Element;
9
9
  export {};