@akinon/ui-steps 0.2.0 → 0.4.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.
@@ -1,17 +1,5 @@
1
1
  import * as React from 'react';
2
- interface IStepProps {
3
- description?: React.ReactNode;
4
- icon?: React.ReactNode;
5
- onClick?: React.MouseEventHandler<HTMLElement>;
6
- disabled?: boolean;
7
- title?: React.ReactNode;
8
- }
9
- export interface IStepsProps {
10
- items?: IStepProps[];
11
- current?: number;
12
- onChange?: (current: number) => void;
13
- size?: 'default' | 'small';
14
- }
15
- export declare const Steps: ({ size, ...restOf }: IStepsProps) => React.JSX.Element;
16
- export {};
2
+ import { IStepProps } from './types';
3
+ export declare const Steps: ({ items, manyItems, ...restStepsProps }: IStepProps) => React.JSX.Element;
4
+ export type { IStepProps };
17
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,UAAU,UAAU;IAClB,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,OAAO,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;IAC/C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACzB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,IAAI,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;CAC5B;AAED,eAAO,MAAM,KAAK,wBAAqC,WAAW,sBAEjE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,eAAO,MAAM,KAAK,4CAIf,UAAU,sBAyMZ,CAAC;AAEF,YAAY,EAAE,UAAU,EAAE,CAAC"}
package/dist/cjs/index.js CHANGED
@@ -12,10 +12,195 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.Steps = void 0;
15
+ const icons_1 = require("@akinon/icons");
16
+ const ui_theme_1 = require("@akinon/ui-theme");
17
+ const cssinjs_1 = require("@ant-design/cssinjs");
15
18
  const antd_1 = require("antd");
16
19
  const React = require("react");
