@techsio/ui-kit 0.0.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.
Files changed (183) hide show
  1. package/README.md +165 -0
  2. package/dist/atoms/badge.js +66 -0
  3. package/dist/atoms/button.js +275 -0
  4. package/dist/atoms/error-text.js +38 -0
  5. package/dist/atoms/extra-text.js +27 -0
  6. package/dist/atoms/icon.js +42 -0
  7. package/dist/atoms/image.js +11 -0
  8. package/dist/atoms/input.js +83 -0
  9. package/dist/atoms/label.js +43 -0
  10. package/dist/atoms/link-button.js +51 -0
  11. package/dist/atoms/link.js +23 -0
  12. package/dist/atoms/numeric-input.js +221 -0
  13. package/dist/atoms/rating.js +117 -0
  14. package/dist/atoms/textarea.js +81 -0
  15. package/dist/atoms/tooltip.js +119 -0
  16. package/dist/molecules/accordion.js +245 -0
  17. package/dist/molecules/breadcrumb.js +168 -0
  18. package/dist/molecules/carousel.js +333 -0
  19. package/dist/molecules/checkbox.js +92 -0
  20. package/dist/molecules/color-select.js +159 -0
  21. package/dist/molecules/combobox.js +253 -0
  22. package/dist/molecules/dialog.js +313 -0
  23. package/dist/molecules/form-checkbox.js +59 -0
  24. package/dist/molecules/form-input.js +55 -0
  25. package/dist/molecules/form-numeric-input.js +47 -0
  26. package/dist/molecules/form-textarea.js +54 -0
  27. package/dist/molecules/menu.js +302 -0
  28. package/dist/molecules/pagination.js +184 -0
  29. package/dist/molecules/popover.js +152 -0
  30. package/dist/molecules/product-card.js +194 -0
  31. package/dist/molecules/search-form.js +106 -0
  32. package/dist/molecules/select.js +217 -0
  33. package/dist/molecules/slider.js +249 -0
  34. package/dist/molecules/steps.js +178 -0
  35. package/dist/molecules/switch.js +109 -0
  36. package/dist/molecules/tabs.js +211 -0
  37. package/dist/molecules/toast.js +126 -0
  38. package/dist/molecules/tree-view.js +451 -0
  39. package/dist/organisms/footer.js +209 -0
  40. package/dist/organisms/header.js +245 -0
  41. package/dist/organisms/table.js +233 -0
  42. package/dist/src/atoms/badge.d.ts +59 -0
  43. package/dist/src/atoms/badge.d.ts.map +1 -0
  44. package/dist/src/atoms/button.d.ts +97 -0
  45. package/dist/src/atoms/button.d.ts.map +1 -0
  46. package/dist/src/atoms/error-text.d.ts +29 -0
  47. package/dist/src/atoms/error-text.d.ts.map +1 -0
  48. package/dist/src/atoms/extra-text.d.ts +27 -0
  49. package/dist/src/atoms/extra-text.d.ts.map +1 -0
  50. package/dist/src/atoms/icon.d.ts +65 -0
  51. package/dist/src/atoms/icon.d.ts.map +1 -0
  52. package/dist/src/atoms/image.d.ts +17 -0
  53. package/dist/src/atoms/image.d.ts.map +1 -0
  54. package/dist/src/atoms/input.d.ts +78 -0
  55. package/dist/src/atoms/input.d.ts.map +1 -0
  56. package/dist/src/atoms/label.d.ts +41 -0
  57. package/dist/src/atoms/label.d.ts.map +1 -0
  58. package/dist/src/atoms/link-button.d.ts +129 -0
  59. package/dist/src/atoms/link-button.d.ts.map +1 -0
  60. package/dist/src/atoms/link.d.ts +17 -0
  61. package/dist/src/atoms/link.d.ts.map +1 -0
  62. package/dist/src/atoms/numeric-input.d.ts +64 -0
  63. package/dist/src/atoms/numeric-input.d.ts.map +1 -0
  64. package/dist/src/atoms/rating.d.ts +108 -0
  65. package/dist/src/atoms/rating.d.ts.map +1 -0
  66. package/dist/src/atoms/textarea.d.ts +81 -0
  67. package/dist/src/atoms/textarea.d.ts.map +1 -0
  68. package/dist/src/atoms/tooltip.d.ts +88 -0
  69. package/dist/src/atoms/tooltip.d.ts.map +1 -0
  70. package/dist/src/molecules/accordion.d.ts +182 -0
  71. package/dist/src/molecules/accordion.d.ts.map +1 -0
  72. package/dist/src/molecules/breadcrumb.d.ts +117 -0
  73. package/dist/src/molecules/breadcrumb.d.ts.map +1 -0
  74. package/dist/src/molecules/carousel.d.ts +261 -0
  75. package/dist/src/molecules/carousel.d.ts.map +1 -0
  76. package/dist/src/molecules/checkbox.d.ts +19 -0
  77. package/dist/src/molecules/checkbox.d.ts.map +1 -0
  78. package/dist/src/molecules/color-select.d.ts +20 -0
  79. package/dist/src/molecules/color-select.d.ts.map +1 -0
  80. package/dist/src/molecules/combobox.d.ts +141 -0
  81. package/dist/src/molecules/combobox.d.ts.map +1 -0
  82. package/dist/src/molecules/dialog.d.ts +234 -0
  83. package/dist/src/molecules/dialog.d.ts.map +1 -0
  84. package/dist/src/molecules/form-checkbox.d.ts +15 -0
  85. package/dist/src/molecules/form-checkbox.d.ts.map +1 -0
  86. package/dist/src/molecules/form-input.d.ts +14 -0
  87. package/dist/src/molecules/form-input.d.ts.map +1 -0
  88. package/dist/src/molecules/form-numeric-input.d.ts +14 -0
  89. package/dist/src/molecules/form-numeric-input.d.ts.map +1 -0
  90. package/dist/src/molecules/form-textarea.d.ts +14 -0
  91. package/dist/src/molecules/form-textarea.d.ts.map +1 -0
  92. package/dist/src/molecules/menu.d.ts +153 -0
  93. package/dist/src/molecules/menu.d.ts.map +1 -0
  94. package/dist/src/molecules/pagination.d.ts +123 -0
  95. package/dist/src/molecules/pagination.d.ts.map +1 -0
  96. package/dist/src/molecules/popover.d.ts +124 -0
  97. package/dist/src/molecules/popover.d.ts.map +1 -0
  98. package/dist/src/molecules/product-card.d.ts +160 -0
  99. package/dist/src/molecules/product-card.d.ts.map +1 -0
  100. package/dist/src/molecules/search-form.d.ts +39 -0
  101. package/dist/src/molecules/search-form.d.ts.map +1 -0
  102. package/dist/src/molecules/select.d.ts +126 -0
  103. package/dist/src/molecules/select.d.ts.map +1 -0
  104. package/dist/src/molecules/slider.d.ts +120 -0
  105. package/dist/src/molecules/slider.d.ts.map +1 -0
  106. package/dist/src/molecules/steps.d.ts +96 -0
  107. package/dist/src/molecules/steps.d.ts.map +1 -0
  108. package/dist/src/molecules/switch.d.ts +71 -0
  109. package/dist/src/molecules/switch.d.ts.map +1 -0
  110. package/dist/src/molecules/tabs.d.ts +207 -0
  111. package/dist/src/molecules/tabs.d.ts.map +1 -0
  112. package/dist/src/molecules/toast.d.ts +83 -0
  113. package/dist/src/molecules/toast.d.ts.map +1 -0
  114. package/dist/src/molecules/tree-view.d.ts +202 -0
  115. package/dist/src/molecules/tree-view.d.ts.map +1 -0
  116. package/dist/src/organisms/footer.d.ts +254 -0
  117. package/dist/src/organisms/footer.d.ts.map +1 -0
  118. package/dist/src/organisms/header.d.ts +186 -0
  119. package/dist/src/organisms/header.d.ts.map +1 -0
  120. package/dist/src/organisms/table.d.ts +250 -0
  121. package/dist/src/organisms/table.d.ts.map +1 -0
  122. package/dist/src/templates/accordion.d.ts +15 -0
  123. package/dist/src/templates/accordion.d.ts.map +1 -0
  124. package/dist/src/templates/carousel.d.ts +13 -0
  125. package/dist/src/templates/carousel.d.ts.map +1 -0
  126. package/dist/src/templates/numeric-input.d.ts +14 -0
  127. package/dist/src/templates/numeric-input.d.ts.map +1 -0
  128. package/dist/src/templates/product-card.d.ts +33 -0
  129. package/dist/src/templates/product-card.d.ts.map +1 -0
  130. package/dist/src/templates/tabs.d.ts +16 -0
  131. package/dist/src/templates/tabs.d.ts.map +1 -0
  132. package/dist/src/types/zag.d.ts +19 -0
  133. package/dist/src/types/zag.d.ts.map +1 -0
  134. package/dist/src/utils.d.ts +4 -0
  135. package/dist/src/utils.d.ts.map +1 -0
  136. package/dist/templates/accordion.js +37 -0
  137. package/dist/templates/carousel.js +55 -0
  138. package/dist/templates/numeric-input.js +49 -0
  139. package/dist/templates/product-card.js +92 -0
  140. package/dist/templates/tabs.js +34 -0
  141. package/dist/types/zag.js +0 -0
  142. package/dist/utils.js +20 -0
  143. package/package.json +126 -0
  144. package/src/tokens/_base.css +25 -0
  145. package/src/tokens/_colors.css +5 -0
  146. package/src/tokens/_layout.css +34 -0
  147. package/src/tokens/_semantic.css +360 -0
  148. package/src/tokens/_spacing.css +22 -0
  149. package/src/tokens/_typography.css +17 -0
  150. package/src/tokens/components/atoms/_badge.css +61 -0
  151. package/src/tokens/components/atoms/_button.css +215 -0
  152. package/src/tokens/components/atoms/_icon.css +122 -0
  153. package/src/tokens/components/atoms/_input.css +125 -0
  154. package/src/tokens/components/atoms/_numeric-input.css +57 -0
  155. package/src/tokens/components/atoms/_rating.css +33 -0
  156. package/src/tokens/components/atoms/_textarea.css +93 -0
  157. package/src/tokens/components/atoms/_tooltip.css +21 -0
  158. package/src/tokens/components/components.css +32 -0
  159. package/src/tokens/components/molecules/_accordion.css +85 -0
  160. package/src/tokens/components/molecules/_breadcrumb.css +44 -0
  161. package/src/tokens/components/molecules/_carousel.css +72 -0
  162. package/src/tokens/components/molecules/_checkbox.css +29 -0
  163. package/src/tokens/components/molecules/_color-select.css +61 -0
  164. package/src/tokens/components/molecules/_combobox.css +116 -0
  165. package/src/tokens/components/molecules/_dialog.css +75 -0
  166. package/src/tokens/components/molecules/_menu.css +48 -0
  167. package/src/tokens/components/molecules/_pagination.css +75 -0
  168. package/src/tokens/components/molecules/_popover.css +39 -0
  169. package/src/tokens/components/molecules/_product-card.css +85 -0
  170. package/src/tokens/components/molecules/_search-form.css +10 -0
  171. package/src/tokens/components/molecules/_select.css +88 -0
  172. package/src/tokens/components/molecules/_slider.css +75 -0
  173. package/src/tokens/components/molecules/_steps.css +54 -0
  174. package/src/tokens/components/molecules/_switch.css +62 -0
  175. package/src/tokens/components/molecules/_tabs.css +69 -0
  176. package/src/tokens/components/molecules/_toast.css +77 -0
  177. package/src/tokens/components/molecules/_tree-view.css +80 -0
  178. package/src/tokens/components/molecules/index.css +2 -0
  179. package/src/tokens/components/organisms/_footer.css +90 -0
  180. package/src/tokens/components/organisms/_header.css +86 -0
  181. package/src/tokens/components/organisms/_table.css +63 -0
  182. package/src/tokens/index.css +67 -0
  183. package/src/tokens/tokens-only.css +66 -0
