@sesionario/blocks 1.1.1 → 1.2.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 CHANGED
@@ -4,6 +4,8 @@ Shared UI components for [Sesionario](https://github.com/Docufacil) applications
4
4
 
5
5
  This package is the Sesionario-specific successor to `@algenium/blocks`. It ships only the components, hooks, and data the five Sesionario apps (`admin`, `app`, `auth`, `backoffice`, `pharma`) actually use, plus shadcn `Empty` primitives under the hood of `EmptyState`.
6
6
 
7
+ Shared feedback patterns include `ConfirmDestructiveDialog` (confirm before delete/mute and similar irreversible actions).
8
+
7
9
  ## Install
8
10
 
9
11
  ```bash
package/dist/index.cjs CHANGED
@@ -7,10 +7,11 @@ var clsx = require('clsx');
7
7
  var tailwindMerge = require('tailwind-merge');
8
8
  var classVarianceAuthority = require('class-variance-authority');
9
9
  var jsxRuntime = require('react/jsx-runtime');
10
+ var AlertDialogPrimitive = require('@radix-ui/react-alert-dialog');
11
+ var reactSlot = require('@radix-ui/react-slot');
10
12
  var nextThemes = require('next-themes');
11
13
  var framerMotion = require('framer-motion');
12
14
  var DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
13
- var reactSlot = require('@radix-ui/react-slot');
14
15
  var SliderPrimitive = require('@radix-ui/react-slider');
15
16
  var TogglePrimitive = require('@radix-ui/react-toggle');
16
17
  var DialogPrimitive = require('@radix-ui/react-dialog');
@@ -43,6 +44,7 @@ function _interopNamespace(e) {
43
44
  }
44
45
 
45
46
  var React5__namespace = /*#__PURE__*/_interopNamespace(React5);
47
+ var AlertDialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(AlertDialogPrimitive);
46
48
  var DropdownMenuPrimitive__namespace = /*#__PURE__*/_interopNamespace(DropdownMenuPrimitive);
47
49
  var SliderPrimitive__namespace = /*#__PURE__*/_interopNamespace(SliderPrimitive);
48
50
  var TogglePrimitive__namespace = /*#__PURE__*/_interopNamespace(TogglePrimitive);
@@ -242,6 +244,217 @@ function EmptyState({
242
244
  }
243
245
  );
244
246
  }
247
+ var buttonVariants = classVarianceAuthority.cva(
248
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
249
+ {
250
+ variants: {
251
+ variant: {
252
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
253
+ destructive: "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
254
+ outline: "border bg-background text-foreground shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:text-foreground dark:hover:bg-muted dark:hover:text-foreground",
255
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
256
+ ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50 dark:hover:text-foreground",
257
+ link: "text-primary underline-offset-4 hover:underline"
258
+ },
259
+ size: {
260
+ default: "h-9 px-4 py-2 has-[>svg]:px-3",
261
+ sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
262
+ lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
263
+ icon: "size-9",
264
+ "icon-sm": "size-8",
265
+ "icon-lg": "size-10"
266
+ }
267
+ },
268
+ defaultVariants: {
269
+ variant: "default",
270
+ size: "default"
271
+ }
272
+ }
273
+ );
274
+ function Button({
275
+ className,
276
+ variant = "default",
277
+ size = "default",
278
+ asChild = false,
279
+ ...props
280
+ }) {
281
+ const Comp = asChild ? reactSlot.Slot : "button";
282
+ return /* @__PURE__ */ jsxRuntime.jsx(
283
+ Comp,
284
+ {
285
+ "data-slot": "button",
286
+ "data-variant": variant,
287
+ "data-size": size,
288
+ className: cn(buttonVariants({ variant, size, className })),
289
+ ...props
290
+ }
291
+ );
292
+ }
293
+ function AlertDialog({
294
+ ...props
295
+ }) {
296
+ return /* @__PURE__ */ jsxRuntime.jsx(AlertDialogPrimitive__namespace.Root, { "data-slot": "alert-dialog", ...props });
297
+ }
298
+ function AlertDialogPortal({
299
+ ...props
300
+ }) {
301
+ return /* @__PURE__ */ jsxRuntime.jsx(AlertDialogPrimitive__namespace.Portal, { "data-slot": "alert-dialog-portal", ...props });
302
+ }
303
+ function AlertDialogOverlay({
304
+ className,
305
+ ...props
306
+ }) {
307
+ return /* @__PURE__ */ jsxRuntime.jsx(
308
+ AlertDialogPrimitive__namespace.Overlay,
309
+ {
310
+ "data-slot": "alert-dialog-overlay",
311
+ className: cn(
312
+ "fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",
313
+ className
314
+ ),
315
+ ...props
316
+ }
317
+ );
318
+ }
319
+ function AlertDialogContent({
320
+ className,
321
+ size = "default",
322
+ ...props
323
+ }) {
324
+ return /* @__PURE__ */ jsxRuntime.jsxs(AlertDialogPortal, { children: [
325
+ /* @__PURE__ */ jsxRuntime.jsx(AlertDialogOverlay, {}),
326
+ /* @__PURE__ */ jsxRuntime.jsx(
327
+ AlertDialogPrimitive__namespace.Content,
328
+ {
329
+ "data-slot": "alert-dialog-content",
330
+ "data-size": size,
331
+ className: cn(
332
+ "group/alert-dialog-content fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[size=sm]:max-w-xs data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[size=default]:sm:max-w-lg",
333
+ className
334
+ ),
335
+ ...props
336
+ }
337
+ )
338
+ ] });
339
+ }
340
+ function AlertDialogHeader({
341
+ className,
342
+ ...props
343
+ }) {
344
+ return /* @__PURE__ */ jsxRuntime.jsx(
345
+ "div",
346
+ {
347
+ "data-slot": "alert-dialog-header",
348
+ className: cn(
349
+ "flex flex-col gap-1.5 text-center sm:text-left",
350
+ className
351
+ ),
352
+ ...props
353
+ }
354
+ );
355
+ }
356
+ function AlertDialogFooter({
357
+ className,
358
+ ...props
359
+ }) {
360
+ return /* @__PURE__ */ jsxRuntime.jsx(
361
+ "div",
362
+ {
363
+ "data-slot": "alert-dialog-footer",
364
+ className: cn(
365
+ "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
366
+ className
367
+ ),
368
+ ...props
369
+ }
370
+ );
371
+ }
372
+ function AlertDialogTitle({
373
+ className,
374
+ ...props
375
+ }) {
376
+ return /* @__PURE__ */ jsxRuntime.jsx(
377
+ AlertDialogPrimitive__namespace.Title,
378
+ {
379
+ "data-slot": "alert-dialog-title",
380
+ className: cn("text-lg font-semibold", className),
381
+ ...props
382
+ }
383
+ );
384
+ }
385
+ function AlertDialogDescription({
386
+ className,
387
+ ...props
388
+ }) {
389
+ return /* @__PURE__ */ jsxRuntime.jsx(
390
+ AlertDialogPrimitive__namespace.Description,
391
+ {
392
+ "data-slot": "alert-dialog-description",
393
+ className: cn("text-sm text-muted-foreground", className),
394
+ ...props
395
+ }
396
+ );
397
+ }
398
+ function AlertDialogAction({
399
+ className,
400
+ variant = "default",
401
+ size = "default",
402
+ ...props
403
+ }) {
404
+ return /* @__PURE__ */ jsxRuntime.jsx(Button, { variant, size, asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
405
+ AlertDialogPrimitive__namespace.Action,
406
+ {
407
+ "data-slot": "alert-dialog-action",
408
+ className: cn(className),
409
+ ...props
410
+ }
411
+ ) });
412
+ }
413
+ function AlertDialogCancel({
414
+ className,
415
+ variant = "outline",
416
+ size = "default",
417
+ ...props
418
+ }) {
419
+ return /* @__PURE__ */ jsxRuntime.jsx(Button, { variant, size, asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
420
+ AlertDialogPrimitive__namespace.Cancel,
421
+ {
422
+ "data-slot": "alert-dialog-cancel",
423
+ className: cn(className),
424
+ ...props
425
+ }
426
+ ) });
427
+ }
428
+ function ConfirmDestructiveDialog({
429
+ open,
430
+ onOpenChange,
431
+ title,
432
+ description,
433
+ confirmLabel = "Eliminar",
434
+ cancelLabel = "Cancelar",
435
+ onConfirm
436
+ }) {
437
+ return /* @__PURE__ */ jsxRuntime.jsx(AlertDialog, { open, onOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(AlertDialogContent, { size: "sm", children: [
438
+ /* @__PURE__ */ jsxRuntime.jsxs(AlertDialogHeader, { children: [
439
+ /* @__PURE__ */ jsxRuntime.jsx(AlertDialogTitle, { children: title }),
440
+ /* @__PURE__ */ jsxRuntime.jsx(AlertDialogDescription, { children: description })
441
+ ] }),
442
+ /* @__PURE__ */ jsxRuntime.jsxs(AlertDialogFooter, { children: [
443
+ /* @__PURE__ */ jsxRuntime.jsx(AlertDialogCancel, { children: cancelLabel }),
444
+ /* @__PURE__ */ jsxRuntime.jsx(
445
+ AlertDialogAction,
446
+ {
447
+ variant: "destructive",
448
+ onClick: () => {
449
+ onConfirm();
450
+ onOpenChange(false);
451
+ },
452
+ children: confirmLabel
453
+ }
454
+ )
455
+ ] })
456
+ ] }) });
457
+ }
245
458
  var miniMenuContentClassName = "max-h-none overflow-x-visible overflow-y-visible";
246
459
  var miniMenuContentDefaults = {
247
460
  sideOffset: 8,
@@ -348,52 +561,6 @@ function DropdownMenuShortcut({
348
561
  }
349
562
  );
350
563
  }
351
- var buttonVariants = classVarianceAuthority.cva(
352
- "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
353
- {
354
- variants: {
355
- variant: {
356
- default: "bg-primary text-primary-foreground hover:bg-primary/90",
357
- destructive: "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
358
- outline: "border bg-background text-foreground shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:text-foreground dark:hover:bg-muted dark:hover:text-foreground",
359
- secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
360
- ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50 dark:hover:text-foreground",
361
- link: "text-primary underline-offset-4 hover:underline"
362
- },
363
- size: {
364
- default: "h-9 px-4 py-2 has-[>svg]:px-3",
365
- sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
366
- lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
367
- icon: "size-9",
368
- "icon-sm": "size-8",
369
- "icon-lg": "size-10"
370
- }
371
- },
372
- defaultVariants: {
373
- variant: "default",
374
- size: "default"
375
- }
376
- }
377
- );
378
- function Button({
379
- className,
380
- variant = "default",
381
- size = "default",
382
- asChild = false,
383
- ...props
384
- }) {
385
- const Comp = asChild ? reactSlot.Slot : "button";
386
- return /* @__PURE__ */ jsxRuntime.jsx(
387
- Comp,
388
- {
389
- "data-slot": "button",
390
- "data-variant": variant,
391
- "data-size": size,
392
- className: cn(buttonVariants({ variant, size, className })),
393
- ...props
394
- }
395
- );
396
- }
397
564
  var defaultLabels = {
398
565
  theme: "Theme",
399
566
  system: "System",
@@ -443,6 +610,7 @@ function ThemeSwitcher({
443
610
  }) {
444
611
  const { theme, setTheme } = nextThemes.useTheme();
445
612
  const [mounted, setMounted] = React5.useState(false);
613
+ const reduceMotion = framerMotion.useReducedMotion();
446
614
  const sizes = sizeClasses[size];
447
615
  const shapeClass = shapeClasses[shape];
448
616
  const labels = { ...defaultLabels, ...userLabels };
@@ -526,11 +694,17 @@ function ThemeSwitcher({
526
694
  "button",
527
695
  {
528
696
  "aria-label": labels[key],
697
+ "aria-pressed": isActive,
529
698
  className: cn("relative", sizes.button, shapeClass),
530
699
  onClick: () => handleThemeClick(key),
531
700
  type: "button",
532
701
  children: [
533
- /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children: isActive && /* @__PURE__ */ jsxRuntime.jsx(
702
+ reduceMotion ? isActive ? /* @__PURE__ */ jsxRuntime.jsx(
703
+ "div",
704
+ {
705
+ className: cn("absolute inset-0 bg-secondary", shapeClass)
706
+ }
707
+ ) : null : /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children: isActive && /* @__PURE__ */ jsxRuntime.jsx(
534
708
  framerMotion.motion.div,
535
709
  {
536
710
  className: cn("absolute inset-0 bg-secondary", shapeClass),
@@ -795,6 +969,7 @@ function LanguageSwitcher({
795
969
  const onLanguageChange = propOnLanguageChange ?? context?.setLanguage;
796
970
  const sizes = sizeClasses2[size];
797
971
  const shapeClass = shapeClasses2[shape];
972
+ const reduceMotion = framerMotion.useReducedMotion();
798
973
  const defaultLabels4 = {
799
974
  language: labels.language ?? "Language"
800
975
  };
@@ -856,11 +1031,17 @@ function LanguageSwitcher({
856
1031
  "button",
857
1032
  {
858
1033
  "aria-label": label,
1034
+ "aria-pressed": isActive,
859
1035
  className: cn("relative font-semibold", sizes.button, shapeClass),
860
1036
  onClick: () => onLanguageChange?.(key),
861
1037
  type: "button",
862
1038
  children: [
863
- /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children: isActive && /* @__PURE__ */ jsxRuntime.jsx(
1039
+ reduceMotion ? isActive ? /* @__PURE__ */ jsxRuntime.jsx(
1040
+ "div",
1041
+ {
1042
+ className: cn("absolute inset-0 bg-secondary", shapeClass)
1043
+ }
1044
+ ) : null : /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children: isActive && /* @__PURE__ */ jsxRuntime.jsx(
864
1045
  framerMotion.motion.div,
865
1046
  {
866
1047
  className: cn("absolute inset-0 bg-secondary", shapeClass),
@@ -4629,6 +4810,7 @@ exports.BubbleContent = BubbleContent;
4629
4810
  exports.BubbleGroup = BubbleGroup;
4630
4811
  exports.BubbleReactions = BubbleReactions;
4631
4812
  exports.ChatMessageList = ChatMessageList;
4813
+ exports.ConfirmDestructiveDialog = ConfirmDestructiveDialog;
4632
4814
  exports.EmojiPicker = EmojiPicker;
4633
4815
  exports.EmojiPickerPopover = EmojiPickerPopover;
4634
4816
  exports.Empty = Empty;