17
20
  const Steps = (_a) => {
18
- var { size = 'default' } = _a, restOf = __rest(_a, ["size"]);
19
- return React.createElement(antd_1.Steps, Object.assign({ size: size }, restOf));
21
+ var { items = [], manyItems = false } = _a, restStepsProps = __rest(_a, ["items", "manyItems"]);
22
+ const stepsWithIcons = items.map(item => (Object.assign(Object.assign({}, item), { icon: item.icon ? React.createElement(icons_1.Icon, { icon: item.icon }) : undefined })));
23
+ const { getPrefixCls, theme } = React.useContext(antd_1.ConfigProvider.ConfigContext);
24
+ const { token, hashId } = (0, ui_theme_1.useToken)();
25
+ const stepToken = token.Steps;
26
+ const prefixWithoutHash = `${getPrefixCls()}-steps`;
27
+ const prefixClsWithoutHash = `.${prefixWithoutHash}`;
28
+ const stepsClassName = `${prefixWithoutHash} ${manyItems ? 'many-items' : ''}`;
29
+ const useStyle = (0, cssinjs_1.useStyleRegister)({
30
+ token: token,
31
+ path: ['Steps'],
32
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
+ theme: theme
34
+ }, () => {
35
+ const prefixCls = `:where(.${hashId}).${getPrefixCls()}-steps`;
36
+ return {
37
+ [prefixCls]: {},
38
+ [prefixClsWithoutHash]: {
39
+ [`${prefixClsWithoutHash}-item`]: {
40
+ paddingInlineStart: stepToken.zero,
41
+ flex: '1 !important',
42
+ [`&-container`]: {
43
+ display: stepToken.flex,
44
+ flexDirection: manyItems ? 'column-reverse' : 'column',
45
+ alignItems: manyItems ? 'center' : 'center',
46
+ justifyContent: manyItems ? 'center' : 'center',
47
+ rowGap: stepToken.rowGap
48
+ },
49
+ [`&-content`]: {
50
+ transform: manyItems
51
+ ? stepToken.manyItemsTransform
52
+ : stepToken.none,
53
+ width: manyItems ? stepToken.manyItemsWidth : stepToken.auto,
54
+ paddingInlineEnd: manyItems
55
+ ? stepToken.paddingInlineEnd
56
+ : stepToken.zero,
57
+ height: manyItems ? stepToken.manyItemsHeight : stepToken.auto,
58
+ whiteSpace: manyItems
59
+ ? stepToken.manyItemsWhiteSpace
60
+ : stepToken.none,
61
+ display: stepToken.flex,
62
+ alignItems: 'center',
63
+ wordBreak: 'break-word',
64
+ marginInlineStart: manyItems
65
+ ? stepToken.manyItemsMarginInlineStart
66
+ : stepToken.zero
67
+ },
68
+ [`&-title`]: {
69
+ lineHeight: 1,
70
+ fontSize: stepToken.titleFontSize,
71
+ fontWeight: '600 !important',
72
+ paddingInlineEnd: manyItems
73
+ ? stepToken.zero
74
+ : stepToken.paddingInlineEnd,
75
+ ['&::after']: {
76
+ display: stepToken.none
77
+ }
78
+ },
79
+ [`&-icon`]: {
80
+ lineHeight: 1,
81
+ width: manyItems
82
+ ? stepToken.manyItemsIconWidthHeight
83
+ : stepToken.iconWidthHeight,
84
+ height: manyItems
85
+ ? stepToken.manyItemsIconWidthHeight
86
+ : stepToken.iconWidthHeight,
87
+ marginInlineEnd: stepToken.zero,
88
+ ['span']: {
89
+ borderRadius: '50%',
90
+ display: stepToken.flex,
91
+ width: stepToken.full,
92
+ height: stepToken.full
93
+ },
94
+ ['svg']: {
95
+ width: stepToken.iconSize,
96
+ height: stepToken.iconSize,
97
+ margin: stepToken.auto,
98
+ color: stepToken.iconColor,
99
+ display: manyItems ? stepToken.none : 'inline-block'
100
+ }
101
+ },
102
+ [`&-tail`]: {
103
+ display: 'block !important',
104
+ zIndex: -1,
105
+ top: manyItems ? stepToken.auto : stepToken.tailTop,
106
+ bottom: manyItems
107
+ ? stepToken.manyItemsTailBottom
108
+ : stepToken.auto,
109
+ ['::after']: {
110
+ height: manyItems
111
+ ? stepToken.manyItemsTailHeight
112
+ : stepToken.tailHeight,
113
+ borderRadius: stepToken.zero
114
+ }
115
+ },
116
+ [`&:first-child`]: {
117
+ [`${prefixClsWithoutHash}-item-tail`]: {
118
+ ['&::after']: {
119
+ background: stepToken.tailFirstChildColor
120
+ }
121
+ }
122
+ },
123
+ [`&:last-child`]: {
124
+ [`${prefixClsWithoutHash}-item-tail`]: {
125
+ ['&::after']: {
126
+ background: stepToken.tailLastChildColor
127
+ }
128
+ }
129
+ },
130
+ [`&:not(.${prefixClsWithoutHash}-item-finish, .${prefixClsWithoutHash}-item-process):last-child`]: {
131
+ [`${prefixClsWithoutHash}-item-tail`]: {
132
+ ['&::after']: {
133
+ background: stepToken.tailColor
134
+ }
135
+ }
136
+ }
137
+ },
138
+ [`${prefixClsWithoutHash}-item-finish`]: {
139
+ [`${prefixClsWithoutHash}-item-icon`]: {
140
+ backgroundColor: stepToken.finishIconBgColor
141
+ },
142
+ ['&:not(:last-child, :first-child)']: {
143
+ [`${prefixClsWithoutHash}-item-tail`]: {
144
+ ['&::after']: {
145
+ backgroundColor: stepToken.finishTailColor
146
+ }
147
+ }
148
+ }
149
+ },
150
+ [`${prefixClsWithoutHash}-item-process`]: {
151
+ [`${prefixClsWithoutHash}-item-icon`]: {
152
+ backgroundColor: stepToken.processIconBgColor
153
+ },
154
+ ['&:not(:last-child, :first-child)']: {
155
+ [`${prefixClsWithoutHash}-item-tail`]: {
156
+ ['&::after']: {
157
+ background: stepToken.tailProcessColor
158
+ }
159
+ }
160
+ },
161
+ ['&:first-child']: {
162
+ [`${prefixClsWithoutHash}-item-tail`]: {
163
+ ['&::after']: {
164
+ background: stepToken.tailProcessFirstChildColor
165
+ }
166
+ }
167
+ },
168
+ ['&:last-child']: {
169
+ [`${prefixClsWithoutHash}-item-tail`]: {
170
+ ['&::after']: {
171
+ background: stepToken.tailLastChildColor
172
+ }
173
+ }
174
+ }
175
+ },
176
+ [`${prefixClsWithoutHash}-item-wait`]: {
177
+ [`${prefixClsWithoutHash}-item-icon`]: {
178
+ backgroundColor: stepToken.waitIconBgColor,
179
+ ['svg']: {
180
+ color: stepToken.waitIconColor
181
+ }
182
+ },
183
+ [`${prefixClsWithoutHash}-item-title`]: {
184
+ color: stepToken.waitTitleColor
185
+ },
186
+ ['&:not(:last-child, :first-child)']: {
187
+ [`${prefixClsWithoutHash}-item-tail`]: {
188
+ ['&::after']: {
189
+ backgroundColor: stepToken.waitTailColor
190
+ }
191
+ }
192
+ },
193
+ [`&:last-child`]: {
194
+ [`${prefixClsWithoutHash}-item-tail`]: {
195
+ ['&::after']: {
196
+ background: stepToken.tailWaitLastChildColor
197
+ }
198
+ }
199
+ }
200
+ }
201
+ }
202
+ };
203
+ });
204
+ return useStyle(React.createElement(antd_1.Steps, Object.assign({}, restStepsProps, { className: stepsClassName, items: stepsWithIcons })));
20
205
  };
