@memobit/libs 3.33.0 → 3.35.0

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,51 +1,53 @@
1
1
  import './MenuHamburger.css';
2
2
  import { Icon as H } from "../Icon/Icon2.js";
3
- import { Button as l } from "../Button/Button2.js";
3
+ import { Button as t } from "../Button/Button2.js";
4
4
  import { ContextMenu as v } from "../ContextMenu/ContextMenu2.js";
5
5
  import { useBreakpoint as f } from "../../hooks/useBreakpoint.js";
6
6
  /* empty css */
7
7
  import { useState as N } from "react";
8
8
  import { jsx as n, jsxs as i } from "react/jsx-runtime";
9
- var I = ({ icon: d = "menu-hamburger", isCompact: o, items: t, label: c, showLabel: s = !0, disableResponsive: p = !1 }) => {
9
+ var I = ({ icon: g = "menu-hamburger", isCompact: s, items: l, label: o, showLabel: c = !0, disableResponsive: p = !1 }) => {
10
10
  const { isAtLeast: M } = f(), [u, m] = N(null), h = (e) => {
11
11
  m(e.currentTarget);
12
- }, g = () => {
12
+ }, d = () => {
13
13
  m(null);
14
- }, a = p ? !0 : M("tablet");
15
- if (t.length === 1) {
16
- const e = t[0], r = a && s;
14
+ }, r = p ? !0 : M("tablet");
15
+ if (l.length === 1) {
16
+ const e = l[0], a = r && c;
17
17
  return /* @__PURE__ */ n("div", {
18
18
  className: "MenuHamburger",
19
- children: /* @__PURE__ */ n(l, {
20
- variant: o || !a ? "plain" : "default",
19
+ children: /* @__PURE__ */ n(t, {
20
+ variant: s || !r ? "plain" : "default",
21
21
  onClick: e.onClick,
22
22
  icon: e.icon,
23
- className: `MenuHamburger_single-item ${r ? "" : "MenuHamburger_single-item--icon-only"} ${e.isActive ? "MenuHamburger_item--active" : ""}`,
24
- children: r ? e.label : ""
23
+ disabled: e.disabled,
24
+ className: `MenuHamburger_single-item ${a ? "" : "MenuHamburger_single-item--icon-only"} ${e.isActive ? "MenuHamburger_item--active" : ""}`,
25
+ children: a ? e.label : ""
25
26
  })
26
27
  });
27
28
  }
28
29
  const _ = (e) => {
29
- e.onClick(), g();
30
- }, b = a && s && !!c;
30
+ e.onClick(), d();
31
+ }, b = r && c && !!o;
31
32
  return /* @__PURE__ */ i("div", {
32
33
  className: "MenuHamburger",
33
- children: [/* @__PURE__ */ n(l, {
34
- variant: o || !a ? "plain" : "default",
34
+ children: [/* @__PURE__ */ n(t, {
35
+ variant: s || !r ? "plain" : "default",
35
36
  onClick: h,
36
- icon: d,
37
+ icon: g,
37
38
  className: b ? "" : "MenuHamburger_opener--icon-only",
38
- children: b ? c : ""
39
+ children: b ? o : ""
39
40
  }), u && /* @__PURE__ */ n(v, {
40
41
  target: u,
41
- onClose: g,
42
+ onClose: d,
42
43
  children: /* @__PURE__ */ n("div", {
43
44
  className: "MenuHamburger_dropdown",
44
- children: t.map((e, r) => /* @__PURE__ */ i("div", {
45
+ children: l.map((e, a) => /* @__PURE__ */ i("div", {
45
46
  className: "MenuHamburger_entry",
46
- children: [e.separator && r > 0 && /* @__PURE__ */ n("div", { className: "MenuHamburger_separator" }), /* @__PURE__ */ i(l, {
47
+ children: [e.separator && a > 0 && /* @__PURE__ */ n("div", { className: "MenuHamburger_separator" }), /* @__PURE__ */ i(t, {
47
48
  variant: "plain",
48
49
  className: `MenuHamburger_item ${e.isActive ? "MenuHamburger_item--active" : ""}`,
50
+ disabled: e.disabled,
49
51
  onClick: () => _(e),
50
52
  children: [/* @__PURE__ */ n("span", {
51
53
  className: "MenuHamburger_item__icon",
@@ -55,7 +57,7 @@ var I = ({ icon: d = "menu-hamburger", isCompact: o, items: t, label: c, showLab
55
57
  children: e.label
56
58
  })]
57
59
  })]
58
- }, r))
60
+ }, a))
59
61
  })
60
62
  })]
61
63
  });
@@ -1,32 +1,55 @@
1
- import { useAccountMenu as u } from "../../hooks/useAccountMenu.js";
2
- import { AppFrameContext as a } from "./useAppFrame.js";
3
- import { useMemo as i } from "react";
4
- import { jsx as n, jsxs as s } from "react/jsx-runtime";
5
- var p = ({ app: r, nav: e, menuItems: o, children: t }) => {
6
- const m = i(() => ({
7
- app: r,
8
- nav: e,
9
- menuItems: o
1
+ import { ThemeSettings as u } from "../ThemeSettings/ThemeSettings2.js";
2
+ import { useAccountMenu as c } from "../../hooks/useAccountMenu.js";
3
+ import { AppFrameContext as l } from "./useAppFrame.js";
4
+ import { useMemo as f, useState as A } from "react";
5
+ import { jsx as o, jsxs as a } from "react/jsx-runtime";
6
+ var s = ({ app: e, nav: t, menuItems: r, status: m, children: n }) => {
7
+ const i = f(() => ({
8
+ app: e,
9
+ nav: t,
10
+ menuItems: r,
11
+ status: m
10
12
  }), [
11
- r,
12
13
  e,
13
- o
14
+ t,
15
+ r,
16
+ m
14
17
  ]);
15
- return /* @__PURE__ */ n(a.Provider, {
16
- value: m,
17
- children: t
18
+ return /* @__PURE__ */ o(l.Provider, {
19
+ value: i,
20
+ children: n
21
+ });
22
+ }, h = ({ account: e, menuItems: t = [], children: r, ...m }) => {
23
+ const n = c(e);
24
+ return /* @__PURE__ */ a(s, {
25
+ ...m,
26
+ menuItems: [...t, ...n.items],
27
+ children: [r, n.modals]
18
28
  });
19
- }, c = ({ account: r, menuItems: e = [], children: o, ...t }) => {
20
- const m = u(r);
21
- return /* @__PURE__ */ s(p, {
22
- ...t,
23
- menuItems: [...e, ...m.items],
24
- children: [o, m.modals]
29
+ }, v = ({ theme: e, menuItems: t = [], children: r, ...m }) => {
30
+ const [n, i] = A(!1), p = {
31
+ label: e.label ?? "Theme",
32
+ icon: "theme-picker",
33
+ onClick: () => i(!0),
34
+ isActive: !1,
35
+ separator: !0
36
+ };
37
+ return /* @__PURE__ */ a(s, {
38
+ ...m,
39
+ menuItems: [...t, p],
40
+ children: [r, /* @__PURE__ */ o(u, {
41
+ isOpen: n,
42
+ onClose: () => i(!1),
43
+ currentApp: e.appName
44
+ })]
25
45
  });
26
- }, x = ({ account: r, ...e }) => r ? /* @__PURE__ */ n(c, {
27
- account: r,
28
- ...e
29
- }) : /* @__PURE__ */ n(p, { ...e });
46
+ }, I = ({ account: e, theme: t, ...r }) => e ? /* @__PURE__ */ o(h, {
47
+ account: e,
48
+ ...r
49
+ }) : t ? /* @__PURE__ */ o(v, {
50
+ theme: t,
51
+ ...r
52
+ }) : /* @__PURE__ */ o(s, { ...r });
30
53
  export {
31
- x as AppFrame
54
+ I as AppFrame
32
55
  };
@@ -1 +1 @@
1
- .filter-field,.filter-field__stack{gap:var(--spacing-8);flex-direction:column;min-width:0;display:flex}.filter-field__segmented{gap:var(--spacing-2);padding:var(--spacing-2);border:1px solid var(--form-control-border-color);border-radius:var(--radius);background-color:var(--form-control-background-color);display:flex}.filter-field__segment{min-width:0;padding:var(--spacing-4) var(--spacing-8);border-radius:var(--radius-sm);color:var(--body-color-muted);font:inherit;font-size:var(--font-size-sm);font-weight:var(--font-weight-medium);white-space:nowrap;cursor:pointer;transition:background-color var(--transition-fast), color var(--transition-fast);text-overflow:ellipsis;white-space:nowrap;background-color:#0000;border:0;flex:auto;overflow:hidden}.filter-field__segment:hover{color:var(--body-color)}.filter-field__segment--selected,.filter-field__segment--selected:hover{background-color:var(--chip-selected-background-color);color:var(--chip-selected-color)}.filter-field__chips{gap:var(--spacing-6);flex-wrap:wrap;display:flex}.filter-field__rows,.filter-field__options{flex-direction:column;display:flex}.filter-field__options{max-height:var(--spacing-300);overflow-y:auto}.filter-field__row{align-items:center;gap:var(--spacing-8);width:100%;padding:var(--spacing-6) var(--spacing-4);border-radius:var(--radius-sm);color:var(--body-color);font:inherit;font-size:var(--font-size-sm);text-align:left;cursor:pointer;background-color:#0000;border:0;display:flex}.filter-field__row:hover{background-color:var(--list-hover-background-color)}.filter-field__row--empty{color:var(--body-color-muted)}.filter-field__mark{width:var(--spacing-16);height:var(--spacing-16);border:1px solid var(--form-control-border-color);color:var(--card-background-color);flex:none;justify-content:center;align-items:center;display:flex}.filter-field__mark--radio{border-radius:var(--radius-full)}.filter-field__mark--check{border-radius:var(--radius-sm)}.filter-field__row--selected .filter-field__mark{border-color:var(--body-accent-color);background-color:var(--body-accent-color)}.filter-field__row--selected .filter-field__mark--radio{padding:var(--spacing-2);background-clip:content-box}.filter-field__row-label{text-overflow:ellipsis;white-space:nowrap;flex:auto;min-width:0;overflow:hidden}.filter-field__count{color:var(--body-color-muted);font-size:var(--font-size-xs);font-variant-numeric:tabular-nums;flex:none}.filter-field__divider{height:1px;margin:var(--spacing-4) 0;background-color:var(--delimiter-color);flex:none}.filter-field__empty{padding:var(--spacing-8) var(--spacing-4);color:var(--body-color-muted);font-size:var(--font-size-sm)}.filter-field__link{padding:var(--spacing-2) 0;color:var(--links-color);font:inherit;font-size:var(--font-size-sm);cursor:pointer;background:0 0;border:0;align-self:flex-start}.filter-field__link:hover{color:var(--links-hover-color)}.filter-field__rating{align-items:center;gap:var(--spacing-8);flex-wrap:wrap;display:flex}.filter-field__switch-row{flex-direction:row;justify-content:space-between;align-items:center}.filter-field__switch-label{min-width:0;padding:var(--spacing-4) 0;color:var(--body-color);font:inherit;font-size:var(--font-size-sm);font-weight:var(--font-weight-medium);text-align:left;cursor:pointer;background:0 0;border:0;flex:auto}.filter-field--sheet .filter-field__segment{padding:var(--spacing-8) var(--spacing-6);font-size:var(--font-size-md)}.filter-field--sheet .filter-field__row{padding:var(--spacing-12) var(--spacing-4);font-size:var(--font-size-md)}.filter-field--sheet .filter-field__options{max-height:none}.filter-field--sheet .filter-field__switch-label{padding:var(--spacing-8) 0;font-size:var(--font-size-md)}
1
+ .filter-field,.filter-field__stack{gap:var(--spacing-8);flex-direction:column;min-width:0;display:flex}.filter-field__segmented{gap:var(--spacing-2);padding:var(--spacing-2);border:1px solid var(--form-control-border-color);border-radius:var(--radius);background-color:var(--form-control-background-color);display:flex}.filter-field__segment{min-width:0;padding:var(--spacing-4) var(--spacing-8);border-radius:var(--radius-sm);color:var(--body-color-muted);font:inherit;font-size:var(--font-size-sm);font-weight:var(--font-weight-medium);white-space:nowrap;cursor:pointer;transition:background-color var(--transition-fast), color var(--transition-fast);text-overflow:ellipsis;white-space:nowrap;background-color:#0000;border:0;flex:auto;overflow:hidden}.filter-field__segment:hover{color:var(--body-color)}.filter-field__segment--selected,.filter-field__segment--selected:hover{background-color:var(--chip-selected-background-color);color:var(--chip-selected-color)}.filter-field__chips{gap:var(--spacing-6);flex-wrap:wrap;display:flex}.filter-field__chips .filter-field__chip--empty{opacity:.6}.filter-field__rows,.filter-field__options{flex-direction:column;display:flex}.filter-field__options{max-height:var(--spacing-300);overflow-y:auto}.filter-field__row{align-items:center;gap:var(--spacing-8);width:100%;padding:var(--spacing-6) var(--spacing-4);border-radius:var(--radius-sm);color:var(--body-color);font:inherit;font-size:var(--font-size-sm);text-align:left;cursor:pointer;background-color:#0000;border:0;display:flex}.filter-field__row:hover{background-color:var(--list-hover-background-color)}.filter-field__row--empty{color:var(--body-color-muted)}.filter-field__mark{width:var(--spacing-16);height:var(--spacing-16);border:1px solid var(--form-control-border-color);color:var(--card-background-color);flex:none;justify-content:center;align-items:center;display:flex}.filter-field__mark--radio{border-radius:var(--radius-full)}.filter-field__mark--check{border-radius:var(--radius-sm)}.filter-field__row--selected .filter-field__mark{border-color:var(--body-accent-color);background-color:var(--body-accent-color)}.filter-field__row--selected .filter-field__mark--radio{padding:var(--spacing-2);background-clip:content-box}.filter-field__row-label{text-overflow:ellipsis;white-space:nowrap;flex:auto;min-width:0;overflow:hidden}.filter-field__count{color:var(--body-color-muted);font-size:var(--font-size-xs);font-variant-numeric:tabular-nums;flex:none}.filter-field__divider{height:1px;margin:var(--spacing-4) 0;background-color:var(--delimiter-color);flex:none}.filter-field__empty{padding:var(--spacing-8) var(--spacing-4);color:var(--body-color-muted);font-size:var(--font-size-sm)}.filter-field__link{padding:var(--spacing-2) 0;color:var(--links-color);font:inherit;font-size:var(--font-size-sm);cursor:pointer;background:0 0;border:0;align-self:flex-start}.filter-field__link:hover{color:var(--links-hover-color)}.filter-field__rating{align-items:center;gap:var(--spacing-8);flex-wrap:wrap;display:flex}.filter-field__switch-row{flex-direction:row;justify-content:space-between;align-items:center}.filter-field__switch-label{min-width:0;padding:var(--spacing-4) 0;color:var(--body-color);font:inherit;font-size:var(--font-size-sm);font-weight:var(--font-weight-medium);text-align:left;cursor:pointer;background:0 0;border:0;flex:auto}.filter-field--sheet .filter-field__segment{padding:var(--spacing-8) var(--spacing-6);font-size:var(--font-size-md)}.filter-field--sheet .filter-field__row{padding:var(--spacing-12) var(--spacing-4);font-size:var(--font-size-md)}.filter-field--sheet .filter-field__options{max-height:none}.filter-field--sheet .filter-field__switch-label{padding:var(--spacing-8) 0;font-size:var(--font-size-md)}
@@ -1,114 +1,115 @@
1
1
  import './FilterField.css';
2
- import { Icon as D } from "../Icon/Icon2.js";
3
- import { libMessages as g } from "../../contexts/LanguageContext/libMessages.js";
4
- import { useMessages as b } from "../../hooks/useLanguage.js";
5
- import { formatDate as L } from "../../helpers/Datetime.js";
6
- import { Chip as j } from "../Chip/Chip2.js";
7
- import { DatePicker as z } from "../DatePicker/DatePicker2.js";
2
+ import { Icon as M } from "../Icon/Icon2.js";
3
+ import { libMessages as v } from "../../contexts/LanguageContext/libMessages.js";
4
+ import { useMessages as g } from "../../hooks/useLanguage.js";
5
+ import { formatDate as w } from "../../helpers/Datetime.js";
6
+ import { Chip as z } from "../Chip/Chip2.js";
7
+ import { DatePicker as R } from "../DatePicker/DatePicker2.js";
8
8
  import { InputSearch as F } from "../InputSearch/InputSearch2.js";
9
9
  import { Rating as C } from "../Rating/Rating2.js";
10
10
  import { ToggleSwitch as T } from "../ToggleSwitch/ToggleSwitch2.js";
11
11
  import { RangeSlider as W } from "../RangeSlider/RangeSlider2.js";
12
- import { getTextModes as Y, pickControl as I, toList as O, toNumber as B, toRange as E, toScalar as M, toText as V } from "./filterRules.js";
12
+ import { getTextModes as I, pickControl as O, toDateRange as B, toList as E, toNumber as V, toRange as q, toScalar as $, toText as P } from "./filterRules.js";
13
13
  /* empty css */
14
- import { useEffect as q, useState as w } from "react";
15
- import { jsx as t, jsxs as u } from "react/jsx-runtime";
16
- var N = ({ items: e, value: r, onSelect: n }) => /* @__PURE__ */ t("div", {
14
+ import { useEffect as Q, useState as y } from "react";
15
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
16
+ var D = ({ items: e, value: a, onSelect: n }) => /* @__PURE__ */ l("div", {
17
17
  className: "filter-field__segmented",
18
- children: e.map((l) => /* @__PURE__ */ t("button", {
18
+ children: e.map((t) => /* @__PURE__ */ l("button", {
19
19
  type: "button",
20
- className: ["filter-field__segment", l.value === r ? "filter-field__segment--selected" : ""].filter(Boolean).join(" "),
21
- onClick: () => n(l.value),
22
- children: l.label
23
- }, String(l.value)))
24
- }), x = ({ label: e, mark: r, selected: n, count: l, icon: a, onClick: c }) => /* @__PURE__ */ u("button", {
20
+ className: ["filter-field__segment", t.value === a ? "filter-field__segment--selected" : ""].filter(Boolean).join(" "),
21
+ onClick: () => n(t.value),
22
+ children: t.label
23
+ }, String(t.value)))
24
+ }), x = ({ label: e, mark: a, selected: n, count: t, icon: r, onClick: c }) => /* @__PURE__ */ u("button", {
25
25
  type: "button",
26
26
  className: [
27
27
  "filter-field__row",
28
28
  n ? "filter-field__row--selected" : "",
29
- l === 0 && !n ? "filter-field__row--empty" : ""
29
+ t === 0 && !n ? "filter-field__row--empty" : ""
30
30
  ].filter(Boolean).join(" "),
31
31
  onClick: c,
32
32
  children: [
33
- /* @__PURE__ */ t("span", {
34
- className: `filter-field__mark filter-field__mark--${r}`,
35
- children: r === "check" && n && /* @__PURE__ */ t(D, {
33
+ /* @__PURE__ */ l("span", {
34
+ className: `filter-field__mark filter-field__mark--${a}`,
35
+ children: a === "check" && n && /* @__PURE__ */ l(M, {
36
36
  name: "checkmark",
37
37
  size: "sm"
38
38
  })
39
39
  }),
40
- a && /* @__PURE__ */ t(D, {
41
- name: a,
40
+ r && /* @__PURE__ */ l(M, {
41
+ name: r,
42
42
  size: "sm"
43
43
  }),
44
- /* @__PURE__ */ t("span", {
44
+ /* @__PURE__ */ l("span", {
45
45
  className: "filter-field__row-label",
46
46
  children: e
47
47
  }),
48
- l !== void 0 && /* @__PURE__ */ t("span", {
48
+ t !== void 0 && /* @__PURE__ */ l("span", {
49
49
  className: "filter-field__count",
50
- children: l
50
+ children: t
51
51
  })
52
52
  ]
53
- }), P = (e, r) => e.includes(r) ? e.filter((n) => n !== r) : [...e, r], Q = ({ spec: e, value: r, context: n, onChange: l }) => {
54
- const a = b(g), [c, d] = w(""), [s, o] = w(!1), f = I(e, n), p = e.kind === "single", _ = p ? [M(r)].filter((i) => i !== null) : O(r), h = (i) => _.includes(i.value), y = (i) => {
55
- if (!p) {
56
- l(P(_, i.value));
53
+ }), G = (e, a) => e.includes(a) ? e.filter((n) => n !== a) : [...e, a], J = ({ spec: e, value: a, context: n, onChange: t }) => {
54
+ const r = g(v), [c, d] = y(""), [s, o] = y(!1), f = O(e, n), k = e.kind === "single", b = k ? [$(a)].filter((i) => i !== null) : E(a), h = (i) => b.includes(i.value), S = (i) => {
55
+ if (!k) {
56
+ t(G(b, i.value));
57
57
  return;
58
58
  }
59
- l(h(i) && f !== "radio" ? null : i.value);
59
+ t(h(i) && f !== "radio" ? null : i.value);
60
60
  };
61
61
  if (f === "segmented") {
62
62
  const i = [{
63
63
  value: null,
64
- label: a.pageAny
64
+ label: r.pageAny
65
65
  }, ...e.options.map((m) => ({
66
66
  value: m.value,
67
67
  label: m.label
68
68
  }))];
69
- return /* @__PURE__ */ t(N, {
69
+ return /* @__PURE__ */ l(D, {
70
70
  items: i,
71
- value: _[0] ?? null,
72
- onSelect: (m) => l(m)
71
+ value: b[0] ?? null,
72
+ onSelect: (m) => t(m)
73
73
  });
74
74
  }
75
- if (f === "chips") return /* @__PURE__ */ t("div", {
75
+ if (f === "chips") return /* @__PURE__ */ l("div", {
76
76
  className: "filter-field__chips",
77
- children: e.options.map((i) => /* @__PURE__ */ t(j, {
77
+ children: e.options.map((i) => /* @__PURE__ */ l(z, {
78
+ className: i.count === 0 && !h(i) ? "filter-field__chip--empty" : void 0,
78
79
  color: i.color,
79
80
  count: i.count,
80
81
  icon: i.icon,
81
82
  selected: h(i),
82
83
  size: n === "sheet" ? "medium" : "small",
83
- onClick: () => y(i),
84
+ onClick: () => S(i),
84
85
  children: i.label
85
86
  }, i.value))
86
87
  });
87
- const R = p ? "radio" : "check", v = (i) => /* @__PURE__ */ t(x, {
88
+ const L = k ? "radio" : "check", N = (i) => /* @__PURE__ */ l(x, {
88
89
  label: i.label,
89
- mark: R,
90
+ mark: L,
90
91
  selected: h(i),
91
92
  count: i.count,
92
93
  icon: i.icon,
93
- onClick: () => y(i)
94
+ onClick: () => S(i)
94
95
  }, i.value);
95
96
  if (f === "search-list") {
96
- const i = c.trim().toLowerCase(), m = e.options.filter(h), k = e.options.filter((A) => !h(A) && (!i || A.label.toLowerCase().includes(i)));
97
+ const i = c.trim().toLowerCase(), m = e.options.filter(h), p = e.options.filter((Y) => !h(Y) && (!i || Y.label.toLowerCase().includes(i)));
97
98
  return /* @__PURE__ */ u("div", {
98
99
  className: "filter-field__stack",
99
- children: [/* @__PURE__ */ t(F, {
100
+ children: [/* @__PURE__ */ l(F, {
100
101
  value: c,
101
- placeholder: a.pageSearchOptions(e.label),
102
+ placeholder: r.pageSearchOptions(e.label),
102
103
  onChange: d
103
104
  }), /* @__PURE__ */ u("div", {
104
105
  className: "filter-field__options",
105
106
  children: [
106
- m.map(v),
107
- m.length > 0 && k.length > 0 && /* @__PURE__ */ t("div", { className: "filter-field__divider" }),
108
- k.map(v),
109
- m.length === 0 && k.length === 0 && /* @__PURE__ */ t("span", {
107
+ m.map(N),
108
+ m.length > 0 && p.length > 0 && /* @__PURE__ */ l("div", { className: "filter-field__divider" }),
109
+ p.map(N),
110
+ m.length === 0 && p.length === 0 && /* @__PURE__ */ l("span", {
110
111
  className: "filter-field__empty",
111
- children: a.pageNoMatches
112
+ children: r.pageNoMatches
112
113
  })
113
114
  ]
114
115
  })]
@@ -116,31 +117,31 @@ var N = ({ items: e, value: r, onSelect: n }) => /* @__PURE__ */ t("div", {
116
117
  }
117
118
  if (f === "radio") return /* @__PURE__ */ u("div", {
118
119
  className: "filter-field__rows",
119
- children: [/* @__PURE__ */ t(x, {
120
- label: a.pageAny,
120
+ children: [/* @__PURE__ */ l(x, {
121
+ label: r.pageAny,
121
122
  mark: "radio",
122
- selected: _.length === 0,
123
- onClick: () => l(null)
124
- }), e.options.map(v)]
123
+ selected: b.length === 0,
124
+ onClick: () => t(null)
125
+ }), e.options.map(N)]
125
126
  });
126
- const S = e.options.length > 7, $ = S && !s ? e.options.filter((i, m) => m < 6 || h(i)) : e.options;
127
+ const A = e.options.length > 7, j = A && !s ? e.options.filter((i, m) => m < 6 || h(i)) : e.options;
127
128
  return /* @__PURE__ */ u("div", {
128
129
  className: "filter-field__stack",
129
- children: [/* @__PURE__ */ t("div", {
130
+ children: [/* @__PURE__ */ l("div", {
130
131
  className: "filter-field__rows",
131
- children: $.map(v)
132
- }), S && /* @__PURE__ */ t("button", {
132
+ children: j.map(N)
133
+ }), A && /* @__PURE__ */ l("button", {
133
134
  type: "button",
134
135
  className: "filter-field__link",
135
136
  onClick: () => o(!s),
136
- children: s ? a.pageShowFewer : a.pageShowAll(e.options.length)
137
+ children: s ? r.pageShowFewer : r.pageShowAll(e.options.length)
137
138
  })]
138
139
  });
139
- }, G = ({ spec: e, value: r, onChange: n }) => {
140
- const [l, a] = E(r, e.min, e.max), [c, d] = w([l, a]);
141
- q(() => d([l, a]), [l, a]);
140
+ }, K = ({ spec: e, value: a, onChange: n }) => {
141
+ const [t, r] = q(a, e.min, e.max), [c, d] = y([t, r]);
142
+ Q(() => d([t, r]), [t, r]);
142
143
  const s = ([o, f]) => n(o <= e.min && f >= e.max ? null : [o, f]);
143
- return /* @__PURE__ */ t(W, {
144
+ return /* @__PURE__ */ l(W, {
144
145
  min: e.min,
145
146
  max: e.max,
146
147
  step: e.step,
@@ -150,145 +151,177 @@ var N = ({ items: e, value: r, onSelect: n }) => /* @__PURE__ */ t("div", {
150
151
  onChange: d,
151
152
  onChangeEnd: s
152
153
  });
153
- }, J = ({ spec: e, value: r, onChange: n }) => {
154
- const l = b(g), a = B(r);
154
+ }, U = ({ spec: e, value: a, onChange: n }) => {
155
+ const t = g(v), r = V(a);
155
156
  if (e.max <= 5) {
156
157
  const c = Array.from({ length: e.max - 1 }, (s, o) => o + 2), d = [{
157
158
  value: 0,
158
- label: l.pageAny
159
+ label: t.pageAny
159
160
  }, ...c.map((s) => ({
160
161
  value: s,
161
162
  label: s === e.max ? `${s}★` : `${s}★+`
162
163
  }))];
163
- return /* @__PURE__ */ t(N, {
164
+ return /* @__PURE__ */ l(D, {
164
165
  items: d,
165
- value: a,
166
+ value: r,
166
167
  onSelect: (s) => n(typeof s == "number" ? s : 0)
167
168
  });
168
169
  }
169
170
  return /* @__PURE__ */ u("div", {
170
171
  className: "filter-field__rating",
171
- children: [/* @__PURE__ */ t(C, {
172
- rating: a,
172
+ children: [/* @__PURE__ */ l(C, {
173
+ rating: r,
173
174
  maxRate: e.max,
174
175
  selectable: !0,
175
- onSelect: (c) => n(c === a ? 0 : c)
176
- }), a > 0 && /* @__PURE__ */ t("button", {
176
+ onSelect: (c) => n(c === r ? 0 : c)
177
+ }), r > 0 && /* @__PURE__ */ l("button", {
177
178
  type: "button",
178
179
  className: "filter-field__link",
179
180
  onClick: () => n(0),
180
- children: l.pageAny
181
+ children: t.pageAny
181
182
  })]
182
183
  });
183
- }, K = ({ spec: e, value: r, onChange: n }) => {
184
- const l = b(g), { text: a, mode: c } = V(r), d = Y(e, {
185
- anyWord: l.pageAnyWord,
186
- allWords: l.pageAllWords
184
+ }, X = ({ spec: e, value: a, onChange: n }) => {
185
+ const t = g(v), { text: r, mode: c } = P(a), d = I(e, {
186
+ anyWord: t.pageAnyWord,
187
+ allWords: t.pageAllWords
187
188
  }), s = c ?? d?.[0]?.value;
188
189
  return /* @__PURE__ */ u("div", {
189
190
  className: "filter-field__stack",
190
- children: [/* @__PURE__ */ t(F, {
191
- value: a,
191
+ children: [/* @__PURE__ */ l(F, {
192
+ value: r,
192
193
  placeholder: e.placeholder,
193
194
  onChange: (o) => n({
194
195
  text: o,
195
196
  mode: s
196
197
  })
197
- }), d && /* @__PURE__ */ t(N, {
198
+ }), d && /* @__PURE__ */ l(D, {
198
199
  items: d.map((o) => ({
199
200
  value: o.value,
200
201
  label: o.label
201
202
  })),
202
203
  value: s ?? null,
203
204
  onSelect: (o) => n({
204
- text: a,
205
+ text: r,
205
206
  mode: o === null ? void 0 : String(o)
206
207
  })
207
208
  })]
208
209
  });
209
- }, U = (e) => {
210
+ }, _ = (e) => {
210
211
  if (e === null) return;
211
- const [r, n, l] = String(e).split("-").map(Number);
212
- return r && n && l ? new Date(r, n - 1, l) : void 0;
213
- }, X = ({ value: e, onChange: r }) => {
214
- const n = b(g);
215
- return /* @__PURE__ */ t(z, {
216
- value: U(M(e)),
217
- placeholder: n.selectDate,
212
+ const [a, n, t] = String(e).split("-").map(Number);
213
+ return a && n && t ? new Date(a, n - 1, t) : void 0;
214
+ }, Z = ({ spec: e, value: a, onChange: n }) => {
215
+ const t = g(v);
216
+ return /* @__PURE__ */ l(R, {
217
+ value: _($(a)),
218
+ minDate: _(e.min ?? null),
219
+ maxDate: _(e.max ?? null),
220
+ placeholder: t.selectDate,
218
221
  clearable: !0,
219
- onChange: (l) => r(l instanceof Date ? L(l, "YYYY-MM-DD") : null)
222
+ onChange: (r) => n(r instanceof Date ? w(r, "YYYY-MM-DD") : null)
220
223
  });
221
- }, fe = ({ spec: e, value: r, context: n, onChange: l }) => {
222
- const a = `filter-field filter-field--${n}`;
224
+ }, H = ({ spec: e, value: a, onChange: n }) => {
225
+ const t = g(v), [r, c] = B(a), d = _(r || null), s = _(c || null);
226
+ return /* @__PURE__ */ l(R, {
227
+ mode: "range",
228
+ value: d && s ? {
229
+ start: d,
230
+ end: s
231
+ } : void 0,
232
+ minDate: _(e.min ?? null),
233
+ maxDate: _(e.max ?? null),
234
+ placeholder: t.selectDate,
235
+ clearable: !0,
236
+ onChange: (o) => n(o && !(o instanceof Date) && !Array.isArray(o) ? [w(o.start, "YYYY-MM-DD"), w(o.end, "YYYY-MM-DD")] : null)
237
+ });
238
+ }, he = ({ spec: e, value: a, context: n, onChange: t }) => {
239
+ const r = `filter-field filter-field--${n}`;
223
240
  switch (e.kind) {
224
241
  case "single":
225
242
  case "multi":
226
- return /* @__PURE__ */ t("div", {
227
- className: a,
228
- children: /* @__PURE__ */ t(Q, {
243
+ return /* @__PURE__ */ l("div", {
244
+ className: r,
245
+ children: /* @__PURE__ */ l(J, {
229
246
  spec: e,
230
- value: r,
247
+ value: a,
231
248
  context: n,
232
- onChange: l
249
+ onChange: t
233
250
  })
234
251
  });
235
252
  case "range":
236
- return /* @__PURE__ */ t("div", {
237
- className: a,
238
- children: /* @__PURE__ */ t(G, {
253
+ return /* @__PURE__ */ l("div", {
254
+ className: r,
255
+ children: /* @__PURE__ */ l(K, {
239
256
  spec: e,
240
- value: r,
241
- onChange: l
257
+ value: a,
258
+ onChange: t
242
259
  })
243
260
  });
244
261
  case "rating":
245
- return /* @__PURE__ */ t("div", {
246
- className: a,
247
- children: /* @__PURE__ */ t(J, {
262
+ return /* @__PURE__ */ l("div", {
263
+ className: r,
264
+ children: /* @__PURE__ */ l(U, {
248
265
  spec: e,
249
- value: r,
250
- onChange: l
266
+ value: a,
267
+ onChange: t
251
268
  })
252
269
  });
253
270
  case "toggle": {
254
- const c = r === !0;
271
+ const c = a === !0;
255
272
  return /* @__PURE__ */ u("div", {
256
- className: `${a} filter-field__switch-row`,
257
- children: [/* @__PURE__ */ t("button", {
258
- type: "button",
259
- className: "filter-field__switch-label",
260
- onClick: () => l(!c),
261
- children: e.label
262
- }), /* @__PURE__ */ t(T, {
263
- checked: c,
264
- size: "small",
265
- showLabels: !1,
266
- onChange: l
267
- })]
273
+ className: `${r} filter-field__switch-row`,
274
+ children: [
275
+ /* @__PURE__ */ l("button", {
276
+ type: "button",
277
+ className: "filter-field__switch-label",
278
+ onClick: () => t(!c),
279
+ children: e.label
280
+ }),
281
+ e.count !== void 0 && /* @__PURE__ */ l("span", {
282
+ className: "filter-field__count",
283
+ children: e.count
284
+ }),
285
+ /* @__PURE__ */ l(T, {
286
+ checked: c,
287
+ size: "small",
288
+ showLabels: !1,
289
+ onChange: t
290
+ })
291
+ ]
268
292
  });
269
293
  }
270
294
  case "text":
271
- return /* @__PURE__ */ t("div", {
272
- className: a,
273
- children: /* @__PURE__ */ t(K, {
295
+ return /* @__PURE__ */ l("div", {
296
+ className: r,
297
+ children: /* @__PURE__ */ l(X, {
274
298
  spec: e,
275
- value: r,
276
- onChange: l
299
+ value: a,
300
+ onChange: t
277
301
  })
278
302
  });
279
303
  case "date":
280
- return /* @__PURE__ */ t("div", {
281
- className: a,
282
- children: /* @__PURE__ */ t(X, {
304
+ return /* @__PURE__ */ l("div", {
305
+ className: r,
306
+ children: /* @__PURE__ */ l(Z, {
307
+ spec: e,
308
+ value: a,
309
+ onChange: t
310
+ })
311
+ });
312
+ case "date-range":
313
+ return /* @__PURE__ */ l("div", {
314
+ className: r,
315
+ children: /* @__PURE__ */ l(H, {
283
316
  spec: e,
284
- value: r,
285
- onChange: l
317
+ value: a,
318
+ onChange: t
286
319
  })
287
320
  });
288
321
  }
289
322
  };
290
323
  export {
291
- fe as FilterField,
324
+ he as FilterField,
292
325
  x as OptionRow,
293
- N as Segmented
326
+ D as Segmented
294
327
  };