@selectwin/kit 0.1.257 → 0.1.259

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.
Files changed (67) hide show
  1. package/README.md +75 -0
  2. package/dist/SelectActionBar.d.ts +29 -0
  3. package/dist/SelectActionBar.js +101 -0
  4. package/dist/SelectActionList.d.ts +5 -0
  5. package/dist/SelectActionList.js +55 -39
  6. package/dist/SelectAppFrame.d.ts +8 -2
  7. package/dist/SelectAppFrame.js +124 -119
  8. package/dist/SelectAvatarGroup.d.ts +31 -0
  9. package/dist/SelectAvatarGroup.js +39 -0
  10. package/dist/SelectBadge.d.ts +10 -1
  11. package/dist/SelectBadge.js +26 -12
  12. package/dist/SelectBulkBar.d.ts +21 -0
  13. package/dist/SelectBulkBar.js +40 -0
  14. package/dist/SelectChannelPreview.d.ts +35 -5
  15. package/dist/SelectChannelPreview.js +127 -60
  16. package/dist/SelectColorField.d.ts +1 -5
  17. package/dist/SelectColorField.js +83 -101
  18. package/dist/SelectCombobox.d.ts +5 -0
  19. package/dist/SelectCombobox.js +52 -49
  20. package/dist/SelectDataTable.d.ts +17 -1
  21. package/dist/SelectDataTable.js +100 -90
  22. package/dist/SelectDeadlineBadge.d.ts +32 -0
  23. package/dist/SelectDeadlineBadge.js +73 -0
  24. package/dist/SelectFieldset.d.ts +14 -0
  25. package/dist/SelectFieldset.js +27 -0
  26. package/dist/SelectFilterBar.d.ts +6 -1
  27. package/dist/SelectFilterBar.js +155 -125
  28. package/dist/SelectImageUploadField.d.ts +5 -3
  29. package/dist/SelectImageUploadField.js +26 -26
  30. package/dist/SelectKanban.d.ts +13 -1
  31. package/dist/SelectKanban.js +72 -50
  32. package/dist/SelectListCard.d.ts +27 -1
  33. package/dist/SelectListCard.js +47 -22
  34. package/dist/SelectLocale.d.ts +96 -0
  35. package/dist/SelectLocale.js +733 -521
  36. package/dist/SelectMail.d.ts +9 -1
  37. package/dist/SelectMail.js +234 -207
  38. package/dist/SelectModal.d.ts +10 -4
  39. package/dist/SelectModal.js +158 -137
  40. package/dist/SelectSection.d.ts +4 -4
  41. package/dist/SelectSection.js +77 -8
  42. package/dist/SelectSegmented.d.ts +7 -0
  43. package/dist/SelectSegmented.js +51 -43
  44. package/dist/SelectSideNav.d.ts +2 -1
  45. package/dist/SelectSideNav.js +156 -135
  46. package/dist/SelectSortable.d.ts +47 -1
  47. package/dist/SelectSortable.js +138 -19
  48. package/dist/SelectSteps.d.ts +3 -0
  49. package/dist/SelectSteps.js +42 -31
  50. package/dist/SelectTable.d.ts +13 -1
  51. package/dist/SelectTable.js +88 -79
  52. package/dist/SelectTabs.d.ts +10 -0
  53. package/dist/SelectTabs.js +68 -30
  54. package/dist/SelectTimeline.d.ts +4 -0
  55. package/dist/SelectTimeline.js +20 -9
  56. package/dist/SelectWeekHours.d.ts +64 -0
  57. package/dist/SelectWeekHours.js +338 -0
  58. package/dist/index.d.ts +19 -2
  59. package/dist/index.js +191 -184
  60. package/dist/internal/color.d.ts +15 -0
  61. package/dist/internal/color.js +40 -0
  62. package/dist/internal/navCount.d.ts +21 -0
  63. package/dist/internal/navCount.js +27 -0
  64. package/dist/internal/safeHref.d.ts +7 -0
  65. package/dist/internal/safeHref.js +12 -1
  66. package/dist/style.css +1 -1
  67. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { ComponentPropsWithoutRef, ReactNode } from 'react';
