uikit-react-public 0.43.1 → 0.43.2

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,20 +1,39 @@
1
- import React, { HTMLAttributes } from 'react';
1
+ import React, { HTMLAttributes, NamedExoticComponent, memo } from 'react';
2
2
  import { css, cx } from '@emotion/css';
3
- import { Icon } from '../';
3
+ import { themes, useTheme } from '../../theme';
4
+ import Icon from '../Icon';
5
+ import BreadcrumbsNew, {
6
+ BaseBreadcrumbsItemProps,
7
+ BreadcrumbsCurrentProps,
8
+ BreadcrumbsLinkProps,
9
+ BreadcrumbsProps as BreadcrumbsNewProps,
10
+ BreadcrumbsSize,
11
+ } from '../BreadcrumbsNew';
4
12
  import Breadcrumb from './Breadcrumb';
13
+ import { BreadcrumbProps } from './Breadcrumb';
5
14
 
6
15
  const NAME = 'ucl-uikit-breadcrumbs';
7
16
 
8
- export interface BreadcrumbsProps extends HTMLAttributes<HTMLElement> {
17
+ export interface LegacyBreadcrumbsProps extends HTMLAttributes<HTMLElement> {
9
18
  testId?: string;
10
19
  }
11
20
 
12
- const Breadcrumbs = ({
21
+ export type BreadcrumbsProps = Omit<BreadcrumbsNewProps, 'children'> &
22
+ LegacyBreadcrumbsProps;
23
+
24
+ export type {
25
+ BaseBreadcrumbsItemProps,
26
+ BreadcrumbsCurrentProps,
27
+ BreadcrumbsLinkProps,
28
+ BreadcrumbsSize,
29
+ };
30
+
31
+ const LegacyBreadcrumbsRoot = ({
13
32
  testId = NAME,
14
33
  className,
15
34
  children,
16
35
  ...props
17
- }: BreadcrumbsProps) => {
36
+ }: LegacyBreadcrumbsProps) => {
18
37
  const separatorStyle = css`
19
38
  display: inline-flex;
20
39
  align-items: center;
@@ -55,6 +74,146 @@ const Breadcrumbs = ({
55
74
  );
56
75
  };
57
76
 
58
- Breadcrumbs.Breadcrumb = Breadcrumb;
77
+ export interface LegacyBreadcrumbsComponent extends NamedExoticComponent<LegacyBreadcrumbsProps> {
78
+ Breadcrumb: typeof Breadcrumb;
79
+ }
80
+
81
+ export const LegacyBreadcrumbs = Object.assign(memo(LegacyBreadcrumbsRoot), {
82
+ Breadcrumb,
83
+ }) as LegacyBreadcrumbsComponent;
84
+
85
+ const Breadcrumbs = ({
86
+ size,
87
+ testId = NAME,
88
+ className,
89
+ children,
90
+ ...props
91
+ }: BreadcrumbsProps) => {
92
+ const [theme] = useTheme();
93
+
94
+ if (theme === themes.default) {
95
+ return (
96
+ <LegacyBreadcrumbs
97
+ testId={testId}
98
+ className={className}
99
+ {...props}
100
+ >
101
+ {children}
102
+ </LegacyBreadcrumbs>
103
+ );
104
+ }
105
+
106
+ return (
107
+ <BreadcrumbsNew
108
+ size={size}
109
+ testId={testId}
110
+ className={className}
111
+ {...props}
112
+ >
113
+ {children}
114
+ </BreadcrumbsNew>
115
+ );
116
+ };
117
+
118
+ type BreadcrumbBridgeProps = BreadcrumbProps & {
119
+ separator?: boolean;
120
+ back?: boolean;
121
+ size?: BreadcrumbsSize;
122
+ };
123
+
124
+ const BreadcrumbBridge = ({
125
+ uri,
126
+ isActive,
127
+ component,
128
+ separator,
129
+ back,
130
+ size,
131
+ testId,
132
+ className,
133
+ children,
134
+ ...props
135
+ }: BreadcrumbBridgeProps) => {
136
+ const [theme] = useTheme();
137
+
138
+ if (theme === themes.default) {
139
+ return (
140
+ <Breadcrumb
141
+ uri={uri}
142
+ isActive={isActive}
143
+ component={component}
144
+ testId={testId}
145
+ className={className}
146
+ {...props}
147
+ >
148
+ {children}
149
+ </Breadcrumb>
150
+ );
151
+ }
152
+
153
+ const activeBreadcrumb =
154
+ isActive ??
155
+ (typeof window !== 'undefined' && window.location.pathname === uri);
156
+
157
+ if (activeBreadcrumb) {
158
+ return (
159
+ <BreadcrumbsNew.Current
160
+ separator={separator}
161
+ size={size}
162
+ testId={testId}
163
+ className={className}
164
+ {...props}
165
+ >
166
+ {children}
167
+ </BreadcrumbsNew.Current>
168
+ );
169
+ }
170
+
171
+ if (component) {
172
+ return (
173
+ <BreadcrumbsNew.Link
174
+ separator={separator}
175
+ back={back}
176
+ size={size}
177
+ testId={testId}
178
+ className={className}
179
+ component={component}
180
+ to={uri}
181
+ {...props}
182
+ >
183
+ {children}
184
+ </BreadcrumbsNew.Link>
185
+ );
186
+ }
187
+
188
+ return (
189
+ <BreadcrumbsNew.Link
190
+ separator={separator}
191
+ back={back}
192
+ size={size}
193
+ testId={testId}
194
+ className={className}
195
+ href={uri}
196
+ {...props}
197
+ >
198
+ {children}
199
+ </BreadcrumbsNew.Link>
200
+ );
201
+ };
202
+
203
+ export interface BreadcrumbsComponent extends NamedExoticComponent<BreadcrumbsProps> {
204
+ Breadcrumb: typeof BreadcrumbBridge;
205
+ BaseItem: typeof BreadcrumbsNew.BaseItem;
206
+ Link: typeof BreadcrumbsNew.Link;
207
+ Current: typeof BreadcrumbsNew.Current;
208
+ }
209
+
210
+ const MemoBreadcrumbs = memo(Breadcrumbs);
211
+
212
+ const BreadcrumbsWithSubComponents = Object.assign(MemoBreadcrumbs, {
213
+ Breadcrumb: BreadcrumbBridge,
214
+ BaseItem: BreadcrumbsNew.BaseItem,
215
+ Link: BreadcrumbsNew.Link,
216
+ Current: BreadcrumbsNew.Current,
217
+ }) as BreadcrumbsComponent;
59
218
 
60
- export default Breadcrumbs;
219
+ export default BreadcrumbsWithSubComponents;
@@ -1,2 +1,5 @@
1
1
  export { default } from './Breadcrumbs';
2
+ export { LegacyBreadcrumbs } from './Breadcrumbs';
2
3
  export type { BreadcrumbsProps } from './Breadcrumbs';
4
+ /** @deprecated Use BreadcrumbsProps instead. LegacyBreadcrumbsProps only supports the default theme. */
5
+ export type { LegacyBreadcrumbsProps } from './Breadcrumbs';
@@ -95,6 +95,10 @@ export type { AppHeaderProps } from './AppHeader';
95
95
  export { default as Breadcrumbs } from './Breadcrumbs';
96
96
  export type { BreadcrumbsProps } from './Breadcrumbs';
97
97
 
98
+ /** @deprecated Use Breadcrumbs instead. BreadcrumbsLegacy only supports the default theme. */
99
+ export { LegacyBreadcrumbs as BreadcrumbsLegacy } from './Breadcrumbs';
100
+ export type { LegacyBreadcrumbsProps as BreadcrumbsLegacyProps } from './Breadcrumbs';
101
+
98
102
  export { default as BreadcrumbsNew } from './BreadcrumbsNew';
99
103
  export type {
100
104
  BaseBreadcrumbsItemProps,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "uikit-react-public",
3
3
  "private": false,
4
4
  "license": "UNLICENSED",
5
- "version": "0.43.1",
5
+ "version": "0.43.2",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
8
8
  "types": "dist/index.d.ts",