@tmlmobilidade/ui 20250211.2350.30 → 20250226.1436.26
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 +15 -12
- 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 +15 -12
- 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/dist/styles.css +25 -0
- package/package.json +2 -2
package/dist/esm/index.js
CHANGED
@@ -1010,11 +1010,12 @@ function Checkbox(props) {
|
|
1010
1010
|
return jsxRuntimeExports.jsx(Checkbox$1, { classNames: { ...styles$l, ...props.classNames }, ...props });
|
1011
1011
|
}
|
1012
1012
|
|
1013
|
-
var styles$k = {"wrapper":"styles-module_wrapper__7zsRX","input":"styles-module_input__kZP4l","placeholder":"styles-module_placeholder__uazW4","pillInputWrapper":"styles-module_pillInputWrapper__rtJzo","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"};
|
1013
|
+
var styles$k = {"wrapper":"styles-module_wrapper__7zsRX","input":"styles-module_input__kZP4l","placeholder":"styles-module_placeholder__uazW4","pillInputWrapper":"styles-module_pillInputWrapper__rtJzo","icon":"styles-module_icon__jXQ8R","pillClearButton":"styles-module_pillClearButton__RYrwJ","pill":"styles-module_pill__eWbVa","label":"styles-module_label__tB0Ce","labelWrapper":"styles-module_labelWrapper__eFj6h","description":"styles-module_description__KHjxV","error":"styles-module_error__fOsRf","dropdownWrapper":"styles-module_dropdownWrapper__guQYa"};
|
1014
1014
|
|
1015
1015
|
function parseComboboxItem(item) {
|
1016
1016
|
if (typeof item === 'string') {
|
1017
1017
|
return {
|
1018
|
+
icon: null,
|
1018
1019
|
label: item,
|
1019
1020
|
value: item,
|
1020
1021
|
};
|
@@ -1037,7 +1038,6 @@ function ComboboxComponent(props) {
|
|
1037
1038
|
}, [multiple, props.value]);
|
1038
1039
|
// Helper functions
|
1039
1040
|
const getValue = (val) => typeof val === 'string' ? val : val.value;
|
1040
|
-
const getLabel = (val) => typeof val === 'string' ? val : val.label;
|
1041
1041
|
/**
|
1042
1042
|
* Resets the value based on initialValue or default state.
|
1043
1043
|
*/
|
@@ -1122,10 +1122,10 @@ function ComboboxComponent(props) {
|
|
1122
1122
|
function renderValues() {
|
1123
1123
|
if (multiple && Array.isArray(value)) {
|
1124
1124
|
return value.map((item) => {
|
1125
|
-
const itemData = data.find(dataItem => getValue(dataItem) === item);
|
1125
|
+
const itemData = parseComboboxItem(data.find(dataItem => getValue(dataItem) === item) || '');
|
1126
1126
|
if (!itemData)
|
1127
1127
|
return null;
|
1128
|
-
return (jsxRuntimeExports.jsx(Pill, { className: styles$k.pill, onRemove: () => removeValue(item), withRemoveButton: true, children: jsxRuntimeExports.jsx("span", { children:
|
1128
|
+
return (jsxRuntimeExports.jsx(Pill, { className: styles$k.pill, onRemove: () => removeValue(item), withRemoveButton: true, children: jsxRuntimeExports.jsxs("div", { className: styles$k.labelWrapper, children: [itemData.icon && jsxRuntimeExports.jsx("span", { className: styles$k.icon, children: itemData.icon }), jsxRuntimeExports.jsx("span", { children: itemData.label })] }) }, item));
|
1129
1129
|
});
|
1130
1130
|
}
|
1131
1131
|
return null;
|
@@ -1133,10 +1133,13 @@ function ComboboxComponent(props) {
|
|
1133
1133
|
// Render Combobox Options
|
1134
1134
|
function renderOptions() {
|
1135
1135
|
const filtered = filterData();
|
1136
|
-
return (jsxRuntimeExports.jsx(ViewportList, { itemMargin: maxHeight, items: filtered, children: item =>
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1136
|
+
return (jsxRuntimeExports.jsx(ViewportList, { itemMargin: maxHeight, items: filtered, children: (item) => {
|
1137
|
+
const itemData = parseComboboxItem(item);
|
1138
|
+
return (jsxRuntimeExports.jsx(Combobox.Option, { value: itemData.value, active: Array.isArray(value)
|
1139
|
+
&& value.some(v => getValue(v) === itemData.value), children: jsxRuntimeExports.jsxs(Group, { gap: "sm", children: [multiple
|
1140
|
+
&& Array.isArray(value)
|
1141
|
+
&& value.some(v => getValue(v) === itemData.value) && jsxRuntimeExports.jsx(CheckIcon, { size: 12 }), jsxRuntimeExports.jsxs("div", { className: styles$k.labelWrapper, children: [itemData.icon && jsxRuntimeExports.jsx("span", { className: styles$k.icon, children: itemData.icon }), jsxRuntimeExports.jsx("span", { children: itemData.label })] })] }) }, itemData.value));
|
1142
|
+
} }));
|
1140
1143
|
}
|
1141
1144
|
// Render Input Field
|
1142
1145
|
function renderInput() {
|
@@ -1153,14 +1156,14 @@ function ComboboxComponent(props) {
|
|
1153
1156
|
}
|
1154
1157
|
} }) }), jsxRuntimeExports.jsx("div", { className: styles$k.pillClearButton, children: renderClearButton() })] }) }) }));
|
1155
1158
|
}
|
1156
|
-
const itemData = data.find(dataItem => getValue(dataItem) === value);
|
1157
|
-
return (jsxRuntimeExports.jsx(Combobox.Target, { children: searchable ? (jsxRuntimeExports.jsx(InputBase, { className: styles$k.input, onChange: handleSearchChange, onClick: () => combobox.openDropdown(), onFocus: () => combobox.openDropdown(), placeholder: "Search value", rightSection: renderClearButton(), type: "text", value: search, onBlur: () => {
|
1159
|
+
const itemData = parseComboboxItem(data.find(dataItem => getValue(dataItem) === value) || '');
|
1160
|
+
return (jsxRuntimeExports.jsx(Combobox.Target, { children: searchable ? (jsxRuntimeExports.jsx(InputBase, { className: styles$k.input, leftSection: itemData?.icon, onChange: handleSearchChange, onClick: () => combobox.openDropdown(), onFocus: () => combobox.openDropdown(), placeholder: "Search value", rightSection: renderClearButton(), type: "text", value: search, onBlur: () => {
|
1158
1161
|
combobox.closeDropdown();
|
1159
|
-
setSearch(itemData ?
|
1162
|
+
setSearch(itemData ? itemData.label : '');
|
1160
1163
|
}, rightSectionPointerEvents: value === null ? 'none' : 'all' })) : (jsxRuntimeExports.jsx(InputBase, { className: styles$k.input, component: "button", onClick: () => combobox.openDropdown(), onFocus: () => combobox.openDropdown(), rightSection: renderClearButton(), type: "button", onBlur: () => {
|
1161
1164
|
combobox.closeDropdown();
|
1162
1165
|
setSearch(value?.toString() || '');
|
1163
|
-
}, rightSectionPointerEvents: value === null ? 'none' : 'all', pointer: true, children: itemData ?
|
1166
|
+
}, rightSectionPointerEvents: value === null ? 'none' : 'all', pointer: true, children: itemData ? (jsxRuntimeExports.jsxs("div", { className: styles$k.labelWrapper, children: [itemData.icon && jsxRuntimeExports.jsx("span", { className: styles$k.icon, children: itemData.icon }), jsxRuntimeExports.jsx("span", { children: itemData.label })] })) : (jsxRuntimeExports.jsx(Input.Placeholder, { className: styles$k.placeholder, children: "Pick value" })) })) }));
|
1164
1167
|
}
|
1165
1168
|
return (jsxRuntimeExports.jsxs("div", { className: cn(styles$k.wrapper, className), style: { width: fullWidth ? '100%' : undefined }, children: [label && jsxRuntimeExports.jsx("label", { className: styles$k.label, children: label }), description && jsxRuntimeExports.jsx("p", { className: styles$k.description, children: description }), error && jsxRuntimeExports.jsx("p", { className: styles$k.error, children: error }), jsxRuntimeExports.jsxs(Combobox, { store: combobox, withinPortal: false, onOptionSubmit: (val) => {
|
1166
1169
|
updateValue(val);
|