21
206
  exports.Steps = Steps;
@@ -1,17 +1,5 @@
1
1
  import * as React from 'react';
2
- interface IStepProps {
3
- description?: React.ReactNode;
4
- icon?: React.ReactNode;
5
- onClick?: React.MouseEventHandler<HTMLElement>;
6
- disabled?: boolean;
7
- title?: React.ReactNode;
8
- }
9
- export interface IStepsProps {
10
- items?: IStepProps[];
11
- current?: number;
12
- onChange?: (current: number) => void;
13
- size?: 'default' | 'small';
14
- }
15
- export declare const Steps: ({ size, ...restOf }: IStepsProps) => React.JSX.Element;
16
- export {};
2
+ import { IStepProps } from './types';
3
+ export declare const Steps: ({ items, manyItems, ...restStepsProps }: IStepProps) => React.JSX.Element;
4
+ export type { IStepProps };
17
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,UAAU,UAAU;IAClB,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,OAAO,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;IAC/C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACzB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,IAAI,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;CAC5B;AAED,eAAO,MAAM,KAAK,wBAAqC,WAAW,sBAEjE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,eAAO,MAAM,KAAK,4CAIf,UAAU,sBAyMZ,CAAC;AAEF,YAAY,EAAE,UAAU,EAAE,CAAC"}
package/dist/esm/index.js CHANGED
@@ -9,9 +9,194 @@ var __rest = (this && this.__rest) || function (s, e) {
9
9
  }
10
10
  return t;
11
11
  };
12
- import { Steps as AntSteps } from 'antd';
12
+ import { Icon } from '@akinon/icons';
13
+ import { useToken } from '@akinon/ui-theme';
14
+ import { useStyleRegister } from '@ant-design/cssinjs';
15
+ import { ConfigProvider, Steps as AntSteps } from 'antd';
13
16
  import * as React from 'react';
