@selectwin/kit 0.1.258 → 0.1.260
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/README.md +47 -0
- package/dist/SelectActionBar.d.ts +29 -0
- package/dist/SelectActionBar.js +101 -0
- package/dist/SelectBadge.d.ts +9 -0
- package/dist/SelectBadge.js +26 -12
- package/dist/SelectBulkBar.d.ts +21 -0
- package/dist/SelectBulkBar.js +40 -0
- package/dist/SelectChannelPreview.d.ts +21 -1
- package/dist/SelectChannelPreview.js +100 -73
- package/dist/SelectColorField.d.ts +1 -5
- package/dist/SelectColorField.js +83 -101
- package/dist/SelectCombobox.d.ts +5 -0
- package/dist/SelectCombobox.js +52 -49
- package/dist/SelectComposerNotice.d.ts +14 -0
- package/dist/SelectComposerNotice.js +37 -0
- package/dist/SelectDataTable.d.ts +17 -1
- package/dist/SelectDataTable.js +100 -90
- package/dist/SelectDeadlineBadge.d.ts +32 -0
- package/dist/SelectDeadlineBadge.js +73 -0
- package/dist/SelectFilterBar.js +5 -5
- package/dist/SelectListCard.d.ts +27 -1
- package/dist/SelectListCard.js +47 -22
- package/dist/SelectLocale.d.ts +62 -0
- package/dist/SelectLocale.js +173 -0
- package/dist/SelectMail.d.ts +52 -8
- package/dist/SelectMail.js +315 -242
- package/dist/SelectSection.d.ts +4 -4
- package/dist/SelectSection.js +77 -8
- package/dist/SelectSegmented.d.ts +11 -0
- package/dist/SelectSegmented.js +87 -68
- package/dist/SelectTable.d.ts +13 -1
- package/dist/SelectTable.js +88 -79
- package/dist/SelectTabs.d.ts +7 -0
- package/dist/SelectTabs.js +47 -40
- package/dist/SelectWeekHours.d.ts +64 -0
- package/dist/SelectWeekHours.js +338 -0
- package/dist/index.d.ts +14 -2
- package/dist/index.js +189 -183
- package/dist/internal/color.d.ts +15 -0
- package/dist/internal/color.js +40 -0
- package/dist/internal/safeHref.d.ts +7 -0
- package/dist/internal/safeHref.js +12 -1
- package/dist/internal/scrollReveal.d.ts +19 -0
- package/dist/internal/scrollReveal.js +38 -0
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/SelectColorField.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/* empty css */
|
|
2
2
|
import { SelectLabelRow as e } from "./SelectField.js";
|
|
3
3
|
import { SelectPopover as t } from "./SelectPopover.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { contrastRatio as n, luminance as r, normalizeHex as i } from "./internal/color.js";
|
|
5
|
+
import { useEffect as a, useId as o, useRef as s, useState as c } from "react";
|
|
6
|
+
import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
6
7
|
//#region src/SelectColorField.tsx
|
|
7
|
-
var
|
|
8
|
+
var f = [
|
|
8
9
|
"#212529",
|
|
9
10
|
"#495057",
|
|
10
11
|
"#868E96",
|
|
@@ -21,39 +22,20 @@ var l = [
|
|
|
21
22
|
"#DB2777",
|
|
22
23
|
"#9333EA",
|
|
23
24
|
"#6D28D9"
|
|
24
|
-
],
|
|
25
|
-
function
|
|
26
|
-
let t =
|
|
27
|
-
return t ? `#${(t[1].length === 3 ? t[1].split("").map((e) => e + e).join("") : t[1]).toUpperCase()}` : null;
|
|
28
|
-
}
|
|
29
|
-
function f(e) {
|
|
30
|
-
let t = d(e);
|
|
31
|
-
if (!t) return 0;
|
|
32
|
-
let [n, r, i] = [
|
|
33
|
-
1,
|
|
34
|
-
3,
|
|
35
|
-
5
|
|
36
|
-
].map((e) => parseInt(t.slice(e, e + 2), 16) / 255).map((e) => e <= .03928 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4);
|
|
37
|
-
return .2126 * n + .7152 * r + .0722 * i;
|
|
38
|
-
}
|
|
39
|
-
function p(e, t) {
|
|
40
|
-
let [n, r] = [f(e), f(t)].sort((e, t) => t - e);
|
|
41
|
-
return (n + .05) / (r + .05);
|
|
42
|
-
}
|
|
43
|
-
var m = (e) => Math.min(1, Math.max(0, e));
|
|
44
|
-
function h(e) {
|
|
45
|
-
let t = d(e) ?? "#000000", [n, r, i] = [
|
|
25
|
+
], p = (e) => Math.min(1, Math.max(0, e));
|
|
26
|
+
function m(e) {
|
|
27
|
+
let t = i(e) ?? "#000000", [n, r, a] = [
|
|
46
28
|
1,
|
|
47
29
|
3,
|
|
48
30
|
5
|
|
49
|
-
].map((e) => parseInt(t.slice(e, e + 2), 16) / 255),
|
|
50
|
-
return
|
|
51
|
-
h:
|
|
52
|
-
s:
|
|
53
|
-
v:
|
|
31
|
+
].map((e) => parseInt(t.slice(e, e + 2), 16) / 255), o = Math.max(n, r, a), s = o - Math.min(n, r, a), c = 0;
|
|
32
|
+
return s && (c = o === n ? (r - a) / s % 6 : o === r ? (a - n) / s + 2 : (n - r) / s + 4, c *= 60, c < 0 && (c += 360)), {
|
|
33
|
+
h: c,
|
|
34
|
+
s: o ? s / o : 0,
|
|
35
|
+
v: o
|
|
54
36
|
};
|
|
55
37
|
}
|
|
56
|
-
function
|
|
38
|
+
function h({ h: e, s: t, v: n }) {
|
|
57
39
|
let r = (r) => {
|
|
58
40
|
let i = (r + e / 60) % 6;
|
|
59
41
|
return n - n * t * Math.max(0, Math.min(i, 4 - i, 1));
|
|
@@ -64,26 +46,26 @@ function g({ h: e, s: t, v: n }) {
|
|
|
64
46
|
r(1)
|
|
65
47
|
].map((e) => Math.round(e * 255).toString(16).padStart(2, "0")).join("").toUpperCase()}`;
|
|
66
48
|
}
|
|
67
|
-
function
|
|
68
|
-
let [
|
|
69
|
-
|
|
49
|
+
function g({ hex: e, onPick: t }) {
|
|
50
|
+
let [n, r] = c(() => m(e ?? "#1D4ED8")), i = s(n), o = (e) => {
|
|
51
|
+
i.current = e, r(e);
|
|
70
52
|
};
|
|
71
|
-
|
|
72
|
-
if (!e ||
|
|
73
|
-
let t =
|
|
74
|
-
|
|
53
|
+
a(() => {
|
|
54
|
+
if (!e || h(i.current) === e) return;
|
|
55
|
+
let t = m(e);
|
|
56
|
+
o(t.s === 0 || t.v === 0 ? {
|
|
75
57
|
...t,
|
|
76
|
-
h:
|
|
58
|
+
h: i.current.h
|
|
77
59
|
} : t);
|
|
78
60
|
}, [e]);
|
|
79
61
|
let f = (e) => {
|
|
80
|
-
|
|
81
|
-
},
|
|
62
|
+
o(e), t(h(e));
|
|
63
|
+
}, g = (e, t, n) => {
|
|
82
64
|
var r;
|
|
83
65
|
(r = e.setPointerCapture) == null || r.call(e, t.pointerId);
|
|
84
66
|
let i = (t) => {
|
|
85
67
|
let r = e.getBoundingClientRect();
|
|
86
|
-
n(
|
|
68
|
+
n(p((t.clientX - r.left) / (r.width || 1)), p((t.clientY - r.top) / (r.height || 1)));
|
|
87
69
|
};
|
|
88
70
|
i(t);
|
|
89
71
|
let a = (e) => i(e), o = () => {
|
|
@@ -91,113 +73,113 @@ function _({ hex: e, onPick: t }) {
|
|
|
91
73
|
};
|
|
92
74
|
e.addEventListener("pointermove", a), e.addEventListener("pointerup", o), e.addEventListener("pointercancel", o);
|
|
93
75
|
}, _ = (e) => {
|
|
94
|
-
let t = e.shiftKey ? .1 : .01, { h: n, s: r, v:
|
|
76
|
+
let t = e.shiftKey ? .1 : .01, { h: n, s: r, v: a } = i.current, o = e.key === "ArrowLeft" ? {
|
|
95
77
|
h: n,
|
|
96
|
-
s:
|
|
97
|
-
v:
|
|
78
|
+
s: p(r - t),
|
|
79
|
+
v: a
|
|
98
80
|
} : e.key === "ArrowRight" ? {
|
|
99
81
|
h: n,
|
|
100
|
-
s:
|
|
101
|
-
v:
|
|
82
|
+
s: p(r + t),
|
|
83
|
+
v: a
|
|
102
84
|
} : e.key === "ArrowUp" ? {
|
|
103
85
|
h: n,
|
|
104
86
|
s: r,
|
|
105
|
-
v:
|
|
87
|
+
v: p(a + t)
|
|
106
88
|
} : e.key === "ArrowDown" ? {
|
|
107
89
|
h: n,
|
|
108
90
|
s: r,
|
|
109
|
-
v:
|
|
91
|
+
v: p(a - t)
|
|
110
92
|
} : null;
|
|
111
|
-
|
|
93
|
+
o && (e.preventDefault(), f(o));
|
|
112
94
|
}, v = (e) => {
|
|
113
|
-
let t = e.shiftKey ? 10 : 1, { h: n, s: r, v:
|
|
114
|
-
|
|
115
|
-
h:
|
|
95
|
+
let t = e.shiftKey ? 10 : 1, { h: n, s: r, v: a } = i.current, o = e.key === "ArrowLeft" || e.key === "ArrowDown" ? Math.max(0, n - t) : e.key === "ArrowRight" || e.key === "ArrowUp" ? Math.min(360, n + t) : e.key === "Home" ? 0 : e.key === "End" ? 360 : null;
|
|
96
|
+
o != null && (e.preventDefault(), f({
|
|
97
|
+
h: o,
|
|
116
98
|
s: r,
|
|
117
|
-
v:
|
|
99
|
+
v: a
|
|
118
100
|
}));
|
|
119
|
-
}, y =
|
|
120
|
-
h:
|
|
101
|
+
}, y = h({
|
|
102
|
+
h: n.h,
|
|
121
103
|
s: 1,
|
|
122
104
|
v: 1
|
|
123
|
-
}), b =
|
|
124
|
-
return /* @__PURE__ */
|
|
105
|
+
}), b = h(n);
|
|
106
|
+
return /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ u("div", {
|
|
125
107
|
className: "select-colorfield__sv",
|
|
126
108
|
style: { backgroundColor: y },
|
|
127
109
|
role: "slider",
|
|
128
110
|
tabIndex: 0,
|
|
129
111
|
"aria-label": "Saturação e brilho",
|
|
130
|
-
"aria-valuetext": `${b} — saturação ${Math.round(
|
|
131
|
-
onPointerDown: (e) =>
|
|
132
|
-
h:
|
|
112
|
+
"aria-valuetext": `${b} — saturação ${Math.round(n.s * 100)}%, brilho ${Math.round(n.v * 100)}%`,
|
|
113
|
+
onPointerDown: (e) => g(e.currentTarget, e, (e, t) => f({
|
|
114
|
+
h: i.current.h,
|
|
133
115
|
s: e,
|
|
134
116
|
v: 1 - t
|
|
135
117
|
})),
|
|
136
118
|
onKeyDown: _,
|
|
137
|
-
children: /* @__PURE__ */
|
|
119
|
+
children: /* @__PURE__ */ u("span", {
|
|
138
120
|
className: "select-colorfield__svthumb",
|
|
139
121
|
style: {
|
|
140
|
-
left: `${
|
|
141
|
-
top: `${(1 -
|
|
122
|
+
left: `${n.s * 100}%`,
|
|
123
|
+
top: `${(1 - n.v) * 100}%`,
|
|
142
124
|
background: b
|
|
143
125
|
}
|
|
144
126
|
})
|
|
145
|
-
}), /* @__PURE__ */
|
|
127
|
+
}), /* @__PURE__ */ u("div", {
|
|
146
128
|
className: "select-colorfield__hue",
|
|
147
129
|
role: "slider",
|
|
148
130
|
tabIndex: 0,
|
|
149
131
|
"aria-label": "Matiz",
|
|
150
132
|
"aria-valuemin": 0,
|
|
151
133
|
"aria-valuemax": 360,
|
|
152
|
-
"aria-valuenow": Math.round(
|
|
153
|
-
onPointerDown: (e) =>
|
|
154
|
-
...
|
|
134
|
+
"aria-valuenow": Math.round(n.h),
|
|
135
|
+
onPointerDown: (e) => g(e.currentTarget, e, (e) => f({
|
|
136
|
+
...i.current,
|
|
155
137
|
h: e * 360
|
|
156
138
|
})),
|
|
157
139
|
onKeyDown: v,
|
|
158
|
-
children: /* @__PURE__ */
|
|
140
|
+
children: /* @__PURE__ */ u("span", {
|
|
159
141
|
className: "select-colorfield__huethumb",
|
|
160
142
|
style: {
|
|
161
|
-
left: `${
|
|
143
|
+
left: `${n.h / 360 * 100}%`,
|
|
162
144
|
background: y
|
|
163
145
|
}
|
|
164
146
|
})
|
|
165
147
|
})] });
|
|
166
148
|
}
|
|
167
|
-
var
|
|
168
|
-
function
|
|
169
|
-
let E =
|
|
170
|
-
|
|
171
|
-
j(
|
|
172
|
-
}, [
|
|
173
|
-
let P =
|
|
149
|
+
var _ = (e) => e.toFixed(1).replace(".", ",");
|
|
150
|
+
function v({ label: s, help: p, hint: m, error: h, value: v, onChange: y, presets: b = f, disabled: x = !1, allowEmpty: S = !1, contrastWith: C, contrastLabel: w = "o texto", id: T }) {
|
|
151
|
+
let E = o(), D = T ?? `color-${E}`, [O, k] = c(!1), [A, j] = c(v ?? ""), [M, N] = c(null);
|
|
152
|
+
a(() => {
|
|
153
|
+
j(v ?? ""), N(null);
|
|
154
|
+
}, [v]);
|
|
155
|
+
let P = i(v ?? ""), F = (e) => {
|
|
174
156
|
if (!e.trim()) {
|
|
175
|
-
S ? (N(null), y("")) : j(
|
|
157
|
+
S ? (N(null), y("")) : j(v ?? "");
|
|
176
158
|
return;
|
|
177
159
|
}
|
|
178
|
-
let t =
|
|
160
|
+
let t = i(e);
|
|
179
161
|
if (!t) {
|
|
180
162
|
N("Use o formato #RRGGBB (ex.: #1D4ED8).");
|
|
181
163
|
return;
|
|
182
164
|
}
|
|
183
165
|
N(null), j(t), t !== P && y(t);
|
|
184
|
-
}, I = C ?
|
|
185
|
-
return /* @__PURE__ */
|
|
166
|
+
}, I = C ? i(C) : null, L = P && I ? n(P, I) : null, R = h ?? M, z = R ? `${D}-err` : m || L != null ? `${D}-hint` : void 0;
|
|
167
|
+
return /* @__PURE__ */ d("div", {
|
|
186
168
|
className: `select-field select-colorfield${x ? " is-disabled" : ""}`,
|
|
187
169
|
children: [
|
|
188
|
-
(
|
|
170
|
+
(s || p) && /* @__PURE__ */ u(e, {
|
|
189
171
|
htmlFor: D,
|
|
190
|
-
label:
|
|
191
|
-
help:
|
|
172
|
+
label: s,
|
|
173
|
+
help: p
|
|
192
174
|
}),
|
|
193
|
-
/* @__PURE__ */
|
|
175
|
+
/* @__PURE__ */ d("div", {
|
|
194
176
|
className: `select-input-wrap select-input-wrap--affixed select-colorfield__control${R ? " select-input-wrap--error" : ""}`,
|
|
195
|
-
children: [/* @__PURE__ */
|
|
177
|
+
children: [/* @__PURE__ */ u(t, {
|
|
196
178
|
active: O,
|
|
197
179
|
onClose: () => k(!1),
|
|
198
180
|
placement: "bottom-start",
|
|
199
181
|
role: "dialog",
|
|
200
|
-
activator: /* @__PURE__ */
|
|
182
|
+
activator: /* @__PURE__ */ u("button", {
|
|
201
183
|
type: "button",
|
|
202
184
|
className: `select-colorfield__swatch${P ? "" : " is-empty"}`,
|
|
203
185
|
style: P ? { background: P } : void 0,
|
|
@@ -206,20 +188,20 @@ function y({ label: i, help: u, hint: m, error: h, value: g, onChange: y, preset
|
|
|
206
188
|
"aria-label": P ? `Cor ${P} — abrir a paleta` : "Escolher uma cor",
|
|
207
189
|
"aria-expanded": O
|
|
208
190
|
}),
|
|
209
|
-
children: /* @__PURE__ */
|
|
191
|
+
children: /* @__PURE__ */ d("div", {
|
|
210
192
|
className: "select-colorfield__panel",
|
|
211
193
|
children: [
|
|
212
|
-
/* @__PURE__ */
|
|
194
|
+
/* @__PURE__ */ u(g, {
|
|
213
195
|
hex: P,
|
|
214
196
|
onPick: F
|
|
215
197
|
}),
|
|
216
|
-
/* @__PURE__ */
|
|
198
|
+
/* @__PURE__ */ u("div", {
|
|
217
199
|
className: "select-colorfield__presets",
|
|
218
200
|
role: "group",
|
|
219
201
|
"aria-label": "Cores prontas",
|
|
220
202
|
children: b.map((e) => {
|
|
221
|
-
let t =
|
|
222
|
-
return /* @__PURE__ */
|
|
203
|
+
let t = i(e) ?? e, n = t === P;
|
|
204
|
+
return /* @__PURE__ */ u("button", {
|
|
223
205
|
type: "button",
|
|
224
206
|
className: `select-colorfield__preset${n ? " is-selected" : ""}`,
|
|
225
207
|
style: { background: t },
|
|
@@ -231,9 +213,9 @@ function y({ label: i, help: u, hint: m, error: h, value: g, onChange: y, preset
|
|
|
231
213
|
}, t);
|
|
232
214
|
})
|
|
233
215
|
}),
|
|
234
|
-
S && P && /* @__PURE__ */
|
|
216
|
+
S && P && /* @__PURE__ */ u("div", {
|
|
235
217
|
className: "select-colorfield__row",
|
|
236
|
-
children: /* @__PURE__ */
|
|
218
|
+
children: /* @__PURE__ */ u("button", {
|
|
237
219
|
type: "button",
|
|
238
220
|
className: "select-colorfield__clear",
|
|
239
221
|
onClick: () => {
|
|
@@ -244,12 +226,12 @@ function y({ label: i, help: u, hint: m, error: h, value: g, onChange: y, preset
|
|
|
244
226
|
})
|
|
245
227
|
]
|
|
246
228
|
})
|
|
247
|
-
}), /* @__PURE__ */
|
|
229
|
+
}), /* @__PURE__ */ u("input", {
|
|
248
230
|
id: D,
|
|
249
231
|
className: "select-input select-input--mono select-colorfield__hex",
|
|
250
232
|
value: A,
|
|
251
233
|
onChange: (e) => {
|
|
252
|
-
j(e.target.value), e.target.value.replace("#", "").length === 6 &&
|
|
234
|
+
j(e.target.value), e.target.value.replace("#", "").length === 6 && i(e.target.value) && F(e.target.value);
|
|
253
235
|
},
|
|
254
236
|
onBlur: () => F(A),
|
|
255
237
|
placeholder: S ? "Padrão" : "#000000",
|
|
@@ -261,23 +243,23 @@ function y({ label: i, help: u, hint: m, error: h, value: g, onChange: y, preset
|
|
|
261
243
|
"aria-describedby": z
|
|
262
244
|
})]
|
|
263
245
|
}),
|
|
264
|
-
R ? /* @__PURE__ */
|
|
246
|
+
R ? /* @__PURE__ */ u("p", {
|
|
265
247
|
id: `${D}-err`,
|
|
266
248
|
className: "select-field__error",
|
|
267
249
|
children: R
|
|
268
|
-
}) : L == null ? m ? /* @__PURE__ */
|
|
250
|
+
}) : L == null ? m ? /* @__PURE__ */ u("p", {
|
|
269
251
|
id: `${D}-hint`,
|
|
270
252
|
className: "select-field__hint",
|
|
271
253
|
children: m
|
|
272
|
-
}) : null : /* @__PURE__ */
|
|
254
|
+
}) : null : /* @__PURE__ */ d("p", {
|
|
273
255
|
id: `${D}-hint`,
|
|
274
256
|
className: `select-field__hint select-colorfield__contrast${L < 4.5 ? " is-low" : ""}`,
|
|
275
|
-
children: [L >= 4.5 ? `Contraste com ${w}: ${
|
|
257
|
+
children: [L >= 4.5 ? `Contraste com ${w}: ${_(L)}:1 — legível.` : `Contraste com ${w}: ${_(L)}:1 — difícil de ler. Escolha uma cor ${r(P) < r(I) ? "mais escura" : "mais clara"}.`, m ? /* @__PURE__ */ d(l, { children: [" ", m] }) : null]
|
|
276
258
|
})
|
|
277
259
|
]
|
|
278
260
|
});
|
|
279
261
|
}
|
|
280
262
|
//#endregion
|
|
281
|
-
export {
|
|
263
|
+
export { f as SELECT_COLOR_PRESETS, v as SelectColorField, n as contrastRatio, m as hexToHsv, h as hsvToHex, i as normalizeHex };
|
|
282
264
|
|
|
283
265
|
//# sourceMappingURL=SelectColorField.js.map
|
package/dist/SelectCombobox.d.ts
CHANGED
|
@@ -25,6 +25,11 @@ type SelectComboboxOwnProps = {
|
|
|
25
25
|
disabled?: boolean;
|
|
26
26
|
/** Accepted for API parity with SelectSelect; sets aria-required (no native form control). */
|
|
27
27
|
required?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* 0.1.259: o "(opcional)" depois do rótulo, dentro dele, como nos outros campos do kit (o `SelectField`, o
|
|
30
|
+
* `SelectSelect`): o leitor de tela ouve "Equipe (opcional)". Sem `label`, ele entra no `ariaLabel`.
|
|
31
|
+
*/
|
|
32
|
+
optional?: boolean;
|
|
28
33
|
/** Control density. Default `md`; use `sm` in dense surfaces and modal/card forms. */
|
|
29
34
|
size?: 'sm' | 'md';
|
|
30
35
|
/** Show the in-list search box (default true). Set false for a plain styled picker — the
|
package/dist/SelectCombobox.js
CHANGED
|
@@ -4,41 +4,41 @@ import { SelectInfoTip as r } from "./SelectInfoTip.js";
|
|
|
4
4
|
import { moveInOptions as i, useOptionListFocus as a } from "./internal/optionList.js";
|
|
5
5
|
import { useSelectReveal as o } from "./internal/useSelectReveal.js";
|
|
6
6
|
import { SelectPopover as s } from "./SelectPopover.js";
|
|
7
|
-
import { forwardRef as c, useId as l, useMemo as
|
|
8
|
-
import { jsx as
|
|
7
|
+
import { forwardRef as c, useId as l, useMemo as ee, useRef as u, useState as d } from "react";
|
|
8
|
+
import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
9
9
|
//#region src/SelectCombobox.tsx
|
|
10
|
-
function
|
|
10
|
+
function m({ count: e, children: t }) {
|
|
11
11
|
let n = e > 0 ? Math.min(.03, .35 / e) : 0, r = o({
|
|
12
12
|
selector: ".select-combobox__option",
|
|
13
13
|
y: 6,
|
|
14
14
|
duration: .3,
|
|
15
15
|
stagger: n
|
|
16
16
|
});
|
|
17
|
-
return /* @__PURE__ */
|
|
17
|
+
return /* @__PURE__ */ f("div", {
|
|
18
18
|
className: "select-combobox__list",
|
|
19
19
|
ref: r,
|
|
20
20
|
children: t
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
|
-
var
|
|
24
|
-
let I = n(), L =
|
|
23
|
+
var h = c(function({ label: o, value: c, onChange: h, options: g, placeholder: _, searchPlaceholder: v, labelAction: y, help: b, hint: x, error: S, emptyText: te, disabled: C, required: w, optional: T = !1, size: E = "md", searchable: D = !0, allowCustom: O = !1, customLabel: k, minWidth: A, ariaLabel: j, className: M, style: N, ...P }, F) {
|
|
24
|
+
let I = n(), L = _ ?? I.common.selectPlaceholder, R = v ?? I.common.searchPlaceholder, z = te ?? I.common.noResults, B = l(), [V, H] = d(!1), [U, W] = d(""), G = u(null);
|
|
25
25
|
a(V, G);
|
|
26
|
-
let K =
|
|
26
|
+
let K = g.find((e) => e.value === c), q = K ? K.label : O && c ? c : null, J = ee(() => {
|
|
27
27
|
let e = U.trim().toLowerCase();
|
|
28
|
-
return !D || !e ?
|
|
28
|
+
return !D || !e ? g : g.filter((t) => {
|
|
29
29
|
var n;
|
|
30
30
|
return t.label.toLowerCase().includes(e) || ((n = t.secondary) == null ? void 0 : n.toLowerCase().includes(e));
|
|
31
31
|
});
|
|
32
32
|
}, [
|
|
33
|
-
|
|
33
|
+
g,
|
|
34
34
|
U,
|
|
35
35
|
D
|
|
36
|
-
]), Y = U.trim(), X = Y ?
|
|
36
|
+
]), Y = U.trim(), X = Y ? g.find((e) => e.label.toLowerCase() === Y.toLowerCase()) : void 0, Z = O && D && Y !== "" && !X, Q = () => {
|
|
37
37
|
H(!1), W("");
|
|
38
38
|
}, $ = (e) => {
|
|
39
|
-
|
|
40
|
-
},
|
|
41
|
-
return /* @__PURE__ */
|
|
39
|
+
h(e), Q();
|
|
40
|
+
}, ne = S ? `${B}-err` : x ? `${B}-hint` : void 0;
|
|
41
|
+
return /* @__PURE__ */ p("div", {
|
|
42
42
|
ref: F,
|
|
43
43
|
...P,
|
|
44
44
|
style: A ? {
|
|
@@ -47,54 +47,57 @@ var g = c(function({ label: o, value: c, onChange: g, options: _, placeholder: v
|
|
|
47
47
|
} : N,
|
|
48
48
|
className: `select-field${E === "sm" ? " select-field--sm" : ""}${M ? " " + M : ""}`,
|
|
49
49
|
children: [
|
|
50
|
-
(o ||
|
|
50
|
+
(o || b || y) && /* @__PURE__ */ p("div", {
|
|
51
51
|
className: "select-field__labelrow",
|
|
52
|
-
children: [/* @__PURE__ */
|
|
52
|
+
children: [/* @__PURE__ */ p("span", {
|
|
53
53
|
className: "select-field__labelwrap",
|
|
54
54
|
children: [o && /* @__PURE__ */ p("label", {
|
|
55
55
|
className: "select-field__label",
|
|
56
56
|
htmlFor: B,
|
|
57
|
-
children: o
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
children: [o, T && /* @__PURE__ */ p("span", {
|
|
58
|
+
className: "select-field__optional",
|
|
59
|
+
children: [" ", I.common.optional]
|
|
60
|
+
})]
|
|
61
|
+
}), b != null && b !== "" && /* @__PURE__ */ f(r, { content: b })]
|
|
62
|
+
}), y]
|
|
60
63
|
}),
|
|
61
|
-
/* @__PURE__ */
|
|
64
|
+
/* @__PURE__ */ f("div", {
|
|
62
65
|
className: "select-combobox",
|
|
63
|
-
children: /* @__PURE__ */
|
|
66
|
+
children: /* @__PURE__ */ f(s, {
|
|
64
67
|
active: V,
|
|
65
68
|
onClose: Q,
|
|
66
69
|
placement: "bottom-start",
|
|
67
70
|
role: "listbox",
|
|
68
71
|
matchWidth: !0,
|
|
69
|
-
activator: /* @__PURE__ */
|
|
72
|
+
activator: /* @__PURE__ */ p("button", {
|
|
70
73
|
id: B,
|
|
71
74
|
type: "button",
|
|
72
|
-
className: `select-combobox__trigger${
|
|
75
|
+
className: `select-combobox__trigger${S ? " select-input--error" : ""}${V ? " is-open" : ""}`,
|
|
73
76
|
onClick: () => V ? Q() : H(!0),
|
|
74
|
-
disabled:
|
|
77
|
+
disabled: C,
|
|
75
78
|
"aria-haspopup": "listbox",
|
|
76
|
-
"aria-label": o ? void 0 : j,
|
|
79
|
+
"aria-label": o ? void 0 : j && T ? `${j} ${I.common.optional}` : j,
|
|
77
80
|
"data-value": c,
|
|
78
81
|
"aria-expanded": V,
|
|
79
|
-
"aria-required":
|
|
80
|
-
"aria-describedby":
|
|
81
|
-
"aria-invalid":
|
|
82
|
-
children: [/* @__PURE__ */
|
|
82
|
+
"aria-required": w || void 0,
|
|
83
|
+
"aria-describedby": ne,
|
|
84
|
+
"aria-invalid": S ? !0 : void 0,
|
|
85
|
+
children: [/* @__PURE__ */ f("span", {
|
|
83
86
|
className: `select-combobox__value${q == null ? " is-placeholder" : ""}`,
|
|
84
87
|
children: q ?? L
|
|
85
|
-
}), /* @__PURE__ */
|
|
88
|
+
}), /* @__PURE__ */ f("span", {
|
|
86
89
|
className: "select-combobox__caret",
|
|
87
90
|
"aria-hidden": "true",
|
|
88
|
-
children: /* @__PURE__ */
|
|
91
|
+
children: /* @__PURE__ */ f(t, {})
|
|
89
92
|
})]
|
|
90
93
|
}),
|
|
91
|
-
children: /* @__PURE__ */
|
|
94
|
+
children: /* @__PURE__ */ p("div", {
|
|
92
95
|
className: "select-combobox__panel",
|
|
93
96
|
ref: G,
|
|
94
97
|
onKeyDown: i,
|
|
95
|
-
children: [D && /* @__PURE__ */
|
|
98
|
+
children: [D && /* @__PURE__ */ f("div", {
|
|
96
99
|
className: "select-combobox__search",
|
|
97
|
-
children: /* @__PURE__ */
|
|
100
|
+
children: /* @__PURE__ */ f("input", {
|
|
98
101
|
className: "select-combobox__searchinput",
|
|
99
102
|
type: "text",
|
|
100
103
|
value: U,
|
|
@@ -104,27 +107,27 @@ var g = c(function({ label: o, value: c, onChange: g, options: _, placeholder: v
|
|
|
104
107
|
},
|
|
105
108
|
placeholder: R
|
|
106
109
|
})
|
|
107
|
-
}), /* @__PURE__ */ m
|
|
110
|
+
}), /* @__PURE__ */ p(m, {
|
|
108
111
|
count: J.length + +!!Z,
|
|
109
|
-
children: [Z && /* @__PURE__ */
|
|
112
|
+
children: [Z && /* @__PURE__ */ f("button", {
|
|
110
113
|
type: "button",
|
|
111
114
|
role: "option",
|
|
112
115
|
"aria-selected": !1,
|
|
113
116
|
className: "select-combobox__option select-combobox__option--custom",
|
|
114
117
|
onClick: () => $(Y),
|
|
115
|
-
children: /* @__PURE__ */
|
|
118
|
+
children: /* @__PURE__ */ f("span", {
|
|
116
119
|
className: "select-combobox__optiontext",
|
|
117
|
-
children: /* @__PURE__ */
|
|
120
|
+
children: /* @__PURE__ */ f("span", {
|
|
118
121
|
className: "select-combobox__optionlabel",
|
|
119
122
|
children: k ? k(Y) : `Usar “${Y}”`
|
|
120
123
|
})
|
|
121
124
|
})
|
|
122
|
-
}), J.length === 0 ? Z ? null : /* @__PURE__ */
|
|
125
|
+
}), J.length === 0 ? Z ? null : /* @__PURE__ */ f("div", {
|
|
123
126
|
className: "select-combobox__empty",
|
|
124
127
|
children: z
|
|
125
128
|
}) : J.map((t) => {
|
|
126
129
|
let n = t.value === c;
|
|
127
|
-
return /* @__PURE__ */
|
|
130
|
+
return /* @__PURE__ */ p("button", {
|
|
128
131
|
type: "button",
|
|
129
132
|
role: "option",
|
|
130
133
|
"aria-selected": n,
|
|
@@ -132,19 +135,19 @@ var g = c(function({ label: o, value: c, onChange: g, options: _, placeholder: v
|
|
|
132
135
|
disabled: t.disabled,
|
|
133
136
|
className: `select-combobox__option${n ? " is-selected" : ""}`,
|
|
134
137
|
onClick: () => $(t.value),
|
|
135
|
-
children: [/* @__PURE__ */
|
|
138
|
+
children: [/* @__PURE__ */ p("span", {
|
|
136
139
|
className: "select-combobox__optiontext",
|
|
137
|
-
children: [/* @__PURE__ */
|
|
140
|
+
children: [/* @__PURE__ */ f("span", {
|
|
138
141
|
className: "select-combobox__optionlabel",
|
|
139
142
|
children: t.label
|
|
140
|
-
}), t.secondary && /* @__PURE__ */
|
|
143
|
+
}), t.secondary && /* @__PURE__ */ f("span", {
|
|
141
144
|
className: "select-combobox__optionsecondary",
|
|
142
145
|
children: t.secondary
|
|
143
146
|
})]
|
|
144
|
-
}), n && /* @__PURE__ */
|
|
147
|
+
}), n && /* @__PURE__ */ f("span", {
|
|
145
148
|
className: "select-combobox__check",
|
|
146
149
|
"aria-hidden": "true",
|
|
147
|
-
children: /* @__PURE__ */
|
|
150
|
+
children: /* @__PURE__ */ f(e, {})
|
|
148
151
|
})]
|
|
149
152
|
}, t.value);
|
|
150
153
|
})]
|
|
@@ -152,19 +155,19 @@ var g = c(function({ label: o, value: c, onChange: g, options: _, placeholder: v
|
|
|
152
155
|
})
|
|
153
156
|
})
|
|
154
157
|
}),
|
|
155
|
-
|
|
158
|
+
S ? /* @__PURE__ */ f("p", {
|
|
156
159
|
id: `${B}-err`,
|
|
157
160
|
className: "select-field__error",
|
|
158
|
-
children:
|
|
159
|
-
}) :
|
|
161
|
+
children: S
|
|
162
|
+
}) : x ? /* @__PURE__ */ f("p", {
|
|
160
163
|
id: `${B}-hint`,
|
|
161
164
|
className: "select-field__hint",
|
|
162
|
-
children:
|
|
165
|
+
children: x
|
|
163
166
|
}) : null
|
|
164
167
|
]
|
|
165
168
|
});
|
|
166
169
|
});
|
|
167
170
|
//#endregion
|
|
168
|
-
export {
|
|
171
|
+
export { h as SelectCombobox };
|
|
169
172
|
|
|
170
173
|
//# sourceMappingURL=SelectCombobox.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
2
|
+
type SelectComposerNoticeOwnProps = {
|
|
3
|
+
/** O que aconteceu ("A janela de 24 h fechou há 2 dias"). */
|
|
4
|
+
title: ReactNode;
|
|
5
|
+
/** O que fazer agora ("Para voltar a falar com Thiago, mande um modelo aprovado pela Meta."). */
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
/** O ícone do quadrado (padrão: o cadeado); `false` tira. */
|
|
8
|
+
icon?: ReactNode;
|
|
9
|
+
/** A ação, à direita (o botão do kit: "Escolher um modelo"). */
|
|
10
|
+
action?: ReactNode;
|
|
11
|
+
};
|
|
12
|
+
export type SelectComposerNoticeProps = SelectComposerNoticeOwnProps & Omit<ComponentPropsWithoutRef<'div'>, keyof SelectComposerNoticeOwnProps>;
|
|
13
|
+
export declare const SelectComposerNotice: import('react').ForwardRefExoticComponent<SelectComposerNoticeOwnProps & Omit<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, keyof SelectComposerNoticeOwnProps> & import('react').RefAttributes<HTMLDivElement>>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { LockIcon as e } from "./icons.js";
|
|
2
|
+
import { forwardRef as t } from "react";
|
|
3
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
4
|
+
//#region src/SelectComposerNotice.tsx
|
|
5
|
+
var i = t(function({ title: t, children: i, icon: a, action: o, className: s, ...c }, l) {
|
|
6
|
+
let u = a === void 0 ? /* @__PURE__ */ n(e, {}) : a;
|
|
7
|
+
return /* @__PURE__ */ r("div", {
|
|
8
|
+
ref: l,
|
|
9
|
+
...c,
|
|
10
|
+
className: `select-composer-notice${s ? " " + s : ""}`,
|
|
11
|
+
children: [
|
|
12
|
+
u != null && u !== !1 ? /* @__PURE__ */ n("span", {
|
|
13
|
+
className: "select-composer-notice__icon",
|
|
14
|
+
"aria-hidden": "true",
|
|
15
|
+
children: u
|
|
16
|
+
}) : null,
|
|
17
|
+
/* @__PURE__ */ r("div", {
|
|
18
|
+
className: "select-composer-notice__body",
|
|
19
|
+
children: [/* @__PURE__ */ n("p", {
|
|
20
|
+
className: "select-composer-notice__title",
|
|
21
|
+
children: t
|
|
22
|
+
}), i != null && i !== !1 ? /* @__PURE__ */ n("p", {
|
|
23
|
+
className: "select-composer-notice__text",
|
|
24
|
+
children: i
|
|
25
|
+
}) : null]
|
|
26
|
+
}),
|
|
27
|
+
o != null && o !== !1 ? /* @__PURE__ */ n("div", {
|
|
28
|
+
className: "select-composer-notice__action",
|
|
29
|
+
children: o
|
|
30
|
+
}) : null
|
|
31
|
+
]
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
//#endregion
|
|
35
|
+
export { i as SelectComposerNotice };
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=SelectComposerNotice.js.map
|