@pathscale/ui 0.0.1 → 0.0.2

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 (69) hide show
  1. package/dist/Accordion-nwuRbRRw.d.ts +27 -0
  2. package/dist/Checkbox-BjaweaOH.d.ts +40 -0
  3. package/dist/Pagination-BlrjElGg.d.ts +43 -0
  4. package/dist/Progress-a616LgE0.d.ts +5 -0
  5. package/dist/Select-CP-TUHJv.d.ts +44 -0
  6. package/dist/Switch-3IXS_68H.d.ts +72 -0
  7. package/dist/Tabs-BNR3p92D.d.ts +42 -0
  8. package/dist/Tag-BPrhn-Ne.d.ts +42 -0
  9. package/dist/Tooltip-BfPongoz.d.ts +53 -0
  10. package/dist/Upload-BrFuZ4JA.d.ts +39 -0
  11. package/dist/chunk/3IHANYRN.js +98 -0
  12. package/dist/chunk/4TWLQ3IA.js +103 -0
  13. package/dist/chunk/6SBH3KSM.jsx +96 -0
  14. package/dist/chunk/CJZGTNJZ.js +115 -0
  15. package/dist/chunk/DBQ7IOPU.js +189 -0
  16. package/dist/chunk/DNTGSCVF.jsx +100 -0
  17. package/dist/chunk/ELRAUORW.jsx +179 -0
  18. package/dist/chunk/FPUQ25SO.js +137 -0
  19. package/dist/chunk/GLEAR2TS.jsx +160 -0
  20. package/dist/chunk/KV6LTJHI.jsx +175 -0
  21. package/dist/chunk/LI3HCFL7.jsx +132 -0
  22. package/dist/chunk/MMTAND25.jsx +126 -0
  23. package/dist/chunk/MXG3MBEN.jsx +148 -0
  24. package/dist/chunk/NZKPDBTE.js +118 -0
  25. package/dist/chunk/P2L6LFLS.js +144 -0
  26. package/dist/chunk/QLESLIWS.jsx +110 -0
  27. package/dist/chunk/QNOJ6PCD.js +278 -0
  28. package/dist/chunk/QONDPQ2I.jsx +105 -0
  29. package/dist/chunk/S3ZDSQSV.js +98 -0
  30. package/dist/chunk/V6Y5E7BL.js +133 -0
  31. package/dist/chunk/WCBMW2TP.jsx +203 -0
  32. package/dist/chunk/WOT36Q7O.js +166 -0
  33. package/dist/components/Progress/index.d.ts +2 -3
  34. package/dist/components/Progress/index.js +1 -278
  35. package/dist/components/Progress/index.jsx +7 -194
  36. package/dist/components/accordion/index.d.ts +5 -24
  37. package/dist/components/accordion/index.js +1 -118
  38. package/dist/components/accordion/index.jsx +3 -100
  39. package/dist/components/breadcrumb/index.d.ts +2 -2
  40. package/dist/components/breadcrumb/index.js +1 -133
  41. package/dist/components/breadcrumb/index.jsx +4 -120
  42. package/dist/components/checkbox/index.d.ts +5 -37
  43. package/dist/components/checkbox/index.js +1 -137
  44. package/dist/components/checkbox/index.jsx +3 -143
  45. package/dist/components/pagination/index.d.ts +5 -40
  46. package/dist/components/pagination/index.js +1 -189
  47. package/dist/components/pagination/index.jsx +3 -174
  48. package/dist/components/select/index.d.ts +5 -41
  49. package/dist/components/select/index.js +1 -98
  50. package/dist/components/select/index.jsx +3 -91
  51. package/dist/components/switch/index.d.ts +5 -69
  52. package/dist/components/switch/index.js +1 -144
  53. package/dist/components/switch/index.jsx +3 -155
  54. package/dist/components/tabs/index.d.ts +5 -39
  55. package/dist/components/tabs/index.js +1 -166
  56. package/dist/components/tabs/index.jsx +3 -170
  57. package/dist/components/tag/index.d.ts +5 -39
  58. package/dist/components/tag/index.js +1 -115
  59. package/dist/components/tag/index.jsx +3 -127
  60. package/dist/components/tooltip/index.d.ts +5 -50
  61. package/dist/components/tooltip/index.js +1 -103
  62. package/dist/components/tooltip/index.jsx +3 -95
  63. package/dist/components/upload/index.d.ts +5 -36
  64. package/dist/components/upload/index.js +1 -98
  65. package/dist/components/upload/index.jsx +3 -105
  66. package/dist/index.d.ts +11 -0
  67. package/dist/index.js +12 -1
  68. package/dist/index.jsx +47 -1
  69. package/package.json +1 -1
