@selectwin/kit 0.1.213 → 0.1.215
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 +141 -132
- package/dist/SelectTooltip.d.ts +3 -1
- package/dist/SelectTooltip.js +38 -37
- package/dist/internal/listChrome.js +54 -49
- package/dist/internal/optionList.d.ts +3 -0
- package/dist/internal/optionList.js +29 -0
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/SelectFilterBar.js
CHANGED
|
@@ -3,137 +3,142 @@ import { useSelectMessages as a } from "./SelectLocale.js";
|
|
|
3
3
|
import { SelectField as o } from "./SelectField.js";
|
|
4
4
|
import { SelectPopover as s } from "./SelectPopover.js";
|
|
5
5
|
import { SelectSearchInput as c } from "./SelectSearchInput.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
6
|
+
import { moveInOptions as l, useOptionListFocus as u } from "./internal/optionList.js";
|
|
7
|
+
import { SelectDateField as d } from "./SelectDateField.js";
|
|
8
|
+
import { formatDateValue as f } from "./internal/dateValue.js";
|
|
9
|
+
import { forwardRef as p, useEffect as m, useRef as h, useState as g } from "react";
|
|
10
|
+
import { jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
10
11
|
//#region src/SelectFilterBar.tsx
|
|
11
|
-
function
|
|
12
|
+
function y(e) {
|
|
12
13
|
return (e ?? "").split(",").map((e) => e.trim()).filter(Boolean);
|
|
13
14
|
}
|
|
14
|
-
function
|
|
15
|
+
function b(e, t) {
|
|
15
16
|
let n = new Set(e);
|
|
16
17
|
return (t ? t.map((e) => e.value).filter((e) => n.has(e)) : [...n]).join(",");
|
|
17
18
|
}
|
|
18
|
-
function
|
|
19
|
+
function x(e, t) {
|
|
19
20
|
var n;
|
|
20
21
|
if (e.type === "select") return ((n = e.options) == null || (n = n.find((e) => e.value === t)) == null ? void 0 : n.label) ?? t;
|
|
21
22
|
if (e.type === "multiselect") {
|
|
22
|
-
let n =
|
|
23
|
+
let n = y(t).map((t) => {
|
|
23
24
|
var n;
|
|
24
25
|
return ((n = e.options) == null || (n = n.find((e) => e.value === t)) == null ? void 0 : n.label) ?? t;
|
|
25
26
|
});
|
|
26
27
|
return n.length > 2 ? `${n[0]} +${n.length - 1}` : n.join(", ");
|
|
27
28
|
}
|
|
28
|
-
return e.type === "date" ?
|
|
29
|
+
return e.type === "date" ? f(t) ?? t : t;
|
|
29
30
|
}
|
|
30
|
-
function
|
|
31
|
-
let
|
|
32
|
-
f(() => {
|
|
33
|
-
|
|
34
|
-
}, [
|
|
35
|
-
let
|
|
36
|
-
return /* @__PURE__ */
|
|
37
|
-
active:
|
|
38
|
-
onClose:
|
|
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
|
+
u(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;
|
|
37
|
+
return /* @__PURE__ */ v(s, {
|
|
38
|
+
active: f,
|
|
39
|
+
onClose: S,
|
|
39
40
|
placement: "bottom-start",
|
|
40
|
-
activator: /* @__PURE__ */
|
|
41
|
+
activator: /* @__PURE__ */ v("button", {
|
|
41
42
|
type: "button",
|
|
42
|
-
className: `select-facet${
|
|
43
|
-
onClick:
|
|
44
|
-
disabled:
|
|
45
|
-
"aria-expanded":
|
|
46
|
-
"aria-invalid":
|
|
47
|
-
title:
|
|
48
|
-
children: [/* @__PURE__ */
|
|
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", {
|
|
49
50
|
className: "select-facet__label",
|
|
50
|
-
children:
|
|
51
|
-
}), /* @__PURE__ */
|
|
52
|
-
className: `select-facet__caret${
|
|
51
|
+
children: k == null ? n.label : `${n.label}: ${k}`
|
|
52
|
+
}), /* @__PURE__ */ _("span", {
|
|
53
|
+
className: `select-facet__caret${f ? " is-open" : ""}`,
|
|
53
54
|
"aria-hidden": "true",
|
|
54
|
-
children: /* @__PURE__ */
|
|
55
|
+
children: /* @__PURE__ */ _(t, {})
|
|
55
56
|
})]
|
|
56
57
|
}),
|
|
57
58
|
children: [
|
|
58
|
-
n.type === "multiselect" ? /* @__PURE__ */
|
|
59
|
+
n.type === "multiselect" ? /* @__PURE__ */ v("div", {
|
|
59
60
|
className: "select-facet__panel",
|
|
60
|
-
|
|
61
|
+
ref: D,
|
|
62
|
+
onKeyDown: l,
|
|
63
|
+
children: [M && /* @__PURE__ */ _("div", {
|
|
61
64
|
className: "select-facet__search",
|
|
62
|
-
children: /* @__PURE__ */
|
|
63
|
-
value:
|
|
64
|
-
onChange:
|
|
65
|
-
placeholder:
|
|
65
|
+
children: /* @__PURE__ */ _(c, {
|
|
66
|
+
value: T,
|
|
67
|
+
onChange: E,
|
|
68
|
+
placeholder: w.filterBar.searchOption
|
|
66
69
|
})
|
|
67
|
-
}), /* @__PURE__ */
|
|
70
|
+
}), /* @__PURE__ */ _("div", {
|
|
68
71
|
className: "select-facet__options",
|
|
69
72
|
role: "listbox",
|
|
70
73
|
"aria-multiselectable": "true",
|
|
71
|
-
children:
|
|
74
|
+
children: N.length === 0 ? /* @__PURE__ */ _("div", {
|
|
72
75
|
className: "select-facet__empty",
|
|
73
|
-
children:
|
|
74
|
-
}) :
|
|
75
|
-
let n =
|
|
76
|
-
return /* @__PURE__ */
|
|
76
|
+
children: w.common.nothingFound
|
|
77
|
+
}) : N.map((t) => {
|
|
78
|
+
let n = y(r), a = n.includes(t.value);
|
|
79
|
+
return /* @__PURE__ */ v("button", {
|
|
77
80
|
type: "button",
|
|
78
81
|
role: "option",
|
|
79
82
|
"aria-selected": a,
|
|
80
83
|
className: "select-facet__opt",
|
|
81
|
-
onClick: () => i(
|
|
82
|
-
children: [/* @__PURE__ */
|
|
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", {
|
|
83
86
|
className: "select-facet__check",
|
|
84
87
|
"aria-hidden": "true",
|
|
85
|
-
children: /* @__PURE__ */
|
|
88
|
+
children: /* @__PURE__ */ _(e, {})
|
|
86
89
|
})]
|
|
87
90
|
}, t.value);
|
|
88
91
|
})
|
|
89
92
|
})]
|
|
90
|
-
}) : n.type === "select" ? /* @__PURE__ */
|
|
93
|
+
}) : n.type === "select" ? /* @__PURE__ */ v("div", {
|
|
91
94
|
className: "select-facet__panel",
|
|
92
|
-
|
|
95
|
+
ref: D,
|
|
96
|
+
onKeyDown: l,
|
|
97
|
+
children: [M && /* @__PURE__ */ _("div", {
|
|
93
98
|
className: "select-facet__search",
|
|
94
|
-
children: /* @__PURE__ */
|
|
95
|
-
value:
|
|
96
|
-
onChange:
|
|
97
|
-
placeholder:
|
|
99
|
+
children: /* @__PURE__ */ _(c, {
|
|
100
|
+
value: T,
|
|
101
|
+
onChange: E,
|
|
102
|
+
placeholder: w.filterBar.searchOption
|
|
98
103
|
})
|
|
99
|
-
}), /* @__PURE__ */
|
|
104
|
+
}), /* @__PURE__ */ _("div", {
|
|
100
105
|
className: "select-facet__options",
|
|
101
106
|
role: "listbox",
|
|
102
|
-
children:
|
|
107
|
+
children: N.length === 0 ? /* @__PURE__ */ _("div", {
|
|
103
108
|
className: "select-facet__empty",
|
|
104
|
-
children:
|
|
105
|
-
}) :
|
|
109
|
+
children: w.common.nothingFound
|
|
110
|
+
}) : N.map((t) => {
|
|
106
111
|
let n = r === t.value;
|
|
107
|
-
return /* @__PURE__ */
|
|
112
|
+
return /* @__PURE__ */ v("button", {
|
|
108
113
|
type: "button",
|
|
109
114
|
role: "option",
|
|
110
115
|
"aria-selected": n,
|
|
111
116
|
className: `select-facet__opt${n ? " is-selected" : ""}`,
|
|
112
117
|
onClick: () => {
|
|
113
|
-
i(n ? "" : t.value),
|
|
118
|
+
i(n ? "" : t.value), S();
|
|
114
119
|
},
|
|
115
|
-
children: [/* @__PURE__ */
|
|
120
|
+
children: [/* @__PURE__ */ _("span", { children: t.label }), n && /* @__PURE__ */ _("span", {
|
|
116
121
|
className: "select-facet__check",
|
|
117
122
|
"aria-hidden": "true",
|
|
118
|
-
children: /* @__PURE__ */
|
|
123
|
+
children: /* @__PURE__ */ _(e, {})
|
|
119
124
|
})]
|
|
120
125
|
}, t.value);
|
|
121
126
|
})
|
|
122
127
|
})]
|
|
123
|
-
}) : n.type === "date" ? /* @__PURE__ */
|
|
128
|
+
}) : n.type === "date" ? /* @__PURE__ */ _("div", {
|
|
124
129
|
className: "select-facet__field",
|
|
125
|
-
children: /* @__PURE__ */
|
|
130
|
+
children: /* @__PURE__ */ _(d, {
|
|
126
131
|
value: r,
|
|
127
132
|
onChange: i,
|
|
128
133
|
placeholder: n.placeholder,
|
|
129
134
|
clearable: !1
|
|
130
135
|
})
|
|
131
|
-
}) : /* @__PURE__ */
|
|
136
|
+
}) : /* @__PURE__ */ _("div", {
|
|
132
137
|
className: "select-facet__field",
|
|
133
138
|
onKeyDown: (e) => {
|
|
134
|
-
e.key === "Enter" && (e.preventDefault(),
|
|
139
|
+
e.key === "Enter" && (e.preventDefault(), S());
|
|
135
140
|
},
|
|
136
|
-
children: /* @__PURE__ */
|
|
141
|
+
children: /* @__PURE__ */ _(o, {
|
|
137
142
|
type: "text",
|
|
138
143
|
value: r,
|
|
139
144
|
onChange: i,
|
|
@@ -141,152 +146,156 @@ function y({ filter: n, value: r, onChange: i, open: u, onToggle: d, onClose: y,
|
|
|
141
146
|
autoFocus: !0
|
|
142
147
|
})
|
|
143
148
|
}),
|
|
144
|
-
|
|
149
|
+
A && /* @__PURE__ */ _("div", {
|
|
145
150
|
className: "select-facet__error",
|
|
146
151
|
role: "alert",
|
|
147
152
|
children: n.error
|
|
148
153
|
}),
|
|
149
|
-
|
|
154
|
+
O && /* @__PURE__ */ _("div", {
|
|
150
155
|
className: "select-facet__foot",
|
|
151
|
-
children: /* @__PURE__ */
|
|
156
|
+
children: /* @__PURE__ */ _("button", {
|
|
152
157
|
type: "button",
|
|
153
158
|
className: "select-facet__clear",
|
|
154
159
|
onClick: () => {
|
|
155
|
-
i(""),
|
|
160
|
+
i(""), S();
|
|
156
161
|
},
|
|
157
|
-
children:
|
|
162
|
+
children: w.filterBar.clear
|
|
158
163
|
})
|
|
159
164
|
})
|
|
160
165
|
]
|
|
161
166
|
});
|
|
162
167
|
}
|
|
163
|
-
var
|
|
164
|
-
let
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
+
var C = p(function({ filters: e, values: t, onChange: o, onClearAll: c, search: d, leading: f, disabled: p, className: m, ...y }, b) {
|
|
169
|
+
let C = a(), [w, T] = g([]), [E, D] = g(null), [O, k] = g(!1), A = h(null);
|
|
170
|
+
u(O, A);
|
|
171
|
+
let j = (e) => (t[e.key] ?? "").trim() !== "", M = (e) => !!e.pinned || j(e) || w.includes(e.key), N = e.filter(M), P = e.filter((e) => !M(e)), F = e.filter(j), I = () => {
|
|
172
|
+
T([]), D(null), c();
|
|
173
|
+
}, L = (e) => {
|
|
174
|
+
T((t) => t.includes(e) ? t : [...t, e]), k(!1), D(e);
|
|
168
175
|
};
|
|
169
|
-
return /* @__PURE__ */
|
|
170
|
-
ref:
|
|
171
|
-
...
|
|
172
|
-
className: `select-filterbar${
|
|
176
|
+
return /* @__PURE__ */ v("div", {
|
|
177
|
+
ref: b,
|
|
178
|
+
...y,
|
|
179
|
+
className: `select-filterbar${m ? " " + m : ""}`,
|
|
173
180
|
children: [
|
|
174
|
-
/* @__PURE__ */
|
|
181
|
+
/* @__PURE__ */ v("div", {
|
|
175
182
|
className: "select-filterbar__row",
|
|
176
183
|
children: [
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
className: `select-filterbar__query${
|
|
184
|
+
f,
|
|
185
|
+
d && /* @__PURE__ */ v("div", {
|
|
186
|
+
className: `select-filterbar__query${d.error ? " select-filterbar__query--error" : ""}`,
|
|
180
187
|
children: [
|
|
181
|
-
/* @__PURE__ */
|
|
188
|
+
/* @__PURE__ */ _("span", {
|
|
182
189
|
className: "select-filterbar__query-icon",
|
|
183
190
|
"aria-hidden": "true",
|
|
184
|
-
children: /* @__PURE__ */
|
|
191
|
+
children: /* @__PURE__ */ _(i, {})
|
|
185
192
|
}),
|
|
186
|
-
/* @__PURE__ */
|
|
193
|
+
/* @__PURE__ */ _("input", {
|
|
187
194
|
className: "select-filterbar__query-input",
|
|
188
195
|
type: "search",
|
|
189
|
-
value:
|
|
190
|
-
placeholder:
|
|
191
|
-
onChange: (e) =>
|
|
192
|
-
onKeyDown:
|
|
196
|
+
value: d.value,
|
|
197
|
+
placeholder: d.placeholder ?? C.common.searchPlaceholder,
|
|
198
|
+
onChange: (e) => d.onChange(e.target.value),
|
|
199
|
+
onKeyDown: d.onSubmit ? (e) => {
|
|
193
200
|
if (e.key === "Enter") {
|
|
194
201
|
var t;
|
|
195
|
-
e.preventDefault(), (t =
|
|
202
|
+
e.preventDefault(), (t = d.onSubmit) == null || t.call(d);
|
|
196
203
|
}
|
|
197
204
|
} : void 0,
|
|
198
|
-
"aria-label":
|
|
199
|
-
"aria-invalid":
|
|
200
|
-
disabled:
|
|
205
|
+
"aria-label": d.ariaLabel ?? d.placeholder ?? C.common.search,
|
|
206
|
+
"aria-invalid": d.error ? !0 : void 0,
|
|
207
|
+
disabled: p
|
|
201
208
|
}),
|
|
202
|
-
|
|
209
|
+
d.value && /* @__PURE__ */ _("button", {
|
|
203
210
|
type: "button",
|
|
204
211
|
className: "select-filterbar__query-clear",
|
|
205
|
-
"aria-label":
|
|
206
|
-
onClick: () =>
|
|
207
|
-
children: /* @__PURE__ */
|
|
212
|
+
"aria-label": C.filterBar.clearSearch,
|
|
213
|
+
onClick: () => d.onChange(""),
|
|
214
|
+
children: /* @__PURE__ */ _(n, {})
|
|
208
215
|
}),
|
|
209
|
-
|
|
216
|
+
d.onSubmit && /* @__PURE__ */ _("button", {
|
|
210
217
|
type: "button",
|
|
211
218
|
className: "select-filterbar__query-submit",
|
|
212
|
-
onClick:
|
|
213
|
-
disabled:
|
|
214
|
-
children:
|
|
219
|
+
onClick: d.onSubmit,
|
|
220
|
+
disabled: p,
|
|
221
|
+
children: d.submitLabel ?? C.common.search
|
|
215
222
|
})
|
|
216
223
|
]
|
|
217
224
|
}),
|
|
218
|
-
|
|
225
|
+
N.map((e) => /* @__PURE__ */ _(S, {
|
|
219
226
|
filter: e,
|
|
220
227
|
value: t[e.key] ?? "",
|
|
221
228
|
onChange: (t) => o(e.key, t),
|
|
222
|
-
open:
|
|
223
|
-
onToggle: () =>
|
|
224
|
-
onClose: () =>
|
|
225
|
-
disabled:
|
|
229
|
+
open: E === e.key,
|
|
230
|
+
onToggle: () => D((t) => t === e.key ? null : e.key),
|
|
231
|
+
onClose: () => D((t) => t === e.key ? null : t),
|
|
232
|
+
disabled: p
|
|
226
233
|
}, e.key)),
|
|
227
|
-
|
|
228
|
-
active:
|
|
229
|
-
onClose: () =>
|
|
234
|
+
P.length > 0 && /* @__PURE__ */ _(s, {
|
|
235
|
+
active: O,
|
|
236
|
+
onClose: () => k(!1),
|
|
230
237
|
placement: "bottom-start",
|
|
231
|
-
activator: /* @__PURE__ */
|
|
238
|
+
activator: /* @__PURE__ */ v("button", {
|
|
232
239
|
type: "button",
|
|
233
240
|
className: "select-facet select-facet--more",
|
|
234
|
-
onClick: () =>
|
|
235
|
-
disabled:
|
|
236
|
-
"aria-expanded":
|
|
237
|
-
children: [/* @__PURE__ */
|
|
241
|
+
onClick: () => k((e) => !e),
|
|
242
|
+
disabled: p,
|
|
243
|
+
"aria-expanded": O,
|
|
244
|
+
children: [/* @__PURE__ */ _("span", {
|
|
238
245
|
className: "select-facet__addicon",
|
|
239
246
|
"aria-hidden": "true",
|
|
240
|
-
children: /* @__PURE__ */
|
|
241
|
-
}),
|
|
247
|
+
children: /* @__PURE__ */ _(r, {})
|
|
248
|
+
}), C.filterBar.moreFilters]
|
|
242
249
|
}),
|
|
243
|
-
children: /* @__PURE__ */
|
|
250
|
+
children: /* @__PURE__ */ _("div", {
|
|
244
251
|
className: "select-facet__options",
|
|
245
252
|
role: "menu",
|
|
246
|
-
|
|
253
|
+
ref: A,
|
|
254
|
+
onKeyDown: l,
|
|
255
|
+
children: P.map((e) => /* @__PURE__ */ _("button", {
|
|
247
256
|
type: "button",
|
|
248
257
|
role: "menuitem",
|
|
249
258
|
className: "select-facet__opt",
|
|
250
|
-
onClick: () =>
|
|
251
|
-
children: /* @__PURE__ */
|
|
259
|
+
onClick: () => L(e.key),
|
|
260
|
+
children: /* @__PURE__ */ _("span", { children: e.label })
|
|
252
261
|
}, e.key))
|
|
253
262
|
})
|
|
254
263
|
})
|
|
255
264
|
]
|
|
256
265
|
}),
|
|
257
|
-
|
|
266
|
+
d != null && d.error ? /* @__PURE__ */ _("p", {
|
|
258
267
|
className: "select-filterbar__query-error",
|
|
259
268
|
role: "alert",
|
|
260
|
-
children:
|
|
269
|
+
children: d.error
|
|
261
270
|
}) : null,
|
|
262
|
-
|
|
271
|
+
F.length > 0 && /* @__PURE__ */ v("div", {
|
|
263
272
|
className: "select-filterbar__applied",
|
|
264
|
-
children: [
|
|
273
|
+
children: [F.map((e) => /* @__PURE__ */ v("span", {
|
|
265
274
|
className: `select-filterbar__tag${e.error ? " is-error" : ""}`,
|
|
266
275
|
title: e.error || void 0,
|
|
267
276
|
children: [
|
|
268
277
|
e.label,
|
|
269
278
|
": ",
|
|
270
|
-
|
|
271
|
-
/* @__PURE__ */
|
|
279
|
+
x(e, t[e.key] ?? ""),
|
|
280
|
+
/* @__PURE__ */ _("button", {
|
|
272
281
|
type: "button",
|
|
273
282
|
className: "select-filterbar__tagx",
|
|
274
|
-
"aria-label":
|
|
283
|
+
"aria-label": C.filterBar.removeFilter(e.label),
|
|
275
284
|
onClick: () => o(e.key, ""),
|
|
276
|
-
children: /* @__PURE__ */
|
|
285
|
+
children: /* @__PURE__ */ _(n, {})
|
|
277
286
|
})
|
|
278
287
|
]
|
|
279
|
-
}, e.key)), /* @__PURE__ */
|
|
288
|
+
}, e.key)), /* @__PURE__ */ _("button", {
|
|
280
289
|
type: "button",
|
|
281
290
|
className: "select-filterbar__clear",
|
|
282
|
-
onClick:
|
|
283
|
-
children:
|
|
291
|
+
onClick: I,
|
|
292
|
+
children: C.filterBar.clearAll
|
|
284
293
|
})]
|
|
285
294
|
})
|
|
286
295
|
]
|
|
287
296
|
});
|
|
288
297
|
});
|
|
289
298
|
//#endregion
|
|
290
|
-
export {
|
|
299
|
+
export { C as SelectFilterBar, b as joinFilterValues, y as splitFilterValues };
|
|
291
300
|
|
|
292
301
|
//# sourceMappingURL=SelectFilterBar.js.map
|
package/dist/SelectTooltip.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { SelectPlacement } from './positioning';
|
|
3
|
-
export declare function SelectTooltip({ content, children, placement, delay, openOnClick, disabled, }: {
|
|
3
|
+
export declare function SelectTooltip({ content, children, placement, delay, openOnClick, disabled, focusable, }: {
|
|
4
4
|
content: ReactNode;
|
|
5
5
|
children: ReactNode;
|
|
6
6
|
placement?: SelectPlacement;
|
|
@@ -12,4 +12,6 @@ export declare function SelectTooltip({ content, children, placement, delay, ope
|
|
|
12
12
|
/** Não abre (0.1.188): o gatilho já mostra o mesmo conteúdo noutro lugar (ex.: o painel de páginas do trilho aberto
|
|
13
13
|
* ao lado do ícone). O embrulho continua no lugar, então o gatilho não remonta nem perde o foco. */
|
|
14
14
|
disabled?: boolean;
|
|
15
|
+
/** 0.1.215: o embrulho recebe o foco (o filho não é focável): o Tab chega na dica, e ela abre no foco do teclado. */
|
|
16
|
+
focusable?: boolean;
|
|
15
17
|
}): import("react").JSX.Element;
|
package/dist/SelectTooltip.js
CHANGED
|
@@ -14,77 +14,78 @@ function f(e) {
|
|
|
14
14
|
return !0;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
function p({ content: p, children: m, placement: h = "top", delay: g = 250, openOnClick: _ = !1, disabled: v = !1 }) {
|
|
18
|
-
let [
|
|
19
|
-
d() && (
|
|
20
|
-
}, N = () => {
|
|
21
|
-
O.current && clearTimeout(O.current), b(!1), w(!1);
|
|
17
|
+
function p({ content: p, children: m, placement: h = "top", delay: g = 250, openOnClick: _ = !1, disabled: v = !1, focusable: y = !1 }) {
|
|
18
|
+
let [b, x] = o(!1), [S, C] = o(!1), [w, T] = o(!1), E = !v && (S || b && !w), D = a(null), O = a(null), k = a(null), [A, j] = o(null), M = r(), N = () => {
|
|
19
|
+
d() && (k.current && clearTimeout(k.current), k.current = setTimeout(() => x(!0), g));
|
|
22
20
|
}, P = () => {
|
|
23
|
-
|
|
21
|
+
k.current && clearTimeout(k.current), x(!1), T(!1);
|
|
22
|
+
}, F = () => {
|
|
23
|
+
_ && (k.current && clearTimeout(k.current), E ? (C(!1), x(!1), T(!0)) : C(!0));
|
|
24
24
|
};
|
|
25
25
|
n(() => () => {
|
|
26
|
-
|
|
26
|
+
k.current && clearTimeout(k.current);
|
|
27
27
|
}, []);
|
|
28
|
-
let
|
|
28
|
+
let I = t(() => {
|
|
29
29
|
var t;
|
|
30
|
-
let n = ((t =
|
|
30
|
+
let n = ((t = D.current) == null ? void 0 : t.firstElementChild) ?? D.current, r = O.current;
|
|
31
31
|
if (!n || !r) return;
|
|
32
32
|
let i = e(n.getBoundingClientRect(), {
|
|
33
33
|
width: r.offsetWidth,
|
|
34
34
|
height: r.offsetHeight
|
|
35
35
|
}, h, 6);
|
|
36
|
-
|
|
36
|
+
j({
|
|
37
37
|
top: i.top,
|
|
38
38
|
left: i.left
|
|
39
39
|
});
|
|
40
40
|
}, [h]);
|
|
41
41
|
return i(() => {
|
|
42
|
-
if (!
|
|
43
|
-
|
|
42
|
+
if (!E) {
|
|
43
|
+
j(null);
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
}, [
|
|
48
|
-
if (!
|
|
49
|
-
let e = () =>
|
|
46
|
+
I();
|
|
47
|
+
}, [E, I]), n(() => {
|
|
48
|
+
if (!E) return;
|
|
49
|
+
let e = () => I();
|
|
50
50
|
return window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
|
|
51
51
|
window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
|
|
52
52
|
};
|
|
53
|
-
}, [
|
|
54
|
-
if (!
|
|
53
|
+
}, [E, I]), n(() => {
|
|
54
|
+
if (!E) return;
|
|
55
55
|
let e = (e) => {
|
|
56
|
-
e.key === "Escape" && (
|
|
56
|
+
e.key === "Escape" && (C(!1), x(!1));
|
|
57
57
|
};
|
|
58
58
|
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
59
|
-
}, [
|
|
60
|
-
if (!
|
|
59
|
+
}, [E]), n(() => {
|
|
60
|
+
if (!S) return;
|
|
61
61
|
let e = (e) => {
|
|
62
62
|
var t, n;
|
|
63
63
|
let r = e.target;
|
|
64
|
-
(t =
|
|
64
|
+
(t = D.current) != null && t.contains(r) || (n = O.current) != null && n.contains(r) || (C(!1), x(!1));
|
|
65
65
|
};
|
|
66
66
|
return document.addEventListener("mousedown", e, !0), () => document.removeEventListener("mousedown", e, !0);
|
|
67
|
-
}, [
|
|
67
|
+
}, [S]), /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("span", {
|
|
68
68
|
className: "select-tip__trigger",
|
|
69
|
-
ref:
|
|
70
|
-
onMouseEnter:
|
|
71
|
-
onMouseLeave:
|
|
69
|
+
ref: D,
|
|
70
|
+
onMouseEnter: N,
|
|
71
|
+
onMouseLeave: P,
|
|
72
72
|
onFocusCapture: (e) => {
|
|
73
|
-
f(e.target) &&
|
|
73
|
+
f(e.target) && x(!0);
|
|
74
74
|
},
|
|
75
|
-
onBlurCapture:
|
|
76
|
-
onClick: _ ?
|
|
77
|
-
|
|
75
|
+
onBlurCapture: P,
|
|
76
|
+
onClick: _ ? F : void 0,
|
|
77
|
+
tabIndex: y ? 0 : void 0,
|
|
78
|
+
"aria-describedby": E ? M : void 0,
|
|
78
79
|
children: m
|
|
79
|
-
}),
|
|
80
|
-
ref:
|
|
81
|
-
id:
|
|
80
|
+
}), E && u(/* @__PURE__ */ c("div", {
|
|
81
|
+
ref: O,
|
|
82
|
+
id: M,
|
|
82
83
|
role: "tooltip",
|
|
83
|
-
className: `select select-tip${
|
|
84
|
-
style:
|
|
84
|
+
className: `select select-tip${S ? " select-tip--pinned" : ""}`,
|
|
85
|
+
style: A ? {
|
|
85
86
|
position: "fixed",
|
|
86
|
-
top:
|
|
87
|
-
left:
|
|
87
|
+
top: A.top,
|
|
88
|
+
left: A.left
|
|
88
89
|
} : {
|
|
89
90
|
position: "fixed",
|
|
90
91
|
top: 0,
|