@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 CHANGED
@@ -1027,11 +1027,12 @@ function Checkbox(props) {
1027
1027
  return jsxRuntimeExports.jsx(core.Checkbox, { classNames: { ...styles$l, ...props.classNames }, ...props });
1028
1028
  }
1029
1029
 
1030
- 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"};
1030
+ 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"};
1031
1031
 
1032
1032
  function parseComboboxItem(item) {
1033
1033
  if (typeof item === 'string') {
1034
1034
  return {
1035
+ icon: null,
1035
1036
  label: item,
1036
1037
  value: item,
1037
1038
  };
@@ -1054,7 +1055,6 @@ function ComboboxComponent(props) {
1054
1055
  }, [multiple, props.value]);
1055
1056
  // Helper functions
1056
1057
  const getValue = (val) => typeof val === 'string' ? val : val.value;
1057
- const getLabel = (val) => typeof val === 'string' ? val : val.label;
1058
1058
  /**
1059
1059
  * Resets the value based on initialValue or default state.
1060
1060
  */
@@ -1139,10 +1139,10 @@ function ComboboxComponent(props) {
1139
1139
  function renderValues() {
1140
1140
  if (multiple && Array.isArray(value)) {
1141
1141
  return value.map((item) => {
1142
- const itemData = data.find(dataItem => getValue(dataItem) === item);
1142
+ const itemData = parseComboboxItem(data.find(dataItem => getValue(dataItem) === item) || '');
1143
1143
  if (!itemData)
1144
1144
  return null;
1145
- return (jsxRuntimeExports.jsx(core.Pill, { className: styles$k.pill, onRemove: () => removeValue(item), withRemoveButton: true, children: jsxRuntimeExports.jsx("span", { children: parseComboboxItem(itemData)?.label }) }, item));
1145
+ return (jsxRuntimeExports.jsx(core.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));
1146
1146
  });
1147
1147
  }
1148
1148
  return null;
@@ -1150,10 +1150,13 @@ function ComboboxComponent(props) {
1150
1150
  // Render Combobox Options
1151
1151
  function renderOptions() {
1152
1152
  const filtered = filterData();
1153
- return (jsxRuntimeExports.jsx(reactViewportList.ViewportList, { itemMargin: maxHeight, items: filtered, children: item => (jsxRuntimeExports.jsx(core.Combobox.Option, { value: getValue(item), active: Array.isArray(value)
1154
- && value.some(v => getValue(v) === getValue(item)), children: jsxRuntimeExports.jsxs(core.Group, { gap: "sm", children: [multiple
1155
- && Array.isArray(value)
1156
- && value.some(v => getValue(v) === getValue(item)) && jsxRuntimeExports.jsx(core.CheckIcon, { size: 12 }), jsxRuntimeExports.jsx("span", { children: getLabel(item) })] }) }, getValue(item))) }));
1153
+ return (jsxRuntimeExports.jsx(reactViewportList.ViewportList, { itemMargin: maxHeight, items: filtered, children: (item) => {
1154
+ const itemData = parseComboboxItem(item);
1155
+ return (jsxRuntimeExports.jsx(core.Combobox.Option, { value: itemData.value, active: Array.isArray(value)
1156
+ && value.some(v => getValue(v) === itemData.value), children: jsxRuntimeExports.jsxs(core.Group, { gap: "sm", children: [multiple
1157
+ && Array.isArray(value)
1158
+ && value.some(v => getValue(v) === itemData.value) && jsxRuntimeExports.jsx(core.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));
1159
+ } }));
1157
1160
  }
1158
1161
  // Render Input Field
1159
1162
  function renderInput() {
@@ -1170,14 +1173,14 @@ function ComboboxComponent(props) {
1170
1173
  }
1171
1174
  } }) }), jsxRuntimeExports.jsx("div", { className: styles$k.pillClearButton, children: renderClearButton() })] }) }) }));
1172
1175
  }
1173
- const itemData = data.find(dataItem => getValue(dataItem) === value);
1174
- return (jsxRuntimeExports.jsx(core.Combobox.Target, { children: searchable ? (jsxRuntimeExports.jsx(core.InputBase, { className: styles$k.input, onChange: handleSearchChange, onClick: () => combobox.openDropdown(), onFocus: () => combobox.openDropdown(), placeholder: "Search value", rightSection: renderClearButton(), type: "text", value: search, onBlur: () => {
1176
+ const itemData = parseComboboxItem(data.find(dataItem => getValue(dataItem) === value) || '');
1177
+ return (jsxRuntimeExports.jsx(core.Combobox.Target, { children: searchable ? (jsxRuntimeExports.jsx(core.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: () => {
1175
1178
  combobox.closeDropdown();
1176
- setSearch(itemData ? parseComboboxItem(itemData)?.label : '');
1179
+ setSearch(itemData ? itemData.label : '');
1177
1180
  }, rightSectionPointerEvents: value === null ? 'none' : 'all' })) : (jsxRuntimeExports.jsx(core.InputBase, { className: styles$k.input, component: "button", onClick: () => combobox.openDropdown(), onFocus: () => combobox.openDropdown(), rightSection: renderClearButton(), type: "button", onBlur: () => {
1178
1181
  combobox.closeDropdown();
1179
1182
  setSearch(value?.toString() || '');
1180
- }, rightSectionPointerEvents: value === null ? 'none' : 'all', pointer: true, children: itemData ? parseComboboxItem(itemData)?.label : jsxRuntimeExports.jsx(core.Input.Placeholder, { className: styles$k.placeholder, children: "Pick value" }) })) }));
1183
+ }, 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(core.Input.Placeholder, { className: styles$k.placeholder, children: "Pick value" })) })) }));
1181
1184
  }
1182
1185
  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(core.Combobox, { store: combobox, withinPortal: false, onOptionSubmit: (val) => {
1183
1186
  updateValue(val);