@akinon/ui-collapse 0.5.0 → 1.0.1

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,5 +1,19 @@
1
1
  import * as React from 'react';
2
2
  import type { CollapseProps } from './types';
3
+ /**
4
+ * Collapse component for Akinon UI.
5
+ *
6
+ * The Collapse component provides a way to organize content in expandable panels.
7
+ * It allows users to toggle the visibility of content sections, supporting both
8
+ * single (accordion) and multiple open panels at a time.
9
+ *
10
+ * The component is fully customizable with options for expand icons, ghost mode,
11
+ * lazy rendering, and border visibility. It adheres to the Akinon design system,
12
+ * ensuring consistent styling and accessibility.
13
+ *
14
+ * Suitable for use cases where space-saving and content organization are priorities,
15
+ * such as FAQs, settings pages, or nested content structures.
16
+ */
3
17
  export declare const Collapse: ({ ...collapseProps }: CollapseProps) => React.JSX.Element;
4
18
  export type * from './types';
5
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,aAAa,EAAc,MAAM,SAAS,CAAC;AAEzD,eAAO,MAAM,QAAQ,yBAA0B,aAAa,sBAmB3D,CAAC;AAEF,mBAAmB,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,aAAa,EAAc,MAAM,SAAS,CAAC;AAEzD;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,QAAQ,yBAA0B,aAAa,sBAqB3D,CAAC;AAEF,mBAAmB,SAAS,CAAC"}
package/dist/cjs/index.js CHANGED
@@ -15,11 +15,28 @@ exports.Collapse = void 0;
15
15
  const icons_1 = require("@akinon/icons");
16
16
  const antd_1 = require("antd");
17
17
  const React = require("react");
18
+ /**
19
+ * Collapse component for Akinon UI.
20
+ *
21
+ * The Collapse component provides a way to organize content in expandable panels.
22
+ * It allows users to toggle the visibility of content sections, supporting both
23
+ * single (accordion) and multiple open panels at a time.
24
+ *
25
+ * The component is fully customizable with options for expand icons, ghost mode,
26
+ * lazy rendering, and border visibility. It adheres to the Akinon design system,
27
+ * ensuring consistent styling and accessibility.
28
+ *
29
+ * Suitable for use cases where space-saving and content organization are priorities,
30
+ * such as FAQs, settings pages, or nested content structures.
31
+ */
18
32
  const Collapse = (_a) => {
19
33
  var _b;
20
34
  var collapseProps = __rest(_a, []);
21
35
  return (React.createElement(antd_1.Collapse, Object.assign({ ghost: true, defaultActiveKey: (_b = collapseProps.items) === null || _b === void 0 ? void 0 : _b.map(item => item.key) }, collapseProps, (collapseProps.expandIcon && {
22
- expandIcon: panelProps => collapseProps.expandIcon ? (React.createElement(icons_1.Icon, { icon: collapseProps.expandIcon(panelProps), style: collapseProps.iconStyle })) : undefined
36
+ expandIcon: panelProps => {
37
+ const { name, style, size } = collapseProps.expandIcon(panelProps);
38
+ return name ? (React.createElement(icons_1.Icon, { size: size !== null && size !== void 0 ? size : 16, icon: name, style: style })) : undefined;
39
+ }
23
40
  }))));
24
41
  };
25
42
  exports.Collapse = Collapse;
@@ -5,60 +5,73 @@ import type React from 'react';
5
5
  export type ExpandIconPosition = 'start' | 'end';
6
6
  export type CollapsibleType = 'header' | 'icon' | 'disabled';
7
7
 
