@shohojdhara/atomix 0.4.5 → 0.4.7

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 (54) hide show
  1. package/dist/atomix.css +70 -33
  2. package/dist/atomix.css.map +1 -1
  3. package/dist/atomix.min.css +2 -2
  4. package/dist/atomix.min.css.map +1 -1
  5. package/dist/charts.d.ts +93 -109
  6. package/dist/charts.js +273 -371
  7. package/dist/charts.js.map +1 -1
  8. package/dist/core.js +183 -184
  9. package/dist/core.js.map +1 -1
  10. package/dist/forms.js +183 -184
  11. package/dist/forms.js.map +1 -1
  12. package/dist/heavy.js +183 -184
  13. package/dist/heavy.js.map +1 -1
  14. package/dist/index.d.ts +7 -51
  15. package/dist/index.esm.js +281 -470
  16. package/dist/index.esm.js.map +1 -1
  17. package/dist/index.js +287 -476
  18. package/dist/index.js.map +1 -1
  19. package/dist/index.min.js +1 -1
  20. package/dist/index.min.js.map +1 -1
  21. package/package.json +1 -1
  22. package/src/components/AtomixGlass/AtomixGlass.tsx +60 -38
  23. package/src/components/AtomixGlass/AtomixGlassContainer.tsx +6 -35
  24. package/src/components/AtomixGlass/glass-utils.ts +27 -14
  25. package/src/components/AtomixGlass/stories/Overview.stories.tsx +19 -21
  26. package/src/components/AtomixGlass/stories/Playground.stories.tsx +1162 -515
  27. package/src/components/AtomixGlass/stories/shared-components.tsx +11 -3
  28. package/src/components/Chart/BubbleChart.tsx +6 -2
  29. package/src/components/Chart/Chart.stories.tsx +108 -96
  30. package/src/components/Chart/ChartToolbar.tsx +6 -4
  31. package/src/components/Chart/ChartTooltip.tsx +5 -4
  32. package/src/components/Chart/GaugeChart.tsx +20 -12
  33. package/src/components/Chart/HeatmapChart.tsx +53 -23
  34. package/src/components/Chart/TreemapChart.tsx +44 -15
  35. package/src/components/Chart/index.ts +0 -2
  36. package/src/components/Chart/types.ts +4 -4
  37. package/src/components/Navigation/Navbar/Navbar.tsx +13 -5
  38. package/src/components/index.ts +0 -1
  39. package/src/lib/composables/index.ts +1 -2
  40. package/src/lib/composables/useAtomixGlass.ts +246 -222
  41. package/src/lib/composables/useAtomixGlassStyles.ts +46 -23
  42. package/src/lib/constants/components.ts +3 -1
  43. package/src/styles/01-settings/_settings.chart.scss +13 -13
  44. package/src/styles/06-components/_components.atomix-glass.scss +45 -20
  45. package/src/styles/06-components/_components.chart.scss +23 -5
  46. package/src/components/Chart/AnimatedChart.tsx +0 -230
  47. package/src/lib/composables/atomix-glass/useGlassBackgroundDetection.ts +0 -329
  48. package/src/lib/composables/atomix-glass/useGlassCornerRadius.ts +0 -82
  49. package/src/lib/composables/atomix-glass/useGlassMouseTracking.ts +0 -153
  50. package/src/lib/composables/atomix-glass/useGlassOverLight.ts +0 -198
  51. package/src/lib/composables/atomix-glass/useGlassState.ts +0 -112
  52. package/src/lib/composables/atomix-glass/useGlassTransforms.ts +0 -160
  53. package/src/lib/composables/glass-styles.ts +0 -302
  54. package/src/lib/composables/useGlassContainer.ts +0 -177
