ublo-lib 1.35.19 → 1.36.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 (122) hide show
  1. package/es/common/components/msem-preset-linker/hooks/use-msem-presets.d.ts.map +1 -1
  2. package/es/common/components/msem-preset-linker/hooks/use-msem-presets.js +3 -2
  3. package/es/common/components/scrolling-carousel/scrolling-carousel.module.css +4 -0
  4. package/es/lbm/components/instant-search/facet-switch.d.ts +8 -0
  5. package/es/lbm/components/instant-search/facet-switch.d.ts.map +1 -0
  6. package/es/lbm/components/instant-search/facet-switch.js +15 -0
  7. package/es/lbm/components/instant-search/facet-switch.module.css +19 -0
  8. package/es/lbm/components/instant-search/faqs.d.ts +12 -0
  9. package/es/lbm/components/instant-search/faqs.d.ts.map +1 -0
  10. package/es/lbm/components/instant-search/faqs.js +44 -0
  11. package/es/lbm/components/instant-search/faqs.module.css +102 -0
  12. package/es/lbm/components/instant-search/hooks/use-constant.d.ts +2 -0
  13. package/es/lbm/components/instant-search/hooks/use-constant.d.ts.map +1 -0
  14. package/es/lbm/components/instant-search/hooks/use-constant.js +8 -0
  15. package/es/lbm/components/instant-search/hooks/use-debounced-search.d.ts +11 -0
  16. package/es/lbm/components/instant-search/hooks/use-debounced-search.d.ts.map +1 -0
  17. package/es/lbm/components/instant-search/hooks/use-debounced-search.js +12 -0
  18. package/es/lbm/components/instant-search/hooks/use-search.d.ts +17 -0
  19. package/es/lbm/components/instant-search/hooks/use-search.d.ts.map +1 -0
  20. package/es/lbm/components/instant-search/hooks/use-search.js +10 -0
  21. package/es/lbm/components/instant-search/i18n.json +32 -0
  22. package/es/lbm/components/instant-search/index.d.ts +3 -0
  23. package/es/lbm/components/instant-search/index.d.ts.map +1 -0
  24. package/es/lbm/components/instant-search/index.js +2 -0
  25. package/es/lbm/components/instant-search/instant-search.d.ts +19 -0
  26. package/es/lbm/components/instant-search/instant-search.d.ts.map +1 -0
  27. package/es/lbm/components/instant-search/instant-search.js +64 -0
  28. package/es/lbm/components/instant-search/instant-search.module.css +8 -0
  29. package/es/lbm/components/instant-search/links.d.ts +12 -0
  30. package/es/lbm/components/instant-search/links.d.ts.map +1 -0
  31. package/es/lbm/components/instant-search/links.js +30 -0
  32. package/es/lbm/components/instant-search/links.module.css +96 -0
  33. package/es/lbm/components/instant-search/no-product.d.ts +6 -0
  34. package/es/lbm/components/instant-search/no-product.d.ts.map +1 -0
  35. package/es/lbm/components/instant-search/no-product.js +4 -0
  36. package/es/lbm/components/instant-search/products.d.ts +14 -0
  37. package/es/lbm/components/instant-search/products.d.ts.map +1 -0
  38. package/es/lbm/components/instant-search/products.js +47 -0
  39. package/es/lbm/components/instant-search/products.module.css +163 -0
  40. package/es/lbm/components/instant-search/results.d.ts +79 -0
  41. package/es/lbm/components/instant-search/results.d.ts.map +1 -0
  42. package/es/lbm/components/instant-search/results.js +34 -0
  43. package/es/lbm/components/instant-search/results.module.css +85 -0
  44. package/es/lbm/components/instant-search/search-input.d.ts +15 -0
  45. package/es/lbm/components/instant-search/search-input.d.ts.map +1 -0
  46. package/es/lbm/components/instant-search/search-input.js +56 -0
  47. package/es/lbm/components/instant-search/search-input.module.css +88 -0
  48. package/es/lbm/components/instant-search/services/api.d.ts +2 -0
  49. package/es/lbm/components/instant-search/services/api.d.ts.map +1 -0
  50. package/es/lbm/components/instant-search/services/api.js +22 -0
  51. package/es/lbm/components/instant-search/services/lumiplan-api.d.ts +9 -0
  52. package/es/lbm/components/instant-search/services/lumiplan-api.d.ts.map +1 -0
  53. package/es/lbm/components/instant-search/services/lumiplan-api.js +37 -0
  54. package/es/lbm/components/instant-search/services/messages.d.ts +2 -0
  55. package/es/lbm/components/instant-search/services/messages.d.ts.map +1 -0
  56. package/es/lbm/components/instant-search/services/messages.js +5 -0
  57. package/es/lbm/components/instant-search/services/utils.d.ts +4 -0
  58. package/es/lbm/components/instant-search/services/utils.d.ts.map +1 -0
  59. package/es/lbm/components/instant-search/services/utils.js +28 -0
  60. package/es/lbm/components/instant-search/widgets/access.d.ts +8 -0
  61. package/es/lbm/components/instant-search/widgets/access.d.ts.map +1 -0
  62. package/es/lbm/components/instant-search/widgets/access.js +29 -0
  63. package/es/lbm/components/instant-search/widgets/activity.d.ts +8 -0
  64. package/es/lbm/components/instant-search/widgets/activity.d.ts.map +1 -0
  65. package/es/lbm/components/instant-search/widgets/activity.js +74 -0
  66. package/es/lbm/components/instant-search/widgets/activity.module.css +6 -0
  67. package/es/lbm/components/instant-search/widgets/components/card.d.ts +11 -0
  68. package/es/lbm/components/instant-search/widgets/components/card.d.ts.map +1 -0
  69. package/es/lbm/components/instant-search/widgets/components/card.js +15 -0
  70. package/es/lbm/components/instant-search/widgets/components/card.module.css +60 -0
  71. package/es/lbm/components/instant-search/widgets/components/metric.d.ts +8 -0
  72. package/es/lbm/components/instant-search/widgets/components/metric.d.ts.map +1 -0
  73. package/es/lbm/components/instant-search/widgets/components/metric.js +6 -0
  74. package/es/lbm/components/instant-search/widgets/components/metric.module.css +12 -0
  75. package/es/lbm/components/instant-search/widgets/components/status-with-icon.d.ts +9 -0
  76. package/es/lbm/components/instant-search/widgets/components/status-with-icon.d.ts.map +1 -0
  77. package/es/lbm/components/instant-search/widgets/components/status-with-icon.js +5 -0
  78. package/es/lbm/components/instant-search/widgets/components/status-with-icon.module.css +12 -0
  79. package/es/lbm/components/instant-search/widgets/dawn-nights-openings.d.ts +9 -0
  80. package/es/lbm/components/instant-search/widgets/dawn-nights-openings.d.ts.map +1 -0
  81. package/es/lbm/components/instant-search/widgets/dawn-nights-openings.js +37 -0
  82. package/es/lbm/components/instant-search/widgets/dawn-nights-openings.module.css +33 -0
  83. package/es/lbm/components/instant-search/widgets/lift.d.ts +8 -0
  84. package/es/lbm/components/instant-search/widgets/lift.d.ts.map +1 -0
  85. package/es/lbm/components/instant-search/widgets/lift.js +52 -0
  86. package/es/lbm/components/instant-search/widgets/lift.module.css +6 -0
  87. package/es/lbm/components/instant-search/widgets/lifts.d.ts +8 -0
  88. package/es/lbm/components/instant-search/widgets/lifts.d.ts.map +1 -0
  89. package/es/lbm/components/instant-search/widgets/lifts.js +26 -0
  90. package/es/lbm/components/instant-search/widgets/msem-widget.d.ts +8 -0
  91. package/es/lbm/components/instant-search/widgets/msem-widget.d.ts.map +1 -0
  92. package/es/lbm/components/instant-search/widgets/msem-widget.js +31 -0
  93. package/es/lbm/components/instant-search/widgets/msem-widget.module.css +51 -0
  94. package/es/lbm/components/instant-search/widgets/openings.d.ts +8 -0
  95. package/es/lbm/components/instant-search/widgets/openings.d.ts.map +1 -0
  96. package/es/lbm/components/instant-search/widgets/openings.js +32 -0
  97. package/es/lbm/components/instant-search/widgets/slope.d.ts +8 -0
  98. package/es/lbm/components/instant-search/widgets/slope.d.ts.map +1 -0
  99. package/es/lbm/components/instant-search/widgets/slope.js +73 -0
  100. package/es/lbm/components/instant-search/widgets/slope.module.css +26 -0
  101. package/es/lbm/components/instant-search/widgets/slopes.d.ts +8 -0
  102. package/es/lbm/components/instant-search/widgets/slopes.d.ts.map +1 -0
  103. package/es/lbm/components/instant-search/widgets/slopes.js +26 -0
  104. package/es/lbm/components/instant-search/widgets/snow.d.ts +9 -0
  105. package/es/lbm/components/instant-search/widgets/snow.d.ts.map +1 -0
  106. package/es/lbm/components/instant-search/widgets/snow.js +25 -0
  107. package/es/lbm/components/instant-search/widgets/types.d.ts +27 -0
  108. package/es/lbm/components/instant-search/widgets/types.d.ts.map +1 -0
  109. package/es/lbm/components/instant-search/widgets/types.js +1 -0
  110. package/es/lbm/components/instant-search/widgets/weather.d.ts +9 -0
  111. package/es/lbm/components/instant-search/widgets/weather.d.ts.map +1 -0
  112. package/es/lbm/components/instant-search/widgets/weather.js +36 -0
  113. package/es/lbm/components/instant-search/widgets/weather.module.css +32 -0
  114. package/es/lbm/components/instant-search/widgets/webcam.d.ts +8 -0
  115. package/es/lbm/components/instant-search/widgets/webcam.d.ts.map +1 -0
  116. package/es/lbm/components/instant-search/widgets/webcam.js +9 -0
  117. package/es/lbm/components/instant-search/widgets/webcam.module.css +13 -0
  118. package/es/lbm/components/instant-search/widgets.d.ts +11 -0
  119. package/es/lbm/components/instant-search/widgets.d.ts.map +1 -0
  120. package/es/lbm/components/instant-search/widgets.js +68 -0
  121. package/es/lbm/components/instant-search/widgets.module.css +14 -0
  122. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"use-msem-presets.d.ts","sourceRoot":"","sources":["../../../../../src/common/components/msem-preset-linker/hooks/use-msem-presets.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE;;;CAAA,QAyC9D"}
