@selectwin/kit 0.1.215 → 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",
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';