@tapcart/mobile-components 0.6.6 → 0.6.7
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/dist/components/ThemeProvider.d.ts +3 -0
- package/dist/components/ThemeProvider.d.ts.map +1 -0
- package/dist/components/ThemeProvider.js +18 -0
- package/dist/components/ThemeToggle.d.ts +2 -0
- package/dist/components/ThemeToggle.d.ts.map +1 -0
- package/dist/components/ThemeToggle.js +8 -0
- package/dist/components/hooks/use-sort-filter.d.ts +26 -0
- package/dist/components/hooks/use-sort-filter.d.ts.map +1 -0
- package/dist/components/hooks/use-sort-filter.js +31 -0
- package/dist/components/libs/sort-filter/beyond-search.d.ts +15 -0
- package/dist/components/libs/sort-filter/beyond-search.d.ts.map +1 -0
- package/dist/components/libs/sort-filter/beyond-search.js +78 -0
- package/dist/components/libs/sort-filter/kmp.d.ts +15 -0
- package/dist/components/libs/sort-filter/kmp.d.ts.map +1 -0
- package/dist/components/libs/sort-filter/kmp.js +55 -0
- package/dist/components/libs/sort-filter/nosto-search.d.ts +9 -0
- package/dist/components/libs/sort-filter/nosto-search.d.ts.map +1 -0
- package/dist/components/libs/sort-filter/nosto-search.js +8 -0
- package/dist/components/libs/sort-filter/search-integration.d.ts +50 -0
- package/dist/components/libs/sort-filter/search-integration.d.ts.map +1 -0
- package/dist/components/libs/sort-filter/search-integration.js +38 -0
- package/dist/components/libs/sort-filter/search-spring.d.ts +9 -0
- package/dist/components/libs/sort-filter/search-spring.d.ts.map +1 -0
- package/dist/components/libs/sort-filter/search-spring.js +8 -0
- package/dist/components/libs/sort-filter/shopify-search-and-discovery.d.ts +64 -0
- package/dist/components/libs/sort-filter/shopify-search-and-discovery.d.ts.map +1 -0
- package/dist/components/libs/sort-filter/shopify-search-and-discovery.js +172 -0
- package/dist/components/ui/empty-message.d.ts.map +1 -1
- package/dist/components/ui/empty-message.js +47 -1
- package/dist/components/ui/input.d.ts +17 -0
- package/dist/components/ui/input.d.ts.map +1 -0
- package/dist/components/ui/input.js +35 -0
- package/dist/components/ui/product-grid.d.ts +15 -0
- package/dist/components/ui/product-grid.d.ts.map +1 -0
- package/dist/components/ui/product-grid.js +22 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/styles.css +17 -0
- package/package.json +1 -1
- package/dist/components/hooks/use-click-outside.d.ts +0 -8
- package/dist/components/hooks/use-click-outside.d.ts.map +0 -1
- package/dist/components/hooks/use-click-outside.js +0 -46
- package/dist/components/hooks/use-pull-to-refresh.d.ts +0 -9
- package/dist/components/hooks/use-pull-to-refresh.d.ts.map +0 -1
- package/dist/components/hooks/use-pull-to-refresh.js +0 -88
- package/dist/components/ui/favorite/favorite.d.ts +0 -16
- package/dist/components/ui/favorite/favorite.d.ts.map +0 -1
- package/dist/components/ui/favorite/favorite.js +0 -156
- package/dist/components/ui/favorite/favorite.spec.d.ts +0 -2
- package/dist/components/ui/favorite/favorite.spec.d.ts.map +0 -1
- package/dist/components/ui/favorite/favorite.spec.js +0 -6
- package/dist/components/ui/favorite/index.d.ts +0 -2
- package/dist/components/ui/favorite/index.d.ts.map +0 -1
- package/dist/components/ui/favorite/index.js +0 -1
- package/dist/components/ui/select.d.ts +0 -39
- package/dist/components/ui/select.d.ts.map +0 -1
- package/dist/components/ui/select.js +0 -87
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import * as React from "react";
|
|
14
|
-
import { cva } from "class-variance-authority";
|
|
15
|
-
import { Icon } from "../icon";
|
|
16
|
-
const favoriteVariants = cva("flex p-2 gap-2 rounded-[4px] shadow-buttonColors-primaryShadow active:[&_svg]:text-stateColors-favorites", {
|
|
17
|
-
variants: {
|
|
18
|
-
size: {
|
|
19
|
-
small: "p-2",
|
|
20
|
-
large: "p-3",
|
|
21
|
-
},
|
|
22
|
-
showBackground: {
|
|
23
|
-
true: "bg-coreColors-inputBackground",
|
|
24
|
-
false: "",
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
defaultVariants: {
|
|
28
|
-
size: "small",
|
|
29
|
-
showBackground: true,
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
const AnimatedHeart = ({ selected, onClick, }) => (_jsxs("div", Object.assign({ onClick: onClick }, { children: [_jsx("style", { children: `* {
|
|
33
|
-
box-sizing: border-box;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
svg {
|
|
38
|
-
height: 24px;
|
|
39
|
-
overflow: visible;
|
|
40
|
-
cursor: pointer;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
label {
|
|
44
|
-
transform: translateX(-2px);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
input[type="checkbox"] {
|
|
48
|
-
display: none;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
input[type="checkbox"] + label {
|
|
52
|
-
width: 20px;
|
|
53
|
-
height: 20px;
|
|
54
|
-
position: relative;
|
|
55
|
-
display: grid;
|
|
56
|
-
place-content: center;
|
|
57
|
-
#center-heart {
|
|
58
|
-
#inner {
|
|
59
|
-
fill: ${selected ? "#d91e18ff" : "transparent"};
|
|
60
|
-
transition: 0.2s ease;
|
|
61
|
-
}
|
|
62
|
-
#outer {
|
|
63
|
-
fill: ${selected ? "#d91e18ff" : "white"};
|
|
64
|
-
transition: 0.2s ease;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
#left-hearts > *,
|
|
68
|
-
#right-hearts > * {
|
|
69
|
-
opacity: 0;
|
|
70
|
-
transition: 0.2s ease;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
input[type="checkbox"]:checked + label {
|
|
75
|
-
cursor: pointer;
|
|
76
|
-
&::before,
|
|
77
|
-
&::after {
|
|
78
|
-
content: "";
|
|
79
|
-
display: grid;
|
|
80
|
-
border-radius: 100%;
|
|
81
|
-
position: absolute;
|
|
82
|
-
outline: 2px solid #d91e18ff;
|
|
83
|
-
height: 24px;
|
|
84
|
-
width: 24px;
|
|
85
|
-
animation: scalePulse 0.5s cubic-bezier(0.12, 0.84, 0.5, 0.44) forwards;
|
|
86
|
-
}
|
|
87
|
-
&::after {
|
|
88
|
-
opacity: 1;
|
|
89
|
-
transform: scale(0);
|
|
90
|
-
animation-delay: 0.2s;
|
|
91
|
-
}
|
|
92
|
-
#center-heart {
|
|
93
|
-
#inner {
|
|
94
|
-
fill: #d91e18ff;
|
|
95
|
-
}
|
|
96
|
-
#outer {
|
|
97
|
-
fill: #d91e18ff;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
#left-hearts > *,
|
|
101
|
-
#right-hearts > * {
|
|
102
|
-
transform-origin: center center;
|
|
103
|
-
animation: floatingHearts 0.65s cubic-bezier(0.12, 0.84, 0.5, 0.44) forwards;
|
|
104
|
-
}
|
|
105
|
-
#right-hearts {
|
|
106
|
-
g:first-child {
|
|
107
|
-
animation-delay: 0.3s;
|
|
108
|
-
}
|
|
109
|
-
g:last-child {
|
|
110
|
-
animation-delay: 0.1s;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
#left-hearts {
|
|
114
|
-
g:first-child {
|
|
115
|
-
animation-delay: 0.2s;
|
|
116
|
-
}
|
|
117
|
-
g:last-child {
|
|
118
|
-
animation-delay: 0.5s;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
@keyframes floatingHearts {
|
|
122
|
-
0% {
|
|
123
|
-
opacity: 0;
|
|
124
|
-
transform: translateY(10px);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
50% {
|
|
128
|
-
opacity: 0.5;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
100% {
|
|
132
|
-
opacity: 0;
|
|
133
|
-
transform: translateY(-50px);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
@keyframes scalePulse {
|
|
138
|
-
from {
|
|
139
|
-
transform: scale(0);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
to {
|
|
143
|
-
transform: scale(1.1);
|
|
144
|
-
opacity: 0;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}` }), _jsx("input", { type: "checkbox", id: "like", name: "like", checked: selected, readOnly: true }), _jsx("label", Object.assign({ htmlFor: "like" }, { children: _jsx("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 189.2 87.507", style: { overflow: "visible" } }, { children: _jsxs("g", Object.assign({ id: "hearts", transform: "translate(-787.902 -454.998)" }, { children: [_jsxs("g", Object.assign({ id: "right-hearts" }, { children: [_jsxs("g", Object.assign({ id: "Group_4", "data-name": "Group 4", opacity: "0.484" }, { children: [_jsx("path", { id: "Path_8", "data-name": "Path 8", d: "M36.508,16.436c-3.141,6.041-11.545,14.257-16.3,18.634a1.342,1.342,0,0,1-1.8,0C13.633,30.693,5.229,22.477,2.087,16.436c-6.9-13.29,10.5-22.151,17.21-8.86C26.01-5.715,43.409,3.146,36.508,16.436Z", transform: "translate(936.502 486.145)", fill: "#fff" }), _jsx("path", { id: "Path_9", "data-name": "Path 9", d: "M19.311,37.916a3.836,3.836,0,0,1-2.575-.99l-.013-.012C11.871,32.47,3.229,24.051-.131,17.589A15.428,15.428,0,0,1-2,10.374,12.021,12.021,0,0,1-.282,4.2,11.848,11.848,0,0,1,16.364.456a13.647,13.647,0,0,1,2.934,2.6,13.649,13.649,0,0,1,2.934-2.6A11.848,11.848,0,0,1,38.879,4.2,12.02,12.02,0,0,1,40.6,10.374a15.428,15.428,0,0,1-1.87,7.214A52.812,52.812,0,0,1,30.8,28.07c-3.2,3.482-6.607,6.728-8.9,8.839l-.018.017a3.836,3.836,0,0,1-2.571.99ZM9.864,3.5A6.907,6.907,0,0,0,3.991,6.8c-1.423,2.342-1.311,5.357.315,8.489,1.013,1.948,4.482,7.467,15,17.213,2.172-2.025,5.076-4.836,7.815-7.813a48.2,48.2,0,0,0,7.166-9.4c1.626-3.131,1.738-6.146.315-8.488a6.848,6.848,0,0,0-9.644-2.149A10.185,10.185,0,0,0,21.529,8.7L19.3,13.121,17.066,8.7a10.185,10.185,0,0,0-3.432-4.057A6.906,6.906,0,0,0,9.864,3.5Z", transform: "translate(936.502 486.145)", fill: "#fff" })] })), _jsxs("g", Object.assign({ id: "Group_5", "data-name": "Group 5", opacity: "0.484" }, { children: [_jsx("path", { id: "Path_10", "data-name": "Path 10", d: "M36.508,16.436c-3.141,6.041-11.545,14.257-16.3,18.634a1.342,1.342,0,0,1-1.8,0C13.633,30.693,5.229,22.477,2.087,16.436c-6.9-13.29,10.5-22.151,17.21-8.86C26.01-5.715,43.409,3.146,36.508,16.436Z", transform: "translate(906.04 497.584)", fill: "#d91e18ff" }), _jsx("path", { id: "Path_11", "data-name": "Path 11", d: "M19.311,37.916a3.836,3.836,0,0,1-2.575-.99l-.013-.012C11.871,32.47,3.229,24.051-.131,17.589A15.428,15.428,0,0,1-2,10.374,12.021,12.021,0,0,1-.282,4.2,11.848,11.848,0,0,1,16.364.456a13.647,13.647,0,0,1,2.934,2.6,13.649,13.649,0,0,1,2.934-2.6A11.848,11.848,0,0,1,38.879,4.2,12.02,12.02,0,0,1,40.6,10.374a15.428,15.428,0,0,1-1.87,7.214A52.812,52.812,0,0,1,30.8,28.07c-3.2,3.482-6.607,6.728-8.9,8.839l-.018.017a3.836,3.836,0,0,1-2.571.99ZM9.864,3.5A6.907,6.907,0,0,0,3.991,6.8c-1.423,2.342-1.311,5.357.315,8.489,1.013,1.948,4.482,7.467,15,17.213,2.172-2.025,5.076-4.836,7.815-7.813a48.2,48.2,0,0,0,7.166-9.4c1.626-3.131,1.738-6.146.315-8.488a6.848,6.848,0,0,0-9.644-2.149A10.185,10.185,0,0,0,21.529,8.7L19.3,13.121,17.066,8.7a10.185,10.185,0,0,0-3.432-4.057A6.906,6.906,0,0,0,9.864,3.5Z", transform: "translate(906.04 497.584)", fill: "#d91e18ff" })] }))] })), _jsxs("g", Object.assign({ id: "left-hearts" }, { children: [_jsxs("g", Object.assign({ id: "Group_6", "data-name": "Group 6", opacity: "0.484" }, { children: [_jsx("path", { id: "Path_12", "data-name": "Path 12", d: "M36.508,16.436c-3.141,6.041-11.545,14.257-16.3,18.634a1.342,1.342,0,0,1-1.8,0C13.633,30.693,5.229,22.477,2.087,16.436c-6.9-13.29,10.5-22.151,17.21-8.86C26.01-5.715,43.409,3.146,36.508,16.436Z", transform: "translate(827.502 483.705)", fill: "#fff" }), _jsx("path", { id: "Path_13", "data-name": "Path 13", d: "M19.311,37.916a3.836,3.836,0,0,1-2.575-.99l-.013-.012C11.871,32.47,3.229,24.051-.131,17.589A15.428,15.428,0,0,1-2,10.374,12.021,12.021,0,0,1-.282,4.2,11.848,11.848,0,0,1,16.364.456a13.647,13.647,0,0,1,2.934,2.6,13.649,13.649,0,0,1,2.934-2.6A11.848,11.848,0,0,1,38.879,4.2,12.02,12.02,0,0,1,40.6,10.374a15.428,15.428,0,0,1-1.87,7.214A52.812,52.812,0,0,1,30.8,28.07c-3.2,3.482-6.607,6.728-8.9,8.839l-.018.017a3.836,3.836,0,0,1-2.571.99ZM9.864,3.5A6.907,6.907,0,0,0,3.991,6.8c-1.423,2.342-1.311,5.357.315,8.489,1.013,1.948,4.482,7.467,15,17.213,2.172-2.025,5.076-4.836,7.815-7.813a48.2,48.2,0,0,0,7.166-9.4c1.626-3.131,1.738-6.146.315-8.488a6.848,6.848,0,0,0-9.644-2.149A10.185,10.185,0,0,0,21.529,8.7L19.3,13.121,17.066,8.7a10.185,10.185,0,0,0-3.432-4.057A6.906,6.906,0,0,0,9.864,3.5Z", transform: "translate(827.502 483.705)", fill: "#fff" })] })), _jsxs("g", Object.assign({ id: "Group_7", "data-name": "Group 7", opacity: "0.484" }, { children: [_jsx("path", { id: "Path_14", "data-name": "Path 14", d: "M36.508,16.436c-3.141,6.041-11.545,14.257-16.3,18.634a1.342,1.342,0,0,1-1.8,0C13.633,30.693,5.229,22.477,2.087,16.436c-6.9-13.29,10.5-22.151,17.21-8.86C26.01-5.715,43.409,3.146,36.508,16.436Z", transform: "translate(789.902 456.497)", fill: "#d91e18ff" }), _jsx("path", { id: "Path_15", "data-name": "Path 15", d: "M19.311,37.916a3.836,3.836,0,0,1-2.575-.99l-.013-.012C11.871,32.47,3.229,24.051-.131,17.589A15.428,15.428,0,0,1-2,10.374,12.021,12.021,0,0,1-.282,4.2,11.848,11.848,0,0,1,16.364.456a13.647,13.647,0,0,1,2.934,2.6,13.649,13.649,0,0,1,2.934-2.6A11.848,11.848,0,0,1,38.879,4.2,12.02,12.02,0,0,1,40.6,10.374a15.428,15.428,0,0,1-1.87,7.214A52.812,52.812,0,0,1,30.8,28.07c-3.2,3.482-6.607,6.728-8.9,8.839l-.018.017a3.836,3.836,0,0,1-2.571.99ZM9.864,3.5A6.907,6.907,0,0,0,3.991,6.8c-1.423,2.342-1.311,5.357.315,8.489,1.013,1.948,4.482,7.467,15,17.213,2.172-2.025,5.076-4.836,7.815-7.813a48.2,48.2,0,0,0,7.166-9.4c1.626-3.131,1.738-6.146.315-8.488a6.848,6.848,0,0,0-9.644-2.149A10.185,10.185,0,0,0,21.529,8.7L19.3,13.121,17.066,8.7a10.185,10.185,0,0,0-3.432-4.057A6.906,6.906,0,0,0,9.864,3.5Z", transform: "translate(789.902 456.497)", fill: "#d91e18ff" })] }))] })), _jsxs("g", Object.assign({ id: "center-heart" }, { children: [_jsx("path", { id: "inner", "data-name": "Path 16", d: "M68.82,30.286C62.86,41.748,46.92,57.336,37.9,65.639a2.547,2.547,0,0,1-3.413,0c-9.068-8.3-25.012-23.892-30.972-35.353C-9.578,5.07,23.432-11.741,36.167,13.475,48.9-11.741,81.912,5.07,68.82,30.286Z", transform: "translate(853.502 473.705)", fill: "#d91e18ff" }), _jsx("path", { id: "outer", "data-name": "Path 17", d: "M36.192,68.8a5.038,5.038,0,0,1-3.382-1.3l-.013-.012C28.5,63.55,22.1,57.47,16,50.84,8.968,43.21,4.022,36.682,1.3,31.439A27.058,27.058,0,0,1-2,18.8,20.564,20.564,0,0,1,.934,8.233,20.236,20.236,0,0,1,29.375,1.847a24.62,24.62,0,0,1,6.792,6.728,24.623,24.623,0,0,1,6.791-6.728A20.236,20.236,0,0,1,71.4,8.233,20.562,20.562,0,0,1,74.336,18.8a27.059,27.059,0,0,1-3.3,12.641c-2.723,5.236-7.666,11.763-14.693,19.4C50.32,57.389,43.909,63.5,39.592,67.478l-.018.017A5.038,5.038,0,0,1,36.192,68.8Zm-.029-5.01a.047.047,0,0,0,.057,0c4.247-3.912,10.543-9.916,16.446-16.332C59.4,40.14,64.084,33.976,66.6,29.132a22.135,22.135,0,0,0,2.734-10.306A15.233,15.233,0,0,0,45.688,6.037,21.52,21.52,0,0,0,38.4,14.6l-2.232,4.418L33.935,14.6a21.521,21.521,0,0,0-7.289-8.566A15.231,15.231,0,0,0,3,18.827,22.133,22.133,0,0,0,5.732,29.134c2.522,4.85,7.213,11.014,13.941,18.319,5.982,6.495,12.268,12.465,16.491,16.333Z", transform: "translate(853.502 473.705)", fill: "#d91e18ff" })] }))] })) })) }))] })));
|
|
148
|
-
const Favorite = React.forwardRef((_a, ref) => {
|
|
149
|
-
var { className, size = "small",
|
|
150
|
-
// selected = false,
|
|
151
|
-
onClick, icon = "heart-filled", showBackground = true, isAnimated = true } = _a, props = __rest(_a, ["className", "size", "onClick", "icon", "showBackground", "isAnimated"]);
|
|
152
|
-
const [selected, setSelected] = React.useState(false);
|
|
153
|
-
return (_jsx("div", { children: isAnimated ? (_jsx(AnimatedHeart, { selected: selected, onClick: () => setSelected(true) })) : (_jsx(Icon, { name: icon, color: selected ? "stateColors-favorites" : "stateColors-disabled", size: size === "small" ? "xs" : "sm", onClick: onClick })) }));
|
|
154
|
-
});
|
|
155
|
-
Favorite.displayName = "Favorite";
|
|
156
|
-
export { Favorite, favoriteVariants };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"favorite.spec.d.ts","sourceRoot":"","sources":["../../../../components/ui/favorite/favorite.spec.tsx"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/ui/favorite/index.tsx"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./favorite";
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
interface SelectProps<T> {
|
|
3
|
-
children: React.ReactElement<{
|
|
4
|
-
value: T;
|
|
5
|
-
onSelect?: () => void;
|
|
6
|
-
isTrigger?: boolean;
|
|
7
|
-
isSelected?: boolean;
|
|
8
|
-
children: ({ isTrigger }: {
|
|
9
|
-
isTrigger: boolean;
|
|
10
|
-
}) => React.ReactNode;
|
|
11
|
-
}>[];
|
|
12
|
-
defaultValue?: T;
|
|
13
|
-
onChange?: (value: T) => void;
|
|
14
|
-
onOpenChange?: (isOpen: boolean) => void;
|
|
15
|
-
onCreateNew?: () => void;
|
|
16
|
-
}
|
|
17
|
-
declare const Select: React.ForwardRefExoticComponent<SelectProps<unknown> & React.RefAttributes<HTMLDivElement>>;
|
|
18
|
-
interface SelectTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
19
|
-
isTrigger?: boolean;
|
|
20
|
-
children: React.ReactNode;
|
|
21
|
-
}
|
|
22
|
-
declare const SelectTrigger: React.ForwardRefExoticComponent<SelectTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
23
|
-
interface SelectContentProps {
|
|
24
|
-
children: React.ReactNode;
|
|
25
|
-
isOpen: boolean;
|
|
26
|
-
className?: string;
|
|
27
|
-
}
|
|
28
|
-
declare const SelectContent: React.ForwardRefExoticComponent<SelectContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
29
|
-
interface SelectItemProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "children"> {
|
|
30
|
-
onSelect?: () => void;
|
|
31
|
-
isSelected?: boolean;
|
|
32
|
-
isTrigger?: boolean;
|
|
33
|
-
children: React.ReactNode | (({ isTrigger }: {
|
|
34
|
-
isTrigger: boolean;
|
|
35
|
-
}) => React.ReactNode);
|
|
36
|
-
}
|
|
37
|
-
declare const SelectItem: React.ForwardRefExoticComponent<SelectItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
38
|
-
export { Select, SelectTrigger, SelectContent, SelectItem };
|
|
39
|
-
//# sourceMappingURL=select.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../components/ui/select.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAK9B,UAAU,WAAW,CAAC,CAAC;IACrB,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC;QAC3B,KAAK,EAAE,CAAC,CAAA;QACR,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;QACrB,SAAS,CAAC,EAAE,OAAO,CAAA;QACnB,UAAU,CAAC,EAAE,OAAO,CAAA;QACpB,QAAQ,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE;YAAE,SAAS,EAAE,OAAO,CAAA;SAAE,KAAK,KAAK,CAAC,SAAS,CAAA;KACrE,CAAC,EAAE,CAAA;IACJ,YAAY,CAAC,EAAE,CAAC,CAAA;IAChB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAA;IAC7B,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAA;IACxC,WAAW,CAAC,EAAE,MAAM,IAAI,CAAA;CACzB;AAED,QAAA,MAAM,MAAM,6FAwGX,CAAA;AAID,UAAU,kBACR,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC;IACrD,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B;AAED,QAAA,MAAM,aAAa,8FAiBlB,CAAA;AAGD,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,MAAM,EAAE,OAAO,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,QAAA,MAAM,aAAa,2FAiBlB,CAAA;AAGD,UAAU,eACR,SAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC;IAC9D,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;IACrB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,QAAQ,EACJ,KAAK,CAAC,SAAS,GACf,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,KAAK,KAAK,CAAC,SAAS,CAAC,CAAA;CACjE;AAED,QAAA,MAAM,UAAU,wFAmBf,CAAA;AAGD,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,CAAA"}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
-
import * as React from "react";
|
|
15
|
-
import { ChevronDown } from "lucide-react";
|
|
16
|
-
import { cn } from "../../lib/utils";
|
|
17
|
-
import { CreateNew, Wishlist } from "./wishlist";
|
|
18
|
-
const Select = React.forwardRef(({ children, defaultValue, onChange, onOpenChange, onCreateNew, }, ref) => {
|
|
19
|
-
const [isOpen, setIsOpen] = React.useState(false);
|
|
20
|
-
const [selectedValue, setSelectedValue] = React.useState(defaultValue);
|
|
21
|
-
const triggerRef = React.useRef(null);
|
|
22
|
-
const contentRef = React.useRef(null);
|
|
23
|
-
// useEffect for click outside listener
|
|
24
|
-
React.useEffect(() => {
|
|
25
|
-
const handleClickOutside = (event) => {
|
|
26
|
-
if (isOpen &&
|
|
27
|
-
triggerRef.current &&
|
|
28
|
-
contentRef.current &&
|
|
29
|
-
!triggerRef.current.contains(event.target) &&
|
|
30
|
-
!contentRef.current.contains(event.target)) {
|
|
31
|
-
setIsOpen(false);
|
|
32
|
-
onOpenChange && onOpenChange(false);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
document.addEventListener("mousedown", handleClickOutside);
|
|
36
|
-
return () => {
|
|
37
|
-
document.removeEventListener("mousedown", handleClickOutside);
|
|
38
|
-
};
|
|
39
|
-
}, [isOpen, onOpenChange]);
|
|
40
|
-
const handleSelect = (value) => {
|
|
41
|
-
setSelectedValue(value);
|
|
42
|
-
setIsOpen(false);
|
|
43
|
-
onChange && onChange(value);
|
|
44
|
-
onOpenChange && onOpenChange(false);
|
|
45
|
-
};
|
|
46
|
-
const handleToggle = () => {
|
|
47
|
-
const newIsOpen = !isOpen;
|
|
48
|
-
setIsOpen(newIsOpen);
|
|
49
|
-
onOpenChange && onOpenChange(newIsOpen);
|
|
50
|
-
};
|
|
51
|
-
const handleCreateNew = () => {
|
|
52
|
-
onCreateNew && onCreateNew();
|
|
53
|
-
setIsOpen(false);
|
|
54
|
-
onOpenChange && onOpenChange(false);
|
|
55
|
-
};
|
|
56
|
-
const selectedChild = React.Children.toArray(children).find((child) => React.isValidElement(child) && child.props.value === selectedValue);
|
|
57
|
-
return (_jsxs("div", Object.assign({ className: "relative", ref: ref }, { children: [_jsxs(SelectTrigger, Object.assign({ ref: triggerRef, onClick: handleToggle }, { children: [_jsx(SelectItem, Object.assign({ isTrigger: true }, { children: selectedChild ? (selectedChild.props.children({ isTrigger: true })) : (_jsx(Wishlist, { name: "My Favorites", isTrigger: true })) })), _jsx(ChevronDown, { className: cn("h-4 w-4 opacity-50 mr-4 transition-transform duration-200 ease-in-out", isOpen && "transform rotate-180") })] })), _jsxs(SelectContent, Object.assign({ isOpen: isOpen, ref: contentRef }, { children: [React.Children.map(children, (child) => React.isValidElement(child)
|
|
58
|
-
? React.cloneElement(child, {
|
|
59
|
-
onSelect: () => handleSelect(child.props.value),
|
|
60
|
-
isSelected: child.props.value === selectedValue,
|
|
61
|
-
}, child.props.children({ isTrigger: false }))
|
|
62
|
-
: child), _jsx("div", Object.assign({ className: "sticky bottom-0 bg-coreColors-inputBackground border-t border-coreColors-dividingLines" }, { children: _jsx(CreateNew, { onClick: handleCreateNew }) }))] }))] })));
|
|
63
|
-
});
|
|
64
|
-
Select.displayName = "Select";
|
|
65
|
-
const SelectTrigger = React.forwardRef((_a, ref) => {
|
|
66
|
-
var { className, children, isTrigger = false } = _a, props = __rest(_a, ["className", "children", "isTrigger"]);
|
|
67
|
-
return (_jsx("button", Object.assign({ ref: ref, className: cn("flex w-full items-center justify-between rounded-md border border-coreColors-brandColorPrimary bg-coreColors-inputBackground text-sm placeholder:text-coreColors-brandColorPrimary disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1", className), style: {
|
|
68
|
-
WebkitTapHighlightColor: "transparent",
|
|
69
|
-
} }, props, { children: children })));
|
|
70
|
-
});
|
|
71
|
-
SelectTrigger.displayName = "SelectTrigger";
|
|
72
|
-
const SelectContent = React.forwardRef((_a, ref) => {
|
|
73
|
-
var { className, children, isOpen } = _a, props = __rest(_a, ["className", "children", "isOpen"]);
|
|
74
|
-
return (_jsx("div", Object.assign({ ref: ref, className: cn("mt-1 absolute z-50 w-full max-h-[200px] overflow-y-auto rounded-md bg-coreColors-inputBackground shadow-md border border-coreColors-brandColorPrimary", "transition-all duration-300 ease-in-out", isOpen
|
|
75
|
-
? "opacity-100 translate-y-0"
|
|
76
|
-
: "opacity-0 translate-y-[-10px] pointer-events-none", className) }, props, { children: children })));
|
|
77
|
-
});
|
|
78
|
-
SelectContent.displayName = "SelectContent";
|
|
79
|
-
const SelectItem = React.forwardRef((_a, ref) => {
|
|
80
|
-
var { className, children, onSelect, isSelected, isTrigger } = _a, props = __rest(_a, ["className", "children", "onSelect", "isSelected", "isTrigger"]);
|
|
81
|
-
return (_jsx("div", Object.assign({ ref: ref, className: cn("relative flex w-full cursor-pointer select-none items-center text-sm outline-none", !isTrigger &&
|
|
82
|
-
"border-b border-coreColors-dividingLines last:border-b-0", isSelected && "bg-stateColors-skeleton", className), onClick: onSelect }, props, { children: typeof children === "function"
|
|
83
|
-
? children({ isTrigger: isTrigger || false })
|
|
84
|
-
: children })));
|
|
85
|
-
});
|
|
86
|
-
SelectItem.displayName = "SelectItem";
|
|
87
|
-
export { Select, SelectTrigger, SelectContent, SelectItem };
|