@@ -0,0 +1,47 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { ErrorText } from "../atoms/error-text.js";
3
+ import { ExtraText } from "../atoms/extra-text.js";
4
+ import { Label } from "../atoms/label.js";
5
+ import { NumericInput } from "../atoms/numeric-input.js";
6
+ function FormNumericInput({ id, label, validateStatus = 'default', helpText, extraText, size = 'md', required, disabled, children, ...numericInputProps }) {
7
+ const helpTextId = helpText ? `${id}-helper` : void 0;
8
+ const extraTextId = extraText ? `${id}-extra` : void 0;
9
+ return /*#__PURE__*/ jsxs("div", {
10
+ className: "flex flex-col gap-numeric-input-root-md data-[size=lg]:gap-numeric-input-root-lg data-[size=sm]:gap-numeric-input-root-sm",
11
+ "data-size": size,
12
+ children: [
13
+ /*#__PURE__*/ jsx(Label, {
14
+ htmlFor: id,
15
+ size: size,
16
+ required: required,
17
+ disabled: disabled,
18
+ children: label
19
+ }),
20
+ /*#__PURE__*/ jsx(NumericInput, {
21
+ id: id,
22
+ size: size,
23
+ required: required,
24
+ invalid: 'error' === validateStatus,
25
+ disabled: disabled,
26
+ ...numericInputProps,
27
+ children: children
28
+ }),
29
+ helpText && ('error' === validateStatus ? /*#__PURE__*/ jsx(ErrorText, {
30
+ id: helpTextId,
31
+ size: size,
32
+ showIcon: true,
33
+ children: helpText
34
+ }) : /*#__PURE__*/ jsx(ExtraText, {
35
+ id: helpTextId,
36
+ size: size,
37
+ children: helpText
38
+ })),
39
+ extraText && /*#__PURE__*/ jsx(ExtraText, {
40
+ id: extraTextId,
41
+ size: size,
42
+ children: extraText
43
+ })
44
+ ]
45
+ });
46
+ }
47
+ export { FormNumericInput };
@@ -0,0 +1,54 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { ErrorText } from "../atoms/error-text.js";
3
+ import { ExtraText } from "../atoms/extra-text.js";
4
+ import { Label } from "../atoms/label.js";
5
+ import { Textarea } from "../atoms/textarea.js";
6
+ function FormTextareaRaw({ id, label, validateStatus = 'default', helpText, extraText, size = 'md', required, disabled, ...props }) {
7
+ const extraTextId = extraText ? `${id}-extra` : void 0;
8
+ return /*#__PURE__*/ jsxs("div", {
9
+ className: "flex flex-col gap-1",
10
+ children: [
11
+ /*#__PURE__*/ jsx(Label, {
12
+ htmlFor: id,
13
+ size: size,
14
+ required: required,
15
+ disabled: disabled,
16
+ children: label
17
+ }),
18
+ /*#__PURE__*/ jsx(Textarea, {
19
+ id: id,
20
+ size: size,
21
+ required: required,
22
+ variant: validateStatus,
23
+ disabled: disabled,
24
+ ...props
25
+ }),
26
+ helpText,
27
+ extraText && /*#__PURE__*/ jsx(ExtraText, {
28
+ id: extraTextId,
29
+ size: size,
30
+ children: extraText
31
+ })
32
+ ]
33
+ });
34
+ }
35
+ function FormTextarea({ helpText, id, validateStatus, size, ...props }) {
36
+ const helpTextId = helpText ? `${id}-helper` : void 0;
37
+ return /*#__PURE__*/ jsx(FormTextareaRaw, {
38
+ id: id,
39
+ size: size,
40
+ validateStatus: validateStatus,
41
+ helpText: 'error' === validateStatus ? /*#__PURE__*/ jsx(ErrorText, {
42
+ id: helpTextId,
43
+ size: size,
44
+ showIcon: true,
45
+ children: helpText
46
+ }) : /*#__PURE__*/ jsx(ExtraText, {
47
+ id: helpTextId,
48
+ size: size,
49
+ children: helpText
50
+ }),
51
+ ...props
52
+ });
53
+ }
54
+ export { FormTextarea, FormTextareaRaw };
@@ -0,0 +1,302 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { connect, machine } from "@zag-js/menu";
3
+ import { Portal, normalizeProps, useMachine } from "@zag-js/react";
4
+ import { cloneElement, isValidElement, useEffect, useId } from "react";
5
+ import { tv } from "tailwind-variants";
6
+ import { Button } from "../atoms/button.js";
7
+ import { Icon } from "../atoms/icon.js";
8
+ const menuVariants = tv({
9
+ slots: {
10
+ trigger: '',
11
+ positioner: [
12
+ 'w-(--reference-width)',
13
+ 'isolate z-(--z-index)'
14
+ ],
15
+ content: [
16
+ 'bg-menu-content-bg border border-menu-content-border',
17
+ 'rounded-menu shadow-menu-content-shadow',
18
+ 'p-menu-content',
19
+ 'overflow-auto',
20
+ 'focus:outline-none',
21
+ 'data-[state=open]:animate-in',
22
+ 'data-[state=closed]:animate-out'
23
+ ],
24
+ item: [
25
+ 'flex items-center gap-menu-item',
26
+ 'cursor-pointer',
27
+ 'px-menu-item-x py-menu-item-y',
28
+ 'text-menu-item-fg',
29
+ 'rounded-menu-item',
30
+ 'hover:bg-menu-item-hover',
31
+ 'focus:bg-menu-item-hover focus:outline-none',
32
+ 'data-[disabled]:opacity-menu-disabled data-[disabled]:cursor-not-allowed',
33
+ 'data-[highlighted]:bg-menu-item-hover',
34
+ 'data-[disabled]:opacity-50'
35
+ ],
36
+ optionItem: [
37
+ 'data-[state=checked]:font-semibold'
38
+ ],
39
+ separator: [
40
+ 'my-menu-separator',
41
+ 'h-menu-separator',
42
+ 'bg-menu-separator-bg'
43
+ ],
44
+ itemText: [
45
+ 'flex-grow'
46
+ ],
47
+ itemIcon: [
48
+ 'text-menu-item-icon-size text-menu-item-icon-fg'
49
+ ],
50
+ submenuIndicator: [
51
+ 'ms-menu-submenu-indicator text-menu-submenu-indicator-fg'
52
+ ]
53
+ },
54
+ variants: {
55
+ size: {
56
+ sm: {
57
+ content: 'text-sm',
58
+ item: 'text-sm'
59
+ },
60
+ md: {
61
+ content: 'text-md',
62
+ item: 'text-md'
63
+ },
64
+ lg: {
65
+ content: 'text-lg',
66
+ item: 'text-lg'
67
+ }
68
+ }
69
+ },
70
+ defaultVariants: {
71
+ size: 'md'
72
+ }
73
+ });
74
+ function SubmenuItem({ item, parentApi, parentService, size = 'md', onCheckedChange, onSelect, closeOnSelect = true }) {
75
+ const submenuService = useMachine(machine, {
76
+ id: useId(),
77
+ closeOnSelect,
78
+ onSelect
79
+ });
80
+ const submenuApi = connect(submenuService, normalizeProps);
81
+ useEffect(()=>{
82
+ parentApi.setChild(submenuService);
83
+ submenuApi.setParent(parentService);
84
+ }, [
85
+ parentApi,
86
+ submenuApi,
87
+ submenuService,
88
+ parentService
89
+ ]);
90
+ const { positioner, content, separator, optionItem, item: itemSlot, itemIcon, itemText, submenuIndicator } = menuVariants({
91
+ size
92
+ });
93
+ const renderMenuItem = (menuItem)=>{
94
+ if ('separator' === menuItem.type) return /*#__PURE__*/ jsx("hr", {
95
+ className: separator()
96
+ }, `separator-${menuItem.id}`);
97
+ if ('submenu' === menuItem.type) return /*#__PURE__*/ jsx(SubmenuItem, {
98
+ item: menuItem,
99
+ parentApi: submenuApi,
100
+ parentService: submenuService,
101
+ size: size,
102
+ onCheckedChange: onCheckedChange,
103
+ onSelect: onSelect,
104
+ closeOnSelect: closeOnSelect
105
+ }, menuItem.value);
106
+ if ('radio' === menuItem.type || 'checkbox' === menuItem.type) return /*#__PURE__*/ jsxs("li", {
107
+ className: `${itemSlot()} ${optionItem()}`,
108
+ ...submenuApi.getOptionItemProps({
109
+ type: menuItem.type,
110
+ value: menuItem.value,
111
+ checked: menuItem.checked,
112
+ onCheckedChange: (checked)=>{
113
+ onCheckedChange?.(menuItem, checked);
114
+ }
115
+ }),
116
+ children: [
117
+ menuItem.checked && /*#__PURE__*/ jsx(Icon, {
118
+ icon: "token-icon-check",
119
+ className: itemIcon()
120
+ }),
121
+ /*#__PURE__*/ jsx("span", {
122
+ className: itemText(),
123
+ children: menuItem.label
124
+ })
125
+ ]
126
+ }, menuItem.value);
127
+ return /*#__PURE__*/ jsxs("li", {
128
+ className: itemSlot(),
129
+ ...submenuApi.getItemProps({
130
+ value: menuItem.value,
131
+ disabled: menuItem.disabled
132
+ }),
133
+ children: [
134
+ menuItem.icon && /*#__PURE__*/ jsx(Icon, {
135
+ icon: menuItem.icon,
136
+ className: itemIcon()
137
+ }),
138
+ /*#__PURE__*/ jsx("span", {
139
+ className: itemText(),
140
+ children: menuItem.label
141
+ })
142
+ ]
143
+ }, menuItem.value);
144
+ };
145
+ const triggerProps = parentApi.getTriggerItemProps(submenuApi);
146
+ return /*#__PURE__*/ jsxs(Fragment, {
147
+ children: [
148
+ /*#__PURE__*/ jsxs("li", {
149
+ className: itemSlot(),
150
+ ...triggerProps,
151
+ "data-disabled": item.disabled || void 0,
152
+ children: [
153
+ item.icon && /*#__PURE__*/ jsx(Icon, {
154
+ icon: item.icon,
155
+ className: itemIcon()
156
+ }),
157
+ /*#__PURE__*/ jsx("span", {
158
+ className: itemText(),
159
+ children: item.label
160
+ }),
161
+ /*#__PURE__*/ jsx(Icon, {
162
+ icon: "token-icon-menu-submenu",
163
+ className: submenuIndicator()
164
+ })
165
+ ]
166
+ }),
167
+ /*#__PURE__*/ jsx(Portal, {
168
+ children: /*#__PURE__*/ jsx("div", {
169
+ className: positioner(),
170
+ ...submenuApi.getPositionerProps(),
171
+ children: /*#__PURE__*/ jsx("ul", {
172
+ className: content(),
173
+ ...submenuApi.getContentProps(),
174
+ children: item.items.map(renderMenuItem)
175
+ })
176
+ })
177
+ })
178
+ ]
179
+ });
180
+ }
181
+ function Menu({ 'aria-label': ariaLabel, dir, id, closeOnSelect = true, loopFocus = true, typeahead = true, positioning, anchorPoint, open, defaultOpen, composite, navigate, defaultHighlightedValue, highlightedValue, onHighlightChange, onSelect, onOpenChange, onEscapeKeyDown, onPointerDownOutside, onInteractOutside, onFocusOutside, items, triggerText = 'Menu', triggerIcon, customTrigger, size = 'md', onCheckedChange }) {
182
+ const generatedId = useId();
183
+ const service = useMachine(machine, {
184
+ id: id || generatedId,
185
+ dir,
186
+ closeOnSelect,
187
+ loopFocus,
188
+ typeahead,
189
+ positioning,
190
+ defaultHighlightedValue,
191
+ highlightedValue,
192
+ anchorPoint,
193
+ open,
194
+ defaultOpen,
195
+ composite,
196
+ navigate,
197
+ onSelect,
198
+ onOpenChange,
199
+ onEscapeKeyDown,
200
+ onPointerDownOutside,
201
+ onInteractOutside,
202
+ onFocusOutside,
203
+ onHighlightChange,
204
+ 'aria-label': ariaLabel
205
+ });
206
+ const api = connect(service, normalizeProps);
207
+ const { trigger, positioner, content, separator, optionItem, item: itemSlot, itemIcon, itemText } = menuVariants({
208
+ size
209
+ });
210
+ const renderMenuItem = (item)=>{
211
+ if ('separator' === item.type) return /*#__PURE__*/ jsx("hr", {
212
+ className: separator()
213
+ }, `separator-${item.id}`);
214
+ if ('submenu' === item.type) return /*#__PURE__*/ jsx(SubmenuItem, {
215
+ item: item,
216
+ parentApi: api,
217
+ parentService: service,
218
+ size: size,
219
+ onCheckedChange: onCheckedChange,
220
+ onSelect: onSelect,
221
+ closeOnSelect: closeOnSelect
222
+ }, item.value);
223
+ if ('radio' === item.type || 'checkbox' === item.type) return /*#__PURE__*/ jsxs("li", {
224
+ className: `${itemSlot()} ${optionItem()}`,
225
+ ...api.getOptionItemProps({
226
+ type: item.type,
227
+ value: item.value,
228
+ checked: item.checked,
229
+ onCheckedChange: (checked)=>{
230
+ onCheckedChange?.(item, checked);
231
+ }
232
+ }),
233
+ children: [
234
+ item.checked && /*#__PURE__*/ jsx(Icon, {
235
+ icon: "token-icon-check",
236
+ className: itemIcon()
237
+ }),
238
+ /*#__PURE__*/ jsx("span", {
239
+ className: itemText(),
240
+ children: item.label
241
+ })
242
+ ]
243
+ }, item.value);
244
+ return /*#__PURE__*/ jsxs("li", {
245
+ className: itemSlot(),
246
+ ...api.getItemProps({
247
+ value: item.value,
248
+ disabled: item.disabled
249
+ }),
250
+ children: [
251
+ item.icon && /*#__PURE__*/ jsx(Icon, {
252
+ icon: item.icon,
253
+ className: itemIcon()
254
+ }),
255
+ /*#__PURE__*/ jsx("span", {
256
+ className: itemText(),
257
+ children: item.label
258
+ })
259
+ ]
260
+ }, item.value);
261
+ };
262
+ return /*#__PURE__*/ jsxs(Fragment, {
263
+ children: [
264
+ customTrigger ? /*#__PURE__*/ isValidElement(customTrigger) ? /*#__PURE__*/ cloneElement(customTrigger, {
265
+ ...api.getTriggerProps()
266
+ }) : /*#__PURE__*/ jsx("button", {
267
+ ...api.getTriggerProps(),
268
+ children: customTrigger
269
+ }) : /*#__PURE__*/ jsxs(Button, {
270
+ ...api.getTriggerProps(),
271
+ className: trigger(),
272
+ children: [
273
+ triggerText,
274
+ triggerIcon && /*#__PURE__*/ jsx(Icon, {
275
+ icon: triggerIcon,
276
+ className: "ms-1"
277
+ }),
278
+ !triggerIcon && /*#__PURE__*/ jsx("span", {
279
+ ...api.getIndicatorProps(),
280
+ children: /*#__PURE__*/ jsx(Icon, {
281
+ icon: "token-icon-menu-trigger",
282
+ className: "ms-1"
283
+ })
284
+ })
285
+ ]
286
+ }),
287
+ /*#__PURE__*/ jsx(Portal, {
288
+ children: /*#__PURE__*/ jsx("div", {
289
+ className: positioner(),
290
+ ...api.getPositionerProps(),
291
+ children: /*#__PURE__*/ jsx("ul", {
292
+ className: content(),
293
+ ...api.getContentProps(),
294
+ children: items.map(renderMenuItem)
295
+ })
296
+ })
297
+ })
298
+ ]
299
+ });
300
+ }
301
+ Menu.displayName = 'Menu';
302
+ export { Menu };
@@ -0,0 +1,184 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { connect, machine } from "@zag-js/pagination";
3
+ import { normalizeProps, useMachine } from "@zag-js/react";
4
+ import { useId } from "react";
5
+ import { Icon } from "../atoms/icon.js";
6
+ import { LinkButton } from "../atoms/link-button.js";
7
+ import { tv } from "../utils.js";
8
+ const paginationVariants = tv({
9
+ slots: {
10
+ base: '',
11
+ list: [
12
+ 'inline-flex items-center gap-pagination-list'
13
+ ],
14
+ item: [
15
+ 'grid cursor-pointer',
16
+ 'has-[[data-part="ellipsis"]]:bg-pagination-neutral-bg',
17
+ 'has-[[data-part="compact-text"]]:bg-pagination-neutral-bg'
18
+ ],
19
+ link: [
20
+ 'focus:outline-none',
21
+ 'focus-visible:ring',
22
+ 'focus-visible:ring-pagination-ring',
23
+ 'border-(length:--border-pagination-width) border-pagination-border rounded-pagination',
24
+ 'aspect-square',
25
+ 'data-[disabled]:text-pagination-fg-disabled data-[disabled]:hover:bg-pagination-bg-disabled',
26
+ 'data-[disabled]:bg-pagination-bg-disabled',
27
+ 'data-[disabled]:border-pagination-border-disabled data-[disabled]:cursor-not-allowed'
28
+ ],
29
+ ellipsis: '',
30
+ compactText: ''
31
+ },
32
+ compoundSlots: [
33
+ {
34
+ slots: [
35
+ 'link',
36
+ 'ellipsis'
37
+ ],
38
+ className: [
39
+ 'inline-flex items-center justify-center',
40
+ 'transition-colors duration-200',
41
+ 'text-pagination-fg'
42
+ ]
43
+ }
44
+ ],
45
+ variants: {
46
+ variant: {
47
+ filled: {
48
+ item: 'bg-pagination-bg',
49
+ link: [
50
+ 'data-[current=true]:bg-pagination-bg-active data-[current=true]:text-pagination-filled-fg-active data-[current=true]:border-pagination-border-active',
51
+ 'hover:bg-pagination-bg-hover hover:border-pagination-border-hover',
52
+ 'hover:text-pagination-filled-fg-active'
53
+ ]
54
+ },
55
+ outlined: {
56
+ item: 'bg-pagination-bg',
57
+ link: [
58
+ 'data-[current=true]:text-pagination-outlined-fg-active data-[current=true]:border-pagination-border-active',
59
+ 'hover:border-pagination-border-hover hover:text-pagination-outlined-fg-active'
60
+ ]
61
+ },
62
+ minimal: {
63
+ link: [
64
+ 'border-transparent',
65
+ 'data-[current=true]:text-pagination-minimal-fg-active',
66
+ 'hover:text-pagination-minimal-fg-active'
67
+ ]
68
+ }
69
+ },
70
+ size: {
71
+ sm: {
72
+ link: ' text-pagination-sm h-pagination-sm',
73
+ compactText: 'text-pagination-sm'
74
+ },
75
+ md: {
76
+ link: ' text-pagination-md h-pagination-md',
77
+ compactText: 'text-pagination-md'
78
+ },
79
+ lg: {
80
+ link: ' text-pagination-lg h-pagination-lg',
81
+ compactText: 'text-pagination-lg'
82
+ }
83
+ }
84
+ },
85
+ defaultVariants: {
86
+ variant: 'filled',
87
+ size: 'md'
88
+ }
89
+ });
90
+ function Pagination({ page, defaultPage = 1, count, pageSize = 10, siblingCount = 1, showPrevNext = true, onPageChange, variant, className, dir = 'ltr', linkAs, size, compact = false, ...props }) {
91
+ const uniqueId = useId();
92
+ const service = useMachine(machine, {
93
+ id: uniqueId,
94
+ count,
95
+ pageSize,
96
+ siblingCount,
97
+ page,
98
+ dir,
99
+ defaultPage,
100
+ onPageChange: ({ page })=>{
101
+ onPageChange?.(page);
102
+ }
103
+ });
104
+ const api = connect(service, normalizeProps);
105
+ const { base, list, link, item, ellipsis, compactText } = paginationVariants({
106
+ variant,
107
+ size
108
+ });
109
+ return /*#__PURE__*/ jsx("nav", {
110
+ className: base({
111
+ className
112
+ }),
113
+ ...api.getRootProps(),
114
+ ...props,
115
+ children: /*#__PURE__*/ jsxs("ul", {
116
+ className: list(),
117
+ "aria-label": "Pagination",
118
+ children: [
119
+ showPrevNext && /*#__PURE__*/ jsx("li", {
120
+ className: item(),
121
+ children: /*#__PURE__*/ jsx(LinkButton, {
122
+ theme: "borderless",
123
+ className: link(),
124
+ icon: "token-icon-pagination-prev",
125
+ disabled: 1 === api.page,
126
+ as: linkAs,
127
+ ...api.getPrevTriggerProps()
128
+ })
129
+ }),
130
+ compact ? /*#__PURE__*/ jsx("li", {
131
+ className: item(),
132
+ children: /*#__PURE__*/ jsxs("span", {
133
+ className: compactText(),
134
+ "data-part": "compact-text",
135
+ children: [
136
+ api.page,
137
+ " of ",
138
+ api.totalPages
139
+ ]
140
+ })
141
+ }) : api.pages.map((page, i)=>{
142
+ if ('page' === page.type) return /*#__PURE__*/ jsx("li", {
143
+ className: item(),
144
+ children: /*#__PURE__*/ jsx(LinkButton, {
145
+ theme: "borderless",
146
+ className: link(),
147
+ "aria-current": api.page === page.value ? 'page' : void 0,
148
+ "data-current": api.page === page.value,
149
+ as: linkAs,
150
+ ...api.getItemProps(page),
151
+ children: page.value
152
+ })
153
+ }, page.value);
154
+ return /*#__PURE__*/ jsx("li", {
155
+ className: item(),
156
+ children: /*#__PURE__*/ jsx("span", {
157
+ className: ellipsis(),
158
+ "aria-hidden": "true",
159
+ ...api.getEllipsisProps({
160
+ index: i
161
+ }),
162
+ children: /*#__PURE__*/ jsx(Icon, {
163
+ icon: "token-icon-pagination-ellipsis",
164
+ size: "current"
165
+ })
166
+ })
167
+ }, `ellipsis-${i}`);
168
+ }),
169
+ showPrevNext && /*#__PURE__*/ jsx("li", {
170
+ className: item(),
171
+ children: /*#__PURE__*/ jsx(LinkButton, {
172
+ theme: "borderless",
173
+ className: link(),
174
+ icon: "token-icon-pagination-next",
175
+ disabled: api.page === api.totalPages,
176
+ as: linkAs,
177
+ ...api.getNextTriggerProps()
178
+ })
179
+ })
180
+ ]
181
+ })
182
+ });
183
+ }
184
+ export { Pagination };