@monolith-forensics/monolith-ui 1.8.0 → 1.8.1-dev.1

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 (120) hide show
  1. package/dist/Button/Button.js +9 -58
  2. package/dist/Calendar/Calendar.d.ts +3 -1
  3. package/dist/Calendar/Calendar.js +134 -33
  4. package/dist/Calendar/CalendarStyles.d.ts +3 -0
  5. package/dist/Calendar/CalendarStyles.js +92 -14
  6. package/dist/Calendar/calendarHelpers.d.ts +5 -1
  7. package/dist/Calendar/calendarHelpers.js +13 -5
  8. package/dist/Charts/BarChart/BarChart.d.ts +5 -0
  9. package/dist/Charts/BarChart/BarChart.js +549 -0
  10. package/dist/Charts/BarChart/BarChart.lib.d.ts +31 -0
  11. package/dist/Charts/BarChart/BarChart.lib.js +136 -0
  12. package/dist/Charts/BarChart/BarChart.styled.d.ts +51 -0
  13. package/dist/Charts/BarChart/BarChart.styled.js +115 -0
  14. package/dist/Charts/BarChart/BarChart.types.d.ts +171 -0
  15. package/dist/Charts/BarChart/BarChart.types.js +1 -0
  16. package/dist/Charts/BarChart/index.d.ts +3 -0
  17. package/dist/Charts/BarChart/index.js +2 -0
  18. package/dist/Charts/ChartPrimitives/ChartExportControl.d.ts +11 -0
  19. package/dist/Charts/ChartPrimitives/ChartExportControl.js +29 -0
  20. package/dist/Charts/ChartPrimitives/chartActions.styled.d.ts +1 -0
  21. package/dist/Charts/ChartPrimitives/chartActions.styled.js +8 -0
  22. package/dist/Charts/ChartPrimitives/chartLegend.styled.d.ts +12 -0
  23. package/dist/Charts/ChartPrimitives/chartLegend.styled.js +52 -0
  24. package/dist/Charts/ChartPrimitives/chartTooltip.styled.d.ts +19 -0
  25. package/dist/Charts/ChartPrimitives/chartTooltip.styled.js +61 -0
  26. package/dist/Charts/ChartPrimitives/index.d.ts +4 -0
  27. package/dist/Charts/ChartPrimitives/index.js +4 -0
  28. package/dist/Charts/ChartUtils/chartColors.d.ts +8 -0
  29. package/dist/Charts/ChartUtils/chartColors.js +65 -0
  30. package/dist/Charts/ChartUtils/chartExport.d.ts +47 -0
  31. package/dist/Charts/ChartUtils/chartExport.js +311 -0
  32. package/dist/Charts/ChartUtils/chartMath.d.ts +3 -0
  33. package/dist/Charts/ChartUtils/chartMath.js +3 -0
  34. package/dist/Charts/ChartUtils/index.d.ts +3 -0
  35. package/dist/Charts/ChartUtils/index.js +3 -0
  36. package/dist/Charts/HeatMap/HeatMap.d.ts +5 -0
  37. package/dist/Charts/HeatMap/HeatMap.js +212 -0
  38. package/dist/Charts/HeatMap/HeatMap.lib.d.ts +30 -0
  39. package/dist/Charts/HeatMap/HeatMap.lib.js +115 -0
  40. package/dist/Charts/HeatMap/HeatMap.styled.d.ts +37 -0
  41. package/dist/Charts/HeatMap/HeatMap.styled.js +91 -0
  42. package/dist/Charts/HeatMap/HeatMap.types.d.ts +80 -0
  43. package/dist/Charts/HeatMap/HeatMap.types.js +1 -0
  44. package/dist/Charts/HeatMap/index.d.ts +3 -0
  45. package/dist/Charts/HeatMap/index.js +2 -0
  46. package/dist/Charts/LineChart/LineChart.d.ts +5 -0
  47. package/dist/Charts/LineChart/LineChart.js +529 -0
  48. package/dist/Charts/LineChart/LineChart.lib.d.ts +24 -0
  49. package/dist/Charts/LineChart/LineChart.lib.js +132 -0
  50. package/dist/Charts/LineChart/LineChart.styled.d.ts +59 -0
  51. package/dist/Charts/LineChart/LineChart.styled.js +147 -0
  52. package/dist/Charts/LineChart/LineChart.types.d.ts +193 -0
  53. package/dist/Charts/LineChart/LineChart.types.js +1 -0
  54. package/dist/Charts/LineChart/index.d.ts +3 -0
  55. package/dist/Charts/LineChart/index.js +2 -0
  56. package/dist/Charts/PieChart/PieChart.d.ts +4 -0
  57. package/dist/Charts/PieChart/PieChart.js +199 -0
  58. package/dist/Charts/PieChart/PieChart.lib.d.ts +5 -0
  59. package/dist/Charts/PieChart/PieChart.lib.js +19 -0
  60. package/dist/Charts/PieChart/PieChart.styled.d.ts +51 -0
  61. package/dist/Charts/PieChart/PieChart.styled.js +163 -0
  62. package/dist/Charts/PieChart/PieChart.types.d.ts +100 -0
  63. package/dist/Charts/PieChart/PieChart.types.js +1 -0
  64. package/dist/Charts/PieChart/index.d.ts +2 -0
  65. package/dist/Charts/PieChart/index.js +1 -0
  66. package/dist/Charts/index.d.ts +5 -0
  67. package/dist/Charts/index.js +4 -0
  68. package/dist/CheckBox/CheckBox.js +2 -16
  69. package/dist/DateInput/DateInput.js +198 -143
  70. package/dist/DropDownMenu/components/MenuComponent.js +2 -1
  71. package/dist/DropDownMenu/components/MenuItem.js +5 -14
  72. package/dist/DropDownMenu/components/MenuItemList.js +7 -24
  73. package/dist/DropDownMenu/components/StyledFloatContainer.js +1 -1
  74. package/dist/FieldLabel/FieldLabel.js +4 -12
  75. package/dist/FileInputField/FileInputField.js +4 -23
  76. package/dist/FormSection/FormSection.js +5 -25
  77. package/dist/IconButton/IconButton.js +2 -16
  78. package/dist/Input/Input.js +7 -56
  79. package/dist/Pill/Pill.js +8 -79
  80. package/dist/Popover/Popover.context.d.ts +2 -1
  81. package/dist/Popover/Popover.js +5 -2
  82. package/dist/Popover/Popover.styles.d.ts +1 -6
  83. package/dist/Popover/Popover.styles.js +11 -28
  84. package/dist/Popover/Popover.transitions.d.ts +4 -2
  85. package/dist/Popover/Popover.transitions.js +23 -49
  86. package/dist/Popover/PopoverDropdown.js +6 -8
  87. package/dist/Popover/PopoverTarget.js +6 -3
  88. package/dist/SegmentedControl/SegmentedControl.utils.d.ts +2 -2
  89. package/dist/SegmentedControl/SegmentedControl.utils.js +3 -30
  90. package/dist/SelectBox/SelectBox.js +5 -5
  91. package/dist/SelectBox/select-box.styled-components.d.ts +4 -1
  92. package/dist/SelectBox/select-box.styled-components.js +11 -48
  93. package/dist/SelectBox/types.d.ts +1 -0
  94. package/dist/Switch/Switch.d.ts +2 -2
  95. package/dist/Switch/Switch.js +18 -83
  96. package/dist/Table/StateStorage.d.ts +4 -0
  97. package/dist/Table/StateStorage.js +13 -0
  98. package/dist/Table/Table.js +160 -12
  99. package/dist/Table/TableComponents.d.ts +10 -0
  100. package/dist/Table/TableComponents.js +57 -0
  101. package/dist/Table/TableDefaults.d.ts +7 -0
  102. package/dist/Table/TableDefaults.js +7 -0
  103. package/dist/Table/TableProvider.js +263 -71
  104. package/dist/Table/TableRow.js +15 -10
  105. package/dist/Table/types.d.ts +64 -0
  106. package/dist/TagBox/TagBox.js +18 -76
  107. package/dist/TextArea/TextArea.js +4 -23
  108. package/dist/TextInput/TextInput.js +12 -6
  109. package/dist/Utilities/parseTimestamp.js +11 -6
  110. package/dist/core/ArrowButton.d.ts +2 -0
  111. package/dist/core/ArrowButton.js +7 -3
  112. package/dist/core/ClearButton.d.ts +2 -0
  113. package/dist/core/ClearButton.js +7 -3
  114. package/dist/core/controlSizes.d.ts +34 -0
  115. package/dist/core/controlSizes.js +190 -0
  116. package/dist/core/index.d.ts +1 -0
  117. package/dist/core/index.js +1 -0
  118. package/dist/index.d.ts +1 -0
  119. package/dist/index.js +1 -0
  120. package/package.json +5 -1
