ublo-lib 1.48.1 → 1.48.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../../src/future/components/msem-package/components/config.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,KAAK,KAAK,MAAM,UAAU,CAAC;AAIvC,KAAK,KAAK,GAAG;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC;IACrB,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;CAC/D,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,KAAK,2CA8CpE"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../../src/future/components/msem-package/components/config.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,KAAK,KAAK,MAAM,UAAU,CAAC;AAIvC,KAAK,KAAK,GAAG;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC;IACrB,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;CAC/D,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,KAAK,2CAsDpE"}
@@ -5,10 +5,16 @@ import Zone from "ublo/zone";
5
5
  import styles from "./config.module.css";
6
6
  export default function Config({ idPrefix, config, setConfig }) {
7
7
  const ref = React.useRef(null);
8
- const { menuPath } = useUbloContext();
9
- const [initialized, setInitialized] = React.useState(false);
8
+ const { menuPath, lang, path } = useUbloContext();
9
+ const initializedRef = React.useRef(false);
10
+ const prevRouteRef = React.useRef(`/${lang}${path}`);
10
11
  React.useEffect(() => {
11
- if (!initialized) {
12
+ const route = `/${lang}${path}`;
13
+ if (route !== prevRouteRef.current) {
14
+ prevRouteRef.current = route;
15
+ initializedRef.current = false;
16
+ }
17
+ if (!initializedRef.current) {
12
18
  const container = ref.current;
13
19
  let script = container?.querySelector("script");
14
20
  if (!script) {
@@ -16,27 +22,27 @@ export default function Config({ idPrefix, config, setConfig }) {
16
22
  type: "application/json",
17
23
  innerHTML: "{}",
18
24
  });
19
- container.appendChild(script);
25
+ container?.appendChild(script);
20
26
  }
21
27
  const storedConfig = script.textContent;
22
28
  if (storedConfig) {
23
- const config = JSON.parse(storedConfig);
29
+ const parsed = JSON.parse(storedConfig);
24
30
  setConfig({
25
- ...config,
26
- id: config.id || `${idPrefix}-${menuPath?.id}`,
31
+ ...parsed,
32
+ id: parsed.id || `${idPrefix}-${menuPath?.id}`,
27
33
  });
28
34
  }
29
- setInitialized(true);
35
+ initializedRef.current = true;
30
36
  }
31
- }, [initialized, setConfig, idPrefix, menuPath?.id]);
37
+ }, [lang, path, setConfig, idPrefix, menuPath?.id]);
32
38
  React.useEffect(() => {
33
39
  const container = ref.current;
34
- if (initialized && container) {
40
+ if (initializedRef.current && container) {
35
41
  const script = container.querySelector("script");
36
42
  if (script) {
37
43
  script.textContent = JSON.stringify(config);
38
44
  }
39
45
  }
40
- }, [config, initialized]);
46
+ }, [config]);
41
47
  return (_jsx(Zone, { ref: ref, id: "package-config", className: styles.zone, readOnly: true }));
42
48
  }
@@ -59,5 +59,5 @@ export default function Filters({ config, stay, setStay }) {
59
59
  closeDatePicker();
60
60
  };
61
61
  const titleKey = forced ? "filters.fixed-title" : "filters.title";
