@box/blueprint-web 9.1.3 → 9.2.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/lib-esm/focusable/focusable.d.ts +3 -0
- package/lib-esm/focusable/focusable.js +35 -0
- package/lib-esm/focusable/index.d.ts +1 -0
- package/lib-esm/index.d.ts +1 -0
- package/lib-esm/index.js +1 -0
- package/lib-esm/utils/disabledFromProps.d.ts +8 -0
- package/lib-esm/utils/disabledFromProps.js +9 -0
- package/lib-esm/utils/is-production.d.ts +1 -0
- package/lib-esm/utils/is-production.js +3 -0
- package/package.json +2 -2
|
@@ -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';
|
package/lib-esm/index.d.ts
CHANGED
|
@@ -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';
|
|
@@ -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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/blueprint-web",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.2.0",
|
|
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": "
|
|
66
|
+
"gitHead": "aea7aacd8bd8226934231748787d65edac379e02",
|
|
67
67
|
"module": "lib-esm/index.js",
|
|
68
68
|
"main": "lib-esm/index.js",
|
|
69
69
|
"exports": {
|