@driveflux/beam 3.0.10 → 3.0.12
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/accordion/Accordion.js +133 -7
- package/dist/accordion/Accordion.stories.js +31 -11
- package/dist/alert/Alert.js +120 -19
- package/dist/alert/Alert.stories.js +50 -15
- package/dist/animations/LoadingAnimation.js +34 -21
- package/dist/badge/Badge.js +96 -7
- package/dist/badge/Badge.stories.js +28 -7
- package/dist/box/Box.js +87 -3
- package/dist/box/Box.stories.js +8 -7
- package/dist/breadcrumbs/Breadcrumbs.js +288 -28
- package/dist/breadcrumbs/Breadcrumbs.stories.js +51 -27
- package/dist/button/Button.js +127 -13
- package/dist/button/Button.stories.js +35 -7
- package/dist/button/TextButton.js +104 -9
- package/dist/card/Card.js +109 -7
- package/dist/card/Card.stories.js +10 -7
- package/dist/carousel/Carousel.js +281 -58
- package/dist/carousel/Carousel.stories.js +39 -7
- package/dist/carousel/CarouselButton.js +68 -7
- package/dist/center/Center.js +63 -3
- package/dist/center/Center.stories.js +19 -7
- package/dist/checkbox/Checkbox.js +124 -4
- package/dist/checkbox/Checkbox.stories.js +10 -8
- package/dist/chip/Chip.js +104 -3
- package/dist/chip/Chip.stories.js +19 -7
- package/dist/circular-progress/CircularProgress.js +150 -11
- package/dist/circular-progress/CircularProgress.stories.js +54 -14
- package/dist/command/command.js +170 -13
- package/dist/datepicker/DatePicker.js +234 -90
- package/dist/datepicker/DatePicker.stories.js +163 -58
- package/dist/datepicker/DatePickerDrawer.js +116 -17
- package/dist/datepicker/DatePickerPopover.js +208 -35
- package/dist/datepicker/constants.js +3 -4
- package/dist/datepicker/utils.js +4 -11
- package/dist/dialog/index.js +180 -33
- package/dist/divider/Divider.js +63 -3
- package/dist/divider/Divider.stories.js +13 -7
- package/dist/drawer/index.js +157 -12
- package/dist/dropdown/Dropdown.js +212 -26
- package/dist/dropdown/Dropdown.stories.js +109 -22
- package/dist/field-wrapper/FieldWrapper.js +139 -3
- package/dist/field-wrapper/FieldWrapper.stories.js +124 -28
- package/dist/flex/Flex.js +63 -3
- package/dist/flex/Flex.stories.js +19 -7
- package/dist/grid/Grid.js +63 -3
- package/dist/grid/Grid.stories.js +28 -7
- package/dist/hooks/use-breakpoint-value.js +77 -14
- package/dist/hooks/use-media-query.js +61 -12
- package/dist/hstack/HStack.js +63 -3
- package/dist/hstack/HStack.stories.js +19 -7
- package/dist/icons/FluxLogo.js +213 -9
- package/dist/icons/FluxLogoTable.js +109 -5
- package/dist/icons/Icon.js +108 -7
- package/dist/icons/Icon.stories.js +12 -7
- package/dist/icons/Icon24Hours.js +83 -5
- package/dist/icons/IconAcceleration.js +72 -4
- package/dist/icons/IconAccount.js +72 -4
- package/dist/icons/IconApplicant.js +78 -5
- package/dist/icons/IconArrow.js +78 -6
- package/dist/icons/IconArrowBack.js +72 -4
- package/dist/icons/IconArrowForward.js +72 -4
- package/dist/icons/IconArrowTopLeft.js +70 -4
- package/dist/icons/IconBluesharkProductGuide.js +80 -5
- package/dist/icons/IconBolt.js +72 -4
- package/dist/icons/IconBriefcase.js +72 -4
- package/dist/icons/IconBulb.js +72 -4
- package/dist/icons/IconCalendar.js +72 -4
- package/dist/icons/IconCalendarArrowBack.js +72 -4
- package/dist/icons/IconCalendarArrowForward.js +72 -4
- package/dist/icons/IconCalendarDoubleArrowBack.js +72 -4
- package/dist/icons/IconCalendarDoubleArrowForward.js +72 -4
- package/dist/icons/IconCancel.js +77 -5
- package/dist/icons/IconCancelMark.js +72 -4
- package/dist/icons/IconCarSUV.js +72 -4
- package/dist/icons/IconCarSedan.js +147 -7
- package/dist/icons/IconChain.js +79 -5
- package/dist/icons/IconCheckmark.js +72 -4
- package/dist/icons/IconChevronRight.js +72 -4
- package/dist/icons/IconCircle.js +114 -11
- package/dist/icons/IconCircleCheckmark.js +77 -5
- package/dist/icons/IconCircleError.js +72 -4
- package/dist/icons/IconCircleExclamation.js +104 -6
- package/dist/icons/IconCircleMark.js +78 -5
- package/dist/icons/IconCircleOutline.js +139 -5
- package/dist/icons/IconClock.js +80 -5
- package/dist/icons/IconClose.js +72 -4
- package/dist/icons/IconCollapseAll.js +94 -5
- package/dist/icons/IconConcierge.js +79 -5
- package/dist/icons/IconConciergeService.js +87 -5
- package/dist/icons/IconCreditCard.js +78 -5
- package/dist/icons/IconDash.js +72 -4
- package/dist/icons/IconDeliver.js +72 -4
- package/dist/icons/IconDelivery.js +87 -5
- package/dist/icons/IconDetails.js +72 -4
- package/dist/icons/IconDot.js +87 -6
- package/dist/icons/IconDownload.js +79 -5
- package/dist/icons/IconEVCharging.js +79 -5
- package/dist/icons/IconElectricCarFuel.js +80 -5
- package/dist/icons/IconEllipsis.js +78 -5
- package/dist/icons/IconEnvelope.js +72 -4
- package/dist/icons/IconExpandAll.js +94 -5
- package/dist/icons/IconEye.js +79 -5
- package/dist/icons/IconFacebook.js +94 -6
- package/dist/icons/IconFilter.js +83 -5
- package/dist/icons/IconFlagMalaysia.js +141 -5
- package/dist/icons/IconGiveKey.js +79 -5
- package/dist/icons/IconGlobe.js +70 -4
- package/dist/icons/IconGoogle.js +87 -5
- package/dist/icons/IconHome.js +78 -5
- package/dist/icons/IconHostAdvertise.js +72 -4
- package/dist/icons/IconHostCar.js +75 -4
- package/dist/icons/IconHostCash.js +91 -5
- package/dist/icons/IconHostHandle.js +70 -4
- package/dist/icons/IconHostLocation.js +70 -4
- package/dist/icons/IconHostPayment.js +91 -5
- package/dist/icons/IconHostService.js +79 -5
- package/dist/icons/IconHotDeals.js +72 -4
- package/dist/icons/IconInfo.js +77 -5
- package/dist/icons/IconInstagram.js +72 -4
- package/dist/icons/IconInsurance.js +99 -5
- package/dist/icons/IconInternet.js +73 -4
- package/dist/icons/IconInventory.js +78 -5
- package/dist/icons/IconLaurel.js +101 -5
- package/dist/icons/IconLinkedIn.js +72 -4
- package/dist/icons/IconLoading.js +78 -4
- package/dist/icons/IconLocation.js +80 -5
- package/dist/icons/IconLock.js +73 -4
- package/dist/icons/IconLogistics.js +72 -4
- package/dist/icons/IconMail.js +94 -5
- package/dist/icons/IconMember.js +78 -5
- package/dist/icons/IconMobilePen.js +83 -5
- package/dist/icons/IconMotorcycleMoped.js +78 -5
- package/dist/icons/IconNoCost.js +92 -5
- package/dist/icons/IconPDF.js +80 -5
- package/dist/icons/IconPencil.js +70 -4
- package/dist/icons/IconPhone.js +70 -4
- package/dist/icons/IconPlus.js +72 -4
- package/dist/icons/IconPricing.js +72 -4
- package/dist/icons/IconProtected.js +71 -4
- package/dist/icons/IconPsychology.js +72 -4
- package/dist/icons/IconQuestionTooltip.js +73 -4
- package/dist/icons/IconQuote.js +72 -4
- package/dist/icons/IconRate.js +71 -4
- package/dist/icons/IconRegister.js +99 -5
- package/dist/icons/IconReport.js +89 -6
- package/dist/icons/IconReturn.js +72 -4
- package/dist/icons/IconSearch.js +70 -4
- package/dist/icons/IconSecure.js +71 -4
- package/dist/icons/IconSecurity.js +73 -4
- package/dist/icons/IconSedanOutline.js +159 -5
- package/dist/icons/IconSelectArrow.js +78 -6
- package/dist/icons/IconSort.js +79 -5
- package/dist/icons/IconSortListed.js +95 -5
- package/dist/icons/IconSortPriceAscending.js +83 -5
- package/dist/icons/IconSortPriceDescending.js +83 -5
- package/dist/icons/IconSortYear.js +79 -5
- package/dist/icons/IconSpan.js +71 -4
- package/dist/icons/IconSpeaker.js +79 -4
- package/dist/icons/IconSpecialCar.js +95 -5
- package/dist/icons/IconStar.js +92 -7
- package/dist/icons/IconStockPhoto.js +95 -5
- package/dist/icons/IconSubscription.js +113 -6
- package/dist/icons/IconSubscriptions.js +113 -6
- package/dist/icons/IconSwap.js +79 -5
- package/dist/icons/IconTax.js +72 -4
- package/dist/icons/IconThinArrow.js +78 -6
- package/dist/icons/IconThumbsdown.js +78 -5
- package/dist/icons/IconThumbsup.js +78 -5
- package/dist/icons/IconTool.js +72 -4
- package/dist/icons/IconTooltip.js +73 -4
- package/dist/icons/IconTrash.js +72 -4
- package/dist/icons/IconTriangleExclamation.js +72 -4
- package/dist/icons/IconTyersBrakes.js +83 -5
- package/dist/icons/IconTyre.js +83 -5
- package/dist/icons/IconVacancy.js +78 -5
- package/dist/icons/IconVolunteer.js +72 -4
- package/dist/icons/IconWhatsapp.js +73 -4
- package/dist/icons/IconXPlatform.js +72 -4
- package/dist/icons/IconZeroEffort.js +77 -5
- package/dist/icons/Logo.js +99 -3
- package/dist/input/Input.js +125 -11
- package/dist/input/Input.stories.js +17 -18
- package/dist/input-mask/InputMask.js +149 -11
- package/dist/input-mask/InputMask.stories.js +5 -6
- package/dist/input-mask/mask-trackers.js +4 -5
- package/dist/input-select/InputSelect.js +357 -68
- package/dist/input-select/InputSelect.stories.js +98 -25
- package/dist/popover/popover.js +72 -4
- package/dist/progress/Progress.js +96 -2
- package/dist/progress/Progress.stories.js +13 -14
- package/dist/radio/Radio.js +163 -4
- package/dist/scroll-area/scroll-area.js +113 -5
- package/dist/search-input-select/SearchInputSelect.js +346 -69
- package/dist/select/Select.js +315 -29
- package/dist/select/Select.stories.js +55 -19
- package/dist/skeleton/Skeleton.js +62 -3
- package/dist/skeleton/Skeleton.stories.js +8 -7
- package/dist/slider/Slider.js +106 -5
- package/dist/slider/Slider.stories.js +12 -11
- package/dist/stack/Stack.js +63 -3
- package/dist/stack/Stack.stories.js +19 -7
- package/dist/table/Table.js +131 -10
- package/dist/table/Table.stories.js +84 -8
- package/dist/tabs/Tabs.js +128 -9
- package/dist/tabs/Tabs.stories.js +46 -13
- package/dist/text/Text.js +88 -6
- package/dist/text/Text.stories.js +44 -7
- package/dist/toast/Toast.stories.js +66 -14
- package/dist/toast/ToastBox.js +77 -29
- package/dist/toast/index.js +0 -1
- package/dist/toast/sonner.js +66 -6
- package/dist/toggle/Toggle.js +116 -7
- package/dist/toggle/Toggle.stories.js +10 -8
- package/dist/tooltip/Tooltip.js +151 -12
- package/dist/tooltip/Tooltip.stories.js +71 -13
- package/dist/utils.js +4 -2
- package/dist/vstack/VStack.js +63 -3
- package/dist/vstack/VStack.stories.js +19 -7
- package/package.json +1 -1
|
@@ -1,4 +1,129 @@
|
|
|
1
1
|
'use client';
|
|
2
|
+
function _array_like_to_array(arr, len) {
|
|
3
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
4
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
5
|
+
return arr2;
|
|
6
|
+
}
|
|
7
|
+
function _array_with_holes(arr) {
|
|
8
|
+
if (Array.isArray(arr)) return arr;
|
|
9
|
+
}
|
|
10
|
+
function _define_property(obj, key, value) {
|
|
11
|
+
if (key in obj) {
|
|
12
|
+
Object.defineProperty(obj, key, {
|
|
13
|
+
value: value,
|
|
14
|
+
enumerable: true,
|
|
15
|
+
configurable: true,
|
|
16
|
+
writable: true
|
|
17
|
+
});
|
|
18
|
+
} else {
|
|
19
|
+
obj[key] = value;
|
|
20
|
+
}
|
|
21
|
+
return obj;
|
|
22
|
+
}
|
|
23
|
+
function _iterable_to_array_limit(arr, i) {
|
|
24
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
25
|
+
if (_i == null) return;
|
|
26
|
+
var _arr = [];
|
|
27
|
+
var _n = true;
|
|
28
|
+
var _d = false;
|
|
29
|
+
var _s, _e;
|
|
30
|
+
try {
|
|
31
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
32
|
+
_arr.push(_s.value);
|
|
33
|
+
if (i && _arr.length === i) break;
|
|
34
|
+
}
|
|
35
|
+
} catch (err) {
|
|
36
|
+
_d = true;
|
|
37
|
+
_e = err;
|
|
38
|
+
} finally{
|
|
39
|
+
try {
|
|
40
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
41
|
+
} finally{
|
|
42
|
+
if (_d) throw _e;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return _arr;
|
|
46
|
+
}
|
|
47
|
+
function _non_iterable_rest() {
|
|
48
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
49
|
+
}
|
|
50
|
+
function _object_spread(target) {
|
|
51
|
+
for(var i = 1; i < arguments.length; i++){
|
|
52
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
53
|
+
var ownKeys = Object.keys(source);
|
|
54
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
55
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
56
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
ownKeys.forEach(function(key) {
|
|
60
|
+
_define_property(target, key, source[key]);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return target;
|
|
64
|
+
}
|
|
65
|
+
function ownKeys(object, enumerableOnly) {
|
|
66
|
+
var keys = Object.keys(object);
|
|
67
|
+
if (Object.getOwnPropertySymbols) {
|
|
68
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
69
|
+
if (enumerableOnly) {
|
|
70
|
+
symbols = symbols.filter(function(sym) {
|
|
71
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
keys.push.apply(keys, symbols);
|
|
75
|
+
}
|
|
76
|
+
return keys;
|
|
77
|
+
}
|
|
78
|
+
function _object_spread_props(target, source) {
|
|
79
|
+
source = source != null ? source : {};
|
|
80
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
81
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
82
|
+
} else {
|
|
83
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
84
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return target;
|
|
88
|
+
}
|
|
89
|
+
function _object_without_properties(source, excluded) {
|
|
90
|
+
if (source == null) return {};
|
|
91
|
+
var target = _object_without_properties_loose(source, excluded);
|
|
92
|
+
var key, i;
|
|
93
|
+
if (Object.getOwnPropertySymbols) {
|
|
94
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
95
|
+
for(i = 0; i < sourceSymbolKeys.length; i++){
|
|
96
|
+
key = sourceSymbolKeys[i];
|
|
97
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
98
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
99
|
+
target[key] = source[key];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return target;
|
|
103
|
+
}
|
|
104
|
+
function _object_without_properties_loose(source, excluded) {
|
|
105
|
+
if (source == null) return {};
|
|
106
|
+
var target = {};
|
|
107
|
+
var sourceKeys = Object.keys(source);
|
|
108
|
+
var key, i;
|
|
109
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
110
|
+
key = sourceKeys[i];
|
|
111
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
112
|
+
target[key] = source[key];
|
|
113
|
+
}
|
|
114
|
+
return target;
|
|
115
|
+
}
|
|
116
|
+
function _sliced_to_array(arr, i) {
|
|
117
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
118
|
+
}
|
|
119
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
120
|
+
if (!o) return;
|
|
121
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
122
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
123
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
124
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
125
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
126
|
+
}
|
|
2
127
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
128
|
import { Command as CommandPrimitive } from 'cmdk';
|
|
4
129
|
import * as React from 'react';
|
|
@@ -7,29 +132,65 @@ import Box from '../box/Box';
|
|
|
7
132
|
import FieldWrapper from '../field-wrapper/FieldWrapper';
|
|
8
133
|
import IconSearch from '../icons/IconSearch';
|
|
9
134
|
import { cn } from '../utils';
|
|
10
|
-
|
|
135
|
+
var Command = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
|
|
136
|
+
var className = _param.className, props = _object_without_properties(_param, [
|
|
137
|
+
"className"
|
|
138
|
+
]);
|
|
139
|
+
return /*#__PURE__*/ _jsx(CommandPrimitive, _object_spread({
|
|
140
|
+
ref: ref,
|
|
141
|
+
className: cn('flex relative w-full', className)
|
|
142
|
+
}, props));
|
|
143
|
+
});
|
|
11
144
|
Command.displayName = CommandPrimitive.displayName;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
145
|
+
var CommandInput = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
|
|
146
|
+
var className = _param.className, error = _param.error, prefix = _param.prefix, isFocused = _param.isFocused, isSelected = _param.isSelected, handleToggle = _param.handleToggle, handleClear = _param.handleClear, props = _object_without_properties(_param, [
|
|
147
|
+
"className",
|
|
148
|
+
"error",
|
|
149
|
+
"prefix",
|
|
150
|
+
"isFocused",
|
|
151
|
+
"isSelected",
|
|
152
|
+
"handleToggle",
|
|
153
|
+
"handleClear"
|
|
154
|
+
]);
|
|
155
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
156
|
+
ref: ref,
|
|
157
|
+
className: cn('flex items-center h-12 w-full border border-primary2 bg-white text-sm cursor-pointer outline-hidden file:border-0 file:bg-transparent file:text-sm file:font-medium hover:border-black focus-within:border-black focus-within:outline-hidden disabled:cursor-not-allowed disabled:opacity-50', error && 'border-alert4 hover:border-alert4 focus-within:border-alert4', className),
|
|
158
|
+
children: [
|
|
159
|
+
prefix,
|
|
160
|
+
/*#__PURE__*/ _jsx(IconSearch, {
|
|
161
|
+
className: "text-primary3 m-2",
|
|
162
|
+
size: '20px',
|
|
163
|
+
title: "Search"
|
|
164
|
+
}),
|
|
165
|
+
/*#__PURE__*/ _jsx(CommandPrimitive.Input, _object_spread_props(_object_spread({
|
|
166
|
+
className: cn('border-none h-full w-full px-3 outline-hidden text-ellipsis placeholder:text-primary2 placeholder:tracking-wide cursor-pointer')
|
|
167
|
+
}, props), {
|
|
168
|
+
onClick: function(_e) {
|
|
169
|
+
if (isSelected) {
|
|
170
|
+
isFocused = true;
|
|
171
|
+
} else if (!isFocused) {
|
|
172
|
+
handleToggle();
|
|
173
|
+
}
|
|
15
174
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
175
|
+
}))
|
|
176
|
+
]
|
|
177
|
+
});
|
|
178
|
+
});
|
|
20
179
|
CommandInput.displayName = CommandPrimitive.Input.displayName;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
180
|
+
var CommandList = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
|
|
181
|
+
var className = _param.className, props = _object_without_properties(_param, [
|
|
182
|
+
"className"
|
|
183
|
+
]);
|
|
184
|
+
var _React_useState = _sliced_to_array(React.useState('bottom'), 2), position = _React_useState[0], setPosition = _React_useState[1];
|
|
185
|
+
useEffect(function() {
|
|
186
|
+
var handlePosition = function() {
|
|
25
187
|
if (ref && 'current' in ref && ref.current) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
188
|
+
var rect = ref.current.getBoundingClientRect();
|
|
189
|
+
var spaceBelow = window.innerHeight - rect.bottom;
|
|
190
|
+
var spaceAbove = rect.top;
|
|
29
191
|
if (spaceBelow < 200 && spaceAbove > spaceBelow) {
|
|
30
192
|
setPosition('top');
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
193
|
+
} else {
|
|
33
194
|
setPosition('bottom');
|
|
34
195
|
}
|
|
35
196
|
}
|
|
@@ -37,101 +198,217 @@ const CommandList = React.forwardRef(({ className, ...props }, ref) => {
|
|
|
37
198
|
handlePosition();
|
|
38
199
|
window.addEventListener('resize', handlePosition);
|
|
39
200
|
window.addEventListener('scroll', handlePosition);
|
|
40
|
-
return ()
|
|
201
|
+
return function() {
|
|
41
202
|
window.removeEventListener('resize', handlePosition);
|
|
42
203
|
window.removeEventListener('scroll', handlePosition);
|
|
43
204
|
};
|
|
44
|
-
}, [
|
|
45
|
-
|
|
205
|
+
}, [
|
|
206
|
+
ref
|
|
207
|
+
]);
|
|
208
|
+
return /*#__PURE__*/ _jsx(CommandPrimitive.List, _object_spread({
|
|
209
|
+
ref: ref,
|
|
210
|
+
className: cn('max-h-80 absolute left-0 right-0 mt-1 shadow-md overflow-y-auto overflow-x-hidden z-10 bg-white', position === 'top' ? 'bottom-full mb-1' : 'top-full mt-1', className)
|
|
211
|
+
}, props));
|
|
46
212
|
});
|
|
47
213
|
CommandList.displayName = CommandPrimitive.List.displayName;
|
|
48
|
-
|
|
214
|
+
var CommandEmpty = /*#__PURE__*/ React.forwardRef(function(props, ref) {
|
|
215
|
+
return /*#__PURE__*/ _jsx(CommandPrimitive.Empty, _object_spread({
|
|
216
|
+
ref: ref,
|
|
217
|
+
className: "p-4 text-center text-sm text-primary3"
|
|
218
|
+
}, props));
|
|
219
|
+
});
|
|
49
220
|
CommandEmpty.displayName = CommandPrimitive.Empty.displayName;
|
|
50
|
-
|
|
221
|
+
var CommandGroup = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
|
|
222
|
+
var className = _param.className, props = _object_without_properties(_param, [
|
|
223
|
+
"className"
|
|
224
|
+
]);
|
|
225
|
+
return /*#__PURE__*/ _jsx(CommandPrimitive.Group, _object_spread({
|
|
226
|
+
ref: ref,
|
|
227
|
+
className: cn('overflow-hidden p-1 text-zinc-950 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-zinc-500 dark:text-zinc-50 dark:[&_[cmdk-group-heading]]:text-zinc-400', className)
|
|
228
|
+
}, props));
|
|
229
|
+
});
|
|
51
230
|
CommandGroup.displayName = CommandPrimitive.Group.displayName;
|
|
52
|
-
|
|
231
|
+
var CommandSeparator = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
|
|
232
|
+
var className = _param.className, props = _object_without_properties(_param, [
|
|
233
|
+
"className"
|
|
234
|
+
]);
|
|
235
|
+
return /*#__PURE__*/ _jsx(CommandPrimitive.Separator, _object_spread({
|
|
236
|
+
ref: ref,
|
|
237
|
+
className: cn('-mx-1 h-px bg-zinc-200 dark:bg-zinc-800', className)
|
|
238
|
+
}, props));
|
|
239
|
+
});
|
|
53
240
|
CommandSeparator.displayName = CommandPrimitive.Separator.displayName;
|
|
54
|
-
|
|
241
|
+
var CommandItem = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
|
|
242
|
+
var className = _param.className, props = _object_without_properties(_param, [
|
|
243
|
+
"className"
|
|
244
|
+
]);
|
|
245
|
+
return /*#__PURE__*/ _jsx(CommandPrimitive.Item, _object_spread({
|
|
246
|
+
ref: ref,
|
|
247
|
+
className: cn('relative flex cursor-pointer select-none items-center rounded-xs px-4 h-10 text-sm outline-hidden data-[disabled=true]:pointer-events-none data-[disabled=true]:bg-primary1 data-[disabled=true]:text-primary2 data-[selected=true]:bg-zinc-100 data-[selected=true]:text-zinc-900 data-[disabled=true]:opacity-50 dark:data-[selected=true]:bg-zinc-800 dark:data-[selected=true]:text-zinc-50', className)
|
|
248
|
+
}, props));
|
|
249
|
+
});
|
|
55
250
|
CommandItem.displayName = CommandPrimitive.Item.displayName;
|
|
56
|
-
|
|
57
|
-
|
|
251
|
+
var CommandShortcut = function(_param) {
|
|
252
|
+
var className = _param.className, props = _object_without_properties(_param, [
|
|
253
|
+
"className"
|
|
254
|
+
]);
|
|
255
|
+
return /*#__PURE__*/ _jsx("span", _object_spread({
|
|
256
|
+
className: cn('ml-auto text-xs tracking-widest text-zinc-500 dark:text-zinc-400', className)
|
|
257
|
+
}, props));
|
|
58
258
|
};
|
|
59
259
|
CommandShortcut.displayName = 'CommandShortcut';
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
// for wrapper
|
|
63
|
-
wrapperProps, htmlFor, label, showRequired, showOptional, outerPrefix, outerSuffix, error,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
260
|
+
var SearchInputSelect = /*#__PURE__*/ React.forwardRef(function(props, _ref) {
|
|
261
|
+
var _options_find;
|
|
262
|
+
var // for wrapper
|
|
263
|
+
wrapperProps = props.wrapperProps, htmlFor = props.htmlFor, label = props.label, showRequired = props.showRequired, showOptional = props.showOptional, outerPrefix = props.outerPrefix, outerSuffix = props.outerSuffix, error = props.error, // for Select-input-search
|
|
264
|
+
providedValue = props.value, placeholder = props.placeholder, prefix = props.prefix, options = props.options, noOptionsText = props.noOptionsText, onChange = props.onChange, _props_isClearable = props.isClearable, isClearable = _props_isClearable === void 0 ? true : _props_isClearable, children = props.children, selectProps = _object_without_properties(props, [
|
|
265
|
+
"wrapperProps",
|
|
266
|
+
"htmlFor",
|
|
267
|
+
"label",
|
|
268
|
+
"showRequired",
|
|
269
|
+
"showOptional",
|
|
270
|
+
"outerPrefix",
|
|
271
|
+
"outerSuffix",
|
|
272
|
+
"error",
|
|
273
|
+
"value",
|
|
274
|
+
"placeholder",
|
|
275
|
+
"prefix",
|
|
276
|
+
"options",
|
|
277
|
+
"noOptionsText",
|
|
278
|
+
"onChange",
|
|
279
|
+
"isClearable",
|
|
280
|
+
"children"
|
|
281
|
+
]);
|
|
282
|
+
var _React_useState = _sliced_to_array(React.useState(false), 2), isFocused = _React_useState[0], setIsFocused = _React_useState[1];
|
|
283
|
+
var _React_useState1 = _sliced_to_array(React.useState(''), 2), search = _React_useState1[0], setSearch = _React_useState1[1];
|
|
284
|
+
var _React_useState2 = _sliced_to_array(React.useState(providedValue), 2), value = _React_useState2[0], setValue = _React_useState2[1];
|
|
285
|
+
var _React_useState3 = _sliced_to_array(React.useState(false), 2), showAll = _React_useState3[0], setShowAll = _React_useState3[1];
|
|
286
|
+
var inputRef = React.useRef(null);
|
|
287
|
+
var listRef = React.useRef(null);
|
|
288
|
+
var wrapperRef = React.useRef(null);
|
|
289
|
+
var filteredOptions = React.useMemo(function() {
|
|
290
|
+
return options.filter(function(option) {
|
|
291
|
+
return typeof option.label === 'string' && option.label.toLowerCase().includes(search.toLowerCase());
|
|
292
|
+
});
|
|
293
|
+
}, [
|
|
294
|
+
search,
|
|
295
|
+
options
|
|
296
|
+
]);
|
|
297
|
+
var displayedOptions = showAll ? filteredOptions : filteredOptions.slice(0, 5);
|
|
298
|
+
var handleFocus = function() {
|
|
81
299
|
setIsFocused(true);
|
|
82
300
|
};
|
|
83
|
-
|
|
301
|
+
var handleBlur = function(e) {
|
|
84
302
|
if (e.relatedTarget === null) {
|
|
303
|
+
var _inputRef_current;
|
|
85
304
|
setIsFocused(false);
|
|
86
|
-
inputRef.current
|
|
305
|
+
(_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.blur();
|
|
87
306
|
}
|
|
88
307
|
};
|
|
89
|
-
|
|
308
|
+
var handleChange = function(value) {
|
|
90
309
|
setSearch(value);
|
|
91
310
|
};
|
|
92
|
-
|
|
311
|
+
var handleSelect = function(option) {
|
|
312
|
+
var _inputRef_current;
|
|
93
313
|
setSearch(option.label);
|
|
94
|
-
onChange
|
|
314
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(option.value);
|
|
95
315
|
setValue(option.value);
|
|
96
316
|
setIsFocused(false);
|
|
97
|
-
inputRef.current
|
|
317
|
+
(_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.focus();
|
|
98
318
|
};
|
|
99
|
-
|
|
100
|
-
setIsFocused((isFocused)
|
|
101
|
-
|
|
319
|
+
var handleToggle = function() {
|
|
320
|
+
setIsFocused(function(isFocused) {
|
|
321
|
+
var _inputRef_current;
|
|
322
|
+
isFocused && ((_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.blur());
|
|
102
323
|
return !isFocused;
|
|
103
324
|
});
|
|
104
325
|
};
|
|
105
|
-
|
|
326
|
+
var handleClear = function(event) {
|
|
106
327
|
event.preventDefault();
|
|
107
328
|
event.stopPropagation();
|
|
108
329
|
setSearch('');
|
|
109
330
|
setIsFocused(false);
|
|
110
|
-
onChange
|
|
331
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(undefined);
|
|
111
332
|
setValue(undefined);
|
|
112
333
|
};
|
|
113
|
-
|
|
114
|
-
if (wrapperRef.current &&
|
|
115
|
-
!wrapperRef.current.contains(event.target)) {
|
|
334
|
+
var handleClickOutside = function(event) {
|
|
335
|
+
if (wrapperRef.current && !wrapperRef.current.contains(event.target)) {
|
|
116
336
|
setIsFocused(false);
|
|
117
337
|
}
|
|
118
338
|
};
|
|
119
|
-
|
|
120
|
-
setShowAll((prev)
|
|
339
|
+
var handleShowAll = function() {
|
|
340
|
+
setShowAll(function(prev) {
|
|
341
|
+
return !prev;
|
|
342
|
+
});
|
|
121
343
|
if (filteredOptions.length > 5) {
|
|
122
344
|
setShowAll(true);
|
|
123
345
|
}
|
|
124
346
|
};
|
|
125
347
|
// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
|
|
126
|
-
React.useEffect(()
|
|
348
|
+
React.useEffect(function() {
|
|
127
349
|
document.addEventListener('mousedown', handleClickOutside);
|
|
128
|
-
return ()
|
|
350
|
+
return function() {
|
|
129
351
|
document.removeEventListener('mousedown', handleClickOutside);
|
|
130
352
|
};
|
|
131
353
|
}, []);
|
|
132
|
-
return
|
|
133
|
-
|
|
134
|
-
|
|
354
|
+
return /*#__PURE__*/ _jsx(FieldWrapper, _object_spread_props(_object_spread({
|
|
355
|
+
htmlFor: htmlFor,
|
|
356
|
+
label: label,
|
|
357
|
+
showOptional: showOptional,
|
|
358
|
+
showRequired: showRequired,
|
|
359
|
+
error: error
|
|
360
|
+
}, wrapperProps), {
|
|
361
|
+
children: /*#__PURE__*/ _jsx("div", {
|
|
362
|
+
ref: wrapperRef,
|
|
363
|
+
className: "relative w-full",
|
|
364
|
+
children: /*#__PURE__*/ _jsxs(Command, {
|
|
365
|
+
shouldFilter: false,
|
|
366
|
+
onFocus: handleFocus,
|
|
367
|
+
onBlur: handleBlur,
|
|
368
|
+
children: [
|
|
369
|
+
/*#__PURE__*/ _jsx(CommandInput, _object_spread_props(_object_spread({}, selectProps), {
|
|
370
|
+
ref: inputRef,
|
|
371
|
+
placeholder: placeholder,
|
|
372
|
+
value: isFocused ? search : ((_options_find = options.find(function(option) {
|
|
373
|
+
return option.value === value;
|
|
374
|
+
})) === null || _options_find === void 0 ? void 0 : _options_find.label) || '',
|
|
375
|
+
isFocused: isFocused,
|
|
376
|
+
isSelected: !!value,
|
|
377
|
+
onValueChange: handleChange,
|
|
378
|
+
handleToggle: handleToggle,
|
|
379
|
+
handleClear: handleClear
|
|
380
|
+
})),
|
|
381
|
+
/*#__PURE__*/ _jsx(CommandList, {
|
|
382
|
+
ref: listRef,
|
|
383
|
+
children: isFocused && !value && /*#__PURE__*/ _jsxs(_Fragment, {
|
|
384
|
+
children: [
|
|
385
|
+
displayedOptions.length > 0 ? displayedOptions.map(function(option) {
|
|
386
|
+
return /*#__PURE__*/ _jsx(CommandItem, {
|
|
387
|
+
value: JSON.stringify(option.value),
|
|
388
|
+
disabled: option.isDisabled,
|
|
389
|
+
onSelect: function() {
|
|
390
|
+
return handleSelect(option);
|
|
391
|
+
},
|
|
392
|
+
className: "tracking-normal text-primary3 w-full",
|
|
393
|
+
children: option.label
|
|
394
|
+
}, option.label);
|
|
395
|
+
}) : /*#__PURE__*/ _jsx(CommandEmpty, {
|
|
396
|
+
children: noOptionsText || 'No options'
|
|
397
|
+
}),
|
|
398
|
+
filteredOptions.length > 5 && !showAll && /*#__PURE__*/ _jsx(Box, {
|
|
399
|
+
className: cn('text-links text-sm font-bold text-center tracking-wide', 'p-2 items-center'),
|
|
400
|
+
as: "button",
|
|
401
|
+
type: "button",
|
|
402
|
+
onClick: handleShowAll,
|
|
403
|
+
children: showAll ? 'Show less' : 'Show all results'
|
|
404
|
+
}),
|
|
405
|
+
children
|
|
406
|
+
]
|
|
407
|
+
})
|
|
408
|
+
})
|
|
409
|
+
]
|
|
410
|
+
})
|
|
411
|
+
})
|
|
412
|
+
}));
|
|
135
413
|
});
|
|
136
414
|
export default SearchInputSelect;
|
|
137
|
-
//# sourceMappingURL=SearchInputSelect.js.map
|