@boxcustodia/library 2.0.0-alpha.22 → 2.0.0-alpha.24

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.
Files changed (110) hide show
  1. package/dist/components/calendar/calendar.cjs.js +1 -1
  2. package/dist/components/calendar/calendar.es.js +43 -44
  3. package/dist/components/date-picker/date-input.cjs.js +1 -1
  4. package/dist/components/date-picker/date-input.es.js +160 -140
  5. package/dist/components/pagination/pagination.cjs.js +1 -1
  6. package/dist/components/pagination/pagination.es.js +37 -35
  7. package/dist/components/popover/popover.cjs.js +1 -1
  8. package/dist/components/popover/popover.es.js +1 -1
  9. package/dist/components/scroll-area/scroll-area.cjs.js +1 -1
  10. package/dist/components/scroll-area/scroll-area.es.js +4 -4
  11. package/dist/components/select/select.cjs.js +1 -1
  12. package/dist/components/select/select.es.js +94 -90
  13. package/dist/components/tag/tag.cjs.js +1 -1
  14. package/dist/components/tag/tag.es.js +37 -18
  15. package/dist/hooks/use-action/use-action.cjs.js +1 -0
  16. package/dist/hooks/use-action/use-action.es.js +41 -0
  17. package/dist/hooks/use-pagination/use-pagination.cjs.js +1 -1
  18. package/dist/hooks/use-pagination/use-pagination.es.js +77 -32
  19. package/dist/hooks/use-range-pagination/use-range-pagination.cjs.js +1 -1
  20. package/dist/hooks/use-range-pagination/use-range-pagination.es.js +8 -5
  21. package/dist/hooks/use-selection/use-selection.cjs.js +1 -1
  22. package/dist/hooks/use-selection/use-selection.es.js +95 -33
  23. package/dist/hooks/use-session-storage/use-session-storage.cjs.js +1 -0
  24. package/dist/hooks/use-session-storage/use-session-storage.es.js +57 -0
  25. package/dist/index.cjs.js +1 -1
  26. package/dist/index.es.js +61 -63
  27. package/dist/src/components/select/select.d.ts +9 -2
  28. package/dist/src/components/tag/tag.d.ts +2 -1
  29. package/dist/src/hooks/index.d.ts +2 -3
  30. package/dist/src/hooks/internal/index.d.ts +1 -0
  31. package/dist/src/hooks/internal/serializer.d.ts +4 -0
  32. package/dist/src/hooks/use-action/index.d.ts +1 -0
  33. package/dist/src/hooks/use-action/use-action.d.ts +22 -0
  34. package/dist/src/hooks/use-local-storage/use-local-storage.d.ts +2 -4
  35. package/dist/src/hooks/use-pagination/use-pagination.d.ts +47 -32
  36. package/dist/src/hooks/use-range-pagination/use-range-pagination.d.ts +16 -10
  37. package/dist/src/hooks/use-selection/use-selection.d.ts +39 -45
  38. package/dist/src/hooks/use-session-storage/index.d.ts +1 -0
  39. package/dist/src/hooks/use-session-storage/use-session-storage.d.ts +11 -0
  40. package/package.json +1 -1
  41. package/src/components/calendar/calendar.tsx +10 -8
  42. package/src/components/combobox/combobox.stories.tsx +16 -0
  43. package/src/components/date-picker/date-input.tsx +23 -2
  44. package/src/components/form/form.tsx +3 -2
  45. package/src/components/pagination/pagination.tsx +5 -3
  46. package/src/components/popover/popover.tsx +1 -1
  47. package/src/components/scroll-area/scroll-area.tsx +2 -2
  48. package/src/components/select/select.tsx +14 -3
  49. package/src/components/tag/tag.stories.tsx +47 -2
  50. package/src/components/tag/tag.tsx +28 -6
  51. package/src/hooks/index.ts +2 -3
  52. package/src/hooks/internal/index.ts +1 -0
  53. package/src/hooks/internal/serializer.ts +4 -0
  54. package/src/hooks/use-action/index.ts +1 -0
  55. package/src/hooks/{use-mutation/use-mutation.stories.tsx → use-action/use-action.stories.tsx} +34 -34
  56. package/src/hooks/{use-mutation/use-mutation.test.ts → use-action/use-action.test.ts} +53 -53
  57. package/src/hooks/{use-mutation/use-mutation.ts → use-action/use-action.ts} +20 -20
  58. package/src/hooks/use-click-outside/use-click-outside.stories.tsx +0 -1
  59. package/src/hooks/use-clipboard/use-clipboard.stories.tsx +0 -1
  60. package/src/hooks/use-document-title/use-document-title.stories.tsx +0 -1
  61. package/src/hooks/use-is-visible/use-is-visible.test.tsx +1 -1
  62. package/src/hooks/use-local-storage/use-local-storage.stories.tsx +0 -1
  63. package/src/hooks/use-local-storage/use-local-storage.ts +2 -5
  64. package/src/hooks/use-media-query/use-media-query.stories.tsx +0 -1
  65. package/src/hooks/use-pagination/use-pagination.stories.tsx +720 -57
  66. package/src/hooks/use-pagination/use-pagination.test.tsx +560 -48
  67. package/src/hooks/use-pagination/use-pagination.ts +266 -0
  68. package/src/hooks/use-prevent-page-close/use-prevent-page-close.stories.tsx +0 -1
  69. package/src/hooks/use-range-pagination/use-range-pagination.test.tsx +2 -2
  70. package/src/hooks/use-range-pagination/use-range-pagination.tsx +24 -21
  71. package/src/hooks/use-selection/use-selection.stories.tsx +339 -84
  72. package/src/hooks/use-selection/use-selection.test.tsx +417 -2
  73. package/src/hooks/use-selection/use-selection.ts +212 -102
  74. package/src/hooks/use-session-storage/index.ts +1 -0
  75. package/src/hooks/use-session-storage/use-session-storage.stories.tsx +122 -0
  76. package/src/hooks/use-session-storage/use-session-storage.test.ts +164 -0
  77. package/src/hooks/use-session-storage/use-session-storage.ts +115 -0
  78. package/dist/hooks/use-async/use-async.cjs.js +0 -1
  79. package/dist/hooks/use-async/use-async.es.js +0 -57
  80. package/dist/hooks/use-focus-trap/scope-tab.cjs.js +0 -1
  81. package/dist/hooks/use-focus-trap/scope-tab.es.js +0 -21
  82. package/dist/hooks/use-focus-trap/tabbable.cjs.js +0 -1
  83. package/dist/hooks/use-focus-trap/tabbable.es.js +0 -38
  84. package/dist/hooks/use-focus-trap/use-focus-trap.cjs.js +0 -1
  85. package/dist/hooks/use-focus-trap/use-focus-trap.es.js +0 -34
  86. package/dist/hooks/use-mutation/use-mutation.cjs.js +0 -1
  87. package/dist/hooks/use-mutation/use-mutation.es.js +0 -41
  88. package/dist/src/hooks/use-async/index.d.ts +0 -1
  89. package/dist/src/hooks/use-async/use-async.d.ts +0 -21
  90. package/dist/src/hooks/use-focus-trap/index.d.ts +0 -1
  91. package/dist/src/hooks/use-focus-trap/scope-tab.d.ts +0 -1
  92. package/dist/src/hooks/use-focus-trap/tabbable.d.ts +0 -4
  93. package/dist/src/hooks/use-focus-trap/use-focus-trap.d.ts +0 -1
  94. package/dist/src/hooks/use-mutation/index.d.ts +0 -1
  95. package/dist/src/hooks/use-mutation/use-mutation.d.ts +0 -22
  96. package/dist/src/hooks/use-mutation/use-mutation.test.d.ts +0 -1
  97. package/src/hooks/use-async/index.ts +0 -1
  98. package/src/hooks/use-async/use-async.stories.tsx +0 -272
  99. package/src/hooks/use-async/use-async.test.ts +0 -397
  100. package/src/hooks/use-async/use-async.ts +0 -135
  101. package/src/hooks/use-focus-trap/index.ts +0 -1
  102. package/src/hooks/use-focus-trap/scope-tab.ts +0 -38
  103. package/src/hooks/use-focus-trap/tabbable.ts +0 -70
  104. package/src/hooks/use-focus-trap/use-focus-trap.stories.tsx +0 -37
  105. package/src/hooks/use-focus-trap/use-focus-trap.test.ts +0 -355
  106. package/src/hooks/use-focus-trap/use-focus-trap.ts +0 -78
  107. package/src/hooks/use-mutation/index.ts +0 -1
  108. package/src/hooks/use-pagination/use-pagination.tsx +0 -84
  109. /package/dist/src/hooks/{use-async/use-async.test.d.ts → use-action/use-action.test.d.ts} +0 -0
  110. /package/dist/src/hooks/{use-focus-trap/use-focus-trap.test.d.ts → use-session-storage/use-session-storage.test.d.ts} +0 -0
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),_=require("date-fns/locale"),g=require("lucide-react"),w=require("react-day-picker"),C=require("../select/select.cjs.js"),a=require("../../lib/cn.cjs.js"),p=new Date().getFullYear(),j=new Date(p-100,0),D=new Date(p+100,11);function N({options:l=[],value:d,onChange:o}){const i=l.map(e=>({label:e.label??"",value:e.value??0})),c=i.find(e=>e.value===Number(d))??null;return r.jsx(C.Select,{items:i,value:c,"aria-invalid":!1,className:"py-1 h-7",getLabel:e=>e.label,getId:e=>String(e.value),onValueChange:e=>{!o||e===null||o({target:{value:String(e.value)}})}})}const m="relative flex size-(--cell-size) text-base sm:text-sm items-center justify-center rounded-lg text-foreground not-in-data-selected:hover:bg-accent disabled:pointer-events-none disabled:opacity-64 [&_svg:not([class*='opacity-'])]:opacity-80 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0";function k({className:l,classNames:d,showOutsideDays:o=!0,components:i,mode:c="single",captionLayout:e="dropdown",startMonth:b=j,endMonth:x=D,...v}){const u={button_next:m,button_previous:m,caption_label:"text-base sm:text-sm font-medium flex items-center gap-2 h-full",day:"size-(--cell-size) text-sm py-px",day_button:a.cn(m,"in-data-disabled:pointer-events-none in-[.range-middle]:rounded-none in-[.range-end:not(.range-start)]:rounded-s-none in-[.range-start:not(.range-end)]:rounded-e-none in-[.range-middle]:in-data-selected:bg-accent in-data-selected:bg-primary in-[.range-middle]:in-data-selected:text-foreground in-data-disabled:text-muted-foreground/72 in-data-outside:text-muted-foreground/72 in-data-selected:in-data-outside:text-primary-foreground in-data-selected:text-primary-foreground in-data-disabled:line-through outline-none in-[[data-selected]:not(.range-middle)]:transition-[color,background-color,border-radius,box-shadow] focus-visible:z-1 focus-visible:ring-[3px] focus-visible:ring-ring/50"),dropdown:"absolute bg-popover inset-0 opacity-0",dropdown_root:"relative has-focus:border-ring has-focus:ring-ring/50 has-focus:ring-[3px] border border-input shadow-xs/5 rounded-lg px-[calc(--spacing(3)-1px)] h-9 sm:h-8 [&_svg:not([class*='opacity-'])]:opacity-80 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:-me-1",dropdowns:"w-full flex items-center text-base sm:text-sm justify-center h-(--cell-size) gap-1.5 *:[span]:font-medium",hidden:"invisible",month:"w-full",month_caption:"relative mx-(--cell-size) px-1 mb-1 flex h-(--cell-size) items-center justify-center z-2",months:"relative flex flex-col sm:flex-row gap-2",nav:"absolute top-0 flex w-full justify-between z-1",outside:"text-muted-foreground data-selected:bg-accent/50 data-selected:text-muted-foreground",range_end:"range-end",range_middle:"range-middle",range_start:"range-start",today:"*:after:pointer-events-none *:after:absolute *:after:bottom-1 *:after:start-1/2 *:after:z-1 *:after:size-[3px] *:after:-translate-x-1/2 *:after:rounded-full *:after:bg-primary [&[data-selected]:not(.range-middle)>*]:after:bg-background [&[data-disabled]>*]:after:bg-foreground/30 *:after:transition-colors",week_number:"size-(--cell-size) p-0 text-xs font-medium text-muted-foreground/72",weekday:"size-(--cell-size) p-0 text-xs font-medium text-muted-foreground/72"},h=Object.keys(u).reduce((t,n)=>{const s=d?.[n],f=u[n];return t[n]=s?a.cn(f,s):f,t},{...u}),z={...{Dropdown:N,Chevron:({className:t,orientation:n,...s})=>n==="left"?r.jsx(g.ChevronLeftIcon,{className:a.cn(t,"rtl:rotate-180"),...s,"aria-hidden":"true"}):n==="right"?r.jsx(g.ChevronRightIcon,{className:a.cn(t,"rtl:rotate-180"),...s,"aria-hidden":"true"}):r.jsx(g.ChevronsUpDownIcon,{className:t,...s,"aria-hidden":"true"})},...i},y={className:a.cn("w-fit [--cell-size:--spacing(10)] sm:[--cell-size:--spacing(9)]",l),classNames:h,components:z,"data-slot":"calendar",formatters:{formatMonthDropdown:t=>t.toLocaleString("es",{month:"short"})},locale:_.es,weekStartsOn:1,captionLayout:e,startMonth:b,endMonth:x,mode:c,showOutsideDays:o,...v};return r.jsx(w.DayPicker,{...y})}exports.Calendar=k;
2
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),w=require("date-fns/locale"),d=require("lucide-react"),C=require("react-day-picker"),f=require("../select/select.cjs.js"),o=require("../../lib/cn.cjs.js"),b=new Date().getFullYear(),N=new Date(b-100,0),j=new Date(b+100,11);function D({options:l=[],value:c,onChange:r}){const i=l.map(e=>({label:e.label??"",value:e.value??0})),u=i.find(e=>e.value===Number(c))??null;return s.jsx(f.Select,{items:i,value:u,icon:s.jsx(d.ChevronDownIcon,{className:f.selectTriggerIconClassName}),"aria-invalid":!1,className:"py-1 h-7 border-none font-medium! w-fit! [&>span]:capitalize",getLabel:e=>e.label,getId:e=>String(e.value),onValueChange:e=>{!r||e===null||r({target:{value:String(e.value)}})}})}const m="relative flex size-(--cell-size) text-base sm:text-sm items-center justify-center rounded-lg text-foreground not-in-data-selected:hover:bg-accent disabled:pointer-events-none disabled:opacity-64 [&_svg:not([class*='opacity-'])]:opacity-80 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0";function k({className:l,classNames:c,showOutsideDays:r=!0,components:i,mode:u="single",captionLayout:e="dropdown",startMonth:x=N,endMonth:v=j,...h}){const g={button_next:m,button_previous:m,caption_label:"text-base sm:text-sm font-medium flex items-center gap-2 h-full",day:"size-(--cell-size) text-sm py-px",day_button:o.cn(m,"in-data-disabled:pointer-events-none in-[.range-middle]:rounded-none in-[.range-end:not(.range-start)]:rounded-s-none in-[.range-start:not(.range-end)]:rounded-e-none in-[.range-middle]:in-data-selected:bg-accent in-data-selected:bg-primary in-[.range-middle]:in-data-selected:text-foreground in-data-disabled:text-muted-foreground/72 in-data-outside:text-muted-foreground/72 in-data-selected:in-data-outside:text-primary-foreground in-data-selected:text-primary-foreground in-data-disabled:line-through outline-none in-[[data-selected]:not(.range-middle)]:transition-[color,background-color,border-radius,box-shadow] focus-visible:z-1 focus-visible:ring-[3px] focus-visible:ring-ring/50"),dropdown:"absolute bg-popover inset-0 opacity-0",dropdown_root:"relative has-focus:border-ring has-focus:ring-ring/50 has-focus:ring-[3px] border border-input shadow-xs/5 rounded-lg px-[calc(--spacing(3)-1px)] h-9 sm:h-8 [&_svg:not([class*='opacity-'])]:opacity-80 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:-me-1",dropdowns:"w-full flex items-center text-base sm:text-sm justify-center h-(--cell-size) gap-1.5 *:[span]:font-medium",hidden:"invisible",month:"w-full",month_caption:"relative mx-(--cell-size) px-1 mb-1 flex h-(--cell-size) items-center justify-center z-2",months:"relative flex flex-col sm:flex-row gap-2",nav:"absolute top-0 flex w-full justify-between z-1",outside:"text-muted-foreground data-selected:bg-accent/50 data-selected:text-muted-foreground",range_end:"range-end",range_middle:"range-middle",range_start:"range-start",today:"*:after:pointer-events-none *:after:absolute *:after:bottom-1 *:after:start-1/2 *:after:z-1 *:after:size-[3px] *:after:-translate-x-1/2 *:after:rounded-full *:after:bg-primary [&[data-selected]:not(.range-middle)>*]:after:bg-background [&[data-disabled]>*]:after:bg-foreground/30 *:after:transition-colors",week_number:"size-(--cell-size) p-0 text-xs font-medium text-muted-foreground/72",weekday:"size-(--cell-size) p-0 text-xs font-medium text-muted-foreground/72"},z=Object.keys(g).reduce((t,n)=>{const a=c?.[n],p=g[n];return t[n]=a?o.cn(p,a):p,t},{...g}),y={...{Dropdown:D,Chevron:({className:t,orientation:n,...a})=>n==="left"?s.jsx(d.ChevronLeftIcon,{className:o.cn(t,"rtl:rotate-180"),...a,"aria-hidden":"true"}):n==="right"?s.jsx(d.ChevronRightIcon,{className:o.cn(t,"rtl:rotate-180"),...a,"aria-hidden":"true"}):s.jsx(d.ChevronDownIcon,{className:t,...a,"aria-hidden":"true"})},...i},_={className:o.cn("w-fit [--cell-size:--spacing(10)] sm:[--cell-size:--spacing(9)]","rounded-xl border bg-background","in-data-[slot=popover-popup]:rounded-none in-data-[slot=popover-popup]:border-0 in-data-[slot=popover-popup]:bg-transparent in-data-[slot=popover-popup]:p-0",l),classNames:z,components:y,"data-slot":"calendar",formatters:{formatMonthDropdown:t=>t.toLocaleString("es",{month:"short"})},locale:w.es,weekStartsOn:1,captionLayout:e,startMonth:x,endMonth:v,mode:u,showOutsideDays:r,...h};return s.jsx(C.DayPicker,{..._})}exports.Calendar=k;
@@ -1,31 +1,32 @@
1
1
  "use client";
