@tmlmobilidade/ui 20250128.1609.43 → 20250128.1647.0

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/cjs/index.js CHANGED
@@ -6,11 +6,12 @@ var core = require('@mantine/core');
6
6
  var clsx = require('clsx');
7
7
  var luxon = require('luxon');
8
8
  var iconsReact = require('@tabler/icons-react');
9
+ var reactViewportList = require('react-viewport-list');
9
10
  var dates = require('@mantine/dates');
10
11
  var modals = require('@mantine/modals');
11
12
  var notifications = require('@mantine/notifications');
12
13
  var hooks = require('@mantine/hooks');
13
- var reactViewportList = require('react-viewport-list');
14
+ var form = require('@mantine/form');
14
15
 
15
16
  function _interopNamespaceDefault(e) {
16
17
  var n = Object.create(null);
@@ -860,7 +861,7 @@ function Component({ classNames, ...props }) {
860
861
  var styles$i = {"wrapper":"styles-module_wrapper__7zsRX","input":"styles-module_input__kZP4l","placeholder":"styles-module_placeholder__uazW4","pillInputWrapper":"styles-module_pillInputWrapper__rtJzo","pillInputField":"styles-module_pillInputField__LYXhi","icon":"styles-module_icon__jXQ8R","pillClearButton":"styles-module_pillClearButton__RYrwJ","pill":"styles-module_pill__eWbVa","label":"styles-module_label__tB0Ce","description":"styles-module_description__KHjxV","dropdownWrapper":"styles-module_dropdownWrapper__guQYa"};
861
862
 
862
863
  function ComboboxComponent(props) {
863
- const { multiple = false, searchable = false, autoComplete = false, onChange, data = [], clearable = false, label, description, fullWidth = false, className, ...rest } = props;
864
+ const { multiple = false, searchable = false, autoComplete = false, onChange, data = [], clearable = false, label, description, fullWidth = false, maxHeight = 200, className, ...rest } = props;
864
865
  // Setup Combobox store
865
866
  const combobox = core.useCombobox({
866
867
  onDropdownClose: () => combobox.resetSelectedOption(),
@@ -891,7 +892,7 @@ function ComboboxComponent(props) {
891
892
  function updateValue(val) {
892
893
  if (multiple && Array.isArray(value)) {
893
894
  let updatedValue;
894
- if (value.some(v => getValue(v) === getValue(val))) {
895
+ if (value.some((v) => getValue(v) === getValue(val))) {
895
896
  updatedValue = value.filter((v) => getValue(v) !== getValue(val));
896
897
  }
897
898
  else {
@@ -925,9 +926,15 @@ function ComboboxComponent(props) {
925
926
  * Filters data based on search input.
926
927
  */
927
928
  function filterData() {
928
- return searchable ? data.filter((item) => typeof item === 'string' ?
929
- item.toLowerCase().includes(search.trim().toLowerCase()) :
930
- item.label.toLowerCase().includes(search.trim().toLowerCase())) : data;
929
+ return searchable
930
+ ? data.filter((item) => typeof item === 'string'
931
+ ? item
932
+ .toLowerCase()
933
+ .includes(search.trim().toLowerCase())
934
+ : item.label
935
+ .toLowerCase()
936
+ .includes(search.trim().toLowerCase()))
937
+ : data;
931
938
  }
932
939
  /**
933
940
  * Handles changes in the search input field.
@@ -940,7 +947,9 @@ function ComboboxComponent(props) {
940
947
  }
941
948
  // Render Clear Button
942
949
  function renderClearButton() {
943
- if (clearable && value && (Array.isArray(value) ? value.length > 0 : true)) {
950
+ if (clearable &&
951
+ value &&
952
+ (Array.isArray(value) ? value.length > 0 : true)) {
944
953
  return (jsxRuntimeExports.jsx(core.ActionIcon, { variant: "transparent", onClick: () => resetValue(), "aria-label": "Clear value", style: { cursor: 'pointer' }, className: styles$i.icon, children: jsxRuntimeExports.jsx(iconsReact.IconX, { size: 24 }) }));
945
954
  }
946
955
  return jsxRuntimeExports.jsx(iconsReact.IconCaretDownFilled, { size: 24, className: styles$i.icon });
@@ -955,7 +964,10 @@ function ComboboxComponent(props) {
955
964
  // Render Combobox Options
956
965
  function renderOptions() {
957
966
  const filtered = filterData();
958
- return filtered.map((item) => (jsxRuntimeExports.jsx(core.Combobox.Option, { value: getValue(item), active: Array.isArray(value) && value.some(v => getValue(v) === getValue(item)), children: jsxRuntimeExports.jsxs(core.Group, { gap: "sm", children: [multiple && Array.isArray(value) && value.some(v => getValue(v) === getValue(item)) && jsxRuntimeExports.jsx(core.CheckIcon, { size: 12 }), jsxRuntimeExports.jsx("span", { children: getLabel(item) })] }) }, getValue(item))));
967
+ return (jsxRuntimeExports.jsx(reactViewportList.ViewportList, { itemMargin: maxHeight, items: filtered, children: (item) => (jsxRuntimeExports.jsx(core.Combobox.Option, { value: getValue(item), active: Array.isArray(value) &&
968
+ value.some((v) => getValue(v) === getValue(item)), children: jsxRuntimeExports.jsxs(core.Group, { gap: "sm", children: [multiple &&
969
+ Array.isArray(value) &&
970
+ value.some((v) => getValue(v) === getValue(item)) && jsxRuntimeExports.jsx(core.CheckIcon, { size: 12 }), jsxRuntimeExports.jsx("span", { children: getLabel(item) })] }) }, getValue(item))) }));
959
971
  }
960
972
  // Render Input Field
961
973
  function renderInput() {
@@ -978,16 +990,12 @@ function ComboboxComponent(props) {
978
990
  }, onChange: handleSearchChange, placeholder: "Search value" })) : (jsxRuntimeExports.jsx(core.InputBase, { className: styles$i.input, component: "button", type: "button", pointer: true, onClick: () => combobox.openDropdown(), onFocus: () => combobox.openDropdown(), onBlur: () => {
979
991
  combobox.closeDropdown();
980
992
  setSearch(value?.toString() || '');
981
- }, rightSection: renderClearButton(), rightSectionPointerEvents: value === null ? 'none' : 'all', children: Array.isArray(value)
982
- ? value.map((item) => getLabel(item)).join(', ')
983
- : typeof value === 'string'
984
- ? getLabel(value)
985
- : (jsxRuntimeExports.jsx(core.Input.Placeholder, { className: styles$i.placeholder, children: "Pick value" })) })) }));
993
+ }, rightSection: renderClearButton(), rightSectionPointerEvents: value === null ? 'none' : 'all', children: Array.isArray(value) ? (value.map((item) => getLabel(item)).join(', ')) : typeof value === 'string' ? (getLabel(value)) : (jsxRuntimeExports.jsx(core.Input.Placeholder, { className: styles$i.placeholder, children: "Pick value" })) })) }));
986
994
  }
987
995
  return (jsxRuntimeExports.jsxs("div", { className: cn(styles$i.wrapper, className), style: { width: fullWidth ? '100%' : undefined }, children: [label && jsxRuntimeExports.jsx("label", { className: styles$i.label, children: label }), description && jsxRuntimeExports.jsx("p", { className: styles$i.description, children: description }), jsxRuntimeExports.jsxs(core.Combobox, { store: combobox, onOptionSubmit: (val) => {
988
- const selectedItem = data.find(item => getValue(item) === val) || val;
996
+ const selectedItem = data.find((item) => getValue(item) === val) || val;
989
997
  updateValue(selectedItem);
990
- }, withinPortal: false, ...rest, children: [renderInput(), jsxRuntimeExports.jsx(core.Combobox.Dropdown, { className: styles$i.dropdownWrapper, children: jsxRuntimeExports.jsx(core.Combobox.Options, { children: renderOptions().length > 0 ? (renderOptions()) : (jsxRuntimeExports.jsx(core.Combobox.Empty, { children: "Nothing found..." })) }) })] })] }));
998
+ }, withinPortal: false, ...rest, children: [renderInput(), jsxRuntimeExports.jsx(core.Combobox.Dropdown, { className: styles$i.dropdownWrapper, children: jsxRuntimeExports.jsx(core.Combobox.Options, { style: { overflowY: 'scroll', maxHeight }, children: filterData().length > 0 ? (renderOptions()) : (jsxRuntimeExports.jsx(core.Combobox.Empty, { children: "Nothing found..." })) }) })] })] }));
991
999
  }
992
1000
 
993
1001
  var styles$h = {"button":"styles-module_button__fQIgs","fontxs":"styles-module_fontxs__c61kh","fontsm":"styles-module_fontsm__zi0bq","fontbase":"styles-module_fontbase__Uzeoy","fontlg":"styles-module_fontlg__TfMwu","fontxl":"styles-module_fontxl__4IxFS","tag":"styles-module_tag__HOLQE","pill":"styles-module_pill__VAXc-","fullWidth":"styles-module_fullWidth__zWbR4","primary":"styles-module_primary__HWgQU","secondary":"styles-module_secondary__UOKnw","muted":"styles-module_muted__fA0Fl","disabled":"styles-module_disabled__EKMKd","danger":"styles-module_danger__gZERs","info":"styles-module_info__b-gyN","success":"styles-module_success__mRhfk","warning":"styles-module_warning__G977Z","active":"styles-module_active__5pkXl"};
@@ -1703,4 +1711,10 @@ Object.keys(hooks).forEach(function (k) {
1703
1711
  get: function () { return hooks[k]; }
1704
1712
  });
1705
1713
  });
1714
+ Object.keys(form).forEach(function (k) {
1715
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
1716
+ enumerable: true,
1717
+ get: function () { return form[k]; }
1718
+ });
1719
+ });
1706
1720
  //# sourceMappingURL=index.js.map