@shohojdhara/atomix 0.3.4 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +101 -199
- package/atomix.config.ts +241 -0
- package/dist/atomix.css +269 -189
- package/dist/atomix.css.map +1 -0
- package/dist/atomix.min.css +15179 -11
- package/dist/atomix.min.css.map +1 -0
- package/dist/charts.d.ts +1929 -0
- package/dist/charts.js +6477 -0
- package/dist/charts.js.map +1 -0
- package/dist/core.d.ts +1289 -0
- package/dist/core.js +3373 -0
- package/dist/core.js.map +1 -0
- package/dist/forms.d.ts +1085 -0
- package/dist/forms.js +2466 -0
- package/dist/forms.js.map +1 -0
- package/dist/heavy.d.ts +636 -0
- package/dist/heavy.js +4566 -0
- package/dist/heavy.js.map +1 -0
- package/dist/index.d.ts +5171 -4792
- package/dist/index.esm.js +6098 -4563
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +6291 -4747
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/layout.d.ts +300 -0
- package/dist/layout.js +336 -0
- package/dist/layout.js.map +1 -0
- package/dist/theme.d.ts +2122 -0
- package/dist/theme.js +6084 -0
- package/dist/theme.js.map +1 -0
- package/package.json +59 -27
- package/scripts/atomix-cli.js +544 -16
- package/scripts/cli/__tests__/cli-commands.test.js +204 -0
- package/scripts/cli/__tests__/utils.test.js +201 -0
- package/scripts/cli/__tests__/vitest.config.js +26 -0
- package/scripts/cli/interactive-init.js +1 -1
- package/scripts/cli/token-manager.js +32 -7
- package/scripts/cli/utils.js +347 -0
- package/src/components/Accordion/Accordion.stories.tsx +50 -17
- package/src/components/Accordion/Accordion.tsx +5 -54
- package/src/components/Accordion/index.ts +1 -1
- package/src/components/AtomixGlass/AtomixGlass.tsx +65 -31
- package/src/components/AtomixGlass/AtomixGlassContainer.tsx +11 -4
- package/src/components/AtomixGlass/stories/AtomixGlass.stories.tsx +1 -32
- package/src/components/AtomixGlass/stories/Examples.stories.tsx +2 -2
- package/src/components/AtomixGlass/stories/shared-components.tsx +0 -31
- package/src/components/Avatar/Avatar.stories.tsx +7 -0
- package/src/components/Avatar/Avatar.tsx +3 -3
- package/src/components/Badge/Badge.stories.tsx +91 -13
- package/src/components/Badge/Badge.tsx +3 -3
- package/src/components/Block/Block.stories.tsx +7 -23
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +7 -0
- package/src/components/Breadcrumb/Breadcrumb.tsx +3 -3
- package/src/components/Button/Button.stories.tsx +141 -22
- package/src/components/Button/ButtonGroup.stories.tsx +315 -0
- package/src/components/Button/ButtonGroup.tsx +67 -0
- package/src/components/Button/index.ts +2 -0
- package/src/components/Callout/Callout.stories.tsx +8 -6
- package/src/components/Card/Card.stories.tsx +82 -28
- package/src/components/Card/ElevationCard.tsx +1 -1
- package/src/components/Chart/AnimatedChart.tsx +19 -18
- package/src/components/Chart/AreaChart.tsx +5 -2
- package/src/components/Chart/BarChart.tsx +1 -1
- package/src/components/Chart/BubbleChart.tsx +6 -6
- package/src/components/Chart/CandlestickChart.tsx +0 -1
- package/src/components/Chart/Chart.stories.tsx +5 -7
- package/src/components/Chart/Chart.tsx +0 -16
- package/src/components/Chart/ChartRenderer.tsx +1 -1
- package/src/components/Chart/ChartToolbar.tsx +1 -0
- package/src/components/Chart/DonutChart.tsx +0 -1
- package/src/components/Chart/FunnelChart.tsx +1 -2
- package/src/components/Chart/GaugeChart.tsx +0 -1
- package/src/components/Chart/HeatmapChart.tsx +0 -1
- package/src/components/Chart/LineChart.tsx +0 -1
- package/src/components/Chart/MultiAxisChart.tsx +0 -1
- package/src/components/Chart/PieChart.tsx +0 -1
- package/src/components/Chart/RadarChart.tsx +19 -13
- package/src/components/Chart/ScatterChart.tsx +3 -4
- package/src/components/Chart/TreemapChart.tsx +2 -1
- package/src/components/Chart/WaterfallChart.tsx +0 -2
- package/src/components/Chart/types.ts +12 -2
- package/src/components/Chart/utils.ts +4 -3
- package/src/components/ColorModeToggle/ColorModeToggle.stories.tsx +7 -0
- package/src/components/DataTable/DataTable.stories.tsx +23 -16
- package/src/components/DataTable/DataTable.tsx +3 -3
- package/src/components/DatePicker/DatePicker.stories.tsx +27 -19
- package/src/components/Dropdown/Dropdown.stories.tsx +11 -19
- package/src/components/Dropdown/Dropdown.tsx +12 -9
- package/src/components/EdgePanel/EdgePanel.stories.tsx +1 -0
- package/src/components/Footer/Footer.stories.tsx +8 -6
- package/src/components/Footer/FooterLink.tsx +9 -2
- package/src/components/Footer/FooterSection.tsx +3 -3
- package/src/components/Form/Checkbox.stories.tsx +7 -0
- package/src/components/Form/Checkbox.tsx +3 -3
- package/src/components/Form/Form.stories.tsx +7 -0
- package/src/components/Form/FormGroup.stories.tsx +9 -1
- package/src/components/Form/Input.stories.tsx +69 -16
- package/src/components/Form/Input.tsx +4 -2
- package/src/components/Form/Radio.stories.tsx +9 -1
- package/src/components/Form/Radio.tsx +3 -3
- package/src/components/Form/Select.stories.tsx +9 -1
- package/src/components/Form/Select.tsx +3 -3
- package/src/components/Form/Textarea.stories.tsx +10 -2
- package/src/components/Form/Textarea.tsx +4 -2
- package/src/components/Hero/Hero.stories.tsx +7 -0
- package/src/components/List/List.stories.tsx +10 -3
- package/src/components/List/List.tsx +3 -3
- package/src/components/List/ListGroup.tsx +3 -1
- package/src/components/Messages/Messages.stories.tsx +8 -7
- package/src/components/Modal/Modal.stories.tsx +17 -6
- package/src/components/Modal/Modal.tsx +3 -3
- package/src/components/Navigation/Menu/MegaMenu.tsx +9 -3
- package/src/components/Navigation/Menu/Menu.stories.tsx +7 -0
- package/src/components/Navigation/Menu/Menu.tsx +9 -3
- package/src/components/Navigation/Nav/Nav.stories.tsx +7 -0
- package/src/components/Navigation/Navbar/Navbar.stories.tsx +1 -0
- package/src/components/Navigation/SideMenu/SideMenu.stories.tsx +1 -1
- package/src/components/Pagination/Pagination.stories.tsx +188 -111
- package/src/components/Pagination/Pagination.tsx +88 -7
- package/src/components/PhotoViewer/PhotoViewer.stories.tsx +10 -5
- package/src/components/PhotoViewer/PhotoViewerImage.tsx +2 -2
- package/src/components/Popover/Popover.stories.tsx +191 -115
- package/src/components/Popover/Popover.tsx +4 -4
- package/src/components/ProductReview/ProductReview.stories.tsx +80 -58
- package/src/components/Progress/Progress.stories.tsx +79 -49
- package/src/components/Progress/Progress.tsx +6 -2
- package/src/components/Rating/Rating.stories.tsx +109 -84
- package/src/components/Rating/Rating.tsx +5 -2
- package/src/components/River/River.stories.tsx +194 -114
- package/src/components/SectionIntro/SectionIntro.stories.tsx +19 -9
- package/src/components/Slider/Slider.stories.tsx +7 -0
- package/src/components/Slider/Slider.tsx +10 -9
- package/src/components/Spinner/Spinner.stories.tsx +15 -11
- package/src/components/Spinner/Spinner.tsx +3 -3
- package/src/components/Steps/Steps.stories.tsx +132 -98
- package/src/components/Tabs/Tabs.stories.tsx +163 -112
- package/src/components/Tabs/Tabs.tsx +3 -3
- package/src/components/Testimonial/Testimonial.stories.tsx +114 -68
- package/src/components/Todo/Todo.stories.tsx +38 -12
- package/src/components/Toggle/Toggle.stories.tsx +61 -28
- package/src/components/Tooltip/Tooltip.stories.tsx +318 -200
- package/src/components/Tooltip/Tooltip.tsx +3 -3
- package/src/components/Upload/Upload.stories.tsx +122 -84
- package/src/components/VideoPlayer/VideoPlayer.stories.tsx +7 -24
- package/src/components/index.ts +6 -2
- package/src/layouts/MasonryGrid/MasonryGrid.tsx +2 -2
- package/src/lib/composables/useAtomixGlass.ts +2 -3
- package/src/lib/composables/useChartPerformance.ts +102 -78
- package/src/lib/composables/useChartScale.ts +10 -0
- package/src/lib/composables/useHero.ts +9 -2
- package/src/lib/composables/useHeroBackgroundSlider.ts +5 -3
- package/src/lib/composables/useNavbar.ts +0 -10
- package/src/lib/composables/useSideMenu.ts +1 -0
- package/src/lib/composables/useVideoPlayer.ts +3 -2
- package/src/lib/config/loader.ts +57 -14
- package/src/lib/constants/components.ts +10 -0
- package/src/lib/hooks/index.ts +0 -1
- package/src/lib/hooks/useComponentCustomization.ts +11 -15
- package/src/lib/hooks/usePerformanceMonitor.ts +149 -0
- package/src/lib/patterns/index.ts +2 -2
- package/src/lib/patterns/slots.tsx +2 -2
- package/src/lib/theme/README.md +174 -0
- package/src/lib/theme/adapters/index.ts +31 -0
- package/src/lib/theme/adapters/themeAdapter.ts +287 -0
- package/src/lib/theme/config/__tests__/configLoader.test.ts +207 -0
- package/src/lib/theme/config/configLoader.ts +254 -0
- package/src/lib/theme/config/loader.ts +37 -48
- package/src/lib/theme/config/types.ts +2 -2
- package/src/lib/theme/config/validator.ts +15 -91
- package/src/lib/theme/{constants.ts → constants/constants.ts} +0 -18
- package/src/lib/theme/constants/index.ts +8 -0
- package/src/lib/theme/core/ThemeRegistry.ts +19 -6
- package/src/lib/theme/core/__tests__/createTheme.test.ts +132 -0
- package/src/lib/theme/core/composeTheme.ts +155 -0
- package/src/lib/theme/core/createTheme.ts +94 -0
- package/src/lib/theme/{createTheme.ts → core/createThemeObject.ts} +10 -6
- package/src/lib/theme/core/index.ts +5 -19
- package/src/lib/theme/devtools/Comparator.tsx +346 -22
- package/src/lib/theme/devtools/IMPROVEMENTS.md +139 -38
- package/src/lib/theme/devtools/Inspector.tsx +335 -51
- package/src/lib/theme/devtools/LiveEditor.tsx +489 -112
- package/src/lib/theme/devtools/Preview.tsx +471 -221
- package/src/lib/theme/{core → devtools}/ThemeValidator.ts +6 -3
- package/src/lib/theme/devtools/index.ts +14 -4
- package/src/lib/theme/devtools/useHistory.ts +130 -0
- package/src/lib/theme/errors/index.ts +12 -0
- package/src/lib/theme/generators/cssFile.ts +79 -0
- package/src/lib/theme/generators/generateCSS.ts +89 -0
- package/src/lib/theme/{generateCSSVariables.ts → generators/generateCSSVariables.ts} +4 -14
- package/src/lib/theme/generators/index.ts +19 -0
- package/src/lib/theme/i18n/rtl.ts +7 -7
- package/src/lib/theme/index.ts +120 -15
- package/src/lib/theme/runtime/ThemeApplicator.ts +53 -95
- package/src/lib/theme/{ThemeContext.tsx → runtime/ThemeContext.tsx} +1 -1
- package/src/lib/theme/runtime/ThemeErrorBoundary.tsx +4 -4
- package/src/lib/theme/runtime/ThemeProvider.tsx +456 -179
- package/src/lib/theme/runtime/index.ts +1 -2
- package/src/lib/theme/runtime/useTheme.ts +1 -2
- package/src/lib/theme/test/testTheme.ts +385 -0
- package/src/lib/theme/tokens/index.ts +12 -0
- package/src/lib/theme/tokens/tokens.ts +721 -0
- package/src/lib/theme/types.ts +6 -42
- package/src/lib/theme/{utils.ts → utils/domUtils.ts} +2 -2
- package/src/lib/theme/utils/index.ts +11 -0
- package/src/lib/theme/utils/injectCSS.ts +90 -0
- package/src/lib/theme/utils/themeHelpers.ts +78 -0
- package/src/lib/theme/{themeUtils.ts → utils/themeUtils.ts} +1 -1
- package/src/lib/theme-tools.ts +8 -9
- package/src/lib/types/components.ts +93 -34
- package/src/lib/types/partProps.ts +0 -16
- package/src/lib/utils/componentUtils.ts +1 -1
- package/src/lib/utils/fontPreloader.ts +148 -0
- package/src/lib/utils/index.ts +11 -0
- package/src/lib/utils/memoryMonitor.ts +189 -0
- package/src/styles/01-settings/_settings.design-tokens.scss +4 -1
- package/src/styles/01-settings/_settings.fonts.scss +2 -5
- package/src/styles/02-tools/_tools.button.scss +66 -79
- package/src/styles/06-components/_components.atomix-glass.scss +13 -3
- package/src/styles/06-components/_components.navbar.scss +0 -6
- package/src/styles/06-components/_components.pagination.scss +88 -0
- package/scripts/build-themes.js +0 -208
- package/scripts/sync-theme-config.js +0 -309
- package/src/components/AtomixGlass/atomixGLass.old.tsx +0 -1263
- package/src/lib/theme/composeTheme.ts +0 -370
- package/src/lib/theme/core/ThemeCache.ts +0 -283
- package/src/lib/theme/core/ThemeEngine.test.ts +0 -146
- package/src/lib/theme/core/ThemeEngine.ts +0 -657
- package/src/lib/theme/createThemeFromConfig.ts +0 -132
- package/src/lib/theme/devtools/CLI.ts +0 -364
- package/src/lib/theme/runtime/ThemeManager.test.ts +0 -192
- package/src/lib/theme/runtime/ThemeManager.ts +0 -442
- package/src/styles/03-generic/_generated-root.css +0 -5
- package/src/themes/README.md +0 -442
- package/src/themes/themes.config.js +0 -35
- /package/src/lib/theme/{cssVariableMapper.ts → adapters/cssVariableMapper.ts} +0 -0
- /package/src/lib/theme/{errors.ts → errors/errors.ts} +0 -0
|
@@ -1,75 +1,105 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Meta,
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
3
|
import { Progress } from './Progress';
|
|
4
|
-
import {
|
|
4
|
+
import { THEME_COLORS, SIZES } from '../../lib/constants/components';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
const meta = {
|
|
7
7
|
title: 'Components/Progress',
|
|
8
8
|
component: Progress,
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: 'centered',
|
|
11
|
+
docs: {
|
|
12
|
+
description: {
|
|
13
|
+
component:
|
|
14
|
+
'The Progress component displays the completion status of a task or process. It provides visual feedback on progress through a horizontal bar that fills based on a percentage value. Progress bars support multiple variants, sizes, and can be used to show loading states, form completion, or any incremental process.',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
tags: ['autodocs'],
|
|
19
|
+
decorators: [
|
|
20
|
+
Story => (
|
|
21
|
+
<div style={{ width: '50%' }}>
|
|
22
|
+
<Story />
|
|
23
|
+
</div>
|
|
24
|
+
),
|
|
25
|
+
],
|
|
9
26
|
argTypes: {
|
|
10
|
-
value: {
|
|
27
|
+
value: {
|
|
28
|
+
control: { type: 'range', min: 0, max: 100 },
|
|
29
|
+
description: 'The progress value as a percentage (0-100)',
|
|
30
|
+
defaultValue: 50,
|
|
31
|
+
},
|
|
11
32
|
variant: {
|
|
12
|
-
control: {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
33
|
+
control: { type: 'select' },
|
|
34
|
+
options: THEME_COLORS,
|
|
35
|
+
description: 'The color variant of the progress bar',
|
|
36
|
+
defaultValue: 'primary',
|
|
16
37
|
},
|
|
17
38
|
size: {
|
|
18
|
-
control: {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
39
|
+
control: { type: 'select' },
|
|
40
|
+
options: SIZES,
|
|
41
|
+
description: 'The size of the progress bar',
|
|
42
|
+
defaultValue: 'md',
|
|
22
43
|
},
|
|
23
44
|
},
|
|
24
|
-
}
|
|
45
|
+
} satisfies Meta<typeof Progress>;
|
|
25
46
|
|
|
26
|
-
|
|
47
|
+
export default meta;
|
|
48
|
+
type Story = StoryObj<typeof meta>;
|
|
27
49
|
|
|
28
|
-
|
|
29
|
-
Default
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
50
|
+
// Default Progress
|
|
51
|
+
export const Default: Story = {
|
|
52
|
+
args: {
|
|
53
|
+
value: 50,
|
|
54
|
+
variant: 'primary',
|
|
55
|
+
size: 'md',
|
|
56
|
+
},
|
|
33
57
|
};
|
|
34
58
|
|
|
35
|
-
export const Secondary =
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
59
|
+
export const Secondary: Story = {
|
|
60
|
+
args: {
|
|
61
|
+
value: 75,
|
|
62
|
+
variant: 'secondary',
|
|
63
|
+
size: 'md',
|
|
64
|
+
},
|
|
40
65
|
};
|
|
41
66
|
|
|
42
|
-
export const Success =
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
67
|
+
export const Success: Story = {
|
|
68
|
+
args: {
|
|
69
|
+
value: 100,
|
|
70
|
+
variant: 'success',
|
|
71
|
+
size: 'md',
|
|
72
|
+
},
|
|
47
73
|
};
|
|
48
74
|
|
|
49
|
-
export const Warning =
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
75
|
+
export const Warning: Story = {
|
|
76
|
+
args: {
|
|
77
|
+
value: 25,
|
|
78
|
+
variant: 'warning',
|
|
79
|
+
size: 'md',
|
|
80
|
+
},
|
|
54
81
|
};
|
|
55
82
|
|
|
56
|
-
export const Error =
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
83
|
+
export const Error: Story = {
|
|
84
|
+
args: {
|
|
85
|
+
value: 10,
|
|
86
|
+
variant: 'error',
|
|
87
|
+
size: 'md',
|
|
88
|
+
},
|
|
61
89
|
};
|
|
62
90
|
|
|
63
|
-
export const Small =
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
91
|
+
export const Small: Story = {
|
|
92
|
+
args: {
|
|
93
|
+
value: 60,
|
|
94
|
+
variant: 'primary',
|
|
95
|
+
size: 'sm',
|
|
96
|
+
},
|
|
68
97
|
};
|
|
69
98
|
|
|
70
|
-
export const Large =
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
99
|
+
export const Large: Story = {
|
|
100
|
+
args: {
|
|
101
|
+
value: 80,
|
|
102
|
+
variant: 'primary',
|
|
103
|
+
size: 'lg',
|
|
104
|
+
},
|
|
75
105
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import React, { forwardRef } from 'react';
|
|
1
|
+
import React, { forwardRef, memo } from 'react';
|
|
2
2
|
import { ProgressProps } from '../../lib/types/components';
|
|
3
3
|
import { useProgress } from '../../lib/composables/useProgress';
|
|
4
4
|
import { PROGRESS } from '../../lib/constants/components';
|
|
5
5
|
import { AtomixGlass } from '../AtomixGlass/AtomixGlass';
|
|
6
6
|
|
|
7
|
-
export const Progress =
|
|
7
|
+
export const Progress = memo(
|
|
8
|
+
forwardRef<HTMLDivElement, ProgressProps>(
|
|
8
9
|
(
|
|
9
10
|
{
|
|
10
11
|
value,
|
|
@@ -54,8 +55,11 @@ export const Progress = forwardRef<HTMLDivElement, ProgressProps>(
|
|
|
54
55
|
|
|
55
56
|
return progressContent;
|
|
56
57
|
}
|
|
58
|
+
)
|
|
57
59
|
);
|
|
58
60
|
|
|
61
|
+
Progress.displayName = 'Progress';
|
|
62
|
+
|
|
59
63
|
export type { ProgressProps };
|
|
60
64
|
|
|
61
65
|
export default Progress;
|
|
@@ -1,118 +1,143 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { fn } from '@storybook/test';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
4
3
|
import { Rating } from './Rating';
|
|
5
|
-
import
|
|
4
|
+
import { THEME_COLORS, SIZES } from '../../lib/constants/components';
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
const meta = {
|
|
8
7
|
title: 'Components/Rating',
|
|
9
8
|
component: Rating,
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: 'centered',
|
|
11
|
+
docs: {
|
|
12
|
+
description: {
|
|
13
|
+
component:
|
|
14
|
+
'The Rating component allows users to display and interact with star-based ratings. It supports whole and half-star ratings, customizable maximum values, and can be used in both interactive and read-only modes. Ratings are ideal for product reviews, user feedback, or any scenario requiring visual rating input.',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
tags: ['autodocs'],
|
|
10
19
|
argTypes: {
|
|
11
|
-
value: {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
20
|
+
value: {
|
|
21
|
+
control: { type: 'number', min: 0, max: 5, step: 0.5 },
|
|
22
|
+
description: 'The current rating value',
|
|
23
|
+
},
|
|
24
|
+
maxValue: {
|
|
25
|
+
control: { type: 'number', min: 1, max: 10 },
|
|
26
|
+
description: 'The maximum rating value',
|
|
27
|
+
},
|
|
28
|
+
allowHalf: {
|
|
29
|
+
control: 'boolean',
|
|
30
|
+
description: 'Whether to allow half-star ratings',
|
|
31
|
+
},
|
|
32
|
+
readOnly: {
|
|
33
|
+
control: 'boolean',
|
|
34
|
+
description: 'Whether the rating is read-only',
|
|
35
|
+
},
|
|
15
36
|
size: {
|
|
16
|
-
control: { type: 'select'
|
|
37
|
+
control: { type: 'select' },
|
|
38
|
+
options: SIZES,
|
|
39
|
+
description: 'The size of the rating stars',
|
|
17
40
|
},
|
|
18
41
|
color: {
|
|
19
|
-
control: {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
},
|
|
42
|
+
control: { type: 'select' },
|
|
43
|
+
options: THEME_COLORS,
|
|
44
|
+
description: 'The color variant of the rating',
|
|
23
45
|
},
|
|
24
46
|
glass: {
|
|
25
47
|
control: 'boolean',
|
|
26
48
|
description: 'Enable glass morphism effect',
|
|
27
49
|
},
|
|
28
50
|
},
|
|
29
|
-
|
|
30
|
-
docs: {
|
|
31
|
-
description: {
|
|
32
|
-
component: 'Rating component for displaying and collecting star ratings',
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
} as Meta;
|
|
51
|
+
} satisfies Meta<typeof Rating>;
|
|
37
52
|
|
|
38
|
-
|
|
53
|
+
export default meta;
|
|
54
|
+
type Story = StoryObj<typeof meta>;
|
|
39
55
|
|
|
40
|
-
|
|
41
|
-
Default
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
56
|
+
// Default Rating
|
|
57
|
+
export const Default: Story = {
|
|
58
|
+
args: {
|
|
59
|
+
value: 3,
|
|
60
|
+
maxValue: 5,
|
|
61
|
+
allowHalf: false,
|
|
62
|
+
readOnly: false,
|
|
63
|
+
size: 'md',
|
|
64
|
+
},
|
|
47
65
|
};
|
|
48
66
|
|
|
49
|
-
export const ReadOnly =
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
67
|
+
export const ReadOnly: Story = {
|
|
68
|
+
args: {
|
|
69
|
+
value: 4,
|
|
70
|
+
maxValue: 5,
|
|
71
|
+
allowHalf: false,
|
|
72
|
+
readOnly: true,
|
|
73
|
+
size: 'md',
|
|
74
|
+
},
|
|
56
75
|
};
|
|
57
76
|
|
|
58
|
-
export const HalfStars =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
77
|
+
export const HalfStars: Story = {
|
|
78
|
+
args: {
|
|
79
|
+
value: 3.5,
|
|
80
|
+
maxValue: 5,
|
|
81
|
+
allowHalf: true,
|
|
82
|
+
readOnly: true,
|
|
83
|
+
size: 'md',
|
|
84
|
+
},
|
|
65
85
|
};
|
|
66
86
|
|
|
67
|
-
export const Small =
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
87
|
+
export const Small: Story = {
|
|
88
|
+
args: {
|
|
89
|
+
value: 4,
|
|
90
|
+
maxValue: 5,
|
|
91
|
+
allowHalf: false,
|
|
92
|
+
readOnly: true,
|
|
93
|
+
size: 'sm',
|
|
94
|
+
},
|
|
74
95
|
};
|
|
75
96
|
|
|
76
|
-
export const Large =
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
97
|
+
export const Large: Story = {
|
|
98
|
+
args: {
|
|
99
|
+
value: 4,
|
|
100
|
+
maxValue: 5,
|
|
101
|
+
allowHalf: false,
|
|
102
|
+
readOnly: true,
|
|
103
|
+
size: 'lg',
|
|
104
|
+
},
|
|
83
105
|
};
|
|
84
106
|
|
|
85
|
-
export const CustomColor =
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
107
|
+
export const CustomColor: Story = {
|
|
108
|
+
args: {
|
|
109
|
+
value: 4,
|
|
110
|
+
maxValue: 5,
|
|
111
|
+
allowHalf: false,
|
|
112
|
+
readOnly: true,
|
|
113
|
+
size: 'md',
|
|
114
|
+
color: 'warning',
|
|
115
|
+
},
|
|
93
116
|
};
|
|
94
117
|
|
|
95
|
-
export const Interactive:
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
118
|
+
export const Interactive: Story = {
|
|
119
|
+
render: () => {
|
|
120
|
+
const [rating, setRating] = useState(3);
|
|
121
|
+
return (
|
|
122
|
+
<div>
|
|
123
|
+
<p>Selected rating: {rating}</p>
|
|
124
|
+
<Rating value={rating} onChange={setRating} allowHalf={true} />
|
|
125
|
+
</div>
|
|
126
|
+
);
|
|
127
|
+
},
|
|
104
128
|
};
|
|
105
129
|
|
|
106
|
-
export const CustomMaxValue =
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
130
|
+
export const CustomMaxValue: Story = {
|
|
131
|
+
args: {
|
|
132
|
+
value: 7,
|
|
133
|
+
maxValue: 10,
|
|
134
|
+
allowHalf: false,
|
|
135
|
+
readOnly: true,
|
|
136
|
+
size: 'md',
|
|
137
|
+
},
|
|
113
138
|
};
|
|
114
139
|
|
|
115
|
-
export const Glass = {
|
|
140
|
+
export const Glass: Story = {
|
|
116
141
|
args: {
|
|
117
142
|
value: 4,
|
|
118
143
|
maxValue: 5,
|
|
@@ -138,7 +163,7 @@ export const Glass = {
|
|
|
138
163
|
),
|
|
139
164
|
};
|
|
140
165
|
|
|
141
|
-
export const GlassInteractive = {
|
|
166
|
+
export const GlassInteractive: Story = {
|
|
142
167
|
args: {
|
|
143
168
|
value: 3,
|
|
144
169
|
maxValue: 5,
|
|
@@ -174,7 +199,7 @@ export const GlassInteractive = {
|
|
|
174
199
|
),
|
|
175
200
|
};
|
|
176
201
|
|
|
177
|
-
export const GlassCustom = {
|
|
202
|
+
export const GlassCustom: Story = {
|
|
178
203
|
args: {
|
|
179
204
|
value: 4.5,
|
|
180
205
|
maxValue: 5,
|
|
@@ -54,6 +54,9 @@ export const Rating = forwardRef<HTMLDivElement, RatingProps>(
|
|
|
54
54
|
onChange,
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
+
// Create forked ref - must be called unconditionally
|
|
58
|
+
const forkedRef = useForkRef(internalRef, ref);
|
|
59
|
+
|
|
57
60
|
// Handle mouse enter on star with half-star support
|
|
58
61
|
const handleMouseEnter = useCallback(
|
|
59
62
|
(e: React.MouseEvent, starValue: number) => {
|
|
@@ -171,7 +174,7 @@ export const Rating = forwardRef<HTMLDivElement, RatingProps>(
|
|
|
171
174
|
// If using vanilla JS, just render the container
|
|
172
175
|
if (useVanillaJS) {
|
|
173
176
|
return (
|
|
174
|
-
<div className={ratingClasses} ref={
|
|
177
|
+
<div className={ratingClasses} ref={forkedRef} id={id} {...restProps}>
|
|
175
178
|
{/* Stars will be generated by the vanilla JS implementation */}
|
|
176
179
|
</div>
|
|
177
180
|
);
|
|
@@ -268,7 +271,7 @@ export const Rating = forwardRef<HTMLDivElement, RatingProps>(
|
|
|
268
271
|
const ratingContent = (
|
|
269
272
|
<div
|
|
270
273
|
className={ratingClasses}
|
|
271
|
-
ref={
|
|
274
|
+
ref={forkedRef}
|
|
272
275
|
id={id}
|
|
273
276
|
style={style}
|
|
274
277
|
data-readonly={readOnly ? 'true' : 'false'}
|