2
- import { jsx as r } from "react/jsx-runtime";
3
- import { es as _ } from "date-fns/locale";
4
- import { ChevronLeftIcon as w, ChevronRightIcon as y, ChevronsUpDownIcon as C } from "lucide-react";
2
+ import { jsx as o } from "react/jsx-runtime";
3
+ import { es as w } from "date-fns/locale";
4
+ import { ChevronLeftIcon as y, ChevronRightIcon as C, ChevronDownIcon as g } from "lucide-react";
5
5
  import { DayPicker as N } from "react-day-picker";
6
- import { Select as D } from "../select/select.es.js";
7
- import { cn as s } from "../../lib/cn.es.js";
8
- const f = (/* @__PURE__ */ new Date()).getFullYear(), k = new Date(f - 100, 0), j = new Date(f + 100, 11);
6
+ import { Select as D, selectTriggerIconClassName as k } from "../select/select.es.js";
7
+ import { cn as r } from "../../lib/cn.es.js";
8
+ const f = (/* @__PURE__ */ new Date()).getFullYear(), T = new Date(f - 100, 0), j = new Date(f + 100, 11);
9
9
  function S({
10
10
  options: d = [],
11
11
  value: l,
12
- onChange: o
12
+ onChange: s
13
13
  }) {
14
14
  const i = d.map((e) => ({
15
15
  label: e.label ?? "",
16
16
  value: e.value ?? 0
17
17
  })), c = i.find((e) => e.value === Number(l)) ?? null;
18
- return /* @__PURE__ */ r(
18
+ return /* @__PURE__ */ o(
19
19
  D,
20
20
  {
21
21
  items: i,
22
22
  value: c,
23
+ icon: /* @__PURE__ */ o(g, { className: k }),
23
24
  "aria-invalid": !1,
24
- className: "py-1 h-7",
25
+ className: "py-1 h-7 border-none font-medium! w-fit! [&>span]:capitalize",
25
26
  getLabel: (e) => e.label,
26
27
  getId: (e) => String(e.value),
27
28
  onValueChange: (e) => {
28
- !o || e === null || o({
29
+ !s || e === null || s({
29
30
  target: { value: String(e.value) }
30
31
  });
31
32
  }
@@ -33,23 +34,23 @@ function S({
33
34
  );
34
35
  }
35
36
  const m = "relative flex size-(--cell-size) text-base sm:text-sm items-center justify-center rounded-lg text-foreground not-in-data-selected:hover:bg-accent disabled:pointer-events-none disabled:opacity-64 [&_svg:not([class*='opacity-'])]:opacity-80 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0";
36
- function M({
37
+ function P({
37
38
  className: d,
38
39
  classNames: l,
39
- showOutsideDays: o = !0,
40
+ showOutsideDays: s = !0,
40
41
  components: i,
41
42
  mode: c = "single",
42
43
  captionLayout: e = "dropdown",
43
- startMonth: p = k,
44
- endMonth: b = j,
45
- ...x
44
+ startMonth: b = T,
45
+ endMonth: x = j,
46
+ ...v
46
47
  }) {
47
48
  const u = {
48
49
  button_next: m,
49
50
  button_previous: m,
50
51
  caption_label: "text-base sm:text-sm font-medium flex items-center gap-2 h-full",
51
52
  day: "size-(--cell-size) text-sm py-px",
52
- day_button: s(
53
+ day_button: r(
53
54
  m,
54
55
  "in-data-disabled:pointer-events-none in-[.range-middle]:rounded-none in-[.range-end:not(.range-start)]:rounded-s-none in-[.range-start:not(.range-end)]:rounded-e-none in-[.range-middle]:in-data-selected:bg-accent in-data-selected:bg-primary in-[.range-middle]:in-data-selected:text-foreground in-data-disabled:text-muted-foreground/72 in-data-outside:text-muted-foreground/72 in-data-selected:in-data-outside:text-primary-foreground in-data-selected:text-primary-foreground in-data-disabled:line-through outline-none in-[[data-selected]:not(.range-middle)]:transition-[color,background-color,border-radius,box-shadow] focus-visible:z-1 focus-visible:ring-[3px] focus-visible:ring-ring/50"
55
56
  ),
@@ -68,72 +69,70 @@ function M({
68
69
  today: "*:after:pointer-events-none *:after:absolute *:after:bottom-1 *:after:start-1/2 *:after:z-1 *:after:size-[3px] *:after:-translate-x-1/2 *:after:rounded-full *:after:bg-primary [&[data-selected]:not(.range-middle)>*]:after:bg-background [&[data-disabled]>*]:after:bg-foreground/30 *:after:transition-colors",
69
70
  week_number: "size-(--cell-size) p-0 text-xs font-medium text-muted-foreground/72",
70
71
  weekday: "size-(--cell-size) p-0 text-xs font-medium text-muted-foreground/72"
71
- }, v = Object.keys(
72
+ }, h = Object.keys(
72
73
  u
73
74
  ).reduce(
74
75
  (t, n) => {
75
- const a = l?.[n], g = u[n];
76
- return t[n] = a ? s(g, a) : g, t;
76
+ const a = l?.[n], p = u[n];
77
+ return t[n] = a ? r(p, a) : p, t;
77
78
  },
78
79
  { ...u }
79
- ), h = {
80
+ ), z = {
80
81
  ...{
81
82
  Dropdown: S,
82
83
  Chevron: ({
83
84
  className: t,
84
85
  orientation: n,
85
86
  ...a
86
- }) => n === "left" ? /* @__PURE__ */ r(
87
- w,
88
- {
89
- className: s(t, "rtl:rotate-180"),
90
- ...a,
91
- "aria-hidden": "true"
92
- }
93
- ) : n === "right" ? /* @__PURE__ */ r(
87
+ }) => n === "left" ? /* @__PURE__ */ o(
94
88
  y,
95
89
  {
96
- className: s(t, "rtl:rotate-180"),
90
+ className: r(t, "rtl:rotate-180"),
97
91
  ...a,
98
92
  "aria-hidden": "true"
99
93
  }
100
- ) : /* @__PURE__ */ r(
94
+ ) : n === "right" ? /* @__PURE__ */ o(
101
95
  C,
102
96
  {
103
- className: t,
97
+ className: r(t, "rtl:rotate-180"),
104
98
  ...a,
105
99
  "aria-hidden": "true"
106
100
  }
107
- )
101
+ ) : /* @__PURE__ */ o(g, { className: t, ...a, "aria-hidden": "true" })
108
102
  },
109
103
  ...i
110
- }, z = {
111
- className: s(
104
+ }, _ = {
105
+ className: r(
112
106
  "w-fit [--cell-size:--spacing(10)] sm:[--cell-size:--spacing(9)]",
107
+ // Standalone container surface. Inside a popover (DatePicker) the
108
+ // popup already paints border + background + padding, so strip ours
109
+ // to avoid a double border.
110
+ "rounded-xl border bg-background",
111
+ "in-data-[slot=popover-popup]:rounded-none in-data-[slot=popover-popup]:border-0 in-data-[slot=popover-popup]:bg-transparent in-data-[slot=popover-popup]:p-0",
113
112
  d
114
113
  ),
115
- classNames: v,
116
- components: h,
114
+ classNames: h,
115
+ components: z,
117
116
  "data-slot": "calendar",
118
117
  formatters: {
119
118
  formatMonthDropdown: (t) => t.toLocaleString("es", { month: "short" })
120
119
  },
121
- locale: _,
120
+ locale: w,
122
121
  weekStartsOn: 1,
123
122
  captionLayout: e,
124
- startMonth: p,
125
- endMonth: b,
123
+ startMonth: b,
124
+ endMonth: x,
126
125
  mode: c,
127
- showOutsideDays: o,
128
- ...x
126
+ showOutsideDays: s,
127
+ ...v
129
128
  };
130
- return /* @__PURE__ */ r(
129
+ return /* @__PURE__ */ o(
131
130
  N,
132
131
  {
133
- ...z
132
+ ..._
134
133
  }
135
134
  );
136
135
  }
137
136
  export {
138
- M as Calendar
137
+ P as Calendar
139
138
  };
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),B=require("@radix-ui/react-use-controllable-state"),s=require("date-fns"),M=require("lucide-react"),O=require("./use-date-input.cjs.js"),k=require("./use-date-input-popover.cjs.js"),H=require("./use-hidden-field-value.cjs.js"),i=require("../popover/popover.cjs.js"),f=require("../field/field.cjs.js"),E=require("../calendar/calendar.cjs.js"),U=require("../../lib/cn.cjs.js"),z=require("../input/input.cjs.js"),A=g=>{const{placeholder:u,value:m,onValueChange:v,defaultValue:y,autoComplete:b,className:x,disabledDate:n,renderFooter:D,disabled:o,onBlur:C,required:j,...q}=g,[a,d]=B.useControllableState({prop:m,onChange:e=>v?.(e??null),defaultProp:y??null}),I=a?s.format(a,"yyyy-MM-dd"):"",P=H.useHiddenFieldValue(I),{inputValue:w,handleChange:N,handleBlur:S,handleKeyDown:F,clear:K,setFromExternalDate:r}=O.useDateInput({date:a??null,onDateChange:e=>d(e),disabledDate:n}),{open:R,setOpen:c,handleInputKeyDown:T,inputRef:l}=k.useDateInputPopover({disabled:o}),V=e=>{F(e),T(e)},p=D?.({value:a??null,clear:()=>{r(null),K()},selectToday:()=>{const e=new Date;n?.(e)||r(e)},setValue:e=>{const h=e&&s.isDate(e)?e:null;d(h),r(h)}});return t.jsxs(i.PopoverRoot,{"data-slot":"date-input",open:R,onOpenChange:c,children:[t.jsxs("div",{className:U.cn(z.inputBaseClasses,"relative flex items-center gap-2 h-8","has-[:focus-visible]:border-ring","aria-invalid:border-error has-[:focus-visible]:aria-invalid:ring-error/20","has-aria-invalid:border-error has-[:focus-visible]:has-aria-invalid:border-error has-[:focus-visible]:has-aria-invalid:ring-error/20","has-[:disabled]:cursor-not-allowed has-[:disabled]:opacity-50",!a&&"text-muted-foreground",x,"field-error"),"data-slot":"date-input-trigger",onClick:e=>{e.target===e.currentTarget&&l.current?.focus()},children:[t.jsx(f.FieldControl,{render:t.jsx("input",{ref:P,type:"text",className:"sr-only",tabIndex:-1,"aria-hidden":"true",required:j,disabled:o,onFocus:()=>l.current?.focus()})}),t.jsx("input",{type:"text",value:w,onChange:N,onBlur:e=>{S(),C?.(e)},onKeyDown:V,placeholder:u??"dd/mm/aaaa",autoComplete:b??"off",disabled:o,className:"flex-1 min-w-0 bg-transparent outline-none text-start truncate pt-px","aria-label":u,ref:l,...q}),t.jsxs(i.PopoverTrigger,{type:"button",disabled:o,"data-slot":"date-input-calendar-trigger",className:"flex shrink-0 items-center justify-center text-muted-foreground hover:text-foreground",children:[t.jsx(M.CalendarIcon,{"data-slot":"date-input-icon"}),t.jsx("span",{className:"sr-only",children:"Seleccionar fecha"})]})]}),t.jsx(i.PopoverPopup,{className:"w-auto p-0",align:"start","data-slot":"date-input-content",children:t.jsxs(f.FieldRoot,{className:"contents",children:[t.jsx(E.Calendar,{className:"border-none",mode:"single",selected:a??void 0,onSelect:e=>{if(!e||!s.isDate(e)){r(null);return}n?.(e)||(r(e),c(!1))},disabled:n}),p&&t.jsx("div",{className:"p-2","data-slot":"date-input-footer",children:p})]})})]})};exports.DateInput=A;
2
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),k=require("@radix-ui/react-use-controllable-state"),i=require("date-fns"),H=require("lucide-react"),E=require("react"),U=require("./date-picker.utils.cjs.js"),_=require("./use-date-input.cjs.js"),z=require("./use-date-input-popover.cjs.js"),A=require("./use-hidden-field-value.cjs.js"),d=require("../popover/popover.cjs.js"),v=require("../field/field.cjs.js"),G=require("../calendar/calendar.cjs.js"),J=require("../../lib/cn.cjs.js"),L=require("../input/input.cjs.js"),Q=m=>{const{placeholder:u,value:y,onValueChange:b,defaultValue:C,autoComplete:D,className:x,disabledDate:r,renderFooter:j,disabled:o,onBlur:q,required:I,...P}=m,[a,c]=k.useControllableState({prop:y,onChange:e=>b?.(e??null),defaultProp:C??null}),w=a?i.format(a,"yyyy-MM-dd"):"",N=A.useHiddenFieldValue(w),{inputValue:p,handleChange:S,handleBlur:F,handleKeyDown:R,clear:T,setFromExternalDate:n}=_.useDateInput({date:a??null,onDateChange:e=>c(e),disabledDate:r}),{open:K,setOpen:h,handleInputKeyDown:M,inputRef:l}=z.useDateInputPopover({disabled:o}),[V,f]=E.useState(void 0),B=e=>{if(e){const s=U.parseInputToDate(p);f(s??a??void 0)}h(e)},O=e=>{R(e),M(e)},g=j?.({value:a??null,clear:()=>{n(null),T()},selectToday:()=>{const e=new Date;r?.(e)||n(e)},setValue:e=>{const s=e&&i.isDate(e)?e:null;c(s),n(s)}});return t.jsxs(d.PopoverRoot,{"data-slot":"date-input",open:K,onOpenChange:B,children:[t.jsxs("div",{className:J.cn(L.inputBaseClasses,"relative flex items-center gap-2 h-8","has-[:focus-visible]:border-ring","aria-invalid:border-error has-[:focus-visible]:aria-invalid:ring-error/20","has-aria-invalid:border-error has-[:focus-visible]:has-aria-invalid:border-error has-[:focus-visible]:has-aria-invalid:ring-error/20","has-[:disabled]:cursor-not-allowed has-[:disabled]:opacity-50",!a&&"text-muted-foreground",x,"field-error"),"data-slot":"date-input-trigger",onClick:e=>{e.target===e.currentTarget&&l.current?.focus()},children:[t.jsx(v.FieldControl,{render:t.jsx("input",{ref:N,type:"text",className:"sr-only",tabIndex:-1,"aria-hidden":"true",required:I,disabled:o,onFocus:()=>l.current?.focus()})}),t.jsx("input",{type:"text",value:p,onChange:S,onBlur:e=>{F(),q?.(e)},onKeyDown:O,placeholder:u??"dd/mm/aaaa",autoComplete:D??"off",disabled:o,className:"flex-1 min-w-0 bg-transparent outline-none text-start truncate pt-px","aria-label":u,ref:l,...P}),t.jsxs(d.PopoverTrigger,{type:"button",disabled:o,"data-slot":"date-input-calendar-trigger",className:"flex shrink-0 items-center justify-center text-muted-foreground hover:text-foreground",children:[t.jsx(H.CalendarIcon,{"data-slot":"date-input-icon"}),t.jsx("span",{className:"sr-only",children:"Seleccionar fecha"})]})]}),t.jsx(d.PopoverPopup,{className:"w-auto p-0",align:"start","data-slot":"date-input-content",children:t.jsxs(v.FieldRoot,{className:"contents",children:[t.jsx(G.Calendar,{className:"border-none",mode:"single",month:V,onMonthChange:f,selected:a??void 0,onSelect:e=>{if(!e||!i.isDate(e)){n(null);return}r?.(e)||(n(e),h(!1))},disabled:r}),g&&t.jsx("div",{className:"p-2","data-slot":"date-input-footer",children:g})]})})]})};exports.DateInput=Q;
@@ -1,168 +1,188 @@
1
1
  "use client";
2
- import { jsxs as l, jsx as t } from "react/jsx-runtime";
3
- import { useControllableState as j } from "@radix-ui/react-use-controllable-state";
4
- import { format as k, isDate as m } from "date-fns";
5
- import { CalendarIcon as M } from "lucide-react";
6
- import { useDateInput as O } from "./use-date-input.es.js";
7
- import { useDateInputPopover as q } from "./use-date-input-popover.es.js";
8
- import { useHiddenFieldValue as E } from "./use-hidden-field-value.es.js";
9
- import { PopoverRoot as H, PopoverTrigger as z, PopoverPopup as A } from "../popover/popover.es.js";
10
- import { FieldControl as G, FieldRoot as J } from "../field/field.es.js";
11
- import { Calendar as L } from "../calendar/calendar.es.js";
12
- import { cn as Q } from "../../lib/cn.es.js";
13
- import { inputBaseClasses as U } from "../input/input.es.js";
14
- const ie = (f) => {
2
+ import { jsxs as s, jsx as t } from "react/jsx-runtime";
3
+ import { useControllableState as k } from "@radix-ui/react-use-controllable-state";
4
+ import { format as q, isDate as h } from "date-fns";
5
+ import { CalendarIcon as E } from "lucide-react";
6
+ import { useState as H } from "react";
7
+ import { parseInputToDate as z } from "./date-picker.utils.es.js";
8
+ import { useDateInput as A } from "./use-date-input.es.js";
9
+ import { useDateInputPopover as G } from "./use-date-input-popover.es.js";
10
+ import { useHiddenFieldValue as J } from "./use-hidden-field-value.es.js";
11
+ import { PopoverRoot as L, PopoverTrigger as Q, PopoverPopup as U } from "../popover/popover.es.js";
12
+ import { FieldControl as W, FieldRoot as X } from "../field/field.es.js";
13
+ import { Calendar as Y } from "../calendar/calendar.es.js";
14
+ import { cn as Z } from "../../lib/cn.es.js";
15
+ import { inputBaseClasses as _ } from "../input/input.es.js";
16
+ const he = (g) => {
15
17
  const {
16
- placeholder: i,
17
- value: h,
18
- onValueChange: g,
19
- defaultValue: v,
20
- autoComplete: y,
21
- className: b,
22
- disabledDate: o,
23
- renderFooter: C,
18
+ placeholder: d,
19
+ value: v,
20
+ onValueChange: y,
21
+ defaultValue: C,
22
+ autoComplete: b,
23
+ className: D,
24
+ disabledDate: r,
25
+ renderFooter: w,
24
26
  disabled: n,
25
- onBlur: D,
26
- required: x,
27
- ...w
28
- } = f, [r, d] = j({
29
- prop: h,
30
- onChange: (e) => g?.(e ?? null),
31
- defaultProp: v ?? null
32
- }), N = r ? k(r, "yyyy-MM-dd") : "", P = E(N), {
33
- inputValue: I,
27
+ onBlur: x,
28
+ required: I,
29
+ ...N
30
+ } = g, [o, u] = k({
31
+ prop: v,
32
+ onChange: (e) => y?.(e ?? null),
33
+ defaultProp: C ?? null
34
+ }), P = o ? q(o, "yyyy-MM-dd") : "", S = J(P), {
35
+ inputValue: c,
34
36
  handleChange: F,
35
37
  handleBlur: K,
36
- handleKeyDown: S,
38
+ handleKeyDown: T,
37
39
  clear: B,
38
40
  setFromExternalDate: a
39
- } = O({
40
- date: r ?? null,
41
- onDateChange: (e) => d(e),
42
- disabledDate: o
41
+ } = A({
42
+ date: o ?? null,
43
+ onDateChange: (e) => u(e),
44
+ disabledDate: r
43
45
  }), {
44
- open: T,
45
- setOpen: u,
46
+ open: M,
47
+ setOpen: p,
46
48
  handleInputKeyDown: V,
47
- inputRef: s
48
- } = q({ disabled: n }), R = (e) => {
49
- S(e), V(e);
50
- }, c = C?.({
51
- value: r ?? null,
49
+ inputRef: i
50
+ } = G({ disabled: n }), [R, m] = H(
51
+ void 0
52
+ ), j = (e) => {
53
+ if (e) {
54
+ const l = z(c);
55
+ m(l ?? o ?? void 0);
56
+ }
57
+ p(e);
58
+ }, O = (e) => {
59
+ T(e), V(e);
60
+ }, f = w?.({
61
+ value: o ?? null,
52
62
  clear: () => {
53
63
  a(null), B();
54
64
  },
55
65
  selectToday: () => {
56
66
  const e = /* @__PURE__ */ new Date();
57
- o?.(e) || a(e);
67
+ r?.(e) || a(e);
58
68
  },
59
69
  setValue: (e) => {
60
- const p = e && m(e) ? e : null;
61
- d(p), a(p);
70
+ const l = e && h(e) ? e : null;
71
+ u(l), a(l);
62
72
  }
63
73
  });
64
- return /* @__PURE__ */ l(H, { "data-slot": "date-input", open: T, onOpenChange: u, children: [
65
- /* @__PURE__ */ l(
66
- "div",
67
- {
68
- className: Q(
69
- U,
70
- "relative flex items-center gap-2 h-8",
71
- "has-[:focus-visible]:border-ring",
72
- "aria-invalid:border-error has-[:focus-visible]:aria-invalid:ring-error/20",
73
- "has-aria-invalid:border-error has-[:focus-visible]:has-aria-invalid:border-error has-[:focus-visible]:has-aria-invalid:ring-error/20",
74
- "has-[:disabled]:cursor-not-allowed has-[:disabled]:opacity-50",
75
- !r && "text-muted-foreground",
76
- b,
77
- "field-error"
78
- ),
79
- "data-slot": "date-input-trigger",
80
- onClick: (e) => {
81
- e.target === e.currentTarget && s.current?.focus();
82
- },
83
- children: [
84
- /* @__PURE__ */ t(
85
- G,
86
- {
87
- render: /* @__PURE__ */ t(
74
+ return /* @__PURE__ */ s(
75
+ L,
76
+ {
77
+ "data-slot": "date-input",
78
+ open: M,
79
+ onOpenChange: j,
80
+ children: [
81
+ /* @__PURE__ */ s(
82
+ "div",
83
+ {
84
+ className: Z(
85
+ _,
86
+ "relative flex items-center gap-2 h-8",
87
+ "has-[:focus-visible]:border-ring",
88
+ "aria-invalid:border-error has-[:focus-visible]:aria-invalid:ring-error/20",
89
+ "has-aria-invalid:border-error has-[:focus-visible]:has-aria-invalid:border-error has-[:focus-visible]:has-aria-invalid:ring-error/20",
90
+ "has-[:disabled]:cursor-not-allowed has-[:disabled]:opacity-50",
91
+ !o && "text-muted-foreground",
92
+ D,
93
+ "field-error"
94
+ ),
95
+ "data-slot": "date-input-trigger",
96
+ onClick: (e) => {
97
+ e.target === e.currentTarget && i.current?.focus();
98
+ },
99
+ children: [
100
+ /* @__PURE__ */ t(
101
+ W,
102
+ {
103
+ render: /* @__PURE__ */ t(
104
+ "input",
105
+ {
106
+ ref: S,
107
+ type: "text",
108
+ className: "sr-only",
109
+ tabIndex: -1,
110
+ "aria-hidden": "true",
111
+ required: I,
112
+ disabled: n,
113
+ onFocus: () => i.current?.focus()
114
+ }
115
+ )
116
+ }
117
+ ),
118
+ /* @__PURE__ */ t(
88
119
  "input",
89
120
  {
90
- ref: P,
91
121
  type: "text",
92
- className: "sr-only",
93
- tabIndex: -1,
94
- "aria-hidden": "true",
95
- required: x,
122
+ value: c,
123
+ onChange: F,
124
+ onBlur: (e) => {
125
+ K(), x?.(e);
126
+ },
127
+ onKeyDown: O,
128
+ placeholder: d ?? "dd/mm/aaaa",
129
+ autoComplete: b ?? "off",
130
+ disabled: n,
131
+ className: "flex-1 min-w-0 bg-transparent outline-none text-start truncate pt-px",
132
+ "aria-label": d,
133
+ ref: i,
134
+ ...N
135
+ }
136
+ ),
137
+ /* @__PURE__ */ s(
138
+ Q,
139
+ {
140
+ type: "button",
96
141
  disabled: n,
97
- onFocus: () => s.current?.focus()
142
+ "data-slot": "date-input-calendar-trigger",
143
+ className: "flex shrink-0 items-center justify-center text-muted-foreground hover:text-foreground",
144
+ children: [
145
+ /* @__PURE__ */ t(E, { "data-slot": "date-input-icon" }),
146
+ /* @__PURE__ */ t("span", { className: "sr-only", children: "Seleccionar fecha" })
147
+ ]
98
148
  }
99
149
  )
100
- }
101
- ),
102
- /* @__PURE__ */ t(
103
- "input",
104
- {
105
- type: "text",
106
- value: I,
107
- onChange: F,
108
- onBlur: (e) => {
109
- K(), D?.(e);
110
- },
111
- onKeyDown: R,
112
- placeholder: i ?? "dd/mm/aaaa",
113
- autoComplete: y ?? "off",
114
- disabled: n,
115
- className: "flex-1 min-w-0 bg-transparent outline-none text-start truncate pt-px",
116
- "aria-label": i,
117
- ref: s,
118
- ...w
119
- }
120
- ),
121
- /* @__PURE__ */ l(
122
- z,
123
- {
124
- type: "button",
125
- disabled: n,
126
- "data-slot": "date-input-calendar-trigger",
127
- className: "flex shrink-0 items-center justify-center text-muted-foreground hover:text-foreground",
128
- children: [
129
- /* @__PURE__ */ t(M, { "data-slot": "date-input-icon" }),
130
- /* @__PURE__ */ t("span", { className: "sr-only", children: "Seleccionar fecha" })
131
- ]
132
- }
133
- )
134
- ]
135
- }
136
- ),
137
- /* @__PURE__ */ t(
138
- A,
139
- {
140
- className: "w-auto p-0",
141
- align: "start",
142
- "data-slot": "date-input-content",
143
- children: /* @__PURE__ */ l(J, { className: "contents", children: [
144
- /* @__PURE__ */ t(
145
- L,
146
- {
147
- className: "border-none",
148
- mode: "single",
149
- selected: r ?? void 0,
150
- onSelect: (e) => {
151
- if (!e || !m(e)) {
152
- a(null);
153
- return;
150
+ ]
151
+ }
152
+ ),
153
+ /* @__PURE__ */ t(
154
+ U,
155
+ {
156
+ className: "w-auto p-0",
157
+ align: "start",
158
+ "data-slot": "date-input-content",
159
+ children: /* @__PURE__ */ s(X, { className: "contents", children: [
160
+ /* @__PURE__ */ t(
161
+ Y,
162
+ {
163
+ className: "border-none",
164
+ mode: "single",
165
+ month: R,
166
+ onMonthChange: m,
167
+ selected: o ?? void 0,
168
+ onSelect: (e) => {
169
+ if (!e || !h(e)) {
170
+ a(null);
171
+ return;
172
+ }
173
+ r?.(e) || (a(e), p(!1));
174
+ },
175
+ disabled: r
154
176
  }
155
- o?.(e) || (a(e), u(!1));
156
- },
157
- disabled: o
158
- }
159
- ),
160
- c && /* @__PURE__ */ t("div", { className: "p-2", "data-slot": "date-input-footer", children: c })
161
- ] })
162
- }
163
- )
164
- ] });
177
+ ),
178
+ f && /* @__PURE__ */ t("div", { className: "p-2", "data-slot": "date-input-footer", children: f })
179
+ ] })
180
+ }
181
+ )
182
+ ]
183
+ }
184
+ );
165
185
  };
166
186
  export {
167
- ie as DateInput
187
+ he as DateInput
168
188
  };
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),M=require("@radix-ui/react-use-controllable-state"),f=require("lucide-react"),h=require("react"),S=require("./pagination.model.cjs.js"),L=require("../../hooks/use-range-pagination/use-range-pagination.cjs.js"),l=require("../../lib/cn.cjs.js"),I=require("../button/button.cjs.js"),A={goToFirst:"Ir a primera página",goToPrevious:"Ir a página anterior",goToNext:"Ir a próxima página",goToLast:"Ir a última página",goToPage:a=>`Ir a la página ${a}`,total:a=>`${a} resultados`,pageInfo:(a,n)=>`Página ${a} de ${n}`,range:(a,n,t)=>`${a} - ${n} de ${t}`,morePages:"Más páginas"},C=h.createContext(null);function c(){const a=h.useContext(C);if(!a)throw new Error("Pagination primitives must be used inside <PaginationRoot>");return a}function z({totalItems:a,pageSize:n,defaultPageSize:t=S.PAGINATION_SIZES[0],onPageSizeChange:i,currentPage:o,defaultCurrentPage:s=1,onCurrentPageChange:r,siblingCount:g=1,getPageHref:u,linkComponent:j="a",texts:v,className:N,children:b,...x}){const[p=t,P]=M.useControllableState({prop:n,defaultProp:t,onChange:i}),d=L.useRangePagination({totalItems:a,pageSize:p,currentPage:o,defaultCurrentPage:s,onCurrentPageChange:r,siblingCount:g}),T=h.useMemo(()=>({...A,...v}),[v]),F=h.useMemo(()=>({...d,pageSize:p,totalItems:a,setPageSize:P,getPageHref:u,linkComponent:j,texts:T}),[d,p,a,P,u,j,T]);return e.jsx(C.Provider,{value:F,children:e.jsx("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:l.cn("flex items-center gap-x-4",N),...x,children:b})})}function m({page:a,isActive:n,disabled:t,ariaLabel:i,dataSlot:o,children:s,className:r,buttonProps:g}){const{goTo:u,getPageHref:j,pageSize:v,linkComponent:N}=c(),b=N,x=j?.({page:a,pageSize:Number(v)}),p=!!x&&!t,P=()=>{t||u(a)},d={"data-slot":o,"data-active":n?"true":"false","aria-current":n?"page":void 0,"aria-label":i,className:l.cn("hover:bg-accent hover:text-accent-foreground",r)};return p&&x?e.jsx(I.Button,{variant:n?"outline":"ghost",size:"icon",nativeButton:!1,render:e.jsx(b,{href:x,onClick:P,children:s}),...d,...g}):e.jsx(I.Button,{variant:n?"outline":"ghost",size:"icon",disabled:t,onClick:P,...d,...g,children:s})}function R({page:a,isActive:n,className:t,children:i,buttonProps:o}){const{currentPage:s,texts:r}=c(),g=n??a===s;return e.jsx(m,{page:a,isActive:g,ariaLabel:r.goToPage(a),dataSlot:"pagination-link",className:t,buttonProps:o,children:i??a})}function _({className:a,buttonProps:n,children:t}){const{isFirstPage:i,texts:o}=c();return e.jsx(m,{page:1,disabled:i,ariaLabel:o.goToFirst,dataSlot:"pagination-first",className:a,buttonProps:n,children:t??e.jsx(f.ChevronsLeft,{"data-slot":"pagination-icon"})})}function k({className:a,buttonProps:n,children:t}){const{currentPage:i,isFirstPage:o,texts:s}=c();return e.jsx(m,{page:Math.max(1,i-1),disabled:o,ariaLabel:s.goToPrevious,dataSlot:"pagination-previous",className:a,buttonProps:n,children:t??e.jsx(f.ChevronLeft,{"data-slot":"pagination-icon"})})}function q({className:a,buttonProps:n,children:t}){const{currentPage:i,maxPage:o,isLastPage:s,texts:r}=c();return e.jsx(m,{page:Math.min(o,i+1),disabled:s,ariaLabel:r.goToNext,dataSlot:"pagination-next",className:a,buttonProps:n,children:t??e.jsx(f.ChevronRight,{"data-slot":"pagination-icon"})})}function B({className:a,buttonProps:n,children:t}){const{maxPage:i,isLastPage:o,texts:s}=c();return e.jsx(m,{page:i,disabled:o,ariaLabel:s.goToLast,dataSlot:"pagination-last",className:a,buttonProps:n,children:t??e.jsx(f.ChevronsRight,{"data-slot":"pagination-icon"})})}function E({className:a,...n}){const{texts:t}=c();return e.jsxs("span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis","data-dots":"true",className:l.cn("flex size-8 items-center justify-center [&_svg:not([class*='size-'])]:size-4",a),...n,children:[e.jsx(f.MoreHorizontal,{}),e.jsx("span",{className:"sr-only",children:t.morePages})]})}function O({className:a,linkClassName:n,ellipsisClassName:t}){const{paginationRange:i}=c();return e.jsx("div",{role:"list","data-slot":"pagination-pages",className:l.cn("flex items-center gap-1",a),children:i.map((o,s)=>o===L.DOTS?e.jsx(E,{className:t},`dots-${s}`):e.jsx(R,{page:o,className:n},o))})}function w({children:a,className:n,...t}){const{totalItems:i,texts:o}=c(),s=typeof a=="function"?a(i):a??o.total(i);return e.jsx("span",{"data-slot":"pagination-total",className:l.cn("text-sm",n),...t,children:s})}function G({children:a,className:n,...t}){const{currentPage:i,maxPage:o,texts:s}=c(),r=typeof a=="function"?a({page:i,max:o}):a??s.pageInfo(i,o);return e.jsx("span",{"data-slot":"pagination-page-info",className:l.cn("text-sm",n),...t,children:r})}function $({children:a,className:n,...t}){const{range:i,totalItems:o,texts:s}=c(),r=typeof a=="function"?a({...i,total:o}):a??s.range(i.start,i.end,o);return e.jsx("span",{"data-slot":"pagination-range",className:l.cn("text-sm",n),...t,children:r})}function y({sizes:a=S.PAGINATION_SIZES,className:n,...t}){const{pageSize:i,setPageSize:o,goTo:s}=c(),r=g=>{const u=Number(g.target.value);o(u),s(1)};return e.jsx("select",{"data-slot":"pagination-size-select",value:i,onChange:r,className:l.cn("border border-input rounded-md w-fit min-w-[3rem] bg-background p-2 ring-offset-background","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",n),...t,children:a.map(g=>e.jsx("option",{value:g,"data-slot":"pagination-size-option",children:g},g))})}function Z({sizes:a=S.PAGINATION_SIZES,selectClassName:n,rangeClassName:t,previousClassName:i,nextClassName:o,className:s,...r}){return e.jsxs(z,{className:s,...r,children:[a&&e.jsx(y,{sizes:a,className:n}),e.jsx($,{className:t}),e.jsx(k,{className:i}),e.jsx(q,{className:o})]})}exports.Pagination=Z;exports.PaginationEllipsis=E;exports.PaginationFirst=_;exports.PaginationLast=B;exports.PaginationLink=R;exports.PaginationNext=q;exports.PaginationPageInfo=G;exports.PaginationPages=O;exports.PaginationPrevious=k;exports.PaginationRange=$;exports.PaginationRoot=z;exports.PaginationSizeSelect=y;exports.PaginationTotal=w;
2
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),M=require("@radix-ui/react-use-controllable-state"),f=require("lucide-react"),h=require("react"),S=require("./pagination.model.cjs.js"),I=require("../../hooks/use-range-pagination/use-range-pagination.cjs.js"),l=require("../../lib/cn.cjs.js"),C=require("../button/button.cjs.js"),A={goToFirst:"Ir a primera página",goToPrevious:"Ir a página anterior",goToNext:"Ir a próxima página",goToLast:"Ir a última página",goToPage:a=>`Ir a la página ${a}`,total:a=>`${a} resultados`,pageInfo:(a,n)=>`Página ${a} de ${n}`,range:(a,n,t)=>`${a} - ${n} de ${t}`,morePages:"Más páginas"},L=h.createContext(null);function c(){const a=h.useContext(L);if(!a)throw new Error("Pagination primitives must be used inside <PaginationRoot>");return a}function z({totalItems:a,pageSize:n,defaultPageSize:t=S.PAGINATION_SIZES[0],onPageSizeChange:i,currentPage:o,defaultCurrentPage:s=1,onCurrentPageChange:r,siblingCount:g=1,getPageHref:p,linkComponent:j="a",texts:v,className:N,children:b,...x}){const[P=t,d]=M.useControllableState({prop:n,defaultProp:t,onChange:i}),u=I.useRangePagination({totalItems:a,pageSize:P,page:o,defaultPage:s,onPageChange:r,siblingCount:g}),T=h.useMemo(()=>({...A,...v}),[v]),F=h.useMemo(()=>({...u,currentPage:u.page,maxPage:u.pageCount,pageSize:P,totalItems:a,setPageSize:d,getPageHref:p,linkComponent:j,texts:T}),[u,P,a,d,p,j,T]);return e.jsx(L.Provider,{value:F,children:e.jsx("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:l.cn("flex items-center gap-x-4",N),...x,children:b})})}function m({page:a,isActive:n,disabled:t,ariaLabel:i,dataSlot:o,children:s,className:r,buttonProps:g}){const{goTo:p,getPageHref:j,pageSize:v,linkComponent:N}=c(),b=N,x=j?.({page:a,pageSize:Number(v)}),P=!!x&&!t,d=()=>{t||p(a)},u={"data-slot":o,"data-active":n?"true":"false","aria-current":n?"page":void 0,"aria-label":i,className:l.cn("hover:bg-accent hover:text-accent-foreground",r)};return P&&x?e.jsx(C.Button,{variant:n?"outline":"ghost",size:"icon",nativeButton:!1,render:e.jsx(b,{href:x,onClick:d,children:s}),...u,...g}):e.jsx(C.Button,{variant:n?"outline":"ghost",size:"icon",disabled:t,onClick:d,...u,...g,children:s})}function R({page:a,isActive:n,className:t,children:i,buttonProps:o}){const{currentPage:s,texts:r}=c(),g=n??a===s;return e.jsx(m,{page:a,isActive:g,ariaLabel:r.goToPage(a),dataSlot:"pagination-link",className:t,buttonProps:o,children:i??a})}function _({className:a,buttonProps:n,children:t}){const{isFirstPage:i,texts:o}=c();return e.jsx(m,{page:1,disabled:i,ariaLabel:o.goToFirst,dataSlot:"pagination-first",className:a,buttonProps:n,children:t??e.jsx(f.ChevronsLeft,{"data-slot":"pagination-icon"})})}function k({className:a,buttonProps:n,children:t}){const{currentPage:i,isFirstPage:o,texts:s}=c();return e.jsx(m,{page:Math.max(1,i-1),disabled:o,ariaLabel:s.goToPrevious,dataSlot:"pagination-previous",className:a,buttonProps:n,children:t??e.jsx(f.ChevronLeft,{"data-slot":"pagination-icon"})})}function q({className:a,buttonProps:n,children:t}){const{currentPage:i,maxPage:o,isLastPage:s,texts:r}=c();return e.jsx(m,{page:Math.min(o,i+1),disabled:s,ariaLabel:r.goToNext,dataSlot:"pagination-next",className:a,buttonProps:n,children:t??e.jsx(f.ChevronRight,{"data-slot":"pagination-icon"})})}function B({className:a,buttonProps:n,children:t}){const{maxPage:i,isLastPage:o,texts:s}=c();return e.jsx(m,{page:i,disabled:o,ariaLabel:s.goToLast,dataSlot:"pagination-last",className:a,buttonProps:n,children:t??e.jsx(f.ChevronsRight,{"data-slot":"pagination-icon"})})}function E({className:a,...n}){const{texts:t}=c();return e.jsxs("span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis","data-dots":"true",className:l.cn("flex size-8 items-center justify-center [&_svg:not([class*='size-'])]:size-4",a),...n,children:[e.jsx(f.MoreHorizontal,{}),e.jsx("span",{className:"sr-only",children:t.morePages})]})}function O({className:a,linkClassName:n,ellipsisClassName:t}){const{paginationRange:i}=c();return e.jsx("div",{role:"list","data-slot":"pagination-pages",className:l.cn("flex items-center gap-1",a),children:i.map((o,s)=>o===I.DOTS?e.jsx(E,{className:t},`dots-${s}`):e.jsx(R,{page:o,className:n},o))})}function w({children:a,className:n,...t}){const{totalItems:i,texts:o}=c(),s=typeof a=="function"?a(i):a??o.total(i);return e.jsx("span",{"data-slot":"pagination-total",className:l.cn("text-sm",n),...t,children:s})}function G({children:a,className:n,...t}){const{currentPage:i,maxPage:o,texts:s}=c(),r=typeof a=="function"?a({page:i,max:o}):a??s.pageInfo(i,o);return e.jsx("span",{"data-slot":"pagination-page-info",className:l.cn("text-sm",n),...t,children:r})}function $({children:a,className:n,...t}){const{range:i,totalItems:o,texts:s}=c(),r=typeof a=="function"?a({...i,total:o}):a??s.range(i.start,i.end,o);return e.jsx("span",{"data-slot":"pagination-range",className:l.cn("text-sm",n),...t,children:r})}function y({sizes:a=S.PAGINATION_SIZES,className:n,...t}){const{pageSize:i,setPageSize:o,goTo:s}=c(),r=g=>{const p=Number(g.target.value);o(p),s(1)};return e.jsx("select",{"data-slot":"pagination-size-select",value:i,onChange:r,className:l.cn("border border-input rounded-md w-fit min-w-[3rem] bg-background p-2 ring-offset-background","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",n),...t,children:a.map(g=>e.jsx("option",{value:g,"data-slot":"pagination-size-option",children:g},g))})}function Z({sizes:a=S.PAGINATION_SIZES,selectClassName:n,rangeClassName:t,previousClassName:i,nextClassName:o,className:s,...r}){return e.jsxs(z,{className:s,...r,children:[a&&e.jsx(y,{sizes:a,className:n}),e.jsx($,{className:t}),e.jsx(k,{className:i}),e.jsx(q,{className:o})]})}exports.Pagination=Z;exports.PaginationEllipsis=E;exports.PaginationFirst=_;exports.PaginationLast=B;exports.PaginationLink=R;exports.PaginationNext=q;exports.PaginationPageInfo=G;exports.PaginationPages=O;exports.PaginationPrevious=k;exports.PaginationRange=$;exports.PaginationRoot=z;exports.PaginationSizeSelect=y;exports.PaginationTotal=w;