1
+ {"version":3,"file":"use-msem-presets.d.ts","sourceRoot":"","sources":["../../../../../src/common/components/msem-preset-linker/hooks/use-msem-presets.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE;;;CAAA,QA0C9D"}
@@ -5,6 +5,7 @@ import * as UrlParams from "../services/url-params";
5
5
  import * as MseM from "../../../utils/msem-widget";
6
6
  export default function useMsemPresets({ mode, defaultOptions }) {
7
7
  const { lang, cmsMode, path } = useUbloContext();
8
+ const widgetLang = lang === "fr" ? "fr" : "en";
8
9
  const isEnabled = cmsMode !== "editing" && cmsMode !== "info" && mode !== MODES.EDITING;
9
10
  const handleSectionClick = React.useCallback((e) => {
10
11
  const target = e.target;
@@ -13,7 +14,7 @@ export default function useMsemPresets({ mode, defaultOptions }) {
13
14
  if (!preset)
14
15
  return;
15
16
  const { widget, options = {}, presets, url } = JSON.parse(preset);
16
- const allOptions = { ...defaultOptions, ...options };
17
+ const allOptions = { ...defaultOptions, ...options, lang: widgetLang };
17
18
  e.preventDefault();
18
19
  e.stopPropagation();
19
20
  if (url) {
@@ -23,7 +24,7 @@ export default function useMsemPresets({ mode, defaultOptions }) {
23
24
  return;
24
25
  }
25
26
  MseM.loadWidget(widget, allOptions, presets);
26
- }, [defaultOptions]);
27
+ }, [defaultOptions, widgetLang]);
27
28
  React.useEffect(() => {
28
29
  const container = document.getElementById("__next");
29
30
  if (isEnabled && container) {
@@ -53,3 +53,7 @@ svg.controlIcon {
53
53
  .inner > :global(.cms) > :global(section) {
54
54
  scroll-snap-align: start;
55
55
  }
56
+
57
+ .inner > :global(.cms) > :global(section:last-child) {
58
+ scroll-snap-align: end;
59
+ }
@@ -0,0 +1,8 @@
1
+ type Props = {
2
+ lang: string;
3
+ facet: number;
4
+ setFacet: (facet: number) => void;
5
+ };
6
+ export default function ThemeSwitch({ lang, facet, setFacet }: Props): import("react/jsx-runtime").JSX.Element;
7
+ export {};
8
+ //# sourceMappingURL=facet-switch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"facet-switch.d.ts","sourceRoot":"","sources":["../../../../src/lbm/components/instant-search/facet-switch.tsx"],"names":[],"mappings":"AAgBA,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IAEd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,KAAK,2CAsBnE"}
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import Select from "dt-design-system/es/select";
3
+ import message from "./services/messages";
4
+ import styles from "./facet-switch.module.css";
5
+ export default function ThemeSwitch({ lang, facet, setFacet }) {
6
+ const facets = {
7
+ 0: { icon: "Snowflake", label: message(lang, "winter") },
8
+ 1: { icon: "Sun", label: message(lang, "summer") },
9
+ };
10
+ const options = Object.keys(facets).map((key) => {
11
+ return { value: key, label: facets[key].label };
12
+ });
13
+ const icon = facets[facet].icon;
14
+ return (_jsx(Select, { className: styles.select, icon: icon, options: options, value: facet.toString(), onValueChange: (value) => setFacet(Number(value)), compact: true }));
15
+ }
@@ -0,0 +1,19 @@
1
+ .select {
2
+ }
3
+
4
+ .select label > span {
5
+ display: none;
6
+ }
7
+
8
+ .label {
9
+ display: flex;
10
+ align-items: center;
11
+ gap: 6px;
12
+ }
13
+
14
+ .icon {
15
+ flex: 0 0 16px;
16
+ width: 16px;
17
+ height: 16px;
18
+ fill: currentColor;
19
+ }
@@ -0,0 +1,12 @@
1
+ import type { Hit } from "./results";
2
+ type Props = {
3
+ lang: string;
4
+ faqs: Hit[];
5
+ loading: boolean;
6
+ sendPlausibleGoal: (path: string) => void;
7
+ maximized: boolean;
8
+ setMaximized: (maximized: boolean) => void;
9
+ };
10
+ export default function Faqs({ lang, faqs, loading, sendPlausibleGoal, maximized, setMaximized, }: Props): import("react/jsx-runtime").JSX.Element;
11
+ export {};
12
+ //# sourceMappingURL=faqs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"faqs.d.ts","sourceRoot":"","sources":["../../../../src/lbm/components/instant-search/faqs.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAGrC,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,OAAO,EAAE,OAAO,CAAC;IAEjB,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,SAAS,EAAE,OAAO,CAAC;IAEnB,YAAY,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CAC5C,CAAC;AAIF,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAC3B,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,iBAAiB,EACjB,SAAS,EACT,YAAY,GACb,EAAE,KAAK,2CA4DP"}
@@ -0,0 +1,44 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import classNames from "classnames";
3
+ import Link from "ublo/link";
4
+ import Loader from "dt-design-system/es/loader";
5
+ import Button from "dt-design-system/es/button";
6
+ import * as Icons from "dt-design-system/es/icons";
7
+ import * as Ripple from "dt-design-system/es/ripple";
8
+ import message from "./services/messages";
9
+ import * as Utils from "./services/utils";
10
+ import styles from "./faqs.module.css";
11
+ const PLACEHOLDERS = [...new Array(1)];
12
+ export default function Faqs({ lang, faqs, loading, sendPlausibleGoal, maximized, setMaximized, }) {
13
+ const noResult = !loading && !faqs.length;
14
+ if (noResult)
15
+ return null;
16
+ const toggleMaximized = () => {
17
+ setMaximized(!maximized);
18
+ };
19
+ const hasMultipleFaqs = faqs.length > 1;
20
+ const ButtonIcon = Icons[maximized ? "ChevronsDown" : "ChevronsUp"];
21
+ const buttonLabel = message(lang, maximized ? "hideAllFAQs" : "showAllFAQs");
22
+ const firstFaq = faqs?.[0];
23
+ const otherFaqs = faqs.slice(1);
24
+ const classes = classNames(styles.faqs, {
25
+ [styles.maximized]: maximized,
26
+ });
27
+ return (_jsxs("div", { className: classes, children: [_jsxs("div", { className: styles.header, children: [_jsx("div", { className: styles.title, children: message(lang, "faqs") }), hasMultipleFaqs && (_jsxs(Button, { onClick: toggleMaximized, compact: true, children: [_jsx(ButtonIcon, {}), buttonLabel, " (", faqs.length, ")", _jsx(ButtonIcon, {})] }))] }), _jsxs("div", { className: styles.preview, children: [loading &&
28
+ PLACEHOLDERS.map((_, i) => {
29
+ return (_jsx("div", { className: styles.loaderContainer, children: _jsx(Loader, { className: styles.loader, variant: "overlay" }) }, i));
30
+ }), !loading && firstFaq && (_jsx(Faq, { faq: firstFaq, sendPlausibleGoal: sendPlausibleGoal }))] }), maximized && (_jsx("div", { className: styles.list, children: otherFaqs.map((faq) => {
31
+ return (_jsx(Faq, { faq: faq, sendPlausibleGoal: sendPlausibleGoal }, faq.document.path));
32
+ }) }))] }));
33
+ }
34
+ function Faq({ faq, sendPlausibleGoal }) {
35
+ const { document, highlight } = faq;
36
+ const { title, text, path } = document;
37
+ const decodedPath = decodeURIComponent(path);
38
+ const faqTitle = Utils.wrapWithMark(title, highlight.title?.matched_tokens);
39
+ const faqText = Utils.wrapWithMark(text, highlight.text?.matched_tokens);
40
+ const createRipple = (e) => {
41
+ Ripple.create(e);
42
+ };
43
+ return (_jsxs(Link, { className: styles.faq, href: decodedPath, onClick: sendPlausibleGoal(decodedPath), onMouseDown: createRipple, children: [_jsx("div", { className: styles.faqTitle, dangerouslySetInnerHTML: { __html: faqTitle } }), _jsx("div", { className: styles.faqText, dangerouslySetInnerHTML: { __html: faqText } })] }));
44
+ }
@@ -0,0 +1,102 @@
1
+ .faqs {
2
+ position: sticky;
3
+ bottom: 0;
4
+ display: flex;
5
+ flex-direction: column;
6
+ gap: 12px;
7
+ margin-top: auto;
8
+ padding: 12px;
9
+ background-color: var(--ds-grey-000, #fff);
10
+ border-top: var(--ds-input-border, 1px solid var(--ds-grey-300, #d7d7d7));
11
+ }
12
+
13
+ .faqs.maximized {
14
+ flex: 1 1 100%;
15
+ transform: translateY(-1px);
16
+ }
17
+
18
+ .header {
19
+ align-self: flex-start;
20
+ display: flex;
21
+ align-items: center;
22
+ gap: 8px;
23
+ }
24
+
25
+ .title {
26
+ font-size: 17px;
27
+ font-weight: 700;
28
+ padding: 3px 8px;
29
+ background-color: var(--ds-grey-200, #efefef);
30
+ border-radius: var(--ds-radius-100, 6px);
31
+ }
32
+
33
+ .list {
34
+ display: flex;
35
+ flex-direction: column;
36
+ gap: 12px;
37
+ }
38
+
39
+ .loaderContainer {
40
+ position: relative;
41
+ width: 100%;
42
+ height: 52px;
43
+ border-radius: var(--ds-radius-100, 6px);
44
+ }
45
+
46
+ .faq {
47
+ position: relative;
48
+ display: flex;
49
+ flex-direction: column;
50
+ gap: 8px;
51
+ padding: 6px 6px 6px 12px;
52
+ color: var(--ds-grey-500, #484848);
53
+ border-radius: var(--ds-radius-100, 6px);
54
+ transition: background-color 160ms
55
+ var(--ds-transition-easing, cubic-bezier(0.4, 0, 0.2, 1));
56
+ }
57
+
58
+ .faq:is(:hover, :focus) {
59
+ background-color: var(--ds-grey-100, #f5f5f5);
60
+ }
61
+
62
+ .faq::before {
63
+ content: "";
64
+ position: absolute;
65
+ top: 15%;
66
+ left: 0;
67
+ height: 70%;
68
+ width: 2px;
69
+ background-color: var(--ds-secondary, var(--ds-blue-400, #4177f6));
70
+ opacity: 0.5;
71
+ }
72
+
73
+ .faqTitle {
74
+ font-size: 15px;
75
+ font-weight: 700;
76
+ }
77
+
78
+ .faqText {
79
+ font-size: 14px;
80
+ }
81
+
82
+ .faqTitle mark,
83
+ .faqText mark {
84
+ position: relative;
85
+ display: inline-block;
86
+ font-weight: 700;
87
+ color: var(--ds-secondary, var(--ds-blue-400, #4177f6));
88
+ background-color: transparent;
89
+ }
90
+
91
+ .faqTitle mark::before,
92
+ .faqText mark::before {
93
+ content: "";
94
+ position: absolute;
95
+ top: 0;
96
+ left: 0;
97
+ width: 100%;
98
+ height: 100%;
99
+ background-color: var(--ds-secondary, var(--ds-blue-400, #4177f6));
100
+ border-radius: calc(var(--ds-radius-100, 6px) / 3);
101
+ opacity: 0.15;
102
+ }
@@ -0,0 +1,2 @@
1
+ export default function useConstant(fn: any): any;
2
+ //# sourceMappingURL=use-constant.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-constant.d.ts","sourceRoot":"","sources":["../../../../../src/lbm/components/instant-search/hooks/use-constant.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAAE,EAAE,GAAG,OAQ1C"}
@@ -0,0 +1,8 @@
1
+ import * as React from "react";
2
+ export default function useConstant(fn) {
3
+ const ref = React.useRef();
4
+ if (!ref.current) {
5
+ ref.current = { v: fn() };
6
+ }
7
+ return ref.current.v;
8
+ }
@@ -0,0 +1,11 @@
1
+ import * as React from "react";
2
+ type SearchFunction = (text: string, facet: number) => Promise<any>;
3
+ export default function useDebouncedSearch(searchFunction: SearchFunction): {
4
+ text: string;
5
+ setText: React.Dispatch<React.SetStateAction<string>>;
6
+ facet: number;
7
+ setFacet: React.Dispatch<React.SetStateAction<number>>;
8
+ search: import("react-async-hook").UseAsyncReturn<any, any[]>;
9
+ };
10
+ export {};
11
+ //# sourceMappingURL=use-debounced-search.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-debounced-search.d.ts","sourceRoot":"","sources":["../../../../../src/lbm/components/instant-search/hooks/use-debounced-search.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B,KAAK,cAAc,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAEpE,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,cAAc,EAAE,cAAc;;;;;;EAcxE"}
@@ -0,0 +1,12 @@
1
+ import * as React from "react";
2
+ import debouncePromise from "awesome-debounce-promise";
3
+ import { useAsync } from "react-async-hook";
4
+ import useConstant from "./use-constant";
5
+ const DEBOUNCE_AMOUNT = 400;
6
+ export default function useDebouncedSearch(searchFunction) {
7
+ const [text, setText] = React.useState("");
8
+ const [facet, setFacet] = React.useState(0);
9
+ const debouncedSearchFunction = useConstant(() => debouncePromise(searchFunction, DEBOUNCE_AMOUNT));
10
+ const search = useAsync(async () => text.length === 0 ? undefined : debouncedSearchFunction(text, facet), [debouncedSearchFunction, text, facet], { setLoading: (state) => ({ ...state, loading: true }) });
11
+ return { text, setText, facet, setFacet, search };
12
+ }
@@ -0,0 +1,17 @@
1
+ /// <reference types="react" />
2
+ export type SearchOptions = {
3
+ groupLimit?: number;
4
+ page?: number;
5
+ perPage?: number;
6
+ queryBy?: string;
7
+ queryByWeights?: string;
8
+ sortBy?: string;
9
+ };
10
+ export default function useSearch(lang: string, options?: SearchOptions): {
11
+ text: string;
12
+ setText: import("react").Dispatch<import("react").SetStateAction<string>>;
13
+ facet: number;
14
+ setFacet: import("react").Dispatch<import("react").SetStateAction<number>>;
15
+ search: import("react-async-hook").UseAsyncReturn<any, any[]>;
16
+ };
17
+ //# sourceMappingURL=use-search.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-search.d.ts","sourceRoot":"","sources":["../../../../../src/lbm/components/instant-search/hooks/use-search.ts"],"names":[],"mappings":";AAOA,MAAM,MAAM,aAAa,GAAG;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB;;;;;;EAY1E"}
@@ -0,0 +1,10 @@
1
+ import getConfig from "next/config";
2
+ import useDebouncedSearch from "./use-debounced-search";
3
+ import * as API from "../services/api";
4
+ const { publicRuntimeConfig } = getConfig();
5
+ const { site } = publicRuntimeConfig;
6
+ export default function useSearch(lang, options = {}) {
7
+ return useDebouncedSearch(async (query, facet) => {
8
+ return API.fetchResults(site, lang, query, facet, options.groupLimit, options.queryBy, options.queryByWeights);
9
+ });
10
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "fr": {
3
+ "try": "Essayez",
4
+ "pages": "Pages",
5
+ "faqs": "Questions fréquentes",
6
+ "information": "Informations",
7
+ "documents": "Documents",
8
+ "noProducts": "Pas de produit correspondant",
9
+ "showOtherResults": "Afficher les autres résultats",
10
+ "winter": "Hiver",
11
+ "summer": "Été",
12
+ "results": "résultats pour",
13
+ "result": "résultat pour",
14
+ "showAllFAQs": "Tout afficher",
15
+ "hideAllFAQs": "Réduire"
16
+ },
17
+ "en": {
18
+ "try": "Try",
19
+ "pages": "Pages",
20
+ "faqs": "FAQs",
21
+ "information": "Information",
22
+ "documents": "Documents",
23
+ "noProducts": "No matching product",
24
+ "showOtherResults": "Show other results",
25
+ "winter": "Winter",
26
+ "summer": "Summer",
27
+ "results": "results for",
28
+ "result": "result for",
29
+ "showAllFAQs": "Show all",
30
+ "hideAllFAQs": "Hide all"
31
+ }
32
+ }
@@ -0,0 +1,3 @@
1
+ import InstantSearch from "./instant-search";
2
+ export default InstantSearch;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lbm/components/instant-search/index.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAE7C,eAAe,aAAa,CAAC"}
@@ -0,0 +1,2 @@
1
+ import InstantSearch from "./instant-search";
2
+ export default InstantSearch;
@@ -0,0 +1,19 @@
1
+ import { type SearchOptions } from "./hooks/use-search";
2
+ type Props = {
3
+ lang: string;
4
+ className?: string;
5
+ ubloContext: {
6
+ lang: string;
7
+ cmsMode: "connected" | "editing" | "info";
8
+ metadata: Record<string, string>;
9
+ path: string;
10
+ };
11
+ suggestions?: {
12
+ fr?: string[];
13
+ en?: string[];
14
+ };
15
+ options?: SearchOptions;
16
+ };
17
+ export default function InstantSearch({ lang, suggestions, className, options, }: Props): import("react/jsx-runtime").JSX.Element;
18
+ export {};
19
+ //# sourceMappingURL=instant-search.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instant-search.d.ts","sourceRoot":"","sources":["../../../../src/lbm/components/instant-search/instant-search.tsx"],"names":[],"mappings":"AAOA,OAAkB,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKnE,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,WAAW,GAAG,SAAS,GAAG,MAAM,CAAC;QAC1C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACjC,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,WAAW,CAAC,EAAE;QACZ,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;QACd,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;KACf,CAAC;IACF,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,IAAI,EACJ,WAAW,EACX,SAAS,EACT,OAAY,GACb,EAAE,KAAK,2CAmGP"}
@@ -0,0 +1,64 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import classNames from "classnames";
4
+ import Router from "next/router";
5
+ import Input from "dt-design-system/es/input";
6
+ import Dialog from "dt-design-system/es/dialog";
7
+ import SearchInput from "./search-input";
8
+ import Results from "./results";
9
+ import useSearch from "./hooks/use-search";
10
+ import * as Plausible from "../../../common/components/plausible";
11
+ import css from "./instant-search.module.css";
12
+ export default function InstantSearch({ lang, suggestions, className, options = {}, }) {
13
+ const [opened, setOpened] = React.useState(false);
14
+ const { text, setText, facet, setFacet, search } = useSearch(lang, options);
15
+ const classes = classNames(css.search, className);
16
+ const openSearch = () => {
17
+ setOpened(true);
18
+ document.body.style.setProperty("overflow", "hidden");
19
+ };
20
+ const closeSearch = (skipEvent) => {
21
+ setOpened(false);
22
+ setText("");
23
+ document.body.style.removeProperty("overflow");
24
+ if (!skipEvent) {
25
+ const event = search?.result?.length === 0 ? "Search failed" : "Search canceled";
26
+ if (text.length > 0) {
27
+ Plausible.sendGoal(event, {
28
+ Terms: text,
29
+ });
30
+ }
31
+ }
32
+ };
33
+ const sendPlausibleGoal = (path) => () => {
34
+ Plausible.sendGoal("Search", {
35
+ "Terms - Destination": `${text} - ${path}`,
36
+ });
37
+ };
38
+ Router.ready(() => {
39
+ Router.events.on("routeChangeStart", () => {
40
+ if (opened) {
41
+ closeSearch(true);
42
+ }
43
+ });
44
+ });
45
+ const handleKeyPresses = React.useCallback((e) => {
46
+ const allowedKeys = ["k"];
47
+ const { code, ctrlKey, key, metaKey } = e;
48
+ const isAllowed = (ctrlKey || metaKey) &&
49
+ (allowedKeys.includes(code) || allowedKeys.includes(key));
50
+ if (!isAllowed)
51
+ return;
52
+ e.preventDefault();
53
+ if (key === "k" && (ctrlKey || metaKey)) {
54
+ openSearch();
55
+ }
56
+ }, []);
57
+ React.useEffect(() => {
58
+ window.addEventListener("keydown", handleKeyPresses);
59
+ return () => {
60
+ window.removeEventListener("keydown", handleKeyPresses);
61
+ };
62
+ }, [handleKeyPresses]);
63
+ return (_jsxs(_Fragment, { children: [_jsx(Input, { icon: "Search", placeholder: "Que recherchez-vous ?", className: classes, onClick: openSearch, readOnly: true }), _jsxs(Dialog, { className: css.dialog, isOpened: opened, showCloseButton: false, close: closeSearch, container: "body", showAsModal: false, children: [_jsx(SearchInput, { lang: lang, text: text, setText: setText, closeSearch: closeSearch, loading: search.loading === true, suggestions: suggestions }), _jsx(Results, { lang: lang, text: text, facet: facet, setFacet: setFacet, results: search.result, loading: search.loading === true && search.result === undefined, sendPlausibleGoal: sendPlausibleGoal })] })] }));
64
+ }
@@ -0,0 +1,8 @@
1
+ .dialog {
2
+ width: 1400px;
3
+ max-width: calc(100% - 6px);
4
+ max-height: calc(100% - 6px);
5
+ background-color: transparent;
6
+ box-shadow: none;
7
+ pointer-events: auto;
8
+ }
@@ -0,0 +1,12 @@
1
+ import type { Hit } from "./results";
2
+ type Props = {
3
+ linksTitle: string;
4
+ icon: "FileText" | "Info" | "Question" | "User" | "File";
5
+ links: Hit[];
6
+ pageTitleAsTitle?: boolean;
7
+ loading: boolean;
8
+ sendPlausibleGoal: (path: string) => void;
9
+ };
10
+ export default function Links({ icon, linksTitle, links, pageTitleAsTitle, loading, sendPlausibleGoal, }: Props): import("react/jsx-runtime").JSX.Element;
11
+ export {};
12
+ //# sourceMappingURL=links.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../../../../src/lbm/components/instant-search/links.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAGrC,KAAK,KAAK,GAAG;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC;IACzD,KAAK,EAAE,GAAG,EAAE,CAAC;IACb,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IAEjB,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3C,CAAC;AAIF,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAC5B,IAAI,EACJ,UAAU,EACV,KAAK,EACL,gBAAgB,EAChB,OAAO,EACP,iBAAiB,GAClB,EAAE,KAAK,2CAmEP"}
@@ -0,0 +1,30 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import Link from "ublo/link";
3
+ import Loader from "dt-design-system/es/loader";
4
+ import * as Icons from "dt-design-system/es/icons";
5
+ import * as Ripple from "dt-design-system/es/ripple";
6
+ import * as Utils from "./services/utils";
7
+ import css from "./links.module.css";
8
+ const PLACEHOLDERS = [...new Array(3)];
9
+ export default function Links({ icon, linksTitle, links, pageTitleAsTitle, loading, sendPlausibleGoal, }) {
10
+ const Icon = Icons[icon];
11
+ const noResult = !loading && !links.length;
12
+ const createRipple = (e) => {
13
+ Ripple.create(e);
14
+ };
15
+ if (noResult)
16
+ return null;
17
+ return (_jsxs("div", { className: css.linksSection, children: [_jsx("div", { className: css.linksTitle, children: linksTitle }), _jsxs("div", { className: css.links, children: [loading &&
18
+ PLACEHOLDERS.map((_, i) => {
19
+ return (_jsx("div", { className: css.loaderContainer, children: _jsx(Loader, { className: css.loader, variant: "overlay" }) }, i));
20
+ }), !loading &&
21
+ links.map((link) => {
22
+ const { id, text, parentTitle, path, target } = link.document;
23
+ const decodedPath = decodeURIComponent(target || path);
24
+ const titleProperty = pageTitleAsTitle ? "pageTitle" : "title";
25
+ const linkTitle = Utils.getHighlight(titleProperty, link.highlight) ||
26
+ link.document[titleProperty].trim();
27
+ const linkText = Utils.getHighlight("text", link.highlight, true) || text?.trim();
28
+ return (_jsxs(Link, { href: decodedPath, className: css.link, onClick: sendPlausibleGoal(decodedPath), onMouseDown: createRipple, children: [_jsx(Icon, { className: css.linkIcon }), _jsxs("div", { className: css.linkContent, children: [parentTitle && (_jsx("div", { className: css.linkParent, dangerouslySetInnerHTML: { __html: parentTitle } })), _jsx("div", { className: css.linkTitle, dangerouslySetInnerHTML: { __html: linkTitle } }), linkText && (_jsx("div", { className: css.linkText, dangerouslySetInnerHTML: { __html: linkText } }))] })] }, id));
29
+ })] })] }));
30
+ }
@@ -0,0 +1,96 @@
1
+ .linksSection {
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: 6px;
5
+ }
6
+
7
+ .linksTitle {
8
+ position: sticky;
9
+ top: 16px;
10
+ font-size: 17px;
11
+ font-weight: 700;
12
+ padding: 3px 8px;
13
+ background-color: var(--ds-grey-200, #efefef);
14
+ border-radius: var(--ds-radius-100, 6px);
15
+ z-index: 1;
16
+ }
17
+
18
+ @media (min-width: 730px) {
19
+ .linksTitle {
20
+ top: 0;
21
+ }
22
+ }
23
+
24
+ .links {
25
+ display: flex;
26
+ flex-direction: column;
27
+ gap: 6px;
28
+ }
29
+
30
+ .loaderContainer {
31
+ position: relative;
32
+ width: 100%;
33
+ height: 44px;
34
+ border-radius: var(--ds-radius-100, 6px);
35
+ }
36
+
37
+ .link {
38
+ position: relative;
39
+ display: flex;
40
+ gap: 10px;
41
+ padding: 6px;
42
+ color: var(--ds-grey-500, #484848);
43
+ border-radius: var(--ds-radius-100, 6px);
44
+ transition: background-color 160ms
45
+ var(--ds-transition-easing, cubic-bezier(0.4, 0, 0.2, 1));
46
+ }
47
+
48
+ .link:is(:hover, :focus) {
49
+ background-color: var(--ds-grey-100, #f5f5f5);
50
+ }
51
+
52
+ .linkIcon {
53
+ flex: 0 0 16px;
54
+ width: 16px;
55
+ height: 16px;
56
+ margin-top: 2px;
57
+ fill: currentColor;
58
+ }
59
+
60
+ .linkContent {
61
+ flex: 1 1 auto;
62
+ }
63
+
64
+ .linkTitle {
65
+ font-size: 15px;
66
+ }
67
+
68
+ .link mark {
69
+ position: relative;
70
+ display: inline-block;
71
+ font-weight: 700;
72
+ color: var(--ds-secondary, var(--ds-blue-400, #4177f6));
73
+ background-color: transparent;
74
+ }
75
+
76
+ .link mark::before {
77
+ content: "";
78
+ position: absolute;
79
+ top: 0;
80
+ left: 0;
81
+ width: 100%;
82
+ height: 100%;
83
+ background-color: var(--ds-secondary, var(--ds-blue-400, #4177f6));
84
+ border-radius: calc(var(--ds-radius-100, 6px) / 3);
85
+ opacity: 0.15;
86
+ }
87
+
88
+ .linkParent {
89
+ text-transform: uppercase;
90
+ font-size: 10px;
91
+ }
92
+
93
+ .linkText {
94
+ font-size: 12px;
95
+ white-space: pre-wrap;
96
+ }
@@ -0,0 +1,6 @@
1
+ type Props = {
2
+ className?: string;
3
+ };
4
+ export default function NoProduct({ className }: Props): import("react/jsx-runtime").JSX.Element;
5
+ export {};
6
+ //# sourceMappingURL=no-product.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-product.d.ts","sourceRoot":"","sources":["../../../../src/lbm/components/instant-search/no-product.tsx"],"names":[],"mappings":"AAEA,KAAK,KAAK,GAAG;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAAE,SAAS,EAAE,EAAE,KAAK,2CA2FrD"}