uikit-react-public 0.43.0 → 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.
@@ -71,11 +71,8 @@ const AccordionHeading: React.FC<AccordionHeadingProps> = ({
71
71
  `;
72
72
 
73
73
  const disabledStyle = css`
74
- cursor: 'not-allowed';
75
-
76
- &:hover {
77
- background-color: ${theme.colour.text.disabled};
78
- }
74
+ cursor: not-allowed;
75
+ color: ${theme.colour.text.disabled};
79
76
  `;
80
77
 
81
78
  const headingStyle = cx(
@@ -47,6 +47,7 @@ export interface AccordionProps extends HTMLAttributes<HTMLDivElement> {
47
47
  size?: AccordionSize;
48
48
  disabled?: boolean;
49
49
  isOpen?: boolean;
50
+ variant?: 'no-background' | 'on-background';
50
51
  }
51
52
 
52
53
  const Accordion: React.FC<AccordionProps> & {
@@ -56,6 +57,7 @@ const Accordion: React.FC<AccordionProps> & {
56
57
  size = 'default',
57
58
  disabled = false,
58
59
  isOpen = false,
60
+ variant = 'no-background',
59
61
  children,
60
62
  className,
61
63
  testId = NAME,
@@ -76,7 +78,8 @@ const Accordion: React.FC<AccordionProps> & {
76
78
  min-width: 288px;
77
79
  max-width: 660px;
78
80
  box-sizing: border-box;
79
- border: 1px solid ${theme.colour.border.default};
81
+ border-top: 1px solid ${theme.colour.border.default};
82
+ border-bottom: 1px solid ${theme.colour.border.default};
80
83
  background-color: ${theme.colour.surface.default};
81
84
  color: ${theme.colour.text.default};
82
85
  flex-shrink: 1;
@@ -88,7 +91,17 @@ const Accordion: React.FC<AccordionProps> & {
88
91
  color: ${theme.colour.text.disabled};
89
92
  `;
90
93
 
91
- const style = cx(NAME, baseStyle, disabled && disabledStyle, className);
94
+ const onBackgroundStyle = css`
95
+ border: 1px solid ${theme.colour.border.default};
96
+ `;
97
+
98
+ const style = cx(
99
+ NAME,
100
+ baseStyle,
101
+ disabled && disabledStyle,
102
+ variant === 'on-background' && onBackgroundStyle,
103
+ className
104
+ );
92
105
 
93
106
  return (
94
107
  <AccordionContext.Provider
@@ -3,7 +3,7 @@
3
3
  exports[`Accordion > snapshot: no props 1`] = `
4
4
  <div
5
5
  aria-disabled="false"
6
- class="ucl-uikit-accordion css-cn49eu"
6
+ class="ucl-uikit-accordion css-1pwsm43"
7
7
  data-testid="ucl-uikit-accordion"
8
8
  >
9
9
  <h6
@@ -39,7 +39,7 @@ exports[`Accordion > snapshot: no props 1`] = `
39
39
  exports[`Accordion > snapshot: testId prop 1`] = `
40
40
  <div
41
41
  aria-disabled="false"
42
- class="ucl-uikit-accordion css-cn49eu"
42
+ class="ucl-uikit-accordion css-1pwsm43"
43
43
  data-testid="abc"
44
44
  >
45
45
  <h6
@@ -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';
@@ -1,14 +1,31 @@
1
- import { HTMLAttributes, memo } from 'react';
1
+ import { HTMLAttributes, NamedExoticComponent, ReactNode, memo } from 'react';
2
2
  import { css, cx } from '@emotion/css';
3
+ import { themes, useTheme } from '../../theme';
4
+ import Icon from '../Icon';
5
+ import MenuNew, {
6
+ MenuBaseItemProps,
7
+ MenuDividerProps,
8
+ MenuHeadProps,
9
+ MenuHeadingProps,
10
+ MenuProps as MenuNewProps,
11
+ MenuSectionProps as MenuNewSectionProps,
12
+ PrimaryMenuItemProps,
13
+ SecondaryMenuItemProps,
14
+ ActionMenuButtonProps,
15
+ MenuAccordionItemProps,
16
+ MenuAccordionProps,
17
+ } from '../MenuNew';
3
18
  import MenuProvider from './Menu.context';
4
19
  import MenuContent from './MenuContent';
5
20
  import MenuItem from './MenuItem';
21
+ import { MenuItemProps } from './MenuItem';
6
22
  import MenuSection from './MenuSection';
23
+ import { MenuSectionProps } from './MenuSection';
7
24
  import MenuTrigger from './MenuTrigger';
8
25
 
9
26
  export const NAME = 'ucl-uikit-menu';
10
27
 
11
- export interface MenuProps extends HTMLAttributes<HTMLDivElement> {
28
+ export interface LegacyMenuProps extends HTMLAttributes<HTMLDivElement> {
12
29
  defaultOpen?: boolean;
13
30
  title?: string;
14
31
  menuId?: string;
@@ -16,7 +33,25 @@ export interface MenuProps extends HTMLAttributes<HTMLDivElement> {
16
33
  position?: 'left' | 'right';
17
34
  }
18
35
 
19
- const Menu = ({
36
+ export type MenuProps = Omit<MenuNewProps, 'children'> &
37
+ Pick<LegacyMenuProps, 'defaultOpen' | 'title' | 'menuId' | 'position'> & {
38
+ children?: ReactNode;
39
+ };
40
+
41
+ export type {
42
+ MenuDividerProps,
43
+ MenuHeadProps,
44
+ MenuHeadingProps,
45
+ MenuNewSectionProps,
46
+ MenuAccordionProps,
47
+ MenuAccordionItemProps,
48
+ MenuBaseItemProps,
49
+ PrimaryMenuItemProps,
50
+ SecondaryMenuItemProps,
51
+ ActionMenuButtonProps,
52
+ };
53
+
54
+ const LegacyMenuRoot = ({
20
55
  defaultOpen = false,
21
56
  title,
22
57
  position = 'right',
@@ -25,7 +60,7 @@ const Menu = ({
25
60
  children,
26
61
  className,
27
62
  ...props
28
- }: MenuProps) => {
63
+ }: LegacyMenuProps) => {
29
64
  const baseStyle = css`
30
65
  position: relative;
31
66
  `;
@@ -52,16 +87,137 @@ const Menu = ({
52
87
  );
53
88
  };
54
89
 
55
- export interface IMenuSubComponents {
90
+ export interface LegacyMenuComponent extends NamedExoticComponent<LegacyMenuProps> {
56
91
  Section: typeof MenuSection;
57
92
  Item: typeof MenuItem;
58
93
  }
59
94
 
60
- const MemoMenu = memo(Menu);
95
+ export const LegacyMenu = Object.assign(memo(LegacyMenuRoot), {
96
+ Section: MenuSection,
97
+ Item: MenuItem,
98
+ }) as LegacyMenuComponent;
61
99
 
62
- const MenuWithSubComponents = MemoMenu as typeof MemoMenu & IMenuSubComponents;
100
+ const Menu = ({
101
+ defaultOpen,
102
+ title,
103
+ position,
104
+ menuId,
105
+ testId = NAME,
106
+ className,
107
+ children,
108
+ border,
109
+ collapsed,
110
+ ...props
111
+ }: MenuProps) => {
112
+ const [theme] = useTheme();
113
+
114
+ if (theme === themes.default) {
115
+ return (
116
+ <LegacyMenu
117
+ defaultOpen={defaultOpen}
118
+ title={title}
119
+ position={position}
120
+ menuId={menuId}
121
+ testId={testId}
122
+ className={className}
123
+ {...props}
124
+ >
125
+ {children}
126
+ </LegacyMenu>
127
+ );
128
+ }
129
+
130
+ return (
131
+ <MenuNew
132
+ testId={testId}
133
+ className={className}
134
+ border={border}
135
+ collapsed={collapsed}
136
+ {...props}
137
+ >
138
+ {children}
139
+ </MenuNew>
140
+ );
141
+ };
142
+
143
+ const MenuSectionBridge = (props: MenuSectionProps | MenuNewSectionProps) => {
144
+ const [theme] = useTheme();
145
+ const Section = theme === themes.default ? MenuSection : MenuNew.Section;
146
+
147
+ return <Section {...props} />;
148
+ };
149
+
150
+ const MenuItemBridge = ({
151
+ secondary,
152
+ externalLink,
153
+ trailingContent,
154
+ ...props
155
+ }: MenuItemProps & PrimaryMenuItemProps & SecondaryMenuItemProps) => {
156
+ const [theme] = useTheme();
157
+
158
+ if (theme === themes.default) {
159
+ return (
160
+ <MenuItem
161
+ secondary={secondary}
162
+ externalLink={externalLink}
163
+ {...props}
164
+ />
165
+ );
166
+ }
167
+
168
+ if (secondary) {
169
+ return (
170
+ <MenuNew.SecondaryItem
171
+ externalLink={externalLink}
172
+ {...props}
173
+ />
174
+ );
175
+ }
176
+
177
+ const resolvedTrailingContent =
178
+ trailingContent ??
179
+ (externalLink ? (
180
+ <Icon.ExternalLink
181
+ size={16}
182
+ aria-hidden='true'
183
+ focusable='false'
184
+ />
185
+ ) : undefined);
186
+
187
+ return (
188
+ <MenuNew.PrimaryItem
189
+ trailingContent={resolvedTrailingContent}
190
+ {...props}
191
+ />
192
+ );
193
+ };
194
+
195
+ interface MenuComponent extends NamedExoticComponent<MenuProps> {
196
+ Section: typeof MenuSectionBridge;
197
+ Item: typeof MenuItemBridge;
198
+ Head: typeof MenuNew.Head;
199
+ Heading: typeof MenuNew.Heading;
200
+ Accordion: typeof MenuNew.Accordion;
201
+ Divider: typeof MenuNew.Divider;
202
+ BaseItem: typeof MenuNew.BaseItem;
203
+ PrimaryItem: typeof MenuNew.PrimaryItem;
204
+ SecondaryItem: typeof MenuNew.SecondaryItem;
205
+ ActionButton: typeof MenuNew.ActionButton;
206
+ }
207
+
208
+ const MemoMenu = memo(Menu);
63
209
 
64
- MenuWithSubComponents.Section = MenuSection;
65
- MenuWithSubComponents.Item = MenuItem;
210
+ const MenuWithSubComponents = Object.assign(MemoMenu, {
211
+ Section: MenuSectionBridge,
212
+ Item: MenuItemBridge,
213
+ Head: MenuNew.Head,
214
+ Heading: MenuNew.Heading,
215
+ Accordion: MenuNew.Accordion,
216
+ Divider: MenuNew.Divider,
217
+ BaseItem: MenuNew.BaseItem,
218
+ PrimaryItem: MenuNew.PrimaryItem,
219
+ SecondaryItem: MenuNew.SecondaryItem,
220
+ ActionButton: MenuNew.ActionButton,
221
+ }) as MenuComponent;
66
222
 
67
223
  export default MenuWithSubComponents;
@@ -1,8 +1,15 @@
1
1
  export { default } from './Menu';
2
+ export { LegacyMenu } from './Menu';
2
3
  export type { MenuProps } from './Menu';
4
+ /** @deprecated Use MenuProps instead. LegacyMenuProps only supports the default theme. */
5
+ export type { LegacyMenuProps } from './Menu';
3
6
 
7
+ /** @deprecated Use Menu.PrimaryItem/Menu.SecondaryItem from the package root instead. */
4
8
  export { default as MenuTrigger } from './MenuTrigger';
9
+ /** @deprecated Use MenuNew component props from the package root instead. */
5
10
  export type { MenuTriggerProps } from './MenuTrigger';
6
11
 
12
+ /** @deprecated Use Menu.Head/Menu.Section from the package root instead. */
7
13
  export { default as MenuContent } from './MenuContent';
14
+ /** @deprecated Use MenuNew component props from the package root instead. */
8
15
  export type { MenuContentProps } from './MenuContent';
@@ -1,6 +1,6 @@
1
1
  import { css, cx } from '@emotion/css';
2
2
  import Button, { ButtonProps } from '../Button';
3
- import { useTheme } from '../..';
3
+ import { useTheme } from '../../theme';
4
4
 
5
5
  export const NAME = 'ucl-uikit-menu__action-button';
6
6
 
@@ -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,
@@ -119,6 +123,10 @@ export type { AppMenuProps } from './AppMenu';
119
123
  export { default as Menu } from './Menu';
120
124
  export type { MenuProps } from './Menu';
121
125
 
126
+ /** @deprecated Use Menu instead. MenuLegacy only supports the default theme. */
127
+ export { LegacyMenu as MenuLegacy } from './Menu';
128
+ export type { LegacyMenuProps as MenuLegacyProps } from './Menu';
129
+
122
130
  export { default as MenuNew } from './MenuNew';
123
131
  export type { MenuProps as MenuNewProps } from './MenuNew';
124
132
 
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.0",
5
+ "version": "0.43.2",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
8
8
  "types": "dist/index.d.ts",