@@ -1,3 +1,4 @@
1
+ import { getControlSizeTokens } from "../core";
1
2
  export const resolveActiveColor = (theme, activeColor) => {
2
3
  var _a;
3
4
  const fallback = {
@@ -21,38 +22,10 @@ export const resolveActiveColor = (theme, activeColor) => {
21
22
  };
22
23
  };
23
24
  export const getSegmentHeight = (size) => {
24
- switch (size) {
25
- case "xxs":
26
- return 22;
27
- case "xs":
28
- return 26;
29
- case "md":
30
- return 38;
31
- case "lg":
32
- return 46;
33
- case "xl":
34
- return 56;
35
- case "sm":
36
- default:
37
- return 32;
38
- }
25
+ return getControlSizeTokens(size).segmentedHeight;
39
26
  };
40
27
  export const getSegmentFontSize = (size) => {
41
- switch (size) {
42
- case "xxs":
43
- return "11px";
44
- case "xs":
45
- return "12px";
46
- case "md":
47
- return "16px";
48
- case "lg":
49
- return "18px";
50
- case "xl":
51
- return "20px";
52
- case "sm":
53
- default:
54
- return "14px";
55
- }
28
+ return `${getControlSizeTokens(size).segmentedFontSize}px`;
56
29
  };
57
30
  export const normalizeSegmentedData = (data) => data.map((item) => {
58
31
  var _a;
@@ -10,7 +10,7 @@ import { StyledInputContainer, StyledInnerItemContainer, EmptyComponent, GroupTi
10
10
  // Re-export for backward compatibility
11
11
  export { StyledInputContainer };
12
12
  export const SelectBox = ({ className, data = [], placeholder = "Select...", arrow = true, onChange, onSearch, searchFn, onScroll, loading, defaultValue, value, size = "sm", variant = "outlined", width = "100%", allowCustomValue = false, searchable = false, clearable = false, label, description, required = false, error, openOnFocus = true, renderOption, actionComponent, focused, grouped, OptionTooltip, // Custom tooltip component for search menu items
13
- DropDownProps = {}, debounceTime = 175, sort = false, disabled = false,
13
+ DropDownProps = {}, debounceTime = 175, sort = false, disabled = false, dynamicOptionHeight,
14
14
  // Enhanced focus control props
15
15
  triggerFocus = false, triggerOpen = false, onFocused, onOpened, }) => {
16
16
  var _a, _b, _c, _d, _e, _f;
@@ -276,16 +276,16 @@ triggerFocus = false, triggerOpen = false, onFocused, onOpened, }) => {
276
276
  // ============================================================================
277
277
  // Render Helper Functions
278
278
  // ============================================================================
279
- const renderOptionItem = (item, index) => (_jsx(Tooltip, { content: OptionTooltip ? _jsx(OptionTooltip, { data: item.data }) : null, side: "left", children: _jsx(StyledItem, { className: "mfFloatingItem", onClick: (e) => handleItemClick(e, item), "data-selected": (_value === null || _value === void 0 ? void 0 : _value.value) === item.value, "data-disabled": item.disabled, size: size, children: (renderOption === null || renderOption === void 0 ? void 0 : renderOption(item)) || _jsx(_Fragment, { children: item === null || item === void 0 ? void 0 : item.label }) }, index) }, index));
279
+ const renderOptionItem = (item, index) => (_jsx(Tooltip, { content: OptionTooltip ? _jsx(OptionTooltip, { data: item.data }) : null, side: "left", children: _jsx(StyledItem, { className: "mfFloatingItem", onClick: (e) => handleItemClick(e, item), "data-selected": (_value === null || _value === void 0 ? void 0 : _value.value) === item.value, "data-disabled": item.disabled, "$dynamicHeight": dynamicOptionHeight !== null && dynamicOptionHeight !== void 0 ? dynamicOptionHeight : Boolean(renderOption), size: size, children: (renderOption === null || renderOption === void 0 ? void 0 : renderOption(item)) || _jsx(_Fragment, { children: item === null || item === void 0 ? void 0 : item.label }) }, index) }, index));
280
280
  const renderActionButton = () => {
281
281
  if (clearable && (_value || !!inputValue)) {
282
- return (_jsx(ClearButton, { className: "input-btn", onClick: handleClear, onMouseDown: (e) => {
282
+ return (_jsx(ClearButton, { size: size, className: "input-btn", onClick: handleClear, onMouseDown: (e) => {
283
283
  e.preventDefault();
284
284
  e.stopPropagation();
285
285
  } }));
286
286
  }
287
287
  if (arrow) {
288
- return (_jsx(ArrowButton, { onClick: (e) => {
288
+ return (_jsx(ArrowButton, { size: size, onClick: (e) => {
289
289
  e.preventDefault();
290
290
  }, onMouseDown: (e) => {
291
291
  e.preventDefault();
@@ -393,7 +393,7 @@ triggerFocus = false, triggerOpen = false, onFocused, onOpened, }) => {
393
393
  : "",
394
394
  }, variant: variant, "data-empty": filteredItems.length === 0 }, DropDownProps, { children: [loading && _jsx(Loader, {}), !loading && actionComponent && (_jsx(ActionMenu, { onClick: () => {
395
395
  setIsOpen(false);
396
- }, children: actionComponent })), !loading && filteredItems.length === 0 && (_jsx(EmptyComponent, { children: getEmptyMessage(allowCustomValue, searchValue) })), !loading && (_jsx(StyledInnerItemContainer, { ref: scrollContainerRef, "data-scroll-active": scrollActive, onScroll: onScroll, children: grouped
396
+ }, children: actionComponent })), !loading && filteredItems.length === 0 && (_jsx(EmptyComponent, { size: size, children: getEmptyMessage(allowCustomValue, searchValue) })), !loading && (_jsx(StyledInnerItemContainer, { ref: scrollContainerRef, "data-scroll-active": scrollActive, onScroll: onScroll, children: grouped
397
397
  ? groups.map((group, index) => (_jsxs("div", { children: [_jsx(GroupTitle, { size: size, children: group.label }), group.items.map((item, index) => renderOptionItem(item, index))] }, group.label)))
398
398
  : filteredItems.map((item, index) => renderOptionItem(item, index)) }))] })) }) }))] }));
399
399
  };
@@ -4,7 +4,9 @@ export declare const StyledInputContainer: import("styled-components/dist/types"
4
4
  width?: string | number | null;
5
5
  }>> & string;
6
6
  export declare const StyledInnerItemContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
7
- export declare const EmptyComponent: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
7
+ export declare const EmptyComponent: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
8
+ size?: Size;
9
+ }>> & string;
8
10
  interface GroupTitleProps {
9
11
  className?: string;
10
12
  children?: ReactNode;
@@ -14,6 +16,7 @@ export declare const GroupTitle: import("styled-components/dist/types").IStyledC
14
16
  export declare const ActionMenu: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
15
17
  export declare const StyledItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
16
18
  size: Size;
19
+ $dynamicHeight?: boolean;
17
20
  }>> & string;
18
21
  export declare const StyledContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
19
22
  export {};
@@ -11,6 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import styled from "styled-components";
14
+ import { getControlSizeTokens } from "../core";
14
15
  export const StyledInputContainer = styled.div `
15
16
  font-family: ${({ theme }) => theme.typography.fontFamily};
16
17
 
@@ -58,7 +59,7 @@ export const EmptyComponent = styled.div `
58
59
  align-items: center;
59
60
  justify-content: center;
60
61
  padding: 5px;
61
- font-size: 12px;
62
+ font-size: ${({ size = "sm" }) => `${getControlSizeTokens(size).supportingFontSize}px`};
62
63
  font-weight: 500;
63
64
  color: ${(props) => props.theme.palette.text.secondary};
64
65
  `;
@@ -74,17 +75,8 @@ export const GroupTitle = styled((_a) => {
74
75
 
75
76
  color: ${(props) => props.theme.palette.text.secondary};
76
77
 
77
- padding: ${({ size }) => size === "xs"
78
- ? "2px 8px"
79
- : size === "sm"
80
- ? "4px 10px"
81
- : size === "md"
82
- ? "4px 12px"
83
- : size === "lg"
84
- ? "5px 14px"
85
- : size === "xl"
86
- ? "6px 16px"
87
- : "2px 8px"};
78
+ min-height: ${({ size = "sm" }) => `${getControlSizeTokens(size).menuRowHeight}px`};
79
+ padding: ${({ size = "sm" }) => `0px ${getControlSizeTokens(size).menuItemPaddingX}px`};
88
80
 
89
81
  .group-label {
90
82
  white-space: nowrap;
@@ -95,17 +87,7 @@ export const GroupTitle = styled((_a) => {
95
87
 
96
88
  font-weight: 500;
97
89
 
98
- font-size: ${({ size }) => size === "xs"
99
- ? "11px"
100
- : size === "sm"
101
- ? "13px"
102
- : size === "md"
103
- ? "15px"
104
- : size === "lg"
105
- ? "17px"
106
- : size === "xl"
107
- ? "19px"
108
- : "11px"};
90
+ font-size: ${({ size = "sm" }) => `${getControlSizeTokens(size).menuGroupFontSize}px`};
109
91
  }
110
92
 
111
93
  .group-line {
@@ -117,10 +99,11 @@ export const ActionMenu = styled.div ``;
117
99
  export const StyledItem = styled.div `
118
100
  color: ${(props) => props.theme.palette.text.primary};
119
101
  border-radius: 3px;
102
+ box-sizing: border-box;
120
103
  display: flex;
121
104
  align-items: center;
122
- min-height: 25px;
123
- padding: 7px 10px;
105
+ min-height: ${({ size }) => `${getControlSizeTokens(size).menuRowHeight}px`};
106
+ height: ${({ size, $dynamicHeight }) => $dynamicHeight ? "auto" : `${getControlSizeTokens(size).menuRowHeight}px`};
124
107
  position: relative;
125
108
  user-select: none;
126
109
  outline: none;
@@ -129,29 +112,9 @@ export const StyledItem = styled.div `
129
112
 
130
113
  font-family: ${({ theme }) => theme.typography.fontFamily};
131
114
 
132
- font-size: ${({ size }) => size === "xs"
133
- ? "11px"
134
- : size === "sm"
135
- ? "13px"
136
- : size === "md"
137
- ? "15px"
138
- : size === "lg"
139
- ? "17px"
140
- : size === "xl"
141
- ? "19px"
142
- : "11px"};
143
-
144
- padding: ${({ size }) => size === "xs"
145
- ? "2px 8px"
146
- : size === "sm"
147
- ? "4px 10px"
148
- : size === "md"
149
- ? "4px 12px"
150
- : size === "lg"
151
- ? "5px 14px"
152
- : size === "xl"
153
- ? "6px 16px"
154
- : "2px 8px"};
115
+ font-size: ${({ size }) => `${getControlSizeTokens(size).fontSize}px`};
116
+
117
+ padding: ${({ size, $dynamicHeight }) => `${$dynamicHeight ? 6 : 0}px ${getControlSizeTokens(size).menuItemPaddingX}px`};
155
118
 
156
119
  &:hover {
157
120
  background-color: ${(props) => props.theme.palette.action.hover};
@@ -34,6 +34,7 @@ export type SelectBoxProps = {
34
34
  debounceTime?: number;
35
35
  sort?: boolean;
36
36
  disabled?: boolean;
37
+ dynamicOptionHeight?: boolean;
37
38
  renderOption?: (item: Option | string) => React.ReactNode;
38
39
  OptionTooltip?: (props: {
39
40
  data: any;
@@ -2,8 +2,8 @@ import { CSSProperties, ReactNode } from "react";
2
2
  import { Size } from "../core";
3
3
  export type SwitchProps = {
4
4
  className?: string;
5
- onChange: (e: any) => void;
6
- size?: Exclude<Size, "xxs">;
5
+ onChange: (checked: boolean) => void;
6
+ size?: Size;
7
7
  label?: string;
8
8
  labelPosition?: "left" | "right";
9
9
  description?: ReactNode;
@@ -13,46 +13,22 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import styled from "styled-components";
14
14
  import * as RadixSwitch from "@radix-ui/react-switch";
15
15
  import { FieldLabel } from "..";
16
+ import { DEFAULT_CONTROL_SIZE, getControlSizeTokens } from "../core";
16
17
  import { Themes } from "../theme";
18
+ const getThumbTranslation = (size = DEFAULT_CONTROL_SIZE) => {
19
+ const { switchTrackWidth, switchThumbSize, switchPadding } = getControlSizeTokens(size);
20
+ return `${switchTrackWidth - switchThumbSize - switchPadding * 2}px`;
21
+ };
17
22
  const StyledRoot = styled(RadixSwitch.Root) `
18
23
  all: unset;
19
24
  cursor: pointer;
20
-
21
- height: ${({ size }) => size === "xs"
22
- ? "10px"
23
- : size === "sm"
24
- ? "16px"
25
- : size === "md"
26
- ? "22px"
27
- : size === "lg"
28
- ? "28px"
29
- : size === "xl"
30
- ? "32px"
31
- : "16px"};
32
-
33
- min-width: ${({ size }) => size === "xs"
34
- ? "26px"
35
- : size === "sm"
36
- ? "35px"
37
- : size === "md"
38
- ? "41px"
39
- : size === "lg"
40
- ? "53px"
41
- : size === "xl"
42
- ? "70px"
43
- : "26px"};
44
-
45
- width: ${({ size }) => size === "xs"
46
- ? "26px"
47
- : size === "sm"
48
- ? "35px"
49
- : size === "md"
50
- ? "41px"
51
- : size === "lg"
52
- ? "53px"
53
- : size === "xl"
54
- ? "70px"
55
- : "26px"};
25
+ display: inline-flex;
26
+ align-items: center;
27
+ box-sizing: border-box;
28
+ flex-shrink: 0;
29
+ height: ${({ size = DEFAULT_CONTROL_SIZE }) => `${getControlSizeTokens(size).switchTrackHeight}px`};
30
+ min-width: ${({ size = DEFAULT_CONTROL_SIZE }) => `${getControlSizeTokens(size).switchTrackWidth}px`};
31
+ width: ${({ size = DEFAULT_CONTROL_SIZE }) => `${getControlSizeTokens(size).switchTrackWidth}px`};
56
32
 
57
33
  background-color: ${({ theme }) => theme.name === Themes.DARK ? "#383838" : "#e3e3e3"};
58
34
  transition: background-color 100ms;
@@ -60,17 +36,7 @@ const StyledRoot = styled(RadixSwitch.Root) `
60
36
  border: 1px solid
61
37
  ${({ theme }) => theme.name === Themes.DARK ? theme.palette.input.border : "#e3e3e3"};
62
38
  position: relative;
63
- padding: ${({ size }) => size === "xs"
64
- ? "2px"
65
- : size === "sm"
66
- ? "2px"
67
- : size === "md"
68
- ? "2px 9px 2px 3px"
69
- : size === "lg"
70
- ? "2px 9px 2px 3px"
71
- : size === "xl"
72
- ? "2px 4px"
73
- : "2px"};
39
+ padding: ${({ size = DEFAULT_CONTROL_SIZE }) => `${getControlSizeTokens(size).switchPadding}px`};
74
40
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
75
41
 
76
42
  &[data-state="checked"] {
@@ -85,29 +51,8 @@ const StyledRoot = styled(RadixSwitch.Root) `
85
51
  `;
86
52
  const StyledThumb = styled(RadixSwitch.Thumb) `
87
53
  display: block;
88
- width: ${({ size }) => size === "xs"
89
- ? "9px"
90
- : size === "sm"
91
- ? "14px"
92
- : size === "md"
93
- ? "22px"
94
- : size === "lg"
95
- ? "28px"
96
- : size === "xl"
97
- ? "28px"
98
- : "14px"};
99
-
100
- height: ${({ size }) => size === "xs"
101
- ? "9px"
102
- : size === "sm"
103
- ? "14px"
104
- : size === "md"
105
- ? "22px"
106
- : size === "lg"
107
- ? "28px"
108
- : size === "xl"
109
- ? "28px"
110
- : "14px"};
54
+ width: ${({ size = DEFAULT_CONTROL_SIZE }) => `${getControlSizeTokens(size).switchThumbSize}px`};
55
+ height: ${({ size = DEFAULT_CONTROL_SIZE }) => `${getControlSizeTokens(size).switchThumbSize}px`};
111
56
 
112
57
  background-color: white;
113
58
  border: none;
@@ -117,25 +62,15 @@ const StyledThumb = styled(RadixSwitch.Thumb) `
117
62
  will-change: transform;
118
63
 
119
64
  &[data-state="checked"] {
120
- transform: ${({ size }) => size === "xs"
121
- ? "translateX(17px)"
122
- : size === "sm"
123
- ? "translateX(20px)"
124
- : size === "md"
125
- ? "translateX(26px)"
126
- : size === "lg"
127
- ? "translateX(32px)"
128
- : size === "xl"
129
- ? "translateX(42px)"
130
- : "translateX(17px)"};
65
+ transform: ${({ size = DEFAULT_CONTROL_SIZE }) => `translateX(${getThumbTranslation(size)})`};
131
66
  }
132
67
  `;
133
68
  export const Switch = styled((_a) => {
134
- var { className, onChange, size = "xs", label, labelPosition = "right", description, error, required, disabled = false, defaultValue, value, style = {} } = _a, other = __rest(_a, ["className", "onChange", "size", "label", "labelPosition", "description", "error", "required", "disabled", "defaultValue", "value", "style"]);
69
+ var { className, onChange, size = DEFAULT_CONTROL_SIZE, label, labelPosition = "right", description, error, required, disabled = false, defaultValue, value, style = {} } = _a, other = __rest(_a, ["className", "onChange", "size", "label", "labelPosition", "description", "error", "required", "disabled", "defaultValue", "value", "style"]);
135
70
  return (_jsxs("div", { className: className, children: [label && labelPosition === "left" && (_jsx(FieldLabel, { error: error, asterisk: required, size: size, description: description, style: { margin: 0 }, children: label })), _jsx(StyledRoot, Object.assign({ size: size, className: "SwitchRoot", onCheckedChange: onChange, defaultChecked: defaultValue, checked: value, disabled: disabled, style: style }, other, { children: _jsx(StyledThumb, { size: size, className: "SwitchThumb" }) })), label && labelPosition === "right" && (_jsx(FieldLabel, { error: error, asterisk: required, size: size, description: description, style: { margin: 0 }, children: label }))] }));
136
71
  }) `
137
72
  display: flex;
138
73
  flex-direction: row;
139
74
  align-items: center;
140
- gap: 10px;
75
+ gap: ${({ size = DEFAULT_CONTROL_SIZE }) => `${getControlSizeTokens(size).switchGap}px`};
141
76
  `;
@@ -11,6 +11,8 @@ type GetSearchStateFn = (key: string) => string;
11
11
  type SetSearchStateFn = (key: string, value: string) => void;
12
12
  type GetFilterStateFn = (key: string) => Query | undefined;
13
13
  type SetFilterStateFn = (key: string, value?: Query | null) => void;
14
+ type GetExpandedKeysFn = (key: string) => string[] | undefined;
15
+ type SetExpandedKeysFn = (key: string, value: string[]) => void;
14
16
  declare const StateStorage: {
15
17
  getTableState: GetTableStateFn;
16
18
  getColumnState: GetColumnStateFn;
@@ -23,5 +25,7 @@ declare const StateStorage: {
23
25
  setSearchState: SetSearchStateFn;
24
26
  getFilterState: GetFilterStateFn;
25
27
  setFilterState: SetFilterStateFn;
28
+ getExpandedKeys: GetExpandedKeysFn;
29
+ setExpandedKeys: SetExpandedKeysFn;
26
30
  };
27
31
  export default StateStorage;
@@ -82,6 +82,17 @@ const setFilterState = (key, value) => {
82
82
  const newState = Object.assign(Object.assign({}, previousState), { filterState: value });
83
83
  set(key, newState);
84
84
  };
85
+ const getExpandedKeys = (key) => {
86
+ const data = getTableState(key);
87
+ return data.expandedKeys;
88
+ };
89
+ const setExpandedKeys = (key, value) => {
90
+ // get previous state
91
+ const previousState = getTableState(key);
92
+ // merge previous state with new state
93
+ const newState = Object.assign(Object.assign({}, previousState), { expandedKeys: value });
94
+ set(key, newState);
95
+ };
85
96
  const StateStorage = {
86
97
  getTableState,
87
98
  getColumnState,
@@ -94,5 +105,7 @@ const StateStorage = {
94
105
  setSearchState,
95
106
  getFilterState,
96
107
  setFilterState,
108
+ getExpandedKeys,
109
+ setExpandedKeys,
97
110
  };
98
111
  export default StateStorage;
@@ -22,6 +22,7 @@ import TableMenu from "./TableMenu";
22
22
  import useTable from "./useTable";
23
23
  import LoadingIndicator from "./LoadingIndicator";
24
24
  import styled from "styled-components";
25
+ import TableDefaults from "./TableDefaults";
25
26
  const StyledTableContainer = styled.div `
26
27
  display: flex;
27
28
  flex-direction: column;
@@ -40,8 +41,20 @@ const TableContent = ({ children, }) => {
40
41
  }, ref: tableElement, "data-compact": compactState, children: [_jsx(LoadingIndicator, { visible: loading }), _jsx(TableHeader, { headerRowElm: headerRowElm }), visibleColumnCount === 0 && _jsx("div", { children: "No columns visible" }), virtualized === true ? (_jsx(VirtualizedRows, { tableDimensions: tableDimensions, targetElm: targetElm, listElm: listElm, rowHeight: rowHeight, headerRowHeight: headerRowHeight })) : (_jsx(StaticRows, { targetElm: targetElm, listElm: listElm }))] })] }));
41
42
  };
42
43
  export const Table = (_a) => {
43
- var { data, columnProps, children } = _a, props = __rest(_a, ["data", "columnProps", "children"]) // pass through props straight to table context
44
+ var { data, columnProps, children, treeOptions } = _a, props = __rest(_a, ["data", "columnProps", "children", "treeOptions"]) // pass through props straight to table context
44
45
  ;
46
+ const resolvedTreeOptions = useMemo(() => {
47
+ var _a, _b, _c, _d, _e, _f;
48
+ return ({
49
+ enabled: (_a = treeOptions === null || treeOptions === void 0 ? void 0 : treeOptions.enabled) !== null && _a !== void 0 ? _a : false,
50
+ mode: (_b = treeOptions === null || treeOptions === void 0 ? void 0 : treeOptions.mode) !== null && _b !== void 0 ? _b : TableDefaults.tree.defaultMode,
51
+ childrenField: (_c = treeOptions === null || treeOptions === void 0 ? void 0 : treeOptions.childrenField) !== null && _c !== void 0 ? _c : TableDefaults.tree.defaultChildrenField,
52
+ parentIdField: (_d = treeOptions === null || treeOptions === void 0 ? void 0 : treeOptions.parentIdField) !== null && _d !== void 0 ? _d : TableDefaults.tree.defaultParentIdField,
53
+ idField: treeOptions === null || treeOptions === void 0 ? void 0 : treeOptions.idField,
54
+ indentPx: (_e = treeOptions === null || treeOptions === void 0 ? void 0 : treeOptions.indentPx) !== null && _e !== void 0 ? _e : TableDefaults.tree.indentPx,
55
+ autoExpandOnMatch: (_f = treeOptions === null || treeOptions === void 0 ? void 0 : treeOptions.autoExpandOnMatch) !== null && _f !== void 0 ? _f : true,
56
+ });
57
+ }, [treeOptions]);
45
58
  const tableElement = useRef(null);
46
59
  const targetElm = useRef(null);
47
60
  const listElm = useRef(null);
@@ -113,18 +126,153 @@ export const Table = (_a) => {
113
126
  // Uses a WeakMap so entries are automatically garbage collected
114
127
  // when their corresponding row objects are no longer referenced.
115
128
  const uuidCache = useRef(new WeakMap());
116
- // Augment each row with a stable __key (UUID) and __index.
117
- // The WeakMap ensures that the same row object always receives
118
- // the same UUID across re-renders, preventing unnecessary DOM
119
- // reconciliation. useMemo preserves referential stability of
120
- // the output array when the data reference hasn't changed.
121
- const __data = useMemo(() => data === null || data === void 0 ? void 0 : data.map((d, i) => {
122
- let key = uuidCache.current.get(d);
129
+ const getOrAssignKey = (row) => {
130
+ let key = uuidCache.current.get(row);
123
131
  if (!key) {
124
132
  key = shortUUID.uuid();
125
- uuidCache.current.set(d, key);
133
+ uuidCache.current.set(row, key);
134
+ }
135
+ return key;
136
+ };
137
+ // Augment each row with stable metadata. When tree mode is disabled,
138
+ // produces a flat 1:1 mapping with __key and __index. When enabled,
139
+ // walks the input (nested or flat) into a flat depth-first array
140
+ // and adds tree metadata (__level, __parentKey, __hasChildren, __childKeys).
141
+ const { rows: __data, treeMeta } = useMemo(() => {
142
+ const parentKeyMap = new Map();
143
+ const childrenKeyMap = new Map();
144
+ const expandableKeys = [];
145
+ if (!data) {
146
+ return {
147
+ rows: [],
148
+ treeMeta: { parentKeyMap, childrenKeyMap, expandableKeys },
149
+ };
150
+ }
151
+ if (!resolvedTreeOptions.enabled) {
152
+ const rows = data.map((d, i) => (Object.assign(Object.assign({}, d), { __key: getOrAssignKey(d), __index: i })));
153
+ return {
154
+ rows,
155
+ treeMeta: { parentKeyMap, childrenKeyMap, expandableKeys },
156
+ };
126
157
  }
127
- return Object.assign(Object.assign({}, d), { __key: key, __index: i });
128
- }), [data]);
129
- return (_jsx(TableProvider, Object.assign({ columns: columnProps, data: __data, tableElement: tableElement, headerRowElm: headerRowElm, tableDimensions: tableDimensions, targetElm: targetElm, listElm: listElm }, props, { children: _jsx(TableContent, { children: children }) })));
158
+ const rows = [];
159
+ let counter = 0;
160
+ if (resolvedTreeOptions.mode === "nested") {
161
+ const childrenField = resolvedTreeOptions.childrenField;
162
+ const walk = (node, level, parentKey) => {
163
+ const key = getOrAssignKey(node);
164
+ const rawChildren = node === null || node === void 0 ? void 0 : node[childrenField];
165
+ const children = Array.isArray(rawChildren) ? rawChildren : [];
166
+ const childKeys = children.map((c) => getOrAssignKey(c));
167
+ // Strip the nested children field from the augmented copy to avoid
168
+ // memory bloat and prevent accidental iteration of the raw tree.
169
+ const _a = node, _b = childrenField, _stripped = _a[_b], rest = __rest(_a, [typeof _b === "symbol" ? _b : _b + ""]);
170
+ const augmented = Object.assign(Object.assign({}, rest), { __key: key, __index: counter++, __level: level, __parentKey: parentKey, __hasChildren: children.length > 0, __childKeys: childKeys });
171
+ rows.push(augmented);
172
+ parentKeyMap.set(key, parentKey);
173
+ if (children.length > 0) {
174
+ childrenKeyMap.set(key, childKeys);
175
+ expandableKeys.push(key);
176
+ }
177
+ for (const child of children) {
178
+ walk(child, level + 1, key);
179
+ }
180
+ };
181
+ const rootKeys = [];
182
+ for (const root of data) {
183
+ rootKeys.push(getOrAssignKey(root));
184
+ walk(root, 0, undefined);
185
+ }
186
+ childrenKeyMap.set(undefined, rootKeys);
187
+ }
188
+ else {
189
+ // flat mode
190
+ const idField = resolvedTreeOptions.idField || props.keyField;
191
+ if (!idField) {
192
+ throw new Error('Table treeOptions.mode="flat" requires either treeOptions.idField or keyField to be set so the table can resolve parent-child relationships against a stable id.');
193
+ }
194
+ const parentIdField = resolvedTreeOptions.parentIdField;
195
+ // Pass 1: assign __key, build idToKey
196
+ const idToKey = new Map();
197
+ const idToRow = new Map();
198
+ for (const d of data) {
199
+ const id = d === null || d === void 0 ? void 0 : d[idField];
200
+ if (id === undefined || id === null)
201
+ continue;
202
+ idToKey.set(id, getOrAssignKey(d));
203
+ idToRow.set(id, d);
204
+ }
205
+ // Pass 2: build parent->children id map. Roots = parentId null/undefined
206
+ // OR parentId points at a non-existent row.
207
+ const parentToChildIds = new Map();
208
+ const rootIds = [];
209
+ let warnedOrphan = false;
210
+ for (const d of data) {
211
+ const id = d === null || d === void 0 ? void 0 : d[idField];
212
+ if (id === undefined || id === null)
213
+ continue;
214
+ const parentId = d === null || d === void 0 ? void 0 : d[parentIdField];
215
+ if (parentId === undefined || parentId === null) {
216
+ rootIds.push(id);
217
+ continue;
218
+ }
219
+ if (!idToRow.has(parentId)) {
220
+ if (!warnedOrphan) {
221
+ // eslint-disable-next-line no-console
222
+ console.warn(`Table tree (flat mode): row id "${id}" references missing parentId "${parentId}"; treating as root.`);
223
+ warnedOrphan = true;
224
+ }
225
+ rootIds.push(id);
226
+ continue;
227
+ }
228
+ if (!parentToChildIds.has(parentId))
229
+ parentToChildIds.set(parentId, []);
230
+ parentToChildIds.get(parentId).push(id);
231
+ }
232
+ // Pass 3: DFS from roots with cycle detection
233
+ const visiting = new Set();
234
+ let warnedCycle = false;
235
+ const walkFlat = (id, level, parentKey) => {
236
+ if (visiting.has(id)) {
237
+ if (!warnedCycle) {
238
+ // eslint-disable-next-line no-console
239
+ console.warn(`Table tree (flat mode): cycle detected at row id "${id}"; truncating subtree.`);
240
+ warnedCycle = true;
241
+ }
242
+ return;
243
+ }
244
+ visiting.add(id);
245
+ const node = idToRow.get(id);
246
+ const key = idToKey.get(id);
247
+ const childIds = parentToChildIds.get(id) || [];
248
+ const childKeys = childIds
249
+ .map((cid) => idToKey.get(cid))
250
+ .filter((k) => !!k);
251
+ const augmented = Object.assign(Object.assign({}, node), { __key: key, __index: counter++, __level: level, __parentKey: parentKey, __hasChildren: childIds.length > 0, __childKeys: childKeys });
252
+ rows.push(augmented);
253
+ parentKeyMap.set(key, parentKey);
254
+ if (childIds.length > 0) {
255
+ childrenKeyMap.set(key, childKeys);
256
+ expandableKeys.push(key);
257
+ }
258
+ for (const cid of childIds) {
259
+ walkFlat(cid, level + 1, key);
260
+ }
261
+ visiting.delete(id);
262
+ };
263
+ const rootKeys = [];
264
+ for (const id of rootIds) {
265
+ const k = idToKey.get(id);
266
+ if (k)
267
+ rootKeys.push(k);
268
+ walkFlat(id, 0, undefined);
269
+ }
270
+ childrenKeyMap.set(undefined, rootKeys);
271
+ }
272
+ return {
273
+ rows,
274
+ treeMeta: { parentKeyMap, childrenKeyMap, expandableKeys },
275
+ };
276
+ }, [data, resolvedTreeOptions, props.keyField]);
277
+ return (_jsx(TableProvider, Object.assign({ columns: columnProps, data: __data, tableElement: tableElement, headerRowElm: headerRowElm, tableDimensions: tableDimensions, targetElm: targetElm, listElm: listElm, treeOptions: resolvedTreeOptions, treeMeta: treeMeta }, props, { children: _jsx(TableContent, { children: children }) })));
130
278
  };
@@ -6,6 +6,16 @@ export declare const THR: import("styled-components/dist/types").IStyledComponen
6
6
  export declare const TD: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, TDProps>> & string;
7
7
  export declare const TH: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof TDProps> & TDProps, never>> & string;
8
8
  export declare const InnerCellContent: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
9
+ export declare const TreeCellWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
10
+ export declare const TreeIndentSpacer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
11
+ $level: number;
12
+ $indentPx: number;
13
+ }>> & string;
14
+ export declare const TreeChevronButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {
15
+ $expanded: boolean;
16
+ }>> & string;
17
+ export declare const TreeChevronPlaceholder: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
18
+ export declare const TreeCellContent: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
9
19
  export declare const TableViewPort: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
10
20
  export declare const TableListElement: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
11
21
  export declare const TableWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;