xmlui 0.9.65 → 0.9.67

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 (113) hide show
  1. package/dist/lib/{apiInterceptorWorker-COjte0L0.mjs → apiInterceptorWorker-JRzJvZYD.mjs} +1 -1
  2. package/dist/lib/{index-E-Ytu3U3.mjs → index-CcvStYZ-.mjs} +17090 -27060
  3. package/dist/lib/index.css +1 -1
  4. package/dist/lib/language-server-web-worker.mjs +1 -1
  5. package/dist/lib/language-server.mjs +1 -1
  6. package/dist/lib/{metadata-utils-CeJek2aP.mjs → metadata-utils-Bes0jMw3.mjs} +1 -1
  7. package/dist/lib/{server-common-Dtnes4sR.mjs → server-common-LUcdzTQs.mjs} +4471 -4526
  8. package/dist/lib/{transform--lQ60cbR.mjs → transform-C_5kSXBN.mjs} +31 -4
  9. package/dist/lib/xmlui-parser.d.ts +7 -0
  10. package/dist/lib/xmlui-parser.mjs +2 -2
  11. package/dist/lib/{xmlui-serializer-B1QY_Hg9.mjs → xmlui-serializer-jEIItW8v.mjs} +1 -1
  12. package/dist/lib/xmlui.d.ts +16 -29
  13. package/dist/lib/xmlui.mjs +2 -2
  14. package/dist/metadata/{apiInterceptorWorker-BK3aQR7T.mjs → apiInterceptorWorker-CkH3kF96.mjs} +1 -1
  15. package/dist/metadata/{collectedComponentMetadata-yjl6u0V8.mjs → collectedComponentMetadata-BarV5tXf.mjs} +17610 -26338
  16. package/dist/metadata/style.css +1 -1
  17. package/dist/metadata/xmlui-metadata.mjs +1 -1
  18. package/dist/metadata/xmlui-metadata.umd.js +127 -134
  19. package/dist/scripts/package.json +6 -3
  20. package/dist/scripts/src/components/APICall/APICall.js +9 -8
  21. package/dist/scripts/src/components/Accordion/AccordionItem.js +1 -0
  22. package/dist/scripts/src/components/App/AppNative.js +10 -7
  23. package/dist/scripts/src/components/App/LinkInfoContext.js +9 -0
  24. package/dist/scripts/src/components/AppState/AppState.js +1 -0
  25. package/dist/scripts/src/components/AutoComplete/AutoComplete.js +2 -2
  26. package/dist/scripts/src/components/Avatar/Avatar.js +1 -0
  27. package/dist/scripts/src/components/Avatar/AvatarNative.js +16 -11
  28. package/dist/scripts/src/components/Bookmark/Bookmark.js +1 -0
  29. package/dist/scripts/src/components/Breakout/Breakout.js +1 -0
  30. package/dist/scripts/src/components/Button/Button.js +1 -1
  31. package/dist/scripts/src/components/Card/Card.js +1 -0
  32. package/dist/scripts/src/components/Carousel/CarouselItem.js +3 -1
  33. package/dist/scripts/src/components/ChangeListener/ChangeListener.js +1 -0
  34. package/dist/scripts/src/components/Charts/BarChart/BarChart.js +1 -1
  35. package/dist/scripts/src/components/Charts/BarChart/BarChartNative.js +85 -7
  36. package/dist/scripts/src/components/Charts/DonutChart/DonutChart.js +1 -1
  37. package/dist/scripts/src/components/Charts/LabelList/LabelList.js +1 -1
  38. package/dist/scripts/src/components/Charts/Legend/Legend.js +1 -1
  39. package/dist/scripts/src/components/Charts/LineChart/LineChart.js +1 -1
  40. package/dist/scripts/src/components/Charts/LineChart/LineChartNative.js +69 -18
  41. package/dist/scripts/src/components/Charts/PieChart/PieChart.js +1 -1
  42. package/dist/scripts/src/components/Charts/PieChart/PieChartNative.js +2 -2
  43. package/dist/scripts/src/components/Checkbox/Checkbox.js +1 -3
  44. package/dist/scripts/src/components/CodeBlock/CodeBlock.js +3 -1
  45. package/dist/scripts/src/components/CodeBlock/CodeBlockNative.js +2 -25
  46. package/dist/scripts/src/components/CodeBlock/highlight-code.js +102 -69
  47. package/dist/scripts/src/components/ColorPicker/ColorPicker.js +1 -0
  48. package/dist/scripts/src/components/Column/Column.js +1 -0
  49. package/dist/scripts/src/components/ContentSeparator/ContentSeparator.js +1 -0
  50. package/dist/scripts/src/components/DropdownMenu/DropdownMenu.js +4 -0
  51. package/dist/scripts/src/components/ExpandableItem/ExpandableItem.js +1 -0
  52. package/dist/scripts/src/components/FileUploadDropZone/FileUploadDropZone.js +1 -0
  53. package/dist/scripts/src/components/FlowLayout/FlowLayout.js +1 -0
  54. package/dist/scripts/src/components/Footer/Footer.js +1 -0
  55. package/dist/scripts/src/components/FormItem/FormItem.js +1 -3
  56. package/dist/scripts/src/components/Heading/Heading.js +7 -0
  57. package/dist/scripts/src/components/HelloWorld/HelloWorld.js +1 -1
  58. package/dist/scripts/src/components/HtmlTags/HtmlTags.js +114 -100
  59. package/dist/scripts/src/components/Image/Image.js +1 -0
  60. package/dist/scripts/src/components/Items/Items.js +1 -0
  61. package/dist/scripts/src/components/Link/Link.js +1 -0
  62. package/dist/scripts/src/components/Logo/Logo.js +6 -1
  63. package/dist/scripts/src/components/Logo/LogoNative.js +3 -2
  64. package/dist/scripts/src/components/Markdown/Markdown.js +1 -0
  65. package/dist/scripts/src/components/ModalDialog/ModalDialog.js +1 -0
  66. package/dist/scripts/src/components/NavGroup/NavGroup.js +1 -0
  67. package/dist/scripts/src/components/NavLink/NavLink.js +1 -0
  68. package/dist/scripts/src/components/NavPanel/NavPanel.js +9 -2
  69. package/dist/scripts/src/components/NavPanel/NavPanelNative.js +10 -9
  70. package/dist/scripts/src/components/NestedApp/AppWithCodeView.js +1 -1
  71. package/dist/scripts/src/components/NestedApp/AppWithCodeViewNative.js +5 -14
  72. package/dist/scripts/src/components/NestedApp/NestedApp.js +1 -0
  73. package/dist/scripts/src/components/NestedApp/NestedAppNative.js +2 -1
  74. package/dist/scripts/src/components/NoResult/NoResult.js +1 -0
  75. package/dist/scripts/src/components/Option/Option.js +1 -0
  76. package/dist/scripts/src/components/PageMetaTitle/PageMetaTitle.js +1 -0
  77. package/dist/scripts/src/components/Pages/Pages.js +1 -0
  78. package/dist/scripts/src/components/Pages/PagesNative.js +2 -7
  79. package/dist/scripts/src/components/ProgressBar/ProgressBar.js +1 -0
  80. package/dist/scripts/src/components/Queue/Queue.js +1 -0
  81. package/dist/scripts/src/components/RadioGroup/RadioGroup.js +1 -0
  82. package/dist/scripts/src/components/RadioGroup/RadioGroupNative.js +6 -4
  83. package/dist/scripts/src/components/RadioGroup/RadioItem.js +5 -2
  84. package/dist/scripts/src/components/RadioGroup/RadioItemNative.js +11 -3
  85. package/dist/scripts/src/components/Redirect/Redirect.js +1 -0
  86. package/dist/scripts/src/components/Select/Select.js +2 -2
  87. package/dist/scripts/src/components/SpaceFiller/SpaceFiller.js +1 -0
  88. package/dist/scripts/src/components/Spinner/Spinner.js +1 -0
  89. package/dist/scripts/src/components/Splitter/Splitter.js +1 -0
  90. package/dist/scripts/src/components/Stack/Stack.js +1 -0
  91. package/dist/scripts/src/components/Switch/Switch.js +1 -0
  92. package/dist/scripts/src/components/Table/Table.js +1 -0
  93. package/dist/scripts/src/components/TableEditor/TableEditor.js +1 -1
  94. package/dist/scripts/src/components/TableOfContents/TableOfContents.js +1 -1
  95. package/dist/scripts/src/components/Tabs/TabItem.js +1 -0
  96. package/dist/scripts/src/components/Tabs/TabItemNative.js +1 -2
  97. package/dist/scripts/src/components/Tabs/Tabs.js +1 -5
  98. package/dist/scripts/src/components/Text/Text.js +1 -0
  99. package/dist/scripts/src/components/Theme/Theme.js +1 -0
  100. package/dist/scripts/src/components/Toggle/Toggle.js +1 -0
  101. package/dist/scripts/src/components/ValidationSummary/ValidationSummary.js +62 -3
  102. package/dist/scripts/src/components-core/Fragment.js +1 -0
  103. package/dist/scripts/src/components-core/XmluiCodeHighlighter.js +3 -1
  104. package/dist/scripts/src/components-core/loader/ApiLoader.js +1 -0
  105. package/dist/scripts/src/components-core/loader/DataLoader.js +1 -0
  106. package/dist/scripts/src/components-core/loader/ExternalDataLoader.js +1 -0
  107. package/dist/scripts/src/components-core/loader/MockLoaderRenderer.js +1 -0
  108. package/dist/scripts/src/components-core/rendering/StateContainer.js +11 -7
  109. package/dist/scripts/src/parsers/xmlui-parser/transform.js +28 -0
  110. package/dist/standalone/xmlui-standalone.es.d.ts +18 -29
  111. package/dist/standalone/xmlui-standalone.umd.js +243 -243
  112. package/package.json +6 -3
  113. package/dist/scripts/src/components/ValidationSummary/ValidationSummaryNative.js +0 -64
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xmlui",
3
- "version": "0.9.65",
3
+ "version": "0.9.67",
4
4
  "sideEffects": false,