@@ -0,0 +1,96 @@
1
+ import {
2
+ classes,
3
+ cva
4
+ } from "./P7WPLZNA.jsx";
5
+
6
+ // src/components/select/Select.tsx
7
+ import {
8
+ splitProps,
9
+ Show,
10
+ createMemo,
11
+ untrack
12
+ } from "solid-js";
13
+
14
+ // src/components/select/Select.styles.ts
15
+ var selectVariants = cva(
16
+ [
17
+ "relative inline-flex items-center appearance-none",
18
+ "border outline-none",
19
+ "transition bg-white text-black",
20
+ "disabled:opacity-50 disabled:cursor-not-allowed"
21
+ ],
22
+ {
23
+ variants: {
24
+ size: {
25
+ sm: "text-sm px-2 py-1",
26
+ md: "text-base px-3 py-2",
27
+ lg: "text-lg px-4 py-2"
28
+ },
29
+ color: {
30
+ primary: "border-gray-300 focus:border-primary",
31
+ info: "border-blue-300 focus:border-blue-500",
32
+ success: "border-green-300 focus:border-green-500",
33
+ warning: "border-yellow-300 focus:border-yellow-500",
34
+ danger: "border-red-300 focus:border-red-500"
35
+ },
36
+ loading: {
37
+ true: "cursor-wait opacity-75",
38
+ false: ""
39
+ },
40
+ expanded: {
41
+ true: "w-full",
42
+ false: "w-fit"
43
+ },
44
+ rounded: {
45
+ true: "rounded",
46
+ false: "rounded-none"
47
+ }
48
+ },
49
+ defaultVariants: {
50
+ size: "md",
51
+ color: "primary",
52
+ loading: false,
53
+ expanded: false,
54
+ rounded: false
55
+ }
56
+ }
57
+ );
58
+
59
+ // src/components/select/Select.tsx
60
+ var Select = (props) => {
61
+ const [localProps, variantProps, otherProps] = splitProps(
62
+ props,
63
+ ["placeholder", "value", "nativeSize", "onChange", "onBlur", "onFocus"],
64
+ ["class", ...selectVariants.variantKeys]
65
+ );
66
+ const empty = createMemo(
67
+ () => untrack(() => localProps.value === null || localProps.value === void 0)
68
+ );
69
+ const selectClasses = createMemo(
70
+ () => classes(selectVariants(variantProps), variantProps.class)
71
+ );
72
+ return <select
73
+ class={selectClasses()}
74
+ size={localProps.nativeSize}
75
+ value={localProps.value}
76
+ onChange={localProps.onChange}
77
+ onFocus={localProps.onFocus}
78
+ onBlur={localProps.onBlur}
79
+ {...otherProps}
80
+ >
81
+ <Show when={localProps.placeholder && empty()}>
82
+ <option value="" disabled hidden>
83
+ {localProps.placeholder}
84
+ </option>
85
+ </Show>
86
+ {props.children}
87
+ </select>;
88
+ };
89
+ var Select_default = Select;
90
+
91
+ // src/components/select/index.ts
92
+ var select_default = Select_default;
93
+
94
+ export {
95
+ select_default
96
+ };
@@ -0,0 +1,115 @@
1
+ import { cva, classes } from './HKS7ET6T.js';
2
+ import { delegateEvents, template, spread, mergeProps, insert, createComponent, effect, setAttribute, className } from 'solid-js/web';
3
+ import { splitProps, createMemo, untrack, Show } from 'solid-js';
4
+
5
+ // src/components/tag/Tag.styles.ts
6
+ var tagVariants = cva(
7
+ [
8
+ "inline-flex items-center gap-2 px-3 py-1 text-sm rounded",
9
+ "transition select-none"
10
+ ],
11
+ {
12
+ variants: {
13
+ size: {
14
+ normal: "text-xs px-2 py-0.5",
15
+ medium: "text-sm px-3 py-1",
16
+ large: "text-base px-4 py-2"
17
+ },
18
+ type: {
19
+ primary: "bg-blue-500 text-white",
20
+ info: "bg-sky-500 text-white",
21
+ success: "bg-green-500 text-white",
22
+ warning: "bg-yellow-500 text-black",
23
+ danger: "bg-red-500 text-white",
24
+ dark: "bg-zinc-800 text-white",
25
+ light: "bg-gray-100 text-black"
26
+ },
27
+ rounded: {
28
+ true: "rounded-full",
29
+ false: ""
30
+ },
31
+ closable: {
32
+ true: "pr-1",
33
+ false: ""
34
+ }
35
+ },
36
+ defaultVariants: {
37
+ size: "normal"
38
+ }
39
+ }
40
+ );
41
+
42
+ // src/components/tag/Tag.tsx
43
+ var _tmpl$ = /* @__PURE__ */ template(`<button type=button class="ml-2 text-xs text-white hover:opacity-80">`);
44
+ var _tmpl$2 = /* @__PURE__ */ template(`<button type=button>`);
45
+ var _tmpl$3 = /* @__PURE__ */ template(`<div role=group><span role=status><span class=truncate>`);
46
+ var Tag = (props) => {
47
+ const [localProps, variantProps, otherProps] = splitProps(props, ["closable", "attached", "onClose", "ariaCloseLabel", "closeIcon", "children", "type"], ["class", ...tagVariants.variantKeys]);
48
+ const isAttachedClosable = createMemo(() => untrack(() => localProps.attached && localProps.closable));
49
+ const isClosable = createMemo(() => untrack(() => localProps.closable && !localProps.attached));
50
+ const tagClasses = createMemo(() => classes(tagVariants({
51
+ ...variantProps,
52
+ closable: localProps.closable
53
+ }), variantProps.class));
54
+ const attachedButtonClasses = createMemo(() => tagVariants({
55
+ ...variantProps,
56
+ class: "ml-1 text-xs hover:opacity-80"
57
+ }));
58
+ const handleClose = (e) => {
59
+ untrack(() => {
60
+ if (typeof localProps.onClose === "function") {
61
+ localProps.onClose(e);
62
+ }
63
+ });
64
+ };
65
+ return (() => {
66
+ var _el$ = _tmpl$3(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild;
67
+ spread(_el$2, mergeProps({
68
+ get ["class"]() {
69
+ return tagClasses();
70
+ }
71
+ }, otherProps), false, true);
72
+ insert(_el$3, () => localProps.children);
73
+ insert(_el$2, createComponent(Show, {
74
+ get when() {
75
+ return isClosable();
76
+ },
77
+ get children() {
78
+ var _el$4 = _tmpl$();
79
+ _el$4.$$click = handleClose;
80
+ insert(_el$4, () => localProps.closeIcon ?? "\xD7");
81
+ effect(() => setAttribute(_el$4, "aria-label", localProps.ariaCloseLabel ?? "Remove tag"));
82
+ return _el$4;
83
+ }
84
+ }), null);
85
+ insert(_el$, createComponent(Show, {
86
+ get when() {
87
+ return isAttachedClosable();
88
+ },
89
+ get children() {
90
+ var _el$5 = _tmpl$2();
91
+ _el$5.$$click = handleClose;
92
+ insert(_el$5, () => localProps.closeIcon ?? "\xD7");
93
+ effect((_p$) => {
94
+ var _v$ = localProps.ariaCloseLabel ?? "Remove tag", _v$2 = attachedButtonClasses();
95
+ _v$ !== _p$.e && setAttribute(_el$5, "aria-label", _p$.e = _v$);
96
+ _v$2 !== _p$.t && className(_el$5, _p$.t = _v$2);
97
+ return _p$;
98
+ }, {
99
+ e: void 0,
100
+ t: void 0
101
+ });
102
+ return _el$5;
103
+ }
104
+ }), null);
105
+ effect(() => className(_el$, isAttachedClosable() ? "tags has-addons" : void 0));
106
+ return _el$;
107
+ })();
108
+ };
109
+ var Tag_default = Tag;
110
+ delegateEvents(["click"]);
111
+
112
+ // src/components/tag/index.ts
113
+ var tag_default = Tag_default;
114
+
115
+ export { tag_default };
@@ -0,0 +1,189 @@
1
+ import { cva } from './HKS7ET6T.js';
2
+ import { delegateEvents, template, spread, mergeProps, insert, createComponent, memo, effect, className } from 'solid-js/web';
3
+ import { splitProps, createMemo, Show, For } from 'solid-js';
4
+
5
+ // src/components/pagination/Pagination.styles.ts
6
+ var paginationItemVariants = cva(
7
+ [
8
+ "inline-flex items-center justify-center font-medium transition-colors",
9
+ "select-none border border-transparent",
10
+ // border shown only when needed
11
+ "disabled:opacity-50 disabled:pointer-events-none"
12
+ ],
13
+ {
14
+ variants: {
15
+ active: {
16
+ true: "bg-blue-500 text-white hover:bg-blue-600",
17
+ false: "bg-transparent text-gray-700 hover:bg-gray-200 dark:text-gray-200 dark:hover:bg-gray-700"
18
+ },
19
+ rounded: {
20
+ true: "rounded-full",
21
+ false: "rounded"
22
+ },
23
+ simple: {
24
+ true: "border-none bg-transparent hover:bg-transparent text-gray-700 dark:text-gray-300",
25
+ false: ""
26
+ },
27
+ size: {
28
+ sm: "text-xs px-2 py-1",
29
+ md: "text-sm px-3 py-1.5",
30
+ lg: "text-base px-4 py-2"
31
+ },
32
+ disabled: {
33
+ true: "opacity-50 pointer-events-none",
34
+ false: ""
35
+ }
36
+ },
37
+ defaultVariants: {
38
+ active: false,
39
+ rounded: false,
40
+ simple: false,
41
+ size: "md",
42
+ disabled: false
43
+ }
44
+ }
45
+ );
46
+ var paginationInfoVariants = cva(
47
+ "inline-block font-medium transition-colors",
48
+ {
49
+ variants: {
50
+ simple: {
51
+ true: "text-sm text-gray-600 dark:text-gray-300 px-2",
52
+ false: "text-sm text-gray-700 dark:text-gray-200 px-2"
53
+ }
54
+ },
55
+ defaultVariants: {
56
+ simple: false
57
+ }
58
+ }
59
+ );
60
+ var paginationContainerVariants = cva(
61
+ "flex items-center gap-1 flex-wrap",
62
+ {
63
+ variants: {
64
+ align: {
65
+ start: "justify-start",
66
+ center: "justify-center",
67
+ end: "justify-end"
68
+ },
69
+ wrap: {
70
+ true: "flex-wrap",
71
+ false: "flex-nowrap"
72
+ }
73
+ },
74
+ defaultVariants: {
75
+ align: "start",
76
+ wrap: true
77
+ }
78
+ }
79
+ );
80
+
81
+ // src/components/pagination/Pagination.tsx
82
+ var _tmpl$ = /* @__PURE__ */ template(`<span>`);
83
+ var _tmpl$2 = /* @__PURE__ */ template(`<nav><button>&laquo;</button><button>&raquo;`);
84
+ var _tmpl$3 = /* @__PURE__ */ template(`<button>`);
85
+ var Pagination = (props) => {
86
+ const [local, variantProps, otherProps] = splitProps(props, ["total", "perPage", "current", "onChange", "rangeBefore", "rangeAfter", "simple", "children"], ["rounded", "size", "disabled", "active", "simple"]);
87
+ const perPage = () => local.perPage ?? 20;
88
+ const pageCount = createMemo(() => Math.ceil(local.total / perPage()));
89
+ const hasPrev = createMemo(() => local.current > 1);
90
+ const hasNext = createMemo(() => local.current < pageCount());
91
+ const pagesInRange = createMemo(() => {
92
+ const before = local.rangeBefore ?? 1;
93
+ const after = local.rangeAfter ?? 1;
94
+ const start = Math.max(1, local.current - before);
95
+ const end = Math.min(local.current + after, pageCount());
96
+ return Array.from({
97
+ length: end - start + 1
98
+ }, (_, i) => start + i);
99
+ });
100
+ const changePage = (page) => {
101
+ if (page >= 1 && page <= pageCount() && page !== local.current) {
102
+ local.onChange(page);
103
+ }
104
+ };
105
+ return (() => {
106
+ var _el$ = _tmpl$2(), _el$2 = _el$.firstChild, _el$4 = _el$2.nextSibling;
107
+ spread(_el$, mergeProps({
108
+ get ["class"]() {
109
+ return paginationContainerVariants({
110
+ align: "start",
111
+ wrap: true
112
+ });
113
+ }
114
+ }, otherProps), false, true);
115
+ _el$2.$$click = () => changePage(local.current - 1);
116
+ insert(_el$, createComponent(Show, {
117
+ get when() {
118
+ return pageCount() > 1;
119
+ },
120
+ get children() {
121
+ return [createComponent(Show, {
122
+ get when() {
123
+ return local.simple;
124
+ },
125
+ get children() {
126
+ var _el$3 = _tmpl$();
127
+ insert(_el$3, (() => {
128
+ var _c$ = memo(() => perPage() === 1);
129
+ return () => _c$() ? `${(local.current - 1) * perPage() + 1} / ${local.total}` : `${(local.current - 1) * perPage() + 1}-${Math.min(local.current * perPage(), local.total)} / ${local.total}`;
130
+ })());
131
+ effect(() => className(_el$3, paginationInfoVariants({
132
+ simple: true
133
+ })));
134
+ return _el$3;
135
+ }
136
+ }), createComponent(Show, {
137
+ get when() {
138
+ return !local.simple;
139
+ },
140
+ get children() {
141
+ return createComponent(For, {
142
+ get each() {
143
+ return pagesInRange();
144
+ },
145
+ children: (page) => (() => {
146
+ var _el$5 = _tmpl$3();
147
+ _el$5.$$click = () => changePage(page);
148
+ insert(_el$5, page);
149
+ effect(() => className(_el$5, paginationItemVariants({
150
+ ...variantProps,
151
+ active: page === local.current
152
+ })));
153
+ return _el$5;
154
+ })()
155
+ });
156
+ }
157
+ })];
158
+ }
159
+ }), _el$4);
160
+ _el$4.$$click = () => changePage(local.current + 1);
161
+ effect((_p$) => {
162
+ var _v$ = paginationItemVariants({
163
+ ...variantProps,
164
+ disabled: !hasPrev()
165
+ }), _v$2 = !hasPrev(), _v$3 = paginationItemVariants({
166
+ ...variantProps,
167
+ disabled: !hasNext()
168
+ }), _v$4 = !hasNext();
169
+ _v$ !== _p$.e && className(_el$2, _p$.e = _v$);
170
+ _v$2 !== _p$.t && (_el$2.disabled = _p$.t = _v$2);
171
+ _v$3 !== _p$.a && className(_el$4, _p$.a = _v$3);
172
+ _v$4 !== _p$.o && (_el$4.disabled = _p$.o = _v$4);
173
+ return _p$;
174
+ }, {
175
+ e: void 0,
176
+ t: void 0,
177
+ a: void 0,
178
+ o: void 0
179
+ });
180
+ return _el$;
181
+ })();
182
+ };
183
+ var Pagination_default = Pagination;
184
+ delegateEvents(["click"]);
185
+
186
+ // src/components/pagination/index.ts
187
+ var pagination_default = Pagination_default;
188
+
189
+ export { pagination_default };
@@ -0,0 +1,100 @@
1
+ import {
2
+ cva
3
+ } from "./P7WPLZNA.jsx";
4
+
5
+ // src/components/tooltip/Tooltip.tsx
6
+ import {
7
+ splitProps,
8
+ Show
9
+ } from "solid-js";
10
+
11
+ // src/components/tooltip/Tooltip.styles.ts
12
+ var tooltipVariants = cva(
13
+ [
14
+ "absolute z-10 px-3 py-1 text-white text-sm",
15
+ "opacity-0 group-hover:opacity-100",
16
+ "pointer-events-none transition-opacity duration-200",
17
+ "max-w-xs break-words",
18
+ "after:content-[''] after:absolute after:w-2 after:h-2 after:rotate-45 after:bg-inherit"
19
+ ].join(" "),
20
+ {
21
+ variants: {
22
+ type: {
23
+ info: "bg-blue-500",
24
+ success: "bg-green-500",
25
+ warning: "bg-yellow-500",
26
+ danger: "bg-red-500",
27
+ primary: "bg-indigo-500",
28
+ gray: "bg-gray-700"
29
+ },
30
+ size: {
31
+ sm: "text-xs",
32
+ md: "text-sm",
33
+ lg: "text-base"
34
+ },
35
+ rounded: {
36
+ true: "rounded",
37
+ false: "rounded-none"
38
+ },
39
+ dashed: {
40
+ true: "border border-white border-dashed",
41
+ false: ""
42
+ },
43
+ multilined: {
44
+ true: "whitespace-pre-wrap",
45
+ false: "whitespace-nowrap"
46
+ },
47
+ animated: {
48
+ true: "transition-opacity duration-300 ease-in-out",
49
+ false: ""
50
+ },
51
+ position: {
52
+ top: "bottom-full left-1/2 -translate-x-1/2 mb-1 after:top-full after:left-1/2 after:-translate-x-1/2 after:-mt-1",
53
+ bottom: "top-full left-1/2 -translate-x-1/2 mt-1 after:bottom-full after:left-1/2 after:-translate-x-1/2 after:-mb-1",
54
+ left: "right-full top-1/2 -translate-y-1/2 mr-1 after:left-full after:top-1/2 after:-translate-y-1/2 after:-ml-1",
55
+ right: "left-full top-1/2 -translate-y-1/2 ml-1 after:right-full after:top-1/2 after:-translate-y-1/2 after:-mr-1"
56
+ }
57
+ },
58
+ defaultVariants: {
59
+ type: "primary",
60
+ size: "md",
61
+ rounded: true,
62
+ dashed: false,
63
+ multilined: false,
64
+ animated: true,
65
+ position: "top"
66
+ }
67
+ }
68
+ );
69
+
70
+ // src/components/tooltip/Tooltip.tsx
71
+ var Tooltip = (props) => {
72
+ const [local, variantProps, otherProps] = splitProps(
73
+ props,
74
+ ["label", "delay", "always", "children"],
75
+ ["type", "size", "position", "rounded", "dashed", "multilined", "animated"]
76
+ );
77
+ return <span class="relative inline-block group" {...otherProps}>
78
+ {local.children}
79
+ <Show when={local.label}>
80
+ <span
81
+ class={tooltipVariants(variantProps)}
82
+ style={{
83
+ "transition-delay": `${local.delay ?? 0}ms`,
84
+ opacity: local.always ? 1 : void 0,
85
+ "pointer-events": "none"
86
+ }}
87
+ >
88
+ {local.label}
89
+ </span>
90
+ </Show>
91
+ </span>;
92
+ };
93
+ var Tooltip_default = Tooltip;
94
+
95
+ // src/components/tooltip/index.ts
96
+ var tooltip_default = Tooltip_default;
97
+
98
+ export {
99
+ tooltip_default
100
+ };
@@ -0,0 +1,179 @@
1
+ import {
2
+ cva
3
+ } from "./P7WPLZNA.jsx";
4
+
5
+ // src/components/pagination/Pagination.tsx
6
+ import {
7
+ splitProps,
8
+ createMemo,
9
+ Show,
10
+ For
11
+ } from "solid-js";
12
+
13
+ // src/components/pagination/Pagination.styles.ts
14
+ var paginationItemVariants = cva(
15
+ [
16
+ "inline-flex items-center justify-center font-medium transition-colors",
17
+ "select-none border border-transparent",
18
+ // border shown only when needed
19
+ "disabled:opacity-50 disabled:pointer-events-none"
20
+ ],
21
+ {
22
+ variants: {
23
+ active: {
24
+ true: "bg-blue-500 text-white hover:bg-blue-600",
25
+ false: "bg-transparent text-gray-700 hover:bg-gray-200 dark:text-gray-200 dark:hover:bg-gray-700"
26
+ },
27
+ rounded: {
28
+ true: "rounded-full",
29
+ false: "rounded"
30
+ },
31
+ simple: {
32
+ true: "border-none bg-transparent hover:bg-transparent text-gray-700 dark:text-gray-300",
33
+ false: ""
34
+ },
35
+ size: {
36
+ sm: "text-xs px-2 py-1",
37
+ md: "text-sm px-3 py-1.5",
38
+ lg: "text-base px-4 py-2"
39
+ },
40
+ disabled: {
41
+ true: "opacity-50 pointer-events-none",
42
+ false: ""
43
+ }
44
+ },
45
+ defaultVariants: {
46
+ active: false,
47
+ rounded: false,
48
+ simple: false,
49
+ size: "md",
50
+ disabled: false
51
+ }
52
+ }
53
+ );
54
+ var paginationInfoVariants = cva(
55
+ "inline-block font-medium transition-colors",
56
+ {
57
+ variants: {
58
+ simple: {
59
+ true: "text-sm text-gray-600 dark:text-gray-300 px-2",
60
+ false: "text-sm text-gray-700 dark:text-gray-200 px-2"
61
+ }
62
+ },
63
+ defaultVariants: {
64
+ simple: false
65
+ }
66
+ }
67
+ );
68
+ var paginationContainerVariants = cva(
69
+ "flex items-center gap-1 flex-wrap",
70
+ {
71
+ variants: {
72
+ align: {
73
+ start: "justify-start",
74
+ center: "justify-center",
75
+ end: "justify-end"
76
+ },
77
+ wrap: {
78
+ true: "flex-wrap",
79
+ false: "flex-nowrap"
80
+ }
81
+ },
82
+ defaultVariants: {
83
+ align: "start",
84
+ wrap: true
85
+ }
86
+ }
87
+ );
88
+
89
+ // src/components/pagination/Pagination.tsx
90
+ var Pagination = (props) => {
91
+ const [local, variantProps, otherProps] = splitProps(
92
+ props,
93
+ [
94
+ "total",
95
+ "perPage",
96
+ "current",
97
+ "onChange",
98
+ "rangeBefore",
99
+ "rangeAfter",
100
+ "simple",
101
+ "children"
102
+ ],
103
+ ["rounded", "size", "disabled", "active", "simple"]
104
+ );
105
+ const perPage = () => local.perPage ?? 20;
106
+ const pageCount = createMemo(() => Math.ceil(local.total / perPage()));
107
+ const hasPrev = createMemo(() => local.current > 1);
108
+ const hasNext = createMemo(() => local.current < pageCount());
109
+ const pagesInRange = createMemo(() => {
110
+ const before = local.rangeBefore ?? 1;
111
+ const after = local.rangeAfter ?? 1;
112
+ const start = Math.max(1, local.current - before);
113
+ const end = Math.min(local.current + after, pageCount());
114
+ return Array.from({ length: end - start + 1 }, (_, i) => start + i);
115
+ });
116
+ const changePage = (page) => {
117
+ if (page >= 1 && page <= pageCount() && page !== local.current) {
118
+ local.onChange(page);
119
+ }
120
+ };
121
+ return <nav
122
+ class={paginationContainerVariants({ align: "start", wrap: true })}
123
+ {...otherProps}
124
+ >
125
+ <button
126
+ class={paginationItemVariants({
127
+ ...variantProps,
128
+ disabled: !hasPrev()
129
+ })}
130
+ onClick={() => changePage(local.current - 1)}
131
+ disabled={!hasPrev()}
132
+ >
133
+ &laquo;
134
+ </button>
135
+
136
+ <Show when={pageCount() > 1}>
137
+ <Show when={local.simple}>
138
+ <span class={paginationInfoVariants({ simple: true })}>
139
+ {perPage() === 1 ? `${(local.current - 1) * perPage() + 1} / ${local.total}` : `${(local.current - 1) * perPage() + 1}-${Math.min(
140
+ local.current * perPage(),
141
+ local.total
142
+ )} / ${local.total}`}
143
+ </span>
144
+ </Show>
145
+
146
+ <Show when={!local.simple}>
147
+ <For each={pagesInRange()}>
148
+ {(page) => <button
149
+ class={paginationItemVariants({
150
+ ...variantProps,
151
+ active: page === local.current
152
+ })}
153
+ onClick={() => changePage(page)}
154
+ >
155
+ {page}
156
+ </button>}
157
+ </For>
158
+ </Show>
159
+ </Show>
160
+ <button
161
+ class={paginationItemVariants({
162
+ ...variantProps,
163
+ disabled: !hasNext()
164
+ })}
165
+ onClick={() => changePage(local.current + 1)}
166
+ disabled={!hasNext()}
167
+ >
168
+ &raquo;
169
+ </button>
170
+ </nav>;
171
+ };
172
+ var Pagination_default = Pagination;
173
+
174
+ // src/components/pagination/index.ts
175
+ var pagination_default = Pagination_default;
176
+
177
+ export {
178
+ pagination_default
179
+ };