@rendra-ui/web 2.4.0 → 2.5.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/README.md +24 -1
- package/dist/base.css +33 -1
- package/dist/{button-C6rjowQi.js → button-BzJgR2gH.js} +86 -21
- package/dist/button-BzJgR2gH.js.map +1 -0
- package/dist/chart.js +61 -15
- package/dist/chart.js.map +1 -1
- package/dist/cli/auditar.js +1 -1
- package/dist/cli/codigos.js +2 -2
- package/dist/cli/executar-auditar.js +1 -1
- package/dist/cli/help.js +1 -1
- package/dist/cli/trocar.js +2 -2
- package/dist/cli/typescript-loader.js +1 -1
- package/dist/{cn-DXDpTGsu.js → cn-Cw7M5kEP.js} +2 -2
- package/dist/{cn-DXDpTGsu.js.map → cn-Cw7M5kEP.js.map} +1 -1
- package/dist/{components-hp7iWioq.js → components-DkpspH9h.js} +2 -2
- package/dist/{components-hp7iWioq.js.map → components-DkpspH9h.js.map} +1 -1
- package/dist/components.css +169 -33
- package/dist/document-viewer.js +6 -6
- package/dist/document-viewer.js.map +1 -1
- package/dist/{empty-state-CdaDLcsB.js → empty-state-Cdb1vkMT.js} +36 -12
- package/dist/{empty-state-CdaDLcsB.js.map → empty-state-Cdb1vkMT.js.map} +1 -1
- package/dist/features-max--5VEt6M7.js +3 -0
- package/dist/index.js +1062 -339
- package/dist/index.js.map +1 -1
- package/dist/motion-context-5BRIQAJm.js +107 -0
- package/dist/motion-context-5BRIQAJm.js.map +1 -0
- package/dist/{rendra-provider-7jUgUHzR.js → rendra-provider-CRe0XdOU.js} +9 -5
- package/dist/rendra-provider-CRe0XdOU.js.map +1 -0
- package/dist/rich-text-editor.js +4 -4
- package/dist/router-bridge.js +5 -4
- package/dist/router-bridge.js.map +1 -1
- package/dist/tokens.css +63 -15
- package/dist/tooltip-BAMSaGbS.js +224 -0
- package/dist/tooltip-BAMSaGbS.js.map +1 -0
- package/dist/types/components/rendra-provider.d.ts +7 -1
- package/dist/types/components/rendra-router-bridge.d.ts +3 -1
- package/dist/types/components/ui/accordion.d.ts +1 -1
- package/dist/types/components/ui/badge.d.ts +1 -1
- package/dist/types/components/ui/button.d.ts +1 -1
- package/dist/types/components/ui/dropdown-menu.d.ts +5 -5
- package/dist/types/components/ui/picker-panel.d.ts +1 -1
- package/dist/types/components/ui/popover.d.ts +3 -3
- package/dist/types/components/ui/radio-group.d.ts +1 -1
- package/dist/types/components/ui/skeleton.d.ts +5 -1
- package/dist/types/components/ui/stat-card.d.ts +1 -1
- package/dist/types/components/ui/table.d.ts +0 -6
- package/dist/types/components/ui/tooltip.d.ts +1 -1
- package/dist/types/hooks/use-reduced-motion.d.ts +3 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/lib/motion/count.d.ts +17 -0
- package/dist/types/lib/motion/features-max.d.ts +1 -0
- package/dist/types/lib/motion/index.d.ts +5 -0
- package/dist/types/lib/motion/motion-context.d.ts +43 -0
- package/dist/types/lib/motion/native-events.d.ts +16 -0
- package/dist/types/lib/motion/presets.d.ts +92 -0
- package/dist/types/lib/motion/reorder.d.ts +7 -0
- package/dist/types/lib/motion/tokens.d.ts +66 -0
- package/dist/types/lib/motion/use-motion-presets.d.ts +8 -0
- package/dist/{use-breakpoint-Dyp-0E_c.js → use-breakpoint-O9eqFmsF.js} +2 -2
- package/dist/{use-breakpoint-Dyp-0E_c.js.map → use-breakpoint-O9eqFmsF.js.map} +1 -1
- package/dist/use-motion-presets-BrkgL8lG.js +401 -0
- package/dist/use-motion-presets-BrkgL8lG.js.map +1 -0
- package/dist/widget-grid.js +3 -3
- package/package.json +3 -1
- package/dist/button-C6rjowQi.js.map +0 -1
- package/dist/rendra-provider-7jUgUHzR.js.map +0 -1
- package/dist/tooltip-bdmbX6vC.js +0 -105
- package/dist/tooltip-bdmbX6vC.js.map +0 -1
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
/*! Rendra Design System v2.5.0 | MIT | © 2026 Bruno Magalhaes | brunomagalhaes.me */
|
|
2
|
+
import { a as getReducedMotion, o as subscribeReducedMotion, r as useMotionMode } from "./motion-context-5BRIQAJm.js";
|
|
3
|
+
import { useMemo, useSyncExternalStore } from "react";
|
|
4
|
+
//#region src/lib/motion/tokens.ts
|
|
5
|
+
/**
|
|
6
|
+
* Reserva das durações, em segundos (SSR, ou variável ausente).
|
|
7
|
+
* `press` e `fast` valem o mesmo (120 ms) com propósitos diferentes: o toque e a saída de overlay.
|
|
8
|
+
*/
|
|
9
|
+
var DURATION = {
|
|
10
|
+
press: .12,
|
|
11
|
+
hover: .15,
|
|
12
|
+
fast: .12,
|
|
13
|
+
base: .2,
|
|
14
|
+
move: .25,
|
|
15
|
+
slow: .32,
|
|
16
|
+
draw: .42,
|
|
17
|
+
pulse: 1
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Reveal: entrada de uso único (dashboard: bloco, cascata, contador e desenho do gráfico), mais
|
|
21
|
+
* lenta que as interações do dia a dia. Reserva em segundos (SSR, ou variável ausente).
|
|
22
|
+
*/
|
|
23
|
+
var REVEAL = {
|
|
24
|
+
enter: .6,
|
|
25
|
+
stagger: .12,
|
|
26
|
+
count: 1.2,
|
|
27
|
+
draw: .9
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Curvas do globals.css (`--rendra-ease-*`). `spring` é a curva "back" (quique): só para a cota
|
|
31
|
+
* rara de encanto. `move` desloca na tela; `drawer` é a curva de gaveta e folha.
|
|
32
|
+
*/
|
|
33
|
+
var EASE = {
|
|
34
|
+
out: [
|
|
35
|
+
.22,
|
|
36
|
+
1,
|
|
37
|
+
.36,
|
|
38
|
+
1
|
|
39
|
+
],
|
|
40
|
+
inOut: [
|
|
41
|
+
.65,
|
|
42
|
+
0,
|
|
43
|
+
.35,
|
|
44
|
+
1
|
|
45
|
+
],
|
|
46
|
+
spring: [
|
|
47
|
+
.34,
|
|
48
|
+
1.56,
|
|
49
|
+
.64,
|
|
50
|
+
1
|
|
51
|
+
],
|
|
52
|
+
move: [
|
|
53
|
+
.77,
|
|
54
|
+
0,
|
|
55
|
+
.175,
|
|
56
|
+
1
|
|
57
|
+
],
|
|
58
|
+
drawer: [
|
|
59
|
+
.32,
|
|
60
|
+
.72,
|
|
61
|
+
0,
|
|
62
|
+
1
|
|
63
|
+
]
|
|
64
|
+
};
|
|
65
|
+
/** Nome da variável CSS de cada curva (`inOut` vira `in-out`). */
|
|
66
|
+
var EASE_VAR = {
|
|
67
|
+
out: "out",
|
|
68
|
+
inOut: "in-out",
|
|
69
|
+
spring: "spring",
|
|
70
|
+
move: "move",
|
|
71
|
+
drawer: "drawer"
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Molas no formato "duração e quique" (Motion). `settle` assenta sem passar do ponto (layout,
|
|
75
|
+
* overlay que entra, soltura do arraste); `sheet` é a folha depois do gesto, com quique mínimo.
|
|
76
|
+
* Mola não é variável CSS: mora aqui, e o app a espelha em `dampingRatio`.
|
|
77
|
+
*/
|
|
78
|
+
var SPRING = {
|
|
79
|
+
settle: {
|
|
80
|
+
duration: .4,
|
|
81
|
+
bounce: 0
|
|
82
|
+
},
|
|
83
|
+
sheet: {
|
|
84
|
+
duration: .3,
|
|
85
|
+
bounce: .2
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
/** Escalas da linguagem: entrada de overlay, tooltip, ponto pequeno, toque, pop e salto curto. */
|
|
89
|
+
var SCALE = {
|
|
90
|
+
enter: .95,
|
|
91
|
+
tooltip: .97,
|
|
92
|
+
small: .9,
|
|
93
|
+
press: .97,
|
|
94
|
+
pop: .8,
|
|
95
|
+
bump: 1.08
|
|
96
|
+
};
|
|
97
|
+
function toSeconds(value) {
|
|
98
|
+
const v = value.trim();
|
|
99
|
+
const n = parseFloat(v);
|
|
100
|
+
if (!Number.isFinite(n)) return null;
|
|
101
|
+
if (v.endsWith("ms")) return n / 1e3;
|
|
102
|
+
if (v.endsWith("s")) return n;
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
/** `cubic-bezier(a, b, c, d)` em vetor; qualquer outra coisa (`ease-in`, vazio) vira `null`. */
|
|
106
|
+
function toBezier(value) {
|
|
107
|
+
const m = /^cubic-bezier\(([^)]+)\)$/.exec(value.trim());
|
|
108
|
+
if (!m) return null;
|
|
109
|
+
const parts = m[1].split(",").map((n) => parseFloat(n));
|
|
110
|
+
if (parts.length !== 4 || parts.some((n) => !Number.isFinite(n))) return null;
|
|
111
|
+
return parts;
|
|
112
|
+
}
|
|
113
|
+
/** Lê as durações e as curvas do documento; o que faltar (ou sem window) vem da reserva. */
|
|
114
|
+
function readMotionTokens() {
|
|
115
|
+
const duration = { ...DURATION };
|
|
116
|
+
const reveal = { ...REVEAL };
|
|
117
|
+
const ease = { ...EASE };
|
|
118
|
+
if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
119
|
+
const style = getComputedStyle(document.documentElement);
|
|
120
|
+
for (const name of Object.keys(DURATION)) {
|
|
121
|
+
const read = toSeconds(style.getPropertyValue(`--rendra-duration-${name}`));
|
|
122
|
+
if (read !== null) duration[name] = read;
|
|
123
|
+
}
|
|
124
|
+
for (const name of Object.keys(REVEAL)) {
|
|
125
|
+
const read = toSeconds(style.getPropertyValue(`--rendra-reveal-${name}`));
|
|
126
|
+
if (read !== null) reveal[name] = read;
|
|
127
|
+
}
|
|
128
|
+
for (const name of Object.keys(EASE)) {
|
|
129
|
+
const read = toBezier(style.getPropertyValue(`--rendra-ease-${EASE_VAR[name]}`));
|
|
130
|
+
if (read !== null) ease[name] = read;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
duration,
|
|
135
|
+
reveal,
|
|
136
|
+
ease
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
//#endregion
|
|
140
|
+
//#region src/lib/motion/presets.ts
|
|
141
|
+
var SHORT_PX = 8;
|
|
142
|
+
/** Mola em "duração e quique" para rigidez e amortecimento (massa 1). */
|
|
143
|
+
function springToBounce({ duration, bounce }) {
|
|
144
|
+
const stiffness = (2 * Math.PI / duration) ** 2;
|
|
145
|
+
return {
|
|
146
|
+
bounceStiffness: Math.round(stiffness),
|
|
147
|
+
bounceDamping: Math.round(2 * (1 - bounce) * Math.sqrt(stiffness))
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function createPresets(tokens, reduced) {
|
|
151
|
+
const { duration, reveal, ease } = tokens;
|
|
152
|
+
const base = {
|
|
153
|
+
duration: duration.base,
|
|
154
|
+
ease: ease.out
|
|
155
|
+
};
|
|
156
|
+
const fastOut = {
|
|
157
|
+
duration: duration.fast,
|
|
158
|
+
ease: ease.out
|
|
159
|
+
};
|
|
160
|
+
const settle = {
|
|
161
|
+
type: "spring",
|
|
162
|
+
...SPRING.settle
|
|
163
|
+
};
|
|
164
|
+
const enter = {
|
|
165
|
+
type: "spring",
|
|
166
|
+
duration: duration.base,
|
|
167
|
+
bounce: SPRING.settle.bounce
|
|
168
|
+
};
|
|
169
|
+
/** O que sobra sob "reduzir movimento": só opacidade, em `base`. */
|
|
170
|
+
const flat = () => ({
|
|
171
|
+
initial: { opacity: 0 },
|
|
172
|
+
animate: { opacity: 1 },
|
|
173
|
+
exit: { opacity: 0 },
|
|
174
|
+
transition: base
|
|
175
|
+
});
|
|
176
|
+
const make = (initial, animate, time, curve = ease.out) => reduced ? flat() : {
|
|
177
|
+
initial,
|
|
178
|
+
animate,
|
|
179
|
+
exit: initial,
|
|
180
|
+
transition: {
|
|
181
|
+
duration: time,
|
|
182
|
+
ease: curve
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
const offset = (from, distance) => {
|
|
186
|
+
const far = distance === "full" ? "100%" : SHORT_PX;
|
|
187
|
+
const sign = from === "left" || from === "top" ? -1 : 1;
|
|
188
|
+
const value = typeof far === "string" ? `${sign * 100}%` : sign * far;
|
|
189
|
+
return from === "left" || from === "right" ? {
|
|
190
|
+
x: value,
|
|
191
|
+
opacity: 0
|
|
192
|
+
} : {
|
|
193
|
+
y: value,
|
|
194
|
+
opacity: 0
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
const settled = (initial) => ({
|
|
198
|
+
opacity: 1,
|
|
199
|
+
...initial.x !== void 0 ? { x: 0 } : {},
|
|
200
|
+
...initial.y !== void 0 ? { y: 0 } : {}
|
|
201
|
+
});
|
|
202
|
+
const fade = reduced ? flat() : {
|
|
203
|
+
initial: { opacity: 0 },
|
|
204
|
+
animate: { opacity: 1 },
|
|
205
|
+
exit: {
|
|
206
|
+
opacity: 0,
|
|
207
|
+
transition: fastOut
|
|
208
|
+
},
|
|
209
|
+
transition: base
|
|
210
|
+
};
|
|
211
|
+
const open = (from = SCALE.enter) => {
|
|
212
|
+
if (reduced) return flat();
|
|
213
|
+
return {
|
|
214
|
+
initial: typeof from === "number" ? {
|
|
215
|
+
opacity: 0,
|
|
216
|
+
scale: from
|
|
217
|
+
} : {
|
|
218
|
+
opacity: 0,
|
|
219
|
+
y: from.y
|
|
220
|
+
},
|
|
221
|
+
animate: {
|
|
222
|
+
...typeof from === "number" ? {
|
|
223
|
+
opacity: 1,
|
|
224
|
+
scale: 1
|
|
225
|
+
} : {
|
|
226
|
+
opacity: 1,
|
|
227
|
+
y: 0
|
|
228
|
+
},
|
|
229
|
+
transition: enter
|
|
230
|
+
},
|
|
231
|
+
exit: {
|
|
232
|
+
opacity: 0,
|
|
233
|
+
transition: fastOut
|
|
234
|
+
},
|
|
235
|
+
transition: enter
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
const sheet = (from) => {
|
|
239
|
+
if (reduced) return flat();
|
|
240
|
+
const sign = from === "left" || from === "top" ? -1 : 1;
|
|
241
|
+
const axis = from === "left" || from === "right" ? "x" : "y";
|
|
242
|
+
const away = { [axis]: `${sign * 100}%` };
|
|
243
|
+
return {
|
|
244
|
+
initial: away,
|
|
245
|
+
animate: { [axis]: 0 },
|
|
246
|
+
exit: {
|
|
247
|
+
...away,
|
|
248
|
+
transition: {
|
|
249
|
+
duration: duration.fast,
|
|
250
|
+
ease: ease.drawer
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
transition: {
|
|
254
|
+
duration: duration.slow,
|
|
255
|
+
ease: ease.drawer
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
};
|
|
259
|
+
const tooltip = (instant) => {
|
|
260
|
+
if (reduced) return instant ? {
|
|
261
|
+
...flat(),
|
|
262
|
+
transition: { duration: 0 }
|
|
263
|
+
} : flat();
|
|
264
|
+
return {
|
|
265
|
+
initial: {
|
|
266
|
+
opacity: 0,
|
|
267
|
+
scale: SCALE.tooltip
|
|
268
|
+
},
|
|
269
|
+
animate: {
|
|
270
|
+
opacity: 1,
|
|
271
|
+
scale: 1
|
|
272
|
+
},
|
|
273
|
+
exit: {
|
|
274
|
+
opacity: 0,
|
|
275
|
+
transition: fastOut
|
|
276
|
+
},
|
|
277
|
+
transition: instant ? { duration: 0 } : fastOut
|
|
278
|
+
};
|
|
279
|
+
};
|
|
280
|
+
const blurred = `blur(2px)`;
|
|
281
|
+
const swap = (direction) => {
|
|
282
|
+
if (reduced) return flat();
|
|
283
|
+
return {
|
|
284
|
+
initial: {
|
|
285
|
+
opacity: 0,
|
|
286
|
+
x: direction * SHORT_PX,
|
|
287
|
+
filter: blurred
|
|
288
|
+
},
|
|
289
|
+
animate: {
|
|
290
|
+
opacity: 1,
|
|
291
|
+
x: 0,
|
|
292
|
+
filter: "blur(0px)",
|
|
293
|
+
transition: base
|
|
294
|
+
},
|
|
295
|
+
exit: {
|
|
296
|
+
opacity: 0,
|
|
297
|
+
filter: blurred,
|
|
298
|
+
transition: fastOut
|
|
299
|
+
},
|
|
300
|
+
transition: base
|
|
301
|
+
};
|
|
302
|
+
};
|
|
303
|
+
const indicatorInitial = {
|
|
304
|
+
opacity: 0,
|
|
305
|
+
scale: SCALE.small
|
|
306
|
+
};
|
|
307
|
+
const press = {
|
|
308
|
+
whileTap: reduced ? void 0 : { scale: SCALE.press },
|
|
309
|
+
transition: {
|
|
310
|
+
duration: duration.press,
|
|
311
|
+
ease: ease.out
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
const move = reduced ? { duration: 0 } : {
|
|
315
|
+
duration: duration.move,
|
|
316
|
+
ease: ease.move
|
|
317
|
+
};
|
|
318
|
+
return {
|
|
319
|
+
reduced,
|
|
320
|
+
press,
|
|
321
|
+
tap: press.whileTap,
|
|
322
|
+
bump: reduced ? void 0 : {
|
|
323
|
+
scale: [SCALE.bump, 1],
|
|
324
|
+
transition: fastOut
|
|
325
|
+
},
|
|
326
|
+
tokens,
|
|
327
|
+
fade,
|
|
328
|
+
scale: open(),
|
|
329
|
+
pop: make({
|
|
330
|
+
opacity: 0,
|
|
331
|
+
scale: SCALE.pop
|
|
332
|
+
}, {
|
|
333
|
+
opacity: 1,
|
|
334
|
+
scale: 1
|
|
335
|
+
}, duration.slow, ease.spring),
|
|
336
|
+
indicator: reduced ? flat() : {
|
|
337
|
+
initial: indicatorInitial,
|
|
338
|
+
animate: {
|
|
339
|
+
opacity: 1,
|
|
340
|
+
scale: 1
|
|
341
|
+
},
|
|
342
|
+
exit: indicatorInitial,
|
|
343
|
+
transition: fastOut
|
|
344
|
+
},
|
|
345
|
+
slide: (from, distance = "full") => {
|
|
346
|
+
const initial = offset(from, distance);
|
|
347
|
+
return make(initial, settled(initial), distance === "full" ? duration.slow : duration.base);
|
|
348
|
+
},
|
|
349
|
+
open,
|
|
350
|
+
sheet,
|
|
351
|
+
tooltip,
|
|
352
|
+
swap,
|
|
353
|
+
reveal: (from) => {
|
|
354
|
+
const initial = offset(from, "short");
|
|
355
|
+
return make(initial, settled(initial), reveal.enter);
|
|
356
|
+
},
|
|
357
|
+
move,
|
|
358
|
+
layout: move,
|
|
359
|
+
settle: reduced ? { duration: 0 } : settle,
|
|
360
|
+
springSheet: reduced ? { duration: 0 } : {
|
|
361
|
+
type: "spring",
|
|
362
|
+
...SPRING.sheet
|
|
363
|
+
},
|
|
364
|
+
sheetBounce: springToBounce(SPRING.sheet),
|
|
365
|
+
stagger: (index, limit = 8) => ({ delay: reduced ? 0 : Math.min(index, limit) * (duration.fast / 2) }),
|
|
366
|
+
staggerReveal: (index, limit = 8) => ({ delay: reduced ? 0 : Math.min(index, limit) * reveal.stagger })
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
/** Curva no formato do recharts: `cubic-bezier(a,b,c,d)`, sem espaços. */
|
|
370
|
+
function toCubicBezier([a, b, c, d]) {
|
|
371
|
+
return `cubic-bezier(${a},${b},${c},${d})`;
|
|
372
|
+
}
|
|
373
|
+
/** Presets com os tokens lidos agora do documento. */
|
|
374
|
+
function presetsFromDocument(reduced) {
|
|
375
|
+
return createPresets(readMotionTokens(), reduced);
|
|
376
|
+
}
|
|
377
|
+
//#endregion
|
|
378
|
+
//#region src/lib/motion/use-motion-presets.ts
|
|
379
|
+
/** Em `off` ninguém lê o documento nem assina o matchMedia: um objeto único e inerte. */
|
|
380
|
+
var OFF_PRESETS = createPresets({
|
|
381
|
+
duration: DURATION,
|
|
382
|
+
reveal: REVEAL,
|
|
383
|
+
ease: EASE
|
|
384
|
+
}, false);
|
|
385
|
+
var noSubscribe = () => () => {};
|
|
386
|
+
var never = () => false;
|
|
387
|
+
/**
|
|
388
|
+
* Presets do motion para o componente. A preferência "reduzir movimento" vem do mesmo
|
|
389
|
+
* `matchMedia` do hook do projeto (`use-reduced-motion.ts`: Spinner, Progress), a fonte única,
|
|
390
|
+
* reativa e testável, sem `MotionConfig reducedMotion` somando por cima. Só em `on` a
|
|
391
|
+
* preferência é assinada e os tokens lidos do documento; em `off` o custo é zero.
|
|
392
|
+
*/
|
|
393
|
+
function useMotionPresets() {
|
|
394
|
+
const on = useMotionMode() === "on";
|
|
395
|
+
const reduced = useSyncExternalStore(on ? subscribeReducedMotion : noSubscribe, on ? getReducedMotion : never, never);
|
|
396
|
+
return useMemo(() => on ? presetsFromDocument(reduced) : OFF_PRESETS, [on, reduced]);
|
|
397
|
+
}
|
|
398
|
+
//#endregion
|
|
399
|
+
export { toCubicBezier as n, useMotionPresets as t };
|
|
400
|
+
|
|
401
|
+
//# sourceMappingURL=use-motion-presets-BrkgL8lG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-motion-presets-BrkgL8lG.js","names":[],"sources":["../src/lib/motion/tokens.ts","../src/lib/motion/presets.ts","../src/lib/motion/use-motion-presets.ts"],"sourcesContent":["/*\n * Durações e curvas do motion (linguagem única, web e app). A fonte é o globals.css:\n * --rendra-duration-* bloco :root fora de camada (vai para o dist/tokens.css do pacote);\n * --rendra-ease-* no mesmo bloco, então o host as sobrescreve; o @theme guarda os nomes\n * do Tailwind (--ease-out, --ease-move...) como alias delas.\n * As constantes daqui são a reserva em tempo de execução (SSR, variável ausente ou inválida), e\n * tokens.test.ts confere que elas batem com o globals.css. Valores em segundos e vetores de 4\n * números, o formato que o Motion aceita.\n */\n\nexport type Bezier = [number, number, number, number]\n\n/**\n * Reserva das durações, em segundos (SSR, ou variável ausente).\n * `press` e `fast` valem o mesmo (120 ms) com propósitos diferentes: o toque e a saída de overlay.\n */\nexport const DURATION = {\n press: 0.12,\n hover: 0.15,\n fast: 0.12,\n base: 0.2,\n move: 0.25,\n slow: 0.32,\n draw: 0.42,\n pulse: 1,\n}\nexport type DurationName = keyof typeof DURATION\n\n/**\n * Reveal: entrada de uso único (dashboard: bloco, cascata, contador e desenho do gráfico), mais\n * lenta que as interações do dia a dia. Reserva em segundos (SSR, ou variável ausente).\n */\nexport const REVEAL = { enter: 0.6, stagger: 0.12, count: 1.2, draw: 0.9 }\nexport type RevealName = keyof typeof REVEAL\n\n/**\n * Curvas do globals.css (`--rendra-ease-*`). `spring` é a curva \"back\" (quique): só para a cota\n * rara de encanto. `move` desloca na tela; `drawer` é a curva de gaveta e folha.\n */\nexport const EASE: Record<'out' | 'inOut' | 'spring' | 'move' | 'drawer', Bezier> = {\n out: [0.22, 1, 0.36, 1],\n inOut: [0.65, 0, 0.35, 1],\n spring: [0.34, 1.56, 0.64, 1],\n move: [0.77, 0, 0.175, 1],\n drawer: [0.32, 0.72, 0, 1],\n}\nexport type EaseName = keyof typeof EASE\n\n/** Nome da variável CSS de cada curva (`inOut` vira `in-out`). */\nconst EASE_VAR: Record<EaseName, string> = {\n out: 'out',\n inOut: 'in-out',\n spring: 'spring',\n move: 'move',\n drawer: 'drawer',\n}\n\n/**\n * Molas no formato \"duração e quique\" (Motion). `settle` assenta sem passar do ponto (layout,\n * overlay que entra, soltura do arraste); `sheet` é a folha depois do gesto, com quique mínimo.\n * Mola não é variável CSS: mora aqui, e o app a espelha em `dampingRatio`.\n */\nexport const SPRING = {\n settle: { duration: 0.4, bounce: 0 },\n sheet: { duration: 0.3, bounce: 0.2 },\n}\n\n/** Escalas da linguagem: entrada de overlay, tooltip, ponto pequeno, toque, pop e salto curto. */\nexport const SCALE = { enter: 0.95, tooltip: 0.97, small: 0.9, press: 0.97, pop: 0.8, bump: 1.08 }\n\n/** Desfoque (px) que disfarça o cruzamento entre dois estados (troca de passo). Abaixo de 20. */\nexport const BLUR = 2\n\nexport interface MotionTokens {\n duration: Record<DurationName, number>\n reveal: Record<RevealName, number>\n ease: Record<EaseName, Bezier>\n}\n\nfunction toSeconds(value: string): number | null {\n const v = value.trim()\n const n = parseFloat(v)\n if (!Number.isFinite(n)) return null\n if (v.endsWith('ms')) return n / 1000\n if (v.endsWith('s')) return n\n return null\n}\n\n/** `cubic-bezier(a, b, c, d)` em vetor; qualquer outra coisa (`ease-in`, vazio) vira `null`. */\nfunction toBezier(value: string): Bezier | null {\n const m = /^cubic-bezier\\(([^)]+)\\)$/.exec(value.trim())\n if (!m) return null\n const parts = m[1]!.split(',').map((n) => parseFloat(n))\n if (parts.length !== 4 || parts.some((n) => !Number.isFinite(n))) return null\n return parts as Bezier\n}\n\n/** Lê as durações e as curvas do documento; o que faltar (ou sem window) vem da reserva. */\nexport function readMotionTokens(): MotionTokens {\n const duration = { ...DURATION }\n const reveal = { ...REVEAL }\n const ease = { ...EASE }\n if (typeof window !== 'undefined' && typeof document !== 'undefined') {\n const style = getComputedStyle(document.documentElement)\n for (const name of Object.keys(DURATION) as DurationName[]) {\n const read = toSeconds(style.getPropertyValue(`--rendra-duration-${name}`))\n if (read !== null) duration[name] = read\n }\n for (const name of Object.keys(REVEAL) as RevealName[]) {\n const read = toSeconds(style.getPropertyValue(`--rendra-reveal-${name}`))\n if (read !== null) reveal[name] = read\n }\n for (const name of Object.keys(EASE) as EaseName[]) {\n const read = toBezier(style.getPropertyValue(`--rendra-ease-${EASE_VAR[name]}`))\n if (read !== null) ease[name] = read\n }\n }\n return { duration, reveal, ease }\n}\n","import type { Target, TargetAndTransition, Transition } from 'motion/react'\nimport { BLUR, readMotionTokens, SCALE, SPRING, type Bezier, type MotionTokens } from './tokens'\n\n/*\n * Presets do caminho `on` (linguagem única de movimento): fade, scale/open, sheet, tooltip,\n * indicator, pop, slide, reveal, press, move, settle e stagger. Toda duração e toda curva vêm de\n * readMotionTokens (globals.css); nenhum número de duração mora neste arquivo (o presets.test.ts\n * varre o código-fonte atrás de literal). As molas e as escalas vêm de tokens.ts.\n *\n * Duas regras moram aqui:\n * - Assimetria: o que o usuário decidiu (abrir) entra no tempo `base`, e o que o sistema\n * responde ao fechar sai em `fast`, só em opacidade. Gaveta e folha saem em `base`, de volta\n * pelo lado de onde vieram.\n * - Reduzido: sem deslocamento, escala, filtro nem cascata; a opacidade usa `base` (não zero),\n * porque o esmaecimento é o que explica a mudança de estado.\n */\n\nexport interface MotionPreset {\n initial: Target\n animate: TargetAndTransition\n exit: TargetAndTransition\n transition: Transition\n}\n\n/** Toque: o alvo do `whileTap` (`undefined` no reduzido) e a transição de ida e de volta. */\nexport interface PressPreset {\n whileTap: TargetAndTransition | undefined\n transition: Transition\n}\n\nexport type SlideFrom = 'left' | 'right' | 'top' | 'bottom'\n\n/** Distância do slide: `full` (painel que entra da borda) ou `short` (conteúdo que assenta). */\nexport type SlideDistance = 'full' | 'short'\n\nconst SHORT_PX = 8\n\nexport interface Presets {\n reduced: boolean\n /** Toque do botão, do polegar e dos controles: 120 ms, `ease.out`, escala 0,97. */\n press: PressPreset\n /** Alias de `press.whileTap`, o nome antigo. Sem movimento reduzido vem `undefined`. */\n tap: TargetAndTransition | undefined\n /**\n * Salto curto de escala (célula do OTP), com a transição dentro do alvo. Estável entre\n * renders; `undefined` se reduzido.\n */\n bump: TargetAndTransition | undefined\n tokens: MotionTokens\n fade: MotionPreset\n /** Alias de `open()`: escala 0,95 com mola a partir da origem, saída rápida só em opacidade. */\n scale: MotionPreset\n /**\n * Cota rara de encanto (check do passo concluído): 0,8 -> 1 com a curva back, em `slow`. Nunca\n * em controle de uso frequente.\n */\n pop: MotionPreset\n /**\n * Indicador de controle frequente (check do Checkbox, ponto do Radio): 0,9 -> 1 com opacidade\n * em `fast`, sem quique e sem partir de zero.\n */\n indicator: MotionPreset\n slide: (from: SlideFrom, distance?: SlideDistance) => MotionPreset\n /**\n * Overlay ancorado (popover, menu, modal, painel do select). Número = escala de partida\n * (padrão 0,95); `{ y }` = entrada plana, sem escala, para a superfície em tela cheia.\n * Entra em mola criticamente amortecida (sem quique) em `base` e sai em `fast`, em opacidade.\n */\n open: (from?: number | { y: number }) => MotionPreset\n /** Gaveta e folha: entram de `from` em `slow` com `ease.drawer`, saem em `fast` pelo mesmo lado. */\n sheet: (from: SlideFrom) => MotionPreset\n /** Tooltip: escala 0,97 em `fast`; aberto em `instant-open` não anima. */\n tooltip: (instant: boolean) => MotionPreset\n /**\n * Troca de conteúdo no lugar (passo do wizard), sem esperar a saída: o que sai esmaece com\n * `blur` de 2 px em `fast`; o que entra vem de `direction` (1 avança, -1 volta), 8 px, em\n * `base`. O desfoque disfarça o cruzamento: sem ele o olho vê dois objetos trocando de lugar.\n */\n swap: (direction: 1 | -1) => MotionPreset\n /**\n * Entrada de uso único (reveal do dashboard): desloca 8 px e dura `reveal.enter`, mais lenta\n * que `slide`. Não serve a interação repetida (overlay, tab, botão).\n */\n reveal: (from: SlideFrom) => MotionPreset\n /** Deslocamento na tela (indicador, reordenação): `move` em `ease.move`. */\n move: Transition\n /** Nome antigo de `move`. */\n layout: Transition\n /** Mola sem quique: onde há gesto ou soltura (drop do kanban, folha que volta). */\n settle: Transition\n /** Mola da folha depois do arraste (quique mínimo). */\n springSheet: Transition\n /**\n * A mesma mola da folha em rigidez e amortecimento (massa 1), que é o que o arraste do Motion\n * (`dragTransition`) pede para a volta à origem: rigidez = (2π / duração)², amortecimento =\n * 2 (1 - quique) raiz(rigidez).\n */\n sheetBounce: { bounceStiffness: number; bounceDamping: number }\n /** Atraso de entrada do item `index`, limitado a `limit` itens (padrão 8: 480 ms). */\n stagger: (index: number, limit?: number) => Transition\n /** Atraso do bloco `index` no reveal (passo `reveal.stagger`), limitado a `limit` blocos. */\n staggerReveal: (index: number, limit?: number) => Transition\n}\n\n/** Mola em \"duração e quique\" para rigidez e amortecimento (massa 1). */\nfunction springToBounce({ duration, bounce }: { duration: number; bounce: number }) {\n const stiffness = ((2 * Math.PI) / duration) ** 2\n return {\n bounceStiffness: Math.round(stiffness),\n bounceDamping: Math.round(2 * (1 - bounce) * Math.sqrt(stiffness)),\n }\n}\n\nexport function createPresets(tokens: MotionTokens, reduced: boolean): Presets {\n const { duration, reveal, ease } = tokens\n const base: Transition = { duration: duration.base, ease: ease.out }\n const fastOut: Transition = { duration: duration.fast, ease: ease.out }\n const settle: Transition = { type: 'spring', ...SPRING.settle }\n const enter: Transition = {\n type: 'spring',\n duration: duration.base,\n bounce: SPRING.settle.bounce,\n }\n\n /** O que sobra sob \"reduzir movimento\": só opacidade, em `base`. */\n const flat = (): MotionPreset => ({\n initial: { opacity: 0 },\n animate: { opacity: 1 },\n exit: { opacity: 0 },\n transition: base,\n })\n const make = (initial: Target, animate: Target, time: number, curve = ease.out): MotionPreset =>\n reduced\n ? flat()\n : {\n initial,\n animate,\n exit: initial,\n transition: { duration: time, ease: curve },\n }\n\n const offset = (from: SlideFrom, distance: SlideDistance): Target => {\n const far = distance === 'full' ? '100%' : SHORT_PX\n const sign = from === 'left' || from === 'top' ? -1 : 1\n const value = typeof far === 'string' ? `${sign * 100}%` : sign * far\n return from === 'left' || from === 'right' ? { x: value, opacity: 0 } : { y: value, opacity: 0 }\n }\n const settled = (initial: Target): Target => ({\n opacity: 1,\n ...(initial.x !== undefined ? { x: 0 } : {}),\n ...(initial.y !== undefined ? { y: 0 } : {}),\n })\n\n const fade: MotionPreset = reduced\n ? flat()\n : {\n initial: { opacity: 0 },\n animate: { opacity: 1 },\n exit: { opacity: 0, transition: fastOut },\n transition: base,\n }\n\n const open = (from: number | { y: number } = SCALE.enter): MotionPreset => {\n if (reduced) return flat()\n const initial: Target =\n typeof from === 'number' ? { opacity: 0, scale: from } : { opacity: 0, y: from.y }\n const to: Target = typeof from === 'number' ? { opacity: 1, scale: 1 } : { opacity: 1, y: 0 }\n return {\n initial,\n animate: { ...to, transition: enter },\n exit: { opacity: 0, transition: fastOut },\n transition: enter,\n }\n }\n\n const sheet = (from: SlideFrom): MotionPreset => {\n if (reduced) return flat()\n const sign = from === 'left' || from === 'top' ? -1 : 1\n const axis = from === 'left' || from === 'right' ? 'x' : 'y'\n const away = { [axis]: `${sign * 100}%` }\n return {\n initial: away,\n animate: { [axis]: 0 },\n exit: { ...away, transition: { duration: duration.fast, ease: ease.drawer } },\n transition: { duration: duration.slow, ease: ease.drawer },\n }\n }\n\n const tooltip = (instant: boolean): MotionPreset => {\n if (reduced) return instant ? { ...flat(), transition: { duration: 0 } } : flat()\n return {\n initial: { opacity: 0, scale: SCALE.tooltip },\n animate: { opacity: 1, scale: 1 },\n exit: { opacity: 0, transition: fastOut },\n transition: instant ? { duration: 0 } : fastOut,\n }\n }\n\n const blurred = `blur(${BLUR}px)`\n const swap = (direction: 1 | -1): MotionPreset => {\n if (reduced) return flat()\n return {\n initial: { opacity: 0, x: direction * SHORT_PX, filter: blurred },\n animate: { opacity: 1, x: 0, filter: 'blur(0px)', transition: base },\n exit: { opacity: 0, filter: blurred, transition: fastOut },\n transition: base,\n }\n }\n\n const indicatorInitial: Target = { opacity: 0, scale: SCALE.small }\n const press: PressPreset = {\n whileTap: reduced ? undefined : { scale: SCALE.press },\n transition: { duration: duration.press, ease: ease.out },\n }\n const move: Transition = reduced ? { duration: 0 } : { duration: duration.move, ease: ease.move }\n\n return {\n reduced,\n press,\n tap: press.whileTap,\n bump: reduced ? undefined : { scale: [SCALE.bump, 1], transition: fastOut },\n tokens,\n fade,\n scale: open(),\n pop: make(\n { opacity: 0, scale: SCALE.pop },\n { opacity: 1, scale: 1 },\n duration.slow,\n ease.spring,\n ),\n indicator: reduced\n ? flat()\n : {\n initial: indicatorInitial,\n animate: { opacity: 1, scale: 1 },\n exit: indicatorInitial,\n transition: fastOut,\n },\n slide: (from, distance = 'full') => {\n const initial = offset(from, distance)\n return make(initial, settled(initial), distance === 'full' ? duration.slow : duration.base)\n },\n open,\n sheet,\n tooltip,\n swap,\n reveal: (from) => {\n const initial = offset(from, 'short')\n return make(initial, settled(initial), reveal.enter)\n },\n move,\n layout: move,\n settle: reduced ? { duration: 0 } : settle,\n springSheet: reduced ? { duration: 0 } : { type: 'spring', ...SPRING.sheet },\n sheetBounce: springToBounce(SPRING.sheet),\n stagger: (index, limit = 8) => ({\n delay: reduced ? 0 : Math.min(index, limit) * (duration.fast / 2),\n }),\n staggerReveal: (index, limit = 8) => ({\n delay: reduced ? 0 : Math.min(index, limit) * reveal.stagger,\n }),\n }\n}\n\n/** Curva no formato do recharts: `cubic-bezier(a,b,c,d)`, sem espaços. */\nexport function toCubicBezier([\n a,\n b,\n c,\n d,\n]: Bezier): `cubic-bezier(${number},${number},${number},${number})` {\n return `cubic-bezier(${a},${b},${c},${d})`\n}\n\n/** Presets com os tokens lidos agora do documento. */\nexport function presetsFromDocument(reduced: boolean): Presets {\n return createPresets(readMotionTokens(), reduced)\n}\n","import { useMemo, useSyncExternalStore } from 'react'\nimport { getReducedMotion, subscribeReducedMotion } from '@/hooks/use-reduced-motion'\nimport { useMotionMode } from './motion-context'\nimport { createPresets, presetsFromDocument, type Presets } from './presets'\nimport { DURATION, EASE, REVEAL } from './tokens'\n\n/** Em `off` ninguém lê o documento nem assina o matchMedia: um objeto único e inerte. */\nconst OFF_PRESETS = createPresets({ duration: DURATION, reveal: REVEAL, ease: EASE }, false)\nconst noSubscribe = () => () => {}\nconst never = () => false\n\n/**\n * Presets do motion para o componente. A preferência \"reduzir movimento\" vem do mesmo\n * `matchMedia` do hook do projeto (`use-reduced-motion.ts`: Spinner, Progress), a fonte única,\n * reativa e testável, sem `MotionConfig reducedMotion` somando por cima. Só em `on` a\n * preferência é assinada e os tokens lidos do documento; em `off` o custo é zero.\n */\nexport function useMotionPresets(): Presets {\n const on = useMotionMode() === 'on'\n const reduced = useSyncExternalStore(\n on ? subscribeReducedMotion : noSubscribe,\n on ? getReducedMotion : never,\n never,\n )\n return useMemo(() => (on ? presetsFromDocument(reduced) : OFF_PRESETS), [on, reduced])\n}\n"],"mappings":";;;;;;;;AAgBA,IAAa,WAAW;CACtB,OAAO;CACP,OAAO;CACP,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,OAAO;AACT;;;;;AAOA,IAAa,SAAS;CAAE,OAAO;CAAK,SAAS;CAAM,OAAO;CAAK,MAAM;AAAI;;;;;AAOzE,IAAa,OAAuE;CAClF,KAAK;EAAC;EAAM;EAAG;EAAM;CAAC;CACtB,OAAO;EAAC;EAAM;EAAG;EAAM;CAAC;CACxB,QAAQ;EAAC;EAAM;EAAM;EAAM;CAAC;CAC5B,MAAM;EAAC;EAAM;EAAG;EAAO;CAAC;CACxB,QAAQ;EAAC;EAAM;EAAM;EAAG;CAAC;AAC3B;;AAIA,IAAM,WAAqC;CACzC,KAAK;CACL,OAAO;CACP,QAAQ;CACR,MAAM;CACN,QAAQ;AACV;;;;;;AAOA,IAAa,SAAS;CACpB,QAAQ;EAAE,UAAU;EAAK,QAAQ;CAAE;CACnC,OAAO;EAAE,UAAU;EAAK,QAAQ;CAAI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1,8 @@
|
|
|
1
|
-
/*! Rendra Design System v2.
|
|
2
|
-
import { t as cn } from "./cn-
|
|
1
|
+
/*! Rendra Design System v2.5.0 | MIT | © 2026 Bruno Magalhaes | brunomagalhaes.me */
|
|
2
|
+
import { t as cn } from "./cn-Cw7M5kEP.js";
|
|
3
3
|
import { GripVertical } from "lucide-react";
|
|
4
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
4
|
import { useMemo, useState } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { ResponsiveGridLayout, useContainerWidth } from "react-grid-layout";
|
|
7
7
|
import "react-grid-layout/css/styles.css";
|
|
8
8
|
//#region src/components/ui/widget-grid.tsx
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rendra-ui/web",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Rendra, design system e boilerplate React (Vite, TypeScript, Tailwind v4, Radix), com CLI de catálogo, auditoria e troca de variante.",
|
|
6
6
|
"author": {
|
|
@@ -114,6 +114,7 @@
|
|
|
114
114
|
"test:a11y": "playwright test --project=a11y",
|
|
115
115
|
"test:visual": "playwright test --project=visual",
|
|
116
116
|
"test:visual:update": "playwright test --project=visual --update-snapshots",
|
|
117
|
+
"test:motion": "playwright test --project=motion --project=estados",
|
|
117
118
|
"test:css-layers": "playwright test --project=css-layers",
|
|
118
119
|
"test:site": "playwright test -c playwright.site.config.ts",
|
|
119
120
|
"registry:build": "node scripts/build-registry.mjs",
|
|
@@ -136,6 +137,7 @@
|
|
|
136
137
|
"date-fns": "^4.4.0",
|
|
137
138
|
"imask": "^7.6.1",
|
|
138
139
|
"lucide-react": "^1.48.0",
|
|
140
|
+
"motion": "^14.3.0",
|
|
139
141
|
"pdfjs-dist": "^6.3.289",
|
|
140
142
|
"radix-ui": "^1.6.7",
|
|
141
143
|
"react": "^19.3.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"button-C6rjowQi.js","names":[],"sources":["../src/hooks/use-reduced-motion.ts","../src/components/ui/spinner.tsx","../src/components/ui/button.tsx"],"sourcesContent":["import { useSyncExternalStore } from 'react'\n\n/*\n * Único hook de leitura de \"menos movimento\" do sistema operacional (prefers-reduced-motion).\n * Usado pelo Spinner e pelo Progress indeterminado para parar a animação sem depender só do\n * CSS, e assim ficar testável (mocke matchMedia para simular a preferência).\n */\n\nfunction subscribe(cb: () => void) {\n const mq = matchMedia('(prefers-reduced-motion: reduce)')\n mq.addEventListener('change', cb)\n return () => mq.removeEventListener('change', cb)\n}\n\nfunction getCurrent() {\n return matchMedia('(prefers-reduced-motion: reduce)').matches\n}\n\nexport function usePrefersReducedMotion() {\n return useSyncExternalStore(subscribe, getCurrent, () => false)\n}\n","import { Loader2 } from 'lucide-react'\nimport { usePrefersReducedMotion } from '@/hooks/use-reduced-motion'\nimport { cn } from '@/lib/cn'\n\n/*\n * Indicador de carregamento único do sistema (A17 do plano da v2). Substitui qualquer\n * `Loader2 animate-spin` solto em Button, Input e Select. Sem label é decorativo\n * (aria-hidden); com label, anuncia o carregamento a quem usa leitor de tela. Para de girar\n * quando o sistema pede menos movimento.\n */\n\nexport interface SpinnerProps {\n size?: 'sm' | 'md' | 'lg'\n /** Nome do que está carregando. Vazio (padrão): decorativo, sem anúncio de leitor de tela. */\n label?: string\n className?: string\n}\n\nconst sizeClass: Record<NonNullable<SpinnerProps['size']>, string> = {\n sm: 'size-icon-sm',\n md: 'size-icon-md',\n lg: 'size-icon-lg',\n}\n\nexport function Spinner({ size = 'md', label, className }: SpinnerProps) {\n const reduced = usePrefersReducedMotion()\n const icon = (\n <Loader2 aria-hidden className={cn(sizeClass[size], reduced ? '' : 'animate-spin')} />\n )\n\n if (!label) {\n return (\n <span data-rendra=\"SPIN-001\" aria-hidden className={cn('inline-flex', className)}>\n {icon}\n </span>\n )\n }\n\n return (\n <span\n data-rendra=\"SPIN-001\"\n role=\"status\"\n className={cn('inline-flex items-center gap-2', className)}\n >\n {icon}\n <span className=\"sr-only\">{label}</span>\n </span>\n )\n}\n","import { cva, type VariantProps } from 'class-variance-authority'\nimport { Slot } from 'radix-ui'\nimport { forwardRef, type ButtonHTMLAttributes, type ReactNode } from 'react'\nimport { resolveCatalogCode } from '@/catalog/components'\nimport { Spinner } from '@/components/ui/spinner'\nimport { cn } from '@/lib/cn'\n\n/**\n * Botão único do sistema. Variantes, tamanho, ícone, só ícone, carregamento e\n * largura total são props: nunca crie outro arquivo de botão.\n * Altura vem de h-control-*: 44px ou mais no mobile, compacta a partir de md.\n */\nexport const buttonVariants = cva(\n 'inline-flex shrink-0 cursor-pointer items-center justify-center gap-2 rounded-control font-medium whitespace-nowrap transition-[color,background-color,border-color,box-shadow,transform] duration-150 ease-out select-none active:scale-98 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 motion-reduce:active:scale-100 [&_svg]:pointer-events-none [&_svg]:shrink-0',\n {\n variants: {\n variant: {\n // Hover troca para a cor de hover da marca e eleva um nível; pressionar comprime.\n primary:\n 'bg-primary text-primary-foreground shadow-sm hover:bg-primary-hover hover:text-primary-hover-foreground hover:shadow-md active:bg-primary-hover active:text-primary-hover-foreground active:shadow-sm',\n secondary:\n 'bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary-hover hover:text-secondary-hover-foreground hover:shadow-md active:bg-secondary-hover active:text-secondary-hover-foreground active:shadow-sm',\n outline:\n 'border border-input bg-card text-foreground hover:border-primary hover:bg-primary-soft hover:text-primary-soft-foreground active:bg-primary-soft',\n // Transparentes: no hover, assumem a cor primária do template.\n ghost:\n 'text-foreground hover:bg-primary-soft hover:text-primary-soft-foreground active:bg-primary-soft',\n destructive:\n 'bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive-hover hover:shadow-md active:bg-destructive-hover active:shadow-sm',\n link: 'min-h-touch min-w-touch text-primary-text underline-offset-4 hover:text-primary-hover hover:underline md:min-h-0 md:min-w-0',\n },\n size: {\n sm: 'h-control-sm px-3 text-sm [&_svg]:size-icon-sm',\n md: 'h-control-md px-4 text-sm [&_svg]:size-icon-sm',\n lg: 'h-control-lg px-6 text-base [&_svg]:size-icon-md',\n },\n iconOnly: { true: 'px-0', false: '' },\n fullWidth: { true: 'w-full', false: '' },\n },\n compoundVariants: [\n { iconOnly: true, size: 'sm', className: 'w-control-sm' },\n { iconOnly: true, size: 'md', className: 'w-control-md' },\n { iconOnly: true, size: 'lg', className: 'w-control-lg' },\n { variant: 'link', className: 'h-auto px-0' },\n ],\n defaultVariants: { variant: 'primary', size: 'md', iconOnly: false, fullWidth: false },\n },\n)\n\ntype Variants = VariantProps<typeof buttonVariants>\n\nexport interface ButtonProps\n extends ButtonHTMLAttributes<HTMLButtonElement>, Omit<Variants, 'iconOnly' | 'fullWidth'> {\n /** Ícone à esquerda do texto (ou o próprio conteúdo, com iconOnly). */\n icon?: ReactNode\n /** Ícone à direita do texto. */\n iconRight?: ReactNode\n /** Botão só com ícone: quadrado, e aria-label passa a ser obrigatório. */\n iconOnly?: boolean\n /** Mostra indicador, bloqueia cliques e marca aria-busy. */\n loading?: boolean\n /** Ocupa toda a largura do contêiner. */\n fullWidth?: boolean\n /** Renderiza o filho (ex.: <Link>) com a aparência de botão. */\n asChild?: boolean\n}\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(\n {\n className,\n variant,\n size,\n icon,\n iconRight,\n iconOnly = false,\n loading = false,\n fullWidth = false,\n asChild = false,\n disabled,\n type = 'button',\n children,\n ...props\n },\n ref,\n) {\n if (import.meta.env.DEV && iconOnly && !props['aria-label']) {\n console.warn('Button com iconOnly precisa de aria-label.')\n }\n const classes = cn(buttonVariants({ variant, size, iconOnly, fullWidth }), className)\n const code = resolveCatalogCode('Button', { variant: variant ?? 'primary' })\n\n if (asChild) {\n return (\n <Slot.Root ref={ref} data-rendra={code} className={classes} {...props}>\n {children}\n </Slot.Root>\n )\n }\n\n // Ícone dentro do botão segue o tamanho do próprio botão (sm/md -> sm, lg -> md, como o\n // [&_svg]:size-icon-* de buttonVariants já fazia com o Loader2 solto).\n const leading = loading ? <Spinner size={size === 'lg' ? 'md' : 'sm'} /> : icon\n return (\n <button\n ref={ref}\n type={type}\n data-rendra={code}\n className={classes}\n disabled={disabled || loading}\n aria-busy={loading || undefined}\n {...props}\n >\n {leading}\n {iconOnly ? (loading ? null : children) : children}\n {!iconOnly && iconRight}\n </button>\n )\n})\n"],"mappings":";;;;;;;;;AAQA,SAAS,UAAU,IAAgB;CACjC,MAAM,KAAK,WAAW,kCAAkC;CACxD,GAAG,iBAAiB,UAAU,EAAE;CAChC,aAAa,GAAG,oBAAoB,UAAU,EAAE;AAClD;AAEA,SAAS,aAAa;CACpB,OAAO,WAAW,kCAAkC,CAAC,CAAC;AACxD;AAEA,SAAgB,0BAA0B;CACxC,OAAO,qBAAqB,WAAW,kBAAkB,KAAK;AAChE;;;ACFA,IAAM,YAA+D;CACnE,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAEA,SAAgB,QAAQ,EAAE,OAAO,MAAM,OAAO,aAA2B;CACvE,MAAM,UAAU,wBAAwB;CACxC,MAAM,OACJ,oBAAC,SAAD;EAAS,eAAA;EAAY,WAAW,GAAG,UAAU,OAAO,UAAU,KAAK,cAAc;CAAI,CAAA;CAGvF,IAAI,CAAC,OACH,OACE,oBAAC,QAAD;EAAM,eAAY;EAAW,eAAA;EAAY,WAAW,GAAG,eAAe,SAAS;EAC5E,UAAA;CACG,CAAA;CAIV,OACE,qBAAC,QAAD;EACE,eAAY;EACZ,MAAK;EACL,WAAW,GAAG,kCAAkC,SAAS;EAH3D,UAAA,CAKG,MACD,oBAAC,QAAD;GAAM,WAAU;GAAW,UAAA;EAAY,CAAA,CACnC;;AAEV;;;;;;;;ACpCA,IAAa,iBAAiB,IAC5B,uaACA;CACE,UAAU;EACR,SAAS;GAEP,SACE;GACF,WACE;GACF,SACE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x"],"sourcesContent":["import {\n createContext,\n useContext,\n useMemo,\n useSyncExternalStore,\n type AnchorHTMLAttributes,\n type ComponentType,\n type ReactNode,\n} from 'react'\n\n/**\n * Link com a mesma interface do `<a>`/`Link`: recebe `to`, `className`, `children`,\n * `aria-*`, `onClick` e repassa o resto.\n */\nexport interface RendraLinkProps {\n to: string\n className?: string\n children?: ReactNode\n [key: string]: unknown\n}\n\nexport interface RendraBreadcrumbItem {\n label: string\n to?: string\n}\n\nexport interface RendraNavigateOptions {\n replace?: boolean\n}\n\nexport interface RendraProviderProps {\n children: ReactNode\n /** Componente de link do roteador do host (ex.: `Link` do react-router). */\n linkComponent: ComponentType<RendraLinkProps>\n /** Devolve o caminho atual (ex.: `useLocation().pathname`). */\n useCurrentPath: () => string\n /** Navega para um caminho, com `replace` opcional. */\n navigate: (to: string, options?: RendraNavigateOptions) => void\n /** Volta à tela anterior. */\n goBack: () => void\n /** Trilha da rota atual (ex.: via `useMatches` e `handle.crumb`). Opcional. */\n useBreadcrumbs?: () => RendraBreadcrumbItem[]\n}\n\ninterface RendraContextValue {\n linkComponent: ComponentType<RendraLinkProps>\n useCurrentPath: () => string\n navigate: (to: string, options?: RendraNavigateOptions) => void\n goBack: () => void\n useBreadcrumbs: () => RendraBreadcrumbItem[]\n}\n\n/** Sem roteador nenhum: o link é só um `<a href>`. */\nfunction DefaultLink({ to, children, ...rest }: RendraLinkProps) {\n return (\n <a href={to} {...(rest as AnchorHTMLAttributes<HTMLAnchorElement>)}>\n {children}\n </a>\n )\n}\n\nfunction subscribeToLocation(onChange: () => void) {\n window.addEventListener('popstate', onChange)\n return () => window.removeEventListener('popstate', onChange)\n}\n\n/** Sem roteador nenhum: lê `window.location.pathname` direto. */\nfunction useDefaultCurrentPath(): string {\n return useSyncExternalStore(\n subscribeToLocation,\n () => window.location.pathname,\n () => '/',\n )\n}\n\n/** Sem roteador nenhum: navega com `window.location`. */\nfunction defaultNavigate(to: string, options?: RendraNavigateOptions) {\n if (options?.replace) {\n window.location.replace(to)\n } else {\n window.location.assign(to)\n }\n}\n\n/** Sem roteador nenhum: volta pelo histórico do navegador. */\nfunction defaultGoBack() {\n window.history.back()\n}\n\n/** Sem roteador nenhum: nenhuma trilha para montar. */\nfunction defaultUseBreadcrumbs(): RendraBreadcrumbItem[] {\n return []\n}\n\nconst defaultValue: RendraContextValue = {\n linkComponent: DefaultLink,\n useCurrentPath: useDefaultCurrentPath,\n navigate: defaultNavigate,\n goBack: defaultGoBack,\n useBreadcrumbs: defaultUseBreadcrumbs,\n}\n\nconst RendraContext = createContext<RendraContextValue>(defaultValue)\n\n/**\n * Única peça que sabe como navegar (`react-router`, outro roteador, ou nenhum).\n * Sem `RendraProvider` na árvore, os hooks abaixo caem para um comportamento simples,\n * baseado só em `window.location`/`history`, e os componentes continuam funcionando.\n */\nexport function RendraProvider({\n children,\n linkComponent,\n useCurrentPath: useCurrentPathProp,\n navigate,\n goBack,\n useBreadcrumbs,\n}: RendraProviderProps) {\n const value = useMemo<RendraContextValue>(\n () => ({\n linkComponent,\n useCurrentPath: useCurrentPathProp,\n navigate,\n goBack,\n useBreadcrumbs: useBreadcrumbs ?? defaultUseBreadcrumbs,\n }),\n [linkComponent, useCurrentPathProp, navigate, goBack, useBreadcrumbs],\n )\n return <RendraContext.Provider value={value}>{children}</RendraContext.Provider>\n}\n\n/** Componente de link do provider ativo (ou `<a href>`, sem provider). */\nexport function useRendraLink(): ComponentType<RendraLinkProps> {\n return useContext(RendraContext).linkComponent\n}\n\n/** Caminho atual (ex.: `/clientes/novo`), do provider ativo ou de `window.location`. */\nexport function useCurrentPath(): string {\n const ctx = useContext(RendraContext)\n return ctx.useCurrentPath()\n}\n\n/** Navegar e voltar, do provider ativo ou de `window.location`/`history`. */\nexport function useRendraNavigate(): {\n navigate: (to: string, options?: RendraNavigateOptions) => void\n goBack: () => void\n} {\n const ctx = useContext(RendraContext)\n return { navigate: ctx.navigate, goBack: ctx.goBack }\n}\n\n/** Trilha da rota atual, do provider ativo ou vazia, sem roteador. */\nexport function useRendraBreadcrumbs(): RendraBreadcrumbItem[] {\n const ctx = useContext(RendraContext)\n return ctx.useBreadcrumbs()\n}\n"],"mappings":";;;;;AAqDA,SAAS,YAAY,EAAE,IAAI,UAAU,GAAG,QAAyB;CAC/D,OACE,oBAAC,KAAD;EAAG,MAAM;EAAI,GAAK;EACf;CACA,CAAA;AAEP;AAEA,SAAS,oBAAoB,UAAsB;CACjD,OAAO,iBAAiB,YAAY,QAAQ;CAC5C,aAAa,OAAO,oBAAoB,YAAY,QAAQ;AAC9D;;AAGA,SAAS,wBAAgC;CACvC,OAAO,qBACL,2BACM,OAAO,SAAS,gBAChB,GACR;AACF;;AAGA,SAAS,gBAAgB,IAAY,SAAiC;CACpE,IAAI,SAAS,SACX,OAAO,SAAS,QAAQ,EAAE;MAE1B,OAAO,SAAS,OAAO,EAAE;AAE7B;;AAGA,SAAS,gBAAgB;CACvB,OAAO,QAAQ,KAAK;AACtB;;AAGA,SAAS,wBAAgD;CACvD,OAAO,CAAC;AACV;AAUA,IAAM,gBAAgB,cAAkC;CAPtD,eAAe;CACf,gBAAgB;CAChB,UAAU;CACV,QAAQ;CACR,gBAAgB;AAGsC,CAAY;;;;;;AAOpE,SAAgB,eAAe,EAC7B,UACA,eACA,gBAAgB,oBAChB,UACA,QACA,kBACsB;CACtB,MAAM,QAAQ,eACL;EACL;EACA,gBAAgB;EAChB;EACA;EACA,gBAAgB,kBAAkB;CACpC,IACA;EAAC;EAAe;EAAoB;EAAU;EAAQ;CAAc,CACtE;CACA,OAAO,oBAAC,cAAc,UAAf;EAA+B;EAAQ;CAAiC,CAAA;AACjF;;AAGA,SAAgB,gBAAgD;CAC9D,OAAO,WAAW,aAAa,CAAC,CAAC;AACnC;;AAGA,SAAgB,iBAAyB;CAEvC,OADY,WAAW,aAChB,CAAA,CAAI,eAAe;AAC5B;;AAGA,SAAgB,oBAGd;CACA,MAAM,MAAM,WAAW,aAAa;CACpC,OAAO;EAAE,UAAU,IAAI;EAAU,QAAQ,IAAI;CAAO;AACtD;;AAGA,SAAgB,uBAA+C;CAE7D,OADY,WAAW,aAChB,CAAA,CAAI,eAAe;AAC5B"}
|
package/dist/tooltip-bdmbX6vC.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
/*! Rendra Design System v2.4.0 | MIT | © 2026 Bruno Magalhaes | brunomagalhaes.me */
|
|
2
|
-
import { t as cn } from "./cn-DXDpTGsu.js";
|
|
3
|
-
import { Check, ChevronRight } from "lucide-react";
|
|
4
|
-
import { DropdownMenu, Tooltip } from "radix-ui";
|
|
5
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
//#region src/components/ui/dropdown-menu.tsx
|
|
7
|
-
var DropdownMenu$1 = DropdownMenu.Root;
|
|
8
|
-
var DropdownMenuTrigger = DropdownMenu.Trigger;
|
|
9
|
-
var DropdownMenuGroup = DropdownMenu.Group;
|
|
10
|
-
var DropdownMenuSub = DropdownMenu.Sub;
|
|
11
|
-
var DropdownMenuRadioGroup = DropdownMenu.RadioGroup;
|
|
12
|
-
var panel = "z-50 w-max min-w-3xs max-w-popover overflow-hidden rounded-surface border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95";
|
|
13
|
-
var item = "relative flex min-h-touch cursor-pointer items-center gap-2 rounded-item px-3 text-sm outline-none select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-highlighted:bg-accent data-highlighted:text-accent-foreground md:min-h-0 md:py-2 [&_svg]:size-icon-sm [&_svg]:shrink-0 [&_svg]:text-muted-foreground";
|
|
14
|
-
function DropdownMenuContent({ className, sideOffset = 8, ...props }) {
|
|
15
|
-
return /* @__PURE__ */ jsx(DropdownMenu.Portal, { children: /* @__PURE__ */ jsx(DropdownMenu.Content, {
|
|
16
|
-
sideOffset,
|
|
17
|
-
collisionPadding: 16,
|
|
18
|
-
"data-rendra": "DDM-001",
|
|
19
|
-
className: cn(panel, className),
|
|
20
|
-
...props
|
|
21
|
-
}) });
|
|
22
|
-
}
|
|
23
|
-
function DropdownMenuItem({ className, destructive, ...props }) {
|
|
24
|
-
return /* @__PURE__ */ jsx(DropdownMenu.Item, {
|
|
25
|
-
className: cn(item, destructive && "text-destructive data-highlighted:bg-destructive-soft data-highlighted:text-destructive-soft-foreground [&_svg]:text-current", className),
|
|
26
|
-
...props
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
function DropdownMenuCheckboxItem({ className, children, ...props }) {
|
|
30
|
-
return /* @__PURE__ */ jsxs(DropdownMenu.CheckboxItem, {
|
|
31
|
-
className: cn(item, "pl-8", className),
|
|
32
|
-
...props,
|
|
33
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
34
|
-
className: "absolute left-2 flex size-icon-sm items-center justify-center",
|
|
35
|
-
children: /* @__PURE__ */ jsx(DropdownMenu.ItemIndicator, { children: /* @__PURE__ */ jsx(Check, { className: "text-primary-text" }) })
|
|
36
|
-
}), children]
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
function DropdownMenuRadioItem({ className, children, ...props }) {
|
|
40
|
-
return /* @__PURE__ */ jsxs(DropdownMenu.RadioItem, {
|
|
41
|
-
className: cn(item, "pl-8", className),
|
|
42
|
-
...props,
|
|
43
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
44
|
-
className: "absolute left-2 flex size-icon-sm items-center justify-center",
|
|
45
|
-
children: /* @__PURE__ */ jsx(DropdownMenu.ItemIndicator, { children: /* @__PURE__ */ jsx(Check, { className: "text-primary-text" }) })
|
|
46
|
-
}), children]
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
function DropdownMenuLabel({ className, ...props }) {
|
|
50
|
-
return /* @__PURE__ */ jsx(DropdownMenu.Label, {
|
|
51
|
-
className: cn("px-2 py-2 text-xs font-medium text-muted-foreground", className),
|
|
52
|
-
...props
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
function DropdownMenuSeparator({ className, ...props }) {
|
|
56
|
-
return /* @__PURE__ */ jsx(DropdownMenu.Separator, {
|
|
57
|
-
className: cn("-mx-1 my-1 h-px bg-border", className),
|
|
58
|
-
...props
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
function DropdownMenuSubTrigger({ className, children, ...props }) {
|
|
62
|
-
return /* @__PURE__ */ jsxs(DropdownMenu.SubTrigger, {
|
|
63
|
-
className: cn(item, "data-[state=open]:bg-accent", className),
|
|
64
|
-
...props,
|
|
65
|
-
children: [children, /* @__PURE__ */ jsx(ChevronRight, { className: "ml-auto" })]
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
function DropdownMenuSubContent({ className, ...props }) {
|
|
69
|
-
return /* @__PURE__ */ jsx(DropdownMenu.Portal, { children: /* @__PURE__ */ jsx(DropdownMenu.SubContent, {
|
|
70
|
-
collisionPadding: 16,
|
|
71
|
-
className: cn(panel, className),
|
|
72
|
-
...props
|
|
73
|
-
}) });
|
|
74
|
-
}
|
|
75
|
-
//#endregion
|
|
76
|
-
//#region src/components/ui/tooltip.tsx
|
|
77
|
-
/**
|
|
78
|
-
* Tooltip: só para informação complementar, nunca essencial (não existe hover no toque).
|
|
79
|
-
* Informação essencial vai em texto de ajuda visível ou em Popover acionado por toque.
|
|
80
|
-
*/
|
|
81
|
-
function TooltipProvider({ children }) {
|
|
82
|
-
return /* @__PURE__ */ jsx(Tooltip.Provider, {
|
|
83
|
-
delayDuration: 300,
|
|
84
|
-
skipDelayDuration: 150,
|
|
85
|
-
children
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
function Tooltip$1({ content, children, side = "top", disabled }) {
|
|
89
|
-
if (disabled) return /* @__PURE__ */ jsx(Fragment, { children });
|
|
90
|
-
return /* @__PURE__ */ jsxs(Tooltip.Root, { children: [/* @__PURE__ */ jsx(Tooltip.Trigger, {
|
|
91
|
-
asChild: true,
|
|
92
|
-
children
|
|
93
|
-
}), /* @__PURE__ */ jsx(Tooltip.Portal, { children: /* @__PURE__ */ jsx(Tooltip.Content, {
|
|
94
|
-
side,
|
|
95
|
-
sideOffset: 8,
|
|
96
|
-
collisionPadding: 16,
|
|
97
|
-
"data-rendra": "TIP-001",
|
|
98
|
-
className: cn("z-50 max-w-xs rounded-control bg-foreground px-3 py-2 text-xs font-medium text-background", "animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0"),
|
|
99
|
-
children: content
|
|
100
|
-
}) })] });
|
|
101
|
-
}
|
|
102
|
-
//#endregion
|
|
103
|
-
export { DropdownMenuContent as a, DropdownMenuLabel as c, DropdownMenuSeparator as d, DropdownMenuSub as f, DropdownMenuTrigger as h, DropdownMenuCheckboxItem as i, DropdownMenuRadioGroup as l, DropdownMenuSubTrigger as m, TooltipProvider as n, DropdownMenuGroup as o, DropdownMenuSubContent as p, DropdownMenu$1 as r, DropdownMenuItem as s, Tooltip$1 as t, DropdownMenuRadioItem as u };
|
|
104
|
-
|
|
105
|
-
//# sourceMappingURL=tooltip-bdmbX6vC.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip-bdmbX6vC.js","names":[],"sources":["../src/components/ui/dropdown-menu.tsx","../src/components/ui/tooltip.tsx"],"sourcesContent":["import { Check, ChevronRight } from 'lucide-react'\nimport { DropdownMenu as D } from 'radix-ui'\nimport type { ComponentProps } from 'react'\nimport { cn } from '@/lib/cn'\n\nexport const DropdownMenu = D.Root\nexport const DropdownMenuTrigger = D.Trigger\nexport const DropdownMenuGroup = D.Group\nexport const DropdownMenuSub = D.Sub\nexport const DropdownMenuRadioGroup = D.RadioGroup\n\nconst panel =\n 'z-50 w-max min-w-3xs max-w-popover overflow-hidden rounded-surface border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95'\n\n// Itens com 44px no mobile (toque) e compactos a partir de md.\nconst item =\n 'relative flex min-h-touch cursor-pointer items-center gap-2 rounded-item px-3 text-sm outline-none select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-highlighted:bg-accent data-highlighted:text-accent-foreground md:min-h-0 md:py-2 [&_svg]:size-icon-sm [&_svg]:shrink-0 [&_svg]:text-muted-foreground'\n\nexport function DropdownMenuContent({\n className,\n sideOffset = 8,\n ...props\n}: ComponentProps<typeof D.Content>) {\n return (\n <D.Portal>\n <D.Content\n sideOffset={sideOffset}\n collisionPadding={16}\n data-rendra=\"DDM-001\"\n className={cn(panel, className)}\n {...props}\n />\n </D.Portal>\n )\n}\n\ninterface ItemProps extends ComponentProps<typeof D.Item> {\n /** Item destrutivo (excluir, sair): texto na cor destrutiva. */\n destructive?: boolean\n}\n\nexport function DropdownMenuItem({ className, destructive, ...props }: ItemProps) {\n return (\n <D.Item\n className={cn(\n item,\n destructive &&\n 'text-destructive data-highlighted:bg-destructive-soft data-highlighted:text-destructive-soft-foreground [&_svg]:text-current',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport function DropdownMenuCheckboxItem({\n className,\n children,\n ...props\n}: ComponentProps<typeof D.CheckboxItem>) {\n return (\n <D.CheckboxItem className={cn(item, 'pl-8', className)} {...props}>\n <span className=\"absolute left-2 flex size-icon-sm items-center justify-center\">\n <D.ItemIndicator>\n <Check className=\"text-primary-text\" />\n </D.ItemIndicator>\n </span>\n {children}\n </D.CheckboxItem>\n )\n}\n\nexport function DropdownMenuRadioItem({\n className,\n children,\n ...props\n}: ComponentProps<typeof D.RadioItem>) {\n return (\n <D.RadioItem className={cn(item, 'pl-8', className)} {...props}>\n <span className=\"absolute left-2 flex size-icon-sm items-center justify-center\">\n <D.ItemIndicator>\n <Check className=\"text-primary-text\" />\n </D.ItemIndicator>\n </span>\n {children}\n </D.RadioItem>\n )\n}\n\nexport function DropdownMenuLabel({ className, ...props }: ComponentProps<typeof D.Label>) {\n return (\n <D.Label\n className={cn('px-2 py-2 text-xs font-medium text-muted-foreground', className)}\n {...props}\n />\n )\n}\n\nexport function DropdownMenuSeparator({ className, ...props }: ComponentProps<typeof D.Separator>) {\n return <D.Separator className={cn('-mx-1 my-1 h-px bg-border', className)} {...props} />\n}\n\nexport function DropdownMenuSubTrigger({\n className,\n children,\n ...props\n}: ComponentProps<typeof D.SubTrigger>) {\n return (\n <D.SubTrigger className={cn(item, 'data-[state=open]:bg-accent', className)} {...props}>\n {children}\n <ChevronRight className=\"ml-auto\" />\n </D.SubTrigger>\n )\n}\n\nexport function DropdownMenuSubContent({\n className,\n ...props\n}: ComponentProps<typeof D.SubContent>) {\n return (\n <D.Portal>\n <D.SubContent collisionPadding={16} className={cn(panel, className)} {...props} />\n </D.Portal>\n )\n}\n","import { Tooltip as T } from 'radix-ui'\nimport type { ReactNode } from 'react'\nimport { cn } from '@/lib/cn'\n\n/**\n * Tooltip: só para informação complementar, nunca essencial (não existe hover no toque).\n * Informação essencial vai em texto de ajuda visível ou em Popover acionado por toque.\n */\nexport function TooltipProvider({ children }: { children: ReactNode }) {\n return (\n <T.Provider delayDuration={300} skipDelayDuration={150}>\n {children}\n </T.Provider>\n )\n}\n\ninterface TooltipProps {\n content: ReactNode\n children: ReactNode\n side?: 'top' | 'right' | 'bottom' | 'left'\n /** Desliga o tooltip sem mudar a árvore (ex.: sidebar expandida já mostra o rótulo). */\n disabled?: boolean\n}\n\nexport function Tooltip({ content, children, side = 'top', disabled }: TooltipProps) {\n if (disabled) return <>{children}</>\n return (\n <T.Root>\n <T.Trigger asChild>{children}</T.Trigger>\n <T.Portal>\n <T.Content\n side={side}\n sideOffset={8}\n collisionPadding={16}\n data-rendra=\"TIP-001\"\n className={cn(\n 'z-50 max-w-xs rounded-control bg-foreground px-3 py-2 text-xs font-medium text-background',\n 'animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0',\n )}\n >\n {content}\n </T.Content>\n </T.Portal>\n </T.Root>\n )\n}\n"],"mappings":";;;;;;AAKA,IAAa,iBAAe,aAA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