@akinon/ui-collapse 0.4.0 → 1.0.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,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;
@@ -0,0 +1,202 @@
1
+ import { IconName } from '@akinon/icons';
2
+ import type { DO_NOT_USE_OR_YOU_WILL_BE_FIRED_INTERNAL_STYLE } from '@akinon/ui-theme';
3
+ import type React from 'react';
4
+
5
+ export type ExpandIconPosition = 'start' | 'end';
6
+ export type CollapsibleType = 'header' | 'icon' | 'disabled';
7
+
8
+ export interface CollapseItemType extends React.DOMAttributes<HTMLDivElement> {
9
+ /**
10
+ * The key of the panel.
11
+ */
12
+ key?: React.Key;
13
+
14
+ /**
15
+ * The label of the panel.
16
+ */
17
+ label?: React.ReactNode;
18
+
19
+ /**
20
+ * The React ref object of the panel.
21
+ */
22
+ ref?: React.RefObject<HTMLDivElement>;
23
+
24
+ /**
25
+ * The id of the panel.
26
+ */
27
+ id?: string;
28
+
29
+ /**
30
+ * The class name of the panel header.
31
+ */
32
+ headerClass?: string;
33
+
34
+ /**
35
+ * Whether to show the arrow.
36
+ */
37
+ showArrow?: boolean;
38
+
39
+ /**
40
+ * The class name of the panel.
41
+ */
42
+ className?: string;
43
+
44
+ /**
45
+ * Whether to destroy the inactive panel.
46
+ */
47
+ destroyInactivePanel?: boolean;
48
+
49
+ /**
50
+ * Forced render of content on panel, instead of lazy rendering after clicking on header.
51
+ */
52
+ forceRender?: boolean;
53
+
54
+ /**
55
+ * The extra element of the panel header.
56
+ */
57
+ extra?: React.ReactNode;
58
+
59
+ /**
60
+ * The callback function that is triggered when the panel is clicked.
61
+ */
62
+ onItemClick?: (panelKey: React.Key) => void;
63
+
64
+ /**
65
+ * Custom expand icon.
66
+ */
67
+ expandIcon?: (panelProps: PanelProps) => IconName;
68
+
69
+ /**
70
+ * The HTML WAI-ARIA role of the panel.
71
+ * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles
72
+ */
73
+ role?: string;
74
+
75
+ /**
76
+ * The children of the panel.
77
+ */
78
+ children?: React.ReactNode;
79
+ }
80
+
81
+ export type CollapseProps = {
82
+ /**
83
+ * The key of the active panel.
84
+ */
85
+ activeKey?: React.Key | React.Key[];
86
+
87
+ /**
88
+ * The default key of the active panel.
89
+ */
90
+ defaultActiveKey?: React.Key | React.Key[];
91
+
92
+ /**
93
+ * The callback function that is triggered when the active panel changes.
94
+ */
95
+ onChange?: (key: React.Key | React.Key[]) => void;
96
+
97
+ /**
98
+ * Whether to enable accordion mode.
99
+ */
100
+ accordion?: boolean;
101
+
102
+ /**
103
+ * The class name of the collapse.
104
+ */
105
+ className?: string;
106
+
107
+ /**
108
+ * The class name of the root element.
109
+ */
110
+ rootClassName?: string;
111
+
112
+ /**
113
+ * Whether to show border.
114
+ */
115
+ bordered?: boolean;
116
+
117
+ /**
118
+ * Whether to destroy the inactive panel.
119
+ */
120
+ destroyInactivePanel?: boolean;
121
+
122
+ /**
123
+ * The expand icon.
124
+ */
125
+ expandIcon?: (panelProps: PanelProps) => {
126
+ name: IconName;
127
+ size?: number;
128
+ style?: React.CSSProperties;
129
+ };
130
+
131
+ /**
132
+ * The position of the expand icon.
133
+ */
134
+ expandIconPosition?: ExpandIconPosition;
135
+
136
+ /**
137
+ * Whether to hide the border and transparent background.
138
+ */
139
+ ghost?: boolean;
140
+
141
+ /**
142
+ * The size of the collapse.
143
+ */
144
+ size?: 'small' | 'middle' | 'large';
145
+
146
+ /**
147
+ * Collapse-wide collapsible part or disabled.
148
+ */
149
+ collapsible?: CollapsibleType;
150
+
151
+ /**
152
+ * The panels of the collapse.
153
+ */
154
+ items?: CollapseItemType[];
155
+
156
+ /**
157
+ * The style of the expand icon.
158
+ */
159
+ iconStyle?: React.CSSProperties;
160
+
161
+ /**
162
+ * @ignore
163
+ */
164
+ style?: DO_NOT_USE_OR_YOU_WILL_BE_FIRED_INTERNAL_STYLE;
165
+ };
166
+
167
+ export type PanelProps = {
168
+ /**
169
+ * Whether the panel is active.
170
+ */
171
+ isActive?: boolean;
172
+
173
+ /**
174
+ * The header of the panel.
175
+ */
176
+ header?: React.ReactNode;
177
+
178
+ /**
179
+ * The class name of the panel.
180
+ */
181
+ className?: string;
182
+
183
+ /**
184
+ * Whether to show the arrow.
185
+ */
186
+ showArrow?: boolean;
187
+
188
+ /**
189
+ * Forced render of content on panel, instead of lazy rendering after clicking on header.
190
+ */
191
+ forceRender?: boolean;
192
+
193
+ /**
194
+ * The extra element of the panel header.
195
+ */
196
+ extra?: React.ReactNode;
197
+
198
+ /**
199
+ * The collapsible part of the panel or disabled.
200
+ */
201
+ collapsible?: CollapsibleType;
202
+ };
@@ -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
  };