14
17
  export const Steps = (_a) => {
15
- var { size = 'default' } = _a, restOf = __rest(_a, ["size"]);
16
- return React.createElement(AntSteps, Object.assign({ size: size }, restOf));
18
+ var { items = [], manyItems = false } = _a, restStepsProps = __rest(_a, ["items", "manyItems"]);
19
+ const stepsWithIcons = items.map(item => (Object.assign(Object.assign({}, item), { icon: item.icon ? React.createElement(Icon, { icon: item.icon }) : undefined })));
20
+ const { getPrefixCls, theme } = React.useContext(ConfigProvider.ConfigContext);
21
+ const { token, hashId } = useToken();
22
+ const stepToken = token.Steps;
23
+ const prefixWithoutHash = `${getPrefixCls()}-steps`;
24
+ const prefixClsWithoutHash = `.${prefixWithoutHash}`;
25
+ const stepsClassName = `${prefixWithoutHash} ${manyItems ? 'many-items' : ''}`;
26
+ const useStyle = useStyleRegister({
27
+ token: token,
28
+ path: ['Steps'],
29
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
+ theme: theme
31
+ }, () => {
32
+ const prefixCls = `:where(.${hashId}).${getPrefixCls()}-steps`;
33
+ return {
34
+ [prefixCls]: {},
35
+ [prefixClsWithoutHash]: {
36
+ [`${prefixClsWithoutHash}-item`]: {
37
+ paddingInlineStart: stepToken.zero,
38
+ flex: '1 !important',
39
+ [`&-container`]: {
40
+ display: stepToken.flex,
41
+ flexDirection: manyItems ? 'column-reverse' : 'column',
42
+ alignItems: manyItems ? 'center' : 'center',
43
+ justifyContent: manyItems ? 'center' : 'center',
44
+ rowGap: stepToken.rowGap
45
+ },
46
+ [`&-content`]: {
47
+ transform: manyItems
48
+ ? stepToken.manyItemsTransform
49
+ : stepToken.none,
50
+ width: manyItems ? stepToken.manyItemsWidth : stepToken.auto,
51
+ paddingInlineEnd: manyItems
52
+ ? stepToken.paddingInlineEnd
53
+ : stepToken.zero,
54
+ height: manyItems ? stepToken.manyItemsHeight : stepToken.auto,
55
+ whiteSpace: manyItems
56
+ ? stepToken.manyItemsWhiteSpace
57
+ : stepToken.none,
58
+ display: stepToken.flex,
59
+ alignItems: 'center',
60
+ wordBreak: 'break-word',
61
+ marginInlineStart: manyItems
62
+ ? stepToken.manyItemsMarginInlineStart
63
+ : stepToken.zero
64
+ },
65
+ [`&-title`]: {
66
+ lineHeight: 1,
67
+ fontSize: stepToken.titleFontSize,
68
+ fontWeight: '600 !important',
69
+ paddingInlineEnd: manyItems
70
+ ? stepToken.zero
71
+ : stepToken.paddingInlineEnd,
72
+ ['&::after']: {
73
+ display: stepToken.none
74
+ }
75
+ },
76
+ [`&-icon`]: {
77
+ lineHeight: 1,
78
+ width: manyItems
79
+ ? stepToken.manyItemsIconWidthHeight
80
+ : stepToken.iconWidthHeight,
81
+ height: manyItems
82
+ ? stepToken.manyItemsIconWidthHeight
83
+ : stepToken.iconWidthHeight,
84
+ marginInlineEnd: stepToken.zero,
85
+ ['span']: {
86
+ borderRadius: '50%',
87
+ display: stepToken.flex,
88
+ width: stepToken.full,
89
+ height: stepToken.full
90
+ },
91
+ ['svg']: {
92
+ width: stepToken.iconSize,
93
+ height: stepToken.iconSize,
94
+ margin: stepToken.auto,
95
+ color: stepToken.iconColor,
96
+ display: manyItems ? stepToken.none : 'inline-block'
97
+ }
98
+ },
99
+ [`&-tail`]: {
100
+ display: 'block !important',
101
+ zIndex: -1,
102
+ top: manyItems ? stepToken.auto : stepToken.tailTop,
103
+ bottom: manyItems
104
+ ? stepToken.manyItemsTailBottom
105
+ : stepToken.auto,
106
+ ['::after']: {
107
+ height: manyItems
108
+ ? stepToken.manyItemsTailHeight
109
+ : stepToken.tailHeight,
110
+ borderRadius: stepToken.zero
111
+ }
112
+ },
113
+ [`&:first-child`]: {
114
+ [`${prefixClsWithoutHash}-item-tail`]: {
115
+ ['&::after']: {
116
+ background: stepToken.tailFirstChildColor
117
+ }
118
+ }
119
+ },
120
+ [`&:last-child`]: {
121
+ [`${prefixClsWithoutHash}-item-tail`]: {
122
+ ['&::after']: {
123
+ background: stepToken.tailLastChildColor
124
+ }
125
+ }
126
+ },
127
+ [`&:not(.${prefixClsWithoutHash}-item-finish, .${prefixClsWithoutHash}-item-process):last-child`]: {
128
+ [`${prefixClsWithoutHash}-item-tail`]: {
129
+ ['&::after']: {
130
+ background: stepToken.tailColor
131
+ }
132
+ }
133
+ }
134
+ },
135
+ [`${prefixClsWithoutHash}-item-finish`]: {
136
+ [`${prefixClsWithoutHash}-item-icon`]: {
137
+ backgroundColor: stepToken.finishIconBgColor
138
+ },
139
+ ['&:not(:last-child, :first-child)']: {
140
+ [`${prefixClsWithoutHash}-item-tail`]: {
141
+ ['&::after']: {
142
+ backgroundColor: stepToken.finishTailColor
143
+ }
144
+ }
145
+ }
146
+ },
147
+ [`${prefixClsWithoutHash}-item-process`]: {
148
+ [`${prefixClsWithoutHash}-item-icon`]: {
149
+ backgroundColor: stepToken.processIconBgColor
150
+ },
151
+ ['&:not(:last-child, :first-child)']: {
152
+ [`${prefixClsWithoutHash}-item-tail`]: {
153
+ ['&::after']: {
154
+ background: stepToken.tailProcessColor
155
+ }
156
+ }
157
+ },
158
+ ['&:first-child']: {
159
+ [`${prefixClsWithoutHash}-item-tail`]: {
160
+ ['&::after']: {
161
+ background: stepToken.tailProcessFirstChildColor
162
+ }
163
+ }
164
+ },
165
+ ['&:last-child']: {
166
+ [`${prefixClsWithoutHash}-item-tail`]: {
167
+ ['&::after']: {
168
+ background: stepToken.tailLastChildColor
169
+ }
170
+ }
171
+ }
172
+ },
173
+ [`${prefixClsWithoutHash}-item-wait`]: {
174
+ [`${prefixClsWithoutHash}-item-icon`]: {
175
+ backgroundColor: stepToken.waitIconBgColor,
176
+ ['svg']: {
177
+ color: stepToken.waitIconColor
178
+ }
179
+ },
180
+ [`${prefixClsWithoutHash}-item-title`]: {
181
+ color: stepToken.waitTitleColor
182
+ },
183
+ ['&:not(:last-child, :first-child)']: {
184
+ [`${prefixClsWithoutHash}-item-tail`]: {
185
+ ['&::after']: {
186
+ backgroundColor: stepToken.waitTailColor
187
+ }
188
+ }
189
+ },
190
+ [`&:last-child`]: {
191
+ [`${prefixClsWithoutHash}-item-tail`]: {
192
+ ['&::after']: {
193
+ background: stepToken.tailWaitLastChildColor
194
+ }
195
+ }
196
+ }
197
+ }
198
+ }
199
+ };
200
+ });
201
+ return useStyle(React.createElement(AntSteps, Object.assign({}, restStepsProps, { className: stepsClassName, items: stepsWithIcons })));
17
202
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/ui-steps",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/esm/index.js",
@@ -9,16 +9,16 @@
9
9
  "dist"
10
10
  ],
