@box/blueprint-web 8.3.1 → 8.4.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/index.css CHANGED
@@ -5114,6 +5114,88 @@ table.bp_inline_table_module_inlineTable--b023b tr:not(:last-child) td{
5114
5114
  background-color:var(--surface-radio-surface-selected-hover);
5115
5115
  }
5116
5116
 
5117
+ .bp_radio_tiles_option_module_radioTileOption--db24b{
5118
+ background-color:var(--surface-radiotile-surface);
5119
+ border:var(--border-1) solid var(--border-radiotile-border);
5120
+ border-radius:var(--radius-3);
5121
+ box-sizing:border-box;
5122
+ cursor:pointer;
5123
+ display:inline-flex;
5124
+ max-width:100%;
5125
+ min-height:var(--size-10);
5126
+ overflow:hidden;
5127
+ pointer-events:auto;
5128
+ position:relative;
5129
+ transition:background-color var(--animation-duration-2), border var(--animation-duration-2);
5130
+ -webkit-user-select:none;
5131
+ user-select:none;
5132
+ }
5133
+ .bp_radio_tiles_option_module_radioTileOption--db24b .bp_radio_tiles_option_module_icon--db24b{
5134
+ display:inline-flex;
5135
+ }
5136
+ .bp_radio_tiles_option_module_radioTileOption--db24b .bp_radio_tiles_option_module_icon--db24b > svg > path{
5137
+ fill:var(--icon-icon-on-light-secondary);
5138
+ }
5139
+ .bp_radio_tiles_option_module_radioTileOption--db24b.bp_radio_tiles_option_module_disabled--db24b{
5140
+ opacity:.6;
5141
+ }
5142
+ .bp_radio_tiles_option_module_radioTileOption--db24b:has(:focus-visible){
5143
+ outline:2px solid var(--border-input-border-focus);
5144
+ outline-offset:var(--border-2);
5145
+ }
5146
+ .bp_radio_tiles_option_module_radioTileOption--db24b.bp_radio_tiles_option_module_checked--db24b{
5147
+ background-color:var(--surface-radiotile-surface-selected);
5148
+ border-color:#0000;
5149
+ box-shadow:0 0 0 2px var(--border-radiotile-border-selected);
5150
+ }
5151
+ .bp_radio_tiles_option_module_radioTileOption--db24b.bp_radio_tiles_option_module_checked--db24b:focus-within{
5152
+ outline-offset:var(--border-3);
5153
+ }
5154
+ .bp_radio_tiles_option_module_radioTileOption--db24b.bp_radio_tiles_option_module_checked--db24b .bp_radio_tiles_option_module_icon--db24b > svg > path{
5155
+ fill:var(--icon-icon-blue);
5156
+ }
5157
+ .bp_radio_tiles_option_module_radioTileOption--db24b:hover:not(.bp_radio_tiles_option_module_disabled--db24b, .bp_radio_tiles_option_module_checked--db24b){
5158
+ background-color:var(--surface-radiotile-surface-hover);
5159
+ border:var(--border-1) solid var(--border-radiotile-border-hover);
5160
+ }
5161
+ .bp_radio_tiles_option_module_radioTileOption--db24b > label{
5162
+ align-items:center;
5163
+ box-sizing:border-box;
5164
+ cursor:inherit;
5165
+ display:flex;
5166
+ flex-direction:column;
5167
+ gap:var(--space-2);
5168
+ justify-content:center;
5169
+ padding:var(--space-2);
5170
+ width:100%;
5171
+ }
5172
+
5173
+ .bp_radio_tiles_option_module_radioTileLabel--db24b{
5174
+ max-width:100%;
5175
+ overflow:hidden;
5176
+ text-align:center;
5177
+ text-overflow:ellipsis;
5178
+ white-space:nowrap;
5179
+ }
5180
+
5181
+ .bp_radio_tiles_module_radioTiles--94f93{
5182
+ display:flex;
5183
+ gap:var(--space-2);
5184
+ }
5185
+ .bp_radio_tiles_module_radioTiles--94f93.bp_radio_tiles_module_hasColumns--94f93{
5186
+ flex-wrap:wrap;
5187
+ }
5188
+ .bp_radio_tiles_module_radioTiles--94f93.bp_radio_tiles_module_hasColumns--94f93 > *{
5189
+ width:100%;
5190
+ }
5191
+ .bp_radio_tiles_module_radioTiles--94f93.bp_radio_tiles_module_default--94f93 > *{
5192
+ flex:1 1 calc(100%/var(--columns) - var(--space-2));
5193
+ width:100%;
5194
+ }
5195
+ .bp_radio_tiles_module_radioTiles--94f93.bp_radio_tiles_module_compact--94f93 > *{
5196
+ flex:0 1 calc(100%/var(--columns) - var(--space-2) + var(--space-2)/var(--columns));
5197
+ }
5198
+
5117
5199
  .bp_search_module_search--b65f4{
5118
5200
  font-family:Lato, -apple-system, BlinkMacSystemFont, "San Francisco", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
5119
5201
  font-size:.875rem;
@@ -46,6 +46,7 @@ export * from './primitives/select-menu-grid';
46
46
  export * from './primitives/supplementary-fonts';
47
47
  export * from './primitives/tabs';
48
48
  export * from './radio-group';
49
+ export * from './radio-tiles';
49
50
  export * from './search-input';
50
51
  export * from './select';
51
52
  export * from './side-panel';
package/lib-esm/index.js CHANGED
@@ -61,6 +61,8 @@ export { useSupplementaryFonts } from './primitives/supplementary-fonts/useSuppl
61
61
  export { getSupplementaryFontFacesConfig } from './primitives/supplementary-fonts/get-supplementary-font-faces-config.js';
62
62
  export { Tabs } from './primitives/tabs/index.js';
63
63
  export { Radio } from './radio-group/index.js';
64
+ export { RadioTiles } from './radio-tiles/radio-tiles.js';
65
+ export { RadioTilesOption } from './radio-tiles/radio-tiles-option.js';
64
66
  export { SearchInput } from './search-input/index.js';
65
67
  export { SELECT_EMPTY_VALUE, Select } from './select/select.js';
66
68
  export { SidePanel } from './side-panel/side-panel.js';
@@ -0,0 +1,3 @@
1
+ export { RadioTiles } from './radio-tiles';
2
+ export { RadioTilesOption } from './radio-tiles-option';
3
+ export type { RadioTilesProps, RadioTilesOptionProps } from './types';
@@ -0,0 +1,2 @@
1
+ import { type RadioTilesOptionProps } from './types';
2
+ export declare const RadioTilesOption: <T extends string>({ children, value, label, icon, disabled: disabledProp, className, "aria-label": ariaLabel, }: RadioTilesOptionProps<T>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,82 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import React__default, { useRef } from 'react';
3
+ import clsx from 'clsx';
4
+ import { Text } from '../text/text.js';
5
+ import { useRadioTilesContext } from './radio-tiles.context.js';
6
+ import styles from './radio-tiles-option.module.js';
7
+ import { useFullTextTooltip } from '../utils/useFullTextTooltip.js';
8
+ import { VisuallyHidden } from '../visually-hidden/visually-hidden.js';
9
+
10
+ const RadioTilesOption = function RadioTilesOption({
11
+ children,
12
+ value,
13
+ label,
14
+ icon,
15
+ disabled: disabledProp,
16
+ className,
17
+ 'aria-label': ariaLabel
18
+ }) {
19
+ const {
20
+ name,
21
+ selectedValue,
22
+ disabled,
23
+ onChange
24
+ } = useRadioTilesContext();
25
+ const labelRef = useRef(null);
26
+ const {
27
+ Wrapper: Tooltip,
28
+ wrapperProps
29
+ } = useFullTextTooltip({
30
+ ref: labelRef,
31
+ textValue: label
32
+ });
33
+ const isSelected = selectedValue === value;
34
+ const isDisabled = disabled || disabledProp;
35
+ const handleChange = event => {
36
+ if (isDisabled) {
37
+ event.preventDefault();
38
+ return;
39
+ }
40
+ onChange(event);
41
+ };
42
+ const radioTileClassNames = clsx(styles.radioTileOption, {
43
+ [styles.checked]: isSelected,
44
+ [styles.disabled]: isDisabled
45
+ }, className);
46
+ return (
47
+ // @ts-expect-error Fix this type error - DSYS-1597
48
+ jsx(Tooltip, {
49
+ ...wrapperProps,
50
+ children: jsx("div", {
51
+ className: radioTileClassNames,
52
+ children: jsxs("label", {
53
+ children: [jsx(VisuallyHidden, {
54
+ children: jsx("input", {
55
+ checked: isSelected,
56
+ disabled: isDisabled,
57
+ name: name,
58
+ onChange: handleChange,
59
+ type: "radio",
60
+ value: value
61
+ })
62
+ }), icon && jsx("div", {
63
+ className: styles.icon,
64
+ children: /*#__PURE__*/React__default.cloneElement(icon, {
65
+ 'aria-label': label || ariaLabel
66
+ })
67
+ }), children && /*#__PURE__*/React__default.cloneElement(children, {
68
+ 'aria-label': label || ariaLabel
69
+ }), label && jsx(Text, {
70
+ ref: labelRef,
71
+ as: "p",
72
+ className: styles.radioTileLabel,
73
+ variant: "bodyDefault",
74
+ children: label
75
+ })]
76
+ })
77
+ })
78
+ })
79
+ );
80
+ };
81
+
82
+ export { RadioTilesOption };
@@ -0,0 +1,4 @@
1
+ import '../index.css';
2
+ var styles = {"radioTileOption":"bp_radio_tiles_option_module_radioTileOption--db24b","icon":"bp_radio_tiles_option_module_icon--db24b","disabled":"bp_radio_tiles_option_module_disabled--db24b","checked":"bp_radio_tiles_option_module_checked--db24b","radioTileLabel":"bp_radio_tiles_option_module_radioTileLabel--db24b"};
3
+
4
+ export { styles as default };
@@ -0,0 +1,9 @@
1
+ import { type ChangeEvent } from 'react';
2
+ export interface RadioTilesContextValue {
3
+ name?: string;
4
+ disabled?: boolean;
5
+ selectedValue: string | undefined | null;
6
+ onChange: (event: ChangeEvent<HTMLInputElement>) => void;
7
+ }
8
+ export declare const RadioTilesContext: import("react").Context<RadioTilesContextValue | null>;
9
+ export declare const useRadioTilesContext: () => RadioTilesContextValue;
@@ -0,0 +1,12 @@
1
+ import { createContext, useContext } from 'react';
2
+
3
+ const RadioTilesContext = /*#__PURE__*/createContext(null);
4
+ const useRadioTilesContext = () => {
5
+ const context = useContext(RadioTilesContext);
6
+ if (!context) {
7
+ throw new Error('useRadioTilesContext cannot be used outside the RadioTilesContext.Provider');
8
+ }
9
+ return context;
10
+ };
11
+
12
+ export { RadioTilesContext, useRadioTilesContext };
@@ -0,0 +1,4 @@
1
+ import { type RadioTilesProps } from './types';
2
+ export declare const RadioTiles: (<T extends string | null = string>({ children, name, value, variant, columns, disabled, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, onChange, }: RadioTilesProps<T>) => import("react/jsx-runtime").JSX.Element) & {
3
+ Option: <T_1 extends string>({ children, value, label, icon, disabled: disabledProp, className, "aria-label": ariaLabel, }: import("./types").RadioTilesOptionProps<T_1>) => import("react/jsx-runtime").JSX.Element;
4
+ };
@@ -0,0 +1,48 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { useMemo } from 'react';
3
+ import clsx from 'clsx';
4
+ import { RadioTilesOption } from './radio-tiles-option.js';
5
+ import { RadioTilesContext } from './radio-tiles.context.js';
6
+ import styles from './radio-tiles.module.js';
7
+
8
+ const RadioTilesRoot = ({
9
+ children,
10
+ name,
11
+ value,
12
+ variant = 'default',
13
+ columns,
14
+ disabled,
15
+ 'aria-label': ariaLabel,
16
+ 'aria-labelledby': ariaLabelledBy,
17
+ onChange
18
+ }) => {
19
+ const containerStyles = {
20
+ '--columns': columns
21
+ };
22
+ const containerClassNames = clsx(styles.radioTiles, {
23
+ [styles.hasColumns]: Number(columns) > 0,
24
+ [variant === 'compact' ? styles.compact : styles.default]: true
25
+ });
26
+ const contextValue = useMemo(() => ({
27
+ name,
28
+ selectedValue: value,
29
+ disabled,
30
+ onChange
31
+ }), [name, value, disabled, onChange]);
32
+ return jsx(RadioTilesContext.Provider, {
33
+ value: contextValue,
34
+ children: jsx("div", {
35
+ "aria-label": ariaLabel,
36
+ "aria-labelledby": ariaLabelledBy,
37
+ className: containerClassNames,
38
+ role: "radiogroup",
39
+ style: containerStyles,
40
+ children: children
41
+ })
42
+ });
43
+ };
44
+ const RadioTiles = Object.assign(RadioTilesRoot, {
45
+ Option: RadioTilesOption
46
+ });
47
+
48
+ export { RadioTiles };
@@ -0,0 +1,4 @@
1
+ import '../index.css';
2
+ var styles = {"radioTiles":"bp_radio_tiles_module_radioTiles--94f93","hasColumns":"bp_radio_tiles_module_hasColumns--94f93","default":"bp_radio_tiles_module_default--94f93","compact":"bp_radio_tiles_module_compact--94f93"};
3
+
4
+ export { styles as default };
@@ -0,0 +1,48 @@
1
+ import { type ChangeEvent, type CSSProperties, type ReactElement, type SVGProps } from 'react';
2
+ /**
3
+ * RadioTilesProps
4
+ */
5
+ interface WithAriaLabel {
6
+ 'aria-label': string;
7
+ 'aria-labelledby'?: never;
8
+ }
9
+ interface WithAriaLabelledBy {
10
+ 'aria-label'?: never;
11
+ 'aria-labelledby': string;
12
+ }
13
+ export type RadioTilesProps<T extends string | null = string | null> = {
14
+ children: ReactElement<RadioTilesOptionProps<NonNullable<T>>>[];
15
+ name?: string;
16
+ value?: T;
17
+ gap?: string;
18
+ columns?: number;
19
+ variant?: 'default' | 'compact';
20
+ disabled?: boolean;
21
+ onChange: (event: ChangeEvent<HTMLInputElement>) => void;
22
+ } & (WithAriaLabel | WithAriaLabelledBy);
23
+ /**
24
+ * RadioTilesOptionProps
25
+ */
26
+ interface WithIcon {
27
+ icon?: ReactElement<SVGProps<SVGSVGElement>>;
28
+ children?: never;
29
+ }
30
+ interface WithoutIcon {
31
+ icon?: never;
32
+ children: ReactElement;
33
+ }
34
+ interface WithLabel {
35
+ label: string;
36
+ 'aria-label'?: never;
37
+ }
38
+ interface WithoutLabel {
39
+ label?: never;
40
+ 'aria-label': string;
41
+ }
42
+ export type RadioTilesOptionProps<T extends string = string> = {
43
+ value: T;
44
+ disabled?: boolean;
45
+ className?: string;
46
+ style?: CSSProperties;
47
+ } & (WithIcon | WithoutIcon) & (WithLabel | WithoutLabel);
48
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/blueprint-web",
3
- "version": "8.3.1",
3
+ "version": "8.4.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": "bef9db208515d53f0fb75d387d1740b389f6f753",
66
+ "gitHead": "057276bec06cb3038669d8e87106aaa2bd86c718",
67
67
  "module": "lib-esm/index.js",
68
68
  "main": "lib-esm/index.js",
69
69
  "exports": {