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