@box/blueprint-web 9.19.3 → 9.20.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.
@@ -9,8 +9,8 @@ import { Calendar as Calendar$1 } from '../primitives/calendar/calendar.js';
9
9
  import '@internationalized/date';
10
10
  import { IconButton } from '../primitives/icon-button/icon-button.js';
11
11
  import { InlineError } from '../primitives/inline-error/inline-error.js';
12
- import { useUniqueId } from '../utils/useUniqueId.js';
13
12
  import { useLabelable } from '../util-components/labelable/useLabelable.js';
13
+ import { useUniqueId } from '../utils/useUniqueId.js';
14
14
  import styles from './date-picker.module.js';
15
15
 
16
16
  const XMarkIcon = label => () => jsx(XMark, {
@@ -65,20 +65,15 @@ const DatePicker = /*#__PURE__*/forwardRef((props, forwardedRef) => {
65
65
  if (value === undefined) {
66
66
  setInternalValue(null);
67
67
  }
68
- firstDateSegmentRef.current?.focus();
69
68
  }, [onChange, value]);
70
69
  const onCalendarDateSelect = useCallback(() => {
71
70
  setIsCalendarOpen(false);
72
71
  }, []);
73
- const onInputWhiteSpaceClick = useCallback(() => {
74
- setIsCalendarOpen(true);
75
- shouldFocusStayInInput.current = true;
76
- }, []);
77
- const onDateSegmentClick = useCallback(() => {
78
- setIsCalendarOpen(true);
79
- shouldFocusStayInInput.current = true;
72
+ const onPressCalendar = useCallback(() => {
73
+ setIsCalendarOpen(v => !v);
74
+ shouldFocusStayInInput.current = false;
80
75
  }, []);
81
- const onKeyUp = useCallback(({
76
+ const onClearButtonKeypress = useCallback(({
82
77
  key
83
78
  }) => {
84
79
  handleSubmitKeyPress(key, () => {
@@ -86,16 +81,9 @@ const DatePicker = /*#__PURE__*/forwardRef((props, forwardedRef) => {
86
81
  firstDateSegmentRef.current?.focus();
87
82
  });
88
83
  }, [onClearInputButtonClicked]);
89
- const onKeyUpButton = useCallback(({
90
- key
91
- }) => {
92
- handleSubmitKeyPress(key, () => {
93
- setIsCalendarOpen(!isCalendarOpen);
94
- shouldFocusStayInInput.current = false;
95
- });
96
- }, [isCalendarOpen]);
97
- const onPress = useCallback(() => {
98
- shouldFocusStayInInput.current = false;
84
+ const onDateInputClick = useCallback(() => {
85
+ setIsCalendarOpen(true);
86
+ shouldFocusStayInInput.current = true;
99
87
  }, []);
100
88
  const hasError = !!error && !isDisabled;
101
89
  const calendarKey = `${internalValue?.day}/${internalValue?.month}/${internalValue?.year}${internalValue?.era}`;
@@ -139,12 +127,12 @@ const DatePicker = /*#__PURE__*/forwardRef((props, forwardedRef) => {
139
127
  asChild: true,
140
128
  children: jsxs(Group, {
141
129
  className: clsx(styles.group),
142
- onClick: onInputWhiteSpaceClick,
143
- onMouseUp: onDateSegmentClick,
144
130
  children: [jsx("div", {
145
131
  className: clsx(styles.groupContainer, {
146
132
  [styles.error]: hasError
147
133
  }),
134
+ "data-testid": "date-picker-input",
135
+ onClickCapture: onDateInputClick,
148
136
  children: jsx(DateInput, {
149
137
  className: clsx(styles.groupContainerInput),
150
138
  children: segment => jsx(DateSegment, {
@@ -163,27 +151,19 @@ const DatePicker = /*#__PURE__*/forwardRef((props, forwardedRef) => {
163
151
  disabled: isDisabled,
164
152
  icon: XMarkIcon(clearDatePickerAriaLabel),
165
153
  onClick: onClearInputButtonClicked,
166
- // onKeyDown overwrites handler which manages arrow navigation within group
167
- // use onKeyUp instead
168
- onKeyUp: onKeyUp,
154
+ onKeyDownCapture: onClearButtonKeypress,
169
155
  size: "x-small"
170
- }), jsx(RadixPopover.Trigger, {
171
- asChild: true,
172
- children: jsx(Button, {
173
- ref: calendarButtonRef,
156
+ }), jsx(Button, {
157
+ "aria-expanded": isCalendarOpen,
158
+ "aria-label": openCalendarDropdownAriaLabel,
159
+ className: styles.button,
160
+ isDisabled: isDisabled,
161
+ onPress: onPressCalendar,
162
+ children: jsx(Calendar, {
174
163
  "aria-label": openCalendarDropdownAriaLabel,
175
- className: styles.button,
176
- isDisabled: isDisabled,
177
- // onKeyDown breaks arrow navigation within group
178
- // onPress doesn't work with Popover.Trigger - onKeyUp is the only option
179
- onKeyUp: onKeyUpButton,
180
- onPress: onPress,
181
- children: jsx(Calendar, {
182
- "aria-label": openCalendarDropdownAriaLabel,
183
- color: Gray65,
184
- height: Size4,
185
- width: Size4
186
- })
164
+ color: Gray65,
165
+ height: Size4,
166
+ width: Size4
187
167
  })
188
168
  })]
189
169
  })
@@ -10,7 +10,7 @@ const GridList = /*#__PURE__*/forwardRef(function GridList(props, forwardedRef)
10
10
  return jsx(BaseGridList, {
11
11
  ...rest,
12
12
  ref: forwardedRef,
13
- layout: "grid",
13
+ layoutStyle: "grid",
14
14
  children: children
15
15
  });
16
16
  });
@@ -6,5 +6,5 @@ export type GridListSubtitleProps = BaseGridListSubtitleProps;
6
6
  export type GridListDescriptionProps = BaseGridListDescriptionProps;
7
7
  export type GridListActionsProps = BaseGridListActionsProps;
8
8
  export type GridListActionIconButtonProps = BaseGridListActionIconButtonProps;
9
- export type GridListProps = Omit<BaseGridListProps, 'layout'>;
9
+ export type GridListProps = Omit<BaseGridListProps, 'layoutStyle'>;
10
10
  export type GridListItemProps = RequireAllOrNone<BaseGridListItemProps, 'pinned' | 'pinAriaLabel'>;
@@ -10,7 +10,7 @@ const LargeList = /*#__PURE__*/forwardRef(function LargeList(props, forwardedRef
10
10
  return jsx(BaseGridList, {
11
11
  ...rest,
12
12
  ref: forwardedRef,
13
- layout: "list",
13
+ layoutStyle: "list",
14
14
  children: children
15
15
  });
16
16
  });
@@ -5,7 +5,7 @@ export type LargeListSubtitleProps = BaseGridListSubtitleProps;
5
5
  export type LargeListDescriptionProps = BaseGridListDescriptionProps;
6
6
  export type LargeListActionsProps = BaseGridListActionsProps;
7
7
  export type LargeListActionIconButtonProps = BaseGridListActionIconButtonProps;
8
- export type LargeListProps = Omit<BaseGridListProps, 'layout'>;
8
+ export type LargeListProps = Omit<BaseGridListProps, 'layoutStyle'>;
9
9
  export type LargeListItemProps = BaseGridListItemProps;
10
10
  export interface LargeListSnippetProps {
11
11
  /** Regular expression pattern to be highlighted in snippetText */
@@ -25,7 +25,7 @@ const TableHeaderInner = (props, ref) => {
25
25
  // creating a `Column` component for each column in the table.
26
26
  // This ensures we can later assign an `__ordinal` property to each column.
27
27
  if (typeof children === 'function' && columns) {
28
- return columns.map(children);
28
+ return Array.from(columns).map(children);
29
29
  }
30
30
  return children;
31
31
  }, [children, columns]);
@@ -10,7 +10,7 @@ const SmallList = /*#__PURE__*/forwardRef(function SmallList(props, forwardedRef
10
10
  return jsx(BaseGridList, {
11
11
  ...rest,
12
12
  ref: forwardedRef,
13
- layout: "small-list",
13
+ layoutStyle: "small-list",
14
14
  children: children
15
15
  });
16
16
  });
@@ -4,5 +4,5 @@ export type SmallListActionsProps = BaseGridListActionsProps;
4
4
  export type SmallListHeaderProps = BaseGridListHeaderProps;
5
5
  export type SmallListThumbnailProps = BaseGridListThumbnailProps;
6
6
  export type SmallListSubtitleProps = BaseGridListSubtitleProps;
7
- export type SmallListProps = Omit<BaseGridListProps, 'layout'>;
7
+ export type SmallListProps = Omit<BaseGridListProps, 'layoutStyle'>;
8
8
  export type SmallListItemProps = BaseGridListItemProps;
@@ -85,7 +85,7 @@ const BaseGridListActionIconButton = /*#__PURE__*/forwardRef(function BaseGridLi
85
85
  });
86
86
  const BaseGridListActions = /*#__PURE__*/forwardRef(function BaseGridListActions(props, forwardedRef) {
87
87
  const {
88
- layout,
88
+ layoutStyle,
89
89
  selectionMode
90
90
  } = useBaseGridListContext();
91
91
  const {
@@ -104,7 +104,7 @@ const BaseGridListActions = /*#__PURE__*/forwardRef(function BaseGridListActions
104
104
  if (loading) {
105
105
  return null;
106
106
  }
107
- const isList = layout === 'list' || layout === 'small-list';
107
+ const isList = layoutStyle === 'list' || layoutStyle === 'small-list';
108
108
  const isSelectionEnabled = selectionMode === 'multiple';
109
109
  const isRenderPropUsed = typeof children === 'function';
110
110
  return jsxs(Fragment, {
@@ -20,7 +20,7 @@ const BaseGridListHeader = /*#__PURE__*/forwardRef(function BaseGridListHeader(p
20
20
  loading
21
21
  } = useBaseGridListItemContext();
22
22
  const {
23
- layout
23
+ layoutStyle
24
24
  } = useBaseGridListContext();
25
25
  const {
26
26
  Wrapper,
@@ -31,8 +31,8 @@ const BaseGridListHeader = /*#__PURE__*/forwardRef(function BaseGridListHeader(p
31
31
  textValue,
32
32
  skipOverflowCheck: loading
33
33
  });
34
- const isLargeItem = layout === 'list';
35
- const isSmallListItem = layout === 'small-list';
34
+ const isLargeItem = layoutStyle === 'list';
35
+ const isSmallListItem = layoutStyle === 'small-list';
36
36
  return (
37
37
  // @ts-expect-error Fix this type error
38
38
  jsx(Wrapper, {
@@ -19,7 +19,7 @@ const BaseGridListSubtitle = /*#__PURE__*/forwardRef(function BaseGridListSubtit
19
19
  loading
20
20
  } = useBaseGridListItemContext();
21
21
  const {
22
- layout
22
+ layoutStyle
23
23
  } = useBaseGridListContext();
24
24
  const {
25
25
  Wrapper,
@@ -29,8 +29,8 @@ const BaseGridListSubtitle = /*#__PURE__*/forwardRef(function BaseGridListSubtit
29
29
  children,
30
30
  skipOverflowCheck: loading
31
31
  });
32
- const isGridItem = layout === 'grid';
33
- const isSmallListItem = layout === 'small-list';
32
+ const isGridItem = layoutStyle === 'grid';
33
+ const isSmallListItem = layoutStyle === 'small-list';
34
34
  const forkRef = useForkRef(ref, forwardedRef);
35
35
  if (isSmallListItem && loading) {
36
36
  // no loading state for small list item subtitle
@@ -28,12 +28,12 @@ const BaseGridListItem = /*#__PURE__*/forwardRef(function BaseGridListItem(props
28
28
  ...rest
29
29
  } = props;
30
30
  const {
31
- layout,
31
+ layoutStyle,
32
32
  isInteractive
33
33
  } = useBaseGridListContext();
34
34
  const textValue = typeof rest.textValue === 'string' ? rest.textValue : undefined;
35
35
  const [isItemInteracted, setIsItemInteracted] = useState(false);
36
- // Use debounce with a small delay to make sure there is style flashing finishing interaction (e.g closing dropdown)
36
+ // Use debounce with a small delay to make sure there is style flashing finishing interaction (e.g. closing dropdown)
37
37
  const debouncedIsItemInteracted = useDebounce(isItemInteracted, 50);
38
38
  const context = useMemo(() => ({
39
39
  loading,
@@ -42,22 +42,22 @@ const BaseGridListItem = /*#__PURE__*/forwardRef(function BaseGridListItem(props
42
42
  isItemInteracted,
43
43
  setIsItemInteracted
44
44
  }), [loading, pinned, pinAriaLabel, isItemInteracted]);
45
- let layoutStyle;
46
- switch (layout) {
45
+ let layoutStyleClass;
46
+ switch (layoutStyle) {
47
47
  case 'list':
48
- layoutStyle = styles.largeListItem;
48
+ layoutStyleClass = styles.largeListItem;
49
49
  break;
50
50
  case 'grid':
51
- layoutStyle = styles.gridListItem;
51
+ layoutStyleClass = styles.gridListItem;
52
52
  break;
53
53
  case 'small-list':
54
- layoutStyle = styles.smallListItem;
54
+ layoutStyleClass = styles.smallListItem;
55
55
  }
56
56
  const GridListItem$1 = isInteractive ? GridListItem : StaticGridListItem;
57
57
  return jsx(GridListItem$1, {
58
58
  ...rest,
59
59
  ref: forwardedRef,
60
- className: clsx(layoutStyle, {
60
+ className: clsx(layoutStyleClass, {
61
61
  [styles.loading]: loading
62
62
  }, {
63
63
  [styles.isItemInteracted]: isItemInteracted || debouncedIsItemInteracted
@@ -8,7 +8,7 @@ import { StaticGridList } from './static-grid-list.js';
8
8
  import styles from './base-grid-list-item.module.js';
9
9
 
10
10
  const BaseGridListContext = /*#__PURE__*/createContext({
11
- layout: 'grid'
11
+ layoutStyle: 'grid'
12
12
  });
13
13
  const useBaseGridListContext = () => {
14
14
  return useContext(BaseGridListContext);
@@ -27,27 +27,32 @@ const BaseGridList = /*#__PURE__*/forwardRef(function BaseGridList(props, forwar
27
27
  onAction,
28
28
  className,
29
29
  isInteractive = true,
30
- layout,
30
+ layoutStyle,
31
31
  ...rest
32
32
  } = props;
33
33
  const handleOnAction = onAction || noop;
34
34
  const context = useMemo(() => ({
35
35
  selectionMode: rest.selectionMode,
36
36
  selectionBehavior: rest.selectionBehavior,
37
- layout,
37
+ layoutStyle,
38
38
  isInteractive,
39
39
  onAction: handleOnAction
40
- }), [rest.selectionMode, rest.selectionBehavior, layout, isInteractive, handleOnAction]);
41
- let layoutStyle;
42
- switch (layout) {
40
+ }), [rest.selectionMode, rest.selectionBehavior, layoutStyle, isInteractive, handleOnAction]);
41
+ let layoutStyleClass;
42
+ let layoutFinal;
43
+ switch (layoutStyle) {
43
44
  case 'list':
44
- layoutStyle = styles.largeList;
45
+ layoutStyleClass = styles.largeList;
46
+ layoutFinal = 'stack';
45
47
  break;
46
48
  case 'grid':
47
- layoutStyle = styles.gridList;
49
+ layoutStyleClass = styles.gridList;
50
+ layoutFinal = 'grid';
48
51
  break;
49
52
  case 'small-list':
50
- layoutStyle = styles.smallList;
53
+ layoutFinal = 'stack';
54
+ layoutStyleClass = styles.smallList;
55
+ break;
51
56
  }
52
57
  const GridList$1 = isInteractive ? GridList : StaticGridList;
53
58
  return jsx("div", {
@@ -57,7 +62,8 @@ const BaseGridList = /*#__PURE__*/forwardRef(function BaseGridList(props, forwar
57
62
  children: jsx(GridList$1, {
58
63
  ...rest,
59
64
  ref: forwardedRef,
60
- className: clsx(layoutStyle, className),
65
+ className: clsx(layoutStyleClass, className),
66
+ layout: layoutFinal,
61
67
  onAction: handleOnAction,
62
68
  children: children
63
69
  })
@@ -3,7 +3,7 @@ import { type GridListItemProps, type GridListProps as RAGridListProps } from 'r
3
3
  import { type IconButtonProps } from '../../primitives/icon-button';
4
4
  import { type Modify } from '../../types/modify';
5
5
  export interface BaseGridListLayoutProp {
6
- layout: 'grid' | 'list' | 'small-list';
6
+ layoutStyle: 'grid' | 'list' | 'small-list';
7
7
  }
8
8
  interface CustomGridListProps extends BaseGridListLayoutProp {
9
9
  /**
@@ -32,7 +32,7 @@ export type BaseGridListActionsProps = Modify<ComponentPropsWithRef<'div'>, {
32
32
  children: ReactNode | ((setIsInteracted: (open: boolean) => void) => ReactNode);
33
33
  }>;
34
34
  export type BaseGridListActionIconButtonProps = IconButtonProps;
35
- export interface BaseGridListProps extends RAGridListProps<object>, CustomGridListProps {
35
+ export interface BaseGridListProps extends Omit<RAGridListProps<object>, 'layout'>, CustomGridListProps {
36
36
  }
37
37
  export interface BaseGridListItemContextType {
38
38
  loading?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/blueprint-web",
3
- "version": "9.19.3",
3
+ "version": "9.20.0",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "publishConfig": {
@@ -47,8 +47,8 @@
47
47
  "dependencies": {
48
48
  "@ariakit/react": "0.4.15",
49
49
  "@ariakit/react-core": "0.4.15",
50
- "@box/blueprint-web-assets": "^4.37.2",
51
- "@internationalized/date": "^3.5.4",
50
+ "@box/blueprint-web-assets": "^4.37.3",
51
+ "@internationalized/date": "^3.7.0",
52
52
  "@radix-ui/react-accordion": "1.1.2",
53
53
  "@radix-ui/react-checkbox": "1.0.4",
54
54
  "@radix-ui/react-collapsible": "1.0.3",
@@ -66,23 +66,23 @@
66
66
  "@radix-ui/react-toggle-group": "1.0.4",
67
67
  "@radix-ui/react-toolbar": "1.0.4",
68
68
  "@radix-ui/react-tooltip": "1.0.7",
69
- "@react-aria/i18n": "^3.11.1",
70
- "@react-aria/utils": "^3.24.1",
69
+ "@react-aria/i18n": "^3.12.7",
70
+ "@react-aria/utils": "^3.28.1",
71
71
  "clsx": "^1.2.1",
72
72
  "color": "2.0.1",
73
73
  "lodash": "^4.17.15",
74
- "react-aria": "^3.33.1",
75
- "react-aria-components": "^1.2.1",
74
+ "react-aria": "^3.38.1",
75
+ "react-aria-components": "^1.7.1",
76
76
  "tabbable": "^4.0.0",
77
77
  "type-fest": "^3.2.0"
78
78
  },
79
79
  "devDependencies": {
80
- "@box/storybook-utils": "^0.8.3",
80
+ "@box/storybook-utils": "^0.9.0",
81
81
  "@types/react": "^18.0.0",
82
82
  "@types/react-dom": "^18.0.0",
83
83
  "react": "^18.3.0",
84
84
  "react-dom": "^18.3.0",
85
- "react-stately": "^3.31.1",
85
+ "react-stately": "^3.35.0",
86
86
  "tsx": "^4.16.5"
87
87
  }
88
88
  }