5
5
  "scripts": {
6
6
  "start-test-bed": "cd src/testing/infrastructure && xmlui start",
@@ -9,7 +9,6 @@
9
9
  "build:xmlui": "vite build --mode lib",
10
10
  "build:xmlui-standalone": "vite build --mode standalone",
11
11
  "build:xmlui-metadata": "vite build --mode metadata",
12
- "build:ext-meta": "node scripts/build-extension-packages/build-extension-packages.mjs",
13
12
  "test:unit": "vitest run",
14
13
  "test:e2e-non-smoke": "playwright test --project non-smoke",
15
14
  "test:e2e-smoke": "playwright test --project smoke",
@@ -50,6 +49,10 @@
50
49
  "@tanstack/react-virtual": "3.10.8",
51
50
  "@tiptap/react": "^2.23.0",
52
51
  "@tiptap/starter-kit": "^2.23.0",
52
+ "@tiptap/extension-table": "^2.23.0",
53
+ "@tiptap/extension-table-cell": "^2.23.0",
54
+ "@tiptap/extension-table-header": "^2.23.0",
55
+ "@tiptap/extension-table-row": "^2.23.0",
53
56
  "@types/chroma-js": "^3.1.1",
54
57
  "@types/color": "3.0.6",
55
58
  "@vitejs/plugin-react": "4.3.0",
@@ -247,7 +250,7 @@
247
250
  ]
248
251
  },
249
252
  "repository": {
250
- "url": "https://github.com/xmlui-com/xmlui.git"
253
+ "url": "https://github.com/xmlui-org/xmlui.git"
251
254
  },
