@akinon/ui-button 0.6.0 → 0.7.0
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/dist/cjs/types.d.ts +102 -0
- package/dist/esm/types.d.ts +102 -0
- package/package.json +5 -5
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { IconName } from '@akinon/icons';
|
|
2
|
+
import { DO_NOT_USE_OR_YOU_WILL_BE_FIRED_INTERNAL_STYLE } from '@akinon/ui-theme';
|
|
3
|
+
|
|
4
|
+
// TODO: contribute antd to extend the types properly
|
|
5
|
+
export type TButtonType =
|
|
6
|
+
| 'default'
|
|
7
|
+
| 'primary'
|
|
8
|
+
| 'text'
|
|
9
|
+
| 'link'
|
|
10
|
+
| 'success'
|
|
11
|
+
| 'warning';
|
|
12
|
+
|
|
13
|
+
type TMergedHTMLAttributes = React.HTMLAttributes<HTMLElement> &
|
|
14
|
+
React.ButtonHTMLAttributes<HTMLButtonElement> &
|
|
15
|
+
React.AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
16
|
+
|
|
17
|
+
// TODO: contribute antd to generate TS docgen with descriptions
|
|
18
|
+
/**
|
|
19
|
+
* The props of the Button component.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
export interface IButtonProps extends TMergedHTMLAttributes {
|
|
23
|
+
/**
|
|
24
|
+
* The type of the button. Note that this is different from the html type.
|
|
25
|
+
* @default default
|
|
26
|
+
*/
|
|
27
|
+
type?: TButtonType;
|
|
28
|
+
/**
|
|
29
|
+
* The href of the button. If provided, the button will be rendered as an anchor (`<a>`) tag.
|
|
30
|
+
*/
|
|
31
|
+
href?: string;
|
|
32
|
+
/**
|
|
33
|
+
* The HTML type of the button. Note that this is different from the `type`.
|
|
34
|
+
* See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#type
|
|
35
|
+
*/
|
|
36
|
+
htmlType?: HTMLButtonElement['type'];
|
|
37
|
+
/**
|
|
38
|
+
* The size of the button. `middle` is strongly recommended due to the Akinon design system.
|
|
39
|
+
* Do not use this prop except for special cases.
|
|
40
|
+
* @default middle
|
|
41
|
+
*/
|
|
42
|
+
size?: 'middle' | 'small';
|
|
43
|
+
/**
|
|
44
|
+
* onClick handler.
|
|
45
|
+
* @param event
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
onClick?: (event: React.MouseEvent) => void;
|
|
49
|
+
/**
|
|
50
|
+
* The icon name of the button. Only icons from `akinon/icons` are supported.
|
|
51
|
+
* If there is no icon which you want to use, please open an issue.
|
|
52
|
+
*/
|
|
53
|
+
icon?: IconName;
|
|
54
|
+
/**
|
|
55
|
+
* The position of the icon. Only applicable when icon is defined.
|
|
56
|
+
* @default start
|
|
57
|
+
*/
|
|
58
|
+
iconPosition?: icon extends IconName ? 'start' | 'end' : never;
|
|
59
|
+
/**
|
|
60
|
+
* Whether the button is in disabled state.
|
|
61
|
+
* @default false
|
|
62
|
+
*/
|
|
63
|
+
disabled?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Whether the button is in loading state. If delay is provided, the loading state will be shown after the delay in ms.
|
|
66
|
+
* @default false
|
|
67
|
+
*/
|
|
68
|
+
loading?:
|
|
69
|
+
| boolean
|
|
70
|
+
| {
|
|
71
|
+
delay?: number;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Whether the button is ghost.
|
|
75
|
+
* Recommended for use with `icon` prop without text due to the Akinon design system.
|
|
76
|
+
* @default false
|
|
77
|
+
*/
|
|
78
|
+
ghost?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Whether the button is danger.
|
|
81
|
+
* @default false
|
|
82
|
+
*/
|
|
83
|
+
danger?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Whether the button is block which means it will take the full width of its container.
|
|
86
|
+
* @default false
|
|
87
|
+
*/
|
|
88
|
+
block?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* The children of the button. `string` is strongly recommended due to the Akinon design system.
|
|
91
|
+
*/
|
|
92
|
+
children?: React.ReactNode;
|
|
93
|
+
/**
|
|
94
|
+
* The data attributes of the button.
|
|
95
|
+
*/
|
|
96
|
+
[key: `data-${string}`]: string;
|
|
97
|
+
/**
|
|
98
|
+
* Never use this prop. Akinon design system does not allow custom styles.
|
|
99
|
+
* @ignore
|
|
100
|
+
*/
|
|
101
|
+
style?: DO_NOT_USE_OR_YOU_WILL_BE_FIRED_INTERNAL_STYLE;
|
|
102
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { IconName } from '@akinon/icons';
|
|
2
|
+
import { DO_NOT_USE_OR_YOU_WILL_BE_FIRED_INTERNAL_STYLE } from '@akinon/ui-theme';
|
|
3
|
+
|
|
4
|
+
// TODO: contribute antd to extend the types properly
|
|
5
|
+
export type TButtonType =
|
|
6
|
+
| 'default'
|
|
7
|
+
| 'primary'
|
|
8
|
+
| 'text'
|
|
9
|
+
| 'link'
|
|
10
|
+
| 'success'
|
|
11
|
+
| 'warning';
|
|
12
|
+
|
|
13
|
+
type TMergedHTMLAttributes = React.HTMLAttributes<HTMLElement> &
|
|
14
|
+
React.ButtonHTMLAttributes<HTMLButtonElement> &
|
|
15
|
+
React.AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
16
|
+
|
|
17
|
+
// TODO: contribute antd to generate TS docgen with descriptions
|
|
18
|
+
/**
|
|
19
|
+
* The props of the Button component.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
export interface IButtonProps extends TMergedHTMLAttributes {
|
|
23
|
+
/**
|
|
24
|
+
* The type of the button. Note that this is different from the html type.
|
|
25
|
+
* @default default
|
|
26
|
+
*/
|
|
27
|
+
type?: TButtonType;
|
|
28
|
+
/**
|
|
29
|
+
* The href of the button. If provided, the button will be rendered as an anchor (`<a>`) tag.
|
|
30
|
+
*/
|
|
31
|
+
href?: string;
|
|
32
|
+
/**
|
|
33
|
+
* The HTML type of the button. Note that this is different from the `type`.
|
|
34
|
+
* See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#type
|
|
35
|
+
*/
|
|
36
|
+
htmlType?: HTMLButtonElement['type'];
|
|
37
|
+
/**
|
|
38
|
+
* The size of the button. `middle` is strongly recommended due to the Akinon design system.
|
|
39
|
+
* Do not use this prop except for special cases.
|
|
40
|
+
* @default middle
|
|
41
|
+
*/
|
|
42
|
+
size?: 'middle' | 'small';
|
|
43
|
+
/**
|
|
44
|
+
* onClick handler.
|
|
45
|
+
* @param event
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
onClick?: (event: React.MouseEvent) => void;
|
|
49
|
+
/**
|
|
50
|
+
* The icon name of the button. Only icons from `akinon/icons` are supported.
|
|
51
|
+
* If there is no icon which you want to use, please open an issue.
|
|
52
|
+
*/
|
|
53
|
+
icon?: IconName;
|
|
54
|
+
/**
|
|
55
|
+
* The position of the icon. Only applicable when icon is defined.
|
|
56
|
+
* @default start
|
|
57
|
+
*/
|
|
58
|
+
iconPosition?: icon extends IconName ? 'start' | 'end' : never;
|
|
59
|
+
/**
|
|
60
|
+
* Whether the button is in disabled state.
|
|
61
|
+
* @default false
|
|
62
|
+
*/
|
|
63
|
+
disabled?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Whether the button is in loading state. If delay is provided, the loading state will be shown after the delay in ms.
|
|
66
|
+
* @default false
|
|
67
|
+
*/
|
|
68
|
+
loading?:
|
|
69
|
+
| boolean
|
|
70
|
+
| {
|
|
71
|
+
delay?: number;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Whether the button is ghost.
|
|
75
|
+
* Recommended for use with `icon` prop without text due to the Akinon design system.
|
|
76
|
+
* @default false
|
|
77
|
+
*/
|
|
78
|
+
ghost?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Whether the button is danger.
|
|
81
|
+
* @default false
|
|
82
|
+
*/
|
|
83
|
+
danger?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Whether the button is block which means it will take the full width of its container.
|
|
86
|
+
* @default false
|
|
87
|
+
*/
|
|
88
|
+
block?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* The children of the button. `string` is strongly recommended due to the Akinon design system.
|
|
91
|
+
*/
|
|
92
|
+
children?: React.ReactNode;
|
|
93
|
+
/**
|
|
94
|
+
* The data attributes of the button.
|
|
95
|
+
*/
|
|
96
|
+
[key: `data-${string}`]: string;
|
|
97
|
+
/**
|
|
98
|
+
* Never use this prop. Akinon design system does not allow custom styles.
|
|
99
|
+
* @ignore
|
|
100
|
+
*/
|
|
101
|
+
style?: DO_NOT_USE_OR_YOU_WILL_BE_FIRED_INTERNAL_STYLE;
|
|
102
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akinon/ui-button",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A basic button react component.",
|
|
6
6
|
"type": "module",
|
|
@@ -11,15 +11,15 @@
|
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"antd": "5.17.0",
|
|
14
|
-
"@akinon/
|
|
15
|
-
"@akinon/
|
|
14
|
+
"@akinon/icons": "0.6.0",
|
|
15
|
+
"@akinon/ui-theme": "0.7.0"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"clean-package": "2.2.0",
|
|
19
19
|
"copyfiles": "^2.4.1",
|
|
20
20
|
"rimraf": "^5.0.5",
|
|
21
21
|
"typescript": "^5.2.2",
|
|
22
|
-
"@akinon/typescript-config": "0.
|
|
22
|
+
"@akinon/typescript-config": "0.4.0"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"react": ">=18",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"build": "pnpm run build:esm && pnpm run build:commonjs && pnpm run copy:files",
|
|
40
40
|
"build:esm": "tsc --outDir dist/esm",
|
|
41
41
|
"build:commonjs": "tsc --module commonjs --outDir dist/cjs",
|
|
42
|
-
"copy:files": "copyfiles -u 1 src
|
|
42
|
+
"copy:files": "copyfiles -u 1 \"src/**/*.!(ts|tsx)\" dist/esm && copyfiles -u 1 \"src/**/*.!(ts|tsx)\" dist/cjs",
|
|
43
43
|
"clean": "rimraf dist/",
|
|
44
44
|
"typecheck": "tsc --noEmit"
|
|
45
45
|
}
|