@@ -174,12 +174,10 @@ const HeatmapChart = memo(
174
174
  data = [],
175
175
  config = {},
176
176
  colorScale = {
177
- scheme: 'viridis',
177
+ scheme: 'blues',
178
178
  steps: 9,
179
179
  },
180
180
  cellConfig = {
181
- width: 40,
182
- height: 40,
183
181
  spacing: 2,
184
182
  borderRadius: 4,
185
183
  showLabels: false,
@@ -272,16 +270,38 @@ const HeatmapChart = memo(
272
270
  return null;
273
271
  }
274
272
 
275
- const cellWidth = cellConfig.width || 40;
276
- const cellHeight = cellConfig.height || 40;
277
- const spacing = cellConfig.spacing || 2;
278
- const borderRadius = cellConfig.borderRadius || 4;
273
+ const spacing = cellConfig.spacing ?? 2;
274
+ const borderRadius = cellConfig.borderRadius ?? 4;
279
275
 
280
- const totalWidth = xLabels.length * (cellWidth + spacing) - spacing;
281
- const totalHeight = yLabels.length * (cellHeight + spacing) - spacing;
276
+ // Container dimensions
277
+ const { width, height } = scales;
282
278
 
283
- const startX = 100; // Leave space for y-axis labels
284
- const startY = 50; // Leave space for x-axis labels
279
+ // Layout padding and spacing
280
+ const paddingLeft = 60; // Space for Y-axis labels
281
+ const paddingBottom = 40; // Space for X-axis labels
282
+ const legendWidth = showColorLegend ? 60 : 0;
283
+ const paddingRight = legendWidth + 20;
284
+ const paddingTop = 20;
285
+
286
+ const availableWidth = Math.max(0, width - paddingLeft - paddingRight);
287
+ const availableHeight = Math.max(0, height - paddingTop - paddingBottom);
288
+
289
+ const cols = Math.max(1, xLabels.length);
290
+ const rows = Math.max(1, yLabels.length);
291
+
292
+ // Dynamically compute max cell dimensions that fit the available space
293
+ const maxCellWidth = Math.max(2, Math.floor((availableWidth - (cols - 1) * spacing) / cols));
294
+ const maxCellHeight = Math.max(2, Math.floor((availableHeight - (rows - 1) * spacing) / rows));
295
+
296
+ const cellWidth = cellConfig.width || maxCellWidth;
297
+ const cellHeight = cellConfig.height || maxCellHeight;
298
+
299
+ const totalWidth = cols * cellWidth + (cols - 1) * spacing;
300
+ const totalHeight = rows * cellHeight + (rows - 1) * spacing;
301
+
302
+ // Center the heatmap chart within the available area
303
+ const startX = paddingLeft + Math.max(0, (availableWidth - totalWidth) / 2);
304
+ const startY = paddingTop + Math.max(0, (availableHeight - totalHeight) / 2);
285
305
 
286
306
  return (
287
307
  <>
@@ -333,11 +353,6 @@ const HeatmapChart = memo(
333
353
  ry={borderRadius}
334
354
  fill={color}
335
355
  className={`c-chart__heatmap-cell ${isHovered ? 'c-chart__heatmap-cell--hovered' : ''}`}
336
- style={{
337
- transition: 'all 0.2s ease',
338
- transform: isHovered ? 'scale(1.05)' : 'scale(1)',
339
- transformOrigin: 'center',
340
- }}
341
356
  onClick={() => {
342
357
  if (cell) {
343
358
  handlers.onDataPointClick?.(
@@ -353,8 +368,21 @@ const HeatmapChart = memo(
353
368
  }}
354
369
  onMouseEnter={e => {
355
370
  setHoveredCell(cell);
371
+ const pointIndex = data.findIndex(d => d.x === cell.x && d.y === cell.y);
372
+ const rect = e.currentTarget.getBoundingClientRect();
373
+ handlers.onPointHover(
374
+ 0, // datasetIndex is always 0 for Heatmap
375
+ pointIndex >= 0 ? pointIndex : 0,
376
+ x,
377
+ y,
378
+ rect.left + rect.width / 2,
379
+ rect.top + rect.height / 2
380
+ );
381
+ }}
382
+ onMouseLeave={() => {
383
+ setHoveredCell(null);
384
+ handlers.onPointLeave();
356
385
  }}
357
- onMouseLeave={() => setHoveredCell(null)}
358
386
  />
359
387
  {cellConfig.showLabels && cell.label && (
360
388
  <text
@@ -411,23 +439,25 @@ const HeatmapChart = memo(
411
439
 
412
440
  {/* Color legend */}
413
441
  {showColorLegend && (
414
- <g transform="translate(600, 100)">
442
+ <g transform={`translate(${startX + totalWidth + 20}, ${startY})`}>
415
443
  <rect
416
444
  x="0"
417
445
  y="0"
418
- width="20"
419
- height="200"
446
+ width="12"
447
+ height={totalHeight}
420
448
  fill="url(#heatmap-legend-gradient)"
421
449
  stroke="var(--atomix-border-color)"
422
450
  className="c-chart__grid"
451
+ rx={borderRadius}
452
+ ry={borderRadius}
423
453
  />
424
- <text x="-10" y="-10" className="c-chart__heatmap-legend-title">
454
+ <text x="-5" y="-10" className="c-chart__heatmap-legend-title">
425
455
  Values
426
456
  </text>
427
- <text x="25" y="5" textAnchor="start" className="c-chart__heatmap-legend-label">
457
+ <text x="20" y="8" textAnchor="start" className="c-chart__heatmap-legend-label">
428
458
  High
429
459
  </text>
430
- <text x="25" y="200" textAnchor="start" className="c-chart__heatmap-legend-label">
460
+ <text x="20" y={totalHeight} textAnchor="start" className="c-chart__heatmap-legend-label">
431
461
  Low
432
462
  </text>
433
463
  </g>
@@ -1,5 +1,6 @@
1
1
  import { forwardRef, memo, useCallback, useMemo, useState } from 'react';
2
2
  import BaseChart from './BaseChart';
3
+ import ChartTooltip from './ChartTooltip';
3
4
  import { ChartProps } from '../../lib/types/components';
4
5
  import { ChartRenderContentParams } from './types';
5
6
 
@@ -103,7 +104,6 @@ const DEFAULT_LABEL_CONFIG = {
103
104
  showLabels: true,
104
105
  minSize: 1000,
105
106
  fontSize: 12,
106
- textColor: 'white',
107
107
  };
108
108
  const DEFAULT_CONFIG = {};
109
109
 
@@ -254,6 +254,7 @@ const TreemapChart = memo(
254
254
  let currentY = y;
255
255
  let remainingWidth = width;
256
256
  let remainingHeight = height;
257
+ let remainingValue = totalValue;
257
258
 
258
259
  while (remainingNodes.length > 0) {
259
260
  const node = remainingNodes.shift();
@@ -262,7 +263,7 @@ const TreemapChart = memo(
262
263
 
263
264
  // Calculate dimensions for current row
264
265
  const rowValue = currentRow.reduce((sum, n) => sum + n.value, 0);
265
- const rowRatio = rowValue / totalValue;
266
+ const rowRatio = remainingValue > 0 ? rowValue / remainingValue : 0;
266
267
 
267
268
  let rowWidth, rowHeight;
268
269
  if (remainingWidth >= remainingHeight) {
@@ -280,7 +281,7 @@ const TreemapChart = memo(
280
281
  if (!nextNode) break;
281
282
  const testRow = [...currentRow, nextNode];
282
283
  const testRowValue = testRow.reduce((sum, n) => sum + n.value, 0);
283
- const testRowRatio = testRowValue / totalValue;
284
+ const testRowRatio = remainingValue > 0 ? testRowValue / remainingValue : 0;
284
285
 
285
286
  let testRowWidth, testRowHeight;
286
287
  if (remainingWidth >= remainingHeight) {
@@ -352,6 +353,7 @@ const TreemapChart = memo(
352
353
  remainingHeight -= rowHeight;
353
354
  }
354
355
 
356
+ remainingValue -= rowValue;
355
357
  currentRow = [];
356
358
  }
357
359
  }
@@ -366,15 +368,19 @@ const TreemapChart = memo(
366
368
  datasets: renderedDatasets,
367
369
  handlers,
368
370
  hoveredPoint,
371
+ toolbarState,
372
+ config: renderConfig,
369
373
  }: ChartRenderContentParams) => {
370
374
  if (!data.length) return null;
371
375
 
372
- // Calculate available space with padding
373
- const padding = 20;
374
- const availableWidth = scales.width - padding * 2;
375
- const availableHeight = scales.height - padding * 2;
376
- const startX = padding;
377
- const startY = padding;
376
+ const showTooltips = toolbarState?.showTooltips ?? renderConfig?.showTooltips ?? true;
377
+
378
+ // Calculate available space
379
+ const gap = 2; // Gap size matched to the one added to rects
380
+ const availableWidth = Math.max(0, scales.width);
381
+ const availableHeight = Math.max(0, scales.height);
382
+ const startX = 0;
383
+ const startY = 0;
378
384
 
379
385
  // Get leaf nodes for treemap layout
380
386
  const leafNodes = data.filter(item => !item.children || item.children.length === 0);
@@ -428,10 +434,12 @@ const TreemapChart = memo(
428
434
  return (
429
435
  <g key={node.id}>
430
436
  <rect
431
- x={node.x}
432
- y={node.y}
433
- width={node.width}
434
- height={node.height}
437
+ x={node.x + gap}
438
+ y={node.y + gap}
439
+ width={Math.max(0, node.width - gap * 2)}
440
+ height={Math.max(0, node.height - gap * 2)}
441
+ rx={6}
442
+ ry={6}
435
443
  fill={node.color}
436
444
  className={`c-chart__treemap-node ${isHovered ? 'c-chart__treemap-node--hovered' : ''} ${isSelected ? 'c-chart__treemap-node--selected' : ''}`}
437
445
  onClick={() => {
@@ -441,9 +449,10 @@ const TreemapChart = memo(
441
449
  onMouseEnter={e => {
442
450
  setHoveredNode(node);
443
451
  const rect = e.currentTarget.getBoundingClientRect();
452
+ const pointIndex = data.indexOf(node.originalData);
444
453
  handlers.onPointHover(
445
454
  0,
446
- 0,
455
+ pointIndex >= 0 ? pointIndex : 0,
447
456
  node.x,
448
457
  node.y,
449
458
  rect.left + rect.width / 2,
@@ -462,7 +471,7 @@ const TreemapChart = memo(
462
471
  textAnchor="middle"
463
472
  dominantBaseline="middle"
464
473
  className="c-chart__treemap-label"
465
- style={{ fontSize: labelConfig.fontSize, fill: labelConfig.textColor }}
474
+ style={{ fontSize: labelConfig.fontSize }}
466
475
  >
467
476
  {node.label}
468
477
  </text>
@@ -470,6 +479,26 @@ const TreemapChart = memo(
470
479
  </g>
471
480
  );
472
481
  })}
482
+
483
+ {showTooltips &&
484
+ hoveredPoint &&
485
+ renderedDatasets[hoveredPoint.datasetIndex]?.data?.[hoveredPoint.pointIndex] && (
486
+ <ChartTooltip
487
+ dataPoint={
488
+ renderedDatasets[hoveredPoint.datasetIndex]!.data![hoveredPoint.pointIndex]!
489
+ }
490
+ datasetLabel={renderedDatasets[hoveredPoint.datasetIndex]?.label}
491
+ datasetColor={
492
+ renderedDatasets[hoveredPoint.datasetIndex]?.color ||
493
+ colors[hoveredPoint.datasetIndex % colors.length]
494
+ }
495
+ position={{
496
+ x: hoveredPoint.clientX,
497
+ y: hoveredPoint.clientY,
498
+ }}
499
+ visible={true}
500
+ />
501
+ )}
473
502
  </>
474
503
  );
475
504
  },
@@ -1,4 +1,3 @@
1
- import AnimatedChart from './AnimatedChart';
2
1
  import AreaChart from './AreaChart';
3
2
  import BarChart from './BarChart';
4
3
  import BaseChart from './BaseChart';
@@ -24,7 +23,6 @@ import * as ChartUtils from './utils';
24
23
 
25
24
  // Export all chart components
26
25
  export {
27
- AnimatedChart,
28
26
  AreaChart,
29
27
  BarChart,
30
28
  BaseChart,
@@ -263,7 +263,7 @@ export interface ChartProps extends BaseComponentProps {
263
263
  onClick: () => void;
264
264
  disabled?: boolean;
265
265
  active?: boolean;
266
- variant?: 'primary' | 'secondary' | 'success' | 'info' | 'warning' | 'error';
266
+ variant?: Variant;
267
267
  tooltip?: string;
268
268
  }>;
269
269
 
@@ -280,7 +280,7 @@ export interface ChartProps extends BaseComponentProps {
280
280
  onClick: () => void;
281
281
  disabled?: boolean;
282
282
  active?: boolean;
283
- variant?: 'primary' | 'secondary' | 'success' | 'info' | 'warning' | 'error';
283
+ variant?: Variant;
284
284
  tooltip?: string;
285
285
  }>;
286
286
  separator?: boolean;
@@ -403,7 +403,7 @@ export interface ChartToolbarConfig {
403
403
  onClick: () => void;
404
404
  disabled?: boolean;
405
405
  active?: boolean;
406
- variant?: 'primary' | 'secondary' | 'success' | 'info' | 'warning' | 'error';
406
+ variant?: Variant;
407
407
  tooltip?: string;
408
408
  }>;
409
409
  customGroups?: Array<{
@@ -416,7 +416,7 @@ export interface ChartToolbarConfig {
416
416
  onClick: () => void;
417
417
  disabled?: boolean;
418
418
  active?: boolean;
419
- variant?: 'primary' | 'secondary' | 'success' | 'info' | 'warning' | 'error';
419
+ variant?: Variant;
420
420
  tooltip?: string;
421
421
  }>;
422
422
  separator?: boolean;
@@ -152,15 +152,23 @@ export const Navbar = forwardRef<HTMLElement, NavbarProps>(
152
152
  shaderVariant: 'premiumGlass' as const,
153
153
  };
154
154
  const glassProps = glass === true ? defaultGlassProps : { ...defaultGlassProps, ...glass };
155
+
156
+ // AtomixGlass hoists layout props (position/top/left/right/zIndex) to its
157
+ // root element, keeping all internal layers in the same stacking context.
158
+ const isFixed = position === 'fixed' || position === 'fixed-bottom';
159
+
155
160
  return (
156
161
  <AtomixGlass
157
162
  {...glassProps}
158
163
  style={{
159
- ...(position === 'fixed' && { position: 'fixed' }),
160
- left: 0,
161
- right: 0,
162
- top: 0,
163
- zIndex: 1000,
164
+ ...(isFixed && {
165
+ position: 'fixed' as const,
166
+ top: position === 'fixed' ? 0 : undefined,
167
+ bottom: position === 'fixed-bottom' ? 0 : undefined,
168
+ left: 0,
169
+ right: 0,
170
+ zIndex: 1030, // matches --atomix-navbar-z-index from _components.navbar.scss
171
+ }),
164
172
  }}
165
173
  >
166
174
  <nav
@@ -15,7 +15,6 @@ export { default as Card, type CardProps } from './Card/Card';
15
15
  // Card sub-components
16
16
  export { default as ElevationCard, type ElevationCardProps } from './Card/ElevationCard';
17
17
  export {
18
- AnimatedChart,
19
18
  AreaChart,
20
19
  BarChart,
21
20
  BubbleChart,
@@ -29,8 +29,7 @@ export * from './useTodo';
29
29
  export * from './useForm';
30
30
  export * from './useFormGroup';
31
31
 
32
- // GlassContainer composables
33
- export * from './useGlassContainer';
32
+ // AtomixGlass composables
34
33
  export * from './useAtomixGlass';
35
34
  export * from './useInput';
36
35
  export * from './useRadio';