@matbea-ui/matbea-ui 0.2.0-dev.573256 → 0.2.0-dev.600564
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/matbea-ui.cjs.js +26 -8
- package/dist/matbea-ui.cjs.js.map +1 -1
- package/dist/matbea-ui.es.js +26 -8
- package/dist/matbea-ui.es.js.map +1 -1
- package/dist/types/index.d.ts +3 -0
- package/package.json +1 -1
package/dist/matbea-ui.cjs.js
CHANGED
|
@@ -1286,6 +1286,7 @@ const List = styled.styled.div `
|
|
|
1286
1286
|
width: ${({ $width }) => `${$width}px`};
|
|
1287
1287
|
z-index: 999;
|
|
1288
1288
|
border-radius: 5px;
|
|
1289
|
+
overflow-x: hidden;
|
|
1289
1290
|
border: 1px solid ${({ theme }) => theme.colors.gray.lightGray2};
|
|
1290
1291
|
background: ${({ theme }) => theme.colors.primary.white};
|
|
1291
1292
|
box-shadow: 0px 8px 24px rgba(15, 23, 42, 0.12);
|
|
@@ -1293,6 +1294,7 @@ const List = styled.styled.div `
|
|
|
1293
1294
|
flex-direction: column;
|
|
1294
1295
|
max-height: 260px;
|
|
1295
1296
|
overflow-y: auto;
|
|
1297
|
+
padding-bottom: 8px;
|
|
1296
1298
|
`;
|
|
1297
1299
|
const Option = styled.styled.button `
|
|
1298
1300
|
display: flex;
|
|
@@ -1330,12 +1332,18 @@ const OptionIcon = styled.styled.span `
|
|
|
1330
1332
|
width: 24px;
|
|
1331
1333
|
height: 24px;
|
|
1332
1334
|
`;
|
|
1335
|
+
const SearchInput = styled.styled(TextField) `
|
|
1336
|
+
margin: 16px 12px 4px 12px;
|
|
1337
|
+
display: flex;
|
|
1338
|
+
width: inherit;
|
|
1339
|
+
`;
|
|
1333
1340
|
|
|
1334
1341
|
const DROPDOWN_OFFSET = 8;
|
|
1335
|
-
const SelectField = React__default.forwardRef(({ options = [], value, defaultValue, placeholder = "Text", label, error, disabled = false, icon, name, onChange, onFocus, onBlur, className, }, ref) => {
|
|
1342
|
+
const SelectField = React__default.forwardRef(({ options = [], value, defaultValue, placeholder = "Text", label, searchInput = false, searchPlaceholder = "Search", error, disabled = false, icon, name, onChange, onFocus, onBlur, className, }, ref) => {
|
|
1336
1343
|
const wrapperRef = React__default.useRef(null);
|
|
1337
1344
|
const fieldRef = React__default.useRef(null);
|
|
1338
1345
|
const listRef = React__default.useRef(null);
|
|
1346
|
+
const [searchValue, setSearchValue] = React__default.useState("");
|
|
1339
1347
|
const [isOpen, setIsOpen] = React__default.useState(false);
|
|
1340
1348
|
const [focused, setFocused] = React__default.useState(false);
|
|
1341
1349
|
const [internalValue, setInternalValue] = React__default.useState(defaultValue ?? "");
|
|
@@ -1457,12 +1465,18 @@ const SelectField = React__default.forwardRef(({ options = [], value, defaultVal
|
|
|
1457
1465
|
onBlur?.(evt);
|
|
1458
1466
|
};
|
|
1459
1467
|
const includeOption = options.find((opt) => opt.value === selectedValue);
|
|
1468
|
+
const data = React__default.useMemo(() => {
|
|
1469
|
+
if (searchInput && searchValue?.trim() !== "") {
|
|
1470
|
+
return options.filter((opt) => [opt.label.toLowerCase(), opt.value.toLowerCase()].includes(searchValue.toLocaleLowerCase()));
|
|
1471
|
+
}
|
|
1472
|
+
return options;
|
|
1473
|
+
}, [options, searchInput, searchValue]);
|
|
1460
1474
|
return (jsxRuntime.jsxs(Wrapper, { "data-select-field": "true", className: className, ref: wrapperRef, onKeyDown: handleKeyDown, onFocus: handleFocus, onBlur: handleBlur, onClick: (e) => e.stopPropagation(), children: [label && jsxRuntime.jsx(Label$1, { children: label }), jsxRuntime.jsxs(FieldContainer, { ref: fieldRef, role: "button", tabIndex: disabled ? -1 : 0, "aria-haspopup": "listbox", "aria-expanded": isOpen, "aria-invalid": hasError, "aria-disabled": disabled, "$hasError": hasError, "$disabled": disabled, "data-state": hasError ? "error" : isOpen || focused ? "active" : undefined, onClick: toggleDropdown, children: [icon ||
|
|
1461
|
-
(includeOption?.icon && (jsxRuntime.jsx(LeadingIcon, { children: icon || includeOption.icon }))), jsxRuntime.jsx(Value, { "$placeholder": displayPlaceholder, children: displayText }), jsxRuntime.jsx(HiddenInput$1, { ref: ref, readOnly: true, name: name, value: selectedValue, tabIndex: -1, "aria-hidden": true })] }), error && jsxRuntime.jsx(ErrorText, { children: error }), isOpen && (jsxRuntime.
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1475
|
+
(includeOption?.icon && (jsxRuntime.jsx(LeadingIcon, { children: icon || includeOption.icon }))), jsxRuntime.jsx(Value, { "$placeholder": displayPlaceholder, children: displayText }), jsxRuntime.jsx(HiddenInput$1, { ref: ref, readOnly: true, name: name, value: selectedValue, tabIndex: -1, "aria-hidden": true })] }), error && jsxRuntime.jsx(ErrorText, { children: error }), isOpen && (jsxRuntime.jsxs(List, { ref: listRef, role: "listbox", "$width": dropdownRect.width, children: [searchInput && (jsxRuntime.jsx("div", { children: jsxRuntime.jsx(SearchInput, { icon: jsxRuntime.jsx(SearchIcon, {}), value: searchValue, placeholder: searchPlaceholder, onChange: (e) => setSearchValue(e.target.value) }) })), data.map((option, index) => {
|
|
1476
|
+
const isActiveOption = option.value === selectedValue;
|
|
1477
|
+
const isHovered = index === hoveredIndex;
|
|
1478
|
+
return (jsxRuntime.jsxs(Option, { role: "option", "aria-selected": isActiveOption, "data-active": isActiveOption || undefined, "data-hovered": isHovered || undefined, onMouseEnter: () => setHoveredIndex(index), onMouseLeave: () => setHoveredIndex(null), onMouseDown: (evt) => evt.preventDefault(), onClick: () => handleSelect(option), children: [option.icon && jsxRuntime.jsx(OptionIcon, { children: option.icon }), jsxRuntime.jsx(OptionText, { variant: "form-input", children: option.label })] }, option.value));
|
|
1479
|
+
})] }))] }));
|
|
1466
1480
|
});
|
|
1467
1481
|
SelectField.displayName = "SelectField";
|
|
1468
1482
|
|
|
@@ -2220,6 +2234,10 @@ const LangCountrySelectContainer = styled.styled.div `
|
|
|
2220
2234
|
min-width: 200px;
|
|
2221
2235
|
width: fit-content;
|
|
2222
2236
|
cursor: pointer;
|
|
2237
|
+
background: ${({ theme }) => theme.colors.primary.white};
|
|
2238
|
+
&:hover {
|
|
2239
|
+
border-color: ${({ theme }) => theme.colors.primary.primaryBlue};
|
|
2240
|
+
}
|
|
2223
2241
|
`;
|
|
2224
2242
|
const LangCountrySelectDropdown = styled.styled.div `
|
|
2225
2243
|
display: flex;
|
|
@@ -2263,7 +2281,7 @@ const LangCountrySelectButton = styled.styled(Button$1) `
|
|
|
2263
2281
|
width: fit-content;
|
|
2264
2282
|
`;
|
|
2265
2283
|
|
|
2266
|
-
const LangCountrySelect = ({ currentLang, currentCurrency, currentCountry, countries = [], currencies = [], languages = [], handleSave, labelLang, labelCurrency, labelCountry, saveText, }) => {
|
|
2284
|
+
const LangCountrySelect = ({ currentLang, currentCurrency, currentCountry, countries = [], currencies = [], languages = [], handleSave, labelLang, labelCurrency, labelCountry, saveText, searchPlaceholder, }) => {
|
|
2267
2285
|
const [isOpen, setIsOpen] = React__default.useState(false);
|
|
2268
2286
|
const ref = React__default.useRef(null);
|
|
2269
2287
|
const [lang, setLang] = React__default.useState(currentLang);
|
|
@@ -2296,7 +2314,7 @@ const LangCountrySelect = ({ currentLang, currentCurrency, currentCountry, count
|
|
|
2296
2314
|
}, [isOpen]);
|
|
2297
2315
|
return (jsxRuntime.jsxs(LangCountrySelectStyled, { ref: ref, children: [jsxRuntime.jsxs(LangCountrySelectContainer, { onClick: handleClick, children: [includedCurrency?.icon && (jsxRuntime.jsx(LangCountrySelectIcon, { children: includedCurrency?.icon })), jsxRuntime.jsx(LangCountrySelectLabel, { children: [includedCurrency?.value, includedLang?.label]
|
|
2298
2316
|
.join(" / ")
|
|
2299
|
-
?.toLocaleUpperCase() }), jsxRuntime.jsx(LangCountrySelectArrow, { "$open": isOpen, size: 9 })] }), jsxRuntime.jsxs(LangCountrySelectDropdown, { "$open": isOpen, children: [jsxRuntime.jsx(SelectField, { placeholder: "", label: labelLang, options: languages, value: lang, onChange: setLang }), jsxRuntime.jsx(SelectField, { icon: includedCurrency?.icon, placeholder: "", label: labelCurrency, options: currencies, value: currency, onChange: setCurrency }), jsxRuntime.jsx(SelectField, { icon: includedCountry?.icon, placeholder: "", label: labelCountry, options: countries, value: country, onChange: setCountry }), jsxRuntime.jsx(LangCountrySelectButton, { size: "medium", onClick: handleClickSave, children: saveText })] })] }));
|
|
2317
|
+
?.toLocaleUpperCase() }), jsxRuntime.jsx(LangCountrySelectArrow, { "$open": isOpen, size: 9 })] }), jsxRuntime.jsxs(LangCountrySelectDropdown, { "$open": isOpen, children: [jsxRuntime.jsx(SelectField, { placeholder: "", label: labelLang, options: languages, value: lang, onChange: setLang }), jsxRuntime.jsx(SelectField, { icon: includedCurrency?.icon, placeholder: "", label: labelCurrency, options: currencies, value: currency, onChange: setCurrency }), jsxRuntime.jsx(SelectField, { icon: includedCountry?.icon, placeholder: "", label: labelCountry, options: countries, value: country, onChange: setCountry, searchPlaceholder: searchPlaceholder, searchInput: true }), jsxRuntime.jsx(LangCountrySelectButton, { size: "medium", onClick: handleClickSave, children: saveText })] })] }));
|
|
2300
2318
|
};
|
|
2301
2319
|
|
|
2302
2320
|
const ApplicationDataStyled = styled.styled.div `
|