@tmlmobilidade/ui 20250129.1606.25 → 20250129.1626.34
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 +17 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +17 -4
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -860,6 +860,15 @@ function Component({ classNames, ...props }) {
|
|
|
860
860
|
|
|
861
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","error":"styles-module_error__fOsRf","dropdownWrapper":"styles-module_dropdownWrapper__guQYa"};
|
|
862
862
|
|
|
863
|
+
function parseComboboxItem(item) {
|
|
864
|
+
if (typeof item === 'string') {
|
|
865
|
+
return {
|
|
866
|
+
value: item,
|
|
867
|
+
label: item,
|
|
868
|
+
};
|
|
869
|
+
}
|
|
870
|
+
return item;
|
|
871
|
+
}
|
|
863
872
|
function ComboboxComponent(props) {
|
|
864
873
|
const { multiple = false, searchable = false, autoComplete = false, onChange, data = [], clearable = false, label, description, fullWidth = false, maxHeight = 200, className, error, ...rest } = props;
|
|
865
874
|
// Setup Combobox store
|
|
@@ -892,7 +901,7 @@ function ComboboxComponent(props) {
|
|
|
892
901
|
function updateValue(val) {
|
|
893
902
|
if (multiple && Array.isArray(value)) {
|
|
894
903
|
let updatedValue;
|
|
895
|
-
if (value.some((v) =>
|
|
904
|
+
if (value.some((v) => v === val)) {
|
|
896
905
|
updatedValue = value.filter((v) => v !== getValue(val));
|
|
897
906
|
}
|
|
898
907
|
else {
|
|
@@ -957,7 +966,12 @@ function ComboboxComponent(props) {
|
|
|
957
966
|
// Render Selected Values as Pills
|
|
958
967
|
function renderValues() {
|
|
959
968
|
if (multiple && Array.isArray(value)) {
|
|
960
|
-
return value.map((item) =>
|
|
969
|
+
return value.map((item) => {
|
|
970
|
+
const itemData = data.find(dataItem => getValue(dataItem) === item);
|
|
971
|
+
if (!itemData)
|
|
972
|
+
return null;
|
|
973
|
+
return (jsxRuntimeExports.jsx(core.Pill, { className: styles$i.pill, withRemoveButton: true, onRemove: () => removeValue(item), children: jsxRuntimeExports.jsx("span", { children: parseComboboxItem(itemData)?.label }) }, item));
|
|
974
|
+
});
|
|
961
975
|
}
|
|
962
976
|
return null;
|
|
963
977
|
}
|
|
@@ -993,8 +1007,7 @@ function ComboboxComponent(props) {
|
|
|
993
1007
|
}, 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" })) })) }));
|
|
994
1008
|
}
|
|
995
1009
|
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 }), error && jsxRuntimeExports.jsx("p", { className: styles$i.error, children: error }), jsxRuntimeExports.jsxs(core.Combobox, { store: combobox, onOptionSubmit: (val) => {
|
|
996
|
-
|
|
997
|
-
updateValue(selectedItem);
|
|
1010
|
+
updateValue(val);
|
|
998
1011
|
}, 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..." })) }) })] })] }));
|
|
999
1012
|
}
|
|
1000
1013
|
|