@recursica/mui-adapter 0.32.0 → 0.33.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.
Files changed (39) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/index.d.ts +42 -7
  3. package/dist/mui-adapter.cjs +66 -66
  4. package/dist/mui-adapter.cjs.map +1 -1
  5. package/dist/mui-adapter.css +1 -1
  6. package/dist/mui-adapter.js +6825 -6751
  7. package/dist/mui-adapter.js.map +1 -1
  8. package/package.json +2 -2
  9. package/src/components/Accordion/Accordion.module.css +7 -0
  10. package/src/components/Autocomplete/AUTOCOMPLETE_IMPLEMENTATION_NOTES.md +17 -0
  11. package/src/components/Autocomplete/Autocomplete.module.css +131 -12
  12. package/src/components/Autocomplete/Autocomplete.stories.tsx +149 -0
  13. package/src/components/Autocomplete/Autocomplete.tsx +47 -2
  14. package/src/components/Autocomplete/USAGE.md +26 -0
  15. package/src/components/Button/Button.module.css +10 -0
  16. package/src/components/Card/Card.stories.tsx +2 -4
  17. package/src/components/Chip/Chip.module.css +9 -0
  18. package/src/components/DatePicker/DatePicker.module.css +13 -0
  19. package/src/components/Dropdown/BareDropdown.tsx +34 -7
  20. package/src/components/Dropdown/DROPDOWN_IMPLEMENTATION_NOTES.md +15 -0
  21. package/src/components/Dropdown/Dropdown.module.css +123 -4
  22. package/src/components/Dropdown/Dropdown.stories.tsx +149 -0
  23. package/src/components/Dropdown/Dropdown.tsx +37 -4
  24. package/src/components/Dropdown/USAGE.md +20 -0
  25. package/src/components/FileInput/FILEINPUT_IMPLEMENTATION_NOTES.md +4 -1
  26. package/src/components/FileInput/FileInput.module.css +17 -0
  27. package/src/components/FileUpload/FileUpload.module.css +6 -0
  28. package/src/components/Link/Link.module.css +5 -0
  29. package/src/components/Menu/Menu.module.css +6 -0
  30. package/src/components/NumberInput/NumberInput.module.css +8 -0
  31. package/src/components/Pagination/Pagination.module.css +7 -0
  32. package/src/components/Slider/Slider.module.css +8 -0
  33. package/src/components/Switch/Switch.module.css +8 -0
  34. package/src/components/Tabs/Tabs.module.css +9 -0
  35. package/src/components/TextArea/TextArea.module.css +8 -0
  36. package/src/components/TextField/TextField.module.css +8 -0
  37. package/src/components/TimePicker/TimePicker.module.css +8 -0
  38. package/src/components/Tree/Tree.module.css +11 -0
  39. package/src/utils/renderRichOption.tsx +51 -0
@@ -0,0 +1,51 @@
1
+ import React from "react";
2
+ import { type RecursicaComboboxItemWithLabel } from "@recursica/adapter-common";
3
+
4
+ export interface RichOptionClassNames {
5
+ optionContent: string;
6
+ optionIcon: string;
7
+ optionText: string;
8
+ /** Combined with `optionText` when `wrapItemText` is true — see `renderRichOptionContent` below. */
9
+ optionTextWrap: string;
10
+ optionSupportingText: string;
11
+ }
12
+
13
+ /**
14
+ * `MenuItem`/option children for Dropdown/Autocomplete that renders `leadingIcon`/`supportingText`
15
+ * (see MANTINE_ADAPTER_RICH_OPTION_DATA.md) inside the row. Falls back to plain `label` when
16
+ * neither is present, so items without the new fields render exactly as before.
17
+ *
18
+ * `wrapItemText` (default `false`) controls whether `label`/`supportingText` wrap onto additional
19
+ * lines or truncate to a single line with an ellipsis.
20
+ */
21
+ export function renderRichOptionContent(
22
+ item: Pick<
23
+ RecursicaComboboxItemWithLabel,
24
+ "label" | "leadingIcon" | "supportingText"
25
+ >,
26
+ classNames: RichOptionClassNames,
27
+ wrapItemText = false,
28
+ ): React.ReactNode {
29
+ const { label, leadingIcon, supportingText } = item;
30
+ if (!leadingIcon && !supportingText) {
31
+ return label;
32
+ }
33
+ const optionTextClassName = wrapItemText
34
+ ? `${classNames.optionText} ${classNames.optionTextWrap}`
35
+ : classNames.optionText;
36
+ return (
37
+ <span className={classNames.optionContent}>
38
+ {leadingIcon && (
39
+ <span className={classNames.optionIcon}>{leadingIcon}</span>
40
+ )}
41
+ <span className={optionTextClassName}>
42
+ <span>{label}</span>
43
+ {supportingText && (
44
+ <span className={classNames.optionSupportingText}>
45
+ {supportingText}
46
+ </span>
47
+ )}
48
+ </span>
49
+ </span>
50
+ );
51
+ }