@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,119 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { Portal, normalizeProps, useMachine } from "@zag-js/react";
3
+ import { connect, machine } from "@zag-js/tooltip";
4
+ import { useId } from "react";
5
+ import { tv } from "tailwind-variants";
6
+ const tooltipVariants = tv({
7
+ slots: {
8
+ trigger: [
9
+ 'inline-flex'
10
+ ],
11
+ content: [
12
+ '[--arrow-size:var(--tooltip-arrow-size)]',
13
+ '[--arrow-background:var(--tooltip-arrow-background)]',
14
+ 'bg-tooltip-bg',
15
+ 'rounded-tooltip shadow-tooltip'
16
+ ],
17
+ positioner: [
18
+ 'relative'
19
+ ],
20
+ arrow: ''
21
+ },
22
+ variants: {
23
+ variant: {
24
+ default: {},
25
+ outline: {
26
+ content: 'border border-tooltip-border',
27
+ arrow: 'border-t border-s border-tooltip-border'
28
+ }
29
+ },
30
+ size: {
31
+ sm: {
32
+ content: 'text-tooltip-sm p-tooltip-sm'
33
+ },
34
+ md: {
35
+ content: 'text-tooltip-md p-tooltip-md'
36
+ },
37
+ lg: {
38
+ content: 'text-tooltip-lg p-tooltip-lg'
39
+ }
40
+ }
41
+ },
42
+ defaultVariants: {
43
+ size: 'md',
44
+ variant: 'default'
45
+ }
46
+ });
47
+ function Tooltip({ content, children, className, ref, size, variant, id: MRAId, dir = 'ltr', openDelay = 200, closeDelay = 200, interactive = true, defaultOpen, open, onOpenChange, disabled, closeOnEscape = true, closeOnPointerDown, closeOnScroll, closeOnClick, placement, offset = {
48
+ mainAxis: 16,
49
+ crossAxis: 0
50
+ }, gutter, flip, sameWidth, boundary, listeners, strategy }) {
51
+ const generatedId = useId();
52
+ const id = MRAId || generatedId;
53
+ const service = useMachine(machine, {
54
+ id,
55
+ dir,
56
+ open,
57
+ defaultOpen,
58
+ disabled,
59
+ openDelay,
60
+ closeDelay,
61
+ interactive,
62
+ closeOnPointerDown,
63
+ closeOnEscape,
64
+ closeOnScroll,
65
+ closeOnClick,
66
+ onOpenChange,
67
+ positioning: {
68
+ placement,
69
+ offset,
70
+ gutter,
71
+ flip,
72
+ sameWidth,
73
+ boundary,
74
+ listeners,
75
+ strategy
76
+ }
77
+ });
78
+ const api = connect(service, normalizeProps);
79
+ const { trigger, positioner, content: contentSlot, arrow } = tooltipVariants({
80
+ variant,
81
+ size
82
+ });
83
+ const triggerProps = api.getTriggerProps();
84
+ const { onBeforeInput, ...spanCompatibleProps } = triggerProps;
85
+ return /*#__PURE__*/ jsxs(Fragment, {
86
+ children: [
87
+ /*#__PURE__*/ jsx("span", {
88
+ ...spanCompatibleProps,
89
+ ref: ref,
90
+ className: trigger(),
91
+ children: children
92
+ }),
93
+ /*#__PURE__*/ jsx(Portal, {
94
+ children: api.open && /*#__PURE__*/ jsx("div", {
95
+ ...api.getPositionerProps(),
96
+ className: positioner(),
97
+ children: /*#__PURE__*/ jsxs("div", {
98
+ ...api.getContentProps(),
99
+ className: contentSlot({
100
+ className
101
+ }),
102
+ children: [
103
+ /*#__PURE__*/ jsx("div", {
104
+ ...api.getArrowProps(),
105
+ children: /*#__PURE__*/ jsx("div", {
106
+ ...api.getArrowTipProps(),
107
+ className: arrow()
108
+ })
109
+ }),
110
+ content
111
+ ]
112
+ })
113
+ })
114
+ })
115
+ ]
116
+ });
117
+ }
118
+ Tooltip.displayName = 'Tooltip';
119
+ export { Tooltip };
@@ -0,0 +1,245 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { connect, machine } from "@zag-js/accordion";
3
+ import { normalizeProps, useMachine } from "@zag-js/react";
4
+ import { createContext, useContext, useId } from "react";
5
+ import { Button } from "../atoms/button.js";
6
+ import { Icon } from "../atoms/icon.js";
7
+ import { tv } from "../utils.js";
8
+ const accordionVariants = tv({
9
+ slots: {
10
+ root: [
11
+ 'flex flex-col w-full',
12
+ 'bg-accordion-bg rounded-accordion',
13
+ 'transition-all duration-200'
14
+ ],
15
+ item: '',
16
+ title: 'grid place-items-start',
17
+ titleTrigger: [
18
+ 'flex items-center relative justify-between w-full cursor-pointer',
19
+ 'rounded-none',
20
+ 'font-accordion-title',
21
+ 'text-accordion-title-fg bg-accordion-title-bg',
22
+ 'focus-visible:outline-none',
23
+ 'focus-visible:ring',
24
+ 'focus-visible:ring-accordion-ring',
25
+ 'focus-visible:bg-accordion-bg-hover',
26
+ 'data-[disabled]:text-accordion-fg-disabled',
27
+ 'hover:bg-accordion-title-bg-hover',
28
+ 'px-0 py-0 pr-accordion-icon',
29
+ 'data-[disabled=true]:cursor-not-allowed'
30
+ ],
31
+ subtitle: [
32
+ 'text-accordion-subtitle-fg'
33
+ ],
34
+ content: [
35
+ 'text-accordion-content-fg bg-accordion-content-bg'
36
+ ],
37
+ icon: [
38
+ 'data-[state=expanded]:rotate-180'
39
+ ]
40
+ },
41
+ variants: {
42
+ variant: {
43
+ default: {
44
+ root: 'border-accordion-border border-(length:--border-width-accordion)',
45
+ item: 'border-b-(length:--border-width-accordion) border-accordion-border'
46
+ },
47
+ borderless: {},
48
+ child: {}
49
+ },
50
+ shadow: {
51
+ sm: {
52
+ root: 'shadow-accordion-root-sm',
53
+ content: 'shadow-accordion-content-sm'
54
+ },
55
+ md: {
56
+ root: 'shadow-accordion-root-md',
57
+ content: 'shadow-accordion-content-md'
58
+ },
59
+ none: ''
60
+ },
61
+ size: {
62
+ sm: {
63
+ title: 'text-accordion-title-sm p-accordion-title-sm',
64
+ content: 'text-accordion-content-sm px-accordion-content-sm',
65
+ subtitle: 'text-accordion-subtitle-sm'
66
+ },
67
+ md: {
68
+ title: 'text-accordion-title-md p-accordion-title-md',
69
+ content: 'text-accordion-content-md p-accordion-content-md',
70
+ subtitle: 'text-accordion-subtitle-md'
71
+ },
72
+ lg: {
73
+ title: 'text-accordion-title-lg p-accordion-title-lg',
74
+ content: 'text-accordion-content-lg p-accordion-content-lg',
75
+ subtitle: 'text-accordion-subtitle-lg'
76
+ }
77
+ }
78
+ },
79
+ compoundVariants: [
80
+ {
81
+ variant: 'child',
82
+ size: [
83
+ 'sm',
84
+ 'md',
85
+ 'lg'
86
+ ],
87
+ className: {
88
+ content: 'py-0 bg-inherit text-inherit'
89
+ }
90
+ }
91
+ ],
92
+ defaultVariants: {
93
+ size: 'md',
94
+ shadow: 'none',
95
+ variant: 'default'
96
+ }
97
+ });
98
+ const AccordionContext = /*#__PURE__*/ createContext(null);
99
+ function useAccordionContext() {
100
+ const context = useContext(AccordionContext);
101
+ if (!context) throw new Error('Accordion components must be used within Accordion.Root');
102
+ return context;
103
+ }
104
+ const AccordionItemContext = /*#__PURE__*/ createContext(null);
105
+ function useAccordionItemContext() {
106
+ const context = useContext(AccordionItemContext);
107
+ if (!context) throw new Error('Accordion item components must be used within Accordion.Item');
108
+ return context;
109
+ }
110
+ function Accordion({ id, defaultValue, value, collapsible = true, multiple = false, dir = 'ltr', onChange, size, shadow, disabled = false, children, ref, className, variant, ...props }) {
111
+ const generatedId = useId();
112
+ const uniqueId = id || generatedId;
113
+ const service = useMachine(machine, {
114
+ id: uniqueId,
115
+ value,
116
+ defaultValue,
117
+ collapsible,
118
+ multiple,
119
+ dir,
120
+ orientation: 'vertical',
121
+ disabled,
122
+ onValueChange: ({ value })=>{
123
+ onChange?.(value);
124
+ }
125
+ });
126
+ const api = connect(service, normalizeProps);
127
+ const styles = accordionVariants({
128
+ size,
129
+ shadow,
130
+ variant
131
+ });
132
+ return /*#__PURE__*/ jsx(AccordionContext.Provider, {
133
+ value: {
134
+ api,
135
+ size,
136
+ shadow,
137
+ styles,
138
+ variant
139
+ },
140
+ children: /*#__PURE__*/ jsx("div", {
141
+ ref: ref,
142
+ className: styles.root({
143
+ className
144
+ }),
145
+ ...props,
146
+ ...api.getRootProps(),
147
+ children: children
148
+ })
149
+ });
150
+ }
151
+ Accordion.Item = function({ value, disabled, children, ref, className, ...props }) {
152
+ const { api, styles, variant } = useAccordionContext();
153
+ return /*#__PURE__*/ jsx(AccordionItemContext.Provider, {
154
+ value: {
155
+ value,
156
+ disabled,
157
+ variant
158
+ },
159
+ children: /*#__PURE__*/ jsx("div", {
160
+ ref: ref,
161
+ ...props,
162
+ ...api.getItemProps({
163
+ value
164
+ }),
165
+ className: styles.item({
166
+ className
167
+ }),
168
+ children: children
169
+ })
170
+ });
171
+ };
172
+ Accordion.Header = function({ children, ref, className, ...props }) {
173
+ const { api, styles } = useAccordionContext();
174
+ const { value, disabled } = useAccordionItemContext();
175
+ return /*#__PURE__*/ jsx("header", {
176
+ ref: ref,
177
+ className: className,
178
+ ...props,
179
+ children: /*#__PURE__*/ jsx(Button, {
180
+ type: "button",
181
+ theme: "borderless",
182
+ className: styles.titleTrigger(),
183
+ ...api.getItemTriggerProps({
184
+ value,
185
+ disabled
186
+ }),
187
+ "data-disabled": disabled,
188
+ children: children
189
+ })
190
+ });
191
+ };
192
+ Accordion.Content = function({ children, ref, className, ...props }) {
193
+ const { api, styles } = useAccordionContext();
194
+ const { value } = useAccordionItemContext();
195
+ return /*#__PURE__*/ jsx("div", {
196
+ ref: ref,
197
+ className: styles.content({
198
+ className
199
+ }),
200
+ ...props,
201
+ ...api.getItemContentProps({
202
+ value
203
+ }),
204
+ "data-state": api.value.includes(value) ? 'expanded' : 'collapsed',
205
+ children: children
206
+ });
207
+ };
208
+ Accordion.Indicator = function({ icon = 'token-icon-accordion-chevron', ref, className, ...props }) {
209
+ const { api, styles } = useAccordionContext();
210
+ const { value } = useAccordionItemContext();
211
+ const isExpanded = api.value.includes(value);
212
+ return /*#__PURE__*/ jsx("span", {
213
+ ref: ref,
214
+ className: className,
215
+ ...props,
216
+ children: /*#__PURE__*/ jsx(Icon, {
217
+ className: styles.icon(),
218
+ icon: icon,
219
+ "data-state": isExpanded ? 'expanded' : 'collapsed'
220
+ })
221
+ });
222
+ };
223
+ Accordion.Title = function({ children, ref, className, ...props }) {
224
+ const { styles } = useAccordionContext();
225
+ return /*#__PURE__*/ jsx("span", {
226
+ className: styles.title({
227
+ className
228
+ }),
229
+ ref: ref,
230
+ ...props,
231
+ children: children
232
+ });
233
+ };
234
+ Accordion.Subtitle = function({ children, ref, className, ...props }) {
235
+ const { styles } = useAccordionContext();
236
+ return /*#__PURE__*/ jsx("span", {
237
+ ref: ref,
238
+ className: styles.subtitle({
239
+ className
240
+ }),
241
+ ...props,
242
+ children: children
243
+ });
244
+ };
245
+ export { Accordion };
@@ -0,0 +1,168 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { tv } from "tailwind-variants";
3
+ import { Icon } from "../atoms/icon.js";
4
+ import { Link } from "../atoms/link.js";
5
+ const breadcrumbsVariants = tv({
6
+ slots: {
7
+ root: [
8
+ 'inline-flex flex-wrap items-center',
9
+ 'bg-breadcrumb-bg'
10
+ ],
11
+ list: [
12
+ 'flex items-center',
13
+ 'break-words',
14
+ 'list-none'
15
+ ],
16
+ item: [
17
+ 'inline-flex items-center',
18
+ 'text-breadcrumb-item-fg',
19
+ 'hover:text-breadcrumb-fg-hover',
20
+ 'data-[current=true]:text-breadcrumb-fg-current',
21
+ 'h-full'
22
+ ],
23
+ link: [
24
+ 'no-underline',
25
+ 'cursor-pointer',
26
+ 'hover:text-breadcrumb-fg-hover',
27
+ 'focus:outline-none',
28
+ 'focus-visible:ring',
29
+ 'focus-visible:ring-breadcrumb-ring'
30
+ ],
31
+ currentLink: [
32
+ 'cursor-default'
33
+ ],
34
+ separator: [
35
+ 'text-breadcrumb-separator-fg',
36
+ 'inline-flex items-center justify-center',
37
+ 'rtl:rotate-180'
38
+ ],
39
+ ellipsis: [
40
+ 'text-breadcrumb-ellipsis-fg',
41
+ 'inline-flex items-center justify-center'
42
+ ]
43
+ },
44
+ compoundSlots: [
45
+ {
46
+ slots: [
47
+ 'link',
48
+ 'currentLink'
49
+ ],
50
+ class: [
51
+ 'font-medium inline-flex items-center',
52
+ 'outline-none focus:outline-none'
53
+ ]
54
+ }
55
+ ],
56
+ variants: {
57
+ size: {
58
+ sm: {
59
+ root: 'text-breadcrumb-sm p-breadcrumb-sm',
60
+ list: 'gap-breadcrumb-sm',
61
+ item: 'gap-breadcrumb-sm',
62
+ separator: 'gap-breadcrumb-sm',
63
+ ellipsis: 'text-breadcrumb-sm'
64
+ },
65
+ md: {
66
+ root: 'text-breadcrumb-md p-breadcrumb-md',
67
+ list: 'gap-breadcrumb-md',
68
+ item: 'gap-breadcrumb-md',
69
+ separator: 'gap-breadcrumb-md',
70
+ ellipsis: 'text-breadcrumb-md'
71
+ },
72
+ lg: {
73
+ root: 'text-breadcrumb-lg p-breadcrumb-lg',
74
+ list: 'gap-breadcrumb-lg',
75
+ item: 'gap-breadcrumb-lg',
76
+ separator: 'gap-breadcrumb-lg',
77
+ ellipsis: 'text-breadcrumb-lg'
78
+ }
79
+ }
80
+ },
81
+ defaultVariants: {
82
+ size: 'md'
83
+ }
84
+ });
85
+ function BreadcrumbItem({ label, href, icon, separator = 'token-icon-breadcrumb-separator', isCurrentPage, lastItem, linkAs }) {
86
+ const { item, currentLink, link, separator: separatorSlot } = breadcrumbsVariants({
87
+ size: 'md'
88
+ });
89
+ return /*#__PURE__*/ jsxs("li", {
90
+ className: item(),
91
+ "data-current": isCurrentPage,
92
+ children: [
93
+ icon && /*#__PURE__*/ jsx(Icon, {
94
+ icon: icon
95
+ }),
96
+ isCurrentPage ? /*#__PURE__*/ jsx("span", {
97
+ className: currentLink(),
98
+ "aria-current": "page",
99
+ children: label
100
+ }) : /*#__PURE__*/ jsx(Link, {
101
+ as: linkAs,
102
+ href: href || '#',
103
+ className: link(),
104
+ children: label
105
+ }),
106
+ !lastItem && /*#__PURE__*/ jsx("span", {
107
+ className: separatorSlot(),
108
+ children: /*#__PURE__*/ jsx(Icon, {
109
+ icon: separator ?? 'token-icon-breadcrumb-separator'
110
+ })
111
+ })
112
+ ]
113
+ });
114
+ }
115
+ function BreadcrumbEllipsis() {
116
+ const { ellipsis, separator: separatorSlot } = breadcrumbsVariants({
117
+ size: 'md'
118
+ });
119
+ return /*#__PURE__*/ jsxs("li", {
120
+ className: ellipsis(),
121
+ children: [
122
+ /*#__PURE__*/ jsx("span", {
123
+ "aria-hidden": "true",
124
+ children: /*#__PURE__*/ jsx(Icon, {
125
+ icon: "token-icon-breadcrumb-ellipsis"
126
+ })
127
+ }),
128
+ /*#__PURE__*/ jsx("span", {
129
+ className: separatorSlot(),
130
+ children: /*#__PURE__*/ jsx(Icon, {
131
+ icon: 'token-icon-breadcrumb-separator'
132
+ })
133
+ })
134
+ ]
135
+ });
136
+ }
137
+ function Breadcrumb({ items, maxItems = 0, size = 'md', className, 'aria-label': ariaLabel = 'breadcrumb', linkAs, ...props }) {
138
+ const { root, list } = breadcrumbsVariants({
139
+ size
140
+ });
141
+ const displayItems = maxItems <= 0 || items.length <= maxItems ? items : 1 === maxItems ? [
142
+ items.at(-1)
143
+ ] : [
144
+ items[0],
145
+ 'ellipsis',
146
+ ...items.slice(-(maxItems - 1))
147
+ ];
148
+ return /*#__PURE__*/ jsx("nav", {
149
+ className: root({
150
+ className
151
+ }),
152
+ "aria-label": ariaLabel,
153
+ ...props,
154
+ children: /*#__PURE__*/ jsx("ol", {
155
+ className: list(),
156
+ children: displayItems.map((item, index)=>'ellipsis' === item ? /*#__PURE__*/ jsx(BreadcrumbEllipsis, {}, "ellipsis") : item && 'string' != typeof item && /*#__PURE__*/ jsx(BreadcrumbItem, {
157
+ label: item.label,
158
+ href: item.href,
159
+ icon: item.icon,
160
+ separator: item.separator,
161
+ lastItem: index === displayItems.length - 1,
162
+ linkAs: linkAs,
163
+ isCurrentPage: item.isCurrent || index === displayItems.length - 1
164
+ }, `${item.label}`))
165
+ })
166
+ });
167
+ }
168
+ export { Breadcrumb };