@selectwin/kit 0.1.236 → 0.1.238

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,4 +1,4 @@
1
- import { CheckIcon as e, ChevronDownIcon as t, CloseIcon as n, PlusIcon as r, SearchIcon as i } from "./icons.js";
1
+ import { CheckIcon as e, ChevronDownIcon as t, CloseIcon as n, FilterIcon as r, SearchIcon as i } from "./icons.js";
2
2
  import { useSelectMessages as a } from "./SelectLocale.js";
3
3
  import { SelectField as o } from "./SelectField.js";
4
4
  import { moveInOptions as s, useOptionListFocus as c } from "./internal/optionList.js";
@@ -28,61 +28,69 @@ function x(e, t) {
28
28
  }
29
29
  return e.type === "date" ? f(t) ?? t : t;
30
30
  }
31
- function S({ filter: n, value: r, onChange: i, open: f, onToggle: p, onClose: S, disabled: C }) {
32
- let w = a(), [T, E] = g(""), D = h(null);
33
- c(f && (n.type === "select" || n.type === "multiselect"), D), m(() => {
34
- f || E("");
35
- }, [f]);
36
- let O = r.trim() !== "", k = O ? x(n, r) : null, A = O && !!n.error, j = n.options ?? [], M = j.length > 7, N = M ? j.filter((e) => e.label.toLowerCase().includes(T.trim().toLowerCase())) : j;
31
+ function S({ filter: n, value: i, onChange: f, open: p, onToggle: S, onClose: C, disabled: w }) {
32
+ let T = a(), [E, D] = g(""), O = h(null);
33
+ c(p && (n.type === "select" || n.type === "multiselect"), O), m(() => {
34
+ p || D("");
35
+ }, [p]);
36
+ let k = i.trim() !== "", A = k ? x(n, i) : null, j = k && !!n.error, M = n.options ?? [], N = M.length > 7, P = N ? M.filter((e) => e.label.toLowerCase().includes(E.trim().toLowerCase())) : M;
37
37
  return /* @__PURE__ */ v(l, {
38
- active: f,
39
- onClose: S,
38
+ active: p,
39
+ onClose: C,
40
40
  placement: "bottom-start",
41
41
  activator: /* @__PURE__ */ v("button", {
42
42
  type: "button",
43
- className: `select-facet${O ? " is-active" : ""}${A ? " is-error" : ""}`,
44
- onClick: p,
45
- disabled: C,
46
- "aria-expanded": f,
47
- "aria-invalid": A || void 0,
48
- title: A ? n.error : void 0,
49
- children: [/* @__PURE__ */ _("span", {
50
- className: "select-facet__label",
51
- children: k == null ? n.label : `${n.label}: ${k}`
52
- }), /* @__PURE__ */ _("span", {
53
- className: `select-facet__caret${f ? " is-open" : ""}`,
54
- "aria-hidden": "true",
55
- children: /* @__PURE__ */ _(t, {})
56
- })]
43
+ className: `select-facet${k ? " is-active" : ""}${j ? " is-error" : ""}`,
44
+ onClick: S,
45
+ disabled: w,
46
+ "aria-expanded": p,
47
+ "aria-invalid": j || void 0,
48
+ title: j ? n.error : void 0,
49
+ children: [
50
+ /* @__PURE__ */ _("span", {
51
+ className: "select-facet__addicon",
52
+ "aria-hidden": "true",
53
+ children: /* @__PURE__ */ _(r, {})
54
+ }),
55
+ /* @__PURE__ */ _("span", {
56
+ className: "select-facet__label",
57
+ children: A == null ? n.label : `${n.label}: ${A}`
58
+ }),
59
+ /* @__PURE__ */ _("span", {
60
+ className: `select-facet__caret${p ? " is-open" : ""}`,
61
+ "aria-hidden": "true",
62
+ children: /* @__PURE__ */ _(t, {})
63
+ })
64
+ ]
57
65
  }),
58
66
  children: [
59
67
  n.type === "multiselect" ? /* @__PURE__ */ v("div", {
60
68
  className: "select-facet__panel",
61
- ref: D,
69
+ ref: O,
62
70
  onKeyDown: s,
63
- children: [M && /* @__PURE__ */ _("div", {
71
+ children: [N && /* @__PURE__ */ _("div", {
64
72
  className: "select-facet__search",
65
73
  children: /* @__PURE__ */ _(u, {
66
- value: T,
67
- onChange: E,
68
- placeholder: w.filterBar.searchOption
74
+ value: E,
75
+ onChange: D,
76
+ placeholder: T.filterBar.searchOption
69
77
  })
70
78
  }), /* @__PURE__ */ _("div", {
71
79
  className: "select-facet__options",
72
80
  role: "listbox",
73
81
  "aria-multiselectable": "true",
74
- children: N.length === 0 ? /* @__PURE__ */ _("div", {
82
+ children: P.length === 0 ? /* @__PURE__ */ _("div", {
75
83
  className: "select-facet__empty",
76
- children: w.common.nothingFound
77
- }) : N.map((t) => {
78
- let n = y(r), a = n.includes(t.value);
84
+ children: T.common.nothingFound
85
+ }) : P.map((t) => {
86
+ let n = y(i), r = n.includes(t.value);
79
87
  return /* @__PURE__ */ v("button", {
80
88
  type: "button",
81
89
  role: "option",
82
- "aria-selected": a,
90
+ "aria-selected": r,
83
91
  className: "select-facet__opt",
84
- onClick: () => i(b(a ? n.filter((e) => e !== t.value) : [...n, t.value], j)),
85
- children: [/* @__PURE__ */ _("span", { children: t.label }), a && /* @__PURE__ */ _("span", {
92
+ onClick: () => f(b(r ? n.filter((e) => e !== t.value) : [...n, t.value], M)),
93
+ children: [/* @__PURE__ */ _("span", { children: t.label }), r && /* @__PURE__ */ _("span", {
86
94
  className: "select-facet__check",
87
95
  "aria-hidden": "true",
88
96
  children: /* @__PURE__ */ _(e, {})
@@ -92,30 +100,30 @@ function S({ filter: n, value: r, onChange: i, open: f, onToggle: p, onClose: S,
92
100
  })]
93
101
  }) : n.type === "select" ? /* @__PURE__ */ v("div", {
94
102
  className: "select-facet__panel",
95
- ref: D,
103
+ ref: O,
96
104
  onKeyDown: s,
97
- children: [M && /* @__PURE__ */ _("div", {
105
+ children: [N && /* @__PURE__ */ _("div", {
98
106
  className: "select-facet__search",
99
107
  children: /* @__PURE__ */ _(u, {
100
- value: T,
101
- onChange: E,
102
- placeholder: w.filterBar.searchOption
108
+ value: E,
109
+ onChange: D,
110
+ placeholder: T.filterBar.searchOption
103
111
  })
104
112
  }), /* @__PURE__ */ _("div", {
105
113
  className: "select-facet__options",
106
114
  role: "listbox",
107
- children: N.length === 0 ? /* @__PURE__ */ _("div", {
115
+ children: P.length === 0 ? /* @__PURE__ */ _("div", {
108
116
  className: "select-facet__empty",
109
- children: w.common.nothingFound
110
- }) : N.map((t) => {
111
- let n = r === t.value;
117
+ children: T.common.nothingFound
118
+ }) : P.map((t) => {
119
+ let n = i === t.value;
112
120
  return /* @__PURE__ */ v("button", {
113
121
  type: "button",
114
122
  role: "option",
115
123
  "aria-selected": n,
116
124
  className: `select-facet__opt${n ? " is-selected" : ""}`,
117
125
  onClick: () => {
118
- i(n ? "" : t.value), S();
126
+ f(n ? "" : t.value), C();
119
127
  },
120
128
  children: [/* @__PURE__ */ _("span", { children: t.label }), n && /* @__PURE__ */ _("span", {
121
129
  className: "select-facet__check",
@@ -128,38 +136,38 @@ function S({ filter: n, value: r, onChange: i, open: f, onToggle: p, onClose: S,
128
136
  }) : n.type === "date" ? /* @__PURE__ */ _("div", {
129
137
  className: "select-facet__field",
130
138
  children: /* @__PURE__ */ _(d, {
131
- value: r,
132
- onChange: i,
139
+ value: i,
140
+ onChange: f,
133
141
  placeholder: n.placeholder,
134
142
  clearable: !1
135
143
  })
136
144
  }) : /* @__PURE__ */ _("div", {
137
145
  className: "select-facet__field",
138
146
  onKeyDown: (e) => {
139
- e.key === "Enter" && (e.preventDefault(), S());
147
+ e.key === "Enter" && (e.preventDefault(), C());
140
148
  },
141
149
  children: /* @__PURE__ */ _(o, {
142
150
  type: "text",
143
- value: r,
144
- onChange: i,
151
+ value: i,
152
+ onChange: f,
145
153
  placeholder: n.placeholder,
146
154
  autoFocus: !0
147
155
  })
148
156
  }),
149
- A && /* @__PURE__ */ _("div", {
157
+ j && /* @__PURE__ */ _("div", {
150
158
  className: "select-facet__error",
151
159
  role: "alert",
152
160
  children: n.error
153
161
  }),
154
- O && /* @__PURE__ */ _("div", {
162
+ k && /* @__PURE__ */ _("div", {
155
163
  className: "select-facet__foot",
156
164
  children: /* @__PURE__ */ _("button", {
157
165
  type: "button",
158
166
  className: "select-facet__clear",
159
167
  onClick: () => {
160
- i(""), S();
168
+ f(""), C();
161
169
  },
162
- children: w.filterBar.clear
170
+ children: T.filterBar.clear
163
171
  })
164
172
  })
165
173
  ]