62
- return (_jsx("div", { ref: ref, className: styles.filters, style: { display: forced ? "none" : "block" }, children: _jsxs("div", { className: styles.form, children: [_jsx("div", { className: styles.title, children: _jsx(T, { id: titleKey }) }), fixed && (_jsxs("div", { className: styles.subtitle, children: [_jsx(T, { id: "filters.subtitle" }), _jsxs("span", { className: styles.bold, children: [nbDays, " ", _jsx(T, { id: "filters.day" }), nbDays > 1 ? "s" : ""] })] })), _jsxs("div", { className: styles.inner, children: [_jsx(Dropdown, { open: datePickerOpen, onClose: closeDatePicker, onOpenChange: (open) => setDatePickerOpen(open), breakpoint: 600, content: _jsx(DatePicker, { stayDates: stayDates, popup: false, close: closeDatePicker, onSubmit: updateStay, min: min, max: usedMax, singleDate: fixed, submitOnSelectionEnd: fixed, ...datePickerOptions }), children: _jsx(Input, { type: "text", icon: "Calendar", className: styles.field, label: t(lang, "filters.stay-from-label"), placeholder: t(lang, "filters.stay-from-placeholder"), value: stay?.from ? Utils.weekToLongDate(stay.from) : "", onClick: () => openDatePicker(), readOnly: true, disabled: forced }) }, JSON.stringify(datePickerOptions)), _jsx(Input, { type: "text", icon: "Calendar", className: styles.field, label: t(lang, "filters.stay-to-label"), placeholder: t(lang, "filters.stay-to-placeholder"), value: stay?.to ? Utils.weekToLongDate(stay?.to || "") : "", onClick: () => openDatePicker({ defaultSelecting: true }), readOnly: true, disabled: forced || fixed || !stay?.from }), _jsxs("div", { className: styles.pax, children: [_jsx(Input, { icon: "User", type: "number", label: t(lang, "filters.pax"), className: styles.field, value: paxPlan || "", disabled: true }), _jsxs("span", { className: styles.paxMessage, children: [_jsx(T, { id: "filters.pax-message" }), " ", paxPlan] })] })] })] }) }));
62
+ return (_jsx("div", { ref: ref, className: styles.filters, style: { display: forced ? "none" : "block" }, children: _jsxs("div", { className: styles.form, children: [_jsx("div", { className: styles.title, children: _jsx(T, { id: titleKey }) }), fixed && (_jsxs("div", { className: styles.subtitle, children: [_jsx(T, { id: "filters.subtitle" }), " ", _jsxs("span", { className: styles.bold, children: [nbDays, " ", _jsx(T, { id: "filters.day" }), nbDays > 1 ? "s" : ""] })] })), _jsxs("div", { className: styles.inner, children: [_jsx(Dropdown, { open: datePickerOpen, onClose: closeDatePicker, onOpenChange: (open) => setDatePickerOpen(open), breakpoint: 600, content: _jsx(DatePicker, { stayDates: stayDates, popup: false, close: closeDatePicker, onSubmit: updateStay, min: min, max: usedMax, singleDate: fixed, submitOnSelectionEnd: fixed, ...datePickerOptions }), children: _jsx(Input, { type: "text", icon: "Calendar", className: styles.field, label: t(lang, "filters.stay-from-label"), placeholder: t(lang, "filters.stay-from-placeholder"), value: stay?.from ? Utils.weekToLongDate(stay.from) : "", onClick: () => openDatePicker(), readOnly: true, disabled: forced }) }, JSON.stringify(datePickerOptions)), _jsx(Input, { type: "text", icon: "Calendar", className: styles.field, label: t(lang, "filters.stay-to-label"), placeholder: t(lang, "filters.stay-to-placeholder"), value: stay?.to ? Utils.weekToLongDate(stay?.to || "") : "", onClick: () => openDatePicker({ defaultSelecting: true }), readOnly: true, disabled: forced || fixed || !stay?.from }), _jsxs("div", { className: styles.pax, children: [_jsx(Input, { icon: "User", type: "number", label: t(lang, "filters.pax"), className: styles.field, value: paxPlan || "", disabled: true }), _jsxs("span", { className: styles.paxMessage, children: [_jsx(T, { id: "filters.pax-message" }), " ", paxPlan] })] })] })] }) }));
63
63
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ublo-lib",
3
- "version": "1.48.1",
3
+ "version": "1.48.3",
4
4
  "peerDependencies": {
5
5
  "classnames": "^2.5.1",
6
6
  "dt-design-system": "^3.12.0",