@selectwin/kit 0.1.247 → 0.1.249

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.
@@ -0,0 +1,16 @@
1
+ import { ComponentPropsWithoutRef, ReactNode } from 'react';
2
+ /** O nível do título de um cartão: do `<h2>` ao `<h6>` (o `<h1>` é o da página). */
3
+ export type SelectHeadingLevel = 2 | 3 | 4 | 5 | 6;
4
+ /** O nível do título deste cartão: o que ele pediu (`headingLevel`), ou o do lugar onde está. */
5
+ export declare function useHeadingLevel(own?: SelectHeadingLevel): SelectHeadingLevel;
6
+ /** Um nível abaixo (o `<h6>` é o último). */
7
+ export declare function nextHeadingLevel(level: SelectHeadingLevel): SelectHeadingLevel;
8
+ /** O que está dentro conta a partir de `level` (o corpo de um cartão titulado, o de um diálogo). */
9
+ export declare function HeadingScope({ level, children }: {
10
+ level: SelectHeadingLevel;
11
+ children: ReactNode;
12
+ }): import("react").JSX.Element;
13
+ /** O título no nível pedido. */
14
+ export declare function SelectHeading({ level, ...props }: {
15
+ level: SelectHeadingLevel;
16
+ } & ComponentPropsWithoutRef<'h2'>): import("react").JSX.Element;
@@ -0,0 +1,25 @@
1
+ import { createContext as e, useContext as t } from "react";
2
+ import { jsx as n } from "react/jsx-runtime";
3
+ //#region src/internal/headingLevel.tsx
4
+ var r = e(2);
5
+ function i(e) {
6
+ let n = t(r);
7
+ return e ?? n;
8
+ }
9
+ function a(e) {
10
+ return e >= 6 ? 6 : e + 1;
11
+ }
12
+ function o({ level: e, children: t }) {
13
+ return /* @__PURE__ */ n(r.Provider, {
14
+ value: e,
15
+ children: t
16
+ });
17
+ }
18
+ function s({ level: e, ...t }) {
19
+ let r = `h${e}`;
20
+ return /* @__PURE__ */ n(r, { ...t });
21
+ }
22
+ //#endregion
23
+ export { o as HeadingScope, s as SelectHeading, a as nextHeadingLevel, i as useHeadingLevel };
24
+
25
+ //# sourceMappingURL=headingLevel.js.map
@@ -1,7 +1,14 @@
1
1
  import { ReactNode } from 'react';