252
255
  "msw": {
253
256
  "workerDirectory": "src/testing/infrastructure/public"
@@ -8,6 +8,7 @@ const abstractions_1 = require("../abstractions");
8
8
  const APICallNative_1 = require("./APICallNative");
9
9
  const COMP = "APICall";
10
10
  exports.APICallMd = (0, metadata_helpers_1.createMetadata)({
11
+ status: "stable",
11
12
  description: "`APICall` creates, updates or deletes data on the backend, versus [`DataSource`]" +
12
13
  "(/components/DataSource) which fetches data. Unlike DataSource, APICall doesn't " +
13
14
  "automatically execute - you must trigger it manually with the `execute()` method, " +
@@ -86,37 +87,37 @@ exports.APICallMd = (0, metadata_helpers_1.createMetadata)({
86
87
  events: {
87
88
  beforeRequest: {
88
89
  description: "This event fires before the request is sent. Returning an explicit boolean" +
89
- "\`false\` value will prevent the request from being sent."
90
+ "\`false\` value will prevent the request from being sent.",
90
91
  },
91
92
  success: {
92
- description: "This event fires when a request results in a success."
93
+ description: "This event fires when a request results in a success.",
93
94
  },
94
95
  // This event fires when a request results in an error.
95
96
  error: {
96
- description: "This event fires when a request results in an error."
97
+ description: "This event fires when a request results in an error.",
97
98
  },
98
99
  progress: (0, metadata_helpers_1.dInternal)(),
99
100
  },
100
101
  contextVars: {
101
102
  $param: {
102
- description: "The first parameter passed to `execute()` method"
103
+ description: "The first parameter passed to `execute()` method",
103
104
  },
104
105
  $params: {
105
106
  description: "Array of all parameters passed to `execute()` method (access with " +
106
- "`$params[0]`, `$params[1]`, etc.)"
107
+ "`$params[0]`, `$params[1]`, etc.)",
107
108
  },
108
109
  $result: {
109
- description: "Response data (available in `completedNotificationMessage` and `success` event)"
110
+ description: "Response data (available in `completedNotificationMessage` and `success` event)",
110
111
  },
111
112
  $error: {
112
- description: "Error details (available in `errorNotificationMessage` and `error` event)"
113
+ description: "Error details (available in `errorNotificationMessage` and `error` event)",
113
114
  },
114
115
  },
115
116
  apis: {
116
117
  execute: {
117
118
  description: "This method triggers the invocation of the API. You can pass an arbitrary " +
118
119
  "number of parameters to the method. In the \`APICall\` instance, you can " +
119
- "access those with the \`$param\` and \`$params\` context values."
120
+ "access those with the \`$param\` and \`$params\` context values.",
120
121
  },
121
122
  },
122
123
  });
@@ -8,6 +8,7 @@ const container_helpers_1 = require("../../components/container-helpers");
8
8
  const AccordionItemNative_1 = require("../../components/Accordion/AccordionItemNative");
9
9
  const COMP = "AccordionItem";
10
10
  exports.AccordionItemMd = (0, metadata_helpers_1.createMetadata)({
11
+ status: "in progress",
11
12
  description: `\`${COMP}\` is a non-visual component describing a tab. Tabs component may use nested ` +
12
13
  `${COMP} instances from which the user can select.`,
13
14
  props: {
@@ -33,6 +33,7 @@ const Sheet_1 = require("../../components/App/Sheet");
33
33
  const AppHeaderNative_1 = require("../../components/AppHeader/AppHeaderNative");
34
34
  const AppLayoutContext_1 = require("./AppLayoutContext");
35
35
  const SearchContext_1 = require("./SearchContext");
36
+ const LinkInfoContext_1 = require("./LinkInfoContext");
36
37
  exports.defaultProps = {
37
38
  scrollWholePage: true,
38
39
  noScrollbarGutters: false,
@@ -139,10 +140,10 @@ function App({ children, style, layout, loggedInUser, scrollWholePage = exports.
139
140
  });
140
141
  }, [forceRefreshAnchorScroll]);
141
142
  const [subNavPanelSlot, setSubNavPanelSlot] = (0, react_1.useState)(null);
142
- const [linkMap, setLinkMap] = (0, react_1.useState)(new Map());
143
143
  const registerSubNavPanelSlot = (0, react_1.useCallback)((element) => {
144
144
  setSubNavPanelSlot(element);
145
145
  }, []);
146
+ const [linkMap, setLinkMap] = (0, react_1.useState)(new Map());
146
147
  const registerLinkMap = (0, react_1.useCallback)((newLinkMap) => {
147
148
  setLinkMap(newLinkMap);
148
149
  }, []);
@@ -168,8 +169,6 @@ function App({ children, style, layout, loggedInUser, scrollWholePage = exports.
168
169
  registerSubNavPanelSlot,
169
170
  subNavPanelSlot,
170
171
  isNested: (appGlobals === null || appGlobals === void 0 ? void 0 : appGlobals.isNested) || false,
171
- linkMap,
172
- registerLinkMap,
173
172
  };
174
173
  }, [
175
174
  hasRegisteredNavPanel,
@@ -186,9 +185,13 @@ function App({ children, style, layout, loggedInUser, scrollWholePage = exports.
186
185
  registerSubNavPanelSlot,
187
186
  subNavPanelSlot,
188
187
  appGlobals === null || appGlobals === void 0 ? void 0 : appGlobals.isNested,
189
- linkMap,
190
- registerLinkMap,
191
188
  ]);
189
+ const linkInfoContextValue = (0, react_1.useMemo)(() => {
190
+ return {
191
+ linkMap,
192
+ registerLinkMap
193
+ };
194
+ }, [linkMap, registerLinkMap]);
192
195
  (0, react_1.useEffect)(() => {
193
196
  if (navPanelVisible) {
194
197
  setDrawerVisible(false);
@@ -239,14 +242,14 @@ function App({ children, style, layout, loggedInUser, scrollWholePage = exports.
239
242
  throw new Error("layout type not supported: " + safeLayout);
240
243
  }
241
244
  // Memoize the rendered nav panel in drawer to prevent unnecessary re-renders
242
- const memoizedNavPanelInDrawer = (0, react_1.useMemo)(() => renderChild && navPanelDef ? renderChild(navPanelDef, { inDrawer: true }) : null, [renderChild, navPanelDef]);
245
+ const memoizedNavPanelInDrawer = (0, react_1.useMemo)(() => (renderChild && navPanelDef ? renderChild(navPanelDef, { inDrawer: true }) : null), [renderChild, navPanelDef]);
243
246
  // Memoize the helmet component
244
247
  const memoizedHelmet = (0, react_1.useMemo)(() => name !== undefined ? (0, jsx_runtime_1.jsx)(react_helmet_async_1.Helmet, { defaultTitle: name, titleTemplate: `%s | ${name}` }) : null, [name]);
245
248
  // Memoize the onOpenChange callback
246
249
  const handleOpenChange = (0, react_1.useCallback)((open) => {
247
250
  setDrawerVisible(open);
248
251
  }, []);
249
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [memoizedHelmet, (0, jsx_runtime_1.jsx)(AppLayoutContext_1.AppLayoutContext.Provider, { value: layoutContextValue, children: (0, jsx_runtime_1.jsxs)(SearchContext_1.SearchContextProvider, { children: [(0, jsx_runtime_1.jsx)(Sheet_1.Sheet, { open: drawerVisible, onOpenChange: handleOpenChange, children: (0, jsx_runtime_1.jsx)(Sheet_1.SheetContent, { side: "left", children: memoizedNavPanelInDrawer }) }), content] }) })] }));
252
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [memoizedHelmet, (0, jsx_runtime_1.jsx)(AppLayoutContext_1.AppLayoutContext.Provider, { value: layoutContextValue, children: (0, jsx_runtime_1.jsx)(LinkInfoContext_1.LinkInfoContext.Provider, { value: linkInfoContextValue, children: (0, jsx_runtime_1.jsxs)(SearchContext_1.SearchContextProvider, { children: [(0, jsx_runtime_1.jsx)(Sheet_1.Sheet, { open: drawerVisible, onOpenChange: handleOpenChange, children: (0, jsx_runtime_1.jsx)(Sheet_1.SheetContent, { side: "left", children: memoizedNavPanelInDrawer }) }), content] }) }) })] }));
250
253
  }
251
254
  function getAppLayoutOrientation(appLayout) {
252
255
  switch (appLayout) {
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LinkInfoContext = void 0;
4
+ exports.useLinkInfoContext = useLinkInfoContext;
5
+ const react_1 = require("react");
6
+ exports.LinkInfoContext = (0, react_1.createContext)(null);
7
+ function useLinkInfoContext() {
8
+ return (0, react_1.useContext)(exports.LinkInfoContext);
9
+ }
@@ -7,6 +7,7 @@ const metadata_helpers_1 = require("../metadata-helpers");
7
7
  const AppStateNative_1 = require("./AppStateNative");
8
8
  const COMP = "AppState";
9
9
  exports.AppStateMd = (0, metadata_helpers_1.createMetadata)({
10
+ status: "stable",
10
11
  description: "`AppState` is an invisible component that provides global state management " +
11
12
  "across your entire application. Unlike component variables that are scoped " +
12
13
  "locally, AppState allows any component to access and update shared state " +
@@ -13,11 +13,11 @@ const metadata_helpers_1 = require("../metadata-helpers");
13
13
  const AutoCompleteNative_1 = require("./AutoCompleteNative");
14
14
  const COMP = "AutoComplete";
15
15
  exports.AutoCompleteMd = (0, metadata_helpers_1.createMetadata)({
16
+ status: "experimental",
16
17
  description: "`AutoComplete` is a searchable dropdown input that allows users to type and " +
17
18
  "filter through options, with support for single or multiple selections. Unlike " +
18
19
  "a basic [`Select`](/components/Select), it provides type-ahead functionality " +
19
20
  "and can allow users to create new options.",
20
- status: "experimental",
21
21
  props: {
22
22
  placeholder: (0, metadata_helpers_1.dPlaceholder)(),
23
23
  initialValue: (0, metadata_helpers_1.dInitialValue)(),
@@ -36,7 +36,7 @@ exports.AutoCompleteMd = (0, metadata_helpers_1.createMetadata)({
36
36
  multi: Object.assign(Object.assign({}, (0, metadata_helpers_1.dMulti)()), { defaultValue: AutoCompleteNative_1.defaultProps.multi }),
37
37
  optionTemplate: (0, metadata_helpers_1.dComponent)(`This property enables the customization of list items. To access the attributes of ` +
38
38
  `a list item use the \`$item\` context variable.`),
39
- emptyListTemplate: (0, metadata_helpers_1.d)("This property defines the template to display when the list of options is empty."),
39
+ emptyListTemplate: (0, metadata_helpers_1.dComponent)("This property defines the template to display when the list of options is empty."),
40
40
  },
41
41
  events: {
42
42
  gotFocus: (0, metadata_helpers_1.dGotFocus)(COMP),
@@ -13,6 +13,7 @@ const AvatarNative_1 = require("./AvatarNative");
13
13
  const metadata_helpers_1 = require("../metadata-helpers");
14
14
  const COMP = "Avatar";
15
15
  exports.AvatarMd = (0, metadata_helpers_1.createMetadata)({
16
+ status: "stable",
16
17
  description: "`Avatar` displays a user or entity's profile picture as a circular image, " +
17
18
  "with automatic fallback to initials when no image is provided. It's commonly " +
18
19
  "used in headers, user lists, comments, and anywhere you need to represent a " +
@@ -22,22 +22,27 @@ const Avatar_module_scss_1 = __importDefault(require("./Avatar.module.scss"));
22
22
  exports.defaultProps = {
23
23
  size: "sm",
24
24
  };
25
- exports.Avatar = (0, react_1.forwardRef)(function Avatar(_a, ref) {
25
+ exports.Avatar = (0, react_1.memo)((0, react_1.forwardRef)(function Avatar(_a, ref) {
26
26
  var { size = exports.defaultProps.size, url, name, style, onClick } = _a, rest = __rest(_a, ["size", "url", "name", "style", "onClick"]);
27
- const commonClassNames = (0, classnames_1.default)(Avatar_module_scss_1.default.container, {
28
- [Avatar_module_scss_1.default.xs]: size === "xs",
29
- [Avatar_module_scss_1.default.sm]: size === "sm",
30
- [Avatar_module_scss_1.default.md]: size === "md",
31
- [Avatar_module_scss_1.default.lg]: size === "lg",
32
- [Avatar_module_scss_1.default.clickable]: !!onClick,
33
- });
27
+ // Memoize the abbreviated name calculation to avoid recalculation on every render
28
+ const abbreviatedName = (0, react_1.useMemo)(() => abbrevName(name !== null && name !== void 0 ? name : null), [name]);
29
+ // Handle keyboard events for accessibility
30
+ const handleKeyDown = (event) => {
31
+ if (onClick && (event.key === 'Enter' || event.key === ' ')) {
32
+ event.preventDefault();
33
+ onClick(event);
34
+ }
35
+ };
36
+ // Simplified className generation by directly mapping size to styles
37
+ const commonClassNames = (0, classnames_1.default)(Avatar_module_scss_1.default.container, Avatar_module_scss_1.default[size] || Avatar_module_scss_1.default.sm, // Fallback to sm if size not found
38
+ { [Avatar_module_scss_1.default.clickable]: !!onClick });
34
39
  const altTxt = !!name ? `Avatar of ${name}` : "Avatar";
35
40
  if (url) {
36
- return ((0, jsx_runtime_1.jsx)("img", Object.assign({}, rest, { ref: ref, src: url, alt: altTxt, className: commonClassNames, style: style, onClick: onClick })));
41
+ return ((0, jsx_runtime_1.jsx)("img", Object.assign({}, rest, { ref: ref, src: url, alt: altTxt, className: commonClassNames, style: style, onClick: onClick, onKeyDown: handleKeyDown, tabIndex: onClick ? 0 : undefined })));
37
42
  }
38
43
  else
39
- return ((0, jsx_runtime_1.jsx)("div", Object.assign({}, rest, { ref: ref, className: commonClassNames, style: style, onClick: onClick, role: "img", "aria-label": altTxt, children: abbrevName(name) || (0, jsx_runtime_1.jsx)("span", { "aria-hidden": "true" }) })));
40
- });
44
+ return ((0, jsx_runtime_1.jsx)("div", Object.assign({}, rest, { ref: ref, className: commonClassNames, style: style, onClick: onClick, onKeyDown: handleKeyDown, role: "img", "aria-label": altTxt, tabIndex: onClick ? 0 : undefined, children: abbreviatedName || (0, jsx_runtime_1.jsx)("span", { "aria-hidden": "true" }) })));
45
+ }));
41
46
  function abbrevName(name) {
42
47
  if (!!name) {
43
48
  const abbrev = name
@@ -7,6 +7,7 @@ const metadata_helpers_1 = require("../metadata-helpers");
7
7
  const BookmarkNative_1 = require("./BookmarkNative");
8
8
  const COMP = "Bookmark";
9
9
  exports.BookmarkMd = (0, metadata_helpers_1.createMetadata)({
10
+ status: "stable",
10
11
  description: "As its name suggests, this component places a bookmark into its parent component's view. The " +
11
12
  "component has an \`id\` that you can use in links to navigate (scroll to) the bookmark's location.",
12
13
  opaque: true,
@@ -7,6 +7,7 @@ const metadata_helpers_1 = require("../metadata-helpers");
7
7
  const BreakoutNative_1 = require("./BreakoutNative");
8
8
  const COMP = "Breakout";
9
9
  exports.BreakoutMd = (0, metadata_helpers_1.createMetadata)({
10
+ status: "stable",
10
11
  description: `The \`${COMP}\` component creates a breakout section. It allows its child to ` +
11
12
  `occupy the entire width of the UI even if the app or the parent container constrains ` +
12
13
  `the maximum content width.`,
@@ -14,10 +14,10 @@ const IconNative_1 = require("../Icon/IconNative");
14
14
  const ButtonNative_1 = require("./ButtonNative");
15
15
  const COMP = "Button";
16
16
  exports.ButtonMd = (0, metadata_helpers_1.createMetadata)({
17
+ status: "stable",
17
18
  description: "`Button` is the primary interactive component for triggering actions like " +
18
19
  "form submissions, navigation, opening modals, and API calls. It supports " +
19
20
  "multiple visual styles and sizes to match different UI contexts and importance levels.",
20
- status: "stable",
21
21
  props: {
22
22
  autoFocus: {
23
23
  description: "Indicates if the button should receive focus when the page loads.",
@@ -13,6 +13,7 @@ const abstractions_1 = require("../abstractions");
13
13
  const CardNative_1 = require("./CardNative");
14
14
  const COMP = "Card";
15
15
  exports.CardMd = (0, metadata_helpers_1.createMetadata)({
16
+ status: "stable",
16
17
  description: "`Card` is a versatile container that groups related content with a visual " +
17
18
  "boundary, typically featuring background color, padding, borders, and rounded " +
18
19
  "corners. It's ideal for organizing information, creating sections, and " +
@@ -6,7 +6,9 @@ const renderers_1 = require("../../components-core/renderers");
6
6
  const metadata_helpers_1 = require("../metadata-helpers");
7
7
  const CarouselItemNative_1 = require("./CarouselItemNative");
8
8
  const COMP = "CarouselItem";
9
- exports.CarouselItemMd = (0, metadata_helpers_1.createMetadata)({});
9
+ exports.CarouselItemMd = (0, metadata_helpers_1.createMetadata)({
10
+ status: "in progress",
11
+ });
10
12
  exports.carouselItemComponentRenderer = (0, renderers_1.createComponentRenderer)(COMP, exports.CarouselItemMd, (rendererContext) => {
11
13
  const { node, renderChild } = rendererContext;
12
14
  return (0, jsx_runtime_1.jsx)(CarouselItemNative_1.CarouselItemComponent, { children: renderChild(node.children) });
@@ -7,6 +7,7 @@ const metadata_helpers_1 = require("../metadata-helpers");
7
7
  const ChangeListenerNative_1 = require("./ChangeListenerNative");
8
8
  const COMP = "ChangeListener";
9
9
  exports.ChangeListenerMd = (0, metadata_helpers_1.createMetadata)({
10
+ status: "stable",
10
11
  description: "`ChangeListener` is an invisible component that watches for changes in values " +
11
12
  "and triggers actions in response. It's essential for creating reactive behavior " +
12
13
  "when you need to respond to data changes, state updates, or component property " +
@@ -7,10 +7,10 @@ const renderers_1 = require("../../../components-core/renderers");
7
7
  const metadata_helpers_1 = require("../../metadata-helpers");
8
8
  const COMP = "BarChart";
9
9
  exports.BarChartMd = (0, metadata_helpers_1.createMetadata)({
10
+ status: "experimental",
10
11
  description: "`BarChart` displays data as horizontal or vertical bars, supporting both grouped " +
11
12
  "and stacked layouts. It's ideal for comparing values across categories, showing " +
12
13
  "revenue trends, or displaying any quantitative data over time or categories.",
13
- status: "experimental",
14
14
  docFolder: "Charts/BarChart",
15
15
  props: {
16
16
  data: {
@@ -38,9 +38,10 @@ exports.BarChart = BarChart;
38
38
  const jsx_runtime_1 = require("react/jsx-runtime");
39
39
  const recharts_1 = require("recharts");
40
40
  const react_1 = require("react");
41
- const xmlui_1 = require("xmlui");
41
+ const react_2 = require("react");
42
42
  const ChartProvider_1 = __importStar(require("../utils/ChartProvider"));
43
43
  const TooltipContent_1 = require("../Tooltip/TooltipContent");
44
+ const ThemeContext_1 = require("../../../components-core/theming/ThemeContext");
44
45
  exports.defaultProps = {
45
46
  layout: "vertical",
46
47
  stacked: false,
@@ -52,8 +53,8 @@ exports.defaultProps = {
52
53
  showLegend: false,
53
54
  };
54
55
  function BarChart({ data = [], layout = exports.defaultProps.layout, nameKey, stacked = exports.defaultProps.stacked, dataKeys = [], hideTickX = exports.defaultProps.hideTickX, hideTickY = exports.defaultProps.hideTickY, hideY = exports.defaultProps.hideY, hideX = exports.defaultProps.hideX, tickFormatter = exports.defaultProps.tickFormatter, style, children, showLegend = exports.defaultProps.showLegend, }) {
55
- const { getThemeVar } = (0, xmlui_1.useTheme)();
56
- const colorValues = (0, react_1.useMemo)(() => {
56
+ const { getThemeVar } = (0, ThemeContext_1.useTheme)();
57
+ const colorValues = (0, react_2.useMemo)(() => {
57
58
  return [
58
59
  getThemeVar("color-primary-500"),
59
60
  getThemeVar("color-primary-300"),
@@ -93,7 +94,7 @@ function BarChart({ data = [], layout = exports.defaultProps.layout, nameKey, st
93
94
  getThemeVar("color-secondary-700"),
94
95
  ];
95
96
  }, [getThemeVar]);
96
- const config = (0, react_1.useMemo)(() => {
97
+ const config = (0, react_2.useMemo)(() => {
97
98
  return Object.assign({}, ...dataKeys.map((key, index) => {
98
99
  return {
99
100
  [key]: {
@@ -104,10 +105,87 @@ function BarChart({ data = [], layout = exports.defaultProps.layout, nameKey, st
104
105
  }));
105
106
  }, [colorValues, dataKeys]);
106
107
  const chartContextValue = (0, ChartProvider_1.useChartContextValue)({ dataKeys, nameKey });
107
- return ((0, jsx_runtime_1.jsxs)(ChartProvider_1.default, { value: chartContextValue, children: [children, (0, jsx_runtime_1.jsx)("div", { style: {
108
+ const containerRef = (0, react_1.useRef)(null);
109
+ const labelsRef = (0, react_1.useRef)(null);
110
+ const [interval, setIntervalState] = (0, react_1.useState)(0);
111
+ const [xAxisHeight, setXAxisHeight] = (0, react_1.useState)(50);
112
+ const [yTickCount, setYTickCount] = (0, react_1.useState)(5);
113
+ const fontSize = 12;
114
+ const [chartMargin, setChartMargin] = (0, react_1.useState)({ left: 30, right: 30, top: 10, bottom: 60 });
115
+ const [tickAngle, setTickAngle] = (0, react_1.useState)(0);
116
+ const [tickAnchor, setTickAnchor] = (0, react_1.useState)("middle");
117
+ const [miniMode, setMiniMode] = (0, react_1.useState)(false);
118
+ const [yAxisWidth, setYAxisWidth] = (0, react_1.useState)(40);
119
+ (0, react_1.useEffect)(() => {
120
+ const calc = () => {
121
+ var _a, _b, _c, _d, _e;
122
+ const width = ((_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 800;
123
+ const spans = ((_b = labelsRef.current) === null || _b === void 0 ? void 0 : _b.querySelectorAll("span")) || [];
124
+ const yTicks = Array.from(document.querySelectorAll(".recharts-y-axis .recharts-layer tspan"));
125
+ const maxYTickWidth = yTicks.length > 0 ? Math.max(...yTicks.map((t) => t.getBBox().width)) : 40;
126
+ setYAxisWidth(maxYTickWidth);
127
+ const maxWidth = Array.from(spans).reduce((mx, s) => Math.max(mx, s.offsetWidth), 50);
128
+ let angle = 0;
129
+ let anchor = "middle";
130
+ let rad = 0;
131
+ let minTickSpacing = maxWidth + 8;
132
+ let leftMargin = Math.ceil(maxWidth / 3);
133
+ let rightMargin = Math.ceil(maxWidth / 3);
134
+ let xAxisH = Math.ceil(fontSize * 1.2);
135
+ let maxTicks = Math.max(1, Math.floor(width / minTickSpacing));
136
+ let skip = Math.max(0, Math.ceil(data.length / maxTicks) - 1);
137
+ if (skip > 0) {
138
+ angle = -60;
139
+ anchor = "end";
140
+ rad = (Math.abs(angle) * Math.PI) / 180;
141
+ minTickSpacing = Math.ceil(maxWidth * Math.cos(rad)) + 2;
142
+ maxTicks = Math.max(1, Math.floor(width / minTickSpacing));
143
+ skip = Math.max(0, Math.ceil(data.length / maxTicks) - 1);
144
+ leftMargin = Math.ceil((maxWidth * Math.cos(rad)) / 1.8);
145
+ rightMargin = Math.ceil((maxWidth * Math.cos(rad)) / 1.8);
146
+ xAxisH = Math.ceil(Math.abs(maxWidth * Math.sin(rad)) + Math.abs(fontSize * Math.cos(rad)));
147
+ }
148
+ setIntervalState(skip);
149
+ setTickAngle(angle);
150
+ setTickAnchor(anchor);
151
+ const xTicks = Array.from(document.querySelectorAll(".recharts-x-axis .recharts-layer tspan"));
152
+ const maxXTickHeight = xTicks.length > 0 ? Math.max(...xTicks.map((t) => t.getBBox().height)) : fontSize;
153
+ let bottomMargin = 10;
154
+ if (layout === "vertical") {
155
+ bottomMargin = maxXTickHeight;
156
+ }
157
+ else {
158
+ bottomMargin = Math.max(xAxisH, maxXTickHeight);
159
+ }
160
+ setChartMargin({ left: leftMargin, right: rightMargin, top: 10, bottom: bottomMargin });
161
+ const chartHeight = ((_c = containerRef.current) === null || _c === void 0 ? void 0 : _c.offsetHeight) || 300;
162
+ const maxYTicks = Math.max(2, Math.floor(chartHeight / (fontSize * 3)));
163
+ setYTickCount(maxYTicks);
164
+ setXAxisHeight(Math.ceil(fontSize));
165
+ const containerHeight = ((_d = containerRef.current) === null || _d === void 0 ? void 0 : _d.offsetHeight) || 0;
166
+ const containerWidth = ((_e = containerRef.current) === null || _e === void 0 ? void 0 : _e.offsetWidth) || 0;
167
+ const neededHeight = 10 + xAxisHeight + 10 + 32;
168
+ const neededWidth = chartMargin.left + chartMargin.right + yAxisWidth + 32;
169
+ setMiniMode(neededHeight > containerHeight || neededWidth > containerWidth);
170
+ };
171
+ calc();
172
+ window.addEventListener("resize", calc);
173
+ return () => window.removeEventListener("resize", calc);
174
+ }, [data, xAxisHeight]);
175
+ return ((0, jsx_runtime_1.jsxs)(ChartProvider_1.default, { value: chartContextValue, children: [children, (0, jsx_runtime_1.jsx)("div", { ref: labelsRef, style: { position: "absolute", visibility: "hidden", height: 0, overflow: "hidden" }, children: data
176
+ .map((d) => d[nameKey])
177
+ .map((label, idx) => ((0, jsx_runtime_1.jsx)("span", { style: { fontSize: 12, whiteSpace: "nowrap" }, children: label }, idx))) }), (0, jsx_runtime_1.jsx)("div", { style: {
108
178
  flexGrow: 1,
109
- minHeight: 0,
110
179
  width: style.width || "100%",
111
180
  height: style.height || "100%",
112
- }, children: (0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { style: style, width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.BarChart, { accessibilityLayer: true, data: data, layout: layout, margin: { left: 10, top: 0, bottom: 0, right: 10 }, children: [(0, jsx_runtime_1.jsx)(recharts_1.CartesianGrid, { vertical: true, strokeDasharray: "3 3" }), layout === "vertical" ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(recharts_1.XAxis, { type: "number", axisLine: false, hide: hideX, tick: { fill: "currentColor" } }), (0, jsx_runtime_1.jsx)(recharts_1.YAxis, { hide: hideY, dataKey: nameKey, type: "category", interval: "equidistantPreserveStart", tickLine: false, tickFormatter: tickFormatter, tick: { fill: "currentColor" } })] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(recharts_1.XAxis, { dataKey: nameKey, type: "category", interval: "equidistantPreserveStart", tickLine: false, tickFormatter: tickFormatter, height: hideX ? 0 : 30, hide: hideX, tick: !hideTickX && { fill: "currentColor" } }), (0, jsx_runtime_1.jsx)(recharts_1.YAxis, { type: "number", axisLine: false, tick: !hideTickY && { fill: "currentColor" }, hide: hideY, width: hideY ? 0 : 60 })] })), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { content: (0, jsx_runtime_1.jsx)(TooltipContent_1.TooltipContent, {}) }), Object.keys(config).map((key, index) => ((0, jsx_runtime_1.jsx)(recharts_1.Bar, { dataKey: key, fill: config[key].color, radius: stacked ? 0 : 8, stackId: stacked ? "stacked" : undefined }, index))), chartContextValue.legend ? chartContextValue.legend : showLegend && (0, jsx_runtime_1.jsx)(recharts_1.Legend, {})] }) }) })] }));
181
+ padding: 0,
182
+ margin: 0,
183
+ }, children: (0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { ref: containerRef, width: "100%", height: "100%", debounce: 100, children: (0, jsx_runtime_1.jsxs)(recharts_1.BarChart, { style: style, accessibilityLayer: true, data: data, layout: layout, margin: miniMode ? { left: 0, right: 0, top: 0, bottom: 0 } : chartMargin, children: [(0, jsx_runtime_1.jsx)(recharts_1.CartesianGrid, { vertical: true, strokeDasharray: "3 3" }), layout === "vertical" ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(recharts_1.XAxis, { type: "number", axisLine: false, hide: miniMode || hideX, tick: miniMode ? false : { fill: "currentColor", fontSize } }), (0, jsx_runtime_1.jsx)(recharts_1.YAxis, { hide: miniMode || hideY, dataKey: nameKey, type: "category", interval: "equidistantPreserveStart", tickLine: false, tickFormatter: miniMode ? undefined : tickFormatter, tick: miniMode ? false : { fill: "currentColor", fontSize } })] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(recharts_1.XAxis, { dataKey: nameKey, type: "category", interval: interval, tickLine: false, angle: tickAngle, textAnchor: tickAnchor, tick: miniMode ? false : { fill: "currentColor", fontSize }, tickFormatter: miniMode ? undefined : tickFormatter, height: miniMode || hideX ? 0 : xAxisHeight, hide: miniMode || hideX }), (0, jsx_runtime_1.jsx)(recharts_1.YAxis, { type: "number", axisLine: false, tick: miniMode ? false : !hideTickY && { fill: "currentColor", fontSize }, hide: miniMode || hideY, tickCount: yTickCount, width: miniMode || hideY || hideTickY ? 0 : 40 })] })), !miniMode && (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { content: (0, jsx_runtime_1.jsx)(TooltipContent_1.TooltipContent, {}) }), Object.keys(config).map((key, index) => ((0, jsx_runtime_1.jsx)(recharts_1.Bar, { dataKey: key, fill: config[key].color, radius: stacked ? 0 : 8, stackId: stacked ? "stacked" : undefined, strokeWidth: 1 }, index))), showLegend && ((0, jsx_runtime_1.jsx)(recharts_1.Legend, { wrapperStyle: {
184
+ bottom: 0,
185
+ left: 0,
186
+ right: 0,
187
+ margin: "0 auto",
188
+ width: "100%",
189
+ textAlign: "center",
190
+ } }))] }) }) })] }));
113
191
  }
@@ -13,9 +13,9 @@ const metadata_helpers_1 = require("../../metadata-helpers");
13
13
  const COMP = "DonutChart";
14
14
  const defaultPropsDonut = Object.assign(Object.assign({}, PieChartNative_1.defaultProps), { innerRadius: 60 });
15
15
  exports.DonutChartMd = (0, metadata_helpers_1.createMetadata)({
16
+ status: "experimental",
16
17
  description: "A derivative of [PieChart](/components/PieChart) with a hollow center. " +
17
18
  "Note that the height of the component or its parent needs to be set explicitly.",
18
- status: "experimental",
19
19
  props: {
20
20
  data: {
21
21
  description: "The data to be displayed in the chart. Needs to be an array of objects.",
@@ -13,11 +13,11 @@ const renderers_1 = require("../../../components-core/renderers");
13
13
  const metadata_helpers_1 = require("../../metadata-helpers");
14
14
  const COMP = "LabelList";
15
15
  exports.LabelListMd = (0, metadata_helpers_1.createMetadata)({
16
+ status: "experimental",
16
17
  description: "`LabelList` adds custom data labels to chart components when automatic " +
17
18
  "labeling isn't sufficient. It's a specialized component for advanced chart " +
18
19
  "customization scenarios where you need precise control over label positioning " +
19
20
  "and appearance.",
20
- status: "experimental",
21
21
  props: {
22
22
  key: {
23
23
  description: "The key that needs to be matched to the data series.",
@@ -7,11 +7,11 @@ const metadata_helpers_1 = require("../../metadata-helpers");
7
7
  const LegendNative_1 = require("./LegendNative");
8
8
  const COMP = "Legend";
9
9
  exports.LegendMd = (0, metadata_helpers_1.createMetadata)({
10
+ status: "experimental",
10
11
  description: "`Legend` provides a standalone legend for chart components when you need " +
11
12
  "custom positioning or styling beyond the chart's built-in `showLegend` " +
12
13
  "property. Most charts can display legends automatically, but this component " +
13
14
  "offers precise control over legend placement and alignment.",
14
- status: "experimental",
15
15
  props: {
16
16
  align: {
17
17
  description: "The alignment of the legend",
@@ -7,11 +7,11 @@ const renderers_1 = require("../../../components-core/renderers");
7
7
  const metadata_helpers_1 = require("../../metadata-helpers");
8
8
  const COMP = "LineChart";
9
9
  exports.LineChartMd = (0, metadata_helpers_1.createMetadata)({
10
+ status: "experimental",
10
11
  description: "`LineChart` displays data as connected points over a continuous axis, ideal " +
11
12
  "for showing trends, changes over time, or relationships between variables. " +
12
13
  "Use it time series data, progress tracking, and comparing multiple data " +
13
14
  "series on the same scale.",
14
- status: "experimental",
15
15
  props: {
16
16
  data: {
17
17
  description: "The data to be displayed in the line chart." +
@@ -40,14 +40,14 @@ const recharts_1 = require("recharts");
40
40
  const react_1 = require("react");
41
41
  const ChartProvider_1 = __importStar(require("../utils/ChartProvider"));
42
42
  const TooltipContent_1 = require("../Tooltip/TooltipContent");
43
- const xmlui_1 = require("xmlui");
43
+ const ThemeContext_1 = require("../../../components-core/theming/ThemeContext");
44
44
  exports.defaultProps = {
45
45
  hideX: false,
46
46
  hideTooltip: false,
47
47
  showLegend: false,
48
48
  };
49
- function LineChart({ data, dataKeys = [], nameKey, style, hideX = false, hideTooltip = false, tickFormatter, children, showLegend = false, marginTop = 0, marginRight = 0, marginBottom = 0, marginLeft = 0, }) {
50
- const { getThemeVar } = (0, xmlui_1.useTheme)();
49
+ function LineChart({ data, dataKeys = [], nameKey, style, hideX = false, hideTooltip = false, tickFormatter, children, showLegend = false, }) {
50
+ const { getThemeVar } = (0, ThemeContext_1.useTheme)();
51
51
  const colorValues = (0, react_1.useMemo)(() => {
52
52
  return [
53
53
  getThemeVar("color-primary-500"),
@@ -88,21 +88,72 @@ function LineChart({ data, dataKeys = [], nameKey, style, hideX = false, hideToo
88
88
  getThemeVar("color-secondary-700"),
89
89
  ];
90
90
  }, [getThemeVar]);
91
- const config = (0, react_1.useMemo)(() => {
92
- return Object.assign({}, ...dataKeys.map((key, index) => {
93
- return {
94
- [key]: {
95
- label: key,
96
- color: colorValues[index % colorValues.length],
97
- },
98
- };
99
- }));
100
- }, [colorValues, dataKeys]);
101
91
  const chartContextValue = (0, ChartProvider_1.useChartContextValue)({ nameKey, dataKeys });
102
- return ((0, jsx_runtime_1.jsxs)(ChartProvider_1.default, { value: chartContextValue, children: [children, (0, jsx_runtime_1.jsx)("div", { style: {
92
+ const containerRef = (0, react_1.useRef)(null);
93
+ const labelsRef = (0, react_1.useRef)(null);
94
+ const [interval, setIntervalState] = (0, react_1.useState)(0);
95
+ const [tickAngle, setTickAngle] = (0, react_1.useState)(0);
96
+ const [tickAnchor, setTickAnchor] = (0, react_1.useState)("middle");
97
+ const [chartMargin, setChartMargin] = (0, react_1.useState)({ left: 30, right: 30, top: 10, bottom: 60 });
98
+ const [xAxisHeight, setXAxisHeight] = (0, react_1.useState)(50);
99
+ const [miniMode, setMiniMode] = (0, react_1.useState)(false);
100
+ const fontSize = 12;
101
+ const safeData = Array.isArray(data) ? data : [];
102
+ (0, react_1.useEffect)(() => {
103
+ const calc = () => {
104
+ var _a, _b, _c;
105
+ const width = ((_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 800;
106
+ const spans = ((_b = labelsRef.current) === null || _b === void 0 ? void 0 : _b.querySelectorAll("span")) || [];
107
+ const maxWidth = Array.from(spans).reduce((mx, s) => Math.max(mx, s.offsetWidth), 50);
108
+ let angle = 0;
109
+ let anchor = "middle";
110
+ let rad = 0;
111
+ let minTickSpacing = maxWidth + 8;
112
+ let leftMargin = Math.max(8, Math.ceil(maxWidth / 3));
113
+ let rightMargin = Math.max(8, Math.ceil(maxWidth / 3));
114
+ let xAxisH = Math.ceil(fontSize * 1.2);
115
+ let maxTicks = Math.max(1, Math.floor(width / minTickSpacing));
116
+ let skip = Math.max(0, Math.ceil(safeData.length / maxTicks) - 1);
117
+ if (skip > 0) {
118
+ angle = -60;
119
+ anchor = "end";
120
+ rad = (Math.abs(angle) * Math.PI) / 180;
121
+ minTickSpacing = Math.ceil(maxWidth * Math.cos(rad)) + 2;
122
+ maxTicks = Math.max(1, Math.floor(width / minTickSpacing));
123
+ skip = Math.max(0, Math.ceil(safeData.length / maxTicks) - 1);
124
+ leftMargin = Math.max(8, Math.ceil((maxWidth * Math.cos(rad)) / 1.8));
125
+ rightMargin = Math.max(8, Math.ceil((maxWidth * Math.cos(rad)) / 1.8));
126
+ xAxisH = Math.ceil(Math.abs(maxWidth * Math.sin(rad)) + Math.abs(fontSize * Math.cos(rad)));
127
+ }
128
+ setIntervalState(skip);
129
+ setTickAngle(angle);
130
+ setTickAnchor(anchor);
131
+ setChartMargin({ left: leftMargin, right: rightMargin, top: 10, bottom: xAxisH });
132
+ setXAxisHeight(Math.ceil(fontSize));
133
+ const containerHeight = ((_c = containerRef.current) === null || _c === void 0 ? void 0 : _c.offsetHeight) || 0;
134
+ const neededHeight = 10 + xAxisHeight + 10 + 32;
135
+ setMiniMode(neededHeight > containerHeight);
136
+ };
137
+ calc();
138
+ window.addEventListener("resize", calc);
139
+ return () => window.removeEventListener("resize", calc);
140
+ }, [data, nameKey, xAxisHeight]);
141
+ return ((0, jsx_runtime_1.jsxs)(ChartProvider_1.default, { value: chartContextValue, children: [children, (0, jsx_runtime_1.jsx)("div", { ref: labelsRef, style: { position: "absolute", visibility: "hidden", height: 0, overflow: "hidden" }, children: safeData.length > 0 && nameKey
142
+ ? safeData
143
+ .map((d) => d === null || d === void 0 ? void 0 : d[nameKey])
144
+ .map((label, idx) => ((0, jsx_runtime_1.jsx)("span", { style: { fontSize: 12, whiteSpace: "nowrap" }, children: label }, idx)))
145
+ : null }), (0, jsx_runtime_1.jsx)("div", { style: {
103
146
  flexGrow: 1,
104
- minHeight: 0,
105
- width: style.width || "100%",
106
- height: style.height || "100%",
107
- }, children: (0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { style: style, width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.LineChart, { accessibilityLayer: true, data: data, margin: { top: marginTop, right: marginRight, bottom: marginBottom, left: marginLeft }, children: [(0, jsx_runtime_1.jsx)(recharts_1.XAxis, { interval: "preserveEnd", dataKey: nameKey, tickLine: false, hide: hideX, axisLine: false, tick: { fill: "currentColor" }, tickFormatter: tickFormatter, minTickGap: 5 }), !hideTooltip && (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { content: (0, jsx_runtime_1.jsx)(TooltipContent_1.TooltipContent, {}) }), Object.keys(config).map((key, index) => ((0, jsx_runtime_1.jsx)(recharts_1.Line, { dataKey: key, type: "monotone", stroke: config[key].color, dot: false }, index))), chartContextValue.legend ? chartContextValue.legend : showLegend && (0, jsx_runtime_1.jsx)(recharts_1.Legend, {})] }) }) })] }));
147
+ width: (style === null || style === void 0 ? void 0 : style.width) || "100%",
148
+ height: (style === null || style === void 0 ? void 0 : style.height) || "100%",
149
+ padding: 0,
150
+ margin: 0,
151
+ }, children: (0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { ref: containerRef, style: style, width: "100%", height: "100%", debounce: 100, children: (0, jsx_runtime_1.jsxs)(recharts_1.LineChart, { accessibilityLayer: true, data: data, margin: miniMode ? { left: 0, right: 0, top: 0, bottom: 0 } : chartMargin, children: [(0, jsx_runtime_1.jsx)(recharts_1.XAxis, { dataKey: nameKey, interval: interval, tickLine: false, angle: tickAngle, textAnchor: tickAnchor, tick: miniMode ? false : { fill: "currentColor", fontSize }, tickFormatter: miniMode ? undefined : tickFormatter, height: miniMode || hideX ? 0 : xAxisHeight, hide: miniMode || hideX }), !miniMode && !hideTooltip && (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { content: (0, jsx_runtime_1.jsx)(TooltipContent_1.TooltipContent, {}) }), dataKeys.map((dataKey, i) => ((0, jsx_runtime_1.jsx)(recharts_1.Line, { type: "monotone", dataKey: dataKey, name: dataKey, stroke: colorValues[i], strokeWidth: 1, dot: false }, dataKey))), showLegend && ((0, jsx_runtime_1.jsx)(recharts_1.Legend, { wrapperStyle: {
152
+ bottom: 0,
153
+ left: 0,
154
+ right: 0,
155
+ margin: "0 auto",
156
+ width: "100%",
157
+ textAlign: "center",
158
+ } }))] }) }) })] }));
108
159
  }