@selectwin/kit 0.1.225 → 0.1.227

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.
@@ -1,142 +1,150 @@
1
1
  import { CheckIcon as e, ChevronDownIcon as t } from "./icons.js";
2
2
  import { useSelectMessages as n } from "./SelectLocale.js";
3
3
  import { SelectInfoTip as r } from "./SelectInfoTip.js";
4
- import { useSelectReveal as i } from "./internal/useSelectReveal.js";
5
- import { SelectPopover as a } from "./SelectPopover.js";
6
- import { forwardRef as o, useId as s, useMemo as c, useState as l } from "react";
7
- import { jsx as u, jsxs as d } from "react/jsx-runtime";
4
+ import { moveInOptions as i, useOptionListFocus as a } from "./internal/optionList.js";
5
+ import { useSelectReveal as o } from "./internal/useSelectReveal.js";
6
+ import { SelectPopover as s } from "./SelectPopover.js";
7
+ import { forwardRef as c, useId as l, useMemo as u, useRef as d, useState as f } from "react";
8
+ import { jsx as p, jsxs as m } from "react/jsx-runtime";
8
9
  //#region src/SelectCombobox.tsx
9
- function f({ count: e, children: t }) {
10
- let n = e > 0 ? Math.min(.03, .35 / e) : 0, r = i({
10
+ function h({ count: e, children: t }) {
11
+ let n = e > 0 ? Math.min(.03, .35 / e) : 0, r = o({
11
12
  selector: ".select-combobox__option",
12
13
  y: 6,
13
14
  duration: .3,
14
15
  stagger: n
15
16
  });
16
- return /* @__PURE__ */ u("div", {
17
+ return /* @__PURE__ */ p("div", {
17
18
  className: "select-combobox__list",
18
19
  ref: r,
19
20
  children: t
20
21
  });
21
22
  }
22
- var p = o(function({ label: i, value: o, onChange: p, options: m, placeholder: h, searchPlaceholder: g, labelAction: _, help: v, hint: y, error: b, emptyText: x, disabled: S, required: C, size: w = "md", searchable: T = !0, allowCustom: E = !1, customLabel: D, minWidth: O, className: k, style: A, ...j }, M) {
23
- let N = n(), P = h ?? N.common.selectPlaceholder, F = g ?? N.common.searchPlaceholder, I = x ?? N.common.noResults, L = s(), [R, z] = l(!1), [B, V] = l(""), H = m.find((e) => e.value === o), U = H ? H.label : E && o ? o : null, W = c(() => {
24
- let e = B.trim().toLowerCase();
25
- return !T || !e ? m : m.filter((t) => {
23
+ var g = c(function({ label: o, value: c, onChange: g, options: _, placeholder: v, searchPlaceholder: y, labelAction: b, help: x, hint: S, error: C, emptyText: ee, disabled: w, required: T, 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 = v ?? I.common.selectPlaceholder, R = y ?? I.common.searchPlaceholder, z = ee ?? I.common.noResults, B = l(), [V, H] = f(!1), [U, W] = f(""), G = d(null);
25
+ a(V, G);
26
+ let K = _.find((e) => e.value === c), q = K ? K.label : O && c ? c : null, J = u(() => {
27
+ let e = U.trim().toLowerCase();
28
+ return !D || !e ? _ : _.filter((t) => {
26
29
  var n;
27
30
  return t.label.toLowerCase().includes(e) || ((n = t.secondary) == null ? void 0 : n.toLowerCase().includes(e));
28
31
  });
29
32
  }, [
30
- m,
31
- B,
32
- T
33
- ]), G = B.trim(), K = G ? m.find((e) => e.label.toLowerCase() === G.toLowerCase()) : void 0, q = E && T && G !== "" && !K, J = () => {
34
- z(!1), V("");
35
- }, Y = (e) => {
36
- p(e), J();
37
- }, X = b ? `${L}-err` : y ? `${L}-hint` : void 0;
38
- return /* @__PURE__ */ d("div", {
39
- ref: M,
40
- ...j,
41
- style: O ? {
42
- minWidth: O,
43
- ...A
44
- } : A,
45
- className: `select-field${w === "sm" ? " select-field--sm" : ""}${k ? " " + k : ""}`,
33
+ _,
34
+ U,
35
+ D
36
+ ]), Y = U.trim(), X = Y ? _.find((e) => e.label.toLowerCase() === Y.toLowerCase()) : void 0, Z = O && D && Y !== "" && !X, Q = () => {
37
+ H(!1), W("");
38
+ }, $ = (e) => {
39
+ g(e), Q();
40
+ }, te = C ? `${B}-err` : S ? `${B}-hint` : void 0;
41
+ return /* @__PURE__ */ m("div", {
42
+ ref: F,
43
+ ...P,
44
+ style: A ? {
45
+ minWidth: A,
46
+ ...N
47
+ } : N,
48
+ className: `select-field${E === "sm" ? " select-field--sm" : ""}${M ? " " + M : ""}`,
46
49
  children: [
47
- (i || v || _) && /* @__PURE__ */ d("div", {
50
+ (o || x || b) && /* @__PURE__ */ m("div", {
48
51
  className: "select-field__labelrow",
49
- children: [/* @__PURE__ */ d("span", {
52
+ children: [/* @__PURE__ */ m("span", {
50
53
  className: "select-field__labelwrap",
51
- children: [i && /* @__PURE__ */ u("label", {
54
+ children: [o && /* @__PURE__ */ p("label", {
52
55
  className: "select-field__label",
53
- htmlFor: L,
54
- children: i
55
- }), v != null && v !== "" && /* @__PURE__ */ u(r, { content: v })]
56
- }), _]
56
+ htmlFor: B,
57
+ children: o
58
+ }), x != null && x !== "" && /* @__PURE__ */ p(r, { content: x })]
59
+ }), b]
57
60
  }),
58
- /* @__PURE__ */ u("div", {
61
+ /* @__PURE__ */ p("div", {
59
62
  className: "select-combobox",
60
- children: /* @__PURE__ */ u(a, {
61
- active: R,
62
- onClose: J,
63
+ children: /* @__PURE__ */ p(s, {
64
+ active: V,
65
+ onClose: Q,
63
66
  placement: "bottom-start",
64
67
  role: "listbox",
65
68
  matchWidth: !0,
66
- activator: /* @__PURE__ */ d("button", {
67
- id: L,
69
+ activator: /* @__PURE__ */ m("button", {
70
+ id: B,
68
71
  type: "button",
69
- className: `select-combobox__trigger${b ? " select-input--error" : ""}${R ? " is-open" : ""}`,
70
- onClick: () => R ? J() : z(!0),
71
- disabled: S,
72
+ className: `select-combobox__trigger${C ? " select-input--error" : ""}${V ? " is-open" : ""}`,
73
+ onClick: () => V ? Q() : H(!0),
74
+ disabled: w,
72
75
  "aria-haspopup": "listbox",
73
- "aria-expanded": R,
74
- "aria-required": C || void 0,
75
- "aria-describedby": X,
76
- children: [/* @__PURE__ */ u("span", {
77
- className: `select-combobox__value${U == null ? " is-placeholder" : ""}`,
78
- children: U ?? P
79
- }), /* @__PURE__ */ u("span", {
76
+ "aria-label": o ? void 0 : j,
77
+ "data-value": c,
78
+ "aria-expanded": V,
79
+ "aria-required": T || void 0,
80
+ "aria-describedby": te,
81
+ "aria-invalid": C ? !0 : void 0,
82
+ children: [/* @__PURE__ */ p("span", {
83
+ className: `select-combobox__value${q == null ? " is-placeholder" : ""}`,
84
+ children: q ?? L
85
+ }), /* @__PURE__ */ p("span", {
80
86
  className: "select-combobox__caret",
81
87
  "aria-hidden": "true",
82
- children: /* @__PURE__ */ u(t, {})
88
+ children: /* @__PURE__ */ p(t, {})
83
89
  })]
84
90
  }),
85
- children: /* @__PURE__ */ d("div", {
91
+ children: /* @__PURE__ */ m("div", {
86
92
  className: "select-combobox__panel",
87
- children: [T && /* @__PURE__ */ u("div", {
93
+ ref: G,
94
+ onKeyDown: i,
95
+ children: [D && /* @__PURE__ */ p("div", {
88
96
  className: "select-combobox__search",
89
- children: /* @__PURE__ */ u("input", {
97
+ children: /* @__PURE__ */ p("input", {
90
98
  className: "select-combobox__searchinput",
91
99
  type: "text",
92
- value: B,
93
- onChange: (e) => V(e.target.value),
100
+ value: U,
101
+ onChange: (e) => W(e.target.value),
94
102
  onKeyDown: (e) => {
95
- e.key === "Enter" && E && G !== "" && (e.preventDefault(), Y(K ? K.value : G));
103
+ e.key === "Enter" && O && Y !== "" && (e.preventDefault(), $(X ? X.value : Y));
96
104
  },
97
- placeholder: F,
98
- autoFocus: !0
105
+ placeholder: R
99
106
  })
100
- }), /* @__PURE__ */ d(f, {
101
- count: W.length + +!!q,
102
- children: [q && /* @__PURE__ */ u("button", {
107
+ }), /* @__PURE__ */ m(h, {
108
+ count: J.length + +!!Z,
109
+ children: [Z && /* @__PURE__ */ p("button", {
103
110
  type: "button",
104
111
  role: "option",
105
112
  "aria-selected": !1,
106
113
  className: "select-combobox__option select-combobox__option--custom",
107
- onClick: () => Y(G),
108
- children: /* @__PURE__ */ u("span", {
114
+ onClick: () => $(Y),
115
+ children: /* @__PURE__ */ p("span", {
109
116
  className: "select-combobox__optiontext",
110
- children: /* @__PURE__ */ u("span", {
117
+ children: /* @__PURE__ */ p("span", {
111
118
  className: "select-combobox__optionlabel",
112
- children: D ? D(G) : `Usar “${G}”`
119
+ children: k ? k(Y) : `Usar “${Y}”`
113
120
  })
114
121
  })
115
- }), W.length === 0 ? q ? null : /* @__PURE__ */ u("div", {
122
+ }), J.length === 0 ? Z ? null : /* @__PURE__ */ p("div", {
116
123
  className: "select-combobox__empty",
117
- children: I
118
- }) : W.map((t) => {
119
- let n = t.value === o;
120
- return /* @__PURE__ */ d("button", {
124
+ children: z
125
+ }) : J.map((t) => {
126
+ let n = t.value === c;
127
+ return /* @__PURE__ */ m("button", {
121
128
  type: "button",
122
129
  role: "option",
123
130
  "aria-selected": n,
131
+ "data-value": t.value,
124
132
  disabled: t.disabled,
125
133
  className: `select-combobox__option${n ? " is-selected" : ""}`,
126
- onClick: () => Y(t.value),
127
- children: [/* @__PURE__ */ d("span", {
134
+ onClick: () => $(t.value),
135
+ children: [/* @__PURE__ */ m("span", {
128
136
  className: "select-combobox__optiontext",
129
- children: [/* @__PURE__ */ u("span", {
137
+ children: [/* @__PURE__ */ p("span", {
130
138
  className: "select-combobox__optionlabel",
131
139
  children: t.label
132
- }), t.secondary && /* @__PURE__ */ u("span", {
140
+ }), t.secondary && /* @__PURE__ */ p("span", {
133
141
  className: "select-combobox__optionsecondary",
134
142
  children: t.secondary
135
143
  })]
136
- }), n && /* @__PURE__ */ u("span", {
144
+ }), n && /* @__PURE__ */ p("span", {
137
145
  className: "select-combobox__check",
138
146
  "aria-hidden": "true",
139
- children: /* @__PURE__ */ u(e, {})
147
+ children: /* @__PURE__ */ p(e, {})
140
148
  })]
141
149
  }, t.value);
142
150
  })]
@@ -144,19 +152,19 @@ var p = o(function({ label: i, value: o, onChange: p, options: m, placeholder: h
144
152
  })
145
153
  })
146
154
  }),
147
- b ? /* @__PURE__ */ u("p", {
148
- id: `${L}-err`,
155
+ C ? /* @__PURE__ */ p("p", {
156
+ id: `${B}-err`,
149
157
  className: "select-field__error",
150
- children: b
151
- }) : y ? /* @__PURE__ */ u("p", {
152
- id: `${L}-hint`,
158
+ children: C
159
+ }) : S ? /* @__PURE__ */ p("p", {
160
+ id: `${B}-hint`,
153
161
  className: "select-field__hint",
154
- children: y
162
+ children: S
155
163
  }) : null
156
164
  ]
157
165
  });
158
166
  });
159
167
  //#endregion
160
- export { p as SelectCombobox };
168
+ export { g as SelectCombobox };
161
169
 
162
170
  //# sourceMappingURL=SelectCombobox.js.map
@@ -1,9 +1,9 @@
1
1
  import { CheckIcon as e, ChevronDownIcon as t, CloseIcon as n, PlusIcon as r, SearchIcon as i } from "./icons.js";
2
2
  import { useSelectMessages as a } from "./SelectLocale.js";
3
3
  import { SelectField as o } from "./SelectField.js";
4
- import { SelectPopover as s } from "./SelectPopover.js";
5
- import { SelectSearchInput as c } from "./SelectSearchInput.js";
6
- import { moveInOptions as l, useOptionListFocus as u } from "./internal/optionList.js";
4
+ import { moveInOptions as s, useOptionListFocus as c } from "./internal/optionList.js";
5
+ import { SelectPopover as l } from "./SelectPopover.js";
6
+ import { SelectSearchInput as u } from "./SelectSearchInput.js";
7
7
  import { SelectDateField as d } from "./SelectDateField.js";
8
8
  import { formatDateValue as f } from "./internal/dateValue.js";
9
9
  import { forwardRef as p, useEffect as m, useRef as h, useState as g } from "react";
@@ -30,11 +30,11 @@ function x(e, t) {
30
30
  }
31
31
  function S({ filter: n, value: r, onChange: i, open: f, onToggle: p, onClose: S, disabled: C }) {
32
32
  let w = a(), [T, E] = g(""), D = h(null);
33
- u(f && (n.type === "select" || n.type === "multiselect"), D), m(() => {
33
+ c(f && (n.type === "select" || n.type === "multiselect"), D), m(() => {
34
34
  f || E("");
35
35
  }, [f]);
36
36
  let O = r.trim() !== "", k = O ? x(n, r) : null, A = O && !!n.error, j = n.options ?? [], M = j.length > 7, N = M ? j.filter((e) => e.label.toLowerCase().includes(T.trim().toLowerCase())) : j;
37
- return /* @__PURE__ */ v(s, {
37
+ return /* @__PURE__ */ v(l, {
38
38
  active: f,
39
39
  onClose: S,
40
40
  placement: "bottom-start",
@@ -59,10 +59,10 @@ function S({ filter: n, value: r, onChange: i, open: f, onToggle: p, onClose: S,
59
59
  n.type === "multiselect" ? /* @__PURE__ */ v("div", {
60
60
  className: "select-facet__panel",
61
61
  ref: D,
62
- onKeyDown: l,
62
+ onKeyDown: s,
63
63
  children: [M && /* @__PURE__ */ _("div", {
64
64
  className: "select-facet__search",
65
- children: /* @__PURE__ */ _(c, {
65
+ children: /* @__PURE__ */ _(u, {
66
66
  value: T,
67
67
  onChange: E,
68
68
  placeholder: w.filterBar.searchOption
@@ -93,10 +93,10 @@ function S({ filter: n, value: r, onChange: i, open: f, onToggle: p, onClose: S,
93
93
  }) : n.type === "select" ? /* @__PURE__ */ v("div", {
94
94
  className: "select-facet__panel",
95
95
  ref: D,
96
- onKeyDown: l,
96
+ onKeyDown: s,
97
97
  children: [M && /* @__PURE__ */ _("div", {
98
98
  className: "select-facet__search",
99
- children: /* @__PURE__ */ _(c, {
99
+ children: /* @__PURE__ */ _(u, {
100
100
  value: T,
101
101
  onChange: E,
102
102
  placeholder: w.filterBar.searchOption
@@ -165,11 +165,11 @@ function S({ filter: n, value: r, onChange: i, open: f, onToggle: p, onClose: S,
165
165
  ]
166
166
  });
167
167
  }
168
- var C = p(function({ filters: e, values: t, onChange: o, onClearAll: c, search: d, leading: f, disabled: p, className: m, ...y }, b) {
168
+ var C = p(function({ filters: e, values: t, onChange: o, onClearAll: u, search: d, leading: f, disabled: p, className: m, ...y }, b) {
169
169
  let C = a(), [w, T] = g([]), [E, D] = g(null), [O, k] = g(!1), A = h(null);
170
- u(O, A);
170
+ c(O, A);
171
171
  let j = (e) => (t[e.key] ?? "").trim() !== "", M = (e) => !!e.pinned || j(e) || w.includes(e.key), N = e.filter(M), P = e.filter((e) => !M(e)), F = e.filter(j), I = () => {
172
- T([]), D(null), c();
172
+ T([]), D(null), u();
173
173
  }, L = (e) => {
174
174
  T((t) => t.includes(e) ? t : [...t, e]), k(!1), D(e);
175
175
  };
@@ -231,7 +231,7 @@ var C = p(function({ filters: e, values: t, onChange: o, onClearAll: c, search:
231
231
  onClose: () => D((t) => t === e.key ? null : t),
232
232
  disabled: p
233
233
  }, e.key)),
234
- P.length > 0 && /* @__PURE__ */ _(s, {
234
+ P.length > 0 && /* @__PURE__ */ _(l, {
235
235
  active: O,
236
236
  onClose: () => k(!1),
237
237
  placement: "bottom-start",
@@ -251,7 +251,7 @@ var C = p(function({ filters: e, values: t, onChange: o, onClearAll: c, search:
251
251
  className: "select-facet__options",
252
252
  role: "menu",
253
253
  ref: A,
254
- onKeyDown: l,
254
+ onKeyDown: s,
255
255
  children: P.map((e) => /* @__PURE__ */ _("button", {
256
256
  type: "button",
257
257
  role: "menuitem",
@@ -134,6 +134,24 @@ export interface SelectKitMessages {
134
134
  fees: string;
135
135
  netShort: string;
136
136
  };
137
+ /** 0.1.227: a moldura do app — o botão do menu do celular e a busca da barra (SelectAppBar, SelectAppSearch). */
138
+ appFrame: {
139
+ menuOpen: string;
140
+ search: {
141
+ label: string;
142
+ placeholder: string;
143
+ open: string;
144
+ panel: string;
145
+ results: string;
146
+ none: (query: string) => string;
147
+ searching: string;
148
+ keys: {
149
+ move: string;
150
+ open: string;
151
+ close: string;
152
+ };
153
+ };
154
+ };
137
155
  }
138
156
  /** Os dicionários do kit, para quem quer conferir ou montar um texto do mesmo jeito. */
139
157
  export declare const selectKitMessages: Readonly<Record<SelectLocaleCode, SelectKitMessages>>;
@@ -138,6 +138,23 @@ var r = {
138
138
  net: "Valor líquido",
139
139
  fees: "Taxas",
140
140
  netShort: "Líquido"
141
+ },
142
+ appFrame: {
143
+ menuOpen: "Abrir o menu",
144
+ search: {
145
+ label: "Buscar",
146
+ placeholder: "Buscar",
147
+ open: "Buscar",
148
+ panel: "Busca",
149
+ results: "Resultados",
150
+ none: (e) => `Nada encontrado para "${e}".`,
151
+ searching: "Buscando…",
152
+ keys: {
153
+ move: "navegar",
154
+ open: "abrir",
155
+ close: "fechar"
156
+ }
157
+ }
141
158
  }
142
159
  },
143
160
  en: {
@@ -277,6 +294,23 @@ var r = {
277
294
  net: "Net amount",
278
295
  fees: "Fees",
279
296
  netShort: "Net"
297
+ },
298
+ appFrame: {
299
+ menuOpen: "Open the menu",
300
+ search: {
301
+ label: "Search",
302
+ placeholder: "Search",
303
+ open: "Search",
304
+ panel: "Search",
305
+ results: "Results",
306
+ none: (e) => `Nothing found for "${e}".`,
307
+ searching: "Searching…",
308
+ keys: {
309
+ move: "move",
310
+ open: "open",
311
+ close: "close"
312
+ }
313
+ }
280
314
  }
281
315
  }
282
316
  }, i = e(null);
package/dist/index.d.ts CHANGED
@@ -69,6 +69,10 @@ export { SelectSection } from './SelectSection';
69
69
  export { SelectRegions, type SelectRegionsProps } from './SelectRegions';
70
70
  export { SelectTabs } from './SelectTabs';
71
71
  export { SelectSideNav } from './SelectSideNav';
72
+ export { SelectAppBar, SelectAppBarButton, SelectAppBarAccount, SelectAppPages } from './SelectAppBar';
73
+ export type { SelectAppBarProps, SelectAppBarButtonProps, SelectAppBarAccountProps, SelectAppPage } from './SelectAppBar';
74
+ export { SelectAppSearch } from './SelectAppSearch';
75
+ export type { SelectAppSearchItem, SelectAppSearchGroup, SelectAppSearchProps } from './SelectAppSearch';
72
76
  export { SelectSearchInput } from './SelectSearchInput';
73
77
  export { SelectTable, SelectTableRow, SelectTableCell, SelectTableEmpty, SelectUserCell } from './SelectTable';
74
78
  export { SelectMenu, SelectMenuItem, SelectMenuLink, SelectMenuHeading, SelectMenuHeader, SelectMenuRow, SelectMenuDivider, SelectMenuButton, } from './SelectMenu';