11
11
  "dependencies": {
12
- "antd": "5.11.0"
12
+ "antd": "5.17.0",
13
+ "@akinon/icons": "0.5.0",
14
+ "@akinon/ui-theme": "0.6.0"
13
15
  },
14
16
  "devDependencies": {
15
17
  "clean-package": "2.2.0",
16
18
  "copyfiles": "^2.4.1",
17
19
  "rimraf": "^5.0.5",
18
20
  "typescript": "^5.2.2",
19
- "@akinon/vite-config": "0.3.0",
20
- "@akinon/eslint-config": "0.1.0",
21
- "@akinon/typescript-config": "0.1.0"
21
+ "@akinon/typescript-config": "0.3.0"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "react": ">=18",
@@ -40,10 +40,6 @@
40
40
  "build:commonjs": "tsc --module commonjs --outDir dist/cjs",
41
41
  "copy:files": "copyfiles -u 1 src/**/*.css dist/esm && copyfiles -u 1 src/**/*.css dist/cjs",
42
42
  "clean": "rimraf dist/",
43
- "lint": "eslint *.ts*",
44
- "test": "vitest run",
45
- "test:ui": "vitest --ui",
46
- "test:watch": "vitest watch",
47
43
  "typecheck": "tsc --noEmit"
48
44
  }
49
45
  }