@iclips/ui 4.3.0 → 4.4.0
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.
- package/dist/components/ui/data/document-editor.cjs +1 -1
- package/dist/components/ui/data/document-editor.cjs.map +1 -1
- package/dist/components/ui/data/document-editor.js +175 -169
- package/dist/components/ui/data/document-editor.js.map +1 -1
- package/dist/components/ui/forms/number-input.cjs +1 -1
- package/dist/components/ui/forms/number-input.cjs.map +1 -1
- package/dist/components/ui/forms/number-input.js +123 -110
- package/dist/components/ui/forms/number-input.js.map +1 -1
- package/dist/editor.d.cts +9 -1
- package/dist/editor.d.ts +9 -1
- package/package.json +1 -1
|
@@ -1,89 +1,98 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import * as
|
|
4
|
-
import { ChevronUp as
|
|
2
|
+
import { jsxs as B, jsx as u } from "react/jsx-runtime";
|
|
3
|
+
import * as n from "react";
|
|
4
|
+
import { ChevronUp as ie, Plus as oe, ChevronDown as ae, Minus as le } from "lucide-react";
|
|
5
5
|
import { cn as f } from "../utils.js";
|
|
6
|
-
function
|
|
7
|
-
var
|
|
8
|
-
const
|
|
9
|
-
return { group: x, decimal:
|
|
6
|
+
function se(h) {
|
|
7
|
+
var c, D;
|
|
8
|
+
const w = new Intl.NumberFormat(h).formatToParts(11222.3), x = ((c = w.find((d) => d.type === "group")) == null ? void 0 : c.value) ?? "", N = ((D = w.find((d) => d.type === "decimal")) == null ? void 0 : D.value) ?? ".";
|
|
9
|
+
return { group: x, decimal: N };
|
|
10
10
|
}
|
|
11
|
-
const
|
|
11
|
+
const ue = n.forwardRef(
|
|
12
12
|
({
|
|
13
|
-
className:
|
|
14
|
-
inputClassName:
|
|
13
|
+
className: h,
|
|
14
|
+
inputClassName: w,
|
|
15
15
|
containerClassName: x,
|
|
16
|
-
style:
|
|
17
|
-
value:
|
|
18
|
-
defaultValue:
|
|
16
|
+
style: N,
|
|
17
|
+
value: c,
|
|
18
|
+
defaultValue: D = 0,
|
|
19
19
|
onChange: d,
|
|
20
|
-
min:
|
|
21
|
-
max:
|
|
22
|
-
step:
|
|
23
|
-
precision:
|
|
24
|
-
formatOptions:
|
|
20
|
+
min: p = Number.MIN_SAFE_INTEGER,
|
|
21
|
+
max: b = Number.MAX_SAFE_INTEGER,
|
|
22
|
+
step: K = 1,
|
|
23
|
+
precision: U = 0,
|
|
24
|
+
formatOptions: S,
|
|
25
25
|
locale: F = "pt-BR",
|
|
26
|
-
allowMouseWheel:
|
|
27
|
-
clampValueOnBlur:
|
|
28
|
-
keepWithinRange:
|
|
29
|
-
showButtons:
|
|
30
|
-
buttonLayout:
|
|
31
|
-
buttonPosition:
|
|
26
|
+
allowMouseWheel: L = !1,
|
|
27
|
+
clampValueOnBlur: O = !0,
|
|
28
|
+
keepWithinRange: _ = !0,
|
|
29
|
+
showButtons: m = !0,
|
|
30
|
+
buttonLayout: i = "vertical",
|
|
31
|
+
buttonPosition: E = "right",
|
|
32
32
|
disabled: o,
|
|
33
33
|
readOnly: a,
|
|
34
34
|
...l
|
|
35
|
-
},
|
|
36
|
-
const [
|
|
37
|
-
() =>
|
|
35
|
+
}, ee) => {
|
|
36
|
+
const [re, ne] = n.useState(D), [R, g] = n.useState(""), [v, G] = n.useState(!1), M = n.useRef(null), C = n.useRef(!1), V = n.useRef(!1), t = c !== void 0 ? c : re, y = n.useCallback((e) => S ? new Intl.NumberFormat(F, S).format(e) : e.toFixed(U), [S, F, U]), { group: T, decimal: I } = n.useMemo(
|
|
37
|
+
() => se(F),
|
|
38
38
|
[F]
|
|
39
|
-
),
|
|
40
|
-
const r = e.replace(/[^\d,.-]/g, ""), s =
|
|
41
|
-
return isNaN(
|
|
42
|
-
},
|
|
43
|
-
const s = r ?
|
|
44
|
-
|
|
45
|
-
}, [
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}, [t,
|
|
49
|
-
const
|
|
39
|
+
), te = (e) => {
|
|
40
|
+
const r = e.replace(/[^\d,.-]/g, ""), s = T ? r.split(T).join("") : r, A = I === "." ? s : s.replace(I, "."), $ = parseFloat(A);
|
|
41
|
+
return isNaN($) ? 0 : $;
|
|
42
|
+
}, W = (e) => _ ? Math.min(Math.max(e, p), b) : e, k = n.useCallback((e, r = !1) => {
|
|
43
|
+
const s = r ? W(e) : e;
|
|
44
|
+
c === void 0 && ne(s), d && d(s);
|
|
45
|
+
}, [c, d, p, b, _]);
|
|
46
|
+
n.useEffect(() => {
|
|
47
|
+
v || g(y(t));
|
|
48
|
+
}, [t, y, v]);
|
|
49
|
+
const j = () => {
|
|
50
50
|
if (o || a) return;
|
|
51
|
-
const e = t +
|
|
52
|
-
e <=
|
|
53
|
-
},
|
|
51
|
+
const e = t + K;
|
|
52
|
+
e <= b && k(e);
|
|
53
|
+
}, z = () => {
|
|
54
54
|
if (o || a) return;
|
|
55
|
-
const e = t -
|
|
56
|
-
e >=
|
|
57
|
-
},
|
|
55
|
+
const e = t - K;
|
|
56
|
+
e >= p && k(e);
|
|
57
|
+
}, Y = (e) => {
|
|
58
58
|
const s = e.target.value.replace(/[^\d,.-]/g, "");
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
},
|
|
63
|
-
if (
|
|
64
|
-
const r =
|
|
65
|
-
|
|
59
|
+
g(s);
|
|
60
|
+
const A = te(s);
|
|
61
|
+
k(A, !1);
|
|
62
|
+
}, q = (e) => {
|
|
63
|
+
if (G(!1), O) {
|
|
64
|
+
const r = W(t);
|
|
65
|
+
k(r, !1), g(y(r));
|
|
66
66
|
} else
|
|
67
|
-
|
|
67
|
+
g(y(t));
|
|
68
68
|
l.onBlur && l.onBlur(e);
|
|
69
|
-
}, Y = (e) => {
|
|
70
|
-
_(!0);
|
|
71
|
-
const r = k === "." ? t.toString() : t.toString().replace(".", k);
|
|
72
|
-
m(r), e.target.select(), l.onFocus && l.onFocus(e);
|
|
73
69
|
}, H = (e) => {
|
|
74
|
-
|
|
70
|
+
G(!0);
|
|
71
|
+
const r = I === "." ? t.toString() : t.toString().replace(".", I);
|
|
72
|
+
g(r), C.current = !0, l.onFocus && l.onFocus(e);
|
|
73
|
+
};
|
|
74
|
+
n.useLayoutEffect(() => {
|
|
75
|
+
var e;
|
|
76
|
+
!v || !C.current || (C.current = !1, (e = M.current) == null || e.select());
|
|
77
|
+
}, [v, R]);
|
|
78
|
+
const P = () => {
|
|
79
|
+
v || (V.current = !0);
|
|
75
80
|
}, X = (e) => {
|
|
76
|
-
|
|
81
|
+
V.current && (V.current = !1, e.preventDefault());
|
|
82
|
+
}, J = (e) => {
|
|
83
|
+
o || a || (e.key === "ArrowUp" ? (e.preventDefault(), j()) : e.key === "ArrowDown" && (e.preventDefault(), z()), l.onKeyDown && l.onKeyDown(e));
|
|
84
|
+
}, Q = (e) => {
|
|
85
|
+
!L || o || a || !v || (e.preventDefault(), e.deltaY < 0 ? j() : e.deltaY > 0 && z());
|
|
77
86
|
};
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
if (!
|
|
81
|
-
const e = /* @__PURE__ */
|
|
87
|
+
n.useImperativeHandle(ee, () => M.current);
|
|
88
|
+
const Z = () => {
|
|
89
|
+
if (!m) return null;
|
|
90
|
+
const e = /* @__PURE__ */ u(
|
|
82
91
|
"button",
|
|
83
92
|
{
|
|
84
93
|
type: "button",
|
|
85
|
-
onClick:
|
|
86
|
-
disabled: o || a || t >=
|
|
94
|
+
onClick: j,
|
|
95
|
+
disabled: o || a || t >= b,
|
|
87
96
|
tabIndex: -1,
|
|
88
97
|
"aria-label": "Increment",
|
|
89
98
|
className: f(
|
|
@@ -91,18 +100,18 @@ const oe = i.forwardRef(
|
|
|
91
100
|
"hover:bg-muted active:bg-accent",
|
|
92
101
|
"disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent",
|
|
93
102
|
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",
|
|
94
|
-
|
|
95
|
-
|
|
103
|
+
i === "vertical" && "h-4 w-7 rounded-sm",
|
|
104
|
+
i === "horizontal" && "h-9 w-9 rounded-l-md border-r border-input bg-input-background"
|
|
96
105
|
),
|
|
97
|
-
children:
|
|
106
|
+
children: i === "vertical" ? /* @__PURE__ */ u(ie, { className: "h-3 w-3" }) : /* @__PURE__ */ u(oe, { className: "h-4 w-4" })
|
|
98
107
|
},
|
|
99
108
|
"inc"
|
|
100
|
-
), r = /* @__PURE__ */
|
|
109
|
+
), r = /* @__PURE__ */ u(
|
|
101
110
|
"button",
|
|
102
111
|
{
|
|
103
112
|
type: "button",
|
|
104
|
-
onClick:
|
|
105
|
-
disabled: o || a || t <=
|
|
113
|
+
onClick: z,
|
|
114
|
+
disabled: o || a || t <= p,
|
|
106
115
|
tabIndex: -1,
|
|
107
116
|
"aria-label": "Decrement",
|
|
108
117
|
className: f(
|
|
@@ -110,20 +119,20 @@ const oe = i.forwardRef(
|
|
|
110
119
|
"hover:bg-muted active:bg-accent",
|
|
111
120
|
"disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent",
|
|
112
121
|
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",
|
|
113
|
-
|
|
114
|
-
|
|
122
|
+
i === "vertical" && "h-4 w-7 rounded-sm",
|
|
123
|
+
i === "horizontal" && "h-9 w-9 rounded-r-md border-l border-input bg-input-background"
|
|
115
124
|
),
|
|
116
|
-
children:
|
|
125
|
+
children: i === "vertical" ? /* @__PURE__ */ u(ae, { className: "h-3 w-3" }) : /* @__PURE__ */ u(le, { className: "h-4 w-4" })
|
|
117
126
|
},
|
|
118
127
|
"dec"
|
|
119
128
|
);
|
|
120
|
-
if (
|
|
121
|
-
return /* @__PURE__ */
|
|
129
|
+
if (i === "vertical")
|
|
130
|
+
return /* @__PURE__ */ B(
|
|
122
131
|
"div",
|
|
123
132
|
{
|
|
124
133
|
className: f(
|
|
125
134
|
"flex flex-col items-center justify-center gap-[2px] self-stretch px-1 shrink-0 overflow-hidden",
|
|
126
|
-
|
|
135
|
+
E === "right" ? "order-2 border-l border-input rounded-r-md" : "order-[-1] border-r border-input rounded-l-md"
|
|
127
136
|
),
|
|
128
137
|
children: [
|
|
129
138
|
e,
|
|
@@ -131,15 +140,15 @@ const oe = i.forwardRef(
|
|
|
131
140
|
]
|
|
132
141
|
}
|
|
133
142
|
);
|
|
134
|
-
if (
|
|
143
|
+
if (i === "horizontal")
|
|
135
144
|
return [r, e];
|
|
136
145
|
};
|
|
137
|
-
return
|
|
138
|
-
|
|
139
|
-
/* @__PURE__ */
|
|
146
|
+
return i === "horizontal" && m ? /* @__PURE__ */ B("div", { className: f("inline-flex items-center w-full", x), style: N, children: [
|
|
147
|
+
Z(),
|
|
148
|
+
/* @__PURE__ */ u(
|
|
140
149
|
"input",
|
|
141
150
|
{
|
|
142
|
-
ref:
|
|
151
|
+
ref: M,
|
|
143
152
|
type: "text",
|
|
144
153
|
inputMode: "decimal",
|
|
145
154
|
"data-slot": "input",
|
|
@@ -148,36 +157,38 @@ const oe = i.forwardRef(
|
|
|
148
157
|
"focus-visible:relative focus-visible:z-10 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
|
|
149
158
|
"aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
150
159
|
"text-center tabular-nums",
|
|
151
|
-
|
|
160
|
+
h
|
|
152
161
|
),
|
|
153
|
-
value:
|
|
154
|
-
onChange:
|
|
155
|
-
onBlur:
|
|
156
|
-
onFocus:
|
|
157
|
-
|
|
158
|
-
|
|
162
|
+
value: R,
|
|
163
|
+
onChange: Y,
|
|
164
|
+
onBlur: q,
|
|
165
|
+
onFocus: H,
|
|
166
|
+
onMouseDown: P,
|
|
167
|
+
onMouseUp: X,
|
|
168
|
+
onKeyDown: J,
|
|
169
|
+
onWheel: Q,
|
|
159
170
|
disabled: o,
|
|
160
171
|
readOnly: a,
|
|
161
|
-
"aria-valuemin":
|
|
162
|
-
"aria-valuemax":
|
|
172
|
+
"aria-valuemin": p,
|
|
173
|
+
"aria-valuemax": b,
|
|
163
174
|
"aria-valuenow": t,
|
|
164
175
|
role: "spinbutton",
|
|
165
176
|
...l
|
|
166
177
|
}
|
|
167
178
|
)
|
|
168
|
-
] }) : /* @__PURE__ */
|
|
179
|
+
] }) : /* @__PURE__ */ B(
|
|
169
180
|
"div",
|
|
170
181
|
{
|
|
171
182
|
className: f(
|
|
172
183
|
"inline-flex w-full items-stretch",
|
|
173
184
|
x
|
|
174
185
|
),
|
|
175
|
-
style:
|
|
186
|
+
style: N,
|
|
176
187
|
children: [
|
|
177
|
-
/* @__PURE__ */
|
|
188
|
+
/* @__PURE__ */ u(
|
|
178
189
|
"input",
|
|
179
190
|
{
|
|
180
|
-
ref:
|
|
191
|
+
ref: M,
|
|
181
192
|
type: "text",
|
|
182
193
|
inputMode: "decimal",
|
|
183
194
|
"data-slot": "input",
|
|
@@ -186,35 +197,37 @@ const oe = i.forwardRef(
|
|
|
186
197
|
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
|
|
187
198
|
"aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
188
199
|
"tabular-nums",
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
!
|
|
192
|
-
|
|
193
|
-
|
|
200
|
+
m && i === "vertical" && E === "right" && "text-right rounded-r-none border-r-0",
|
|
201
|
+
m && i === "vertical" && E === "left" && "text-left rounded-l-none border-l-0",
|
|
202
|
+
!m && "text-right",
|
|
203
|
+
w,
|
|
204
|
+
h
|
|
194
205
|
),
|
|
195
|
-
value:
|
|
196
|
-
onChange:
|
|
197
|
-
onBlur:
|
|
198
|
-
onFocus:
|
|
199
|
-
|
|
200
|
-
|
|
206
|
+
value: R,
|
|
207
|
+
onChange: Y,
|
|
208
|
+
onBlur: q,
|
|
209
|
+
onFocus: H,
|
|
210
|
+
onMouseDown: P,
|
|
211
|
+
onMouseUp: X,
|
|
212
|
+
onKeyDown: J,
|
|
213
|
+
onWheel: Q,
|
|
201
214
|
disabled: o,
|
|
202
215
|
readOnly: a,
|
|
203
|
-
"aria-valuemin":
|
|
204
|
-
"aria-valuemax":
|
|
216
|
+
"aria-valuemin": p,
|
|
217
|
+
"aria-valuemax": b,
|
|
205
218
|
"aria-valuenow": t,
|
|
206
219
|
role: "spinbutton",
|
|
207
220
|
...l
|
|
208
221
|
}
|
|
209
222
|
),
|
|
210
|
-
|
|
223
|
+
Z()
|
|
211
224
|
]
|
|
212
225
|
}
|
|
213
226
|
);
|
|
214
227
|
}
|
|
215
228
|
);
|
|
216
|
-
|
|
229
|
+
ue.displayName = "NumberInput";
|
|
217
230
|
export {
|
|
218
|
-
|
|
231
|
+
ue as NumberInput
|
|
219
232
|
};
|
|
220
233
|
//# sourceMappingURL=number-input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-input.js","sources":["../../../../src/components/ui/forms/number-input.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Plus, Minus, ChevronUp, ChevronDown } from \"lucide-react\";\nimport { cn } from \"../utils\";\n\nexport interface NumberInputProps extends Omit<React.ComponentProps<\"input\">, \"type\" | \"onChange\" | \"value\"> {\n /**\n * Valor controlado\n */\n value?: number;\n /**\n * Valor padrão inicial\n */\n defaultValue?: number;\n /**\n * Callback quando o valor muda\n */\n onChange?: (value: number) => void;\n /**\n * Valor mínimo permitido\n */\n min?: number;\n /**\n * Valor máximo permitido\n */\n max?: number;\n /**\n * Incremento/decremento\n * @default 1\n */\n step?: number;\n /**\n * Casas decimais para exibição\n * @default 0\n */\n precision?: number;\n /**\n * Opções de formatação Intl.NumberFormat\n */\n formatOptions?: Intl.NumberFormatOptions;\n /**\n * Locale para formatação\n * @default \"pt-BR\"\n */\n locale?: string;\n /**\n * Permite incrementar/decrementar com scroll do mouse\n * @default false\n */\n allowMouseWheel?: boolean;\n /**\n * Ajusta valor dentro dos limites ao perder foco\n * @default true\n */\n clampValueOnBlur?: boolean;\n /**\n * Mantém valor sempre dentro do range\n * @default true\n */\n keepWithinRange?: boolean;\n /**\n * Mostra os botões de incremento/decremento\n * @default true\n */\n showButtons?: boolean;\n /**\n * Layout dos botões\n * @default \"vertical\"\n */\n buttonLayout?: \"vertical\" | \"horizontal\";\n /**\n * Posição dos botões (apenas para layout vertical)\n * @default \"right\"\n */\n buttonPosition?: \"right\" | \"left\";\n /**\n * Classes CSS para o container externo\n */\n containerClassName?: string;\n /**\n * Classes CSS adicionais para o input (não sobrescreva padding/alinhamento)\n */\n inputClassName?: string;\n}\n\n// Descobre o separador de milhar e decimal reais do locale (ex: pt-BR usa \".\" e \",\", en-US usa \",\" e \".\")\nfunction getLocaleSeparators(loc: string): { group: string; decimal: string } {\n const parts = new Intl.NumberFormat(loc).formatToParts(11222.3);\n const group = parts.find((p) => p.type === \"group\")?.value ?? \"\";\n const decimal = parts.find((p) => p.type === \"decimal\")?.value ?? \".\";\n return { group, decimal };\n}\n\nconst NumberInput = React.forwardRef<HTMLInputElement, NumberInputProps>(\n (\n {\n className,\n inputClassName,\n containerClassName,\n style,\n value: controlledValue,\n defaultValue = 0,\n onChange,\n min = Number.MIN_SAFE_INTEGER,\n max = Number.MAX_SAFE_INTEGER,\n step = 1,\n precision = 0,\n formatOptions,\n locale = \"pt-BR\",\n allowMouseWheel = false,\n clampValueOnBlur = true,\n keepWithinRange = true,\n showButtons = true,\n buttonLayout = \"vertical\",\n buttonPosition = \"right\",\n disabled,\n readOnly,\n ...props\n },\n ref\n ) => {\n const [internalValue, setInternalValue] = React.useState<number>(defaultValue);\n const [displayValue, setDisplayValue] = React.useState<string>(\"\");\n const [isFocused, setIsFocused] = React.useState(false);\n const inputRef = React.useRef<HTMLInputElement>(null);\n\n // Usar valor controlado se fornecido, senão usar interno\n const value = controlledValue !== undefined ? controlledValue : internalValue;\n\n // Formata número para exibição\n const formatNumber = React.useCallback((num: number): string => {\n if (formatOptions) {\n return new Intl.NumberFormat(locale, formatOptions).format(num);\n }\n return num.toFixed(precision);\n }, [formatOptions, locale, precision]);\n\n const { group: groupSeparator, decimal: decimalSeparator } = React.useMemo(\n () => getLocaleSeparators(locale),\n [locale]\n );\n\n // Parse string para número, respeitando separador de milhar/decimal do locale\n // (ex: em pt-BR, \"72.000\" deve virar 72000, não 72 — \".\" é milhar, \",\" é decimal)\n const parseValue = (str: string): number => {\n const cleaned = str.replace(/[^\\d,.-]/g, \"\");\n const withoutGroupSeparator = groupSeparator ? cleaned.split(groupSeparator).join(\"\") : cleaned;\n const normalized =\n decimalSeparator === \".\"\n ? withoutGroupSeparator\n : withoutGroupSeparator.replace(decimalSeparator, \".\");\n const parsed = parseFloat(normalized);\n return isNaN(parsed) ? 0 : parsed;\n };\n\n // Clamp value dentro do range\n const clampValue = (val: number): number => {\n if (!keepWithinRange) return val;\n return Math.min(Math.max(val, min), max);\n };\n\n // Atualiza valor\n const updateValue = React.useCallback((newValue: number, shouldClamp = false) => {\n const finalValue = shouldClamp ? clampValue(newValue) : newValue;\n \n if (controlledValue === undefined) {\n setInternalValue(finalValue);\n }\n \n if (onChange) {\n onChange(finalValue);\n }\n }, [controlledValue, onChange, min, max, keepWithinRange]);\n\n // Atualiza display quando valor muda\n React.useEffect(() => {\n if (!isFocused) {\n setDisplayValue(formatNumber(value));\n }\n }, [value, formatNumber, isFocused]);\n\n // Incrementa valor\n const increment = () => {\n if (disabled || readOnly) return;\n const newValue = value + step;\n if (newValue <= max) {\n updateValue(newValue);\n }\n };\n\n // Decrementa valor\n const decrement = () => {\n if (disabled || readOnly) return;\n const newValue = value - step;\n if (newValue >= min) {\n updateValue(newValue);\n }\n };\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const input = e.target.value;\n const cleaned = input.replace(/[^\\d,.-]/g, \"\");\n setDisplayValue(cleaned);\n const parsed = parseValue(cleaned);\n updateValue(parsed, false);\n };\n\n const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {\n setIsFocused(false);\n \n if (clampValueOnBlur) {\n const clamped = clampValue(value);\n updateValue(clamped, false);\n setDisplayValue(formatNumber(clamped));\n } else {\n setDisplayValue(formatNumber(value));\n }\n \n if (props.onBlur) {\n props.onBlur(e);\n }\n };\n\n const handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {\n setIsFocused(true);\n // value.toString() sempre usa \".\" como decimal (JS); ajusta pro separador do locale\n // para ficar consistente com o parseValue ao continuar editando\n const rawValue =\n decimalSeparator === \".\" ? value.toString() : value.toString().replace(\".\", decimalSeparator);\n setDisplayValue(rawValue);\n e.target.select();\n \n if (props.onFocus) {\n props.onFocus(e);\n }\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (disabled || readOnly) return;\n \n if (e.key === \"ArrowUp\") {\n e.preventDefault();\n increment();\n } else if (e.key === \"ArrowDown\") {\n e.preventDefault();\n decrement();\n }\n \n if (props.onKeyDown) {\n props.onKeyDown(e);\n }\n };\n\n const handleWheel = (e: React.WheelEvent<HTMLInputElement>) => {\n if (!allowMouseWheel || disabled || readOnly || !isFocused) return;\n \n e.preventDefault();\n if (e.deltaY < 0) {\n increment();\n } else if (e.deltaY > 0) {\n decrement();\n }\n };\n\n // Combina refs\n React.useImperativeHandle(ref, () => inputRef.current!);\n\n // Renderiza botões baseado no layout\n const renderButtons = () => {\n if (!showButtons) return null;\n\n const incrementButton = (\n <button\n key=\"inc\"\n type=\"button\"\n onClick={increment}\n disabled={disabled || readOnly || value >= max}\n tabIndex={-1}\n aria-label=\"Increment\"\n className={cn(\n \"inline-flex items-center justify-center transition-colors\",\n \"hover:bg-muted active:bg-accent\",\n \"disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1\",\n buttonLayout === \"vertical\" && \"h-4 w-7 rounded-sm\",\n buttonLayout === \"horizontal\" && \"h-9 w-9 rounded-l-md border-r border-input bg-input-background\"\n )}\n >\n {buttonLayout === \"vertical\" ? (\n <ChevronUp className=\"h-3 w-3\" />\n ) : (\n <Plus className=\"h-4 w-4\" />\n )}\n </button>\n );\n\n const decrementButton = (\n <button\n key=\"dec\"\n type=\"button\"\n onClick={decrement}\n disabled={disabled || readOnly || value <= min}\n tabIndex={-1}\n aria-label=\"Decrement\"\n className={cn(\n \"inline-flex items-center justify-center transition-colors\",\n \"hover:bg-muted active:bg-accent\",\n \"disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1\",\n buttonLayout === \"vertical\" && \"h-4 w-7 rounded-sm\",\n buttonLayout === \"horizontal\" && \"h-9 w-9 rounded-r-md border-l border-input bg-input-background\"\n )}\n >\n {buttonLayout === \"vertical\" ? (\n <ChevronDown className=\"h-3 w-3\" />\n ) : (\n <Minus className=\"h-4 w-4\" />\n )}\n </button>\n );\n\n if (buttonLayout === \"vertical\") {\n return (\n <div\n className={cn(\n \"flex flex-col items-center justify-center gap-[2px] self-stretch px-1 shrink-0 overflow-hidden\",\n buttonPosition === \"right\"\n ? \"order-2 border-l border-input rounded-r-md\"\n : \"order-[-1] border-r border-input rounded-l-md\"\n )}\n >\n {incrementButton}\n {decrementButton}\n </div>\n );\n }\n\n if (buttonLayout === \"horizontal\") {\n return [decrementButton, incrementButton];\n }\n\n };\n\n // Layout horizontal tem estrutura diferente\n if (buttonLayout === \"horizontal\" && showButtons) {\n return (\n <div className={cn(\"inline-flex items-center w-full\", containerClassName)} style={style}>\n {renderButtons()}\n <input\n ref={inputRef}\n type=\"text\"\n inputMode=\"decimal\"\n data-slot=\"input\"\n className={cn(\n \"file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground border-input flex h-9 w-full min-w-0 border-y px-3 py-1 text-base bg-input-background transition-[color,box-shadow] outline-none disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\",\n \"focus-visible:relative focus-visible:z-10 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]\",\n \"aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive\",\n \"text-center tabular-nums\",\n className\n )}\n value={displayValue}\n onChange={handleChange}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n onWheel={handleWheel}\n disabled={disabled}\n readOnly={readOnly}\n aria-valuemin={min}\n aria-valuemax={max}\n aria-valuenow={value}\n role=\"spinbutton\"\n {...props}\n />\n </div>\n );\n }\n\n // Layout vertical (padrão)\n return (\n <div\n className={cn(\n \"inline-flex w-full items-stretch\",\n containerClassName\n )}\n style={style}\n >\n <input\n ref={inputRef}\n type=\"text\"\n inputMode=\"decimal\"\n data-slot=\"input\"\n className={cn(\n \"file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground border-input flex h-9 w-full min-w-0 rounded-md border px-3 py-1 text-base bg-input-background transition-[color,box-shadow] outline-none disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\",\n \"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]\",\n \"aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive\",\n \"tabular-nums\",\n showButtons && buttonLayout === \"vertical\" && buttonPosition === \"right\" && \"text-right rounded-r-none border-r-0\",\n showButtons && buttonLayout === \"vertical\" && buttonPosition === \"left\" && \"text-left rounded-l-none border-l-0\",\n !showButtons && \"text-right\",\n inputClassName,\n className\n )}\n value={displayValue}\n onChange={handleChange}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n onWheel={handleWheel}\n disabled={disabled}\n readOnly={readOnly}\n aria-valuemin={min}\n aria-valuemax={max}\n aria-valuenow={value}\n role=\"spinbutton\"\n {...props}\n />\n {renderButtons()}\n </div>\n );\n }\n);\n\nNumberInput.displayName = \"NumberInput\";\n\nexport { NumberInput };\n"],"names":["getLocaleSeparators","loc","parts","group","_a","p","decimal","_b","NumberInput","React","className","inputClassName","containerClassName","style","controlledValue","defaultValue","onChange","min","max","step","precision","formatOptions","locale","allowMouseWheel","clampValueOnBlur","keepWithinRange","showButtons","buttonLayout","buttonPosition","disabled","readOnly","props","ref","internalValue","setInternalValue","displayValue","setDisplayValue","isFocused","setIsFocused","inputRef","value","formatNumber","num","groupSeparator","decimalSeparator","parseValue","str","cleaned","withoutGroupSeparator","normalized","parsed","clampValue","val","updateValue","newValue","shouldClamp","finalValue","increment","decrement","handleChange","handleBlur","clamped","handleFocus","rawValue","handleKeyDown","handleWheel","renderButtons","incrementButton","jsx","cn","ChevronUp","Plus","decrementButton","ChevronDown","Minus","jsxs"],"mappings":";;;;;AAuFA,SAASA,GAAoBC,GAAiD;;AAC5E,QAAMC,IAAQ,IAAI,KAAK,aAAaD,CAAG,EAAE,cAAc,OAAO,GACxDE,MAAQC,IAAAF,EAAM,KAAK,CAACG,MAAMA,EAAE,SAAS,OAAO,MAApC,gBAAAD,EAAuC,UAAS,IACxDE,MAAUC,IAAAL,EAAM,KAAK,CAACG,MAAMA,EAAE,SAAS,SAAS,MAAtC,gBAAAE,EAAyC,UAAS;AAClE,SAAO,EAAE,OAAAJ,GAAO,SAAAG,EAAA;AAClB;AAEA,MAAME,KAAcC,EAAM;AAAA,EACxB,CACE;AAAA,IACE,WAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,OAAAC;AAAA,IACA,OAAOC;AAAA,IACP,cAAAC,IAAe;AAAA,IACf,UAAAC;AAAA,IACA,KAAAC,IAAM,OAAO;AAAA,IACb,KAAAC,IAAM,OAAO;AAAA,IACb,MAAAC,IAAO;AAAA,IACP,WAAAC,IAAY;AAAA,IACZ,eAAAC;AAAA,IACA,QAAAC,IAAS;AAAA,IACT,iBAAAC,IAAkB;AAAA,IAClB,kBAAAC,IAAmB;AAAA,IACnB,iBAAAC,IAAkB;AAAA,IAClB,aAAAC,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C;AAAA,YAAA;AAAA,cACC,KAAK7B;AAAA,cACL,MAAK;AAAA,cACL,WAAU;AAAA,cACV,aAAU;AAAA,cACV,WAAW8B;AAAA,gBACT;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA3C,KAAeC,MAAiB,cAAcC,MAAmB,WAAW;AAAA,gBAC5EF,KAAeC,MAAiB,cAAcC,MAAmB,UAAU;AAAA,gBAC3E,CAACF,KAAe;AAAA,gBAChBf;AAAA,gBACAD;AAAA,cAAA;AAAA,cAEF,OAAOyB;AAAA,cACP,UAAUwB;AAAA,cACV,QAAQC;AAAA,cACR,SAASE;AAAA,cACT,WAAWE;AAAA,cACX,SAASC;AAAA,cACT,UAAApC;AAAA,cACA,UAAAC;AAAA,cACA,iBAAeb;AAAA,cACf,iBAAeC;AAAA,cACf,iBAAesB;AAAA,cACf,MAAK;AAAA,cACJ,GAAGT;AAAA,YAAA;AAAA,UAAA;AAAA,UAELmC,EAAA;AAAA,QAAc;AAAA,MAAA;AAAA,IAAA;AAAA,EAGrB;AACF;AAEA1D,GAAY,cAAc;"}
|
|
1
|
+
{"version":3,"file":"number-input.js","sources":["../../../../src/components/ui/forms/number-input.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Plus, Minus, ChevronUp, ChevronDown } from \"lucide-react\";\nimport { cn } from \"../utils\";\n\nexport interface NumberInputProps extends Omit<React.ComponentProps<\"input\">, \"type\" | \"onChange\" | \"value\"> {\n /**\n * Valor controlado\n */\n value?: number;\n /**\n * Valor padrão inicial\n */\n defaultValue?: number;\n /**\n * Callback quando o valor muda\n */\n onChange?: (value: number) => void;\n /**\n * Valor mínimo permitido\n */\n min?: number;\n /**\n * Valor máximo permitido\n */\n max?: number;\n /**\n * Incremento/decremento\n * @default 1\n */\n step?: number;\n /**\n * Casas decimais para exibição\n * @default 0\n */\n precision?: number;\n /**\n * Opções de formatação Intl.NumberFormat\n */\n formatOptions?: Intl.NumberFormatOptions;\n /**\n * Locale para formatação\n * @default \"pt-BR\"\n */\n locale?: string;\n /**\n * Permite incrementar/decrementar com scroll do mouse\n * @default false\n */\n allowMouseWheel?: boolean;\n /**\n * Ajusta valor dentro dos limites ao perder foco\n * @default true\n */\n clampValueOnBlur?: boolean;\n /**\n * Mantém valor sempre dentro do range\n * @default true\n */\n keepWithinRange?: boolean;\n /**\n * Mostra os botões de incremento/decremento\n * @default true\n */\n showButtons?: boolean;\n /**\n * Layout dos botões\n * @default \"vertical\"\n */\n buttonLayout?: \"vertical\" | \"horizontal\";\n /**\n * Posição dos botões (apenas para layout vertical)\n * @default \"right\"\n */\n buttonPosition?: \"right\" | \"left\";\n /**\n * Classes CSS para o container externo\n */\n containerClassName?: string;\n /**\n * Classes CSS adicionais para o input (não sobrescreva padding/alinhamento)\n */\n inputClassName?: string;\n}\n\n// Descobre o separador de milhar e decimal reais do locale (ex: pt-BR usa \".\" e \",\", en-US usa \",\" e \".\")\nfunction getLocaleSeparators(loc: string): { group: string; decimal: string } {\n const parts = new Intl.NumberFormat(loc).formatToParts(11222.3);\n const group = parts.find((p) => p.type === \"group\")?.value ?? \"\";\n const decimal = parts.find((p) => p.type === \"decimal\")?.value ?? \".\";\n return { group, decimal };\n}\n\nconst NumberInput = React.forwardRef<HTMLInputElement, NumberInputProps>(\n (\n {\n className,\n inputClassName,\n containerClassName,\n style,\n value: controlledValue,\n defaultValue = 0,\n onChange,\n min = Number.MIN_SAFE_INTEGER,\n max = Number.MAX_SAFE_INTEGER,\n step = 1,\n precision = 0,\n formatOptions,\n locale = \"pt-BR\",\n allowMouseWheel = false,\n clampValueOnBlur = true,\n keepWithinRange = true,\n showButtons = true,\n buttonLayout = \"vertical\",\n buttonPosition = \"right\",\n disabled,\n readOnly,\n ...props\n },\n ref\n ) => {\n const [internalValue, setInternalValue] = React.useState<number>(defaultValue);\n const [displayValue, setDisplayValue] = React.useState<string>(\"\");\n const [isFocused, setIsFocused] = React.useState(false);\n const inputRef = React.useRef<HTMLInputElement>(null);\n // Ao focar, o texto exibido troca (formatado → valor cru) e isso desfaz a seleção; ela é refeita depois da troca.\n const selecionarAoFocar = React.useRef(false);\n // O mouseup do clique que deu o foco poria o cursor no ponto clicado (antes do \"0\" num campo vazio).\n const focoPeloClique = React.useRef(false);\n\n // Usar valor controlado se fornecido, senão usar interno\n const value = controlledValue !== undefined ? controlledValue : internalValue;\n\n // Formata número para exibição\n const formatNumber = React.useCallback((num: number): string => {\n if (formatOptions) {\n return new Intl.NumberFormat(locale, formatOptions).format(num);\n }\n return num.toFixed(precision);\n }, [formatOptions, locale, precision]);\n\n const { group: groupSeparator, decimal: decimalSeparator } = React.useMemo(\n () => getLocaleSeparators(locale),\n [locale]\n );\n\n // Parse string para número, respeitando separador de milhar/decimal do locale\n // (ex: em pt-BR, \"72.000\" deve virar 72000, não 72 — \".\" é milhar, \",\" é decimal)\n const parseValue = (str: string): number => {\n const cleaned = str.replace(/[^\\d,.-]/g, \"\");\n const withoutGroupSeparator = groupSeparator ? cleaned.split(groupSeparator).join(\"\") : cleaned;\n const normalized =\n decimalSeparator === \".\"\n ? withoutGroupSeparator\n : withoutGroupSeparator.replace(decimalSeparator, \".\");\n const parsed = parseFloat(normalized);\n return isNaN(parsed) ? 0 : parsed;\n };\n\n // Clamp value dentro do range\n const clampValue = (val: number): number => {\n if (!keepWithinRange) return val;\n return Math.min(Math.max(val, min), max);\n };\n\n // Atualiza valor\n const updateValue = React.useCallback((newValue: number, shouldClamp = false) => {\n const finalValue = shouldClamp ? clampValue(newValue) : newValue;\n \n if (controlledValue === undefined) {\n setInternalValue(finalValue);\n }\n \n if (onChange) {\n onChange(finalValue);\n }\n }, [controlledValue, onChange, min, max, keepWithinRange]);\n\n // Atualiza display quando valor muda\n React.useEffect(() => {\n if (!isFocused) {\n setDisplayValue(formatNumber(value));\n }\n }, [value, formatNumber, isFocused]);\n\n // Incrementa valor\n const increment = () => {\n if (disabled || readOnly) return;\n const newValue = value + step;\n if (newValue <= max) {\n updateValue(newValue);\n }\n };\n\n // Decrementa valor\n const decrement = () => {\n if (disabled || readOnly) return;\n const newValue = value - step;\n if (newValue >= min) {\n updateValue(newValue);\n }\n };\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const input = e.target.value;\n const cleaned = input.replace(/[^\\d,.-]/g, \"\");\n setDisplayValue(cleaned);\n const parsed = parseValue(cleaned);\n updateValue(parsed, false);\n };\n\n const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {\n setIsFocused(false);\n \n if (clampValueOnBlur) {\n const clamped = clampValue(value);\n updateValue(clamped, false);\n setDisplayValue(formatNumber(clamped));\n } else {\n setDisplayValue(formatNumber(value));\n }\n \n if (props.onBlur) {\n props.onBlur(e);\n }\n };\n\n const handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {\n setIsFocused(true);\n // value.toString() sempre usa \".\" como decimal (JS); ajusta pro separador do locale\n // para ficar consistente com o parseValue ao continuar editando\n const rawValue =\n decimalSeparator === \".\" ? value.toString() : value.toString().replace(\".\", decimalSeparator);\n setDisplayValue(rawValue);\n selecionarAoFocar.current = true;\n \n if (props.onFocus) {\n props.onFocus(e);\n }\n };\n\n React.useLayoutEffect(() => {\n if (!isFocused || !selecionarAoFocar.current) return;\n selecionarAoFocar.current = false;\n inputRef.current?.select();\n }, [isFocused, displayValue]);\n\n const handleMouseDown = () => {\n if (!isFocused) focoPeloClique.current = true;\n };\n\n const handleMouseUp = (e: React.MouseEvent<HTMLInputElement>) => {\n if (!focoPeloClique.current) return;\n focoPeloClique.current = false;\n e.preventDefault();\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (disabled || readOnly) return;\n \n if (e.key === \"ArrowUp\") {\n e.preventDefault();\n increment();\n } else if (e.key === \"ArrowDown\") {\n e.preventDefault();\n decrement();\n }\n \n if (props.onKeyDown) {\n props.onKeyDown(e);\n }\n };\n\n const handleWheel = (e: React.WheelEvent<HTMLInputElement>) => {\n if (!allowMouseWheel || disabled || readOnly || !isFocused) return;\n \n e.preventDefault();\n if (e.deltaY < 0) {\n increment();\n } else if (e.deltaY > 0) {\n decrement();\n }\n };\n\n // Combina refs\n React.useImperativeHandle(ref, () => inputRef.current!);\n\n // Renderiza botões baseado no layout\n const renderButtons = () => {\n if (!showButtons) return null;\n\n const incrementButton = (\n <button\n key=\"inc\"\n type=\"button\"\n onClick={increment}\n disabled={disabled || readOnly || value >= max}\n tabIndex={-1}\n aria-label=\"Increment\"\n className={cn(\n \"inline-flex items-center justify-center transition-colors\",\n \"hover:bg-muted active:bg-accent\",\n \"disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1\",\n buttonLayout === \"vertical\" && \"h-4 w-7 rounded-sm\",\n buttonLayout === \"horizontal\" && \"h-9 w-9 rounded-l-md border-r border-input bg-input-background\"\n )}\n >\n {buttonLayout === \"vertical\" ? (\n <ChevronUp className=\"h-3 w-3\" />\n ) : (\n <Plus className=\"h-4 w-4\" />\n )}\n </button>\n );\n\n const decrementButton = (\n <button\n key=\"dec\"\n type=\"button\"\n onClick={decrement}\n disabled={disabled || readOnly || value <= min}\n tabIndex={-1}\n aria-label=\"Decrement\"\n className={cn(\n \"inline-flex items-center justify-center transition-colors\",\n \"hover:bg-muted active:bg-accent\",\n \"disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1\",\n buttonLayout === \"vertical\" && \"h-4 w-7 rounded-sm\",\n buttonLayout === \"horizontal\" && \"h-9 w-9 rounded-r-md border-l border-input bg-input-background\"\n )}\n >\n {buttonLayout === \"vertical\" ? (\n <ChevronDown className=\"h-3 w-3\" />\n ) : (\n <Minus className=\"h-4 w-4\" />\n )}\n </button>\n );\n\n if (buttonLayout === \"vertical\") {\n return (\n <div\n className={cn(\n \"flex flex-col items-center justify-center gap-[2px] self-stretch px-1 shrink-0 overflow-hidden\",\n buttonPosition === \"right\"\n ? \"order-2 border-l border-input rounded-r-md\"\n : \"order-[-1] border-r border-input rounded-l-md\"\n )}\n >\n {incrementButton}\n {decrementButton}\n </div>\n );\n }\n\n if (buttonLayout === \"horizontal\") {\n return [decrementButton, incrementButton];\n }\n\n };\n\n // Layout horizontal tem estrutura diferente\n if (buttonLayout === \"horizontal\" && showButtons) {\n return (\n <div className={cn(\"inline-flex items-center w-full\", containerClassName)} style={style}>\n {renderButtons()}\n <input\n ref={inputRef}\n type=\"text\"\n inputMode=\"decimal\"\n data-slot=\"input\"\n className={cn(\n \"file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground border-input flex h-9 w-full min-w-0 border-y px-3 py-1 text-base bg-input-background transition-[color,box-shadow] outline-none disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\",\n \"focus-visible:relative focus-visible:z-10 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]\",\n \"aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive\",\n \"text-center tabular-nums\",\n className\n )}\n value={displayValue}\n onChange={handleChange}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n onKeyDown={handleKeyDown}\n onWheel={handleWheel}\n disabled={disabled}\n readOnly={readOnly}\n aria-valuemin={min}\n aria-valuemax={max}\n aria-valuenow={value}\n role=\"spinbutton\"\n {...props}\n />\n </div>\n );\n }\n\n // Layout vertical (padrão)\n return (\n <div\n className={cn(\n \"inline-flex w-full items-stretch\",\n containerClassName\n )}\n style={style}\n >\n <input\n ref={inputRef}\n type=\"text\"\n inputMode=\"decimal\"\n data-slot=\"input\"\n className={cn(\n \"file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground border-input flex h-9 w-full min-w-0 rounded-md border px-3 py-1 text-base bg-input-background transition-[color,box-shadow] outline-none disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\",\n \"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]\",\n \"aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive\",\n \"tabular-nums\",\n showButtons && buttonLayout === \"vertical\" && buttonPosition === \"right\" && \"text-right rounded-r-none border-r-0\",\n showButtons && buttonLayout === \"vertical\" && buttonPosition === \"left\" && \"text-left rounded-l-none border-l-0\",\n !showButtons && \"text-right\",\n inputClassName,\n className\n )}\n value={displayValue}\n onChange={handleChange}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n onKeyDown={handleKeyDown}\n onWheel={handleWheel}\n disabled={disabled}\n readOnly={readOnly}\n aria-valuemin={min}\n aria-valuemax={max}\n aria-valuenow={value}\n role=\"spinbutton\"\n {...props}\n />\n {renderButtons()}\n </div>\n );\n }\n);\n\nNumberInput.displayName = \"NumberInput\";\n\nexport { NumberInput };\n"],"names":["getLocaleSeparators","loc","parts","group","_a","p","decimal","_b","NumberInput","React","className","inputClassName","containerClassName","style","controlledValue","defaultValue","onChange","min","max","step","precision","formatOptions","locale","allowMouseWheel","clampValueOnBlur","keepWithinRange","showButtons","buttonLayout","buttonPosition","disabled","readOnly","props","ref","internalValue","setInternalValue","displayValue","setDisplayValue","isFocused","setIsFocused","inputRef","selecionarAoFocar","focoPeloClique","value","formatNumber","num","groupSeparator","decimalSeparator","parseValue","str","cleaned","withoutGroupSeparator","normalized","parsed","clampValue","val","updateValue","newValue","shouldClamp","finalValue","increment","decrement","handleChange","handleBlur","clamped","handleFocus","rawValue","handleMouseDown","handleMouseUp","handleKeyDown","handleWheel","renderButtons","incrementButton","jsx","cn","ChevronUp","Plus","decrementButton","ChevronDown","Minus","jsxs"],"mappings":";;;;;AAuFA,SAASA,GAAoBC,GAAiD;;AAC5E,QAAMC,IAAQ,IAAI,KAAK,aAAaD,CAAG,EAA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,cACV,aAAU;AAAA,cACV,WAAWkC;AAAA,gBACT;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA/C,KAAeC,MAAiB,cAAcC,MAAmB,WAAW;AAAA,gBAC5EF,KAAeC,MAAiB,cAAcC,MAAmB,UAAU;AAAA,gBAC3E,CAACF,KAAe;AAAA,gBAChBf;AAAA,gBACAD;AAAA,cAAA;AAAA,cAEF,OAAOyB;AAAA,cACP,UAAU0B;AAAA,cACV,QAAQC;AAAA,cACR,SAASE;AAAA,cACT,aAAaE;AAAA,cACb,WAAWC;AAAA,cACX,WAAWC;AAAA,cACX,SAASC;AAAA,cACT,UAAAxC;AAAA,cACA,UAAAC;AAAA,cACA,iBAAeb;AAAA,cACf,iBAAeC;AAAA,cACf,iBAAewB;AAAA,cACf,MAAK;AAAA,cACJ,GAAGX;AAAA,YAAA;AAAA,UAAA;AAAA,UAELuC,EAAA;AAAA,QAAc;AAAA,MAAA;AAAA,IAAA;AAAA,EAGrB;AACF;AAEA9D,GAAY,cAAc;"}
|
package/dist/editor.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AnyExtension } from '@tiptap/react';
|
|
2
|
+
import { Editor } from '@tiptap/react';
|
|
2
3
|
import { ForwardRefExoticComponent } from 'react';
|
|
3
4
|
import { JSX } from 'react/jsx-runtime';
|
|
4
5
|
import { RefAttributes } from 'react';
|
|
@@ -94,7 +95,7 @@ export declare interface CommentUser {
|
|
|
94
95
|
role: UserRole;
|
|
95
96
|
}
|
|
96
97
|
|
|
97
|
-
export declare function DocumentEditor({ content, onChange, placeholder, variant, className, readOnly, label, onImageUpload, imageDefaults, imageAcceptedTypes, imageMaxBytes, imageHint, page, }: DocumentEditorProps): JSX.Element | null;
|
|
98
|
+
export declare function DocumentEditor({ content, onChange, placeholder, variant, className, readOnly, label, onImageUpload, imageDefaults, imageAcceptedTypes, imageMaxBytes, imageHint, page, onReady, }: DocumentEditorProps): JSX.Element | null;
|
|
98
99
|
|
|
99
100
|
declare interface DocumentEditorImageDefaults {
|
|
100
101
|
/** Largura, em px CSS, com que uma imagem recém-inserida entra (padrão: 5 cm). */
|
|
@@ -126,11 +127,18 @@ export declare interface DocumentEditorProps {
|
|
|
126
127
|
imageHint?: string;
|
|
127
128
|
/** Só no `full`. Desenha o documento como uma folha. */
|
|
128
129
|
page?: DocumentPage;
|
|
130
|
+
/**
|
|
131
|
+
* Chamado uma vez, com o editor Tiptap, assim que ele existe. Para a tela inserir conteúdo de fora
|
|
132
|
+
* (ex.: um tópico clicado ao lado do editor) ou levar o cursor a um ponto do texto.
|
|
133
|
+
*/
|
|
134
|
+
onReady?: (editor: Editor) => void;
|
|
129
135
|
}
|
|
130
136
|
|
|
131
137
|
/** Formato de folha. Só vale no `variant="full"`; hoje existe apenas A4. */
|
|
132
138
|
declare type DocumentPage = 'a4';
|
|
133
139
|
|
|
140
|
+
export { Editor }
|
|
141
|
+
|
|
134
142
|
export declare function EditorialCalendar(props: BaseCalendarProps): JSX.Element;
|
|
135
143
|
|
|
136
144
|
export declare type EditorVariant = 'simple' | 'full';
|
package/dist/editor.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AnyExtension } from '@tiptap/react';
|
|
2
|
+
import { Editor } from '@tiptap/react';
|
|
2
3
|
import { ForwardRefExoticComponent } from 'react';
|
|
3
4
|
import { JSX } from 'react/jsx-runtime';
|
|
4
5
|
import { RefAttributes } from 'react';
|
|
@@ -94,7 +95,7 @@ export declare interface CommentUser {
|
|
|
94
95
|
role: UserRole;
|
|
95
96
|
}
|
|
96
97
|
|
|
97
|
-
export declare function DocumentEditor({ content, onChange, placeholder, variant, className, readOnly, label, onImageUpload, imageDefaults, imageAcceptedTypes, imageMaxBytes, imageHint, page, }: DocumentEditorProps): JSX.Element | null;
|
|
98
|
+
export declare function DocumentEditor({ content, onChange, placeholder, variant, className, readOnly, label, onImageUpload, imageDefaults, imageAcceptedTypes, imageMaxBytes, imageHint, page, onReady, }: DocumentEditorProps): JSX.Element | null;
|
|
98
99
|
|
|
99
100
|
declare interface DocumentEditorImageDefaults {
|
|
100
101
|
/** Largura, em px CSS, com que uma imagem recém-inserida entra (padrão: 5 cm). */
|
|
@@ -126,11 +127,18 @@ export declare interface DocumentEditorProps {
|
|
|
126
127
|
imageHint?: string;
|
|
127
128
|
/** Só no `full`. Desenha o documento como uma folha. */
|
|
128
129
|
page?: DocumentPage;
|
|
130
|
+
/**
|
|
131
|
+
* Chamado uma vez, com o editor Tiptap, assim que ele existe. Para a tela inserir conteúdo de fora
|
|
132
|
+
* (ex.: um tópico clicado ao lado do editor) ou levar o cursor a um ponto do texto.
|
|
133
|
+
*/
|
|
134
|
+
onReady?: (editor: Editor) => void;
|
|
129
135
|
}
|
|
130
136
|
|
|
131
137
|
/** Formato de folha. Só vale no `variant="full"`; hoje existe apenas A4. */
|
|
132
138
|
declare type DocumentPage = 'a4';
|
|
133
139
|
|
|
140
|
+
export { Editor }
|
|
141
|
+
|
|
134
142
|
export declare function EditorialCalendar(props: BaseCalendarProps): JSX.Element;
|
|
135
143
|
|
|
136
144
|
export declare type EditorVariant = 'simple' | 'full';
|