@selectwin/kit 0.1.214 → 0.1.216

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.
@@ -12,6 +12,8 @@ type SelectCodeBlockOwnProps = {
12
12
  copyable?: boolean;
13
13
  /** `critical` = o bloco fica sobre um aviso vermelho (a resposta de uma falha). */
14
14
  tone?: 'neutral' | 'critical';
15
+ /** 0.1.216: o nome do botão de copiar (padrão "Copiar"): com vários blocos na tela, diga qual ("Copiar: Node.js"). */
16
+ copyLabel?: string;
15
17
  };
16
18
  export type SelectCodeBlockProps = SelectCodeBlockOwnProps & Omit<ComponentPropsWithoutRef<'div'>, keyof SelectCodeBlockOwnProps>;
17
19
  /** JSON válido → indentado; qualquer outra coisa → como veio. */
@@ -1,51 +1,42 @@
1
1
  /* empty css */
2
- import { CheckIcon as e, CopyIcon as t } from "./icons.js";
3
- import { useSelectMessages as n } from "./SelectLocale.js";
4
- import { SelectIconButton as r } from "./SelectIconButton.js";
5
- import { forwardRef as i, useState as a } from "react";
6
- import { jsx as o, jsxs as s } from "react/jsx-runtime";
2
+ import { SelectCopyButton as e } from "./SelectCopyButton.js";
3
+ import { forwardRef as t } from "react";
4
+ import { jsx as n, jsxs as r } from "react/jsx-runtime";
7
5
  //#region src/SelectCodeBlock.tsx
