@box/blueprint-web 9.1.3 → 9.2.1

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.
@@ -0,0 +1,3 @@
1
+ import { type FocusableProps } from '@ariakit/react';
2
+ import React from 'react';
3
+ export declare const Focusable: React.ForwardRefExoticComponent<Omit<FocusableProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,35 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { Focusable as Focusable$1 } from '@ariakit/react';
3
+ import { forwardRef, isValidElement } from 'react';
4
+ import { isProduction } from '../utils/is-production.js';
5
+ import { disabledFromProps } from '../utils/disabledFromProps.js';
6
+
7
+ const Focusable = /*#__PURE__*/forwardRef((props, forwardedRef) => {
8
+ const {
9
+ children,
10
+ focusable = true,
11
+ ...restProps
12
+ } = props;
13
+ if (! /*#__PURE__*/isValidElement(children)) {
14
+ if (!isProduction()) {
15
+ /* eslint-disable-next-line no-console */
16
+ console.error('Focusable children must be a valid React element.');
17
+ }
18
+ return children;
19
+ }
20
+ const isChildDisabled = disabledFromProps(children.props);
21
+ const renderProps = isChildDisabled ? {
22
+ children
23
+ } : {
24
+ render: children
25
+ };
26
+ return jsx(Focusable$1, {
27
+ ref: forwardedRef,
28
+ focusable: focusable,
29
+ tabIndex: focusable ? 0 : undefined,
30
+ ...restProps,
31
+ ...renderProps
32
+ });
33
+ });
34
+
35
+ export { Focusable };
@@ -0,0 +1 @@
1
+ export { Focusable } from './focusable';
@@ -17,6 +17,7 @@ export * from './data-table/data-table';
17
17
  export * from './date-picker';
18
18
  export * from './divider';
19
19
  export * from './empty-state';
20
+ export * from './focusable';
20
21
  export * from './ghost';
21
22
  export * from './grid-list-item';
22
23
  export * from './guided-tooltip';
package/lib-esm/index.js CHANGED
@@ -20,6 +20,7 @@ export { DataTableWrapper, StickyCell } from './data-table/data-table.js';
20
20
  export { DatePicker } from './date-picker/date-picker.js';
21
21
  export { Divider } from './divider/divider.js';
22
22
  export { EmptyState } from './empty-state/empty-state.js';
23
+ export { Focusable } from './focusable/focusable.js';
23
24
  export { Ghost } from './ghost/ghost.js';
24
25
  export { GridList } from './grid-list-item/index.js';
25
26
  export { GuidedTooltip } from './guided-tooltip/guided-tooltip.js';
@@ -3,6 +3,7 @@ import { CompositeItem, Button } from '@ariakit/react';
3
3
  import { Gray05, Gray100, BoxBlue100, DarkBlue100, GreenLight100, Grimace100, Size4, Size6 } from '@box/blueprint-web-assets/tokens/tokens';
4
4
  import clsx from 'clsx';
5
5
  import Color from 'color';
6
+ import omit from 'lodash/omit';
6
7
  import { forwardRef, createElement } from 'react';
7
8
  import { Text } from '../../text/text.js';
8
9
  import { Ghost } from '../../ghost/ghost.js';
@@ -42,10 +43,11 @@ const SelectMenuGridOption = /*#__PURE__*/forwardRef((props, forwardedRef) => {
42
43
  const isButtonDragged = isWithLabel && !isButtonDisabled && props.draggable && props.dragging;
43
44
  const shouldShowTooltip = !isButtonDisabled && !isWithLabel;
44
45
  const ariaLabel = !isWithLabel ? props['aria-label'] : props.label;
46
+ const buttonProps = isWithLabel ? omit(restProps, ['colorVariant', 'icon']) : restProps;
45
47
  // TODO: [DSYS-764] use IconButton instead of AriakitButton
46
48
  const button = jsx(CompositeItem, {
47
49
  render: jsxs(Button, {
48
- ...restProps,
50
+ ...buttonProps,
49
51
  ref: forwardedRef,
50
52
  "aria-label": loading ? loadingAriaLabel : ariaLabel,
51
53
  className: clsx(styles.optionButton, className, {
@@ -17,6 +17,10 @@ const SelectMenuGrid = /*#__PURE__*/forwardRef((props, forwardedRef) => {
17
17
  className,
18
18
  ...rest
19
19
  } = props;
20
+ if (new Set(Children.toArray(children).map(child => child?.type)).size > 1) {
21
+ // eslint-disable-next-line no-console
22
+ console.warn('SelectMenuGrid: all children should be of the same type');
23
+ }
20
24
  const childrenByColumns = chunk(Children.toArray(children), columns);
21
25
  return jsx(CompositeProvider, {
22
26
  children: jsx(Composite, {
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Checks whether something is disabled or not based on its props.
3
+ * Provided by ariakit https://github.com/ariakit/ariakit/blob/main/packages/ariakit-core/src/utils/misc.ts
4
+ */
5
+ export declare function disabledFromProps(props: {
6
+ disabled?: boolean;
7
+ 'aria-disabled'?: boolean | 'true' | 'false';
8
+ }): boolean;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Checks whether something is disabled or not based on its props.
3
+ * Provided by ariakit https://github.com/ariakit/ariakit/blob/main/packages/ariakit-core/src/utils/misc.ts
4
+ */
5
+ function disabledFromProps(props) {
6
+ return props.disabled || props['aria-disabled'] === true || props['aria-disabled'] === 'true';
7
+ }
8
+
9
+ export { disabledFromProps };
@@ -0,0 +1 @@
1
+ export declare const isProduction: () => boolean;
@@ -0,0 +1,3 @@
1
+ const isProduction = () => process.env.NODE_ENV === 'production';
2
+
3
+ export { isProduction };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/blueprint-web",
3
- "version": "9.1.3",
3
+ "version": "9.2.1",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "publishConfig": {
@@ -63,7 +63,7 @@
63
63
  "react-stately": "^3.31.1",
64
64
  "tsx": "^4.16.5"
65
65
  },
66
- "gitHead": "9a853cf5c13b885475cc76128d6eebeb1de4788a",
66
+ "gitHead": "94a36651838769cd08fd62a9ab1b41e0b4cb5280",
67
67
  "module": "lib-esm/index.js",
68
68
  "main": "lib-esm/index.js",
69
69
  "exports": {