@akinon/ui-breadcrumb 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,14 @@
1
1
  import * as React from 'react';
2
2
  import type { BreadcrumbProps } from './types';
3
- export type { BreadcrumbProps } from './types';
3
+ /**
4
+ * Breadcrumb component is used to display a breadcrumb navigation trail, which helps users understand the hierarchy and navigate through the structure of the application.
5
+ * It provides support for custom breadcrumb items, separators, routing parameters, and event handlers for item clicks.
6
+ *
7
+ * - The `onAnyItemClick` event allows custom handling when any breadcrumb item is clicked.
8
+ * - Custom renderers and item definitions can be provided through the `itemRender` and `items` props.
9
+ * - Supports hierarchical navigation with `path` and `href` options for breadcrumb items.
10
+ *
11
+ */
4
12
  export declare const Breadcrumb: (props: BreadcrumbProps) => React.JSX.Element;
13
+ export type * from './types';
5
14
  //# 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,eAAe,EAAY,MAAM,SAAS,CAAC;AAEzD,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,eAAO,MAAM,UAAU,UAAW,eAAe,sBAgGhD,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,EAAsB,eAAe,EAAE,MAAM,SAAS,CAAC;AAEnE;;;;;;;;GAQG;AAEH,eAAO,MAAM,UAAU,UAAW,eAAe,sBAgGhD,CAAC;AAEF,mBAAmB,SAAS,CAAC"}
package/dist/cjs/index.js CHANGED
@@ -5,6 +5,15 @@ const ui_theme_1 = require("@akinon/ui-theme");
5
5
  const cssinjs_1 = require("@ant-design/cssinjs");
6
6
  const antd_1 = require("antd");
7
7
  const React = require("react");
