@selectwin/kit 0.1.235 → 0.1.237
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.
- package/dist/SelectFilterBar.js +62 -54
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/SelectFilterBar.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CheckIcon as e, ChevronDownIcon as t, CloseIcon as n,
|
|
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:
|
|
32
|
-
let
|
|
33
|
-
c(
|
|
34
|
-
|
|
35
|
-
}, [
|
|
36
|
-
let
|
|
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:
|
|
39
|
-
onClose:
|
|
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${
|
|
44
|
-
onClick:
|
|
45
|
-
disabled:
|
|
46
|
-
"aria-expanded":
|
|
47
|
-
"aria-invalid":
|
|
48
|
-
title:
|
|
49
|
-
children: [
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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:
|
|
69
|
+
ref: O,
|
|
62
70
|
onKeyDown: s,
|
|
63
|
-
children: [
|
|
71
|
+
children: [N && /* @__PURE__ */ _("div", {
|
|
64
72
|
className: "select-facet__search",
|
|
65
73
|
children: /* @__PURE__ */ _(u, {
|
|
66
|
-
value:
|
|
67
|
-
onChange:
|
|
68
|
-
placeholder:
|
|
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:
|
|
82
|
+
children: P.length === 0 ? /* @__PURE__ */ _("div", {
|
|
75
83
|
className: "select-facet__empty",
|
|
76
|
-
children:
|
|
77
|
-
}) :
|
|
78
|
-
let n = y(
|
|
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":
|
|
90
|
+
"aria-selected": r,
|
|
83
91
|
className: "select-facet__opt",
|
|
84
|
-
onClick: () =>
|
|
85
|
-
children: [/* @__PURE__ */ _("span", { children: t.label }),
|
|
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:
|
|
103
|
+
ref: O,
|
|
96
104
|
onKeyDown: s,
|
|
97
|
-
children: [
|
|
105
|
+
children: [N && /* @__PURE__ */ _("div", {
|
|
98
106
|
className: "select-facet__search",
|
|
99
107
|
children: /* @__PURE__ */ _(u, {
|
|
100
|
-
value:
|
|
101
|
-
onChange:
|
|
102
|
-
placeholder:
|
|
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:
|
|
115
|
+
children: P.length === 0 ? /* @__PURE__ */ _("div", {
|
|
108
116
|
className: "select-facet__empty",
|
|
109
|
-
children:
|
|
110
|
-
}) :
|
|
111
|
-
let n =
|
|
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
|
-
|
|
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:
|
|
132
|
-
onChange:
|
|
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(),
|
|
147
|
+
e.key === "Enter" && (e.preventDefault(), C());
|
|
140
148
|
},
|
|
141
149
|
children: /* @__PURE__ */ _(o, {
|
|
142
150
|
type: "text",
|
|
143
|
-
value:
|
|
144
|
-
onChange:
|
|
151
|
+
value: i,
|
|
152
|
+
onChange: f,
|
|
145
153
|
placeholder: n.placeholder,
|
|
146
154
|
autoFocus: !0
|
|
147
155
|
})
|
|
148
156
|
}),
|
|
149
|
-
|
|
157
|
+
j && /* @__PURE__ */ _("div", {
|
|
150
158
|
className: "select-facet__error",
|
|
151
159
|
role: "alert",
|
|
152
160
|
children: n.error
|
|
153
161
|
}),
|
|
154
|
-
|
|
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
|
-
|
|
168
|
+
f(""), C();
|
|
161
169
|
},
|
|
162
|
-
children:
|
|
170
|
+
children: T.filterBar.clear
|
|
163
171
|
})
|
|
164
172
|
})
|
|
165
173
|
]
|