8
- export interface ItemType extends React.DOMAttributes<HTMLDivElement> {
8
+ export interface CollapseItemType extends React.DOMAttributes<HTMLDivElement> {
9
9
  /**
10
10
  * The key of the panel.
11
11
  */
12
12
  key?: React.Key;
13
+
13
14
  /**
14
15
  * The label of the panel.
15
16
  */
16
17
  label?: React.ReactNode;
18
+
17
19
  /**
18
20
  * The React ref object of the panel.
19
21
  */
20
22
  ref?: React.RefObject<HTMLDivElement>;
23
+
21
24
  /**
22
25
  * The id of the panel.
23
26
  */
24
27
  id?: string;
28
+
25
29
  /**
26
30
  * The class name of the panel header.
27
31
  */
28
32
  headerClass?: string;
33
+
29
34
  /**
30
35
  * Whether to show the arrow.
31
36
  */
32
37
  showArrow?: boolean;
38
+
33
39
  /**
34
40
  * The class name of the panel.
35
41
  */
36
42
  className?: string;
43
+
37
44
  /**
38
45
  * Whether to destroy the inactive panel.
39
46
  */
40
47
  destroyInactivePanel?: boolean;
48
+
41
49
  /**
42
50
  * Forced render of content on panel, instead of lazy rendering after clicking on header.
43
51
  */
44
52
  forceRender?: boolean;
53
+
45
54
  /**
46
55
  * The extra element of the panel header.
47
56
  */
48
57
  extra?: React.ReactNode;
58
+
49
59
  /**
50
60
  * The callback function that is triggered when the panel is clicked.
51
61
  */
52
62
  onItemClick?: (panelKey: React.Key) => void;
63
+
53
64
  /**
54
65
  * Custom expand icon.
55
66
  */
56
67
  expandIcon?: (panelProps: PanelProps) => IconName;
68
+
57
69
  /**
58
70
  * The HTML WAI-ARIA role of the panel.
59
71
  * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles
60
72
  */
61
73
  role?: string;
74
+
62
75
  /**
63
76
  * The children of the panel.
64
77
  */
@@ -70,62 +83,77 @@ export type CollapseProps = {
70
83
  * The key of the active panel.
71
84
  */
72
85
  activeKey?: React.Key | React.Key[];
86
+
73
87
  /**
74
88
  * The default key of the active panel.
75
89
  */
76
90
  defaultActiveKey?: React.Key | React.Key[];
91
+
77
92
  /**
78
93
  * The callback function that is triggered when the active panel changes.
79
94
  */
80
95
  onChange?: (key: React.Key | React.Key[]) => void;
96
+
81
97
  /**
82
98
  * Whether to enable accordion mode.
83
99
  */
84
100
  accordion?: boolean;
101
+
85
102
  /**
86
103
  * The class name of the collapse.
87
104
  */
88
105
  className?: string;
106
+
89
107
  /**
90
108
  * The class name of the root element.
91
109
  */
92
110
  rootClassName?: string;
111
+
93
112
  /**
94
113
  * Whether to show border.
95
114
  */
96
115
  bordered?: boolean;
116
+
97
117
  /**
98
118
  * Whether to destroy the inactive panel.
99
119
  */
100
120
  destroyInactivePanel?: boolean;
121
+
101
122
  /**
102
123
  * The expand icon.
103
124
  */
104
- expandIcon?: (panelProps: PanelProps) => IconName;
125
+ expandIcon?: (panelProps: PanelProps) => {
126
+ name: IconName;
127
+ size?: number;
128
+ style?: React.CSSProperties;
129
+ ariaProps?: React.HTMLAttributes<HTMLElement>;
130
+ };
131
+
105
132
  /**
106
133
  * The position of the expand icon.
107
134
  */
108
135
  expandIconPosition?: ExpandIconPosition;
136
+
109
137
  /**
110
138
  * Whether to hide the border and transparent background.
111
139
  */
112
140
  ghost?: boolean;
141
+
113
142
  /**
114
143
  * The size of the collapse.
115
144
  */
116
145
  size?: 'small' | 'middle' | 'large';
146
+
117
147
  /**
118
148
  * Collapse-wide collapsible part or disabled.
119
149
  */
120
150
  collapsible?: CollapsibleType;
151
+
121
152
  /**
122
153
  * The panels of the collapse.
123
154
  */
124
- items?: ItemType[];
125
- /**
126
- * The style of the expand icon.
127
- */
128
- iconStyle?: React.CSSProperties;
155
+ items?: CollapseItemType[];
156
+
129
157
  /**
130
158
  * @ignore
131
159
  */
@@ -137,32 +165,34 @@ export type PanelProps = {
137
165
  * Whether the panel is active.
138
166
  */
139
167
  isActive?: boolean;
168
+
140
169
  /**
141
170
  * The header of the panel.
142
171
  */
143
172
  header?: React.ReactNode;
173
+
144
174
  /**
145
175
  * The class name of the panel.
146
176
  */
147
177
  className?: string;
178
+
148
179
  /**
149
180
  * Whether to show the arrow.
150
181
  */
151
182
  showArrow?: boolean;
183
+
152
184
  /**
153
185
  * Forced render of content on panel, instead of lazy rendering after clicking on header.
154
186
  */
155
187
  forceRender?: boolean;
188
+
156
189
  /**
157
190
  * The extra element of the panel header.
158
191
  */
159
192
  extra?: React.ReactNode;
193
+
160
194
  /**
161
195
  * The collapsible part of the panel or disabled.
162
196
  */
163
197
  collapsible?: CollapsibleType;
164
- /**
165
- * The style of the expand icon.
166
- */
167
- iconStyle?: React.CSSProperties;
168
198
  };
@@ -1,5 +1,19 @@
1
1
  import * as React from 'react';
2
2
  import type { CollapseProps } from './types';
3
+ /**
4
+ * Collapse component for Akinon UI.
5
+ *
6
+ * The Collapse component provides a way to organize content in expandable panels.
7
+ * It allows users to toggle the visibility of content sections, supporting both
8
+ * single (accordion) and multiple open panels at a time.
9
+ *
10
+ * The component is fully customizable with options for expand icons, ghost mode,
11
+ * lazy rendering, and border visibility. It adheres to the Akinon design system,
12
+ * ensuring consistent styling and accessibility.
13
+ *
14
+ * Suitable for use cases where space-saving and content organization are priorities,
15
+ * such as FAQs, settings pages, or nested content structures.
16
+ */
3
17
  export declare const Collapse: ({ ...collapseProps }: CollapseProps) => React.JSX.Element;
4
18
  export type * from './types';
5
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,aAAa,EAAc,MAAM,SAAS,CAAC;AAEzD,eAAO,MAAM,QAAQ,yBAA0B,aAAa,sBAmB3D,CAAC;AAEF,mBAAmB,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,aAAa,EAAc,MAAM,SAAS,CAAC;AAEzD;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,QAAQ,yBAA0B,aAAa,sBAqB3D,CAAC;AAEF,mBAAmB,SAAS,CAAC"}
package/dist/esm/index.js CHANGED
@@ -12,10 +12,27 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  import { Icon } from '@akinon/icons';
13
13
  import { Collapse as AntCollapse } from 'antd';
14
14
  import * as React from 'react';
15
+ /**
16
+ * Collapse component for Akinon UI.
17
+ *
18
+ * The Collapse component provides a way to organize content in expandable panels.
19
+ * It allows users to toggle the visibility of content sections, supporting both
20
+ * single (accordion) and multiple open panels at a time.
21
+ *
22
+ * The component is fully customizable with options for expand icons, ghost mode,
23
+ * lazy rendering, and border visibility. It adheres to the Akinon design system,
24
+ * ensuring consistent styling and accessibility.
25
+ *
26
+ * Suitable for use cases where space-saving and content organization are priorities,
27
+ * such as FAQs, settings pages, or nested content structures.
28
+ */
15
29
  export const Collapse = (_a) => {
16
30
  var _b;
17
31
  var collapseProps = __rest(_a, []);
18
32
  return (React.createElement(AntCollapse, Object.assign({ ghost: true, defaultActiveKey: (_b = collapseProps.items) === null || _b === void 0 ? void 0 : _b.map(item => item.key) }, collapseProps, (collapseProps.expandIcon && {
19
- expandIcon: panelProps => collapseProps.expandIcon ? (React.createElement(Icon, { icon: collapseProps.expandIcon(panelProps), style: collapseProps.iconStyle })) : undefined
33
+ expandIcon: panelProps => {
34
+ const { name, style, size } = collapseProps.expandIcon(panelProps);
35
+ return name ? (React.createElement(Icon, { size: size !== null && size !== void 0 ? size : 16, icon: name, style: style })) : undefined;
36
+ }
20
37
  }))));
21
38
  };
@@ -5,60 +5,73 @@ import type React from 'react';
5
5
  export type ExpandIconPosition = 'start' | 'end';
6
6
  export type CollapsibleType = 'header' | 'icon' | 'disabled';
7
7
 
8
- export interface ItemType extends React.DOMAttributes<HTMLDivElement> {
8
+ export interface CollapseItemType extends React.DOMAttributes<HTMLDivElement> {
9
9
  /**
10
10
  * The key of the panel.
11
11
  */
12
12
  key?: React.Key;
13
+
13
14
  /**
14
15
  * The label of the panel.
15
16
  */
16
17
  label?: React.ReactNode;
18
+
17
19
  /**
18
20
  * The React ref object of the panel.
19
21
  */
20
22
  ref?: React.RefObject<HTMLDivElement>;
23
+
21
24
  /**
22
25
  * The id of the panel.
23
26
  */
24
27
  id?: string;
28
+
25
29
  /**
26
30
  * The class name of the panel header.
27
31
  */
28
32
  headerClass?: string;
33
+
29
34
  /**
30
35
  * Whether to show the arrow.
31
36
  */
32
37
  showArrow?: boolean;
38
+
33
39
  /**
34
40
  * The class name of the panel.
35
41
  */
36
42
  className?: string;
43
+
37
44
  /**
38
45
  * Whether to destroy the inactive panel.
39
46
  */
40
47
  destroyInactivePanel?: boolean;
48
+
41
49
  /**
42
50
  * Forced render of content on panel, instead of lazy rendering after clicking on header.
43
51
  */
44
52
  forceRender?: boolean;
53
+
45
54
  /**
46
55
  * The extra element of the panel header.
47
56
  */
48
57
  extra?: React.ReactNode;
58
+
49
59
  /**
50
60
  * The callback function that is triggered when the panel is clicked.
51
61
  */
52
62
  onItemClick?: (panelKey: React.Key) => void;
63
+
53
64
  /**
54
65
  * Custom expand icon.
55
66
  */
56
67
  expandIcon?: (panelProps: PanelProps) => IconName;
68
+
57
69
  /**
58
70
  * The HTML WAI-ARIA role of the panel.
59
71
  * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles
60
72
  */
61
73
  role?: string;
74
+
62
75
  /**
63
76
  * The children of the panel.
64
77
  */
@@ -70,62 +83,77 @@ export type CollapseProps = {
70
83
  * The key of the active panel.
71
84
  */
72
85
  activeKey?: React.Key | React.Key[];
86
+
73
87
  /**
74
88
  * The default key of the active panel.
75
89
  */
76
90
  defaultActiveKey?: React.Key | React.Key[];
91
+
77
92
  /**
78
93
  * The callback function that is triggered when the active panel changes.
79
94
  */
80
95
  onChange?: (key: React.Key | React.Key[]) => void;
96
+
81
97
  /**
82
98
  * Whether to enable accordion mode.
83
99
  */
84
100
  accordion?: boolean;
101
+
85
102
  /**
86
103
  * The class name of the collapse.
87
104
  */
88
105
  className?: string;
106
+
89
107
  /**
90
108
  * The class name of the root element.
91
109
  */
92
110
  rootClassName?: string;
111
+
93
112
  /**
94
113
  * Whether to show border.
95
114
  */
96
115
  bordered?: boolean;
116
+
97
117
  /**
98
118
  * Whether to destroy the inactive panel.
99
119
  */
100
120
  destroyInactivePanel?: boolean;
121
+
101
122
  /**
102
123
  * The expand icon.
103
124
  */
104
- expandIcon?: (panelProps: PanelProps) => IconName;
125
+ expandIcon?: (panelProps: PanelProps) => {
126
+ name: IconName;
127
+ size?: number;
128
+ style?: React.CSSProperties;
129
+ ariaProps?: React.HTMLAttributes<HTMLElement>;
130
+ };
131
+
105
132
  /**
106
133
  * The position of the expand icon.
107
134
  */
108
135
  expandIconPosition?: ExpandIconPosition;
136
+
109
137
  /**
110
138
  * Whether to hide the border and transparent background.
111
139
  */
112
140
  ghost?: boolean;
141
+
113
142
  /**
114
143
  * The size of the collapse.
115
144
  */
116
145
  size?: 'small' | 'middle' | 'large';
146
+
117
147
  /**
118
148
  * Collapse-wide collapsible part or disabled.
119
149
  */
120
150
  collapsible?: CollapsibleType;
151
+
121
152
  /**
122
153
  * The panels of the collapse.
123
154
  */
124
- items?: ItemType[];
125
- /**
126
- * The style of the expand icon.
127
- */
128
- iconStyle?: React.CSSProperties;
155
+ items?: CollapseItemType[];
156
+
129
157
  /**
130
158
  * @ignore
131
159
  */
@@ -137,32 +165,34 @@ export type PanelProps = {
137
165
  * Whether the panel is active.
138
166
  */
139
167
  isActive?: boolean;
168
+
140
169
  /**
141
170
  * The header of the panel.
142
171
  */
143
172
  header?: React.ReactNode;
173
+
144
174
  /**
145
175
  * The class name of the panel.
146
176
  */
147
177
  className?: string;
178
+
148
179
  /**
149
180
  * Whether to show the arrow.
150
181
  */
151
182
  showArrow?: boolean;
183
+
152
184
  /**
153
185
  * Forced render of content on panel, instead of lazy rendering after clicking on header.
154
186
  */
155
187
  forceRender?: boolean;
188
+
156
189
  /**
157
190
  * The extra element of the panel header.
158
191
  */
159
192
  extra?: React.ReactNode;
193
+
160
194
  /**
161
195
  * The collapsible part of the panel or disabled.
162
196
  */
163
197
  collapsible?: CollapsibleType;
164
- /**
165
- * The style of the expand icon.
166
- */
167
- iconStyle?: React.CSSProperties;
168
198
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/ui-collapse",
3
- "version": "0.5.0",
3
+ "version": "1.0.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/esm/index.js",
@@ -9,17 +9,17 @@
9
9
  "dist"
10
10
  ],
11
11
  "dependencies": {
12
- "antd": "5.17.0",
13
- "@akinon/icons": "^0.6.0"
12
+ "antd": "5.22.6",
13
+ "@akinon/icons": "^1.0.1"
14
14
  },
15
15
  "devDependencies": {
16
16
  "clean-package": "2.2.0",
17
17
  "copyfiles": "^2.4.1",
18
18
  "rimraf": "^5.0.5",
19
- "typescript": "^5.2.2",
20
- "@akinon/icons": "0.6.0",
21
- "@akinon/typescript-config": "0.4.0",
22
- "@akinon/ui-theme": "0.7.0"
19
+ "typescript": "*",
20
+ "@akinon/ui-theme": "1.0.1",
21
+ "@akinon/typescript-config": "1.0.1",
22
+ "@akinon/icons": "1.0.1"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "react": ">=18",