@selectwin/kit 0.1.266 → 0.1.268
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 +32 -5
- package/dist/SelectCalendar.d.ts +7 -1
- package/dist/SelectCalendar.js +36 -36
- package/dist/SelectDateField.js +112 -145
- package/dist/SelectField.d.ts +4 -0
- package/dist/SelectKpiBand.d.ts +3 -1
- package/dist/SelectKpiBand.js +14 -9
- package/dist/SelectLocale.d.ts +57 -0
- package/dist/SelectLocale.js +153 -39
- package/dist/SelectMail.d.ts +21 -3
- package/dist/SelectMail.js +61 -57
- package/dist/SelectMonthField.d.ts +20 -0
- package/dist/SelectMonthField.js +181 -0
- package/dist/SelectScrollArea.d.ts +6 -2
- package/dist/SelectScrollArea.js +7 -7
- package/dist/SelectTable.d.ts +8 -0
- package/dist/SelectTable.js +90 -90
- package/dist/SelectWhenField.d.ts +26 -0
- package/dist/SelectWhenField.js +192 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +17 -15
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/SelectTable.js
CHANGED
|
@@ -4,39 +4,39 @@ import { FrameBody as r, useFrameKind as i } from "./internal/frame.js";
|
|
|
4
4
|
import { SelectAvatar as a } from "./SelectAvatar.js";
|
|
5
5
|
import { SelectListChrome as o, listChromeShape as s } from "./internal/listChrome.js";
|
|
6
6
|
import { SelectTableEmpty as c } from "./SelectTableEmpty.js";
|
|
7
|
-
import { Children as l, Fragment as u, cloneElement as d, createContext as f, forwardRef as p, isValidElement as m, useCallback as h, useContext as g, useId as
|
|
8
|
-
import { Fragment as
|
|
7
|
+
import { Children as l, Fragment as u, cloneElement as d, createContext as f, forwardRef as p, isValidElement as m, useCallback as h, useContext as g, useId as ee, useLayoutEffect as _, useRef as te, useState as ne } from "react";
|
|
8
|
+
import { Fragment as v, jsx as y, jsxs as b } from "react/jsx-runtime";
|
|
9
9
|
//#region src/SelectTable.tsx
|
|
10
|
-
var
|
|
11
|
-
function
|
|
10
|
+
var x = 40, S = 1200, C = 8;
|
|
11
|
+
function w(e) {
|
|
12
12
|
let t = parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;
|
|
13
13
|
return `${Math.round(e / t * 1e3) / 1e3}rem`;
|
|
14
14
|
}
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
let
|
|
18
|
-
open:
|
|
19
|
-
onToggle: () =>
|
|
20
|
-
controls:
|
|
21
|
-
} : void 0,
|
|
15
|
+
var T = f(0), E = p(function({ columns: t, children: a, empty: c, footer: u, title: d, headingLevel: f, help: p, description: m, action: g, filters: v, tools: E, onColumnResize: D, onColumnResizeReset: O, collapsible: k = !1, defaultOpen: A = !0, flush: j = !1, bare: M = !1, label: N, minWidth: P, sizing: ie = "even", className: F, ...I }, L) {
|
|
16
|
+
var R;
|
|
17
|
+
let ae = N ?? (typeof d == "string" ? d : void 0), [z, B] = ne(A), V = ee(), H = k && d != null ? {
|
|
18
|
+
open: z,
|
|
19
|
+
onToggle: () => B((e) => !e),
|
|
20
|
+
controls: V
|
|
21
|
+
} : void 0, U = l.count(a) === 0, W = U && !!c, { hasFilters: G, hasTitleRow: K } = s({
|
|
22
22
|
title: d,
|
|
23
23
|
description: m,
|
|
24
24
|
action: g,
|
|
25
|
-
filters:
|
|
26
|
-
tools:
|
|
27
|
-
}),
|
|
25
|
+
filters: v,
|
|
26
|
+
tools: E
|
|
27
|
+
}), q = W && !K && !G, J = (R = t[t.length - 1]) == null ? void 0 : R.label, oe = J != null && J !== "" && J !== !1, Y = i(), X = M && !j, se = Y === "body" || X, ce = Y === "list" && !X, le = n({
|
|
28
28
|
selector: ".select-table__row",
|
|
29
29
|
y: 8,
|
|
30
30
|
duration: .45,
|
|
31
31
|
stagger: .05,
|
|
32
32
|
scroll: !0
|
|
33
|
-
}), Z = t.length ? t.map((e) => e.width ?? `minmax(${e.minWidth ?? "var(--select-table-col-min, 6.5rem)"}, ${e.grow ?? 1}fr)`).join(" ") : "1fr", Q = te(null),
|
|
34
|
-
Q.current = e, typeof
|
|
35
|
-
}, [
|
|
36
|
-
|
|
33
|
+
}), Z = t.length ? t.map((e) => e.width ?? `minmax(${e.minWidth ?? "var(--select-table-col-min, 6.5rem)"}, ${e.grow ?? 1}fr)`).join(" ") : "1fr", Q = te(null), ue = h((e) => {
|
|
34
|
+
Q.current = e, typeof L == "function" ? L(e) : L && (L.current = e);
|
|
35
|
+
}, [L]);
|
|
36
|
+
_(() => {
|
|
37
37
|
let e = Q.current;
|
|
38
38
|
if (!e) return;
|
|
39
|
-
if (
|
|
39
|
+
if (ie !== "content" || !t.some((e) => e.width == null)) {
|
|
40
40
|
e.style.setProperty("--select-table-cols", Z);
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
@@ -64,9 +64,9 @@ var E = f(0), D = p(function({ columns: t, children: a, empty: c, footer: u, tit
|
|
|
64
64
|
if (!r) return;
|
|
65
65
|
let i = t.map((t, r) => r === e ? `${n}px` : t.width ?? `minmax(${t.minWidth ?? "var(--select-table-col-min, 6.5rem)"}, ${t.grow ?? 1}fr)`);
|
|
66
66
|
r.style.setProperty("--select-table-cols", i.join(" "));
|
|
67
|
-
},
|
|
67
|
+
}, de = (e) => (t) => {
|
|
68
68
|
var n;
|
|
69
|
-
if (!
|
|
69
|
+
if (!D || t.button !== 0) return;
|
|
70
70
|
let r = (n = t.currentTarget.parentElement) == null ? void 0 : n.getBoundingClientRect();
|
|
71
71
|
if (!r) return;
|
|
72
72
|
let i = t.clientX, a = r.width;
|
|
@@ -74,87 +74,87 @@ var E = f(0), D = p(function({ columns: t, children: a, empty: c, footer: u, tit
|
|
|
74
74
|
let o = Q.current;
|
|
75
75
|
o == null || o.classList.add("select-table--resizing");
|
|
76
76
|
let s = a, c = (t) => {
|
|
77
|
-
s = Math.min(
|
|
77
|
+
s = Math.min(S, Math.max(x, a + (t.clientX - i))), $(e, s);
|
|
78
78
|
}, l = () => {
|
|
79
|
-
window.removeEventListener("pointermove", c), window.removeEventListener("pointerup", l), window.removeEventListener("pointercancel", l), o == null || o.classList.remove("select-table--resizing"),
|
|
79
|
+
window.removeEventListener("pointermove", c), window.removeEventListener("pointerup", l), window.removeEventListener("pointercancel", l), o == null || o.classList.remove("select-table--resizing"), D(e, w(s));
|
|
80
80
|
};
|
|
81
81
|
window.addEventListener("pointermove", c), window.addEventListener("pointerup", l), window.addEventListener("pointercancel", l);
|
|
82
|
-
},
|
|
82
|
+
}, fe = (e) => (t) => {
|
|
83
83
|
var n;
|
|
84
|
-
if (!
|
|
84
|
+
if (!D) return;
|
|
85
85
|
let r = t.key === "ArrowRight" ? 1 : t.key === "ArrowLeft" ? -1 : 0;
|
|
86
86
|
if (r === 0) return;
|
|
87
87
|
let i = (n = t.currentTarget.parentElement) == null ? void 0 : n.getBoundingClientRect();
|
|
88
88
|
if (!i) return;
|
|
89
89
|
t.preventDefault();
|
|
90
|
-
let a =
|
|
91
|
-
$(e, o),
|
|
90
|
+
let a = C * (t.shiftKey ? 10 : 1), o = Math.min(S, Math.max(x, i.width + r * a));
|
|
91
|
+
$(e, o), D(e, w(o));
|
|
92
92
|
};
|
|
93
|
-
return /* @__PURE__ */
|
|
94
|
-
ref:
|
|
95
|
-
...
|
|
96
|
-
className: `select-table${
|
|
93
|
+
return /* @__PURE__ */ b("div", {
|
|
94
|
+
ref: ue,
|
|
95
|
+
...I,
|
|
96
|
+
className: `select-table${q ? " select-table--empty" : ""}${se && !j ? " select-table--nested" : ""}${ce && !j ? " select-table--inlist" : ""}${j ? " select-table--flush" : ""}${X ? " select-table--bare" : ""}${H ? ` select-table--collapsible${z ? " is-open" : ""}` : ""}${oe ? " select-table--free-last" : ""}${F ? " " + F : ""}`,
|
|
97
97
|
style: {
|
|
98
98
|
"--select-table-cols": Z,
|
|
99
99
|
...P ? { "--select-table-min": P } : {}
|
|
100
100
|
},
|
|
101
|
-
children: [/* @__PURE__ */
|
|
101
|
+
children: [/* @__PURE__ */ y(o, {
|
|
102
102
|
title: d,
|
|
103
103
|
headingLevel: f,
|
|
104
|
-
help:
|
|
104
|
+
help: H ? void 0 : p,
|
|
105
105
|
description: m,
|
|
106
106
|
action: g,
|
|
107
|
-
filters:
|
|
108
|
-
tools:
|
|
109
|
-
toggle:
|
|
110
|
-
}), /* @__PURE__ */
|
|
111
|
-
enabled: !!
|
|
112
|
-
open:
|
|
113
|
-
id:
|
|
107
|
+
filters: H ? void 0 : v,
|
|
108
|
+
tools: H ? void 0 : E,
|
|
109
|
+
toggle: H
|
|
110
|
+
}), /* @__PURE__ */ b(re, {
|
|
111
|
+
enabled: !!H,
|
|
112
|
+
open: z,
|
|
113
|
+
id: V,
|
|
114
114
|
children: [
|
|
115
|
-
|
|
116
|
-
filters:
|
|
117
|
-
tools:
|
|
115
|
+
H && (v != null || E != null) ? /* @__PURE__ */ y(o, {
|
|
116
|
+
filters: v,
|
|
117
|
+
tools: E
|
|
118
118
|
}) : null,
|
|
119
|
-
/* @__PURE__ */
|
|
120
|
-
className: `select-table__scroll${
|
|
121
|
-
children: /* @__PURE__ */
|
|
119
|
+
/* @__PURE__ */ y("div", {
|
|
120
|
+
className: `select-table__scroll${W ? " select-table__scroll--empty" : ""}`,
|
|
121
|
+
children: /* @__PURE__ */ b("div", {
|
|
122
122
|
className: "select-table__scrollinner",
|
|
123
|
-
...
|
|
123
|
+
...W ? {} : {
|
|
124
124
|
role: "table",
|
|
125
|
-
"aria-label":
|
|
125
|
+
"aria-label": ae
|
|
126
126
|
},
|
|
127
|
-
children: [!
|
|
127
|
+
children: [!W && /* @__PURE__ */ y("div", {
|
|
128
128
|
className: "select-table__head",
|
|
129
129
|
role: "row",
|
|
130
|
-
children: t.map((n, r) => /* @__PURE__ */
|
|
130
|
+
children: t.map((n, r) => /* @__PURE__ */ b("div", {
|
|
131
131
|
role: "columnheader",
|
|
132
132
|
"aria-sort": n.sortable ? n.sortDir === "asc" ? "ascending" : n.sortDir === "desc" ? "descending" : "none" : void 0,
|
|
133
133
|
className: `select-table__th select-table__cell--${n.align ?? "start"}${n.tone ? ` select-table__th--${n.tone}` : ""}`,
|
|
134
|
-
children: [n.sortable ? /* @__PURE__ */
|
|
134
|
+
children: [n.sortable ? /* @__PURE__ */ b("button", {
|
|
135
135
|
type: "button",
|
|
136
136
|
className: `select-table__sortbtn${n.sortDir === "asc" ? " select-table__sortbtn--asc" : ""}${n.sortDir == null ? "" : " select-table__sortbtn--active"}`,
|
|
137
137
|
onClick: n.onSort,
|
|
138
|
-
children: [n.label, /* @__PURE__ */
|
|
139
|
-
}) : n.label,
|
|
138
|
+
children: [n.label, /* @__PURE__ */ y(e, {})]
|
|
139
|
+
}) : n.label, D && n.resizable !== !1 && r < t.length - 1 && /* @__PURE__ */ y("span", {
|
|
140
140
|
role: "separator",
|
|
141
141
|
"aria-orientation": "vertical",
|
|
142
142
|
"aria-label": "Ajustar a largura da coluna",
|
|
143
143
|
tabIndex: 0,
|
|
144
144
|
className: "select-table__resizer",
|
|
145
|
-
onPointerDown:
|
|
146
|
-
onKeyDown:
|
|
147
|
-
onDoubleClick:
|
|
145
|
+
onPointerDown: de(r),
|
|
146
|
+
onKeyDown: fe(r),
|
|
147
|
+
onDoubleClick: O ? () => O(r) : void 0
|
|
148
148
|
})]
|
|
149
149
|
}, r))
|
|
150
|
-
}), /* @__PURE__ */
|
|
150
|
+
}), /* @__PURE__ */ y("div", {
|
|
151
151
|
className: "select-table__body",
|
|
152
|
-
children: /* @__PURE__ */
|
|
152
|
+
children: /* @__PURE__ */ y("div", {
|
|
153
153
|
className: "select-table__rows",
|
|
154
|
-
ref:
|
|
155
|
-
children: /* @__PURE__ */
|
|
154
|
+
ref: le,
|
|
155
|
+
children: /* @__PURE__ */ y(T.Provider, {
|
|
156
156
|
value: t.length,
|
|
157
|
-
children: /* @__PURE__ */
|
|
157
|
+
children: /* @__PURE__ */ y(r, { children: U && c ? /* @__PURE__ */ y("div", {
|
|
158
158
|
className: "select-table__empty",
|
|
159
159
|
children: c
|
|
160
160
|
}) : a })
|
|
@@ -163,7 +163,7 @@ var E = f(0), D = p(function({ columns: t, children: a, empty: c, footer: u, tit
|
|
|
163
163
|
})]
|
|
164
164
|
})
|
|
165
165
|
}),
|
|
166
|
-
u && /* @__PURE__ */
|
|
166
|
+
u && /* @__PURE__ */ y("div", {
|
|
167
167
|
className: "select-table__footer",
|
|
168
168
|
children: u
|
|
169
169
|
})
|
|
@@ -171,56 +171,56 @@ var E = f(0), D = p(function({ columns: t, children: a, empty: c, footer: u, tit
|
|
|
171
171
|
})]
|
|
172
172
|
});
|
|
173
173
|
});
|
|
174
|
-
function
|
|
175
|
-
return e ? /* @__PURE__ */
|
|
174
|
+
function re({ enabled: e, open: t, id: n, children: r }) {
|
|
175
|
+
return e ? /* @__PURE__ */ y("div", {
|
|
176
176
|
className: "select-table__collapse",
|
|
177
177
|
id: n,
|
|
178
178
|
"data-open": t,
|
|
179
179
|
"aria-hidden": !t,
|
|
180
|
-
children: /* @__PURE__ */
|
|
180
|
+
children: /* @__PURE__ */ y("div", {
|
|
181
181
|
className: "select-table__collapsewrap",
|
|
182
182
|
children: r
|
|
183
183
|
})
|
|
184
|
-
}) : /* @__PURE__ */
|
|
184
|
+
}) : /* @__PURE__ */ y(v, { children: r });
|
|
185
185
|
}
|
|
186
|
-
var
|
|
187
|
-
return /* @__PURE__ */
|
|
186
|
+
var D = p(function({ name: e, secondary: t, src: n, badge: r, className: i, ...o }, s) {
|
|
187
|
+
return /* @__PURE__ */ b("span", {
|
|
188
188
|
ref: s,
|
|
189
189
|
...o,
|
|
190
190
|
className: `select-usercell${i ? " " + i : ""}`,
|
|
191
|
-
children: [/* @__PURE__ */
|
|
191
|
+
children: [/* @__PURE__ */ y(a, {
|
|
192
192
|
name: typeof e == "string" ? e : void 0,
|
|
193
193
|
src: n
|
|
194
|
-
}), /* @__PURE__ */
|
|
194
|
+
}), /* @__PURE__ */ b("span", {
|
|
195
195
|
className: "select-usercell__text",
|
|
196
|
-
children: [r ? /* @__PURE__ */
|
|
196
|
+
children: [r ? /* @__PURE__ */ b("span", {
|
|
197
197
|
className: "select-usercell__line",
|
|
198
|
-
children: [/* @__PURE__ */
|
|
198
|
+
children: [/* @__PURE__ */ y("span", {
|
|
199
199
|
className: "select-usercell__name",
|
|
200
200
|
children: e
|
|
201
201
|
}), r]
|
|
202
|
-
}) : /* @__PURE__ */
|
|
202
|
+
}) : /* @__PURE__ */ y("span", {
|
|
203
203
|
className: "select-usercell__name",
|
|
204
204
|
children: e
|
|
205
|
-
}), t && /* @__PURE__ */
|
|
205
|
+
}), t && /* @__PURE__ */ y("span", {
|
|
206
206
|
className: "select-usercell__secondary",
|
|
207
207
|
children: t
|
|
208
208
|
})]
|
|
209
209
|
})]
|
|
210
210
|
});
|
|
211
211
|
});
|
|
212
|
-
function
|
|
212
|
+
function O(e, t) {
|
|
213
213
|
let n = l.toArray(e), r = (e) => m(e) && e.type !== u, i = n.findIndex((e) => r(e) && e.props.header === !0), a = i >= 0 ? i : n.findIndex(r);
|
|
214
214
|
if (a < 0) return e;
|
|
215
215
|
let o = n[a];
|
|
216
|
-
return n[a] = d(o, void 0, /* @__PURE__ */
|
|
216
|
+
return n[a] = d(o, void 0, /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ y("span", {
|
|
217
217
|
className: "select-visually-hidden",
|
|
218
218
|
children: `${t}: `
|
|
219
219
|
}), o.props.children] })), n;
|
|
220
220
|
}
|
|
221
|
-
function
|
|
222
|
-
let d = c ?
|
|
223
|
-
return t ? /* @__PURE__ */
|
|
221
|
+
function k({ children: e, onClick: t, expanded: n, nested: r = !1, current: i = !1, section: a = !1, muted: o = !1, tone: s, toneLabel: c, className: l, ...u }) {
|
|
222
|
+
let d = c ? O(e, c) : e, f = `select-table__row${t ? " select-table__row--clickable" : ""}${r ? " select-table__row--nested" : ""}${a ? " select-table__row--section" : ""}${o ? " select-table__row--muted" : ""}${s ? ` select-table__row--tone select-table__row--tone-${s}` : ""}${n ? " is-expanded" : ""}${i ? " is-current" : ""}${l ? " " + l : ""}`;
|
|
223
|
+
return t ? /* @__PURE__ */ y("div", {
|
|
224
224
|
...u,
|
|
225
225
|
className: f,
|
|
226
226
|
role: "row",
|
|
@@ -228,13 +228,13 @@ function A({ children: e, onClick: t, expanded: n, nested: r = !1, current: i =
|
|
|
228
228
|
"aria-expanded": n,
|
|
229
229
|
"aria-current": i || void 0,
|
|
230
230
|
onClick: (e) => {
|
|
231
|
-
|
|
231
|
+
j(e.target, e.currentTarget) || t();
|
|
232
232
|
},
|
|
233
233
|
onKeyDown: (e) => {
|
|
234
234
|
e.target !== e.currentTarget || e.key !== "Enter" && e.key !== " " || (e.preventDefault(), t());
|
|
235
235
|
},
|
|
236
236
|
children: d
|
|
237
|
-
}) : /* @__PURE__ */
|
|
237
|
+
}) : /* @__PURE__ */ y("div", {
|
|
238
238
|
...u,
|
|
239
239
|
className: f,
|
|
240
240
|
role: "row",
|
|
@@ -242,15 +242,15 @@ function A({ children: e, onClick: t, expanded: n, nested: r = !1, current: i =
|
|
|
242
242
|
children: d
|
|
243
243
|
});
|
|
244
244
|
}
|
|
245
|
-
var
|
|
246
|
-
function
|
|
245
|
+
var A = "button, a[href], input, select, textarea, label, summary, [role=\"button\"], [role=\"menuitem\"], [role=\"checkbox\"], [role=\"switch\"], [data-row-click=\"ignore\"]";
|
|
246
|
+
function j(e, t) {
|
|
247
247
|
if (!(e instanceof Element) || !t.contains(e)) return !0;
|
|
248
|
-
let n = e.closest(
|
|
248
|
+
let n = e.closest(A);
|
|
249
249
|
return n !== null && n !== t && t.contains(n);
|
|
250
250
|
}
|
|
251
|
-
var
|
|
252
|
-
let d = g(
|
|
253
|
-
return /* @__PURE__ */
|
|
251
|
+
var M = p(function({ children: e, align: n = "start", disclosure: r, header: i = !1, span: a, wrap: o = !1, className: s, style: c, ...l }, u) {
|
|
252
|
+
let d = g(T), f = a === "all" ? d || void 0 : a;
|
|
253
|
+
return /* @__PURE__ */ b("div", {
|
|
254
254
|
ref: u,
|
|
255
255
|
...l,
|
|
256
256
|
role: i ? "rowheader" : "cell",
|
|
@@ -260,14 +260,14 @@ var N = p(function({ children: e, align: n = "start", disclosure: r, header: i =
|
|
|
260
260
|
...c
|
|
261
261
|
} : c,
|
|
262
262
|
className: `select-table__td select-table__cell--${n}${o ? " select-table__td--wrap" : ""}${s ? " " + s : ""}`,
|
|
263
|
-
children: [r ? /* @__PURE__ */
|
|
263
|
+
children: [r ? /* @__PURE__ */ y("span", {
|
|
264
264
|
className: `select-table__disclosure${r === "open" ? " is-open" : ""}`,
|
|
265
265
|
"aria-hidden": "true",
|
|
266
|
-
children: r !== "none" && /* @__PURE__ */
|
|
266
|
+
children: r !== "none" && /* @__PURE__ */ y(t, {})
|
|
267
267
|
}) : null, e]
|
|
268
268
|
});
|
|
269
269
|
});
|
|
270
270
|
//#endregion
|
|
271
|
-
export {
|
|
271
|
+
export { E as SelectTable, M as SelectTableCell, c as SelectTableEmpty, k as SelectTableRow, D as SelectUserCell };
|
|
272
272
|
|
|
273
273
|
//# sourceMappingURL=SelectTable.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** O "Quando": o começo no relógio da parede e a duração. */
|
|
2
|
+
export interface SelectWhenValue {
|
|
3
|
+
/** O começo, 'YYYY-MM-DDTHH:mm' (sem fuso: o relógio da parede de quem usa); '' enquanto não há dia. */
|
|
4
|
+
start: string;
|
|
5
|
+
/** A duração, em minutos (o fim é o começo mais ela). */
|
|
6
|
+
minutes: number;
|
|
7
|
+
}
|
|
8
|
+
/** As durações do "Termina", em minutos, quando o app não passa as dele. */
|
|
9
|
+
export declare const SELECT_WHEN_DURATIONS: readonly number[];
|
|
10
|
+
export interface SelectWhenFieldProps {
|
|
11
|
+
label?: string;
|
|
12
|
+
value: SelectWhenValue;
|
|
13
|
+
onChange: (value: SelectWhenValue) => void;
|
|
14
|
+
/** As durações do "Termina", em minutos (padrão: `SELECT_WHEN_DURATIONS`). A do `value` entra quando não está aqui. */
|
|
15
|
+
durations?: readonly number[];
|
|
16
|
+
placeholder?: string;
|
|
17
|
+
required?: boolean;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
error?: string;
|
|
20
|
+
hint?: string;
|
|
21
|
+
/** O primeiro e o último dia que se escolhem (inclusive); os de fora ficam apagados. */
|
|
22
|
+
minDate?: Date | null;
|
|
23
|
+
maxDate?: Date | null;
|
|
24
|
+
id?: string;
|
|
25
|
+
}
|
|
26
|
+
export declare const SelectWhenField: import('react').ForwardRefExoticComponent<SelectWhenFieldProps & Omit<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, keyof SelectWhenFieldProps> & import('react').RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/* empty css */
|
|
2
|
+
import { SelectButton as e } from "./SelectButton.js";
|
|
3
|
+
import { CalendarIcon as t, ChevronLeftIcon as n, ChevronRightIcon as r } from "./icons.js";
|
|
4
|
+
import { useSelectLocale as i, useSelectMessages as a } from "./SelectLocale.js";
|
|
5
|
+
import { SelectField as o, SelectLabelRow as ee } from "./SelectField.js";
|
|
6
|
+
import { SelectSelect as te } from "./SelectSelect.js";
|
|
7
|
+
import { SelectPopover as ne } from "./SelectPopover.js";
|
|
8
|
+
import { selectDurationText as s } from "./SelectDeadlineBadge.js";
|
|
9
|
+
import { forwardRef as c, useId as l, useState as u } from "react";
|
|
10
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
11
|
+
//#region src/SelectWhenField.tsx
|
|
12
|
+
var p = [
|
|
13
|
+
15,
|
|
14
|
+
30,
|
|
15
|
+
45,
|
|
16
|
+
60,
|
|
17
|
+
90,
|
|
18
|
+
120
|
|
19
|
+
], m = (e) => String(e).padStart(2, "0"), h = (e) => new Date(e.getFullYear(), e.getMonth(), e.getDate()), g = (e) => new Date(e.getFullYear(), e.getMonth(), 1), _ = (e, t) => new Date(e.getFullYear(), e.getMonth(), e.getDate() + t), v = (e, t) => new Date(e.getFullYear(), e.getMonth() + t, 1), y = (e, t) => e.getFullYear() === t.getFullYear() && e.getMonth() === t.getMonth() && e.getDate() === t.getDate(), b = (e) => `${m(e.getHours())}:${m(e.getMinutes())}`, x = (e) => e.charAt(0).toUpperCase() + e.slice(1);
|
|
20
|
+
function re(e) {
|
|
21
|
+
let t = /^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2}))?/.exec(e || "");
|
|
22
|
+
return t ? new Date(Number(t[1]), Number(t[2]) - 1, Number(t[3]), Number(t[4] ?? 0), Number(t[5] ?? 0)) : null;
|
|
23
|
+
}
|
|
24
|
+
var ie = (e) => `${e.getFullYear()}-${m(e.getMonth() + 1)}-${m(e.getDate())}T${b(e)}`, S = (e, t) => new Date(e.getFullYear(), e.getMonth(), e.getDate(), e.getHours(), e.getMinutes() + t), C = c(function({ label: c, value: m, onChange: C, durations: w = p, placeholder: T, required: E, disabled: D, error: O, hint: k, minDate: A, maxDate: j, id: ae, className: M, ...oe }, se) {
|
|
25
|
+
let N = a(), P = N.whenField, F = N.calendar, I = i(), L = (e) => s(e, !1, I), R = l(), z = ae ?? R, [B, V] = u(!1), H = re(m.start), U = A ? h(A) : null, W = j ? h(j) : null, G = (e) => !!U && h(e) < U || !!W && h(e) > W, K = () => {
|
|
26
|
+
if (H) return H;
|
|
27
|
+
let e = /* @__PURE__ */ new Date();
|
|
28
|
+
return W && e > W ? W : U && e < U ? U : e;
|
|
29
|
+
}, [q, J] = u(() => g(K())), Y = h(/* @__PURE__ */ new Date()), ce = _(g(q), -g(q).getDay()), le = Array.from({ length: 42 }, (e, t) => _(ce, t)), ue = [.../* @__PURE__ */ new Set([...w, m.minutes])].filter((e) => Number.isFinite(e) && e > 0).sort((e, t) => e - t), de = O ? `${z}-err` : k ? `${z}-hint` : void 0, X = (e) => P.day(e.getFullYear(), e.getMonth() + 1, e.getDate(), e.getFullYear() !== Y.getFullYear()), Z = (() => {
|
|
30
|
+
if (!H) return null;
|
|
31
|
+
if (!(m.minutes > 0)) return `${X(H)}, ${b(H)}`;
|
|
32
|
+
let e = S(H, m.minutes);
|
|
33
|
+
return P.value(X(H), b(H), y(H, e) ? b(e) : `${X(e)}, ${b(e)}`);
|
|
34
|
+
})(), Q = (e, t = m.minutes) => C({
|
|
35
|
+
start: e ? ie(e) : "",
|
|
36
|
+
minutes: t
|
|
37
|
+
}), fe = () => {
|
|
38
|
+
D || (J(g(K())), V((e) => !e));
|
|
39
|
+
}, $ = (e) => {
|
|
40
|
+
G(e) || Q(new Date(e.getFullYear(), e.getMonth(), e.getDate(), (H == null ? void 0 : H.getHours()) ?? 0, (H == null ? void 0 : H.getMinutes()) ?? 0));
|
|
41
|
+
}, pe = (e) => {
|
|
42
|
+
let t = /^(\d{1,2}):(\d{2})/.exec(e);
|
|
43
|
+
if (!t) return;
|
|
44
|
+
let n = H ?? Y;
|
|
45
|
+
Q(new Date(n.getFullYear(), n.getMonth(), n.getDate(), Number(t[1]), Number(t[2])));
|
|
46
|
+
}, me = /* @__PURE__ */ f("div", {
|
|
47
|
+
className: `select-input-wrap${O ? " select-input-wrap--error" : ""}`,
|
|
48
|
+
children: [/* @__PURE__ */ d("button", {
|
|
49
|
+
id: z,
|
|
50
|
+
type: "button",
|
|
51
|
+
className: `select-input select-datefield__activator select-whenfield__activator${O ? " select-input--error" : ""}`,
|
|
52
|
+
onClick: fe,
|
|
53
|
+
disabled: D,
|
|
54
|
+
"aria-haspopup": "dialog",
|
|
55
|
+
"aria-expanded": B,
|
|
56
|
+
"aria-invalid": O ? !0 : void 0,
|
|
57
|
+
"aria-describedby": de,
|
|
58
|
+
children: Z ?? /* @__PURE__ */ d("span", {
|
|
59
|
+
className: "select-datefield__ph",
|
|
60
|
+
children: T ?? P.placeholder
|
|
61
|
+
})
|
|
62
|
+
}), /* @__PURE__ */ d("span", {
|
|
63
|
+
className: "select-datefield__icon",
|
|
64
|
+
"aria-hidden": "true",
|
|
65
|
+
children: /* @__PURE__ */ d(t, {})
|
|
66
|
+
})]
|
|
67
|
+
});
|
|
68
|
+
return /* @__PURE__ */ f("div", {
|
|
69
|
+
ref: se,
|
|
70
|
+
...oe,
|
|
71
|
+
className: `select-field select-whenfield${M ? " " + M : ""}`,
|
|
72
|
+
children: [
|
|
73
|
+
c && /* @__PURE__ */ d(ee, {
|
|
74
|
+
htmlFor: z,
|
|
75
|
+
label: E ? `${c} *` : c
|
|
76
|
+
}),
|
|
77
|
+
/* @__PURE__ */ d("div", {
|
|
78
|
+
className: "select-datefield",
|
|
79
|
+
children: /* @__PURE__ */ d(ne, {
|
|
80
|
+
active: B,
|
|
81
|
+
onClose: () => V(!1),
|
|
82
|
+
placement: "bottom-start",
|
|
83
|
+
role: "dialog",
|
|
84
|
+
activator: me,
|
|
85
|
+
children: /* @__PURE__ */ f("div", {
|
|
86
|
+
className: "select-datefield__pop select-whenfield__pop",
|
|
87
|
+
children: [
|
|
88
|
+
/* @__PURE__ */ f("div", {
|
|
89
|
+
className: "select-datepicker__calhead",
|
|
90
|
+
children: [
|
|
91
|
+
/* @__PURE__ */ d("button", {
|
|
92
|
+
type: "button",
|
|
93
|
+
className: "select-datepicker__nav",
|
|
94
|
+
"aria-label": F.prevMonth,
|
|
95
|
+
onClick: () => J((e) => v(e, -1)),
|
|
96
|
+
children: /* @__PURE__ */ d(n, {})
|
|
97
|
+
}),
|
|
98
|
+
/* @__PURE__ */ d("span", {
|
|
99
|
+
className: "select-datepicker__monthlabel",
|
|
100
|
+
"aria-live": "polite",
|
|
101
|
+
children: x(F.monthTitle(q.getMonth() + 1, q.getFullYear()))
|
|
102
|
+
}),
|
|
103
|
+
/* @__PURE__ */ d("button", {
|
|
104
|
+
type: "button",
|
|
105
|
+
className: "select-datepicker__nav",
|
|
106
|
+
"aria-label": F.nextMonth,
|
|
107
|
+
onClick: () => J((e) => v(e, 1)),
|
|
108
|
+
children: /* @__PURE__ */ d(r, {})
|
|
109
|
+
})
|
|
110
|
+
]
|
|
111
|
+
}),
|
|
112
|
+
/* @__PURE__ */ f("div", {
|
|
113
|
+
className: "select-datepicker__grid",
|
|
114
|
+
children: [F.dow.map((e) => /* @__PURE__ */ d("div", {
|
|
115
|
+
className: "select-datepicker__weekday",
|
|
116
|
+
"aria-hidden": "true",
|
|
117
|
+
children: x(e)
|
|
118
|
+
}, e)), le.map((e) => {
|
|
119
|
+
let t = !!H && y(e, H), n = y(e, Y), r = "select-datepicker__daybtn" + (t ? " is-selected" : "") + (n && !t ? " is-today" : "") + (e.getMonth() === q.getMonth() ? "" : " is-outside");
|
|
120
|
+
return /* @__PURE__ */ d("div", {
|
|
121
|
+
className: "select-datepicker__day",
|
|
122
|
+
children: /* @__PURE__ */ d("button", {
|
|
123
|
+
type: "button",
|
|
124
|
+
className: r,
|
|
125
|
+
disabled: G(e),
|
|
126
|
+
"aria-label": F.dayLabel(e.getMonth() + 1, e.getDate()),
|
|
127
|
+
"aria-pressed": t,
|
|
128
|
+
"aria-current": n ? "date" : void 0,
|
|
129
|
+
onClick: () => $(e),
|
|
130
|
+
children: e.getDate()
|
|
131
|
+
})
|
|
132
|
+
}, e.getTime());
|
|
133
|
+
})]
|
|
134
|
+
}),
|
|
135
|
+
/* @__PURE__ */ f("div", {
|
|
136
|
+
className: "select-whenfield__times",
|
|
137
|
+
children: [/* @__PURE__ */ d(o, {
|
|
138
|
+
size: "sm",
|
|
139
|
+
type: "time",
|
|
140
|
+
label: P.start,
|
|
141
|
+
value: H ? b(H) : "",
|
|
142
|
+
onChange: pe
|
|
143
|
+
}), /* @__PURE__ */ d(te, {
|
|
144
|
+
size: "sm",
|
|
145
|
+
label: P.end,
|
|
146
|
+
value: String(m.minutes),
|
|
147
|
+
onChange: (e) => Q(H, Number(e)),
|
|
148
|
+
options: ue.map((e) => ({
|
|
149
|
+
value: String(e),
|
|
150
|
+
label: H ? P.endOption(b(S(H, e)), L(e)) : L(e)
|
|
151
|
+
}))
|
|
152
|
+
})]
|
|
153
|
+
}),
|
|
154
|
+
/* @__PURE__ */ f("div", {
|
|
155
|
+
className: "select-datefield__footer",
|
|
156
|
+
children: [/* @__PURE__ */ d("span", {}), /* @__PURE__ */ f("div", {
|
|
157
|
+
className: "select-datefield__footer-right",
|
|
158
|
+
children: [!G(Y) && /* @__PURE__ */ d(e, {
|
|
159
|
+
variant: "secondary",
|
|
160
|
+
inline: !0,
|
|
161
|
+
onClick: () => {
|
|
162
|
+
J(g(Y)), $(Y);
|
|
163
|
+
},
|
|
164
|
+
children: F.today
|
|
165
|
+
}), /* @__PURE__ */ d(e, {
|
|
166
|
+
variant: "primary",
|
|
167
|
+
inline: !0,
|
|
168
|
+
onClick: () => V(!1),
|
|
169
|
+
children: P.done
|
|
170
|
+
})]
|
|
171
|
+
})]
|
|
172
|
+
})
|
|
173
|
+
]
|
|
174
|
+
})
|
|
175
|
+
})
|
|
176
|
+
}),
|
|
177
|
+
O ? /* @__PURE__ */ d("p", {
|
|
178
|
+
id: `${z}-err`,
|
|
179
|
+
className: "select-field__error",
|
|
180
|
+
children: O
|
|
181
|
+
}) : k ? /* @__PURE__ */ d("p", {
|
|
182
|
+
id: `${z}-hint`,
|
|
183
|
+
className: "select-field__hint",
|
|
184
|
+
children: k
|
|
185
|
+
}) : null
|
|
186
|
+
]
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
//#endregion
|
|
190
|
+
export { p as SELECT_WHEN_DURATIONS, C as SelectWhenField };
|
|
191
|
+
|
|
192
|
+
//# sourceMappingURL=SelectWhenField.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -57,7 +57,7 @@ export { SelectLoader, type SelectLoaderProps } from './SelectLoader';
|
|
|
57
57
|
export { SelectText } from './SelectText';
|
|
58
58
|
export { SelectBox, SelectStack, SelectInline, SelectGrid } from './SelectLayout';
|
|
59
59
|
export { SelectScrollArea } from './SelectScrollArea';
|
|
60
|
-
export type { SelectScrollAreaProps, SelectScrollAreaElement, SelectScrollAxis } from './SelectScrollArea';
|
|
60
|
+
export type { SelectScrollAreaProps, SelectScrollAreaElement, SelectScrollAxis, SelectScrollGutter } from './SelectScrollArea';
|
|
61
61
|
export { SelectAvatarGroup } from './SelectAvatarGroup';
|
|
62
62
|
export type { SelectAvatarGroupProps, SelectAvatarGroupPerson } from './SelectAvatarGroup';
|
|
63
63
|
export { SelectFieldset } from './SelectFieldset';
|
|
@@ -325,6 +325,10 @@ export { selectRangeDays } from './SelectDatePicker';
|
|
|
325
325
|
export { SelectDateRangeField } from './SelectDateRangeField';
|
|
326
326
|
export { SelectDateField } from './SelectDateField';
|
|
327
327
|
export type { SelectDateFieldProps } from './SelectDateField';
|
|
328
|
+
export { SelectMonthField } from './SelectMonthField';
|
|
329
|
+
export type { SelectMonthFieldProps } from './SelectMonthField';
|
|
330
|
+
export { SelectWhenField, SELECT_WHEN_DURATIONS } from './SelectWhenField';
|
|
331
|
+
export type { SelectWhenFieldProps, SelectWhenValue } from './SelectWhenField';
|
|
328
332
|
export { SelectRating } from './SelectRating';
|
|
329
333
|
export { SelectNumberField } from './SelectNumberField';
|
|
330
334
|
export { SelectQuantityField } from './SelectQuantityField';
|