@selectwin/kit 0.1.259 → 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 +16 -0
- package/dist/SelectComposerNotice.d.ts +14 -0
- package/dist/SelectComposerNotice.js +37 -0
- package/dist/SelectMail.d.ts +43 -7
- package/dist/SelectMail.js +108 -62
- package/dist/SelectSegmented.d.ts +11 -0
- package/dist/SelectSegmented.js +87 -68
- package/dist/SelectTabs.d.ts +5 -8
- package/dist/SelectTabs.js +24 -55
- package/dist/index.d.ts +2 -0
- package/dist/index.js +183 -182
- 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/SelectSegmented.js
CHANGED
|
@@ -1,113 +1,132 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { revealInTrack as e, watchTrackOverflow as t } from "./internal/scrollReveal.js";
|
|
2
|
+
import { forwardRef as n, useCallback as r, useId as i, useLayoutEffect as a, useRef as o, useState as s } from "react";
|
|
3
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
3
4
|
//#region src/SelectSegmented.tsx
|
|
4
|
-
var
|
|
5
|
-
let
|
|
6
|
-
|
|
5
|
+
var u = n(function({ value: n, onChange: u, options: d, ariaLabel: f, fullWidth: p = !1, label: m, hint: h, disabled: g = !1, error: _, variant: v = "track", semantics: y = v === "chips" ? "radio" : "tabs", size: b = "md", scroll: x = !1, selected: S = "outline", className: C, ...w }, T) {
|
|
6
|
+
let E = i(), D = Math.max(0, d.findIndex((e) => e.value === n)), O = o([]), [k, A] = s(null), j = y === "radio", M = d.map((e) => e.count ?? "").join(",");
|
|
7
|
+
a(() => {
|
|
7
8
|
let e = () => {
|
|
8
|
-
let e =
|
|
9
|
+
let e = O.current[D];
|
|
9
10
|
if (!e) return;
|
|
10
11
|
let t = {
|
|
11
12
|
left: e.offsetLeft,
|
|
12
13
|
width: e.offsetWidth
|
|
13
14
|
};
|
|
14
|
-
|
|
15
|
+
A((e) => e && e.left === t.left && e.width === t.width ? e : t);
|
|
15
16
|
};
|
|
16
17
|
e();
|
|
17
18
|
let t = typeof ResizeObserver < "u" ? new ResizeObserver(e) : null;
|
|
18
|
-
return
|
|
19
|
+
return O.current.forEach((e) => e && (t == null ? void 0 : t.observe(e))), () => t == null ? void 0 : t.disconnect();
|
|
19
20
|
}, [
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
D,
|
|
22
|
+
d.length,
|
|
23
|
+
M
|
|
23
24
|
]);
|
|
24
|
-
let
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
let N = x && v === "chips", P = o(null), F = o(!1);
|
|
26
|
+
a(() => {
|
|
27
|
+
let t = P.current;
|
|
28
|
+
N && t && (e(t, O.current[D] ?? null, F.current), F.current = !0);
|
|
29
|
+
}, [
|
|
30
|
+
N,
|
|
31
|
+
D,
|
|
32
|
+
d.length
|
|
33
|
+
]), a(() => {
|
|
34
|
+
let e = P.current;
|
|
35
|
+
if (N && e) return t(e, O.current.filter((e) => e !== null));
|
|
36
|
+
}, [
|
|
37
|
+
N,
|
|
38
|
+
d.length,
|
|
39
|
+
M
|
|
40
|
+
]);
|
|
41
|
+
let I = m != null, L = r((e) => {
|
|
42
|
+
P.current = e, !I && (typeof T == "function" ? T(e) : T && (T.current = e));
|
|
43
|
+
}, [T, I]), R = k ? {
|
|
44
|
+
left: k.left,
|
|
45
|
+
width: k.width,
|
|
27
46
|
opacity: 1
|
|
28
|
-
} : { opacity: 0 },
|
|
29
|
-
var
|
|
30
|
-
if ((
|
|
31
|
-
let i =
|
|
47
|
+
} : { opacity: 0 }, z = m == null ? w : {}, B = (e) => {
|
|
48
|
+
var t, r;
|
|
49
|
+
if ((t = z.onKeyDown) == null || t.call(z, e), e.defaultPrevented || g || !d.length) return;
|
|
50
|
+
let i = O.current.findIndex((t) => t === e.target);
|
|
32
51
|
if (i < 0) return;
|
|
33
|
-
let a =
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
ref:
|
|
37
|
-
...
|
|
38
|
-
className: `select-segmented${
|
|
39
|
-
role:
|
|
40
|
-
"aria-label":
|
|
41
|
-
"aria-labelledby":
|
|
42
|
-
"aria-disabled":
|
|
43
|
-
onKeyDown:
|
|
44
|
-
children: [
|
|
52
|
+
let a = e.key === "ArrowRight" || j && e.key === "ArrowDown", o = e.key === "ArrowLeft" || j && e.key === "ArrowUp", s = a ? (i + 1) % d.length : o ? (i - 1 + d.length) % d.length : e.key === "Home" ? 0 : e.key === "End" ? d.length - 1 : -1;
|
|
53
|
+
s < 0 || (e.preventDefault(), (r = O.current[s]) == null || r.focus(), d[s].value !== n && u(d[s].value));
|
|
54
|
+
}, V = /* @__PURE__ */ l("div", {
|
|
55
|
+
ref: L,
|
|
56
|
+
...z,
|
|
57
|
+
className: `select-segmented${v === "chips" ? " select-segmented--chips" : ""}${N ? " select-segmented--scroll" : ""}${v === "chips" && S === "solid" ? " select-segmented--solid" : ""}${p ? " select-segmented--full" : ""}${b === "sm" ? " select-segmented--sm" : ""}${g ? " select-segmented--disabled" : ""}${_ != null && _ !== !1 ? " select-segmented--error" : ""}${m == null && C ? " " + C : ""}`,
|
|
58
|
+
role: j ? "radiogroup" : "tablist",
|
|
59
|
+
"aria-label": f,
|
|
60
|
+
"aria-labelledby": m != null && !f ? E : void 0,
|
|
61
|
+
"aria-disabled": g || void 0,
|
|
62
|
+
onKeyDown: B,
|
|
63
|
+
children: [v === "chips" ? null : /* @__PURE__ */ c("span", {
|
|
45
64
|
className: "select-segmented__pill",
|
|
46
65
|
"aria-hidden": "true",
|
|
47
|
-
style:
|
|
48
|
-
}),
|
|
49
|
-
let r =
|
|
50
|
-
return /* @__PURE__ */
|
|
66
|
+
style: R
|
|
67
|
+
}), d.map((e, t) => {
|
|
68
|
+
let r = e.value === n, i = !!e.count && e.count > 0, a = e.title && i ? `${e.title}, ${e.countLabel ?? e.count}` : e.title;
|
|
69
|
+
return /* @__PURE__ */ l("button", {
|
|
51
70
|
ref: (e) => {
|
|
52
|
-
|
|
71
|
+
O.current[t] = e;
|
|
53
72
|
},
|
|
54
73
|
type: "button",
|
|
55
|
-
role:
|
|
56
|
-
"aria-selected":
|
|
57
|
-
"aria-checked":
|
|
58
|
-
tabIndex:
|
|
74
|
+
role: j ? "radio" : "tab",
|
|
75
|
+
"aria-selected": j ? void 0 : r,
|
|
76
|
+
"aria-checked": j ? r : void 0,
|
|
77
|
+
tabIndex: t === D ? 0 : -1,
|
|
59
78
|
className: `select-segmented__item${r ? " select-segmented__item--active" : ""}`,
|
|
60
|
-
title:
|
|
61
|
-
"aria-label":
|
|
62
|
-
disabled:
|
|
63
|
-
onClick: () =>
|
|
79
|
+
title: e.title,
|
|
80
|
+
"aria-label": a,
|
|
81
|
+
disabled: g,
|
|
82
|
+
onClick: () => u(e.value),
|
|
64
83
|
children: [
|
|
65
|
-
|
|
84
|
+
e.icon != null && e.icon !== !1 ? /* @__PURE__ */ c("span", {
|
|
66
85
|
className: "select-segmented__icon",
|
|
67
86
|
"aria-hidden": "true",
|
|
68
|
-
children:
|
|
87
|
+
children: e.icon
|
|
69
88
|
}) : null,
|
|
70
|
-
|
|
71
|
-
i ? /* @__PURE__ */
|
|
89
|
+
e.label,
|
|
90
|
+
i ? /* @__PURE__ */ c("span", {
|
|
72
91
|
className: "select-segmented__count",
|
|
73
|
-
"aria-hidden":
|
|
74
|
-
children:
|
|
92
|
+
"aria-hidden": e.title ? !0 : void 0,
|
|
93
|
+
children: e.count
|
|
75
94
|
}) : null
|
|
76
95
|
]
|
|
77
|
-
},
|
|
96
|
+
}, e.value);
|
|
78
97
|
})]
|
|
79
|
-
}),
|
|
80
|
-
return
|
|
98
|
+
}), H = _ != null && _ !== !1 && _ !== "";
|
|
99
|
+
return m == null && !H ? V : m == null ? /* @__PURE__ */ l("div", {
|
|
81
100
|
className: "select-field",
|
|
82
|
-
children: [
|
|
101
|
+
children: [V, /* @__PURE__ */ c("p", {
|
|
83
102
|
className: "select-field__error",
|
|
84
|
-
children:
|
|
103
|
+
children: _
|
|
85
104
|
})]
|
|
86
|
-
}) : /* @__PURE__ */
|
|
87
|
-
ref:
|
|
88
|
-
...
|
|
89
|
-
className: `select-field${
|
|
105
|
+
}) : /* @__PURE__ */ l("div", {
|
|
106
|
+
ref: T,
|
|
107
|
+
...w,
|
|
108
|
+
className: `select-field${C ? " " + C : ""}`,
|
|
90
109
|
children: [
|
|
91
|
-
/* @__PURE__ */
|
|
110
|
+
/* @__PURE__ */ c("div", {
|
|
92
111
|
className: "select-field__labelrow",
|
|
93
|
-
children: /* @__PURE__ */
|
|
112
|
+
children: /* @__PURE__ */ c("span", {
|
|
94
113
|
className: "select-field__label",
|
|
95
|
-
id:
|
|
96
|
-
children:
|
|
114
|
+
id: E,
|
|
115
|
+
children: m
|
|
97
116
|
})
|
|
98
117
|
}),
|
|
99
|
-
|
|
100
|
-
|
|
118
|
+
V,
|
|
119
|
+
H ? /* @__PURE__ */ c("p", {
|
|
101
120
|
className: "select-field__error",
|
|
102
|
-
children:
|
|
103
|
-
}) :
|
|
121
|
+
children: _
|
|
122
|
+
}) : h != null && /* @__PURE__ */ c("p", {
|
|
104
123
|
className: "select-field__hint",
|
|
105
|
-
children:
|
|
124
|
+
children: h
|
|
106
125
|
})
|
|
107
126
|
]
|
|
108
127
|
});
|
|
109
128
|
});
|
|
110
129
|
//#endregion
|
|
111
|
-
export {
|
|
130
|
+
export { u as SelectSegmented };
|
|
112
131
|
|
|
113
132
|
//# sourceMappingURL=SelectSegmented.js.map
|
package/dist/SelectTabs.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ReactNode, ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
import { selectScrollOverflow, selectScrollTarget } from './internal/scrollReveal';
|
|
2
3
|
export interface SelectTab {
|
|
3
4
|
id: string;
|
|
4
5
|
label: ReactNode;
|
|
@@ -19,14 +20,10 @@ type SelectTabsOwnProps = {
|
|
|
19
20
|
};
|
|
20
21
|
export type SelectTabsProps = SelectTabsOwnProps & Omit<ComponentPropsWithoutRef<'div'>, keyof SelectTabsOwnProps>;
|
|
21
22
|
/**
|
|
22
|
-
* 0.1.259: as pontas da barra que escondem abas
|
|
23
|
-
*
|
|
23
|
+
* 0.1.259: as pontas da barra que escondem abas e até onde rolar para a aba ficar à vista — as contas moram em
|
|
24
|
+
* `internal/scrollReveal` desde a 0.1.260 (as fichas que rolam usam as mesmas); os nomes daqui seguem. PURAS.
|
|
24
25
|
*/
|
|
25
|
-
export declare
|
|
26
|
-
|
|
27
|
-
* 0.1.259: até onde rolar para a aba [left, right) ficar à vista com um pedaço do vizinho; `null` quando ela já está à
|
|
28
|
-
* vista (ou tudo cabe). PURA.
|
|
29
|
-
*/
|
|
30
|
-
export declare function selectTabScrollTarget(left: number, right: number, scrollLeft: number, clientWidth: number, scrollWidth: number): number | null;
|
|
26
|
+
export declare const selectTabsOverflow: typeof selectScrollOverflow;
|
|
27
|
+
export declare const selectTabScrollTarget: typeof selectScrollTarget;
|
|
31
28
|
export declare function SelectTabs({ tabs, value, onChange, end, panelId, className, onKeyDown, ...rest }: SelectTabsProps): import("react").JSX.Element;
|
|
32
29
|
export {};
|
package/dist/SelectTabs.js
CHANGED
|
@@ -1,51 +1,20 @@
|
|
|
1
1
|
import { formatSelectNumber as e, useSelectLocale as t } from "./SelectLocale.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { revealInTrack as n, watchTrackOverflow as r } from "./internal/scrollReveal.js";
|
|
3
|
+
import { useLayoutEffect as i, useRef as a, useState as o } from "react";
|
|
4
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
4
5
|
//#region src/SelectTabs.tsx
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
if (t - n <= 1) return null;
|
|
8
|
-
let r = e > 1, i = e + n < t - 1;
|
|
9
|
-
return r && i ? "both" : r ? "start" : i ? "end" : null;
|
|
10
|
-
}
|
|
11
|
-
function l(e, t, n, r, i) {
|
|
12
|
-
if (i - r <= 1) return null;
|
|
13
|
-
let a = i - r;
|
|
14
|
-
return e < n + s && n > 0 ? Math.max(0, Math.min(a, e - s)) : t > n + r - s && n < a ? Math.max(0, Math.min(a, t + s - r)) : null;
|
|
15
|
-
}
|
|
16
|
-
function u(e, t) {
|
|
17
|
-
var n, r;
|
|
18
|
-
let i = e.querySelector(".select-tab--active");
|
|
19
|
-
if (!i) return;
|
|
20
|
-
let a = i.offsetLeft, o = l(a, a + i.offsetWidth, e.scrollLeft, e.clientWidth, e.scrollWidth);
|
|
21
|
-
if (o === null) return;
|
|
22
|
-
let s = typeof window < "u" && ((n = (r = window).matchMedia) == null ? void 0 : n.call(r, "(prefers-reduced-motion: reduce)").matches);
|
|
23
|
-
t && !s && typeof e.scrollTo == "function" ? e.scrollTo({
|
|
24
|
-
left: o,
|
|
25
|
-
behavior: "smooth"
|
|
26
|
-
}) : e.scrollLeft = o;
|
|
27
|
-
}
|
|
28
|
-
function d({ tabs: s, value: l, onChange: d, end: f, panelId: p, className: m, onKeyDown: h, ...g }) {
|
|
29
|
-
let _ = t(), v = r(null), y = r([]), [b, x] = i({
|
|
6
|
+
function l({ tabs: l, value: u, onChange: d, end: f, panelId: p, className: m, onKeyDown: h, ...g }) {
|
|
7
|
+
let _ = t(), v = a(null), y = a([]), [b, x] = o({
|
|
30
8
|
left: 0,
|
|
31
9
|
width: 0
|
|
32
|
-
}), S =
|
|
33
|
-
|
|
10
|
+
}), S = l.findIndex((e) => e.id === u), C = l.map((e) => e.id).join("\0"), w = a(!1);
|
|
11
|
+
i(() => {
|
|
34
12
|
let e = v.current;
|
|
35
|
-
e && (
|
|
36
|
-
}, [
|
|
13
|
+
e && (n(e, e.querySelector(".select-tab--active"), w.current), w.current = !0);
|
|
14
|
+
}, [u, C]), i(() => {
|
|
37
15
|
let e = v.current;
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
let t = c(e.scrollLeft, e.scrollWidth, e.clientWidth);
|
|
41
|
-
t ? e.setAttribute("data-overflow", t) : e.removeAttribute("data-overflow");
|
|
42
|
-
};
|
|
43
|
-
t(), e.addEventListener("scroll", t, { passive: !0 });
|
|
44
|
-
let n = typeof ResizeObserver < "u" ? new ResizeObserver(t) : null;
|
|
45
|
-
return n == null || n.observe(e), e.querySelectorAll(".select-tab").forEach((e) => n == null ? void 0 : n.observe(e)), () => {
|
|
46
|
-
e.removeEventListener("scroll", t), n == null || n.disconnect();
|
|
47
|
-
};
|
|
48
|
-
}, [s.length, C]), n(() => {
|
|
16
|
+
if (e) return r(e, e.querySelectorAll(".select-tab"));
|
|
17
|
+
}, [l.length, C]), i(() => {
|
|
49
18
|
let e = v.current;
|
|
50
19
|
if (!e) return;
|
|
51
20
|
let t = () => {
|
|
@@ -67,31 +36,31 @@ function d({ tabs: s, value: l, onChange: d, end: f, panelId: p, className: m, o
|
|
|
67
36
|
let n = typeof ResizeObserver < "u" ? new ResizeObserver(t) : null;
|
|
68
37
|
return n == null || n.observe(e), y.current.forEach((e) => e && (n == null ? void 0 : n.observe(e))), () => n == null ? void 0 : n.disconnect();
|
|
69
38
|
}, [
|
|
70
|
-
|
|
71
|
-
|
|
39
|
+
u,
|
|
40
|
+
l.length,
|
|
72
41
|
C
|
|
73
42
|
]);
|
|
74
43
|
let T = (e) => {
|
|
75
44
|
var t;
|
|
76
|
-
if (h == null || h(e), e.defaultPrevented || !
|
|
45
|
+
if (h == null || h(e), e.defaultPrevented || !l.length) return;
|
|
77
46
|
let n = y.current.findIndex((t) => t === e.target);
|
|
78
47
|
if (n < 0) return;
|
|
79
|
-
let r =
|
|
80
|
-
i < 0 || (e.preventDefault(), (t = y.current[i]) == null || t.focus(),
|
|
48
|
+
let r = l.length - 1, i = e.key === "ArrowRight" ? (n + 1) % l.length : e.key === "ArrowLeft" ? (n - 1 + l.length) % l.length : e.key === "Home" ? 0 : e.key === "End" ? r : -1;
|
|
49
|
+
i < 0 || (e.preventDefault(), (t = y.current[i]) == null || t.focus(), l[i].id !== u && d(l[i].id));
|
|
81
50
|
}, E = {
|
|
82
51
|
"--tab-ind-left": `${b.left}px`,
|
|
83
52
|
"--tab-ind-width": `${b.width}px`
|
|
84
53
|
};
|
|
85
|
-
return /* @__PURE__ */
|
|
54
|
+
return /* @__PURE__ */ c("div", {
|
|
86
55
|
...g,
|
|
87
56
|
className: `select-tabs${m ? " " + m : ""}`,
|
|
88
57
|
role: "tablist",
|
|
89
58
|
ref: v,
|
|
90
59
|
style: E,
|
|
91
60
|
onKeyDown: T,
|
|
92
|
-
children: [
|
|
93
|
-
let r = t.id ===
|
|
94
|
-
return /* @__PURE__ */
|
|
61
|
+
children: [l.map((t, n) => {
|
|
62
|
+
let r = t.id === u;
|
|
63
|
+
return /* @__PURE__ */ c("button", {
|
|
95
64
|
ref: (e) => {
|
|
96
65
|
y.current[n] = e;
|
|
97
66
|
},
|
|
@@ -103,24 +72,24 @@ function d({ tabs: s, value: l, onChange: d, end: f, panelId: p, className: m, o
|
|
|
103
72
|
className: `select-tab${r ? " select-tab--active" : ""}`,
|
|
104
73
|
onClick: () => d(t.id),
|
|
105
74
|
children: [
|
|
106
|
-
t.dot && /* @__PURE__ */
|
|
75
|
+
t.dot && /* @__PURE__ */ s("span", {
|
|
107
76
|
className: `select-tab__dot select-tab__dot--${t.dot}`,
|
|
108
77
|
"aria-hidden": "true"
|
|
109
78
|
}),
|
|
110
79
|
t.label,
|
|
111
|
-
t.count !== void 0 && /* @__PURE__ */
|
|
80
|
+
t.count !== void 0 && /* @__PURE__ */ s("span", {
|
|
112
81
|
className: "select-tab__count",
|
|
113
82
|
children: e(t.count, _)
|
|
114
83
|
})
|
|
115
84
|
]
|
|
116
85
|
}, t.id);
|
|
117
|
-
}), f != null && /* @__PURE__ */
|
|
86
|
+
}), f != null && /* @__PURE__ */ s("div", {
|
|
118
87
|
className: "select-tabs__end",
|
|
119
88
|
children: f
|
|
120
89
|
})]
|
|
121
90
|
});
|
|
122
91
|
}
|
|
123
92
|
//#endregion
|
|
124
|
-
export {
|
|
93
|
+
export { l as SelectTabs };
|
|
125
94
|
|
|
126
95
|
//# sourceMappingURL=SelectTabs.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -74,6 +74,8 @@ export { SelectDeadlineBadge, selectDeadlineText, selectDurationText } from './S
|
|
|
74
74
|
export type { SelectDeadlineBadgeProps, SelectDeadlineState } from './SelectDeadlineBadge';
|
|
75
75
|
export { SelectBulkBar } from './SelectBulkBar';
|
|
76
76
|
export type { SelectBulkBarProps } from './SelectBulkBar';
|
|
77
|
+
export { SelectComposerNotice } from './SelectComposerNotice';
|
|
78
|
+
export type { SelectComposerNoticeProps } from './SelectComposerNotice';
|
|
77
79
|
export { SelectPage, SelectPageBackProvider, SelectPageHeader } from './SelectPage';
|
|
78
80
|
export { SelectFormLayout } from './SelectFormLayout';
|
|
79
81
|
export { SelectSkeleton } from './SelectSkeleton';
|