@tmlmobilidade/ui 20250128.1609.43 → 20250128.1631.30
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 +22 -15
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/src/components/common/Combobox/index.d.ts +1 -0
- package/dist/esm/index.js +22 -15
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/src/components/common/Combobox/index.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -6,11 +6,11 @@ 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
14
|
|
|
15
15
|
function _interopNamespaceDefault(e) {
|
|
16
16
|
var n = Object.create(null);
|
|
@@ -860,7 +860,7 @@ function Component({ classNames, ...props }) {
|
|
|
860
860
|
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
861
|
|
|
862
862
|
function ComboboxComponent(props) {
|
|
863
|
-
const { multiple = false, searchable = false, autoComplete = false, onChange, data = [], clearable = false, label, description, fullWidth = false, className, ...rest } = props;
|
|
863
|
+
const { multiple = false, searchable = false, autoComplete = false, onChange, data = [], clearable = false, label, description, fullWidth = false, maxHeight = 200, className, ...rest } = props;
|
|
864
864
|
// Setup Combobox store
|
|
865
865
|
const combobox = core.useCombobox({
|
|
866
866
|
onDropdownClose: () => combobox.resetSelectedOption(),
|
|
@@ -891,7 +891,7 @@ function ComboboxComponent(props) {
|
|
|
891
891
|
function updateValue(val) {
|
|
892
892
|
if (multiple && Array.isArray(value)) {
|
|
893
893
|
let updatedValue;
|
|
894
|
-
if (value.some(v => getValue(v) === getValue(val))) {
|
|
894
|
+
if (value.some((v) => getValue(v) === getValue(val))) {
|
|
895
895
|
updatedValue = value.filter((v) => getValue(v) !== getValue(val));
|
|
896
896
|
}
|
|
897
897
|
else {
|
|
@@ -925,9 +925,15 @@ function ComboboxComponent(props) {
|
|
|
925
925
|
* Filters data based on search input.
|
|
926
926
|
*/
|
|
927
927
|
function filterData() {
|
|
928
|
-
return searchable
|
|
929
|
-
|
|
930
|
-
|
|
928
|
+
return searchable
|
|
929
|
+
? data.filter((item) => typeof item === 'string'
|
|
930
|
+
? item
|
|
931
|
+
.toLowerCase()
|
|
932
|
+
.includes(search.trim().toLowerCase())
|
|
933
|
+
: item.label
|
|
934
|
+
.toLowerCase()
|
|
935
|
+
.includes(search.trim().toLowerCase()))
|
|
936
|
+
: data;
|
|
931
937
|
}
|
|
932
938
|
/**
|
|
933
939
|
* Handles changes in the search input field.
|
|
@@ -940,7 +946,9 @@ function ComboboxComponent(props) {
|
|
|
940
946
|
}
|
|
941
947
|
// Render Clear Button
|
|
942
948
|
function renderClearButton() {
|
|
943
|
-
if (clearable &&
|
|
949
|
+
if (clearable &&
|
|
950
|
+
value &&
|
|
951
|
+
(Array.isArray(value) ? value.length > 0 : true)) {
|
|
944
952
|
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
953
|
}
|
|
946
954
|
return jsxRuntimeExports.jsx(iconsReact.IconCaretDownFilled, { size: 24, className: styles$i.icon });
|
|
@@ -955,7 +963,10 @@ function ComboboxComponent(props) {
|
|
|
955
963
|
// Render Combobox Options
|
|
956
964
|
function renderOptions() {
|
|
957
965
|
const filtered = filterData();
|
|
958
|
-
return
|
|
966
|
+
return (jsxRuntimeExports.jsx(reactViewportList.ViewportList, { itemMargin: maxHeight, items: filtered, children: (item) => (jsxRuntimeExports.jsx(core.Combobox.Option, { value: getValue(item), active: Array.isArray(value) &&
|
|
967
|
+
value.some((v) => getValue(v) === getValue(item)), children: jsxRuntimeExports.jsxs(core.Group, { gap: "sm", children: [multiple &&
|
|
968
|
+
Array.isArray(value) &&
|
|
969
|
+
value.some((v) => getValue(v) === getValue(item)) && jsxRuntimeExports.jsx(core.CheckIcon, { size: 12 }), jsxRuntimeExports.jsx("span", { children: getLabel(item) })] }) }, getValue(item))) }));
|
|
959
970
|
}
|
|
960
971
|
// Render Input Field
|
|
961
972
|
function renderInput() {
|
|
@@ -978,16 +989,12 @@ function ComboboxComponent(props) {
|
|
|
978
989
|
}, 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
990
|
combobox.closeDropdown();
|
|
980
991
|
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" })) })) }));
|
|
992
|
+
}, 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
993
|
}
|
|
987
994
|
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;
|
|
995
|
+
const selectedItem = data.find((item) => getValue(item) === val) || val;
|
|
989
996
|
updateValue(selectedItem);
|
|
990
|
-
}, withinPortal: false, ...rest, children: [renderInput(), jsxRuntimeExports.jsx(core.Combobox.Dropdown, { className: styles$i.dropdownWrapper, children: jsxRuntimeExports.jsx(core.Combobox.Options, { children:
|
|
997
|
+
}, 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
998
|
}
|
|
992
999
|
|
|
993
1000
|
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"};
|