@@ -0,0 +1,202 @@
1
+ import { IconName } from '@akinon/icons';
2
+ import type { DO_NOT_USE_OR_YOU_WILL_BE_FIRED_INTERNAL_STYLE } from '@akinon/ui-theme';
3
+ import type React from 'react';
4
+
5
+ export type ExpandIconPosition = 'start' | 'end';
6
+ export type CollapsibleType = 'header' | 'icon' | 'disabled';
7
+
8
+ export interface CollapseItemType extends React.DOMAttributes<HTMLDivElement> {
9
+ /**
10
+ * The key of the panel.
11
+ */
12
+ key?: React.Key;
13
+
14
+ /**
15
+ * The label of the panel.
16
+ */
17
+ label?: React.ReactNode;
18
+
19
+ /**
20
+ * The React ref object of the panel.
21
+ */
22
+ ref?: React.RefObject<HTMLDivElement>;
23
+
24
+ /**
25
+ * The id of the panel.
26
+ */
27
+ id?: string;
28
+
29
+ /**
30
+ * The class name of the panel header.
31
+ */
32
+ headerClass?: string;
33
+
34
+ /**
35
+ * Whether to show the arrow.
36
+ */
37
+ showArrow?: boolean;
38
+
39
+ /**
40
+ * The class name of the panel.
41
+ */
42
+ className?: string;
43
+
44
+ /**
45
+ * Whether to destroy the inactive panel.
46
+ */
47
+ destroyInactivePanel?: boolean;
48
+
49
+ /**
50
+ * Forced render of content on panel, instead of lazy rendering after clicking on header.
51
+ */
52
+ forceRender?: boolean;
53
+
54
+ /**
55
+ * The extra element of the panel header.
56
+ */
57
+ extra?: React.ReactNode;
58
+
59
+ /**
60
+ * The callback function that is triggered when the panel is clicked.
61
+ */
62
+ onItemClick?: (panelKey: React.Key) => void;
63
+
64
+ /**
65
+ * Custom expand icon.
66
+ */
67
+ expandIcon?: (panelProps: PanelProps) => IconName;
68
+
69
+ /**
70
+ * The HTML WAI-ARIA role of the panel.
71
+ * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles
72
+ */
73
+ role?: string;
74
+
75
+ /**
76
+ * The children of the panel.
77
+ */
78
+ children?: React.ReactNode;
79
+ }
80
+
81
+ export type CollapseProps = {
82
+ /**
83
+ * The key of the active panel.
84
+ */
85
+ activeKey?: React.Key | React.Key[];
86
+
87
+ /**
88
+ * The default key of the active panel.
89
+ */
90
+ defaultActiveKey?: React.Key | React.Key[];
91
+
92
+ /**
93
+ * The callback function that is triggered when the active panel changes.
94
+ */
95
+ onChange?: (key: React.Key | React.Key[]) => void;
96
+
97
+ /**
98
+ * Whether to enable accordion mode.
99
+ */
100
+ accordion?: boolean;
101
+
102
+ /**
103
+ * The class name of the collapse.
104
+ */
105
+ className?: string;
106
+
107
+ /**
108
+ * The class name of the root element.
109
+ */
110
+ rootClassName?: string;
111
+
112
+ /**
113
+ * Whether to show border.
114
+ */
115
+ bordered?: boolean;
116
+
117
+ /**
118
+ * Whether to destroy the inactive panel.
119
+ */
120
+ destroyInactivePanel?: boolean;
121
+
122
+ /**
123
+ * The expand icon.
124
+ */
125
+ expandIcon?: (panelProps: PanelProps) => {
126
+ name: IconName;
127
+ size?: number;
128
+ style?: React.CSSProperties;
129
+ };
130
+
131
+ /**
132
+ * The position of the expand icon.
133
+ */
134
+ expandIconPosition?: ExpandIconPosition;
135
+
136
+ /**
137
+ * Whether to hide the border and transparent background.
138
+ */
139
+ ghost?: boolean;
140
+
141
+ /**
142
+ * The size of the collapse.
143
+ */
144
+ size?: 'small' | 'middle' | 'large';
145
+
146
+ /**
147
+ * Collapse-wide collapsible part or disabled.
148
+ */
149
+ collapsible?: CollapsibleType;
150
+
151
+ /**
152
+ * The panels of the collapse.
153
+ */
154
+ items?: CollapseItemType[];
155
+
156
+ /**
157
+ * The style of the expand icon.
158
+ */
159
+ iconStyle?: React.CSSProperties;
160
+
161
+ /**
162
+ * @ignore
163
+ */
164
+ style?: DO_NOT_USE_OR_YOU_WILL_BE_FIRED_INTERNAL_STYLE;
165
+ };
166
+
167
+ export type PanelProps = {
168
+ /**
169
+ * Whether the panel is active.
170
+ */
171
+ isActive?: boolean;
172
+
173
+ /**
174
+ * The header of the panel.
175
+ */
176
+ header?: React.ReactNode;
177
+
178
+ /**
179
+ * The class name of the panel.
180
+ */
181
+ className?: string;
182
+
183
+ /**
184
+ * Whether to show the arrow.
185
+ */
186
+ showArrow?: boolean;
187
+
188
+ /**
189
+ * Forced render of content on panel, instead of lazy rendering after clicking on header.
190
+ */
191
+ forceRender?: boolean;
192
+
193
+ /**
194
+ * The extra element of the panel header.
195
+ */
196
+ extra?: React.ReactNode;
197
+
198
+ /**
199
+ * The collapsible part of the panel or disabled.
200
+ */
201
+ collapsible?: CollapsibleType;
202
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/ui-collapse",
3
- "version": "0.4.0",
3
+ "version": "1.0.0",
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.5.0"
12
+ "antd": "5.22.6",
13
+ "@akinon/icons": "^1.0.0"
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/ui-theme": "0.6.0",
21
- "@akinon/icons": "0.5.0",
22
- "@akinon/typescript-config": "0.3.0"
19
+ "typescript": "*",
20
+ "@akinon/icons": "1.0.0",
21
+ "@akinon/ui-theme": "1.0.0",
22
+ "@akinon/typescript-config": "1.0.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/**/*.css dist/esm && copyfiles -u 1 src/**/*.css dist/cjs",
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
  }