@box/blueprint-web 12.118.1 → 12.119.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.
@@ -1,6 +1,7 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import { PointerChevronDown, PointerChevronUp } from '@box/blueprint-web-assets/icons/Fill';
3
- import { ChevronDown, ChevronUp } from '@box/blueprint-web-assets/icons/Medium';
3
+ import { ChevronDown, ChevronUp, ChevronRight } from '@box/blueprint-web-assets/icons/Medium';
4
+ import { Size4 } from '@box/blueprint-web-assets/tokens/tokens';
4
5
  import * as Collapsible from '@radix-ui/react-collapsible';
5
6
  import clsx from 'clsx';
6
7
  import { forwardRef, useState, useEffect, useCallback, useMemo } from 'react';
@@ -18,6 +19,7 @@ const CollapsibleSectionImpl = /*#__PURE__*/forwardRef((props, forwardedRef) =>
18
19
  openSectionButtonAriaLabel,
19
20
  onOpenChange,
20
21
  children,
22
+ variant = 'default',
21
23
  ...rest
22
24
  } = props;
23
25
  const {
@@ -37,20 +39,30 @@ const CollapsibleSectionImpl = /*#__PURE__*/forwardRef((props, forwardedRef) =>
37
39
  down: enableModernizedComponents ? ChevronDown : PointerChevronDown,
38
40
  size: enableModernizedComponents ? 'large' : 'x-small'
39
41
  }), [enableModernizedComponents]);
