@box/blueprint-web 18.3.0 → 18.5.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/dist/lib-esm/blueprint-configuration-context/consts.d.ts +1 -1
- package/dist/lib-esm/blueprint-configuration-context/consts.js +5 -1
- package/dist/lib-esm/components.css +433 -297
- package/dist/lib-esm/index.css +433 -297
- package/dist/lib-esm/list-item/main.module.js +1 -1
- package/dist/lib-esm/list-item/row.d.ts +5 -0
- package/dist/lib-esm/list-item/row.js +3 -1
- package/dist/lib-esm/primitives/tabs/tab-list.js +31 -5
- package/dist/lib-esm/primitives/tabs/tabs.module.js +1 -1
- package/dist/lib-esm/primitives/tabs/use-tab-indicator.d.ts +17 -0
- package/dist/lib-esm/primitives/tabs/use-tab-indicator.js +62 -0
- package/dist/lib-esm/util-components/base-grid-list-item/base-grid-list-item.js +3 -0
- package/dist/lib-esm/util-components/base-grid-list-item/base-grid-list-item.module.js +1 -1
- package/dist/lib-esm/util-components/base-grid-list-item/types.d.ts +5 -0
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '../index.css';
|
|
2
|
-
var styles = {"tableSortingContainer":"bp_main_module_tableSortingContainer--
|
|
2
|
+
var styles = {"tableSortingContainer":"bp_main_module_tableSortingContainer--fceb8","resizableTableContainer":"bp_main_module_resizableTableContainer--fceb8","resizableTable":"bp_main_module_resizableTable--fceb8","tableHeader":"bp_main_module_tableHeader--fceb8","column":"bp_main_module_column--fceb8","columnNameWrapper":"bp_main_module_columnNameWrapper--fceb8","columnName":"bp_main_module_columnName--fceb8","focusVisible":"bp_main_module_focusVisible--fceb8","sorted":"bp_main_module_sorted--fceb8","sortingFlexWrapper":"bp_main_module_sortingFlexWrapper--fceb8","columnResizer":"bp_main_module_columnResizer--fceb8","dropdownHeaderContainer":"bp_main_module_dropdownHeaderContainer--fceb8","droppableColumn":"bp_main_module_droppableColumn--fceb8","actionColumn":"bp_main_module_actionColumn--fceb8","hiddenColumn":"bp_main_module_hiddenColumn--fceb8","tableBody":"bp_main_module_tableBody--fceb8","row":"bp_main_module_row--fceb8","cell":"bp_main_module_cell--fceb8","actionsWrapper":"bp_main_module_actionsWrapper--fceb8","actionChildren":"bp_main_module_actionChildren--fceb8","actions":"bp_main_module_actions--fceb8","alwaysShowSelection":"bp_main_module_alwaysShowSelection--fceb8","isCellHidden":"bp_main_module_isCellHidden--fceb8","highlighted":"bp_main_module_highlighted--fceb8","droppableTarget":"bp_main_module_droppableTarget--fceb8","rowDraggingHighlighted":"bp_main_module_rowDraggingHighlighted--fceb8"};
|
|
3
3
|
|
|
4
4
|
export { styles as default };
|
|
@@ -5,6 +5,11 @@ export type RowProps<T> = PrimitiveRowProps<T> & {
|
|
|
5
5
|
* Set to `false` to style this item as an invalid drop target.
|
|
6
6
|
*/
|
|
7
7
|
isDroppableTarget?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Flashes a green tint that fades to the row's normal background, e.g. for a newly added item.
|
|
10
|
+
* The fade runs once each time this becomes `true`.
|
|
11
|
+
*/
|
|
12
|
+
isHighlighted?: boolean;
|
|
8
13
|
};
|
|
9
14
|
/**
|
|
10
15
|
* Based on React Aria Components `Row`
|
|
@@ -15,6 +15,7 @@ const RowInner = (props, ref) => {
|
|
|
15
15
|
children,
|
|
16
16
|
className,
|
|
17
17
|
isDroppableTarget = true,
|
|
18
|
+
isHighlighted = false,
|
|
18
19
|
...rest
|
|
19
20
|
} = props;
|
|
20
21
|
let newChildren = children;
|
|
@@ -33,7 +34,8 @@ const RowInner = (props, ref) => {
|
|
|
33
34
|
...rest,
|
|
34
35
|
ref: ref,
|
|
35
36
|
className: clsx(styles.row, {
|
|
36
|
-
[styles.droppableTarget]: isDroppableTarget
|
|
37
|
+
[styles.droppableTarget]: isDroppableTarget,
|
|
38
|
+
[styles.highlighted]: isHighlighted
|
|
37
39
|
}, className),
|
|
38
40
|
id: id,
|
|
39
41
|
children: childrenWithOrdinals
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { TabList as TabList$1 } from '@ariakit/react';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
|
-
import { forwardRef } from 'react';
|
|
4
|
+
import { forwardRef, useRef } from 'react';
|
|
5
|
+
import '../../blueprint-configuration-context/blueprint-configuration-context.js';
|
|
6
|
+
import '../../blueprint-configuration-context/consts.js';
|
|
7
|
+
import { useBlueprintConfiguration } from '../../blueprint-configuration-context/useBlueprintConfiguration.js';
|
|
8
|
+
import { useForkRef } from '../../utils/useForkRef.js';
|
|
5
9
|
import styles from './tabs.module.js';
|
|
10
|
+
import { useTabIndicatorStyle } from './use-tab-indicator.js';
|
|
6
11
|
import { useTabs } from './use-tabs.js';
|
|
7
12
|
|
|
8
13
|
const TabList = /*#__PURE__*/forwardRef(function TabList(props, ref) {
|
|
@@ -10,19 +15,40 @@ const TabList = /*#__PURE__*/forwardRef(function TabList(props, ref) {
|
|
|
10
15
|
className,
|
|
11
16
|
variant = 'default',
|
|
12
17
|
containerClassname,
|
|
18
|
+
children,
|
|
13
19
|
...rest
|
|
14
20
|
} = props;
|
|
15
21
|
const tab = useTabs();
|
|
22
|
+
const listRef = useRef(null);
|
|
23
|
+
const {
|
|
24
|
+
componentsWithAnimationEnabled
|
|
25
|
+
} = useBlueprintConfiguration();
|
|
26
|
+
const isAnimationEnabled = componentsWithAnimationEnabled.includes('Tabs');
|
|
27
|
+
const selectedTabElement = tab?.useState(state => state.items.find(item => item.id === state.selectedId)?.element ?? null);
|
|
28
|
+
const indicatorStyle = useTabIndicatorStyle({
|
|
29
|
+
enabled: isAnimationEnabled,
|
|
30
|
+
listRef,
|
|
31
|
+
selectedTabElement
|
|
32
|
+
});
|
|
33
|
+
const listRefs = useForkRef(ref, listRef);
|
|
16
34
|
if (!tab) {
|
|
17
35
|
throw new Error('TabList must be wrapped in a Tabs component');
|
|
18
36
|
}
|
|
19
37
|
return jsx("div", {
|
|
20
38
|
className: clsx(styles.tabsListContainer, containerClassname),
|
|
21
|
-
children:
|
|
39
|
+
children: jsxs(TabList$1, {
|
|
22
40
|
...rest,
|
|
23
|
-
ref:
|
|
41
|
+
ref: listRefs,
|
|
24
42
|
className: clsx(variant === 'contentSwitcher' ? styles.contentSwitchTabList : styles.tabList, className),
|
|
25
|
-
|
|
43
|
+
"data-bp-animated": isAnimationEnabled ? 'true' : 'false',
|
|
44
|
+
store: tab,
|
|
45
|
+
children: [isAnimationEnabled && indicatorStyle ? jsx("div", {
|
|
46
|
+
"aria-hidden": "true",
|
|
47
|
+
className: styles.tabIndicator,
|
|
48
|
+
"data-bp-tab-indicator": "",
|
|
49
|
+
role: "presentation",
|
|
50
|
+
style: indicatorStyle
|
|
51
|
+
}) : null, children]
|
|
26
52
|
})
|
|
27
53
|
});
|
|
28
54
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '../../index.css';
|
|
2
|
-
var styles = {"hiddenWidthSetter":"bp_tabs_module_hiddenWidthSetter--
|
|
2
|
+
var styles = {"hiddenWidthSetter":"bp_tabs_module_hiddenWidthSetter--13d72","contentSwitchTabList":"bp_tabs_module_contentSwitchTabList--13d72","contentSwitchTab":"bp_tabs_module_contentSwitchTab--13d72","tabIndicator":"bp_tabs_module_tabIndicator--13d72","tabsListContainer":"bp_tabs_module_tabsListContainer--13d72","tabList":"bp_tabs_module_tabList--13d72","tabSeparator":"bp_tabs_module_tabSeparator--13d72","tab":"bp_tabs_module_tab--13d72"};
|
|
3
3
|
|
|
4
4
|
export { styles as default };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type CSSProperties, type RefObject } from 'react';
|
|
2
|
+
export type TabIndicatorStyle = Pick<CSSProperties, 'transform' | 'width'>;
|
|
3
|
+
/**
|
|
4
|
+
* Measures the selected tab and returns the sliding-indicator `transform` +
|
|
5
|
+
* `width`. `useContentSizeObserver` is a threshold/`data-large` helper, so
|
|
6
|
+
* ResizeObserver lives here: the list for container resize, the selected tab
|
|
7
|
+
* for label/size changes that do not change the list box.
|
|
8
|
+
*
|
|
9
|
+
* The indicator must be a child of the scrolling tab list (or subtract
|
|
10
|
+
* `scrollLeft`). `offsetLeft` is relative to that list and does not include
|
|
11
|
+
* scroll, so horizontal scroll stays correct without extra math.
|
|
12
|
+
*/
|
|
13
|
+
export declare const useTabIndicatorStyle: ({ enabled, listRef, selectedTabElement, }: {
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
listRef: RefObject<HTMLElement | null>;
|
|
16
|
+
selectedTabElement: HTMLElement | null | undefined;
|
|
17
|
+
}) => TabIndicatorStyle | undefined;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { useEnhancedEffect } from '../../utils/useEnhancedEffect.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Measures the selected tab and returns the sliding-indicator `transform` +
|
|
6
|
+
* `width`. `useContentSizeObserver` is a threshold/`data-large` helper, so
|
|
7
|
+
* ResizeObserver lives here: the list for container resize, the selected tab
|
|
8
|
+
* for label/size changes that do not change the list box.
|
|
9
|
+
*
|
|
10
|
+
* The indicator must be a child of the scrolling tab list (or subtract
|
|
11
|
+
* `scrollLeft`). `offsetLeft` is relative to that list and does not include
|
|
12
|
+
* scroll, so horizontal scroll stays correct without extra math.
|
|
13
|
+
*/
|
|
14
|
+
const useTabIndicatorStyle = ({
|
|
15
|
+
enabled,
|
|
16
|
+
listRef,
|
|
17
|
+
selectedTabElement
|
|
18
|
+
}) => {
|
|
19
|
+
const [style, setStyle] = useState(undefined);
|
|
20
|
+
useEnhancedEffect(() => {
|
|
21
|
+
if (!enabled) {
|
|
22
|
+
setStyle(undefined);
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
const list = listRef.current;
|
|
26
|
+
const selectedTab = selectedTabElement ?? null;
|
|
27
|
+
const measure = () => {
|
|
28
|
+
if (!selectedTab) {
|
|
29
|
+
setStyle(undefined);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const transform = `translateX(${selectedTab.offsetLeft}px)`;
|
|
33
|
+
const width = selectedTab.offsetWidth;
|
|
34
|
+
setStyle(previous => {
|
|
35
|
+
if (previous?.transform === transform && previous.width === width) {
|
|
36
|
+
return previous;
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
transform,
|
|
40
|
+
width
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
measure();
|
|
45
|
+
if (typeof ResizeObserver === 'undefined') {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
const observer = new ResizeObserver(measure);
|
|
49
|
+
if (list) {
|
|
50
|
+
observer.observe(list);
|
|
51
|
+
}
|
|
52
|
+
if (selectedTab) {
|
|
53
|
+
observer.observe(selectedTab);
|
|
54
|
+
}
|
|
55
|
+
return () => {
|
|
56
|
+
observer.disconnect();
|
|
57
|
+
};
|
|
58
|
+
}, [enabled, listRef, selectedTabElement]);
|
|
59
|
+
return style;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export { useTabIndicatorStyle };
|
|
@@ -26,6 +26,7 @@ const BaseGridListItem = /*#__PURE__*/forwardRef(function BaseGridListItem(props
|
|
|
26
26
|
children,
|
|
27
27
|
className,
|
|
28
28
|
isDroppableTarget = true,
|
|
29
|
+
isHighlighted = false,
|
|
29
30
|
loading = false,
|
|
30
31
|
pinned = false,
|
|
31
32
|
pinAriaLabel,
|
|
@@ -134,6 +135,8 @@ const BaseGridListItem = /*#__PURE__*/forwardRef(function BaseGridListItem(props
|
|
|
134
135
|
[styles.noActions]: isV2Layout && !hasActions
|
|
135
136
|
}, {
|
|
136
137
|
[styles.droppableTarget]: isDroppableTarget
|
|
138
|
+
}, {
|
|
139
|
+
[styles.highlighted]: isHighlighted
|
|
137
140
|
}, className),
|
|
138
141
|
textValue: textValue,
|
|
139
142
|
children: jsxs(BaseGridListItemContext.Provider, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '../../index.css';
|
|
2
|
-
var styles = {"smallList":"bp_base_grid_list_item_module_smallList--
|
|
2
|
+
var styles = {"smallList":"bp_base_grid_list_item_module_smallList--c86e5","smallListItem":"bp_base_grid_list_item_module_smallListItem--c86e5","loading":"bp_base_grid_list_item_module_loading--c86e5","thumbnail":"bp_base_grid_list_item_module_thumbnail--c86e5","thumbnailContent":"bp_base_grid_list_item_module_thumbnailContent--c86e5","header":"bp_base_grid_list_item_module_header--c86e5","subtitle":"bp_base_grid_list_item_module_subtitle--c86e5","actions":"bp_base_grid_list_item_module_actions--c86e5","selection":"bp_base_grid_list_item_module_selection--c86e5","inner":"bp_base_grid_list_item_module_inner--c86e5","actionsCheckboxWrapper":"bp_base_grid_list_item_module_actionsCheckboxWrapper--c86e5","largeList":"bp_base_grid_list_item_module_largeList--c86e5","largeListItem":"bp_base_grid_list_item_module_largeListItem--c86e5","fade":"bp_base_grid_list_item_module_fade--c86e5","description":"bp_base_grid_list_item_module_description--c86e5","snippet":"bp_base_grid_list_item_module_snippet--c86e5","snippetContent":"bp_base_grid_list_item_module_snippetContent--c86e5","gridList":"bp_base_grid_list_item_module_gridList--c86e5","gridListItem":"bp_base_grid_list_item_module_gridListItem--c86e5","statusPin":"bp_base_grid_list_item_module_statusPin--c86e5","isItemInteracted":"bp_base_grid_list_item_module_isItemInteracted--c86e5","tooltipContent":"bp_base_grid_list_item_module_tooltipContent--c86e5","tooltipArrow":"bp_base_grid_list_item_module_tooltipArrow--c86e5","gridListV2":"bp_base_grid_list_item_module_gridListV2--c86e5","gridListV2Item":"bp_base_grid_list_item_module_gridListV2Item--c86e5","droppableTarget":"bp_base_grid_list_item_module_droppableTarget--c86e5","noActions":"bp_base_grid_list_item_module_noActions--c86e5","thumbnailBadges":"bp_base_grid_list_item_module_thumbnailBadges--c86e5","statusBadge":"bp_base_grid_list_item_module_statusBadge--c86e5","fileTypePill":"bp_base_grid_list_item_module_fileTypePill--c86e5","alwaysShowSelection":"bp_base_grid_list_item_module_alwaysShowSelection--c86e5","textCentered":"bp_base_grid_list_item_module_textCentered--c86e5","innerCentered":"bp_base_grid_list_item_module_innerCentered--c86e5","highlighted":"bp_base_grid_list_item_module_highlighted--c86e5","gridListV2Small":"bp_base_grid_list_item_module_gridListV2Small--c86e5","gridListV2XSmall":"bp_base_grid_list_item_module_gridListV2XSmall--c86e5","gridListV2XSmallBordered":"bp_base_grid_list_item_module_gridListV2XSmallBordered--c86e5","gridV2ClickShield":"bp_base_grid_list_item_module_gridV2ClickShield--c86e5","listV2ClickShield":"bp_base_grid_list_item_module_listV2ClickShield--c86e5","listV2":"bp_base_grid_list_item_module_listV2--c86e5","listV2Item":"bp_base_grid_list_item_module_listV2Item--c86e5","listV2Divider":"bp_base_grid_list_item_module_listV2Divider--c86e5","content":"bp_base_grid_list_item_module_content--c86e5","staticList":"bp_base_grid_list_item_module_staticList--c86e5","staticListItem":"bp_base_grid_list_item_module_staticListItem--c86e5"};
|
|
3
3
|
|
|
4
4
|
export { styles as default };
|
|
@@ -152,5 +152,10 @@ export interface BaseGridListItemProps extends GridListItemProps, Omit<BaseGridL
|
|
|
152
152
|
* Set to `false` to style this item as an invalid drop target.
|
|
153
153
|
*/
|
|
154
154
|
isDroppableTarget?: boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Flashes a green tint that fades to the item's normal background, e.g. for a newly added item.
|
|
157
|
+
* The fade runs once each time this becomes `true`. Supported in `grid-v2` and `list-v2` layouts.
|
|
158
|
+
*/
|
|
159
|
+
isHighlighted?: boolean;
|
|
155
160
|
}
|
|
156
161
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/blueprint-web",
|
|
3
|
-
"version": "18.
|
|
3
|
+
"version": "18.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"publishConfig": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@ariakit/react": "0.4.21",
|
|
57
57
|
"@ariakit/react-core": "0.4.21",
|
|
58
|
-
"@box/blueprint-web-assets": "^5.12.
|
|
58
|
+
"@box/blueprint-web-assets": "^5.12.4",
|
|
59
59
|
"@internationalized/date": "^3.12.0",
|
|
60
60
|
"@radix-ui/react-accordion": "1.1.2",
|
|
61
61
|
"@radix-ui/react-checkbox": "1.0.4",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@box/box-test-client": "^3.2.7",
|
|
88
88
|
"@box/playwright-utils": "^2.8.5",
|
|
89
|
-
"@box/storybook-utils": "^1.4.
|
|
89
|
+
"@box/storybook-utils": "^1.4.16",
|
|
90
90
|
"@figma/code-connect": "1.4.4",
|
|
91
91
|
"@playwright/test": "1.46.1",
|
|
92
92
|
"@types/js-yaml": "^4.0.9",
|