8
+ /**
9
+ * Breadcrumb component is used to display a breadcrumb navigation trail, which helps users understand the hierarchy and navigate through the structure of the application.
10
+ * It provides support for custom breadcrumb items, separators, routing parameters, and event handlers for item clicks.
11
+ *
12
+ * - The `onAnyItemClick` event allows custom handling when any breadcrumb item is clicked.
13
+ * - Custom renderers and item definitions can be provided through the `itemRender` and `items` props.
14
+ * - Supports hierarchical navigation with `path` and `href` options for breadcrumb items.
15
+ *
16
+ */
8
17
  const Breadcrumb = (props) => {
9
18
  const { onAnyItemClick, items } = props;
10
19
  const { getPrefixCls, theme } = React.useContext(antd_1.ConfigProvider.ConfigContext);
@@ -0,0 +1,206 @@
1
+ import { DO_NOT_USE_OR_YOU_WILL_BE_FIRED_INTERNAL_STYLE } from '@akinon/ui-theme';
2
+
3
+ /**
4
+ * Defines properties for separators used in breadcrumb navigation.
5
+ */
6
+ export interface SeparatorType {
7
+ /**
8
+ * Custom separator element for breadcrumb items.
9
+ */
10
+ separator?: React.ReactNode;
11
+
12
+ /**
13
+ * Unique key for the separator.
14
+ */
15
+ key?: React.Key;
16
+ }
17
+
18
+ /**
19
+ * Represents individual menu items in a breadcrumb.
20
+ */
21
+ interface MenuItem {
22
+ /**
23
+ * Unique key for the menu item.
24
+ */
25
+ key?: React.Key;
26
+
27
+ /**
28
+ * Title of the menu item.
29
+ */
30
+ title?: React.ReactNode;
31
+
32
+ /**
33
+ * Label for the menu item.
34
+ */
35
+ label?: React.ReactNode;
36
+
37
+ /**
38
+ * Path associated with the menu item.
39
+ */
40
+ path?: string;
41
+
42
+ /**
43
+ * URL to navigate when the menu item is clicked.
44
+ */
45
+ href?: string;
46
+ }
47
+
48
+ /**
49
+ * Properties for individual breadcrumb items.
50
+ */
51
+ export interface BreadcrumbItemProps extends SeparatorType {
52
+ /**
53
+ * URL for the breadcrumb item.
54
+ */
55
+ href?: string;
56
+
57
+ /**
58
+ * Callback triggered when the breadcrumb item is clicked.
59
+ */
60
+ onClick?: React.MouseEventHandler<HTMLAnchorElement | HTMLSpanElement>;
61
+
62
+ /**
63
+ * Additional CSS class for the breadcrumb item.
64
+ */
65
+ className?: string;
66
+
67
+ /**
68
+ * Children elements inside the breadcrumb item.
69
+ */
70
+ children?: React.ReactNode;
71
+ }
72
+
73
+ /**
74
+ * Defines the structure of an individual breadcrumb item.
75
+ */
76
+ export interface BreadcrumbItemType {
77
+ /**
78
+ * Unique key for the breadcrumb item.
79
+ */
80
+ key?: React.Key;
81
+
82
+ /**
83
+ * Different with `path`. Directly set the link of this item.
84
+ */
85
+ href?: string;
86
+
87
+ /**
88
+ * Different with `href`. It will concat all prev `path` to the current one.
89
+ */
90
+ path?: string;
91
+
92
+ /**
93
+ * Title or label of the breadcrumb item.
94
+ */
95
+ title?: React.ReactNode;
96
+
97
+ /**
98
+ * Name displayed in the breadcrumb.
99
+ */
100
+ breadcrumbName?: string;
101
+
102
+ /**
103
+ * Additional CSS class for the breadcrumb item.
104
+ */
105
+ className?: string;
106
+
107
+ /**
108
+ * Callback triggered when the breadcrumb item is clicked.
109
+ */
110
+ onClick?: React.MouseEventHandler<HTMLAnchorElement | HTMLSpanElement>;
111
+ }
112
+
113
+ /**
114
+ * Defines the structure of a separator in the breadcrumb.
115
+ */
116
+ export interface BreadcrumbSeparatorType {
117
+ /**
118
+ * Specifies that the item is a separator.
119
+ */
120
+ type: 'separator';
121
+
122
+ /**
123
+ * Custom separator element.
124
+ */
125
+ separator?: React.ReactNode;
126
+ }
127
+
128
+ /**
129
+ * Represents an individual item or separator in the breadcrumb.
130
+ */
131
+ export type BreadcrumbItemType = Partial<
132
+ BreadcrumbItemType & BreadcrumbSeparatorType
133
+ >;
134
+
135
+ /**
136
+ * Defines the internal structure of routing information in the breadcrumb.
137
+ */
138
+ export type InternalRouteType = Partial<
139
+ BreadcrumbItemType & BreadcrumbSeparatorType
140
+ >;
141
+
142
+ /**
143
+ * Properties for the main `Breadcrumb` component.
144
+ */
145
+ export interface BreadcrumbProps {
146
+ /**
147
+ * Routing parameters. <code>object</code><br /><br />
148
+ */
149
+ params?: {
150
+ [key: string]: unknown;
151
+ };
152
+
153
+ /**
154
+ * Custom separator element for the breadcrumb.
155
+ */
156
+ separator?: React.ReactNode;
157
+
158
+ /**
159
+ * Inline styles for the breadcrumb.
160
+ * @ignore
161
+ */
162
+ style?: DO_NOT_USE_OR_YOU_WILL_BE_FIRED_INTERNAL_STYLE;
163
+
164
+ /**
165
+ * The additional css class
166
+ */
167
+ className?: string;
168
+
169
+ /**
170
+ * ClassName on the root element
171
+ */
172
+ rootClassName?: string;
173
+
174
+ /**
175
+ * Children elements inside the breadcrumb.
176
+ */
177
+ children?: React.ReactNode;
178
+
179
+ /**
180
+ * The routing stack information of router
181
+ */
182
+ items?: BreadcrumbItemType[];
183
+
184
+ /**
185
+ * Custom item renderer. <code>(route, params, routes, paths) => ReactNode</code><br /><br />
186
+ *
187
+ * @param route - The current breadcrumb item.
188
+ * @param params - Routing parameters.
189
+ * @param routes - All breadcrumb items.
190
+ * @param paths - The accumulated paths.
191
+ * @returns - Custom rendered breadcrumb item.
192
+ */
193
+ itemRender?: (
194
+ route: BreadcrumbItemType,
195
+ params: {
196
+ [key: string]: unknown;
197
+ },
198
+ routes: BreadcrumbItemType[],
199
+ paths: string[]
200
+ ) => React.ReactNode;
201
+
202
+ /**
203
+ * This is a custom event that is triggered when any breadcrumb item is clicked. It takes href of the clicked item as parameter.
204
+ */
205
+ onAnyItemClick?: ({ href }: { href: string }) => void;
206
+ }
@@ -1,5 +1,14 @@
1
1
  import * as React from 'react';
2
2
  import type { BreadcrumbProps } from './types';
3
- export type { BreadcrumbProps } from './types';
3
+ /**
4
+ * Breadcrumb component is used to display a breadcrumb navigation trail, which helps users understand the hierarchy and navigate through the structure of the application.
5
+ * It provides support for custom breadcrumb items, separators, routing parameters, and event handlers for item clicks.
6
+ *
7
+ * - The `onAnyItemClick` event allows custom handling when any breadcrumb item is clicked.
8
+ * - Custom renderers and item definitions can be provided through the `itemRender` and `items` props.
9
+ * - Supports hierarchical navigation with `path` and `href` options for breadcrumb items.
10
+ *
11
+ */
4
12
  export declare const Breadcrumb: (props: BreadcrumbProps) => React.JSX.Element;
13
+ export type * from './types';
5
14
  //# 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,eAAe,EAAY,MAAM,SAAS,CAAC;AAEzD,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,eAAO,MAAM,UAAU,UAAW,eAAe,sBAgGhD,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,EAAsB,eAAe,EAAE,MAAM,SAAS,CAAC;AAEnE;;;;;;;;GAQG;AAEH,eAAO,MAAM,UAAU,UAAW,eAAe,sBAgGhD,CAAC;AAEF,mBAAmB,SAAS,CAAC"}
package/dist/esm/index.js CHANGED
@@ -2,6 +2,15 @@ import { useToken } from '@akinon/ui-theme';
2
2
  import { useStyleRegister } from '@ant-design/cssinjs';
3
3
  import { Breadcrumb as AntBreadcrumb, ConfigProvider } from 'antd';
4
4
  import * as React from 'react';
5
+ /**
6
+ * Breadcrumb component is used to display a breadcrumb navigation trail, which helps users understand the hierarchy and navigate through the structure of the application.
7
+ * It provides support for custom breadcrumb items, separators, routing parameters, and event handlers for item clicks.
8
+ *
9
+ * - The `onAnyItemClick` event allows custom handling when any breadcrumb item is clicked.
10
+ * - Custom renderers and item definitions can be provided through the `itemRender` and `items` props.
11
+ * - Supports hierarchical navigation with `path` and `href` options for breadcrumb items.
12
+ *
13
+ */
5
14
  export const Breadcrumb = (props) => {
6
15
  const { onAnyItemClick, items } = props;
7
16
  const { getPrefixCls, theme } = React.useContext(ConfigProvider.ConfigContext);
@@ -0,0 +1,206 @@
1
+ import { DO_NOT_USE_OR_YOU_WILL_BE_FIRED_INTERNAL_STYLE } from '@akinon/ui-theme';
2
+
3
+ /**
4
+ * Defines properties for separators used in breadcrumb navigation.
5
+ */
6
+ export interface SeparatorType {
7
+ /**
8
+ * Custom separator element for breadcrumb items.
9
+ */
10
+ separator?: React.ReactNode;
11
+
12
+ /**
13
+ * Unique key for the separator.
14
+ */
15
+ key?: React.Key;
16
+ }
17
+
18
+ /**
19
+ * Represents individual menu items in a breadcrumb.
20
+ */
21
+ interface MenuItem {
22
+ /**
23
+ * Unique key for the menu item.
24
+ */
25
+ key?: React.Key;
26
+
27
+ /**
28
+ * Title of the menu item.
29
+ */
30
+ title?: React.ReactNode;
31
+
32
+ /**
33
+ * Label for the menu item.
34
+ */
35
+ label?: React.ReactNode;
36
+
37
+ /**
38
+ * Path associated with the menu item.
39
+ */
40
+ path?: string;
41
+
42
+ /**
43
+ * URL to navigate when the menu item is clicked.
44
+ */
45
+ href?: string;
46
+ }
47
+
48
+ /**
49
+ * Properties for individual breadcrumb items.
50
+ */
51
+ export interface BreadcrumbItemProps extends SeparatorType {
52
+ /**
53
+ * URL for the breadcrumb item.
54
+ */
55
+ href?: string;
56
+
57
+ /**
58
+ * Callback triggered when the breadcrumb item is clicked.
59
+ */
60
+ onClick?: React.MouseEventHandler<HTMLAnchorElement | HTMLSpanElement>;
61
+
62
+ /**
63
+ * Additional CSS class for the breadcrumb item.
64
+ */
65
+ className?: string;
66
+
67
+ /**
68
+ * Children elements inside the breadcrumb item.
69
+ */
70
+ children?: React.ReactNode;
71
+ }
72
+
73
+ /**
74
+ * Defines the structure of an individual breadcrumb item.
75
+ */
76
+ export interface BreadcrumbItemType {
77
+ /**
78
+ * Unique key for the breadcrumb item.
79
+ */
80
+ key?: React.Key;
81
+
82
+ /**
83
+ * Different with `path`. Directly set the link of this item.
84
+ */
85
+ href?: string;
86
+
87
+ /**
88
+ * Different with `href`. It will concat all prev `path` to the current one.
89
+ */
90
+ path?: string;
91
+
92
+ /**
93
+ * Title or label of the breadcrumb item.
94
+ */
95
+ title?: React.ReactNode;
96
+
97
+ /**
98
+ * Name displayed in the breadcrumb.
99
+ */
100
+ breadcrumbName?: string;
101
+
102
+ /**
103
+ * Additional CSS class for the breadcrumb item.
104
+ */
105
+ className?: string;
106
+
107
+ /**
108
+ * Callback triggered when the breadcrumb item is clicked.
109
+ */
110
+ onClick?: React.MouseEventHandler<HTMLAnchorElement | HTMLSpanElement>;
111
+ }
112
+
113
+ /**
114
+ * Defines the structure of a separator in the breadcrumb.
115
+ */
116
+ export interface BreadcrumbSeparatorType {
117
+ /**
118
+ * Specifies that the item is a separator.
119
+ */
120
+ type: 'separator';
121
+
122
+ /**
123
+ * Custom separator element.
124
+ */
125
+ separator?: React.ReactNode;
126
+ }
127
+
128
+ /**
129
+ * Represents an individual item or separator in the breadcrumb.
130
+ */
131
+ export type BreadcrumbItemType = Partial<
132
+ BreadcrumbItemType & BreadcrumbSeparatorType
133
+ >;
134
+
135
+ /**
136
+ * Defines the internal structure of routing information in the breadcrumb.
137
+ */
138
+ export type InternalRouteType = Partial<
139
+ BreadcrumbItemType & BreadcrumbSeparatorType
140
+ >;
141
+
142
+ /**
143
+ * Properties for the main `Breadcrumb` component.
144
+ */
145
+ export interface BreadcrumbProps {
146
+ /**
147
+ * Routing parameters. <code>object</code><br /><br />
148
+ */
149
+ params?: {
150
+ [key: string]: unknown;
151
+ };
152
+
153
+ /**
154
+ * Custom separator element for the breadcrumb.
155
+ */
156
+ separator?: React.ReactNode;
157
+
158
+ /**
159
+ * Inline styles for the breadcrumb.
160
+ * @ignore
161
+ */
162
+ style?: DO_NOT_USE_OR_YOU_WILL_BE_FIRED_INTERNAL_STYLE;
163
+
164
+ /**
165
+ * The additional css class
166
+ */
167
+ className?: string;
168
+
169
+ /**
170
+ * ClassName on the root element
171
+ */
172
+ rootClassName?: string;
173
+
174
+ /**
175
+ * Children elements inside the breadcrumb.
176
+ */
177
+ children?: React.ReactNode;
178
+
179
+ /**
180
+ * The routing stack information of router
181
+ */
182
+ items?: BreadcrumbItemType[];
183
+
184
+ /**
185
+ * Custom item renderer. <code>(route, params, routes, paths) => ReactNode</code><br /><br />
186
+ *
187
+ * @param route - The current breadcrumb item.
188
+ * @param params - Routing parameters.
189
+ * @param routes - All breadcrumb items.
190
+ * @param paths - The accumulated paths.
191
+ * @returns - Custom rendered breadcrumb item.
192
+ */
193
+ itemRender?: (
194
+ route: BreadcrumbItemType,
195
+ params: {
196
+ [key: string]: unknown;
197
+ },
198
+ routes: BreadcrumbItemType[],
199
+ paths: string[]
200
+ ) => React.ReactNode;
201
+
202
+ /**
203
+ * This is a custom event that is triggered when any breadcrumb item is clicked. It takes href of the clicked item as parameter.
204
+ */
205
+ onAnyItemClick?: ({ href }: { href: string }) => void;
206
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/ui-breadcrumb",
3
- "version": "0.4.0",
3
+ "version": "1.0.0",
4
4
  "private": false,
5
5
  "description": "A basic button react component.",
6
6
  "type": "module",
@@ -10,15 +10,15 @@
10
10
  "dist"
11
11
  ],
12
12
  "dependencies": {
13
- "antd": "5.17.0",
14
- "@akinon/ui-theme": "0.6.0"
13
+ "antd": "5.22.6",
14
+ "@akinon/ui-theme": "1.0.0"
15
15
  },
16
16
  "devDependencies": {
17
17
  "clean-package": "2.2.0",
18
18
  "copyfiles": "^2.4.1",
19
19
  "rimraf": "^5.0.5",
20
- "typescript": "^5.2.2",
21
- "@akinon/typescript-config": "0.3.0"
20
+ "typescript": "*",
21
+ "@akinon/typescript-config": "1.0.0"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "react": ">=18",
@@ -38,7 +38,7 @@
38
38
  "build": "pnpm run build:esm && pnpm run build:commonjs && pnpm run copy:files",
39
39
  "build:esm": "tsc --outDir dist/esm",
40
40
  "build:commonjs": "tsc --module commonjs --outDir dist/cjs",
41
- "copy:files": "copyfiles -u 1 src/**/*.css dist/esm && copyfiles -u 1 src/**/*.css dist/cjs",
41
+ "copy:files": "copyfiles -u 1 \"src/**/*.!(ts|tsx)\" dist/esm && copyfiles -u 1 \"src/**/*.!(ts|tsx)\" dist/cjs",
42
42
  "clean": "rimraf dist/",
43
43
  "typecheck": "tsc --noEmit"
44
44
  }