@box/blueprint-web 18.5.1 → 18.5.2

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.
@@ -21,6 +21,7 @@ export interface PageFastContextValuesType extends PagePortalRefs {
21
21
  mainSectionSidebarVisible: boolean;
22
22
  sidePanelExpanded: boolean;
23
23
  sidePanelExpandedUserControlled: boolean;
24
+ sidePanelId?: string;
24
25
  }
25
26
  export declare const PageProvider: ({ children }: {
26
27
  children: React.ReactNode;
@@ -37,6 +38,7 @@ export declare const useMainSectionSidebar: () => {
37
38
  };
38
39
  export declare const useSidePanel: () => {
39
40
  sidePanelExpanded: boolean;
41
+ sidePanelId: string | undefined;
40
42
  setSidePanelExpanded: (expanded: boolean) => void;
41
43
  toggleSidePanelExpanded: () => void;
42
44
  };
@@ -67,6 +67,7 @@ const useMainSectionSidebar = () => {
67
67
  };
68
68
  const useSidePanel = () => {
69
69
  const [sidePanelExpanded, setPageStore] = usePageStore(store => store.sidePanelExpanded);
70
+ const [sidePanelId] = usePageStore(store => store.sidePanelId);
70
71
  const breakpoint = useBreakpoint();
71
72
  const setSidePanelExpanded = expanded => {
72
73
  setPageStore({
@@ -86,6 +87,7 @@ const useSidePanel = () => {
86
87
  };
87
88
  return {
88
89
  sidePanelExpanded,
90
+ sidePanelId,
89
91
  setSidePanelExpanded,
90
92
  toggleSidePanelExpanded
91
93
  };
@@ -1,9 +1,9 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
  import { FocusTrapRegion } from '@ariakit/react';
3
3
  import clsx from 'clsx';
4
- import { forwardRef, useEffect } from 'react';
4
+ import { forwardRef, useEffect, useId } from 'react';
5
5
  import { useBreakpoint, Breakpoint } from '../utils/useBreakpoint.js';
6
- import { usePageStore, usePageStoreRef } from './page-context.js';
6
+ import { usePageStore, usePageStoreRef, usePageStoreSetterSafe } from './page-context.js';
7
7
  import styles from './page.module.js';
8
8
 
9
9
  const useSidePanelBreakpointSync = () => {
@@ -36,24 +36,40 @@ const useSidePanelBreakpointSync = () => {
36
36
  }
37
37
  }, [breakpoint, defaultSidePanelExpanded, setPageStore, sidePanelExpandedUserControlled]);
38
38
  };
39
+ const useSidePanelId = idProp => {
40
+ const generatedId = useId();
41
+ const id = idProp || `bp-page-side-panel-${generatedId}`;
42
+ const setPageStore = usePageStoreSetterSafe();
43
+ useEffect(() => {
44
+ setPageStore?.({
45
+ sidePanelId: id
46
+ });
47
+ return () => setPageStore?.({
48
+ sidePanelId: undefined
49
+ });
50
+ }, [id, setPageStore]);
51
+ return id;
52
+ };
39
53
  const PageSidePanel = /*#__PURE__*/forwardRef(({
40
54
  className,
41
55
  children,
56
+ id: idProp,
42
57
  ...rest
43
58
  }, forwardedRef) => {
44
59
  useSidePanelBreakpointSync();
45
60
  const [sidePanelExpanded] = usePageStore(store => store.sidePanelExpanded);
46
61
  const setRef = usePageStoreRef('pageSidePanelRef', forwardedRef);
62
+ const id = useSidePanelId(idProp);
47
63
  const breakpoint = useBreakpoint();
48
64
  const isFullScreen = breakpoint < Breakpoint.Large && sidePanelExpanded;
49
65
  return jsx(FocusTrapRegion, {
50
66
  ...rest,
51
67
  ref: setRef,
52
- "aria-expanded": sidePanelExpanded,
53
68
  className: clsx(styles.sidePanel, className, {
54
69
  [styles.expanded]: sidePanelExpanded
55
70
  }),
56
71
  enabled: isFullScreen,
72
+ id: id,
57
73
  children: children
58
74
  });
59
75
  });
@@ -21,9 +21,16 @@ const FilterTriggerChip = /*#__PURE__*/forwardRef((props, forwardedRef) => {
21
21
  type
22
22
  } = useContext(FilterChipGroupContext);
23
23
  const chipClassName = type === 'multiple' ? styles.multiSelectChip : styles.singleSelectChip;
24
- const selectionStateAttrs = {
24
+ // A host can turn the chip into another widget (e.g. an Ariakit Select trigger passes role="combobox"),
25
+ // in which case toggle state attributes are not allowed. The keys must be present to override Radix defaults.
26
+ const isToggleButton = !rest.role || rest.role === 'button';
27
+ const selectionStateAttrs = isToggleButton ? {
25
28
  'data-state': selected ? 'on' : 'off',
26
29
  'aria-pressed': Boolean(selected)
30
+ } : {
31
+ 'data-state': selected ? 'on' : 'off',
32
+ 'aria-pressed': undefined,
33
+ 'aria-checked': undefined
27
34
  };
28
35
  return jsx(Chip, {
29
36
  ...rest,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/blueprint-web",
3
- "version": "18.5.1",
3
+ "version": "18.5.2",
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.5",
58
+ "@box/blueprint-web-assets": "^5.12.6",
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",
@@ -85,7 +85,7 @@
85
85
  "devDependencies": {
86
86
  "@box/box-test-client": "^3.2.7",
87
87
  "@box/playwright-utils": "^2.8.5",
88
- "@box/storybook-utils": "^1.4.17",
88
+ "@box/storybook-utils": "^1.4.18",
89
89
  "@figma/code-connect": "1.4.4",
90
90
  "@playwright/test": "1.46.1",
91
91
  "@types/js-yaml": "^4.0.9",