@apify/ui-library 1.90.0 → 1.91.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apify/ui-library",
3
- "version": "1.90.0",
3
+ "version": "1.91.0",
4
4
  "description": "React UI library used by apify.com",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -66,5 +66,5 @@
66
66
  "src",
67
67
  "style"
68
68
  ],
69
- "gitHead": "9e6600fd773251daac9236b90a189d6ebbcf1aab"
69
+ "gitHead": "b3fa3cfa3a161f319afedcd69317e9f153719626"
70
70
  }
@@ -42,6 +42,12 @@ export const Default = () => {
42
42
  Badge
43
43
  </Badge>
44
44
  </td>
45
+ </React.Fragment>
46
+ );
47
+ })}
48
+ {BADGE_SIZES.map((size) => {
49
+ return (
50
+ <React.Fragment key={`code-${size}`}>
45
51
  <td>
46
52
  <Badge
47
53
  size={size}
@@ -10,17 +10,19 @@ import { Box, type MarginSpacingProps, type RegularBoxProps } from './box.js';
10
10
  import { Text } from './text/index.js';
11
11
  import type { SharedTextSize, SharedTextType } from './text/text_shared.js';
12
12
 
13
- export type BadgeSize = 'regular' | 'small' | 'extra_small';
14
- export const BADGE_SIZES: BadgeSize[] = ['regular', 'small'];
13
+ export type BadgeSize = 'large' | 'regular' | 'small' | 'extra_small';
14
+ export const BADGE_SIZES: BadgeSize[] = ['large', 'regular', 'small', 'extra_small'];
15
15
 
16
16
  const BADGE_ICON_SIZES = {
17
- regular: '16',
17
+ large: '16',
18
+ regular: '12',
18
19
  small: '12',
19
20
  extra_small: '12',
20
21
  } satisfies Record<BadgeSize, IconSize>;
21
22
 
22
23
  const BADGE_TEXT_SIZES = {
23
- regular: 'regular',
24
+ large: 'regular',
25
+ regular: 'small',
24
26
  small: 'small',
25
27
  extra_small: 'small',
26
28
  } satisfies Record<BadgeSize, SharedTextSize>;
@@ -38,18 +40,21 @@ export type BadgeProps = SharedBadgeProps & {
38
40
  };
39
41
 
40
42
  const badgeSizeStyle = {
41
- regular: css`
43
+ large: css`
42
44
  padding: ${theme.space.space4} ${theme.space.space8};
43
45
  border-radius: ${theme.radius.radius6};
44
46
  `,
47
+ regular: css`
48
+ padding: ${theme.space.space4} ${theme.space.space6};
49
+ border-radius: ${theme.radius.radius4};
50
+ `,
45
51
  small: css`
46
- height: 2rem;
47
52
  padding: ${theme.space.space2} ${theme.space.space6};
48
53
  border-radius: ${theme.radius.radius4};
49
54
  `,
50
55
  extra_small: css`
51
56
  height: ${theme.space.space16};
52
- padding: ${theme.space.space2} ${theme.space.space4};
57
+ padding: 0 ${theme.space.space4};
53
58
  border-radius: ${theme.radius.radius4};
54
59
  `,
55
60
  } satisfies Record<BadgeSize, FlattenSimpleInterpolation>;
@@ -11,6 +11,7 @@ import {
11
11
  import clsx from 'clsx';
12
12
  import type React from 'react';
13
13
  import {
14
+ useCallback,
14
15
  useMemo,
15
16
  useRef,
16
17
  useState,
@@ -49,6 +50,7 @@ export interface MenuProps<T = MenuOption> {
49
50
  options: T[],
50
51
  value?: string,
51
52
  onSelect: (newValue: string, selectedBy: SelectActionType) => void,
53
+ onMenuOpen?: (isOpen: boolean) => void,
52
54
  defaultLabel?: React.ReactNode,
53
55
  closeOnSelect?: boolean,
54
56
  renderOption?: (option: T) => React.ReactNode,
@@ -70,6 +72,7 @@ export const Menu = <T extends MenuOption>({
70
72
  options,
71
73
  value,
72
74
  onSelect,
75
+ onMenuOpen,
73
76
  closeOnSelect = true,
74
77
  defaultLabel,
75
78
  components,
@@ -77,7 +80,13 @@ export const Menu = <T extends MenuOption>({
77
80
  className,
78
81
  ...rest
79
82
  }: MenuProps<T> & BoxProps) => {
80
- const [isOpen, setIsOpen] = useState(false);
83
+ const [isOpen, setIsOpenState] = useState(false);
84
+ const setIsOpen = useCallback((newIsOpen: boolean) => {
85
+ setIsOpenState(newIsOpen);
86
+ if (onMenuOpen) {
87
+ onMenuOpen(newIsOpen);
88
+ }
89
+ }, [onMenuOpen]);
81
90
  const { refs, floatingStyles, context } = useFloatingMenu({
82
91
  isOpen,
83
92
  setIsOpen,