1
+ import { ComponentPropsWithoutRef, FocusEvent, KeyboardEvent, PointerEvent, ReactNode } from 'react';
2
2
  type SelectSortableItemOwnProps = {
3
3
  /** O item que está sendo arrastado: sobe por cima dos outros, com sombra. */
4
4
  dragging?: boolean;
@@ -25,4 +25,50 @@ export declare const SelectDragHandle: import('react').ForwardRefExoticComponent
25
25
  export declare function SelectDragPreview({ children }: {
26
26
  children?: ReactNode;
27
27
  }): import("react").JSX.Element;
28
+ /** 0.1.258: a lista com o item de `from` no lugar `to` (a conta do arrasto e a de quem grava). PURA. */
29
+ export declare function selectSortableOrder<T>(items: readonly T[], from: number, to: number): T[];
30
+ export interface SelectSortableOptions {
31
+ /** Os ids na ordem de agora. */
32
+ ids: readonly string[];
33
+ /** O item de `from` vai para `to` (a tela grava; `selectSortableOrder` faz a conta). */
34
+ onMove: (from: number, to: number) => void;
35
+ /** O nome do item, para a alça e o leitor de tela ("Nome"). Padrão: "item 2". */
36
+ getLabel?: (id: string, index: number) => string;
37
+ /** O eixo da lista: `y` (o padrão, as setas para cima e para baixo) ou `x` (para os lados). */
38
+ axis?: 'y' | 'x';
39
+ /** Nada se move (o só para ler). */
40
+ disabled?: boolean;
41
+ }
42
+ /** O que o `handle(id)` devolve: as props do `SelectDragHandle`. */
43
+ export interface SelectSortableHandleProps {
44
+ ref: (el: HTMLButtonElement | null) => void;
45
+ label: string;
46
+ dragging: boolean;
47
+ disabled?: boolean;
48
+ 'aria-describedby': string;
49
+ 'aria-pressed': boolean;
50
+ onPointerDown: (event: PointerEvent<HTMLButtonElement>) => void;
51
+ onPointerMove: (event: PointerEvent<HTMLButtonElement>) => void;
52
+ onPointerUp: (event: PointerEvent<HTMLButtonElement>) => void;
53
+ onPointerCancel: (event: PointerEvent<HTMLButtonElement>) => void;
54
+ onKeyDown: (event: KeyboardEvent<HTMLButtonElement>) => void;
55
+ onBlur: (event: FocusEvent<HTMLButtonElement>) => void;
56
+ }
57
+ /** O que o `item(id)` devolve: as props do `SelectSortableItem`. */
58
+ export interface SelectSortableItemBinding {
59
+ ref: (el: HTMLDivElement | null) => void;
60
+ dragging: boolean;
61
+ }
62
+ export interface SelectSortable {
63
+ /** Os ids na ordem da prévia (com o item no lugar novo enquanto se move): desenhe nesta ordem. */
64
+ order: string[];
65
+ /** O id do item que se move agora, ou `null`. */
66
+ active: string | null;
67
+ item: (id: string) => SelectSortableItemBinding;
68
+ handle: (id: string) => SelectSortableHandleProps;
69
+ /** As instruções e a região que fala: desenhe uma vez, perto da lista. */
70
+ live: ReactNode;
71
+ }
72
+ /** 0.1.258: a lista que se ordena pelo ponteiro (o mouse e o dedo) e pelo teclado, com os avisos ao leitor de tela. */
73
+ export declare function useSelectSortable({ ids, onMove, getLabel, axis, disabled }: SelectSortableOptions): SelectSortable;
28
74
  export {};
@@ -1,31 +1,150 @@
1
1
  import { GripIcon as e } from "./icons.js";
2
- import { forwardRef as t } from "react";
3
- import { jsx as n, jsxs as r } from "react/jsx-runtime";
2
+ import { useSelectMessages as t } from "./SelectLocale.js";
3
+ import { forwardRef as n, useId as r, useLayoutEffect as i, useRef as a, useState as o } from "react";
4
+ import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
4
5
  //#region src/SelectSortable.tsx
5
- var i = t(function({ dragging: e = !1, ghost: t = !1, className: r, ...i }, a) {
6
- return /* @__PURE__ */ n("div", {
7
- ref: a,
8
- ...i,
9
- className: `select-sortitem${e && !t ? " is-dragging" : ""}${t ? " is-ghost" : ""}${r ? " " + r : ""}`
6
+ var u = n(function({ dragging: e = !1, ghost: t = !1, className: n, ...r }, i) {
7
+ return /* @__PURE__ */ c("div", {
8
+ ref: i,
9
+ ...r,
10
+ className: `select-sortitem${e && !t ? " is-dragging" : ""}${t ? " is-ghost" : ""}${n ? " " + n : ""}`
10
11
  });
11
- }), a = t(function({ dragging: t = !1, variant: r = "inline", label: i = "Arrastar para reordenar", className: a, ...o }, s) {
12
- return /* @__PURE__ */ n("button", {
13
- ref: s,
12
+ }), d = n(function({ dragging: t = !1, variant: n = "inline", label: r = "Arrastar para reordenar", className: i, ...a }, o) {
13
+ return /* @__PURE__ */ c("button", {
14
+ ref: o,
14
15
  type: "button",
15
- "aria-label": i,
16
- title: i,
17
- ...o,
18
- className: `select-draghandle${r === "floating" ? " select-draghandle--floating" : ""}${t ? " is-dragging" : ""}${a ? " " + a : ""}`,
19
- children: /* @__PURE__ */ n(e, {})
16
+ "aria-label": r,
17
+ title: r,
18
+ ...a,
19
+ className: `select-draghandle${n === "floating" ? " select-draghandle--floating" : ""}${t ? " is-dragging" : ""}${i ? " " + i : ""}`,
20
+ children: /* @__PURE__ */ c(e, {})
20
21
  });
21
22
  });
22
- function o({ children: t }) {
23
- return /* @__PURE__ */ r("span", {
23
+ function f({ children: t }) {
24
+ return /* @__PURE__ */ l("span", {
24
25
  className: "select-dragpreview",
25
- children: [/* @__PURE__ */ n(e, {}), t]
26
+ children: [/* @__PURE__ */ c(e, {}), t]
26
27
  });
27
28
  }
29
+ function p(e, t, n) {
30
+ let r = e.slice();
31
+ if (t === n || t < 0 || t >= r.length) return r;
32
+ let [i] = r.splice(t, 1);
33
+ return r.splice(Math.max(0, Math.min(n, r.length)), 0, i), r;
34
+ }
35
+ function m({ ids: e, onMove: n, getLabel: u, axis: d = "y", disabled: f = !1 }) {
36
+ let m = t().sortable, h = r(), g = a(/* @__PURE__ */ new Map()), _ = a(/* @__PURE__ */ new Map()), v = a([]), y = a(null), [b, x] = o(null), [S, C] = o("");
37
+ i(() => {
38
+ let e = y.current;
39
+ if (!e) return;
40
+ y.current = null;
41
+ let t = _.current.get(e);
42
+ t && document.activeElement !== t && t.focus({ preventScroll: !0 });
43
+ });
44
+ let w = e.length, T = b ? e.indexOf(b.id) : -1, E = b && T >= 0 ? b : null, D = E ? p(e, T, E.to) : e.slice(), O = (t) => {
45
+ let n = e.indexOf(t);
46
+ return (u == null ? void 0 : u(t, n)) ?? m.item(n + 1);
47
+ }, k = (e) => {
48
+ if (!E) {
49
+ x(null);
50
+ return;
51
+ }
52
+ let t = O(E.id);
53
+ x(null), E.by === "keyboard" && (y.current = E.id), e && E.to !== T ? (n(T, E.to), C(m.dropped(t, E.to + 1, w))) : e ? E.by === "keyboard" && C(m.dropped(t, T + 1, w)) : C(m.canceled(t, T + 1));
54
+ };
55
+ return {
56
+ order: D,
57
+ active: (E == null ? void 0 : E.id) ?? null,
58
+ item: (e) => ({
59
+ ref: (t) => {
60
+ t ? g.current.set(e, t) : g.current.delete(e);
61
+ },
62
+ dragging: (E == null ? void 0 : E.id) === e
63
+ }),
64
+ handle: (t) => {
65
+ let n = e.indexOf(t), r = (E == null ? void 0 : E.id) === t, i = r && (E == null ? void 0 : E.by) === "keyboard";
66
+ return {
67
+ ref: (e) => {
68
+ e ? _.current.set(t, e) : _.current.delete(t);
69
+ },
70
+ label: m.handle(O(t)),
71
+ dragging: r,
72
+ ...f ? { disabled: !0 } : {},
73
+ "aria-describedby": h,
74
+ "aria-pressed": i,
75
+ onPointerDown: (r) => {
76
+ if (!(f || r.button !== 0 || E)) {
77
+ try {
78
+ var i, a;
79
+ (i = (a = r.currentTarget).setPointerCapture) == null || i.call(a, r.pointerId);
80
+ } catch {}
81
+ v.current = e.map((e) => {
82
+ var t;
83
+ let n = (t = g.current.get(e)) == null ? void 0 : t.getBoundingClientRect();
84
+ return n ? d === "y" ? n.top + n.height / 2 : n.left + n.width / 2 : 0;
85
+ }), x({
86
+ id: t,
87
+ to: n,
88
+ by: "pointer"
89
+ });
90
+ }
91
+ },
92
+ onPointerMove: (e) => {
93
+ if (!r || (E == null ? void 0 : E.by) !== "pointer") return;
94
+ let t = d === "y" ? e.clientY : e.clientX, n = v.current.filter((e, n) => n !== T && e < t).length;
95
+ n !== E.to && x({
96
+ ...E,
97
+ to: n
98
+ });
99
+ },
100
+ onPointerUp: () => {
101
+ r && (E == null ? void 0 : E.by) === "pointer" && k(!0);
102
+ },
103
+ onPointerCancel: () => {
104
+ r && (E == null ? void 0 : E.by) === "pointer" && k(!1);
105
+ },
106
+ onKeyDown: (e) => {
107
+ if (f) return;
108
+ if (e.key === " " || e.key === "Enter") {
109
+ e.preventDefault(), i ? k(!0) : E || (x({
110
+ id: t,
111
+ to: n,
112
+ by: "keyboard"
113
+ }), C(m.grabbed(O(t), n + 1, w)));
114
+ return;
115
+ }
116
+ if (!i || !E) return;
117
+ if (e.key === "Escape") {
118
+ e.preventDefault(), k(!1);
119
+ return;
120
+ }
121
+ let r = d === "y" ? e.key === "ArrowUp" : e.key === "ArrowLeft", a = d === "y" ? e.key === "ArrowDown" : e.key === "ArrowRight";
122
+ if (!r && !a) return;
123
+ e.preventDefault();
124
+ let o = Math.max(0, Math.min(w - 1, E.to + (a ? 1 : -1)));
125
+ o !== E.to && (y.current = t, x({
126
+ ...E,
127
+ to: o
128
+ }), C(m.moved(O(t), o + 1, w)));
129
+ },
130
+ onBlur: () => {
131
+ i && y.current !== t && k(!1);
132
+ }
133
+ };
134
+ },
135
+ live: /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("span", {
136
+ id: h,
137
+ className: "select-visually-hidden",
138
+ children: m.instructions
139
+ }), /* @__PURE__ */ c("span", {
140
+ className: "select-visually-hidden",
141
+ "aria-live": "assertive",
142
+ "aria-atomic": "true",
143
+ children: S
144
+ })] })
145
+ };
146
+ }
28
147
  //#endregion
29
- export { a as SelectDragHandle, o as SelectDragPreview, i as SelectSortableItem };
148
+ export { d as SelectDragHandle, f as SelectDragPreview, u as SelectSortableItem, p as selectSortableOrder, m as useSelectSortable };
30
149
 
31
150
  //# sourceMappingURL=SelectSortable.js.map
@@ -4,11 +4,14 @@ export type SelectStepState = 'done' | 'current' | 'error' | 'pending';
4
4
  /**
5
5
  * Um passo: só o rótulo, ou rótulo + descrição (a descrição só aparece na vertical) + o
6
6
  * `state`, que vence o que sai do `current` (antes = feito, ele = atual, depois = pendente).
7
+ * 0.1.258: `locked` (o cadeado: a etapa automática) e `lockedLabel` (o que o leitor de tela ouve; padrão "automática").
7
8
  */
8
9
  export type SelectStepItem = string | {
9
10
  label: string;
10
11
  description?: string;
11
12
  state?: SelectStepState;
13
+ locked?: boolean;
14
+ lockedLabel?: string;
12
15
  };
13
16
  type SelectStepsOwnProps = {
14
17
  steps: SelectStepItem[];
@@ -1,62 +1,73 @@
1
- import { CheckIcon as e } from "./icons.js";
2
- import { useSelectMessages as t } from "./SelectLocale.js";
3
- import { forwardRef as n } from "react";
4
- import { Fragment as r, jsx as i, jsxs as a } from "react/jsx-runtime";
1
+ import { CheckIcon as e, LockIcon as t } from "./icons.js";
2
+ import { useSelectMessages as n } from "./SelectLocale.js";
3
+ import { forwardRef as r } from "react";
4
+ import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
5
5
  //#region src/SelectSteps.tsx
6
- var o = n(function({ steps: n, current: o, onSelect: s, orientation: c = "horizontal", connected: l = !1, className: u, ...d }, f) {
7
- let p = t(), m = c === "vertical";
8
- return /* @__PURE__ */ i("ol", {
9
- ref: f,
10
- ...d,
11
- className: `select-steps${m ? " select-steps--vertical" : ""}${l && !m ? " select-steps--connected" : ""}${u ? " " + u : ""}`,
12
- children: n.map((t, n) => {
13
- let c = typeof t == "string" ? { label: t } : t, l = c.state ?? (n < o ? "done" : n === o ? "current" : "pending"), u = !!s && n !== o && (l === "done" || l === "error"), d = /* @__PURE__ */ a(r, { children: [/* @__PURE__ */ i("span", {
6
+ var s = r(function({ steps: r, current: s, onSelect: c, orientation: l = "horizontal", connected: u = !1, className: d, ...f }, p) {
7
+ let m = n(), h = l === "vertical";
8
+ return /* @__PURE__ */ a("ol", {
9
+ ref: p,
10
+ ...f,
11
+ className: `select-steps${h ? " select-steps--vertical" : ""}${u && !h ? " select-steps--connected" : ""}${d ? " " + d : ""}`,
12
+ children: r.map((n, r) => {
13
+ let l = typeof n == "string" ? { label: n } : n, u = l.state ?? (r < s ? "done" : r === s ? "current" : "pending"), d = !!c && r !== s && (u === "done" || u === "error"), f = /* @__PURE__ */ o(i, { children: [/* @__PURE__ */ o("span", {
14
14
  className: "select-steps__num",
15
15
  "aria-hidden": "true",
16
- children: l === "done" ? /* @__PURE__ */ i(e, {}) : l === "error" ? "!" : n + 1
17
- }), /* @__PURE__ */ a("span", {
16
+ children: [u === "done" ? /* @__PURE__ */ a(e, {}) : u === "error" ? "!" : r + 1, l.locked ? /* @__PURE__ */ a("span", {
17
+ className: "select-steps__lock",
18
+ children: /* @__PURE__ */ a(t, {})
19
+ }) : null]
20
+ }), /* @__PURE__ */ o("span", {
18
21
  className: "select-steps__text",
19
22
  children: [
20
- /* @__PURE__ */ i("span", {
23
+ /* @__PURE__ */ a("span", {
21
24
  className: "select-steps__label",
22
- children: c.label
25
+ children: l.label
23
26
  }),
24
- l === "error" && /* @__PURE__ */ a("span", {
27
+ l.locked && /* @__PURE__ */ o("span", {
25
28
  className: "select-steps__sr",
26
29
  children: [
27
30
  "(",
28
- p.common.needsAttention,
31
+ l.lockedLabel ?? m.lock.label,
29
32
  ")"
30
33
  ]
31
34
  }),
32
- l === "done" && /* @__PURE__ */ a("span", {
35
+ u === "error" && /* @__PURE__ */ o("span", {
33
36
  className: "select-steps__sr",
34
37
  children: [
35
38
  "(",
36
- p.common.done,
39
+ m.common.needsAttention,
37
40
  ")"
38
41
  ]
39
42
  }),
40
- m && c.description && /* @__PURE__ */ i("span", {
43
+ u === "done" && /* @__PURE__ */ o("span", {
44
+ className: "select-steps__sr",
45
+ children: [
46
+ "(",
47
+ m.common.done,
48
+ ")"
49
+ ]
50
+ }),
51
+ h && l.description && /* @__PURE__ */ a("span", {
41
52
  className: "select-steps__desc",
42
- children: c.description
53
+ children: l.description
43
54
  })
44
55
  ]
45
56
  })] });
46
- return /* @__PURE__ */ i("li", {
47
- className: `select-steps__step select-steps__step--${l === "pending" ? "todo" : l}`,
48
- "aria-current": l === "current" ? "step" : void 0,
49
- children: u ? /* @__PURE__ */ i("button", {
57
+ return /* @__PURE__ */ a("li", {
58
+ className: `select-steps__step select-steps__step--${u === "pending" ? "todo" : u}`,
59
+ "aria-current": u === "current" ? "step" : void 0,
60
+ children: d ? /* @__PURE__ */ a("button", {
50
61
  type: "button",
51
62
  className: "select-steps__btn",
52
- onClick: () => s(n),
53
- children: d
54
- }) : d
55
- }, n);
63
+ onClick: () => c(r),
64
+ children: f
65
+ }) : f
66
+ }, r);
56
67
  })
57
68
  });
58
69
  });
59
70
  //#endregion
60
- export { o as SelectSteps };
71
+ export { s as SelectSteps };
61
72
 
62
73
  //# sourceMappingURL=SelectSteps.js.map
@@ -138,9 +138,21 @@ type SelectTableRowOwnProps = {
138
138
  * chave, o menu) fica cheia.
139
139
  */
140
140
  muted?: boolean;
141
+ /**
142
+ * 0.1.259: o tom da linha (o chamado vencido): a borda da esquerda no tom. A cor não diz sozinha: o estado à vista
143
+ * (o ícone e o texto, o `SelectDeadlineBadge variant="text"`) vai numa célula, e o `toneLabel` o diz ao leitor de tela.
144
+ */
145
+ tone?: SelectTableRowTone;
146
+ /**
147
+ * 0.1.259: o tom em palavras ("Vencido"), para o leitor de tela: entra fora da vista no começo da célula de cabeçalho
148
+ * da linha (`header`), ou da primeira célula sem ela.
149
+ */
150
+ toneLabel?: string;
141
151
  };
142
152
  export type SelectTableRowProps = SelectTableRowOwnProps & Omit<ComponentPropsWithoutRef<'div'>, keyof SelectTableRowOwnProps | 'role'>;
143
- export declare function SelectTableRow({ children, onClick, expanded, nested, current, section, muted, className, ...rest }: SelectTableRowProps): import("react").JSX.Element;
153
+ /** 0.1.259: os tons da linha (a borda da esquerda): o vencido, o perto de vencer, o cumprido e o de informação. */
154
+ export type SelectTableRowTone = 'critical' | 'warning' | 'success' | 'info';
155
+ export declare function SelectTableRow({ children: childrenProp, onClick, expanded, nested, current, section, muted, tone, toneLabel, className, ...rest }: SelectTableRowProps): import("react").JSX.Element;
144
156
  type SelectTableCellOwnProps = {
145
157
  children: ReactNode;
146
158
  align?: 'start' | 'end' | 'center';