enwawa-ui 1.0.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.
- package/.babelrc.json +16 -0
- package/.eslintrc.cjs +37 -0
- package/.husky/pre-commit +6 -0
- package/.prettierignore +6 -0
- package/.prettierrc +4 -0
- package/.storybook/main.ts +21 -0
- package/.storybook/preview.tsx +57 -0
- package/.vscode/settings.json +14 -0
- package/CHANGELOG.md +118 -0
- package/auto.config.ts +34 -0
- package/constants.ts +1 -0
- package/createIndexes.js +34 -0
- package/index.ts +5 -0
- package/package.json +94 -0
- package/placeholder.ts +1 -0
- package/readme.md +1 -0
- package/rollup.config.mjs +48 -0
- package/stories/Introduction.mdx +221 -0
- package/stories/assets/backgrounds/bg-1.png +0 -0
- package/stories/assets/carousel/login/1st.png +0 -0
- package/stories/assets/icons/code-brackets.svg +1 -0
- package/stories/assets/icons/colors.svg +1 -0
- package/stories/assets/icons/comments.svg +1 -0
- package/stories/assets/icons/direction.svg +1 -0
- package/stories/assets/icons/flow.svg +1 -0
- package/stories/assets/icons/plugin.svg +1 -0
- package/stories/assets/icons/repo.svg +1 -0
- package/stories/assets/icons/stackalt.svg +1 -0
- package/stories/assets/icons/wawa-isotype.svg +4 -0
- package/stories/assets/icons/wawa-logo.svg +6 -0
- package/stories/atoms/AtAvatar/AtAvatar.stories.tsx +61 -0
- package/stories/atoms/AtAvatar/index.tsx +46 -0
- package/stories/atoms/AtButton/AtButton.stories.ts +88 -0
- package/stories/atoms/AtButton/index.tsx +69 -0
- package/stories/atoms/AtButton/styles.ts +13 -0
- package/stories/atoms/AtCheckBox/AtCheckBox.stories.tsx +30 -0
- package/stories/atoms/AtCheckBox/index.tsx +38 -0
- package/stories/atoms/AtDatePicker/AtDatePicker.stories.tsx +45 -0
- package/stories/atoms/AtDatePicker/index.tsx +93 -0
- package/stories/atoms/AtDivider/AtDivider.stories.tsx +57 -0
- package/stories/atoms/AtDivider/index.tsx +44 -0
- package/stories/atoms/AtImage/AtImage.stories.tsx +66 -0
- package/stories/atoms/AtImage/index.tsx +41 -0
- package/stories/atoms/AtLogo/AtLogo.stories.ts +47 -0
- package/stories/atoms/AtLogo/index.tsx +22 -0
- package/stories/atoms/AtLogo/styles.ts +26 -0
- package/stories/atoms/AtNumberInput/AtNumberInput.stories.ts +40 -0
- package/stories/atoms/AtNumberInput/index.tsx +138 -0
- package/stories/atoms/AtNumberInput/styles.tsx +7 -0
- package/stories/atoms/AtPasswordInput/AtPasswordInput.stories.ts +24 -0
- package/stories/atoms/AtPasswordInput/index.tsx +11 -0
- package/stories/atoms/AtRadio/AtRadio.stories.tsx +36 -0
- package/stories/atoms/AtRadio/index.tsx +44 -0
- package/stories/atoms/AtSelect/AtSelect.stories.tsx +132 -0
- package/stories/atoms/AtSelect/index.tsx +229 -0
- package/stories/atoms/AtSelect/styles.tsx +8 -0
- package/stories/atoms/AtText/AtText.stories.ts +104 -0
- package/stories/atoms/AtText/index.tsx +65 -0
- package/stories/atoms/AtTextInput/AtTextInput.stories.ts +40 -0
- package/stories/atoms/AtTextInput/index.tsx +85 -0
- package/stories/atoms/AtTitle/AtTitle.stories.ts +103 -0
- package/stories/atoms/AtTitle/index.tsx +77 -0
- package/stories/atoms/AtTitle/styles.ts +7 -0
- package/stories/atoms/index.ts +14 -0
- package/stories/molecules/MlBreadCrumb/MlBreadCrumb.stories.tsx +123 -0
- package/stories/molecules/MlBreadCrumb/index.tsx +29 -0
- package/stories/molecules/MlCard/MlCard.stories.tsx +55 -0
- package/stories/molecules/MlCard/index.tsx +100 -0
- package/stories/molecules/MlCard/styles.tsx +22 -0
- package/stories/molecules/MlCarousel/MlCarousel.stories.tsx +98 -0
- package/stories/molecules/MlCarousel/index.tsx +67 -0
- package/stories/molecules/MlDropdown/MlDropdown.stories.tsx +121 -0
- package/stories/molecules/MlDropdown/index.tsx +97 -0
- package/stories/molecules/MlFormItem/MlFormItem.stories.tsx +33 -0
- package/stories/molecules/MlFormItem/index.tsx +100 -0
- package/stories/molecules/MlRadioGroup/MlRadioGroup.stories.ts +40 -0
- package/stories/molecules/MlRadioGroup/index.tsx +60 -0
- package/stories/molecules/index.ts +6 -0
- package/stories/organisms/OrAlert/OrAlert.stories.tsx +136 -0
- package/stories/organisms/OrAlert/index.tsx +64 -0
- package/stories/organisms/OrCol/OrCol.stories.tsx +33 -0
- package/stories/organisms/OrCol/index.tsx +108 -0
- package/stories/organisms/OrCol/styles.ts +86 -0
- package/stories/organisms/OrContent/index.tsx +6 -0
- package/stories/organisms/OrCountryCard/OrCountryCard.stories.ts +19 -0
- package/stories/organisms/OrCountryCard/index.tsx +55 -0
- package/stories/organisms/OrFlagGrid/OrFlagGrid.stories.ts +41 -0
- package/stories/organisms/OrFlagGrid/index.tsx +54 -0
- package/stories/organisms/OrFrom/index.tsx +10 -0
- package/stories/organisms/OrHeader/index.tsx +6 -0
- package/stories/organisms/OrLayout/index.tsx +6 -0
- package/stories/organisms/OrLoginLayout/OrLoginLayout.stories.tsx +34 -0
- package/stories/organisms/OrLoginLayout/index.tsx +63 -0
- package/stories/organisms/OrLoginLayout/styles.tsx +16 -0
- package/stories/organisms/OrRow/OrRow.stories.tsx +48 -0
- package/stories/organisms/OrRow/index.tsx +71 -0
- package/stories/organisms/OrRow/styles.ts +24 -0
- package/stories/organisms/OrSider/index.tsx +6 -0
- package/stories/organisms/OrSimpleBanner/OrSimpleBanner.stories.ts +18 -0
- package/stories/organisms/OrSimpleBanner/index.tsx +26 -0
- package/stories/organisms/OrSimpleBanner/styles.ts +12 -0
- package/stories/organisms/OrSpace/OrSpace.stories.tsx +169 -0
- package/stories/organisms/OrSpace/index.tsx +43 -0
- package/stories/organisms/OrSpaceCompact/OrSpaceCompact.stories.tsx +94 -0
- package/stories/organisms/OrSpaceCompact/index.tsx +35 -0
- package/stories/organisms/index.ts +14 -0
- package/stories/templates/TmLoginCountry/TmLoginCountry.stories.ts +44 -0
- package/stories/templates/TmLoginCountry/index.tsx +64 -0
- package/stories/templates/TmLoginCountry/styles.tsx +14 -0
- package/stories/templates/TmLoginPhone/TmLoginPhone.stories.tsx +49 -0
- package/stories/templates/TmLoginPhone/index.tsx +191 -0
- package/stories/templates/TmLoginPhone/styles.tsx +31 -0
- package/stories/templates/index.ts +2 -0
- package/theme.tsx +56 -0
- package/tsconfig.json +38 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Carousel } from 'antd';
|
|
3
|
+
import { DotPosition } from 'antd/es/carousel';
|
|
4
|
+
|
|
5
|
+
export interface MlCarouselProps {
|
|
6
|
+
/**
|
|
7
|
+
* The ID for input
|
|
8
|
+
*/
|
|
9
|
+
id?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Whether to scroll automatically
|
|
12
|
+
*/
|
|
13
|
+
autoplay?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Delay between each auto scroll (in milliseconds)
|
|
16
|
+
*/
|
|
17
|
+
autoplaySpeed?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Center elements into carousel
|
|
20
|
+
*/
|
|
21
|
+
centerMode?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* The position of the dots, which can be one of top bottom left right
|
|
24
|
+
*/
|
|
25
|
+
dotPosition?: DotPosition;
|
|
26
|
+
/**
|
|
27
|
+
* Whether to show the dots at the bottom of the gallery, object for dotsClass and any others
|
|
28
|
+
*/
|
|
29
|
+
dots?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Whether to wait for the animation when switching
|
|
32
|
+
*/
|
|
33
|
+
waitForAnimate?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Transition interpolation function name
|
|
36
|
+
*/
|
|
37
|
+
easing?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Transition effect
|
|
40
|
+
*/
|
|
41
|
+
effect?: 'scrollx' | 'fade';
|
|
42
|
+
/**
|
|
43
|
+
* Callback function called after the current index changes
|
|
44
|
+
*/
|
|
45
|
+
afterChange?: (current: number) => void;
|
|
46
|
+
/**
|
|
47
|
+
* Callback function called before the current index changes
|
|
48
|
+
*/
|
|
49
|
+
beforeChange?: (current: number, next: number) => void;
|
|
50
|
+
|
|
51
|
+
children?: React.ReactNode;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const MlCarousel: React.FC<MlCarouselProps> = ({ ...props }) => (
|
|
55
|
+
<Carousel {...props}>{props.children}</Carousel>
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
MlCarousel.defaultProps = {
|
|
59
|
+
autoplay: false,
|
|
60
|
+
autoplaySpeed: 5000,
|
|
61
|
+
dotPosition: 'bottom',
|
|
62
|
+
dots: true,
|
|
63
|
+
waitForAnimate: false,
|
|
64
|
+
easing: 'linear',
|
|
65
|
+
effect: 'scrollx',
|
|
66
|
+
centerMode: true,
|
|
67
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import { DownOutlined } from '@ant-design/icons';
|
|
4
|
+
import { Space, message } from 'antd';
|
|
5
|
+
import { MIDropdown } from '.';
|
|
6
|
+
|
|
7
|
+
const meta = {
|
|
8
|
+
title: 'Molecules/MIDropdown',
|
|
9
|
+
component: MIDropdown,
|
|
10
|
+
tags: ['autodocs'],
|
|
11
|
+
args: {
|
|
12
|
+
menu: {
|
|
13
|
+
onClick: () => message.info('Click on menu item.'),
|
|
14
|
+
items: [
|
|
15
|
+
{
|
|
16
|
+
key: 1,
|
|
17
|
+
label: 'Item 1',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
key: 2,
|
|
21
|
+
label: 'Item 2',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
key: 3,
|
|
25
|
+
label: 'Item 3',
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
} satisfies Meta<typeof MIDropdown>;
|
|
31
|
+
|
|
32
|
+
export default meta;
|
|
33
|
+
|
|
34
|
+
const defaultChildren = (
|
|
35
|
+
<a onClick={(e) => e.preventDefault()}>
|
|
36
|
+
<Space>
|
|
37
|
+
Hover me
|
|
38
|
+
<DownOutlined />
|
|
39
|
+
</Space>
|
|
40
|
+
</a>
|
|
41
|
+
);
|
|
42
|
+
type Story = StoryObj<typeof meta>;
|
|
43
|
+
|
|
44
|
+
export const Basic: Story = {
|
|
45
|
+
args: {
|
|
46
|
+
children: defaultChildren,
|
|
47
|
+
placement: 'bottomLeft',
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const Loading: Story = {
|
|
52
|
+
args: {
|
|
53
|
+
loading: true,
|
|
54
|
+
children: (
|
|
55
|
+
<a onClick={(e) => e.preventDefault()}>
|
|
56
|
+
<Space>Loading</Space>
|
|
57
|
+
</a>
|
|
58
|
+
),
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const Button: Story = {
|
|
63
|
+
args: {
|
|
64
|
+
children: (
|
|
65
|
+
<a onClick={(e) => e.preventDefault()}>
|
|
66
|
+
<Space>Click Me</Space>
|
|
67
|
+
</a>
|
|
68
|
+
),
|
|
69
|
+
button: true,
|
|
70
|
+
onClick: () => message.info('Click on left button.'),
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const AllPlacements: Story = {
|
|
75
|
+
args: {
|
|
76
|
+
children: defaultChildren,
|
|
77
|
+
placement: 'bottomLeft',
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const PlacementTopLeft: Story = {
|
|
82
|
+
args: {
|
|
83
|
+
...AllPlacements.args,
|
|
84
|
+
placement: 'topLeft',
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export const PlacementTopCenter: Story = {
|
|
89
|
+
args: {
|
|
90
|
+
...AllPlacements.args,
|
|
91
|
+
placement: 'topCenter',
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export const PlacementTopRight: Story = {
|
|
96
|
+
args: {
|
|
97
|
+
...AllPlacements.args,
|
|
98
|
+
placement: 'topRight',
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export const PlacementBottomLeft: Story = {
|
|
103
|
+
args: {
|
|
104
|
+
...AllPlacements.args,
|
|
105
|
+
placement: 'bottomLeft',
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export const PlacementBottomCenter: Story = {
|
|
110
|
+
args: {
|
|
111
|
+
...AllPlacements.args,
|
|
112
|
+
placement: 'bottomCenter',
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export const PlacementBottomRight: Story = {
|
|
117
|
+
args: {
|
|
118
|
+
...AllPlacements.args,
|
|
119
|
+
placement: 'bottomRight',
|
|
120
|
+
},
|
|
121
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { Dropdown, DropdownProps, MenuProps } from 'antd';
|
|
3
|
+
|
|
4
|
+
interface AtDropdownProps extends DropdownProps {
|
|
5
|
+
/**
|
|
6
|
+
* If true, an arrow will be shown
|
|
7
|
+
*/
|
|
8
|
+
arrow?: boolean;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Whether to adjust popup placement automatically in case of overflow
|
|
12
|
+
*/
|
|
13
|
+
autoAdjustOverflow?: boolean;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* If true, the dropdown will be disabled
|
|
17
|
+
*/
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A function used to render the dropdown menu
|
|
22
|
+
*/
|
|
23
|
+
dropdownRender?: (menu: ReactNode) => ReactNode;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Style of the dropdown menu
|
|
27
|
+
*/
|
|
28
|
+
overlayStyle?: React.CSSProperties;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Placement of the dropdown menu. Possible values: 'topLeft', 'topCenter', 'topRight', 'bottomLeft', 'bottomCenter', 'bottomRight'
|
|
32
|
+
*/
|
|
33
|
+
placement?:
|
|
34
|
+
| 'topLeft'
|
|
35
|
+
| 'topCenter'
|
|
36
|
+
| 'topRight'
|
|
37
|
+
| 'bottomLeft'
|
|
38
|
+
| 'bottomCenter'
|
|
39
|
+
| 'bottomRight';
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Triggers for showing the overlay. Possible values: 'click', 'hover', 'contextMenu'
|
|
43
|
+
*/
|
|
44
|
+
trigger?: ('click' | 'hover' | 'contextMenu')[];
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* If true, the dropdown is opened
|
|
48
|
+
*/
|
|
49
|
+
open?: boolean;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* A function to be called when visible changes
|
|
53
|
+
*/
|
|
54
|
+
onOpenChange?: (visible: boolean) => void;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Child elements of the Dropdown component
|
|
58
|
+
*/
|
|
59
|
+
children?: ReactNode;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Menu items
|
|
63
|
+
*/
|
|
64
|
+
menu?: MenuProps;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* If true, the loading icon will be shown
|
|
68
|
+
*/
|
|
69
|
+
loading?: boolean;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* If true, the dropdown will be shown as a button
|
|
73
|
+
*/
|
|
74
|
+
button?: boolean;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* when button is true, the onlick function will be called
|
|
78
|
+
*/
|
|
79
|
+
onClick?: () => void;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export const MIDropdown: React.FC<AtDropdownProps> = (props) => {
|
|
83
|
+
if (props.loading || props.button) {
|
|
84
|
+
return <Dropdown.Button {...props}>{props.children}</Dropdown.Button>;
|
|
85
|
+
}
|
|
86
|
+
return <Dropdown {...props}>{props.children}</Dropdown>;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
MIDropdown.defaultProps = {
|
|
90
|
+
arrow: false,
|
|
91
|
+
autoAdjustOverflow: true,
|
|
92
|
+
disabled: false,
|
|
93
|
+
overlayStyle: {},
|
|
94
|
+
placement: 'bottomLeft',
|
|
95
|
+
trigger: ['hover'],
|
|
96
|
+
loading: false,
|
|
97
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import { MlFormItem } from '.';
|
|
4
|
+
import { AtTextInput } from '../../atoms';
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'Molecules/MlFormItem',
|
|
8
|
+
component: MlFormItem,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
argTypes: {
|
|
11
|
+
validateStatus: {
|
|
12
|
+
control: {
|
|
13
|
+
options: ['none', 'success', 'warning', 'error', 'validating'],
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
} satisfies Meta<typeof MlFormItem>;
|
|
18
|
+
|
|
19
|
+
export default meta;
|
|
20
|
+
type Story = StoryObj<typeof meta>;
|
|
21
|
+
|
|
22
|
+
export const Default: Story = {
|
|
23
|
+
args: {
|
|
24
|
+
name: 'input',
|
|
25
|
+
label: 'Name',
|
|
26
|
+
hasFeedback: true,
|
|
27
|
+
},
|
|
28
|
+
render: (args) => (
|
|
29
|
+
<MlFormItem {...args}>
|
|
30
|
+
<AtTextInput />
|
|
31
|
+
</MlFormItem>
|
|
32
|
+
),
|
|
33
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import FormItem from 'antd/es/form/FormItem';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { NamePath, Store, StoreValue } from 'antd/es/form/interface';
|
|
4
|
+
import { ColProps } from 'antd';
|
|
5
|
+
import { Rule } from 'antd/es/form';
|
|
6
|
+
import { LabelTooltipType } from 'antd/es/form/FormItemLabel';
|
|
7
|
+
|
|
8
|
+
interface MlFromItemProps {
|
|
9
|
+
/**
|
|
10
|
+
* Set the dependencies field by names
|
|
11
|
+
*/
|
|
12
|
+
dependencies?: string[];
|
|
13
|
+
/**
|
|
14
|
+
* The extra prompt message. It is similar to help. Usage example: to display error message and prompt message at the same time
|
|
15
|
+
*/
|
|
16
|
+
extra?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Used with validateStatus, this option specifies the validation status icon. Recommended to be used only with Input
|
|
19
|
+
*/
|
|
20
|
+
hasFeedback?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The prompt message. If not provided, the prompt message will be generated by the validation rule.
|
|
23
|
+
*/
|
|
24
|
+
help?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Whether to hide Form.Item (still collect and validate value)
|
|
27
|
+
*/
|
|
28
|
+
hidden?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Config sub default value. Form initialValues get higher priority when conflict
|
|
31
|
+
*/
|
|
32
|
+
initialValue?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Label text
|
|
35
|
+
*/
|
|
36
|
+
label?: string;
|
|
37
|
+
/**
|
|
38
|
+
* The layout of label. You can set span offset to something like {span: 3, offset: 12} or sm: {span: 3, offset: 12} same as with <Col>. You can set labelCol on Form which will not affect nest Item. If both exists, use Item first
|
|
39
|
+
*/
|
|
40
|
+
labelCol?: ColProps;
|
|
41
|
+
/**
|
|
42
|
+
* The default validate field info
|
|
43
|
+
*/
|
|
44
|
+
messageVariables?: Record<string, string>;
|
|
45
|
+
/**
|
|
46
|
+
* Field name, support array
|
|
47
|
+
*/
|
|
48
|
+
name?: NamePath;
|
|
49
|
+
/**
|
|
50
|
+
* No style for true, used as a pure field control
|
|
51
|
+
*/
|
|
52
|
+
noStyle?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Normalize value from component value before passing to Form instance. Do not support async
|
|
55
|
+
*/
|
|
56
|
+
normalize?: (
|
|
57
|
+
value: StoreValue,
|
|
58
|
+
prevValue: StoreValue,
|
|
59
|
+
allValues: Store,
|
|
60
|
+
) => StoreValue;
|
|
61
|
+
/**
|
|
62
|
+
* Display required style. It will be generated by the validation rule
|
|
63
|
+
*/
|
|
64
|
+
required?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Rules for field validation. Click [here](https://ant.design/components/form#components-form-demo-basic) to see an example
|
|
67
|
+
*/
|
|
68
|
+
rules?: Rule[];
|
|
69
|
+
/**
|
|
70
|
+
* Config tooltip info
|
|
71
|
+
*/
|
|
72
|
+
tooltip?: LabelTooltipType;
|
|
73
|
+
/**
|
|
74
|
+
* The validation status. If not provided, it will be generated by validation rule. options: success warning error validating
|
|
75
|
+
*/
|
|
76
|
+
validateStatus?: 'success' | 'warning' | 'error' | 'validating' | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* When to validate the value of children node
|
|
79
|
+
*/
|
|
80
|
+
validateTrigger?: string | string[] | false;
|
|
81
|
+
/**
|
|
82
|
+
* The layout for input controls, same as labelCol. You can set wrapperCol on Form which will not affect nest Item. If both exists, use Item first
|
|
83
|
+
*/
|
|
84
|
+
wrapperCol?: ColProps;
|
|
85
|
+
children?: React.ReactElement;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export const MlFormItem: React.FC<MlFromItemProps> = ({
|
|
89
|
+
children,
|
|
90
|
+
...props
|
|
91
|
+
}) => {
|
|
92
|
+
return <FormItem {...props}>{children}</FormItem>;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
MlFormItem.defaultProps = {
|
|
96
|
+
hasFeedback: false,
|
|
97
|
+
hidden: false,
|
|
98
|
+
required: false,
|
|
99
|
+
noStyle: false,
|
|
100
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { MlRadioGroup } from '.';
|
|
3
|
+
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'Molecules/MlRadioGroup',
|
|
6
|
+
component: MlRadioGroup,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
argTypes: {
|
|
9
|
+
buttonStyle: { options: ['outline', 'solid'] },
|
|
10
|
+
optionType: { options: ['default', 'button'] },
|
|
11
|
+
size: { options: ['large', 'middle', 'small'] },
|
|
12
|
+
},
|
|
13
|
+
} satisfies Meta<typeof MlRadioGroup>;
|
|
14
|
+
|
|
15
|
+
export default meta;
|
|
16
|
+
|
|
17
|
+
type Story = StoryObj<typeof meta>;
|
|
18
|
+
|
|
19
|
+
export const Base: Story = {
|
|
20
|
+
args: {
|
|
21
|
+
id: '1',
|
|
22
|
+
options: [
|
|
23
|
+
{
|
|
24
|
+
label: 'a',
|
|
25
|
+
value: 'a v',
|
|
26
|
+
disabled: false,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
label: 'b',
|
|
30
|
+
value: 'b v',
|
|
31
|
+
disabled: false,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
label: 'c',
|
|
35
|
+
value: 'c v',
|
|
36
|
+
disabled: true,
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { RadioChangeEvent, Radio } from 'antd';
|
|
3
|
+
|
|
4
|
+
export interface MlRadioGroupProps {
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The ID for input
|
|
8
|
+
*/
|
|
9
|
+
id?: string;
|
|
10
|
+
/**
|
|
11
|
+
* The style type of radio button
|
|
12
|
+
*/
|
|
13
|
+
buttonStyle?: 'outline' | 'solid';
|
|
14
|
+
/**
|
|
15
|
+
* Default selected value
|
|
16
|
+
*/
|
|
17
|
+
defaultValue?: any;
|
|
18
|
+
/**
|
|
19
|
+
* Disable all radio buttons
|
|
20
|
+
*/
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* The name property of all input[type="radio"] children
|
|
24
|
+
*/
|
|
25
|
+
name?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Set children optional
|
|
28
|
+
*/
|
|
29
|
+
options?: string[] | number[] | Array<{ label: ReactNode; value: string; disabled?: boolean; }>;
|
|
30
|
+
/**
|
|
31
|
+
* Set Radio optionType
|
|
32
|
+
*/
|
|
33
|
+
optionType?: 'default' | 'button';
|
|
34
|
+
/**
|
|
35
|
+
* The size of radio button style
|
|
36
|
+
*/
|
|
37
|
+
size?: 'large' | 'middle' | 'small';
|
|
38
|
+
/**
|
|
39
|
+
* Used for setting the currently selected value
|
|
40
|
+
*/
|
|
41
|
+
value?: any;
|
|
42
|
+
/**
|
|
43
|
+
* The callback function that is triggered when the state changes
|
|
44
|
+
*/
|
|
45
|
+
onChange?: (e: RadioChangeEvent) => void;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const MlRadioGroup: React.FC<MlRadioGroupProps> = (props) => {
|
|
49
|
+
return <Radio.Group {...props} />
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
MlRadioGroup.defaultProps = {
|
|
53
|
+
buttonStyle: "outline",
|
|
54
|
+
disabled: false,
|
|
55
|
+
optionType: "default",
|
|
56
|
+
size: "middle"
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import Marquee from 'react-fast-marquee';
|
|
4
|
+
import { OrAlert } from '.';
|
|
5
|
+
import { Button, Space } from 'antd';
|
|
6
|
+
|
|
7
|
+
const meta = {
|
|
8
|
+
title: 'Organisms/OrAlert',
|
|
9
|
+
component: OrAlert,
|
|
10
|
+
tags: ['autodocs'],
|
|
11
|
+
argTypes: {
|
|
12
|
+
action: {
|
|
13
|
+
table: {
|
|
14
|
+
type: {
|
|
15
|
+
summary: 'ReactNode | ReactNode[]',
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
options: {
|
|
19
|
+
default: [],
|
|
20
|
+
withChild: [
|
|
21
|
+
<Space direction="vertical">
|
|
22
|
+
<Button size="small" type="primary">
|
|
23
|
+
Accept
|
|
24
|
+
</Button>
|
|
25
|
+
<Button size="small" danger ghost>
|
|
26
|
+
Decline
|
|
27
|
+
</Button>
|
|
28
|
+
</Space>
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
closeIcon: {
|
|
33
|
+
options: [true, false,
|
|
34
|
+
<Button size="small" danger ghost>
|
|
35
|
+
Close
|
|
36
|
+
</Button>
|
|
37
|
+
],
|
|
38
|
+
control: 'select',
|
|
39
|
+
},
|
|
40
|
+
message: {
|
|
41
|
+
control: 'text',
|
|
42
|
+
},
|
|
43
|
+
description: {
|
|
44
|
+
control: 'text',
|
|
45
|
+
},
|
|
46
|
+
}
|
|
47
|
+
} satisfies Meta<typeof OrAlert>;
|
|
48
|
+
|
|
49
|
+
export default meta;
|
|
50
|
+
|
|
51
|
+
type Story = StoryObj<typeof meta>;
|
|
52
|
+
|
|
53
|
+
export const Basic: Story = {
|
|
54
|
+
args: {
|
|
55
|
+
message: 'I can be a React component, multiple React components, or just some text.',
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const Banner: Story = {
|
|
60
|
+
args: {
|
|
61
|
+
banner: true,
|
|
62
|
+
message: <Marquee pauseOnHover gradient={false}>
|
|
63
|
+
I can be a React component, multiple React components, or just some text.
|
|
64
|
+
</Marquee>
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export const ActionAlert: Story = {
|
|
69
|
+
args: {
|
|
70
|
+
message: 'I can be a React component, multiple React components, or just some text.',
|
|
71
|
+
action: [
|
|
72
|
+
<Space direction="vertical">
|
|
73
|
+
<Button size="small" type="primary">
|
|
74
|
+
Accept
|
|
75
|
+
</Button>
|
|
76
|
+
<Button size="small" danger ghost>
|
|
77
|
+
Decline
|
|
78
|
+
</Button>
|
|
79
|
+
</Space>
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export const Closable: Story = {
|
|
86
|
+
args: {
|
|
87
|
+
message: 'I can be a React component, multiple React components, or just some text.',
|
|
88
|
+
closeIcon: true,
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export const Description: Story = {
|
|
93
|
+
args: {
|
|
94
|
+
message: 'I can be a React component, multiple React components, or just some text.',
|
|
95
|
+
description: 'I can be a React component, multiple React components, or just some text.',
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export const Icon: Story = {
|
|
100
|
+
args: {
|
|
101
|
+
message: 'I can be a React component, multiple React components, or just some text.',
|
|
102
|
+
showIcon: true,
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export const Success: Story = {
|
|
107
|
+
args: {
|
|
108
|
+
message: 'I can be a React component, multiple React components, or just some text.',
|
|
109
|
+
type: 'success',
|
|
110
|
+
showIcon: true,
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export const Info: Story = {
|
|
115
|
+
args: {
|
|
116
|
+
message: 'I can be a React component, multiple React components, or just some text.',
|
|
117
|
+
type: 'info',
|
|
118
|
+
showIcon: true,
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export const Warning: Story = {
|
|
123
|
+
args: {
|
|
124
|
+
message: 'I can be a React component, multiple React components, or just some text.',
|
|
125
|
+
type: 'warning',
|
|
126
|
+
showIcon: true,
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export const Error: Story = {
|
|
131
|
+
args: {
|
|
132
|
+
message: 'I can be a React component, multiple React components, or just some text.',
|
|
133
|
+
type: 'error',
|
|
134
|
+
showIcon: true,
|
|
135
|
+
}
|
|
136
|
+
}
|