2
+ import { SelectHeadingLevel } from './headingLevel';
2
3
  export interface SelectListChromeProps {
3
4
  /** Faixa 1, à esquerda: o nome da lista. */
4
5
  title?: ReactNode;
6
+ /**
7
+ * O nível do título (`2` = `<h2>`, até `6`). Sem ele, o kit conta (`internal/headingLevel.tsx`): `<h2>` com a lista
8
+ * sozinha na página, `<h3>` no corpo de uma seção ou de um modal com título. Era sempre `<h3>`: a grade logo abaixo
9
+ * do `<h1>` da página pulava um nível (o axe, `heading-order` — achado do Club).
10
+ */
11
+ headingLevel?: SelectHeadingLevel;
5
12
  /** Ajuda contextual: vira o "!" ao lado do título (SelectInfoTip). Precisa de `title`. */
6
13
  help?: ReactNode;
7
14
  /** Linha discreta ABAIXO do título (subtítulo/descrição da lista). */
@@ -29,7 +36,7 @@ export declare function listChromeShape({ title, description, action, filters, t
29
36
  hasTitleRow: boolean;
30
37
  };
31
38
  /** As faixas 1 e 2 — a faixa 3 (o conteúdo) é de quem chama. */
32
- export declare function SelectListChrome({ title, help, description, action, filters, tools, toggle }: SelectListChromeProps): import("react").JSX.Element;
39
+ export declare function SelectListChrome({ title, headingLevel, help, description, action, filters, tools, toggle }: SelectListChromeProps): import("react").JSX.Element;
33
40
  /**
34
41
  * Rodapé da lista. Os campos de cursor (hasPrevious/onPrevious/hasNext/onNext) já dão o
35
42
  * prev/next centrado; `total` + `pageSize` + `page` acrescentam o rótulo de contagem, e
@@ -3,11 +3,12 @@ import { formatSelectNumber as n, useSelectLocale as r, useSelectMessages as i }
3
3
  import { SelectInfoTip as a } from "../SelectInfoTip.js";
4
4
  import { moveInOptions as o, useOptionListFocus as s } from "./optionList.js";
5
5
  import { SelectPopover as c } from "../SelectPopover.js";
6
- import { SelectPagination as l } from "../SelectPagination.js";
7
- import { useRef as u, useState as d } from "react";
8
- import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
6
+ import { SelectHeading as l, useHeadingLevel as u } from "./headingLevel.js";
7
+ import { SelectPagination as d } from "../SelectPagination.js";
8
+ import { useRef as f, useState as p } from "react";
9
+ import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
9
10
  //#region src/internal/listChrome.tsx
10
- function h({ title: e, description: t, action: n, filters: r, tools: i }) {
11
+ function _({ title: e, description: t, action: n, filters: r, tools: i }) {
11
12
  let a = r != null, o = a ? null : i, s = e != null || t != null;
12
13
  return {
13
14
  hasFilters: a,
@@ -16,61 +17,62 @@ function h({ title: e, description: t, action: n, filters: r, tools: i }) {
16
17
  hasTitleRow: s || n != null || o != null
17
18
  };
18
19
  }
19
- function g({ title: e, help: n, description: r, action: i, filters: o, tools: s, toggle: c }) {
20
- let { hasFilters: l, inlineTools: u, hasIdentity: d, hasTitleRow: g } = h({
20
+ function v({ title: e, headingLevel: n, help: r, description: i, action: o, filters: s, tools: c, toggle: d }) {
21
+ let { hasFilters: f, inlineTools: p, hasIdentity: v, hasTitleRow: y } = _({
21
22
  title: e,
22
- description: r,
23
- action: i,
24
- filters: o,
25
- tools: s
26
- });
27
- return /* @__PURE__ */ m(f, { children: [g && /* @__PURE__ */ m("div", {
23
+ description: i,
24
+ action: o,
25
+ filters: s,
26
+ tools: c
27
+ }), b = u(n);
28
+ return /* @__PURE__ */ g(m, { children: [y && /* @__PURE__ */ g("div", {
28
29
  className: "select-table__title",
29
- children: [c ? /* @__PURE__ */ m("button", {
30
+ children: [d ? /* @__PURE__ */ g("button", {
30
31
  type: "button",
31
32
  className: "select-table__toggle",
32
- "aria-expanded": c.open,
33
- "aria-controls": c.controls,
34
- onClick: c.onToggle,
35
- children: [/* @__PURE__ */ m("span", {
33
+ "aria-expanded": d.open,
34
+ "aria-controls": d.controls,
35
+ onClick: d.onToggle,
36
+ children: [/* @__PURE__ */ g("span", {
36
37
  className: "select-table__heading",
37
- children: [e != null && /* @__PURE__ */ p("span", {
38
+ children: [e != null && /* @__PURE__ */ h("span", {
38
39
  className: "select-table__titletext",
39
40
  children: e
40
- }), r != null && /* @__PURE__ */ p("span", {
41
+ }), i != null && /* @__PURE__ */ h("span", {
41
42
  className: "select-table__desc",
42
- children: r
43
+ children: i
43
44
  })]
44
- }), /* @__PURE__ */ p("span", {
45
+ }), /* @__PURE__ */ h("span", {
45
46
  className: "select-table__chevron",
46
47
  "aria-hidden": "true",
47
- children: /* @__PURE__ */ p(t, {})
48
+ children: /* @__PURE__ */ h(t, {})
48
49
  })]
49
- }) : d && /* @__PURE__ */ m("div", {
50
+ }) : v && /* @__PURE__ */ g("div", {
50
51
  className: "select-table__heading",
51
- children: [e != null && /* @__PURE__ */ m("h3", {
52
- className: `select-table__titletext${n == null ? "" : " select-table__titletext--help"}`,
53
- children: [e, n != null && /* @__PURE__ */ p(a, { content: n })]
54
- }), r != null && /* @__PURE__ */ p("p", {
52
+ children: [e != null && /* @__PURE__ */ g(l, {
53
+ level: b,
54
+ className: `select-table__titletext${r == null ? "" : " select-table__titletext--help"}`,
55
+ children: [e, r != null && /* @__PURE__ */ h(a, { content: r })]
56
+ }), i != null && /* @__PURE__ */ h("p", {
55
57
  className: "select-table__desc",
56
- children: r
58
+ children: i
57
59
  })]
58
- }), (i != null || u != null) && /* @__PURE__ */ m("div", {
60
+ }), (o != null || p != null) && /* @__PURE__ */ g("div", {
59
61
  className: "select-table__actions",
60
- children: [i, u]
62
+ children: [o, p]
61
63
  })]
62
- }), l && /* @__PURE__ */ m("div", {
64
+ }), f && /* @__PURE__ */ g("div", {
63
65
  className: "select-table__toolbar",
64
- children: [/* @__PURE__ */ p("div", {
66
+ children: [/* @__PURE__ */ h("div", {
65
67
  className: "select-table__filters",
66
- children: o
67
- }), s != null && /* @__PURE__ */ p("div", {
68
- className: "select-table__tools",
69
68
  children: s
69
+ }), c != null && /* @__PURE__ */ h("div", {
70
+ className: "select-table__tools",
71
+ children: c
70
72
  })]
71
73
  })] });
72
74
  }
73
- function _(e, t, n) {
75
+ function y(e, t, n) {
74
76
  if (!e || e.length === 0) return [];
75
77
  let r = [...e].sort((e, t) => e - t);
76
78
  if (t == null) return r;
@@ -79,63 +81,63 @@ function _(e, t, n) {
79
81
  for (let e of r) if (i.push(e), e >= t) break;
80
82
  return n != null && r.includes(n) && !i.includes(n) && (i.push(n), i.sort((e, t) => e - t)), i;
81
83
  }
82
- function v({ pagination: a, className: f }) {
83
- let h = i().pagination, g = r(), [v, y] = d(!1), b = u(null);
84
- s(v, b);
85
- let x = _(a.pageSizeOptions, a.total, a.pageSize), S = x.length > 1 && a.onPageSizeChange != null;
86
- return !S && !a.hasPrevious && !a.hasNext ? null : /* @__PURE__ */ m("div", {
87
- className: `select-datatable__pagination${f ? " " + f : ""}`,
88
- children: [S && a.onPageSizeChange && /* @__PURE__ */ p("div", {
84
+ function b({ pagination: a, className: l }) {
85
+ let u = i().pagination, m = r(), [_, v] = p(!1), b = f(null);
86
+ s(_, b);
87
+ let x = y(a.pageSizeOptions, a.total, a.pageSize), S = x.length > 1 && a.onPageSizeChange != null;
88
+ return !S && !a.hasPrevious && !a.hasNext ? null : /* @__PURE__ */ g("div", {
89
+ className: `select-datatable__pagination${l ? " " + l : ""}`,
90
+ children: [S && a.onPageSizeChange && /* @__PURE__ */ h("div", {
89
91
  className: "select-datatable__pagesize",
90
- children: /* @__PURE__ */ p(c, {
91
- active: v,
92
- onClose: () => y(!1),
92
+ children: /* @__PURE__ */ h(c, {
93
+ active: _,
94
+ onClose: () => v(!1),
93
95
  placement: "top-start",
94
96
  role: "listbox",
95
- activator: /* @__PURE__ */ m("button", {
97
+ activator: /* @__PURE__ */ g("button", {
96
98
  type: "button",
97
- className: `select-facet${v ? " is-active" : ""}`,
98
- onClick: () => y((e) => !e),
99
- "aria-expanded": v,
99
+ className: `select-facet${_ ? " is-active" : ""}`,
100
+ onClick: () => v((e) => !e),
101
+ "aria-expanded": _,
100
102
  "aria-haspopup": "listbox",
101
- children: [/* @__PURE__ */ p("span", {
103
+ children: [/* @__PURE__ */ h("span", {
102
104
  className: "select-facet__label",
103
- children: h.perPage(a.pageSize == null ? "—" : n(a.pageSize, g))
104
- }), /* @__PURE__ */ p("span", {
105
- className: `select-facet__caret${v ? " is-open" : ""}`,
105
+ children: u.perPage(a.pageSize == null ? "—" : n(a.pageSize, m))
106
+ }), /* @__PURE__ */ h("span", {
107
+ className: `select-facet__caret${_ ? " is-open" : ""}`,
106
108
  "aria-hidden": "true",
107
- children: /* @__PURE__ */ p(t, {})
109
+ children: /* @__PURE__ */ h(t, {})
108
110
  })]
109
111
  }),
110
- children: /* @__PURE__ */ p("div", {
112
+ children: /* @__PURE__ */ h("div", {
111
113
  className: "select-facet__panel",
112
114
  ref: b,
113
115
  onKeyDown: o,
114
- children: /* @__PURE__ */ p("div", {
116
+ children: /* @__PURE__ */ h("div", {
115
117
  className: "select-facet__options",
116
118
  role: "listbox",
117
119
  children: x.map((t) => {
118
120
  let r = t === a.pageSize;
119
- return /* @__PURE__ */ m("button", {
121
+ return /* @__PURE__ */ g("button", {
120
122
  type: "button",
121
123
  role: "option",
122
124
  "aria-selected": r,
123
125
  className: `select-facet__opt${r ? " is-selected" : ""}`,
124
126
  onClick: () => {
125
127
  var e;
126
- (e = a.onPageSizeChange) == null || e.call(a, t), y(!1);
128
+ (e = a.onPageSizeChange) == null || e.call(a, t), v(!1);
127
129
  },
128
- children: [/* @__PURE__ */ p("span", { children: h.perPage(n(t, g)) }), r && /* @__PURE__ */ p("span", {
130
+ children: [/* @__PURE__ */ h("span", { children: u.perPage(n(t, m)) }), r && /* @__PURE__ */ h("span", {
129
131
  className: "select-facet__check",
130
132
  "aria-hidden": "true",
131
- children: /* @__PURE__ */ p(e, {})
133
+ children: /* @__PURE__ */ h(e, {})
132
134
  })]
133
135
  }, t);
134
136
  })
135
137
  })
136
138
  })
137
139
  })
138
- }), /* @__PURE__ */ p(l, {
140
+ }), /* @__PURE__ */ h(d, {
139
141
  page: a.page ?? 1,
140
142
  pageCount: a.pageCount,
141
143
  total: a.total,
@@ -151,6 +153,6 @@ function v({ pagination: a, className: f }) {
151
153
  });
152
154
  }
153
155
  //#endregion
154
- export { g as SelectListChrome, v as SelectListFooter, h as listChromeShape, _ as usablePageSizes };
156
+ export { v as SelectListChrome, b as SelectListFooter, _ as listChromeShape, y as usablePageSizes };
155
157
 
156
158
  //# sourceMappingURL=listChrome.js.map