42
+ const BorderlessIcon = useMemo(() => collapsibleSectionOpen ? ChevronDown : ChevronRight, [collapsibleSectionOpen]);
43
+ const iconAriaLabel = useMemo(() => collapsibleSectionOpen ? closeSectionButtonAriaLabel : openSectionButtonAriaLabel, [collapsibleSectionOpen, closeSectionButtonAriaLabel, openSectionButtonAriaLabel]);
44
+ const isBorderless = variant === 'borderless';
40
45
  return jsxs(Collapsible.Root, {
41
46
  ...rest,
42
47
  ref: forwardedRef,
43
48
  className: clsx(styles.collapsibleSection, className),
44
49
  "data-modern": enableModernizedComponents ? 'true' : 'false',
50
+ "data-variant": variant,
45
51
  onOpenChange: onCollapsibleOpenChanged,
46
52
  open: collapsibleSectionOpen,
47
53
  children: [jsx(Collapsible.Trigger, {
48
54
  asChild: true,
49
55
  children: jsxs("div", {
56
+ "aria-label": isBorderless ? iconAriaLabel : undefined,
50
57
  className: styles.collapsibleSectionHeader,
51
58
  role: "button",
52
- children: [headerSlot?.props.children, jsx(IconButton, {
53
- "aria-label": collapsibleSectionOpen ? closeSectionButtonAriaLabel : openSectionButtonAriaLabel,
59
+ children: [headerSlot?.props.children, isBorderless ? jsx(BorderlessIcon, {
60
+ "aria-hidden": true,
61
+ className: styles.collapsibleSectionHeaderArrow,
62
+ height: Size4,
63
+ width: Size4
64
+ }) : jsx(IconButton, {
65
+ "aria-label": iconAriaLabel,
54
66
  className: styles.collapsibleSectionHeaderArrow,
55
67
  icon: collapsibleSectionOpen ? icon.up : icon.down,
56
68
  size: icon.size,
@@ -1,4 +1,4 @@
1
1
  import '../index.css';
2
- var styles = {"collapsibleSection":"bp_collapsible_section_module_collapsibleSection--3ab4e","collapsibleSectionHeader":"bp_collapsible_section_module_collapsibleSectionHeader--3ab4e","collapsibleSectionHeaderArrow":"bp_collapsible_section_module_collapsibleSectionHeaderArrow--3ab4e","collapsibleSectionContent":"bp_collapsible_section_module_collapsibleSectionContent--3ab4e","collapsibleSectionBody":"bp_collapsible_section_module_collapsibleSectionBody--3ab4e"};
2
+ var styles = {"collapsibleSection":"bp_collapsible_section_module_collapsibleSection--b26d9","collapsibleSectionHeader":"bp_collapsible_section_module_collapsibleSectionHeader--b26d9","collapsibleSectionHeaderArrow":"bp_collapsible_section_module_collapsibleSectionHeaderArrow--b26d9","collapsibleSectionContent":"bp_collapsible_section_module_collapsibleSectionContent--b26d9","collapsibleSectionBody":"bp_collapsible_section_module_collapsibleSectionBody--b26d9"};
3
3
 
4
4
  export { styles as default };
@@ -1,2 +1,2 @@
1
1
  export { CollapsibleSection } from './collapsible-section';
2
- export type { CollapsibleSectionProps } from './types';
2
+ export type { CollapsibleSectionProps, CollapsibleSectionVariant } from './types';
@@ -1,4 +1,5 @@
1
1
  import { type CollapsibleProps as RadixCollapsibleSectionProps } from '@radix-ui/react-collapsible';
2
+ export type CollapsibleSectionVariant = 'default' | 'borderless';
2
3
  export type CollapsibleSectionProps = RadixCollapsibleSectionProps & React.ComponentPropsWithRef<'div'> & {
3
4
  /**
4
5
  * Aria label for button opening CollapsibleSection
@@ -8,4 +9,11 @@ export type CollapsibleSectionProps = RadixCollapsibleSectionProps & React.Compo
8
9
  * Aria label for button closing CollapsibleSection
9
10
  */
10
11
  closeSectionButtonAriaLabel: string;
12
+ /**
13
+ * Visual variant of the collapsible section
14
+ * - default: Full width with border and background
15
+ * - borderless: No border, header fits content width
16
+ * @default 'default'
17
+ */
18
+ variant?: CollapsibleSectionVariant;
11
19
  };
@@ -3125,7 +3125,7 @@
3125
3125
  .bp_checkbox_module_option--ae591.bp_checkbox_module_disabled--ae591 .bp_checkbox_module_label--ae591{
3126
3126
  cursor:default;
3127
3127
  }
3128
- .bp_collapsible_section_module_collapsibleSection--3ab4e[data-modern=false]{
3128
+ .bp_collapsible_section_module_collapsibleSection--b26d9[data-modern=false]{
3129
3129
  --collapsible-section-header-padding:var(--space-5);
3130
3130
  --collapsible-section-body-padding:var(--space-5);
3131
3131
  --collapsible-section-padding:var(--space-5);
@@ -3140,7 +3140,7 @@
3140
3140
  --collapsible-section-header-expanded-border-bottom:var(--border-1) solid var(--border-collapsible-border);
3141
3141
  }
3142
3142
 
3143
- .bp_collapsible_section_module_collapsibleSection--3ab4e[data-modern=true]{
3143
+ .bp_collapsible_section_module_collapsibleSection--b26d9[data-modern=true]{
3144
3144
  --collapsible-section-header-padding:var(--bp-space-050) var(--bp-space-020);
3145
3145
  --collapsible-section-body-padding:var(--bp-space-040) var(--bp-space-050);
3146
3146
  --collapsible-section-padding:var(--bp-space-050);
@@ -3155,10 +3155,20 @@
3155
3155
  --collapsible-section-header-expanded-border-bottom:none;
3156
3156
  }
3157
3157
 
3158
- .bp_collapsible_section_module_collapsibleSection--3ab4e{
3158
+ .bp_collapsible_section_module_collapsibleSection--b26d9[data-variant=borderless]{
3159
+ --collapsible-section-border:none;
3160
+ --collapsible-section-header-background-color:#0000;
3161
+ --collapsible-section-content-background-color:#0000;
3162
+ --collapsible-section-padding:var(--bp-space-040);
3163
+ --collapsible-section-header-padding:0;
3164
+ --collapsible-section-body-padding:var(--bp-space-020);
3165
+ --collapsible-section-header-expanded-border-bottom:inherit;
3166
+ }
3167
+
3168
+ .bp_collapsible_section_module_collapsibleSection--b26d9{
3159
3169
  width:100%;
3160
3170
  }
3161
- .bp_collapsible_section_module_collapsibleSectionHeader--3ab4e{
3171
+ .bp_collapsible_section_module_collapsibleSectionHeader--b26d9{
3162
3172
  align-items:center;
3163
3173
  background:var(--collapsible-section-header-background-color);
3164
3174
  border:var(--collapsible-section-border);
@@ -3175,7 +3185,7 @@
3175
3185
  user-select:none;
3176
3186
  width:100%;
3177
3187
  }
3178
- .bp_collapsible_section_module_collapsibleSectionHeader--3ab4e:focus::before{
3188
+ .bp_collapsible_section_module_collapsibleSectionHeader--b26d9:focus::before{
3179
3189
  border:var(--collapsible-section-outline-width) solid var(--collapsible-section-header-focus-color);
3180
3190
  border-radius:var(--collapsible-section-outline-border-radius);
3181
3191
  bottom:var(--collapsible-section-outline-offset);
@@ -3185,29 +3195,31 @@
3185
3195
  right:var(--collapsible-section-outline-offset);
3186
3196
  top:var(--collapsible-section-outline-offset);
3187
3197
  }
3188
- .bp_collapsible_section_module_collapsibleSectionHeader--3ab4e[aria-expanded=true],.bp_collapsible_section_module_collapsibleSectionHeader--3ab4e[aria-expanded=true]::before{
3189
- border-bottom:var(--collapsible-section-header-expanded-border-bottom);
3198
+ .bp_collapsible_section_module_collapsibleSectionHeader--b26d9[aria-expanded=true],.bp_collapsible_section_module_collapsibleSectionHeader--b26d9[aria-expanded=true]::before{
3190
3199
  border-end-end-radius:0;
3191
3200
  border-end-start-radius:0;
3201
+ }
3202
+ .bp_collapsible_section_module_collapsibleSectionHeader--b26d9[aria-expanded=true]{
3203
+ border-bottom:var(--collapsible-section-header-expanded-border-bottom);
3192
3204
  padding-block:var(--collapsible-section-header-padding);
3193
3205
  }
3194
- .bp_collapsible_section_module_collapsibleSectionHeaderArrow--3ab4e{
3206
+ .bp_collapsible_section_module_collapsibleSectionHeaderArrow--b26d9{
3195
3207
  display:block;
3196
3208
  margin-inline-start:var(--collapsible-section-padding);
3197
3209
  }
3198
- .bp_collapsible_section_module_collapsibleSectionHeaderArrow--3ab4e > svg{
3210
+ .bp_collapsible_section_module_collapsibleSectionHeaderArrow--b26d9 > svg{
3199
3211
  vertical-align:middle;
3200
3212
  }
3201
- .bp_collapsible_section_module_collapsibleSectionContent--3ab4e{
3213
+ .bp_collapsible_section_module_collapsibleSectionContent--b26d9{
3202
3214
  overflow:hidden;
3203
3215
  }
3204
- .bp_collapsible_section_module_collapsibleSectionContent--3ab4e[data-state=open]{
3205
- animation:bp_collapsible_section_module_slideDown--3ab4e .25s ease-out;
3216
+ .bp_collapsible_section_module_collapsibleSectionContent--b26d9[data-state=open]{
3217
+ animation:bp_collapsible_section_module_slideDown--b26d9 .25s ease-out;
3206
3218
  }
3207
- .bp_collapsible_section_module_collapsibleSectionContent--3ab4e[data-state=closed]{
3208
- animation:bp_collapsible_section_module_slideUp--3ab4e .25s ease-out;
3219
+ .bp_collapsible_section_module_collapsibleSectionContent--b26d9[data-state=closed]{
3220
+ animation:bp_collapsible_section_module_slideUp--b26d9 .25s ease-out;
3209
3221
  }
3210
- .bp_collapsible_section_module_collapsibleSectionBody--3ab4e{
3222
+ .bp_collapsible_section_module_collapsibleSectionBody--b26d9{
3211
3223
  align-items:center;
3212
3224
  background:var(--collapsible-section-content-background-color);
3213
3225
  border:var(--collapsible-section-border);
@@ -3219,8 +3231,29 @@
3219
3231
  padding-block:var(--collapsible-section-body-padding);
3220
3232
  padding-inline:var(--collapsible-section-padding);
3221
3233
  }
3234
+ .bp_collapsible_section_module_collapsibleSection--b26d9[data-variant=borderless] .bp_collapsible_section_module_collapsibleSectionHeader--b26d9{
3235
+ padding-block:var(--bp-space-030);
3236
+ width:-moz-fit-content;
3237
+ width:fit-content;
3238
+ }
3239
+ .bp_collapsible_section_module_collapsibleSection--b26d9[data-variant=borderless] .bp_collapsible_section_module_collapsibleSectionHeader--b26d9:focus,.bp_collapsible_section_module_collapsibleSection--b26d9[data-variant=borderless] .bp_collapsible_section_module_collapsibleSectionHeader--b26d9:hover{
3240
+ background:var(--bp-surface-cta-surface-tertiary-hover);
3241
+ }
3242
+ .bp_collapsible_section_module_collapsibleSection--b26d9[data-variant=borderless] .bp_collapsible_section_module_collapsibleSectionHeader--b26d9:focus{
3243
+ outline:var(--collapsible-section-outline-width) solid var(--collapsible-section-header-focus-color);
3244
+ outline-offset:var(--collapsible-section-outline-offset);
3245
+ }
3246
+ .bp_collapsible_section_module_collapsibleSection--b26d9[data-variant=borderless] .bp_collapsible_section_module_collapsibleSectionHeader--b26d9:focus::before{
3247
+ display:none;
3248
+ }
3249
+ .bp_collapsible_section_module_collapsibleSection--b26d9[data-variant=borderless] .bp_collapsible_section_module_collapsibleSectionHeader--b26d9[aria-expanded=false],.bp_collapsible_section_module_collapsibleSection--b26d9[data-variant=borderless] .bp_collapsible_section_module_collapsibleSectionHeader--b26d9[aria-expanded=true]{
3250
+ border-radius:var(--collapsible-section-border-radius);
3251
+ }
3252
+ .bp_collapsible_section_module_collapsibleSection--b26d9[data-variant=borderless] .bp_collapsible_section_module_collapsibleSectionHeaderArrow--b26d9{
3253
+ margin-inline-start:var(--bp-space-020);
3254
+ }
3222
3255
 
3223
- @keyframes bp_collapsible_section_module_slideDown--3ab4e{
3256
+ @keyframes bp_collapsible_section_module_slideDown--b26d9{
3224
3257
  from{
3225
3258
  height:0;
3226
3259
  }
@@ -3228,7 +3261,7 @@
3228
3261
  height:var(--radix-collapsible-content-height);
3229
3262
  }
3230
3263
  }
3231
- @keyframes bp_collapsible_section_module_slideUp--3ab4e{
3264
+ @keyframes bp_collapsible_section_module_slideUp--b26d9{
3232
3265
  from{
3233
3266
  height:var(--radix-collapsible-content-height);
3234
3267
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/blueprint-web",
3
- "version": "12.118.1",
3
+ "version": "12.119.0",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "publishConfig": {
@@ -47,7 +47,7 @@
47
47
  "dependencies": {
48
48
  "@ariakit/react": "0.4.15",
49
49
  "@ariakit/react-core": "0.4.15",
50
- "@box/blueprint-web-assets": "^4.94.0",
50
+ "@box/blueprint-web-assets": "^4.94.1",
51
51
  "@internationalized/date": "^3.7.0",
52
52
  "@radix-ui/react-accordion": "1.1.2",
53
53
  "@radix-ui/react-checkbox": "1.0.4",
@@ -77,7 +77,7 @@
77
77
  "type-fest": "^3.2.0"
78
78
  },
79
79
  "devDependencies": {
80
- "@box/storybook-utils": "^0.16.4",
80
+ "@box/storybook-utils": "^0.16.5",
81
81
  "@types/react": "^18.0.0",
82
82
  "@types/react-dom": "^18.0.0",
83
83
  "react": "^18.3.0",