@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.
- package/README.md +165 -0
- package/dist/atoms/badge.js +66 -0
- package/dist/atoms/button.js +275 -0
- package/dist/atoms/error-text.js +38 -0
- package/dist/atoms/extra-text.js +27 -0
- package/dist/atoms/icon.js +42 -0
- package/dist/atoms/image.js +11 -0
- package/dist/atoms/input.js +83 -0
- package/dist/atoms/label.js +43 -0
- package/dist/atoms/link-button.js +51 -0
- package/dist/atoms/link.js +23 -0
- package/dist/atoms/numeric-input.js +221 -0
- package/dist/atoms/rating.js +117 -0
- package/dist/atoms/textarea.js +81 -0
- package/dist/atoms/tooltip.js +119 -0
- package/dist/molecules/accordion.js +245 -0
- package/dist/molecules/breadcrumb.js +168 -0
- package/dist/molecules/carousel.js +333 -0
- package/dist/molecules/checkbox.js +92 -0
- package/dist/molecules/color-select.js +159 -0
- package/dist/molecules/combobox.js +253 -0
- package/dist/molecules/dialog.js +313 -0
- package/dist/molecules/form-checkbox.js +59 -0
- package/dist/molecules/form-input.js +55 -0
- package/dist/molecules/form-numeric-input.js +47 -0
- package/dist/molecules/form-textarea.js +54 -0
- package/dist/molecules/menu.js +302 -0
- package/dist/molecules/pagination.js +184 -0
- package/dist/molecules/popover.js +152 -0
- package/dist/molecules/product-card.js +194 -0
- package/dist/molecules/search-form.js +106 -0
- package/dist/molecules/select.js +217 -0
- package/dist/molecules/slider.js +249 -0
- package/dist/molecules/steps.js +178 -0
- package/dist/molecules/switch.js +109 -0
- package/dist/molecules/tabs.js +211 -0
- package/dist/molecules/toast.js +126 -0
- package/dist/molecules/tree-view.js +451 -0
- package/dist/organisms/footer.js +209 -0
- package/dist/organisms/header.js +245 -0
- package/dist/organisms/table.js +233 -0
- package/dist/src/atoms/badge.d.ts +59 -0
- package/dist/src/atoms/badge.d.ts.map +1 -0
- package/dist/src/atoms/button.d.ts +97 -0
- package/dist/src/atoms/button.d.ts.map +1 -0
- package/dist/src/atoms/error-text.d.ts +29 -0
- package/dist/src/atoms/error-text.d.ts.map +1 -0
- package/dist/src/atoms/extra-text.d.ts +27 -0
- package/dist/src/atoms/extra-text.d.ts.map +1 -0
- package/dist/src/atoms/icon.d.ts +65 -0
- package/dist/src/atoms/icon.d.ts.map +1 -0
- package/dist/src/atoms/image.d.ts +17 -0
- package/dist/src/atoms/image.d.ts.map +1 -0
- package/dist/src/atoms/input.d.ts +78 -0
- package/dist/src/atoms/input.d.ts.map +1 -0
- package/dist/src/atoms/label.d.ts +41 -0
- package/dist/src/atoms/label.d.ts.map +1 -0
- package/dist/src/atoms/link-button.d.ts +129 -0
- package/dist/src/atoms/link-button.d.ts.map +1 -0
- package/dist/src/atoms/link.d.ts +17 -0
- package/dist/src/atoms/link.d.ts.map +1 -0
- package/dist/src/atoms/numeric-input.d.ts +64 -0
- package/dist/src/atoms/numeric-input.d.ts.map +1 -0
- package/dist/src/atoms/rating.d.ts +108 -0
- package/dist/src/atoms/rating.d.ts.map +1 -0
- package/dist/src/atoms/textarea.d.ts +81 -0
- package/dist/src/atoms/textarea.d.ts.map +1 -0
- package/dist/src/atoms/tooltip.d.ts +88 -0
- package/dist/src/atoms/tooltip.d.ts.map +1 -0
- package/dist/src/molecules/accordion.d.ts +182 -0
- package/dist/src/molecules/accordion.d.ts.map +1 -0
- package/dist/src/molecules/breadcrumb.d.ts +117 -0
- package/dist/src/molecules/breadcrumb.d.ts.map +1 -0
- package/dist/src/molecules/carousel.d.ts +261 -0
- package/dist/src/molecules/carousel.d.ts.map +1 -0
- package/dist/src/molecules/checkbox.d.ts +19 -0
- package/dist/src/molecules/checkbox.d.ts.map +1 -0
- package/dist/src/molecules/color-select.d.ts +20 -0
- package/dist/src/molecules/color-select.d.ts.map +1 -0
- package/dist/src/molecules/combobox.d.ts +141 -0
- package/dist/src/molecules/combobox.d.ts.map +1 -0
- package/dist/src/molecules/dialog.d.ts +234 -0
- package/dist/src/molecules/dialog.d.ts.map +1 -0
- package/dist/src/molecules/form-checkbox.d.ts +15 -0
- package/dist/src/molecules/form-checkbox.d.ts.map +1 -0
- package/dist/src/molecules/form-input.d.ts +14 -0
- package/dist/src/molecules/form-input.d.ts.map +1 -0
- package/dist/src/molecules/form-numeric-input.d.ts +14 -0
- package/dist/src/molecules/form-numeric-input.d.ts.map +1 -0
- package/dist/src/molecules/form-textarea.d.ts +14 -0
- package/dist/src/molecules/form-textarea.d.ts.map +1 -0
- package/dist/src/molecules/menu.d.ts +153 -0
- package/dist/src/molecules/menu.d.ts.map +1 -0
- package/dist/src/molecules/pagination.d.ts +123 -0
- package/dist/src/molecules/pagination.d.ts.map +1 -0
- package/dist/src/molecules/popover.d.ts +124 -0
- package/dist/src/molecules/popover.d.ts.map +1 -0
- package/dist/src/molecules/product-card.d.ts +160 -0
- package/dist/src/molecules/product-card.d.ts.map +1 -0
- package/dist/src/molecules/search-form.d.ts +39 -0
- package/dist/src/molecules/search-form.d.ts.map +1 -0
- package/dist/src/molecules/select.d.ts +126 -0
- package/dist/src/molecules/select.d.ts.map +1 -0
- package/dist/src/molecules/slider.d.ts +120 -0
- package/dist/src/molecules/slider.d.ts.map +1 -0
- package/dist/src/molecules/steps.d.ts +96 -0
- package/dist/src/molecules/steps.d.ts.map +1 -0
- package/dist/src/molecules/switch.d.ts +71 -0
- package/dist/src/molecules/switch.d.ts.map +1 -0
- package/dist/src/molecules/tabs.d.ts +207 -0
- package/dist/src/molecules/tabs.d.ts.map +1 -0
- package/dist/src/molecules/toast.d.ts +83 -0
- package/dist/src/molecules/toast.d.ts.map +1 -0
- package/dist/src/molecules/tree-view.d.ts +202 -0
- package/dist/src/molecules/tree-view.d.ts.map +1 -0
- package/dist/src/organisms/footer.d.ts +254 -0
- package/dist/src/organisms/footer.d.ts.map +1 -0
- package/dist/src/organisms/header.d.ts +186 -0
- package/dist/src/organisms/header.d.ts.map +1 -0
- package/dist/src/organisms/table.d.ts +250 -0
- package/dist/src/organisms/table.d.ts.map +1 -0
- package/dist/src/templates/accordion.d.ts +15 -0
- package/dist/src/templates/accordion.d.ts.map +1 -0
- package/dist/src/templates/carousel.d.ts +13 -0
- package/dist/src/templates/carousel.d.ts.map +1 -0
- package/dist/src/templates/numeric-input.d.ts +14 -0
- package/dist/src/templates/numeric-input.d.ts.map +1 -0
- package/dist/src/templates/product-card.d.ts +33 -0
- package/dist/src/templates/product-card.d.ts.map +1 -0
- package/dist/src/templates/tabs.d.ts +16 -0
- package/dist/src/templates/tabs.d.ts.map +1 -0
- package/dist/src/types/zag.d.ts +19 -0
- package/dist/src/types/zag.d.ts.map +1 -0
- package/dist/src/utils.d.ts +4 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/templates/accordion.js +37 -0
- package/dist/templates/carousel.js +55 -0
- package/dist/templates/numeric-input.js +49 -0
- package/dist/templates/product-card.js +92 -0
- package/dist/templates/tabs.js +34 -0
- package/dist/types/zag.js +0 -0
- package/dist/utils.js +20 -0
- package/package.json +126 -0
- package/src/tokens/_base.css +25 -0
- package/src/tokens/_colors.css +5 -0
- package/src/tokens/_layout.css +34 -0
- package/src/tokens/_semantic.css +360 -0
- package/src/tokens/_spacing.css +22 -0
- package/src/tokens/_typography.css +17 -0
- package/src/tokens/components/atoms/_badge.css +61 -0
- package/src/tokens/components/atoms/_button.css +215 -0
- package/src/tokens/components/atoms/_icon.css +122 -0
- package/src/tokens/components/atoms/_input.css +125 -0
- package/src/tokens/components/atoms/_numeric-input.css +57 -0
- package/src/tokens/components/atoms/_rating.css +33 -0
- package/src/tokens/components/atoms/_textarea.css +93 -0
- package/src/tokens/components/atoms/_tooltip.css +21 -0
- package/src/tokens/components/components.css +32 -0
- package/src/tokens/components/molecules/_accordion.css +85 -0
- package/src/tokens/components/molecules/_breadcrumb.css +44 -0
- package/src/tokens/components/molecules/_carousel.css +72 -0
- package/src/tokens/components/molecules/_checkbox.css +29 -0
- package/src/tokens/components/molecules/_color-select.css +61 -0
- package/src/tokens/components/molecules/_combobox.css +116 -0
- package/src/tokens/components/molecules/_dialog.css +75 -0
- package/src/tokens/components/molecules/_menu.css +48 -0
- package/src/tokens/components/molecules/_pagination.css +75 -0
- package/src/tokens/components/molecules/_popover.css +39 -0
- package/src/tokens/components/molecules/_product-card.css +85 -0
- package/src/tokens/components/molecules/_search-form.css +10 -0
- package/src/tokens/components/molecules/_select.css +88 -0
- package/src/tokens/components/molecules/_slider.css +75 -0
- package/src/tokens/components/molecules/_steps.css +54 -0
- package/src/tokens/components/molecules/_switch.css +62 -0
- package/src/tokens/components/molecules/_tabs.css +69 -0
- package/src/tokens/components/molecules/_toast.css +77 -0
- package/src/tokens/components/molecules/_tree-view.css +80 -0
- package/src/tokens/components/molecules/index.css +2 -0
- package/src/tokens/components/organisms/_footer.css +90 -0
- package/src/tokens/components/organisms/_header.css +86 -0
- package/src/tokens/components/organisms/_table.css +63 -0
- package/src/tokens/index.css +67 -0
- package/src/tokens/tokens-only.css +66 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { connect, machine } from "@zag-js/popover";
|
|
3
|
+
import { Portal, normalizeProps, useMachine } from "@zag-js/react";
|
|
4
|
+
import { useId } from "react";
|
|
5
|
+
import { Button } from "../atoms/button.js";
|
|
6
|
+
import { tv } from "../utils.js";
|
|
7
|
+
const popoverVariants = tv({
|
|
8
|
+
slots: {
|
|
9
|
+
trigger: [
|
|
10
|
+
'p-popover-trigger',
|
|
11
|
+
'disabled:pointer-events-none',
|
|
12
|
+
'disabled:opacity-disabled'
|
|
13
|
+
],
|
|
14
|
+
positioner: [
|
|
15
|
+
'absolute'
|
|
16
|
+
],
|
|
17
|
+
content: [
|
|
18
|
+
'bg-popover-bg',
|
|
19
|
+
'text-popover-fg',
|
|
20
|
+
'rounded-popover',
|
|
21
|
+
'outline-none',
|
|
22
|
+
'z-50'
|
|
23
|
+
],
|
|
24
|
+
arrow: '',
|
|
25
|
+
title: [
|
|
26
|
+
'font-popover-title',
|
|
27
|
+
'leading-none',
|
|
28
|
+
'mb-popover-title-mb'
|
|
29
|
+
],
|
|
30
|
+
description: [
|
|
31
|
+
"text-popover-description-fg text-popover-description-size",
|
|
32
|
+
'leading-normal'
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
variants: {
|
|
36
|
+
shadow: {
|
|
37
|
+
true: {
|
|
38
|
+
content: 'shadow-popover'
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
border: {
|
|
42
|
+
true: {
|
|
43
|
+
content: 'border border-popover-border',
|
|
44
|
+
arrow: 'border-popover-border border-t border-l'
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
size: {
|
|
48
|
+
sm: {
|
|
49
|
+
content: 'p-popover-sm text-sm',
|
|
50
|
+
title: 'text-popover-title-sm'
|
|
51
|
+
},
|
|
52
|
+
md: {
|
|
53
|
+
content: 'p-popover-md',
|
|
54
|
+
title: 'text-popover-title-md'
|
|
55
|
+
},
|
|
56
|
+
lg: {
|
|
57
|
+
content: 'p-popover-lg text-lg',
|
|
58
|
+
title: 'text-popover-title-lg'
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
defaultVariants: {
|
|
63
|
+
size: 'md',
|
|
64
|
+
shadow: true
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
function Popover({ trigger, children, open, defaultOpen, onOpenChange, placement = 'bottom', offset = {
|
|
68
|
+
mainAxis: 8,
|
|
69
|
+
crossAxis: 0
|
|
70
|
+
}, gutter = 8, sameWidth = false, slide = true, flip = true, overflowPadding = 8, modal = false, closeOnInteractOutside = true, closeOnEscape = true, showArrow = true, autoFocus = true, portalled = true, title, description, id, triggerRef, contentRef, triggerClassName, contentClassName, size = 'md', shadow = true, border = true, onPointerDownOutside }) {
|
|
71
|
+
const generatedId = useId();
|
|
72
|
+
const uniqueId = id || generatedId;
|
|
73
|
+
const service = useMachine(machine, {
|
|
74
|
+
id: uniqueId,
|
|
75
|
+
open,
|
|
76
|
+
defaultOpen,
|
|
77
|
+
dir: 'ltr',
|
|
78
|
+
positioning: {
|
|
79
|
+
placement,
|
|
80
|
+
offset,
|
|
81
|
+
gutter,
|
|
82
|
+
sameWidth,
|
|
83
|
+
slide,
|
|
84
|
+
flip,
|
|
85
|
+
overflowPadding
|
|
86
|
+
},
|
|
87
|
+
modal,
|
|
88
|
+
closeOnInteractOutside,
|
|
89
|
+
closeOnEscape,
|
|
90
|
+
autoFocus,
|
|
91
|
+
portalled,
|
|
92
|
+
onOpenChange,
|
|
93
|
+
onPointerDownOutside
|
|
94
|
+
});
|
|
95
|
+
const api = connect(service, normalizeProps);
|
|
96
|
+
const { trigger: triggerStyles, positioner, content: contentStyles, arrow, title: titleStyles, description: descriptionStyles } = popoverVariants({
|
|
97
|
+
size,
|
|
98
|
+
shadow,
|
|
99
|
+
border
|
|
100
|
+
});
|
|
101
|
+
const renderContent = ()=>/*#__PURE__*/ jsx("div", {
|
|
102
|
+
...api.getPositionerProps(),
|
|
103
|
+
className: positioner(),
|
|
104
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
105
|
+
...api.getContentProps(),
|
|
106
|
+
ref: contentRef,
|
|
107
|
+
className: contentStyles({
|
|
108
|
+
className: contentClassName
|
|
109
|
+
}),
|
|
110
|
+
"data-side": placement.split('-')[0],
|
|
111
|
+
"data-state": api.open ? 'open' : 'closed',
|
|
112
|
+
children: [
|
|
113
|
+
showArrow && /*#__PURE__*/ jsx("div", {
|
|
114
|
+
...api.getArrowProps(),
|
|
115
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
116
|
+
...api.getArrowTipProps(),
|
|
117
|
+
className: arrow()
|
|
118
|
+
})
|
|
119
|
+
}),
|
|
120
|
+
title && /*#__PURE__*/ jsx("div", {
|
|
121
|
+
...api.getTitleProps(),
|
|
122
|
+
className: titleStyles(),
|
|
123
|
+
children: title
|
|
124
|
+
}),
|
|
125
|
+
description && /*#__PURE__*/ jsx("div", {
|
|
126
|
+
...api.getDescriptionProps(),
|
|
127
|
+
className: descriptionStyles(),
|
|
128
|
+
children: description
|
|
129
|
+
}),
|
|
130
|
+
children
|
|
131
|
+
]
|
|
132
|
+
})
|
|
133
|
+
});
|
|
134
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
135
|
+
children: [
|
|
136
|
+
/*#__PURE__*/ jsx(Button, {
|
|
137
|
+
theme: "borderless",
|
|
138
|
+
...api.getTriggerProps(),
|
|
139
|
+
ref: triggerRef,
|
|
140
|
+
className: triggerStyles({
|
|
141
|
+
className: triggerClassName
|
|
142
|
+
}),
|
|
143
|
+
"data-state": api.open ? 'open' : 'closed',
|
|
144
|
+
children: trigger
|
|
145
|
+
}),
|
|
146
|
+
portalled ? /*#__PURE__*/ jsx(Portal, {
|
|
147
|
+
children: api.open && renderContent()
|
|
148
|
+
}) : api.open && renderContent()
|
|
149
|
+
]
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
export { Popover };
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
import { Button } from "../atoms/button.js";
|
|
4
|
+
import { Image } from "../atoms/image.js";
|
|
5
|
+
import { Rating } from "../atoms/rating.js";
|
|
6
|
+
import { tv } from "../utils.js";
|
|
7
|
+
const productCardVariants = tv({
|
|
8
|
+
slots: {
|
|
9
|
+
root: [
|
|
10
|
+
'rounded-product-card p-product-card-padding',
|
|
11
|
+
'border-(length:--border-product-card-width) border-product-card-border bg-product-card-bg max-w-product-card-max shadow-sm'
|
|
12
|
+
],
|
|
13
|
+
imageSlot: 'object-cover h-full rounded-product-card-image',
|
|
14
|
+
nameSlot: 'text-product-card-name-fg font-product-card-name text-product-card-name-size line-clamp-product-card-name',
|
|
15
|
+
priceSlot: 'text-product-card-price-fg font-product-card-price text-product-card-price-size',
|
|
16
|
+
stockStatusSlot: [
|
|
17
|
+
'text-product-card-stock-size font-product-card-stock',
|
|
18
|
+
'data-[stock=in-stock]:text-product-card-stock-fg-in-stock',
|
|
19
|
+
'data-[stock=limited-stock]:text-product-card-stock-fg-limited-stock',
|
|
20
|
+
'data-[stock=out-of-stock]:text-product-card-stock-fg-out-of-stock'
|
|
21
|
+
],
|
|
22
|
+
badgesSlot: 'flex flex-wrap gap-product-card-box',
|
|
23
|
+
ratingSlot: 'flex items-center',
|
|
24
|
+
actionsSlot: 'flex flex-wrap gap-product-card-buttons',
|
|
25
|
+
button: ''
|
|
26
|
+
},
|
|
27
|
+
variants: {
|
|
28
|
+
buttonVariant: {
|
|
29
|
+
cart: {
|
|
30
|
+
button: 'bg-product-card-button-cart-bg hover:bg-product-card-button-cart-bg-hover text-product-card-button-cart-fg w-max'
|
|
31
|
+
},
|
|
32
|
+
detail: {
|
|
33
|
+
button: 'bg-product-card-button-detail-bg hover:bg-product-card-button-detail-bg-hover text-product-card-button-detail-fg w-max'
|
|
34
|
+
},
|
|
35
|
+
wishlist: {
|
|
36
|
+
button: 'bg-product-card-button-wishlist-bg hover:bg-product-card-button-wishlist-bg-hover text-product-card-button-wishlist-fg w-max'
|
|
37
|
+
},
|
|
38
|
+
custom: {}
|
|
39
|
+
},
|
|
40
|
+
layout: {
|
|
41
|
+
column: {
|
|
42
|
+
root: [
|
|
43
|
+
'grid grid-cols-(--product-card-layout-column-grid) gap-product-card-col-layout'
|
|
44
|
+
],
|
|
45
|
+
imageSlot: 'aspect-product-card-image'
|
|
46
|
+
},
|
|
47
|
+
row: {
|
|
48
|
+
root: 'grid grid-cols-(--product-card-layout-row-grid) gap-x-product-card-row-layout',
|
|
49
|
+
imageSlot: 'row-span-6 aspect-auto'
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
defaultVariants: {
|
|
54
|
+
layout: 'column',
|
|
55
|
+
buttonVariant: 'cart'
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
const ProductCardContext = /*#__PURE__*/ createContext({});
|
|
59
|
+
function ProductCard({ children, layout = 'column', className, ref, ...props }) {
|
|
60
|
+
const { root } = productCardVariants({
|
|
61
|
+
layout
|
|
62
|
+
});
|
|
63
|
+
return /*#__PURE__*/ jsx(ProductCardContext.Provider, {
|
|
64
|
+
value: {
|
|
65
|
+
layout
|
|
66
|
+
},
|
|
67
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
68
|
+
ref: ref,
|
|
69
|
+
className: root({
|
|
70
|
+
className
|
|
71
|
+
}),
|
|
72
|
+
...props,
|
|
73
|
+
children: children
|
|
74
|
+
})
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
ProductCard.Image = function({ as, className, ref, ...props }) {
|
|
78
|
+
const context = useContext(ProductCardContext);
|
|
79
|
+
const { imageSlot } = productCardVariants({
|
|
80
|
+
layout: context.layout
|
|
81
|
+
});
|
|
82
|
+
const ImageComponent = as || Image;
|
|
83
|
+
return /*#__PURE__*/ jsx(ImageComponent, {
|
|
84
|
+
ref: ref,
|
|
85
|
+
className: imageSlot({
|
|
86
|
+
className
|
|
87
|
+
}),
|
|
88
|
+
...props
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
ProductCard.Name = function({ children, className, ref, ...props }) {
|
|
92
|
+
const context = useContext(ProductCardContext);
|
|
93
|
+
const { nameSlot } = productCardVariants({
|
|
94
|
+
layout: context.layout
|
|
95
|
+
});
|
|
96
|
+
return /*#__PURE__*/ jsx("h3", {
|
|
97
|
+
ref: ref,
|
|
98
|
+
className: nameSlot({
|
|
99
|
+
className
|
|
100
|
+
}),
|
|
101
|
+
...props,
|
|
102
|
+
children: children
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
ProductCard.Price = function({ children, className, ref, ...props }) {
|
|
106
|
+
const context = useContext(ProductCardContext);
|
|
107
|
+
const { priceSlot } = productCardVariants({
|
|
108
|
+
layout: context.layout
|
|
109
|
+
});
|
|
110
|
+
return /*#__PURE__*/ jsx("p", {
|
|
111
|
+
ref: ref,
|
|
112
|
+
className: priceSlot({
|
|
113
|
+
className
|
|
114
|
+
}),
|
|
115
|
+
...props,
|
|
116
|
+
children: children
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
ProductCard.Stock = function({ children, className, ref, status = 'in-stock', ...props }) {
|
|
120
|
+
const context = useContext(ProductCardContext);
|
|
121
|
+
const { stockStatusSlot } = productCardVariants({
|
|
122
|
+
layout: context.layout
|
|
123
|
+
});
|
|
124
|
+
return /*#__PURE__*/ jsx("p", {
|
|
125
|
+
ref: ref,
|
|
126
|
+
"data-stock": status,
|
|
127
|
+
className: stockStatusSlot({
|
|
128
|
+
className
|
|
129
|
+
}),
|
|
130
|
+
...props,
|
|
131
|
+
children: children
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
ProductCard.Badges = function({ children, className, ref, ...props }) {
|
|
135
|
+
const context = useContext(ProductCardContext);
|
|
136
|
+
const { badgesSlot } = productCardVariants({
|
|
137
|
+
layout: context.layout
|
|
138
|
+
});
|
|
139
|
+
return /*#__PURE__*/ jsx("div", {
|
|
140
|
+
ref: ref,
|
|
141
|
+
className: badgesSlot({
|
|
142
|
+
className
|
|
143
|
+
}),
|
|
144
|
+
...props,
|
|
145
|
+
children: children
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
ProductCard.Rating = function({ children, className, rating, ref, ...props }) {
|
|
149
|
+
const context = useContext(ProductCardContext);
|
|
150
|
+
const { ratingSlot } = productCardVariants({
|
|
151
|
+
layout: context.layout
|
|
152
|
+
});
|
|
153
|
+
return /*#__PURE__*/ jsx("div", {
|
|
154
|
+
ref: ref,
|
|
155
|
+
className: ratingSlot({
|
|
156
|
+
className
|
|
157
|
+
}),
|
|
158
|
+
...props,
|
|
159
|
+
children: rating ? /*#__PURE__*/ jsx(Rating, {
|
|
160
|
+
...rating
|
|
161
|
+
}) : children
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
ProductCard.Actions = function({ children, className, ref, ...props }) {
|
|
165
|
+
const context = useContext(ProductCardContext);
|
|
166
|
+
const { actionsSlot } = productCardVariants({
|
|
167
|
+
layout: context.layout
|
|
168
|
+
});
|
|
169
|
+
return /*#__PURE__*/ jsx("div", {
|
|
170
|
+
ref: ref,
|
|
171
|
+
className: actionsSlot({
|
|
172
|
+
className
|
|
173
|
+
}),
|
|
174
|
+
...props,
|
|
175
|
+
children: children
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
ProductCard.Button = function({ children, onClick, icon, className, buttonVariant, ref, ...props }) {
|
|
179
|
+
const { button } = productCardVariants({
|
|
180
|
+
buttonVariant
|
|
181
|
+
});
|
|
182
|
+
return /*#__PURE__*/ jsx(Button, {
|
|
183
|
+
ref: ref,
|
|
184
|
+
size: "sm",
|
|
185
|
+
className: button({
|
|
186
|
+
className
|
|
187
|
+
}),
|
|
188
|
+
onClick: onClick,
|
|
189
|
+
icon: icon,
|
|
190
|
+
...props,
|
|
191
|
+
children: children
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
export { ProductCard };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from "react";
|
|
3
|
+
import { Button } from "../atoms/button.js";
|
|
4
|
+
import { Icon } from "../atoms/icon.js";
|
|
5
|
+
import { Input } from "../atoms/input.js";
|
|
6
|
+
import { Label } from "../atoms/label.js";
|
|
7
|
+
import { tv } from "../utils.js";
|
|
8
|
+
const iconSizeMap = {
|
|
9
|
+
sm: 'lg',
|
|
10
|
+
md: 'xl',
|
|
11
|
+
lg: '2xl'
|
|
12
|
+
};
|
|
13
|
+
const formVariants = tv({
|
|
14
|
+
base: [
|
|
15
|
+
'grid relative'
|
|
16
|
+
],
|
|
17
|
+
variants: {
|
|
18
|
+
size: {
|
|
19
|
+
sm: 'gap-search-form-sm',
|
|
20
|
+
md: 'gap-search-form-md',
|
|
21
|
+
lg: 'gap-search-form-lg'
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
defaultVariants: {
|
|
25
|
+
size: 'md'
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const inputWrapperVariants = tv({
|
|
29
|
+
base: [
|
|
30
|
+
'grid relative overflow-hidden rounded-md'
|
|
31
|
+
],
|
|
32
|
+
variants: {
|
|
33
|
+
size: {
|
|
34
|
+
sm: 'gap-search-form-sm',
|
|
35
|
+
md: 'gap-search-form-md',
|
|
36
|
+
lg: 'gap-search-form-lg'
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
const buttonVariants = tv({
|
|
41
|
+
base: [
|
|
42
|
+
'absolute',
|
|
43
|
+
'justify-self-end place-self-center',
|
|
44
|
+
'h-full rounded-none p-200'
|
|
45
|
+
]
|
|
46
|
+
});
|
|
47
|
+
function SearchForm({ inputProps, buttonProps, size = 'md', buttonText, buttonIcon = false, placeholder = 'Search...', label, className, ref, searchId, ...props }) {
|
|
48
|
+
const fallbackId = useId();
|
|
49
|
+
const id = searchId || `search-${fallbackId}`;
|
|
50
|
+
const withButton = !!buttonText || buttonIcon;
|
|
51
|
+
const iconSize = iconSizeMap[size] || 'lg';
|
|
52
|
+
return /*#__PURE__*/ jsx("search", {
|
|
53
|
+
children: /*#__PURE__*/ jsxs("form", {
|
|
54
|
+
ref: ref,
|
|
55
|
+
className: formVariants({
|
|
56
|
+
size,
|
|
57
|
+
className
|
|
58
|
+
}),
|
|
59
|
+
onSubmit: props.onSubmit,
|
|
60
|
+
...props,
|
|
61
|
+
children: [
|
|
62
|
+
label && /*#__PURE__*/ jsx(Label, {
|
|
63
|
+
htmlFor: id,
|
|
64
|
+
size: size,
|
|
65
|
+
children: label
|
|
66
|
+
}),
|
|
67
|
+
/*#__PURE__*/ jsxs("div", {
|
|
68
|
+
className: inputWrapperVariants({
|
|
69
|
+
size
|
|
70
|
+
}),
|
|
71
|
+
children: [
|
|
72
|
+
/*#__PURE__*/ jsx(Input, {
|
|
73
|
+
id: id,
|
|
74
|
+
type: "search",
|
|
75
|
+
withButtonInside: withButton && 'right',
|
|
76
|
+
placeholder: placeholder,
|
|
77
|
+
size: size,
|
|
78
|
+
"aria-label": label ? void 0 : 'Search',
|
|
79
|
+
...inputProps
|
|
80
|
+
}),
|
|
81
|
+
withButton && /*#__PURE__*/ jsxs(Button, {
|
|
82
|
+
type: "submit",
|
|
83
|
+
theme: buttonProps?.theme || 'borderless',
|
|
84
|
+
block: false,
|
|
85
|
+
size: size,
|
|
86
|
+
"aria-label": buttonText ? void 0 : 'Search',
|
|
87
|
+
className: buttonVariants({
|
|
88
|
+
className: buttonText ? '' : 'aspect-square'
|
|
89
|
+
}),
|
|
90
|
+
...buttonProps,
|
|
91
|
+
children: [
|
|
92
|
+
buttonText,
|
|
93
|
+
buttonIcon && /*#__PURE__*/ jsx(Icon, {
|
|
94
|
+
icon: 'token-icon-search',
|
|
95
|
+
size: iconSize
|
|
96
|
+
})
|
|
97
|
+
]
|
|
98
|
+
})
|
|
99
|
+
]
|
|
100
|
+
})
|
|
101
|
+
]
|
|
102
|
+
})
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
SearchForm.displayName = 'SearchForm';
|
|
106
|
+
export { SearchForm };
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Portal, normalizeProps, useMachine } from "@zag-js/react";
|
|
3
|
+
import { collection as select_collection, connect, machine } from "@zag-js/select";
|
|
4
|
+
import { useId } from "react";
|
|
5
|
+
import { tv } from "tailwind-variants";
|
|
6
|
+
import { Button } from "../atoms/button.js";
|
|
7
|
+
import { ErrorText } from "../atoms/error-text.js";
|
|
8
|
+
import { ExtraText } from "../atoms/extra-text.js";
|
|
9
|
+
import { Icon } from "../atoms/icon.js";
|
|
10
|
+
import { Label } from "../atoms/label.js";
|
|
11
|
+
const selectVariants = tv({
|
|
12
|
+
slots: {
|
|
13
|
+
root: [
|
|
14
|
+
'relative',
|
|
15
|
+
'flex flex-col gap-select-root',
|
|
16
|
+
'w-full'
|
|
17
|
+
],
|
|
18
|
+
control: [
|
|
19
|
+
'flex relative items-center justify-between',
|
|
20
|
+
'w-full'
|
|
21
|
+
],
|
|
22
|
+
positioner: [
|
|
23
|
+
'w-(--reference-width)',
|
|
24
|
+
'isolate z-(--z-index)'
|
|
25
|
+
],
|
|
26
|
+
trigger: [
|
|
27
|
+
'w-full',
|
|
28
|
+
'p-select-trigger',
|
|
29
|
+
'border border-select-trigger-border rounded-select',
|
|
30
|
+
'text-select-trigger-size text-left',
|
|
31
|
+
'hover:bg-select-trigger-bg-hover',
|
|
32
|
+
'focus:outline-none focus:border-select-trigger-border-focus',
|
|
33
|
+
'data-[disabled]:cursor-not-allowed',
|
|
34
|
+
'data-[invalid]:border-select-danger data-[invalid]:ring-select-danger'
|
|
35
|
+
],
|
|
36
|
+
clearTrigger: [
|
|
37
|
+
'absolute right-select-right h-full',
|
|
38
|
+
'p-select-clear-trigger',
|
|
39
|
+
'hover:bg-select-clear-trigger-bg',
|
|
40
|
+
'text-select-clear-trigger-fg hover:text-select-danger',
|
|
41
|
+
'focus:text-select-danger',
|
|
42
|
+
'focus:outline-none focus:ring-offset-transparent focus:ring-transparent'
|
|
43
|
+
],
|
|
44
|
+
content: [
|
|
45
|
+
'bg-select-content-bg border border-select-content-border',
|
|
46
|
+
'rounded-select shadow-select-content max-h-fit',
|
|
47
|
+
'h-[calc(var(--available-height)-var(--spacing-content))]',
|
|
48
|
+
'overflow-auto z-(--z-content)'
|
|
49
|
+
],
|
|
50
|
+
item: [
|
|
51
|
+
'flex items-center justify-between',
|
|
52
|
+
'bg-select-item-bg cursor-pointer',
|
|
53
|
+
'p-select-item',
|
|
54
|
+
'text-select-item-fg',
|
|
55
|
+
'hover:bg-select-item-bg-hover',
|
|
56
|
+
'data-[state=checked]:bg-select-item-bg-selected',
|
|
57
|
+
'data-[state=checked]:text-select-item-selected-fg',
|
|
58
|
+
'data-[disabled]:opacity-select-disabled data-[disabled]:cursor-not-allowed'
|
|
59
|
+
],
|
|
60
|
+
itemIndicator: [
|
|
61
|
+
'text-select-indicator'
|
|
62
|
+
],
|
|
63
|
+
value: [
|
|
64
|
+
'flex-grow truncate data-[placeholder]:text-select-placeholder'
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
variants: {
|
|
68
|
+
size: {
|
|
69
|
+
xs: {
|
|
70
|
+
trigger: 'text-select-xs',
|
|
71
|
+
item: 'text-select-xs',
|
|
72
|
+
value: 'text-select-xs'
|
|
73
|
+
},
|
|
74
|
+
sm: {
|
|
75
|
+
trigger: 'text-select-sm',
|
|
76
|
+
item: 'text-select-sm',
|
|
77
|
+
value: 'text-select-sm'
|
|
78
|
+
},
|
|
79
|
+
md: {
|
|
80
|
+
trigger: 'text-select-md',
|
|
81
|
+
item: 'text-select-md',
|
|
82
|
+
value: 'text-select-md'
|
|
83
|
+
},
|
|
84
|
+
lg: {
|
|
85
|
+
trigger: 'text-select-lg',
|
|
86
|
+
item: 'text-select-lg',
|
|
87
|
+
value: 'text-select-lg'
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
defaultVariants: {
|
|
92
|
+
size: 'md'
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
function Select({ options, label, placeholder = 'Select an option', size = 'md', value, defaultValue, multiple = false, clearIcon = true, disabled = false, invalid = false, required = false, readOnly = false, errorText, helperText, closeOnSelect = true, loopFocus = true, name, form, onValueChange, onOpenChange, onHighlightChange, onSelect, className, id: providedId }) {
|
|
96
|
+
const generatedId = useId();
|
|
97
|
+
const id = providedId || generatedId;
|
|
98
|
+
const collection = select_collection({
|
|
99
|
+
items: options,
|
|
100
|
+
itemToString: (item)=>item.displayValue || item.value,
|
|
101
|
+
itemToValue: (item)=>item.value,
|
|
102
|
+
isItemDisabled: (item)=>!!item.disabled
|
|
103
|
+
});
|
|
104
|
+
const service = useMachine(machine, {
|
|
105
|
+
id,
|
|
106
|
+
collection,
|
|
107
|
+
name,
|
|
108
|
+
form,
|
|
109
|
+
multiple,
|
|
110
|
+
disabled,
|
|
111
|
+
invalid,
|
|
112
|
+
required,
|
|
113
|
+
readOnly,
|
|
114
|
+
closeOnSelect,
|
|
115
|
+
loopFocus,
|
|
116
|
+
defaultValue,
|
|
117
|
+
value,
|
|
118
|
+
onValueChange,
|
|
119
|
+
onOpenChange,
|
|
120
|
+
onHighlightChange,
|
|
121
|
+
onSelect
|
|
122
|
+
});
|
|
123
|
+
const api = connect(service, normalizeProps);
|
|
124
|
+
const { root, control, trigger, clearTrigger, content, positioner, item, itemIndicator, value: valueSlot } = selectVariants({
|
|
125
|
+
size
|
|
126
|
+
});
|
|
127
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
128
|
+
children: [
|
|
129
|
+
/*#__PURE__*/ jsx("select", {
|
|
130
|
+
...api.getHiddenSelectProps(),
|
|
131
|
+
children: options.map((option)=>/*#__PURE__*/ jsx("option", {
|
|
132
|
+
value: option.value,
|
|
133
|
+
disabled: option.disabled,
|
|
134
|
+
children: option.displayValue || option.value
|
|
135
|
+
}, option.value))
|
|
136
|
+
}),
|
|
137
|
+
/*#__PURE__*/ jsxs("div", {
|
|
138
|
+
className: root({
|
|
139
|
+
className
|
|
140
|
+
}),
|
|
141
|
+
...api.getRootProps(),
|
|
142
|
+
children: [
|
|
143
|
+
label && /*#__PURE__*/ jsx(Label, {
|
|
144
|
+
...api.getLabelProps(),
|
|
145
|
+
children: label
|
|
146
|
+
}),
|
|
147
|
+
/*#__PURE__*/ jsxs("div", {
|
|
148
|
+
className: control(),
|
|
149
|
+
...api.getControlProps(),
|
|
150
|
+
children: [
|
|
151
|
+
/*#__PURE__*/ jsx(Button, {
|
|
152
|
+
theme: "borderless",
|
|
153
|
+
className: trigger(),
|
|
154
|
+
...api.getTriggerProps(),
|
|
155
|
+
icon: api.open ? 'token-icon-select-indicator-open' : 'token-icon-select-indicator',
|
|
156
|
+
iconPosition: "right",
|
|
157
|
+
children: /*#__PURE__*/ jsx("span", {
|
|
158
|
+
className: valueSlot(),
|
|
159
|
+
"data-placeholder": 0 === api.value.length,
|
|
160
|
+
children: api.value.length > 0 ? options.find((option)=>option.value === api.value[0])?.label : placeholder
|
|
161
|
+
})
|
|
162
|
+
}),
|
|
163
|
+
clearIcon && /*#__PURE__*/ jsx(Button, {
|
|
164
|
+
theme: "borderless",
|
|
165
|
+
...api.getClearTriggerProps(),
|
|
166
|
+
className: clearTrigger(),
|
|
167
|
+
"aria-label": "Clear selection",
|
|
168
|
+
icon: "token-icon-select-clear"
|
|
169
|
+
})
|
|
170
|
+
]
|
|
171
|
+
}),
|
|
172
|
+
/*#__PURE__*/ jsx(Portal, {
|
|
173
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
174
|
+
className: positioner(),
|
|
175
|
+
...api.getPositionerProps(),
|
|
176
|
+
children: /*#__PURE__*/ jsx("ul", {
|
|
177
|
+
className: content(),
|
|
178
|
+
...api.getContentProps(),
|
|
179
|
+
children: options.map((option)=>/*#__PURE__*/ jsxs("li", {
|
|
180
|
+
className: item(),
|
|
181
|
+
...api.getItemProps({
|
|
182
|
+
item: option
|
|
183
|
+
}),
|
|
184
|
+
children: [
|
|
185
|
+
/*#__PURE__*/ jsx("span", {
|
|
186
|
+
...api.getItemTextProps({
|
|
187
|
+
item: option
|
|
188
|
+
}),
|
|
189
|
+
children: option.label
|
|
190
|
+
}),
|
|
191
|
+
/*#__PURE__*/ jsx("span", {
|
|
192
|
+
className: itemIndicator(),
|
|
193
|
+
...api.getItemIndicatorProps({
|
|
194
|
+
item: option
|
|
195
|
+
}),
|
|
196
|
+
children: /*#__PURE__*/ jsx(Icon, {
|
|
197
|
+
icon: "token-icon-select-check"
|
|
198
|
+
})
|
|
199
|
+
})
|
|
200
|
+
]
|
|
201
|
+
}, option.value))
|
|
202
|
+
})
|
|
203
|
+
})
|
|
204
|
+
}),
|
|
205
|
+
invalid && /*#__PURE__*/ jsx(ErrorText, {
|
|
206
|
+
children: errorText
|
|
207
|
+
}),
|
|
208
|
+
!invalid && helperText && /*#__PURE__*/ jsx(ExtraText, {
|
|
209
|
+
children: helperText
|
|
210
|
+
})
|
|
211
|
+
]
|
|
212
|
+
})
|
|
213
|
+
]
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
Select.displayName = 'Select';
|
|
217
|
+
export { Select };
|