@storepecker/storefront-core 2.3.6 → 2.4.1
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/api/index.cjs +28 -24
- package/dist/api/index.d.cts +8 -5
- package/dist/api/index.d.ts +8 -5
- package/dist/api/index.js +1 -1
- package/dist/{booking-CG6tul9l.d.ts → booking-BVWe8HHh.d.ts} +1 -1
- package/dist/{booking-DNVf5ZAS.d.cts → booking-DX9SU_qm.d.cts} +1 -1
- package/dist/cart-kJoawc_Z.d.cts +126 -0
- package/dist/cart-y-7RPmnQ.d.ts +126 -0
- package/dist/checkout/index.cjs +22 -22
- package/dist/checkout/index.d.cts +3 -1
- package/dist/checkout/index.d.ts +3 -1
- package/dist/checkout/index.js +2 -2
- package/dist/{chunk-BTT3XQ32.cjs → chunk-33TWVRZE.cjs} +6 -6
- package/dist/chunk-3YRSHPM6.cjs +34 -0
- package/dist/chunk-6DXB4O6P.cjs +121 -0
- package/dist/{chunk-ILVGYHNI.js → chunk-6Q7QMPOQ.js} +2 -1
- package/dist/{chunk-HTFVROIV.cjs → chunk-7UK3E7SL.cjs} +6 -0
- package/dist/chunk-B3BXKMQA.cjs +271 -0
- package/dist/chunk-BTR3HLL4.js +14 -0
- package/dist/chunk-EGFOTJPC.js +22 -0
- package/dist/{chunk-YUPBTD4M.js → chunk-F45S7UWC.js} +1 -139
- package/dist/chunk-HAQWCNDY.cjs +24 -0
- package/dist/{chunk-Y4NGR42Z.js → chunk-HUIT4JCR.js} +1 -1
- package/dist/{chunk-TF2KMTB6.js → chunk-JRYWZMNT.js} +1 -1
- package/dist/{chunk-JCOOINQF.cjs → chunk-KLNKIQQM.cjs} +4 -3
- package/dist/chunk-L43KF3AC.js +269 -0
- package/dist/chunk-LHF5BSWO.cjs +16 -0
- package/dist/chunk-LJUGNSQQ.cjs +149 -0
- package/dist/chunk-LLRSKDH5.js +115 -0
- package/dist/chunk-OSM73ETC.js +139 -0
- package/dist/{chunk-4CVKE6CC.cjs → chunk-OTMTHA5C.cjs} +0 -147
- package/dist/{chunk-JH4JJBXE.cjs → chunk-TTIQRDHX.cjs} +2 -2
- package/dist/chunk-U7EXLQCT.js +32 -0
- package/dist/{chunk-LW3V53WJ.js → chunk-UVU7H4E6.js} +6 -1
- package/dist/chunk-V447PVRV.cjs +308 -0
- package/dist/chunk-YK4M3SFP.js +301 -0
- package/dist/{collections-Bz9KD7Na.d.cts → collections-BDSVfRNo.d.ts} +1 -1
- package/dist/{collections-CkEUi3BR.d.ts → collections-WzvTO0OQ.d.cts} +1 -1
- package/dist/components/address-form.cjs +17 -0
- package/dist/components/address-form.css +329 -0
- package/dist/components/address-form.d.cts +33 -0
- package/dist/components/address-form.d.ts +33 -0
- package/dist/components/address-form.js +11 -0
- package/dist/components/digital-product-download-modal.cjs +8 -0
- package/dist/components/digital-product-download-modal.d.cts +15 -0
- package/dist/components/digital-product-download-modal.d.ts +15 -0
- package/dist/components/digital-product-download-modal.js +2 -0
- package/dist/components/index.cjs +35 -695
- package/dist/components/index.d.cts +14 -87
- package/dist/components/index.d.ts +14 -87
- package/dist/components/index.js +11 -688
- package/dist/components/search-dropdown.cjs +7 -0
- package/dist/components/search-dropdown.css +200 -0
- package/dist/components/search-dropdown.d.cts +28 -0
- package/dist/components/search-dropdown.d.ts +28 -0
- package/dist/components/search-dropdown.js +1 -0
- package/dist/components/share-button.cjs +9 -0
- package/dist/components/share-button.d.cts +11 -0
- package/dist/components/share-button.d.ts +11 -0
- package/dist/components/share-button.js +3 -0
- package/dist/components/share-icon.cjs +7 -0
- package/dist/components/share-icon.d.cts +9 -0
- package/dist/components/share-icon.d.ts +9 -0
- package/dist/components/share-icon.js +1 -0
- package/dist/components/theme-data-initializer.cjs +8 -0
- package/dist/components/theme-data-initializer.d.cts +12 -0
- package/dist/components/theme-data-initializer.d.ts +12 -0
- package/dist/components/theme-data-initializer.js +2 -0
- package/dist/hooks/index.cjs +18 -17
- package/dist/hooks/index.d.cts +4 -2
- package/dist/hooks/index.d.ts +4 -2
- package/dist/hooks/index.js +6 -5
- package/dist/models/index.d.cts +6 -4
- package/dist/models/index.d.ts +6 -4
- package/dist/orders-CjNmCY5I.d.cts +144 -0
- package/dist/orders-L_8eIkUS.d.ts +144 -0
- package/dist/{pixelEvents-OVIkPw-J.d.ts → pixelEvents-Bo-VjAx8.d.ts} +4 -2
- package/dist/{pixelEvents-DYkiTkb2.d.cts → pixelEvents-C1rFPOwb.d.cts} +4 -2
- package/dist/{orders-fIdANHSl.d.ts → product-DJMdi4D4.d.cts} +1 -265
- package/dist/{orders-fIdANHSl.d.cts → product-DJMdi4D4.d.ts} +1 -265
- package/dist/store/index.cjs +5 -5
- package/dist/store/index.d.cts +6 -4
- package/dist/store/index.d.ts +6 -4
- package/dist/store/index.js +2 -2
- package/dist/utils/index.cjs +44 -43
- package/dist/utils/index.d.cts +7 -5
- package/dist/utils/index.d.ts +7 -5
- package/dist/utils/index.js +3 -2
- package/dist/{wishlist-stNzfvIP.d.cts → wishlist-CUuCTSVJ.d.cts} +1 -1
- package/dist/{wishlist-_bd4gLyQ.d.ts → wishlist-DKYFZR0s.d.ts} +1 -1
- package/package.json +50 -6
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var clsx = require('clsx');
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
|
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
var clsx__default = /*#__PURE__*/_interopDefault(clsx);
|
|
10
|
+
|
|
11
|
+
// src/components/search-dropdown/search-dropdown.tsx
|
|
12
|
+
|
|
13
|
+
// src/components/search-dropdown/search-dropdown.module.css
|
|
14
|
+
var search_dropdown_default = {};
|
|
15
|
+
function DownChevron({
|
|
16
|
+
width = 24,
|
|
17
|
+
height = 24,
|
|
18
|
+
className
|
|
19
|
+
}) {
|
|
20
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
21
|
+
"svg",
|
|
22
|
+
{
|
|
23
|
+
fill: "currentColor",
|
|
24
|
+
height,
|
|
25
|
+
width,
|
|
26
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
27
|
+
xmlnsXlink: "http://www.w3.org/1999/xlink",
|
|
28
|
+
viewBox: "0 0 407.437 407.437",
|
|
29
|
+
xmlSpace: "preserve",
|
|
30
|
+
className,
|
|
31
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
32
|
+
"polygon",
|
|
33
|
+
{
|
|
34
|
+
points: "386.258,91.567 203.718,273.512 21.179,91.567 0,112.815 203.718,315.87 407.437,112.815 ",
|
|
35
|
+
strokeWidth: "2"
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
function SearchIcon({
|
|
42
|
+
width = 24,
|
|
43
|
+
height = 24,
|
|
44
|
+
className
|
|
45
|
+
}) {
|
|
46
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
47
|
+
"svg",
|
|
48
|
+
{
|
|
49
|
+
width,
|
|
50
|
+
height,
|
|
51
|
+
viewBox: "0 0 24 24",
|
|
52
|
+
fill: "none",
|
|
53
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
54
|
+
className,
|
|
55
|
+
children: [
|
|
56
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
57
|
+
"path",
|
|
58
|
+
{
|
|
59
|
+
d: "M17.5 17.5L22 22",
|
|
60
|
+
stroke: "currentColor",
|
|
61
|
+
strokeWidth: "1.5",
|
|
62
|
+
strokeLinecap: "round",
|
|
63
|
+
strokeLinejoin: "round"
|
|
64
|
+
}
|
|
65
|
+
),
|
|
66
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
67
|
+
"path",
|
|
68
|
+
{
|
|
69
|
+
d: "M20 11C20 6.02944 15.9706 2 11 2C6.02944 2 2 6.02944 2 11C2 15.9706 6.02944 20 11 20C15.9706 20 20 15.9706 20 11Z",
|
|
70
|
+
stroke: "currentColor",
|
|
71
|
+
strokeWidth: "1.5",
|
|
72
|
+
strokeLinejoin: "round"
|
|
73
|
+
}
|
|
74
|
+
)
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
var SearchDropdown = ({
|
|
80
|
+
options,
|
|
81
|
+
value,
|
|
82
|
+
onChange,
|
|
83
|
+
placeholder = "Select an option",
|
|
84
|
+
searchPlaceholder = "Search...",
|
|
85
|
+
className,
|
|
86
|
+
disabled = false,
|
|
87
|
+
error,
|
|
88
|
+
label,
|
|
89
|
+
name,
|
|
90
|
+
renderOption,
|
|
91
|
+
renderSelected,
|
|
92
|
+
filterFunction,
|
|
93
|
+
emptyMessage = "No options found",
|
|
94
|
+
maxHeight = "300px"
|
|
95
|
+
}) => {
|
|
96
|
+
const [isOpen, setIsOpen] = react.useState(false);
|
|
97
|
+
const [searchTerm, setSearchTerm] = react.useState("");
|
|
98
|
+
const [focusedIndex, setFocusedIndex] = react.useState(-1);
|
|
99
|
+
const dropdownRef = react.useRef(null);
|
|
100
|
+
const searchInputRef = react.useRef(null);
|
|
101
|
+
const optionsListRef = react.useRef(null);
|
|
102
|
+
const selectedOption = react.useMemo(
|
|
103
|
+
() => options.find((opt) => opt.value === value) || null,
|
|
104
|
+
[options, value]
|
|
105
|
+
);
|
|
106
|
+
const defaultFilter = react.useCallback(
|
|
107
|
+
(option, term) => {
|
|
108
|
+
return option.label.toLowerCase().includes(term.toLowerCase());
|
|
109
|
+
},
|
|
110
|
+
[]
|
|
111
|
+
);
|
|
112
|
+
const filter = filterFunction || defaultFilter;
|
|
113
|
+
const filteredOptions = react.useMemo(() => {
|
|
114
|
+
if (!searchTerm.trim()) return options;
|
|
115
|
+
return options.filter((option) => filter(option, searchTerm));
|
|
116
|
+
}, [options, searchTerm, filter]);
|
|
117
|
+
react.useEffect(() => {
|
|
118
|
+
function handleClickOutside(event) {
|
|
119
|
+
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
120
|
+
setIsOpen(false);
|
|
121
|
+
setSearchTerm("");
|
|
122
|
+
setFocusedIndex(-1);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (isOpen) {
|
|
126
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
127
|
+
setTimeout(() => {
|
|
128
|
+
searchInputRef.current?.focus();
|
|
129
|
+
}, 0);
|
|
130
|
+
}
|
|
131
|
+
return () => {
|
|
132
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
133
|
+
};
|
|
134
|
+
}, [isOpen]);
|
|
135
|
+
const handleSelect = react.useCallback(
|
|
136
|
+
(option) => {
|
|
137
|
+
if (option.disabled) return;
|
|
138
|
+
onChange?.(option.value, option);
|
|
139
|
+
setIsOpen(false);
|
|
140
|
+
setSearchTerm("");
|
|
141
|
+
setFocusedIndex(-1);
|
|
142
|
+
},
|
|
143
|
+
[onChange]
|
|
144
|
+
);
|
|
145
|
+
react.useEffect(() => {
|
|
146
|
+
function handleKeyDown(event) {
|
|
147
|
+
if (!isOpen) return;
|
|
148
|
+
switch (event.key) {
|
|
149
|
+
case "ArrowDown":
|
|
150
|
+
event.preventDefault();
|
|
151
|
+
setFocusedIndex(
|
|
152
|
+
(prev) => prev < filteredOptions.length - 1 ? prev + 1 : prev
|
|
153
|
+
);
|
|
154
|
+
break;
|
|
155
|
+
case "ArrowUp":
|
|
156
|
+
event.preventDefault();
|
|
157
|
+
setFocusedIndex((prev) => prev > 0 ? prev - 1 : -1);
|
|
158
|
+
break;
|
|
159
|
+
case "Enter":
|
|
160
|
+
event.preventDefault();
|
|
161
|
+
if (focusedIndex >= 0 && focusedIndex < filteredOptions.length) {
|
|
162
|
+
handleSelect(filteredOptions[focusedIndex]);
|
|
163
|
+
}
|
|
164
|
+
break;
|
|
165
|
+
case "Escape":
|
|
166
|
+
event.preventDefault();
|
|
167
|
+
setIsOpen(false);
|
|
168
|
+
setSearchTerm("");
|
|
169
|
+
setFocusedIndex(-1);
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (isOpen) {
|
|
174
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
175
|
+
}
|
|
176
|
+
return () => {
|
|
177
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
178
|
+
};
|
|
179
|
+
}, [isOpen, filteredOptions, focusedIndex, handleSelect]);
|
|
180
|
+
react.useEffect(() => {
|
|
181
|
+
if (focusedIndex >= 0 && optionsListRef.current) {
|
|
182
|
+
const focusedElement = optionsListRef.current.children[focusedIndex];
|
|
183
|
+
if (focusedElement) {
|
|
184
|
+
focusedElement.scrollIntoView({
|
|
185
|
+
behavior: "smooth",
|
|
186
|
+
block: "nearest"
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}, [focusedIndex]);
|
|
191
|
+
const handleToggle = () => {
|
|
192
|
+
if (disabled) return;
|
|
193
|
+
setIsOpen((prev) => !prev);
|
|
194
|
+
if (!isOpen) {
|
|
195
|
+
setSearchTerm("");
|
|
196
|
+
setFocusedIndex(-1);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
const handleSearchChange = (e) => {
|
|
200
|
+
setSearchTerm(e.target.value);
|
|
201
|
+
setFocusedIndex(-1);
|
|
202
|
+
};
|
|
203
|
+
const handleOptionMouseEnter = (index) => {
|
|
204
|
+
setFocusedIndex(index);
|
|
205
|
+
};
|
|
206
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
207
|
+
"div",
|
|
208
|
+
{
|
|
209
|
+
ref: dropdownRef,
|
|
210
|
+
className: clsx__default.default(search_dropdown_default.searchDropdown, className, {
|
|
211
|
+
[search_dropdown_default.disabled]: disabled,
|
|
212
|
+
[search_dropdown_default.error]: error,
|
|
213
|
+
[search_dropdown_default.open]: isOpen
|
|
214
|
+
}),
|
|
215
|
+
children: [
|
|
216
|
+
label && /* @__PURE__ */ jsxRuntime.jsx("label", { className: search_dropdown_default.label, htmlFor: name, children: label }),
|
|
217
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: search_dropdown_default.dropdownContainer, children: [
|
|
218
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
219
|
+
"button",
|
|
220
|
+
{
|
|
221
|
+
type: "button",
|
|
222
|
+
className: search_dropdown_default.dropdownButton,
|
|
223
|
+
onClick: handleToggle,
|
|
224
|
+
disabled,
|
|
225
|
+
"aria-expanded": isOpen,
|
|
226
|
+
"aria-haspopup": "listbox",
|
|
227
|
+
"aria-label": label || placeholder,
|
|
228
|
+
id: name,
|
|
229
|
+
children: [
|
|
230
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: search_dropdown_default.selectedValue, children: selectedOption ? renderSelected ? renderSelected(selectedOption) : selectedOption.label : placeholder }),
|
|
231
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
232
|
+
DownChevron,
|
|
233
|
+
{
|
|
234
|
+
width: 16,
|
|
235
|
+
height: 16,
|
|
236
|
+
className: clsx__default.default(search_dropdown_default.chevron, {
|
|
237
|
+
[search_dropdown_default.chevronOpen]: isOpen
|
|
238
|
+
})
|
|
239
|
+
}
|
|
240
|
+
)
|
|
241
|
+
]
|
|
242
|
+
}
|
|
243
|
+
),
|
|
244
|
+
isOpen && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: search_dropdown_default.dropdownMenu, style: { maxHeight }, children: [
|
|
245
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: search_dropdown_default.searchContainer, children: [
|
|
246
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
247
|
+
SearchIcon,
|
|
248
|
+
{
|
|
249
|
+
width: 16,
|
|
250
|
+
height: 16,
|
|
251
|
+
className: search_dropdown_default.searchIcon
|
|
252
|
+
}
|
|
253
|
+
),
|
|
254
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
255
|
+
"input",
|
|
256
|
+
{
|
|
257
|
+
ref: searchInputRef,
|
|
258
|
+
type: "text",
|
|
259
|
+
className: search_dropdown_default.searchInput,
|
|
260
|
+
placeholder: searchPlaceholder,
|
|
261
|
+
value: searchTerm,
|
|
262
|
+
onChange: handleSearchChange,
|
|
263
|
+
onClick: (e) => e.stopPropagation(),
|
|
264
|
+
onKeyDown: (e) => {
|
|
265
|
+
if (e.key === "Enter" && filteredOptions.length === 1) {
|
|
266
|
+
e.preventDefault();
|
|
267
|
+
handleSelect(filteredOptions[0]);
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
autoComplete: "off"
|
|
271
|
+
}
|
|
272
|
+
)
|
|
273
|
+
] }),
|
|
274
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
275
|
+
"ul",
|
|
276
|
+
{
|
|
277
|
+
ref: optionsListRef,
|
|
278
|
+
className: search_dropdown_default.optionsList,
|
|
279
|
+
role: "listbox",
|
|
280
|
+
children: filteredOptions.length > 0 ? filteredOptions.map((option, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
281
|
+
"li",
|
|
282
|
+
{
|
|
283
|
+
className: clsx__default.default(search_dropdown_default.option, {
|
|
284
|
+
[search_dropdown_default.optionSelected]: option.value === value,
|
|
285
|
+
[search_dropdown_default.optionFocused]: index === focusedIndex,
|
|
286
|
+
[search_dropdown_default.optionDisabled]: option.disabled
|
|
287
|
+
}),
|
|
288
|
+
onClick: () => handleSelect(option),
|
|
289
|
+
onMouseEnter: () => handleOptionMouseEnter(index),
|
|
290
|
+
role: "option",
|
|
291
|
+
"aria-selected": option.value === value,
|
|
292
|
+
children: renderOption ? renderOption(option) : option.label
|
|
293
|
+
},
|
|
294
|
+
option.value
|
|
295
|
+
)) : /* @__PURE__ */ jsxRuntime.jsx("li", { className: search_dropdown_default.emptyMessage, children: emptyMessage })
|
|
296
|
+
}
|
|
297
|
+
)
|
|
298
|
+
] })
|
|
299
|
+
] }),
|
|
300
|
+
error && /* @__PURE__ */ jsxRuntime.jsx("span", { className: search_dropdown_default.errorMessage, children: error })
|
|
301
|
+
]
|
|
302
|
+
}
|
|
303
|
+
);
|
|
304
|
+
};
|
|
305
|
+
var search_dropdown_default2 = SearchDropdown;
|
|
306
|
+
|
|
307
|
+
exports.DownChevron = DownChevron;
|
|
308
|
+
exports.search_dropdown_default = search_dropdown_default2;
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import { useState, useRef, useMemo, useCallback, useEffect } from 'react';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
// src/components/search-dropdown/search-dropdown.tsx
|
|
6
|
+
|
|
7
|
+
// src/components/search-dropdown/search-dropdown.module.css
|
|
8
|
+
var search_dropdown_default = {};
|
|
9
|
+
function DownChevron({
|
|
10
|
+
width = 24,
|
|
11
|
+
height = 24,
|
|
12
|
+
className
|
|
13
|
+
}) {
|
|
14
|
+
return /* @__PURE__ */ jsx(
|
|
15
|
+
"svg",
|
|
16
|
+
{
|
|
17
|
+
fill: "currentColor",
|
|
18
|
+
height,
|
|
19
|
+
width,
|
|
20
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
21
|
+
xmlnsXlink: "http://www.w3.org/1999/xlink",
|
|
22
|
+
viewBox: "0 0 407.437 407.437",
|
|
23
|
+
xmlSpace: "preserve",
|
|
24
|
+
className,
|
|
25
|
+
children: /* @__PURE__ */ jsx(
|
|
26
|
+
"polygon",
|
|
27
|
+
{
|
|
28
|
+
points: "386.258,91.567 203.718,273.512 21.179,91.567 0,112.815 203.718,315.87 407.437,112.815 ",
|
|
29
|
+
strokeWidth: "2"
|
|
30
|
+
}
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
function SearchIcon({
|
|
36
|
+
width = 24,
|
|
37
|
+
height = 24,
|
|
38
|
+
className
|
|
39
|
+
}) {
|
|
40
|
+
return /* @__PURE__ */ jsxs(
|
|
41
|
+
"svg",
|
|
42
|
+
{
|
|
43
|
+
width,
|
|
44
|
+
height,
|
|
45
|
+
viewBox: "0 0 24 24",
|
|
46
|
+
fill: "none",
|
|
47
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
48
|
+
className,
|
|
49
|
+
children: [
|
|
50
|
+
/* @__PURE__ */ jsx(
|
|
51
|
+
"path",
|
|
52
|
+
{
|
|
53
|
+
d: "M17.5 17.5L22 22",
|
|
54
|
+
stroke: "currentColor",
|
|
55
|
+
strokeWidth: "1.5",
|
|
56
|
+
strokeLinecap: "round",
|
|
57
|
+
strokeLinejoin: "round"
|
|
58
|
+
}
|
|
59
|
+
),
|
|
60
|
+
/* @__PURE__ */ jsx(
|
|
61
|
+
"path",
|
|
62
|
+
{
|
|
63
|
+
d: "M20 11C20 6.02944 15.9706 2 11 2C6.02944 2 2 6.02944 2 11C2 15.9706 6.02944 20 11 20C15.9706 20 20 15.9706 20 11Z",
|
|
64
|
+
stroke: "currentColor",
|
|
65
|
+
strokeWidth: "1.5",
|
|
66
|
+
strokeLinejoin: "round"
|
|
67
|
+
}
|
|
68
|
+
)
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
var SearchDropdown = ({
|
|
74
|
+
options,
|
|
75
|
+
value,
|
|
76
|
+
onChange,
|
|
77
|
+
placeholder = "Select an option",
|
|
78
|
+
searchPlaceholder = "Search...",
|
|
79
|
+
className,
|
|
80
|
+
disabled = false,
|
|
81
|
+
error,
|
|
82
|
+
label,
|
|
83
|
+
name,
|
|
84
|
+
renderOption,
|
|
85
|
+
renderSelected,
|
|
86
|
+
filterFunction,
|
|
87
|
+
emptyMessage = "No options found",
|
|
88
|
+
maxHeight = "300px"
|
|
89
|
+
}) => {
|
|
90
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
91
|
+
const [searchTerm, setSearchTerm] = useState("");
|
|
92
|
+
const [focusedIndex, setFocusedIndex] = useState(-1);
|
|
93
|
+
const dropdownRef = useRef(null);
|
|
94
|
+
const searchInputRef = useRef(null);
|
|
95
|
+
const optionsListRef = useRef(null);
|
|
96
|
+
const selectedOption = useMemo(
|
|
97
|
+
() => options.find((opt) => opt.value === value) || null,
|
|
98
|
+
[options, value]
|
|
99
|
+
);
|
|
100
|
+
const defaultFilter = useCallback(
|
|
101
|
+
(option, term) => {
|
|
102
|
+
return option.label.toLowerCase().includes(term.toLowerCase());
|
|
103
|
+
},
|
|
104
|
+
[]
|
|
105
|
+
);
|
|
106
|
+
const filter = filterFunction || defaultFilter;
|
|
107
|
+
const filteredOptions = useMemo(() => {
|
|
108
|
+
if (!searchTerm.trim()) return options;
|
|
109
|
+
return options.filter((option) => filter(option, searchTerm));
|
|
110
|
+
}, [options, searchTerm, filter]);
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
function handleClickOutside(event) {
|
|
113
|
+
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
114
|
+
setIsOpen(false);
|
|
115
|
+
setSearchTerm("");
|
|
116
|
+
setFocusedIndex(-1);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (isOpen) {
|
|
120
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
121
|
+
setTimeout(() => {
|
|
122
|
+
searchInputRef.current?.focus();
|
|
123
|
+
}, 0);
|
|
124
|
+
}
|
|
125
|
+
return () => {
|
|
126
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
127
|
+
};
|
|
128
|
+
}, [isOpen]);
|
|
129
|
+
const handleSelect = useCallback(
|
|
130
|
+
(option) => {
|
|
131
|
+
if (option.disabled) return;
|
|
132
|
+
onChange?.(option.value, option);
|
|
133
|
+
setIsOpen(false);
|
|
134
|
+
setSearchTerm("");
|
|
135
|
+
setFocusedIndex(-1);
|
|
136
|
+
},
|
|
137
|
+
[onChange]
|
|
138
|
+
);
|
|
139
|
+
useEffect(() => {
|
|
140
|
+
function handleKeyDown(event) {
|
|
141
|
+
if (!isOpen) return;
|
|
142
|
+
switch (event.key) {
|
|
143
|
+
case "ArrowDown":
|
|
144
|
+
event.preventDefault();
|
|
145
|
+
setFocusedIndex(
|
|
146
|
+
(prev) => prev < filteredOptions.length - 1 ? prev + 1 : prev
|
|
147
|
+
);
|
|
148
|
+
break;
|
|
149
|
+
case "ArrowUp":
|
|
150
|
+
event.preventDefault();
|
|
151
|
+
setFocusedIndex((prev) => prev > 0 ? prev - 1 : -1);
|
|
152
|
+
break;
|
|
153
|
+
case "Enter":
|
|
154
|
+
event.preventDefault();
|
|
155
|
+
if (focusedIndex >= 0 && focusedIndex < filteredOptions.length) {
|
|
156
|
+
handleSelect(filteredOptions[focusedIndex]);
|
|
157
|
+
}
|
|
158
|
+
break;
|
|
159
|
+
case "Escape":
|
|
160
|
+
event.preventDefault();
|
|
161
|
+
setIsOpen(false);
|
|
162
|
+
setSearchTerm("");
|
|
163
|
+
setFocusedIndex(-1);
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (isOpen) {
|
|
168
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
169
|
+
}
|
|
170
|
+
return () => {
|
|
171
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
172
|
+
};
|
|
173
|
+
}, [isOpen, filteredOptions, focusedIndex, handleSelect]);
|
|
174
|
+
useEffect(() => {
|
|
175
|
+
if (focusedIndex >= 0 && optionsListRef.current) {
|
|
176
|
+
const focusedElement = optionsListRef.current.children[focusedIndex];
|
|
177
|
+
if (focusedElement) {
|
|
178
|
+
focusedElement.scrollIntoView({
|
|
179
|
+
behavior: "smooth",
|
|
180
|
+
block: "nearest"
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}, [focusedIndex]);
|
|
185
|
+
const handleToggle = () => {
|
|
186
|
+
if (disabled) return;
|
|
187
|
+
setIsOpen((prev) => !prev);
|
|
188
|
+
if (!isOpen) {
|
|
189
|
+
setSearchTerm("");
|
|
190
|
+
setFocusedIndex(-1);
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
const handleSearchChange = (e) => {
|
|
194
|
+
setSearchTerm(e.target.value);
|
|
195
|
+
setFocusedIndex(-1);
|
|
196
|
+
};
|
|
197
|
+
const handleOptionMouseEnter = (index) => {
|
|
198
|
+
setFocusedIndex(index);
|
|
199
|
+
};
|
|
200
|
+
return /* @__PURE__ */ jsxs(
|
|
201
|
+
"div",
|
|
202
|
+
{
|
|
203
|
+
ref: dropdownRef,
|
|
204
|
+
className: clsx(search_dropdown_default.searchDropdown, className, {
|
|
205
|
+
[search_dropdown_default.disabled]: disabled,
|
|
206
|
+
[search_dropdown_default.error]: error,
|
|
207
|
+
[search_dropdown_default.open]: isOpen
|
|
208
|
+
}),
|
|
209
|
+
children: [
|
|
210
|
+
label && /* @__PURE__ */ jsx("label", { className: search_dropdown_default.label, htmlFor: name, children: label }),
|
|
211
|
+
/* @__PURE__ */ jsxs("div", { className: search_dropdown_default.dropdownContainer, children: [
|
|
212
|
+
/* @__PURE__ */ jsxs(
|
|
213
|
+
"button",
|
|
214
|
+
{
|
|
215
|
+
type: "button",
|
|
216
|
+
className: search_dropdown_default.dropdownButton,
|
|
217
|
+
onClick: handleToggle,
|
|
218
|
+
disabled,
|
|
219
|
+
"aria-expanded": isOpen,
|
|
220
|
+
"aria-haspopup": "listbox",
|
|
221
|
+
"aria-label": label || placeholder,
|
|
222
|
+
id: name,
|
|
223
|
+
children: [
|
|
224
|
+
/* @__PURE__ */ jsx("span", { className: search_dropdown_default.selectedValue, children: selectedOption ? renderSelected ? renderSelected(selectedOption) : selectedOption.label : placeholder }),
|
|
225
|
+
/* @__PURE__ */ jsx(
|
|
226
|
+
DownChevron,
|
|
227
|
+
{
|
|
228
|
+
width: 16,
|
|
229
|
+
height: 16,
|
|
230
|
+
className: clsx(search_dropdown_default.chevron, {
|
|
231
|
+
[search_dropdown_default.chevronOpen]: isOpen
|
|
232
|
+
})
|
|
233
|
+
}
|
|
234
|
+
)
|
|
235
|
+
]
|
|
236
|
+
}
|
|
237
|
+
),
|
|
238
|
+
isOpen && /* @__PURE__ */ jsxs("div", { className: search_dropdown_default.dropdownMenu, style: { maxHeight }, children: [
|
|
239
|
+
/* @__PURE__ */ jsxs("div", { className: search_dropdown_default.searchContainer, children: [
|
|
240
|
+
/* @__PURE__ */ jsx(
|
|
241
|
+
SearchIcon,
|
|
242
|
+
{
|
|
243
|
+
width: 16,
|
|
244
|
+
height: 16,
|
|
245
|
+
className: search_dropdown_default.searchIcon
|
|
246
|
+
}
|
|
247
|
+
),
|
|
248
|
+
/* @__PURE__ */ jsx(
|
|
249
|
+
"input",
|
|
250
|
+
{
|
|
251
|
+
ref: searchInputRef,
|
|
252
|
+
type: "text",
|
|
253
|
+
className: search_dropdown_default.searchInput,
|
|
254
|
+
placeholder: searchPlaceholder,
|
|
255
|
+
value: searchTerm,
|
|
256
|
+
onChange: handleSearchChange,
|
|
257
|
+
onClick: (e) => e.stopPropagation(),
|
|
258
|
+
onKeyDown: (e) => {
|
|
259
|
+
if (e.key === "Enter" && filteredOptions.length === 1) {
|
|
260
|
+
e.preventDefault();
|
|
261
|
+
handleSelect(filteredOptions[0]);
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
autoComplete: "off"
|
|
265
|
+
}
|
|
266
|
+
)
|
|
267
|
+
] }),
|
|
268
|
+
/* @__PURE__ */ jsx(
|
|
269
|
+
"ul",
|
|
270
|
+
{
|
|
271
|
+
ref: optionsListRef,
|
|
272
|
+
className: search_dropdown_default.optionsList,
|
|
273
|
+
role: "listbox",
|
|
274
|
+
children: filteredOptions.length > 0 ? filteredOptions.map((option, index) => /* @__PURE__ */ jsx(
|
|
275
|
+
"li",
|
|
276
|
+
{
|
|
277
|
+
className: clsx(search_dropdown_default.option, {
|
|
278
|
+
[search_dropdown_default.optionSelected]: option.value === value,
|
|
279
|
+
[search_dropdown_default.optionFocused]: index === focusedIndex,
|
|
280
|
+
[search_dropdown_default.optionDisabled]: option.disabled
|
|
281
|
+
}),
|
|
282
|
+
onClick: () => handleSelect(option),
|
|
283
|
+
onMouseEnter: () => handleOptionMouseEnter(index),
|
|
284
|
+
role: "option",
|
|
285
|
+
"aria-selected": option.value === value,
|
|
286
|
+
children: renderOption ? renderOption(option) : option.label
|
|
287
|
+
},
|
|
288
|
+
option.value
|
|
289
|
+
)) : /* @__PURE__ */ jsx("li", { className: search_dropdown_default.emptyMessage, children: emptyMessage })
|
|
290
|
+
}
|
|
291
|
+
)
|
|
292
|
+
] })
|
|
293
|
+
] }),
|
|
294
|
+
error && /* @__PURE__ */ jsx("span", { className: search_dropdown_default.errorMessage, children: error })
|
|
295
|
+
]
|
|
296
|
+
}
|
|
297
|
+
);
|
|
298
|
+
};
|
|
299
|
+
var search_dropdown_default2 = SearchDropdown;
|
|
300
|
+
|
|
301
|
+
export { DownChevron, search_dropdown_default2 as search_dropdown_default };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkB3BXKMQA_cjs = require('../chunk-B3BXKMQA.cjs');
|
|
4
|
+
require('../chunk-V447PVRV.cjs');
|
|
5
|
+
require('../chunk-KLNKIQQM.cjs');
|
|
6
|
+
require('../chunk-RDUT4W3B.cjs');
|
|
7
|
+
require('../chunk-LJUGNSQQ.cjs');
|
|
8
|
+
require('../chunk-OTMTHA5C.cjs');
|
|
9
|
+
require('../chunk-TB72NPRM.cjs');
|
|
10
|
+
require('../chunk-ECHV2JSY.cjs');
|
|
11
|
+
require('../chunk-BBRXE57K.cjs');
|
|
12
|
+
require('../chunk-NE3ZHELZ.cjs');
|
|
13
|
+
require('../chunk-N3CTXRFT.cjs');
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
module.exports = chunkB3BXKMQA_cjs.address_form_default;
|