8
- function c(e) {
6
+ function i(e) {
9
7
  try {
10
8
  return JSON.stringify(JSON.parse(e), null, 2);
11
9
  } catch {
12
10
  return e;
13
11
  }
14
12
  }
15
- var l = i(function({ value: i, label: l, pretty: u = !1, maxHeight: d = 14, copyable: f = !0, tone: p = "neutral", className: m, style: h, ...g }, _) {
16
- let v = n(), [y, b] = a(!1), x = u ? c(i) : i, S = () => {
17
- var e;
18
- (e = navigator.clipboard) == null || e.writeText(x).then(() => {
19
- b(!0), setTimeout(() => b(!1), 1200);
20
- });
21
- };
22
- return /* @__PURE__ */ s("div", {
23
- ref: _,
24
- ...g,
25
- className: `select-codeblock${p === "critical" ? " select-codeblock--critical" : ""}${m ? " " + m : ""}`,
26
- style: h,
27
- children: [l != null && /* @__PURE__ */ o("span", {
13
+ var a = t(function({ value: t, label: a, pretty: o = !1, maxHeight: s = 14, copyable: c = !0, tone: l = "neutral", copyLabel: u, className: d, style: f, ...p }, m) {
14
+ let h = o ? i(t) : t;
15
+ return /* @__PURE__ */ r("div", {
16
+ ref: m,
17
+ ...p,
18
+ className: `select-codeblock${l === "critical" ? " select-codeblock--critical" : ""}${d ? " " + d : ""}`,
19
+ style: f,
20
+ children: [a != null && /* @__PURE__ */ n("span", {
28
21
  className: "select-codeblock__label",
29
- children: l
30
- }), /* @__PURE__ */ s("div", {
22
+ children: a
23
+ }), /* @__PURE__ */ r("div", {
31
24
  className: "select-codeblock__box",
32
- children: [/* @__PURE__ */ o("pre", {
25
+ children: [/* @__PURE__ */ n("pre", {
33
26
  className: "select-codeblock__pre",
34
- style: { maxHeight: `${d}rem` },
35
- children: x
36
- }), f && /* @__PURE__ */ o("span", {
27
+ style: { maxHeight: `${s}rem` },
28
+ children: h
29
+ }), c && /* @__PURE__ */ n("span", {
37
30
  className: "select-codeblock__copy",
38
- children: /* @__PURE__ */ o(r, {
39
- size: "sm",
40
- icon: o(y ? e : t, {}),
41
- label: y ? v.common.copied : v.common.copy,
42
- onClick: S
31
+ children: /* @__PURE__ */ n(e, {
32
+ value: h,
33
+ ...u ? { label: u } : {}
43
34
  })
44
35
  })]
45
36
  })]
46
37
  });
47
38
  });
48
39
  //#endregion
49
- export { l as SelectCodeBlock, c as prettyCode };
40
+ export { a as SelectCodeBlock, i as prettyCode };
50
41
 
51
42
  //# sourceMappingURL=SelectCodeBlock.js.map
@@ -0,0 +1,14 @@
1
+ export interface SelectCopyButtonProps {
2
+ /** O que vai para a área de transferência. */
3
+ value: string;
4
+ /** O nome do botão (e o texto, com `showLabel`). Padrão: "Copiar". */
5
+ label?: string;
6
+ /** O botão com o texto ao lado do ícone, em vez do ícone sozinho. */
7
+ showLabel?: boolean;
8
+ size?: 'sm' | 'md';
9
+ /** Depois de copiar (um aviso de quem usa); a cópia em si é do botão. */
10
+ onCopy?: (value: string) => void;
11
+ disabled?: boolean;
12
+ className?: string;
13
+ }
14
+ export declare function SelectCopyButton({ value, label: labelProp, showLabel, size, onCopy, disabled, className }: SelectCopyButtonProps): import("react").JSX.Element;
@@ -0,0 +1,41 @@
1
+ /* empty css */
2
+ import { SelectButton as e } from "./SelectButton.js";
3
+ import { CheckIcon as t, CopyIcon as n } from "./icons.js";
4
+ import { useSelectMessages as r } from "./SelectLocale.js";
5
+ import { SelectIconButton as i } from "./SelectIconButton.js";
6
+ import { useClipboard as a } from "./internal/clipboard.js";
7
+ import { useRef as o } from "react";
8
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
9
+ //#region src/SelectCopyButton.tsx
10
+ function l({ value: l, label: u, showLabel: d = !1, size: f = "sm", onCopy: p, disabled: m = !1, className: h }) {
11
+ let g = r().common, _ = u ?? g.copy, v = o(null), { state: y, copy: b } = a(), x = async () => {
12
+ await b(l, v.current) && (p == null || p(l));
13
+ }, S = s(y === "copied" ? t : n, {});
14
+ return /* @__PURE__ */ c("span", {
15
+ ref: v,
16
+ className: `select-copybtn${y === "copied" ? " is-copied" : ""}${h ? " " + h : ""}`,
17
+ children: [d ? /* @__PURE__ */ s(e, {
18
+ variant: "secondary",
19
+ size: f,
20
+ inline: !0,
21
+ icon: S,
22
+ onClick: x,
23
+ disabled: m,
24
+ children: y === "copied" ? g.copied : _
25
+ }) : /* @__PURE__ */ s(i, {
26
+ size: f,
27
+ icon: S,
28
+ label: _,
29
+ onClick: x,
30
+ disabled: m
31
+ }), /* @__PURE__ */ s("span", {
32
+ role: "status",
33
+ className: "select-copybtn__status",
34
+ children: y === "copied" ? g.copied : y === "failed" ? g.copyFailed : ""
35
+ })]
36
+ });
37
+ }
38
+ //#endregion
39
+ export { l as SelectCopyButton };
40
+
41
+ //# sourceMappingURL=SelectCopyButton.js.map
@@ -12,6 +12,16 @@ type SelectCopyRowOwnProps = {
12
12
  prose?: boolean;
13
13
  /** Onde cortar quando não cabe: no fim (padrão) ou no começo — para link e id, cuja parte que distingue é o fim. */
14
14
  truncate?: 'end' | 'start';
15
+ /** 0.1.216: o nome do botão de copiar (padrão "Copiar"): com vários na tela, diga o quê. */
16
+ copyLabel?: string;
17
+ /** 0.1.216: o valor inteiro, quebrando a linha onde precisar (sem reticências), na fonte mono. */
18
+ wrap?: boolean;
19
+ /**
20
+ * 0.1.216: o valor fica escondido (pontos) até o olho; o copiar leva o valor de verdade. `secretName` dá o nome para o
21
+ * leitor de tela ("client secret escondido", "Mostrar client secret").
22
+ */
23
+ secret?: boolean;
24
+ secretName?: string;
15
25
  };
16
26
  export type SelectCopyRowProps = SelectCopyRowOwnProps & Omit<ComponentPropsWithoutRef<'div'>, keyof SelectCopyRowOwnProps>;
17
27
  export declare const SelectCopyRow: import('react').ForwardRefExoticComponent<SelectCopyRowOwnProps & Omit<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, keyof SelectCopyRowOwnProps> & import('react').RefAttributes<HTMLDivElement>>;
@@ -1,61 +1,65 @@
1
- import { SelectButton as e } from "./SelectButton.js";
2
- import { safeHref as t } from "./internal/safeHref.js";
3
- import { CheckIcon as n, CopyIcon as r, ExternalLinkIcon as i } from "./icons.js";
4
- import { useSelectMessages as a } from "./SelectLocale.js";
5
- import { SelectIconButton as o } from "./SelectIconButton.js";
1
+ import { safeHref as e } from "./internal/safeHref.js";
2
+ import { ExternalLinkIcon as t, EyeIcon as n, EyeOffIcon as r } from "./icons.js";
3
+ import { useSelectMessages as i } from "./SelectLocale.js";
4
+ import { SelectIconButton as a } from "./SelectIconButton.js";
5
+ import { SelectCopyButton as o } from "./SelectCopyButton.js";
6
6
  import { forwardRef as s, useState as c } from "react";
7
- import { jsx as l, jsxs as u } from "react/jsx-runtime";
7
+ import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
8
8
  //#region src/SelectCopyRow.tsx
9
- var d = s(function({ label: s, value: d, href: f, onCopy: p, prose: m = !1, truncate: h = "end", className: g, ..._ }, v) {
10
- let y = a(), [b, x] = c(!1), S = t(f), C = () => {
11
- navigator.clipboard.writeText(d).then(() => {
12
- x(!0), setTimeout(() => x(!1), 1200), p == null || p(d);
13
- });
14
- };
15
- return /* @__PURE__ */ u("div", {
16
- ref: v,
17
- ..._,
18
- className: `select-copyrow${m ? " select-copyrow--prose" : ""}${h === "start" && !m ? " select-copyrow--truncate-start" : ""}${g ? " " + g : ""}`,
19
- children: [s && /* @__PURE__ */ l("span", {
9
+ var f = s(function({ label: s, value: f, href: p, onCopy: m, prose: h = !1, truncate: g = "end", copyLabel: _, wrap: v = !1, secret: y = !1, secretName: b, className: x, ...S }, C) {
10
+ let w = i(), [T, E] = c(!1), D = e(p), O = b ?? s ?? w.copyable.secret, k = y && !T, A = g === "start" && !h && !v;
11
+ return /* @__PURE__ */ d("div", {
12
+ ref: C,
13
+ ...S,
14
+ className: `select-copyrow${h ? " select-copyrow--prose" : ""}${A ? " select-copyrow--truncate-start" : ""}${v ? " select-copyrow--wrap" : ""}${x ? " " + x : ""}`,
15
+ children: [s && /* @__PURE__ */ u("span", {
20
16
  className: "select-copyrow__label",
21
17
  children: s
22
- }), /* @__PURE__ */ u("div", {
18
+ }), /* @__PURE__ */ d("div", {
23
19
  className: "select-copyrow__value",
24
- children: [/* @__PURE__ */ l("span", {
20
+ children: [/* @__PURE__ */ u("span", {
25
21
  className: "select-copyrow__text",
26
- title: h === "start" && !m ? d : void 0,
27
- children: h === "start" && !m ? /* @__PURE__ */ l("bdi", {
22
+ title: A && !k ? f : void 0,
23
+ children: k ? /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ u("span", {
24
+ "aria-hidden": "true",
25
+ children: "•".repeat(Math.min(32, f.length))
26
+ }), /* @__PURE__ */ u("span", {
27
+ className: "select-copybtn__status",
28
+ children: w.copyable.concealed(O)
29
+ })] }) : A ? /* @__PURE__ */ u("bdi", {
28
30
  dir: "ltr",
29
- children: d
30
- }) : d
31
- }), /* @__PURE__ */ u("div", {
31
+ children: f
32
+ }) : f
33
+ }), /* @__PURE__ */ d("div", {
32
34
  className: "select-copyrow__actions",
33
- children: [S && /* @__PURE__ */ l("a", {
34
- className: "select-iconbtn select-iconbtn--sm",
35
- href: S,
36
- target: "_blank",
37
- rel: "noreferrer",
38
- "aria-label": y.common.open,
39
- title: y.common.open,
40
- children: /* @__PURE__ */ l(i, {})
41
- }), m ? /* @__PURE__ */ l(e, {
42
- variant: "secondary",
43
- size: "sm",
44
- inline: !0,
45
- icon: l(b ? n : r, {}),
46
- onClick: C,
47
- children: b ? y.common.copied : y.common.copy
48
- }) : /* @__PURE__ */ l(o, {
49
- size: "sm",
50
- icon: l(b ? n : r, {}),
51
- label: b ? y.common.copied : y.common.copy,
52
- onClick: C
53
- })]
35
+ children: [
36
+ D && /* @__PURE__ */ u("a", {
37
+ className: "select-iconbtn select-iconbtn--sm",
38
+ href: D,
39
+ target: "_blank",
40
+ rel: "noreferrer",
41
+ "aria-label": w.common.open,
42
+ title: w.common.open,
43
+ children: /* @__PURE__ */ u(t, {})
44
+ }),
45
+ y && /* @__PURE__ */ u(a, {
46
+ size: "sm",
47
+ icon: u(T ? r : n, {}),
48
+ label: T ? w.copyable.conceal(O) : w.copyable.reveal(O),
49
+ onClick: () => E((e) => !e)
50
+ }),
51
+ /* @__PURE__ */ u(o, {
52
+ value: f,
53
+ ..._ ? { label: _ } : {},
54
+ showLabel: h,
55
+ ...m ? { onCopy: m } : {}
56
+ })
57
+ ]
54
58
  })]
55
59
  })]
56
60
  });
57
61
  });
58
62
  //#endregion
59
- export { d as SelectCopyRow };
63
+ export { f as SelectCopyRow };
60
64
 
61
65
  //# sourceMappingURL=SelectCopyRow.js.map
@@ -8,6 +8,8 @@ export interface SelectKitMessages {
8
8
  save: string;
9
9
  copy: string;
10
10
  copied: string;
11
+ /** 0.1.216: a área de transferência recusou (o botão de copiar diz ao leitor de tela). */
12
+ copyFailed: string;
11
13
  open: string;
12
14
  back: string;
13
15
  actions: string;
@@ -60,6 +62,11 @@ export interface SelectKitMessages {
60
62
  copyable: {
61
63
  copyCode: string;
62
64
  copyId: string;
65
+ /** 0.1.216: o valor escondido do SelectCopyRow `secret` (o nome padrão, e o que o olho e o leitor de tela dizem). */
66
+ secret: string;
67
+ reveal: (name: string) => string;
68
+ conceal: (name: string) => string;
69
+ concealed: (name: string) => string;
63
70
  };
64
71
  assistant: {
65
72
  send: string;
@@ -8,6 +8,7 @@ var r = {
8
8
  confirm: "Confirmar",
9
9
  save: "Salvar",
10
10
  copy: "Copiar",
11
+ copyFailed: "Não deu para copiar",
11
12
  copied: "Copiado",
12
13
  open: "Abrir",
13
14
  back: "Voltar",
@@ -58,7 +59,11 @@ var r = {
58
59
  },
59
60
  copyable: {
60
61
  copyCode: "Copiar código",
61
- copyId: "Copiar id"
62
+ copyId: "Copiar id",
63
+ secret: "o segredo",
64
+ reveal: (e) => `Mostrar ${e}`,
65
+ conceal: (e) => `Esconder ${e}`,
66
+ concealed: (e) => `${e} escondido`
62
67
  },
63
68
  assistant: {
64
69
  send: "Enviar",
@@ -96,6 +101,7 @@ var r = {
96
101
  confirm: "Confirm",
97
102
  save: "Save",
98
103
  copy: "Copy",
104
+ copyFailed: "Couldn't copy",
99
105
  copied: "Copied",
100
106
  open: "Open",
101
107
  back: "Back",
@@ -146,7 +152,11 @@ var r = {
146
152
  },
147
153
  copyable: {
148
154
  copyCode: "Copy code",
149
- copyId: "Copy ID"
155
+ copyId: "Copy ID",
156
+ secret: "the secret",
157
+ reveal: (e) => `Show ${e}`,
158
+ conceal: (e) => `Hide ${e}`,
159
+ concealed: (e) => `${e} hidden`
150
160
  },
151
161
  assistant: {
152
162
  send: "Send",
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { SelectPlacement } from './positioning';
3
- export declare function SelectTooltip({ content, children, placement, delay, openOnClick, disabled, }: {
3
+ export declare function SelectTooltip({ content, children, placement, delay, openOnClick, disabled, focusable, }: {
4
4
  content: ReactNode;
5
5
  children: ReactNode;
6
6
  placement?: SelectPlacement;
@@ -12,4 +12,6 @@ export declare function SelectTooltip({ content, children, placement, delay, ope
12
12
  /** Não abre (0.1.188): o gatilho já mostra o mesmo conteúdo noutro lugar (ex.: o painel de páginas do trilho aberto
13
13
  * ao lado do ícone). O embrulho continua no lugar, então o gatilho não remonta nem perde o foco. */
14
14
  disabled?: boolean;
15
+ /** 0.1.215: o embrulho recebe o foco (o filho não é focável): o Tab chega na dica, e ela abre no foco do teclado. */
16
+ focusable?: boolean;
15
17
  }): import("react").JSX.Element;
@@ -14,77 +14,78 @@ function f(e) {
14
14
  return !0;
15
15
  }
16
16
  }
17
- function p({ content: p, children: m, placement: h = "top", delay: g = 250, openOnClick: _ = !1, disabled: v = !1 }) {
18
- let [y, b] = o(!1), [x, S] = o(!1), [C, w] = o(!1), T = !v && (x || y && !C), E = a(null), D = a(null), O = a(null), [k, A] = o(null), j = r(), M = () => {
19
- d() && (O.current && clearTimeout(O.current), O.current = setTimeout(() => b(!0), g));
20
- }, N = () => {
21
- O.current && clearTimeout(O.current), b(!1), w(!1);
17
+ function p({ content: p, children: m, placement: h = "top", delay: g = 250, openOnClick: _ = !1, disabled: v = !1, focusable: y = !1 }) {
18
+ let [b, x] = o(!1), [S, C] = o(!1), [w, T] = o(!1), E = !v && (S || b && !w), D = a(null), O = a(null), k = a(null), [A, j] = o(null), M = r(), N = () => {
19
+ d() && (k.current && clearTimeout(k.current), k.current = setTimeout(() => x(!0), g));
22
20
  }, P = () => {
23
- _ && (O.current && clearTimeout(O.current), T ? (S(!1), b(!1), w(!0)) : S(!0));
21
+ k.current && clearTimeout(k.current), x(!1), T(!1);
22
+ }, F = () => {
23
+ _ && (k.current && clearTimeout(k.current), E ? (C(!1), x(!1), T(!0)) : C(!0));
24
24
  };
25
25
  n(() => () => {
26
- O.current && clearTimeout(O.current);
26
+ k.current && clearTimeout(k.current);
27
27
  }, []);
28
- let F = t(() => {
28
+ let I = t(() => {
29
29
  var t;
30
- let n = ((t = E.current) == null ? void 0 : t.firstElementChild) ?? E.current, r = D.current;
30
+ let n = ((t = D.current) == null ? void 0 : t.firstElementChild) ?? D.current, r = O.current;
31
31
  if (!n || !r) return;
32
32
  let i = e(n.getBoundingClientRect(), {
33
33
  width: r.offsetWidth,
34
34
  height: r.offsetHeight
35
35
  }, h, 6);
36
- A({
36
+ j({
37
37
  top: i.top,
38
38
  left: i.left
39
39
  });
40
40
  }, [h]);
41
41
  return i(() => {
42
- if (!T) {
43
- A(null);
42
+ if (!E) {
43
+ j(null);
44
44
  return;
45
45
  }
46
- F();
47
- }, [T, F]), n(() => {
48
- if (!T) return;
49
- let e = () => F();
46
+ I();
47
+ }, [E, I]), n(() => {
48
+ if (!E) return;
49
+ let e = () => I();
50
50
  return window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
51
51
  window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
52
52
  };
53
- }, [T, F]), n(() => {
54
- if (!T) return;
53
+ }, [E, I]), n(() => {
54
+ if (!E) return;
55
55
  let e = (e) => {
56
- e.key === "Escape" && (S(!1), b(!1));
56
+ e.key === "Escape" && (C(!1), x(!1));
57
57
  };
58
58
  return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
59
- }, [T]), n(() => {
60
- if (!x) return;
59
+ }, [E]), n(() => {
60
+ if (!S) return;
61
61
  let e = (e) => {
62
62
  var t, n;
63
63
  let r = e.target;
64
- (t = E.current) != null && t.contains(r) || (n = D.current) != null && n.contains(r) || (S(!1), b(!1));
64
+ (t = D.current) != null && t.contains(r) || (n = O.current) != null && n.contains(r) || (C(!1), x(!1));
65
65
  };
66
66
  return document.addEventListener("mousedown", e, !0), () => document.removeEventListener("mousedown", e, !0);
67
- }, [x]), /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("span", {
67
+ }, [S]), /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("span", {
68
68
  className: "select-tip__trigger",
69
- ref: E,
70
- onMouseEnter: M,
71
- onMouseLeave: N,
69
+ ref: D,
70
+ onMouseEnter: N,
71
+ onMouseLeave: P,
72
72
  onFocusCapture: (e) => {
73
- f(e.target) && b(!0);
73
+ f(e.target) && x(!0);
74
74
  },
75
- onBlurCapture: N,
76
- onClick: _ ? P : void 0,
77
- "aria-describedby": T ? j : void 0,
75
+ onBlurCapture: P,
76
+ onClick: _ ? F : void 0,
77
+ tabIndex: y ? 0 : void 0,
78
+ "aria-describedby": E ? M : void 0,
78
79
  children: m
79
- }), T && u(/* @__PURE__ */ c("div", {
80
- ref: D,
81
- id: j,
80
+ }), E && u(/* @__PURE__ */ c("div", {
81
+ ref: O,
82
+ id: M,
82
83
  role: "tooltip",
83
- className: `select select-tip${x ? " select-tip--pinned" : ""}`,
84
- style: k ? {
84
+ className: `select select-tip${S ? " select-tip--pinned" : ""}`,
85
+ style: A ? {
85
86
  position: "fixed",
86
- top: k.top,
87
- left: k.left
87
+ top: A.top,
88
+ left: A.left
88
89
  } : {
89
90
  position: "fixed",
90
91
  top: 0,
package/dist/index.d.ts CHANGED
@@ -74,6 +74,9 @@ export { SelectTable, SelectTableRow, SelectTableCell, SelectTableEmpty, SelectU
74
74
  export { SelectMenu, SelectMenuItem, SelectMenuLink, SelectMenuHeading, SelectMenuDivider, SelectMenuButton } from './SelectMenu';
75
75
  export { SelectFilterChip } from './SelectFilterChip';
76
76
  export { SelectCopyRow } from './SelectCopyRow';
77
+ export type { SelectCopyRowProps } from './SelectCopyRow';
78
+ export { SelectCopyButton } from './SelectCopyButton';
79
+ export type { SelectCopyButtonProps } from './SelectCopyButton';
77
80
  export { SelectCodeBlock, prettyCode } from './SelectCodeBlock';
78
81
  export type { SelectCodeBlockProps } from './SelectCodeBlock';
79
82
  export { SelectCopyableId } from './SelectCopyableId';