@atlaskit/editor-toolbar 0.5.1 → 0.6.1
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/CHANGELOG.md +20 -0
- package/dist/cjs/index.js +20 -0
- package/dist/cjs/ui/ResponsiveContainer.compiled.css +12 -0
- package/dist/cjs/ui/ResponsiveContainer.js +71 -0
- package/dist/cjs/ui/Show.js +43 -0
- package/dist/cjs/ui/Toolbar.compiled.css +2 -0
- package/dist/cjs/ui/Toolbar.js +18 -4
- package/dist/cjs/ui/ToolbarButton.js +2 -1
- package/dist/cjs/ui/ToolbarButtonGroup.js +2 -1
- package/dist/cjs/ui/ToolbarDropdownItem.js +8 -1
- package/dist/cjs/ui/ToolbarDropdownMenu.compiled.css +3 -1
- package/dist/cjs/ui/ToolbarDropdownMenu.js +34 -21
- package/dist/cjs/ui/ToolbarDropdownMenuContext.js +10 -2
- package/dist/cjs/ui/ToolbarSection.js +2 -1
- package/dist/es2019/index.js +3 -1
- package/dist/es2019/ui/ResponsiveContainer.compiled.css +12 -0
- package/dist/es2019/ui/ResponsiveContainer.js +65 -0
- package/dist/es2019/ui/Show.js +36 -0
- package/dist/es2019/ui/Toolbar.compiled.css +2 -0
- package/dist/es2019/ui/Toolbar.js +18 -4
- package/dist/es2019/ui/ToolbarButton.js +2 -1
- package/dist/es2019/ui/ToolbarButtonGroup.js +2 -1
- package/dist/es2019/ui/ToolbarDropdownItem.js +8 -1
- package/dist/es2019/ui/ToolbarDropdownMenu.compiled.css +3 -1
- package/dist/es2019/ui/ToolbarDropdownMenu.js +33 -22
- package/dist/es2019/ui/ToolbarDropdownMenuContext.js +7 -1
- package/dist/es2019/ui/ToolbarSection.js +2 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/ui/ResponsiveContainer.compiled.css +12 -0
- package/dist/esm/ui/ResponsiveContainer.js +64 -0
- package/dist/esm/ui/Show.js +35 -0
- package/dist/esm/ui/Toolbar.compiled.css +2 -0
- package/dist/esm/ui/Toolbar.js +18 -4
- package/dist/esm/ui/ToolbarButton.js +2 -1
- package/dist/esm/ui/ToolbarButtonGroup.js +2 -1
- package/dist/esm/ui/ToolbarDropdownItem.js +8 -1
- package/dist/esm/ui/ToolbarDropdownMenu.compiled.css +3 -1
- package/dist/esm/ui/ToolbarDropdownMenu.js +34 -21
- package/dist/esm/ui/ToolbarDropdownMenuContext.js +9 -1
- package/dist/esm/ui/ToolbarSection.js +2 -1
- package/dist/types/index.d.ts +3 -1
- package/dist/types/ui/ResponsiveContainer.d.ts +54 -0
- package/dist/types/ui/Show.d.ts +22 -0
- package/dist/types/ui/Toolbar.d.ts +3 -1
- package/dist/types/ui/ToolbarDropdownMenu.d.ts +5 -1
- package/dist/types/ui/ToolbarDropdownMenuContext.d.ts +3 -1
- package/dist/types-ts4.5/index.d.ts +3 -1
- package/dist/types-ts4.5/ui/ResponsiveContainer.d.ts +54 -0
- package/dist/types-ts4.5/ui/Show.d.ts +22 -0
- package/dist/types-ts4.5/ui/Toolbar.d.ts +3 -1
- package/dist/types-ts4.5/ui/ToolbarDropdownMenu.d.ts +5 -1
- package/dist/types-ts4.5/ui/ToolbarDropdownMenuContext.d.ts +3 -1
- package/package.json +3 -2
|
@@ -17,7 +17,8 @@ export const ToolbarButtonGroup = ({
|
|
|
17
17
|
const LastChild = items.at(-1);
|
|
18
18
|
const middleChildren = items.slice(1, -1);
|
|
19
19
|
return /*#__PURE__*/React.createElement(Box, {
|
|
20
|
-
xcss: styles.container
|
|
20
|
+
xcss: styles.container,
|
|
21
|
+
"data-toolbar-component": "button-group"
|
|
21
22
|
}, items.length <= 1 ? children : /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
22
23
|
className: ax([styles.firstChild])
|
|
23
24
|
}, FirstChild), middleChildren, /*#__PURE__*/React.createElement("div", {
|
|
@@ -6,6 +6,7 @@ import { cx } from '@atlaskit/css';
|
|
|
6
6
|
import { DropdownItem } from '@atlaskit/dropdown-menu';
|
|
7
7
|
import { Pressable } from '@atlaskit/primitives/compiled';
|
|
8
8
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
9
|
+
import { useToolbarDropdownMenuNew } from './ToolbarDropdownMenuContext';
|
|
9
10
|
const styles = {
|
|
10
11
|
toolbarDropdownItem: "_18zrpxbi _1rjcu2gc _1e0c1txw _kqswh2mm _bfhksm61 _1bsb1osq _1tke14no _1ul9163w _1basglpi _1ah31i6y",
|
|
11
12
|
enabled: "_irr3166n _1di61dty",
|
|
@@ -48,8 +49,14 @@ export const ToolbarDropdownItem = ({
|
|
|
48
49
|
target,
|
|
49
50
|
rel
|
|
50
51
|
}) => {
|
|
52
|
+
const parentContext = useToolbarDropdownMenuNew();
|
|
51
53
|
return /*#__PURE__*/React.createElement(DropdownItem, {
|
|
52
|
-
onClick:
|
|
54
|
+
onClick: expValEquals('platform_editor_toolbar_aifc_patch_1', 'isEnabled', true) ? e => {
|
|
55
|
+
if (!hasNestedDropdownMenu) {
|
|
56
|
+
parentContext === null || parentContext === void 0 ? void 0 : parentContext.closeMenu();
|
|
57
|
+
}
|
|
58
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
59
|
+
} : onClick,
|
|
53
60
|
elemBefore: elemBefore,
|
|
54
61
|
elemAfter: elemAfter,
|
|
55
62
|
isSelected: isSelected,
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
._1mou1b66{margin-block:var(--ds-space-050,4px)}._18l8n7od [data-section]:first-of-type{border-block-start:unset}
|
|
2
|
+
._1mou1b66{margin-block:var(--ds-space-050,4px)}._18l8n7od [data-section]:first-of-type{border-block-start:unset}
|
|
3
|
+
._18m91wug{overflow-y:auto}
|
|
4
|
+
._c71lnklw{max-height:20pc}
|
|
@@ -2,14 +2,17 @@
|
|
|
2
2
|
import "./ToolbarDropdownMenu.compiled.css";
|
|
3
3
|
import { ax, ix } from "@compiled/react/runtime";
|
|
4
4
|
import React, { useCallback } from 'react';
|
|
5
|
+
import { cx } from '@compiled/react';
|
|
5
6
|
import DropdownMenu from '@atlaskit/dropdown-menu';
|
|
7
|
+
import { Box } from '@atlaskit/primitives/compiled';
|
|
6
8
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
9
|
import { useToolbarUI } from '../hooks/ui-context';
|
|
8
10
|
import { ToolbarButton } from './ToolbarButton';
|
|
9
11
|
import { ToolbarDropdownMenuProvider, useToolbarDropdownMenu } from './ToolbarDropdownMenuContext';
|
|
10
12
|
const styles = {
|
|
11
13
|
sectionMargin: "_1mou1b66",
|
|
12
|
-
firstSectionSeparator: "_18l8n7od"
|
|
14
|
+
firstSectionSeparator: "_18l8n7od",
|
|
15
|
+
scrollContainer: "_c71lnklw _18m91wug"
|
|
13
16
|
};
|
|
14
17
|
const ToolbarDropdownMenuContent = ({
|
|
15
18
|
iconBefore,
|
|
@@ -21,24 +24,20 @@ const ToolbarDropdownMenuContent = ({
|
|
|
21
24
|
const {
|
|
22
25
|
onDropdownOpenChanged
|
|
23
26
|
} = useToolbarUI();
|
|
24
|
-
const
|
|
25
|
-
closeMenu,
|
|
26
|
-
isOpen,
|
|
27
|
-
openMenu
|
|
28
|
-
} = useToolbarDropdownMenu();
|
|
27
|
+
const menuContext = useToolbarDropdownMenu();
|
|
29
28
|
const handleOpenChange = useCallback(args => {
|
|
30
29
|
onDropdownOpenChanged(args);
|
|
31
30
|
if (!args.isOpen) {
|
|
32
|
-
closeMenu();
|
|
31
|
+
menuContext === null || menuContext === void 0 ? void 0 : menuContext.closeMenu();
|
|
33
32
|
}
|
|
34
|
-
}, [
|
|
33
|
+
}, [menuContext, onDropdownOpenChanged]);
|
|
35
34
|
const handleClick = useCallback(() => {
|
|
36
|
-
if (!isOpen) {
|
|
37
|
-
openMenu();
|
|
35
|
+
if (!(menuContext !== null && menuContext !== void 0 && menuContext.isOpen)) {
|
|
36
|
+
menuContext === null || menuContext === void 0 ? void 0 : menuContext.openMenu();
|
|
38
37
|
} else {
|
|
39
|
-
closeMenu();
|
|
38
|
+
menuContext === null || menuContext === void 0 ? void 0 : menuContext.closeMenu();
|
|
40
39
|
}
|
|
41
|
-
}, [
|
|
40
|
+
}, [menuContext]);
|
|
42
41
|
return /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
43
42
|
trigger: triggerProps => /*#__PURE__*/React.createElement(ToolbarButton, {
|
|
44
43
|
ref: triggerProps.triggerRef,
|
|
@@ -58,7 +57,7 @@ const ToolbarDropdownMenuContent = ({
|
|
|
58
57
|
label: label
|
|
59
58
|
}),
|
|
60
59
|
onOpenChange: handleOpenChange,
|
|
61
|
-
isOpen: isOpen
|
|
60
|
+
isOpen: menuContext === null || menuContext === void 0 ? void 0 : menuContext.isOpen
|
|
62
61
|
}, children);
|
|
63
62
|
};
|
|
64
63
|
export const ToolbarDropdownMenu = ({
|
|
@@ -67,14 +66,26 @@ export const ToolbarDropdownMenu = ({
|
|
|
67
66
|
isDisabled,
|
|
68
67
|
testId,
|
|
69
68
|
label,
|
|
70
|
-
hasSectionMargin = true
|
|
69
|
+
hasSectionMargin = true,
|
|
70
|
+
enableMaxHeight = false
|
|
71
71
|
}) => {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
72
|
+
if (expValEquals('platform_editor_toolbar_aifc_patch_1', 'isEnabled', true)) {
|
|
73
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownMenuContent, {
|
|
74
|
+
iconBefore: iconBefore,
|
|
75
|
+
isDisabled: isDisabled,
|
|
76
|
+
testId: testId,
|
|
77
|
+
label: label
|
|
78
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
79
|
+
xcss: cx(hasSectionMargin && styles.sectionMargin, enableMaxHeight && styles.scrollContainer, expValEquals('platform_editor_toolbar_migrate_loom', 'isEnabled', true) && styles.firstSectionSeparator)
|
|
80
|
+
}, children));
|
|
81
|
+
} else {
|
|
82
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownMenuProvider, null, /*#__PURE__*/React.createElement(ToolbarDropdownMenuContent, {
|
|
83
|
+
iconBefore: iconBefore,
|
|
84
|
+
isDisabled: isDisabled,
|
|
85
|
+
testId: testId,
|
|
86
|
+
label: label
|
|
87
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
88
|
+
className: ax([hasSectionMargin && styles.sectionMargin, expValEquals('platform_editor_toolbar_migrate_loom', 'isEnabled', true) && styles.firstSectionSeparator])
|
|
89
|
+
}, children)));
|
|
90
|
+
}
|
|
80
91
|
};
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import React, { createContext, useContext, useState } from 'react';
|
|
2
|
+
import { conditionalHooksFactory } from '@atlaskit/platform-feature-flags-react';
|
|
3
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
2
4
|
const ToolbarDropdownMenuContext = /*#__PURE__*/createContext(undefined);
|
|
3
|
-
export const
|
|
5
|
+
export const useToolbarDropdownMenuOld = () => {
|
|
4
6
|
const context = useContext(ToolbarDropdownMenuContext);
|
|
5
7
|
if (!context) {
|
|
6
8
|
throw new Error('useToolbarDropdownMenu must be used within ToolbarDropdownMenuProvider');
|
|
7
9
|
}
|
|
8
10
|
return context;
|
|
9
11
|
};
|
|
12
|
+
export const useToolbarDropdownMenuNew = () => {
|
|
13
|
+
return useContext(ToolbarDropdownMenuContext);
|
|
14
|
+
};
|
|
15
|
+
export const useToolbarDropdownMenu = conditionalHooksFactory(() => expValEquals('platform_editor_toolbar_aifc_patch_1', 'isEnabled', true), useToolbarDropdownMenuNew, useToolbarDropdownMenuOld);
|
|
10
16
|
export const ToolbarDropdownMenuProvider = ({
|
|
11
17
|
children
|
|
12
18
|
}) => {
|
|
@@ -15,7 +15,8 @@ export const ToolbarSection = ({
|
|
|
15
15
|
}) => {
|
|
16
16
|
return /*#__PURE__*/React.createElement(Box, {
|
|
17
17
|
xcss: cx(styles.container),
|
|
18
|
-
testId: testId
|
|
18
|
+
testId: testId,
|
|
19
|
+
"data-toolbar-component": "section"
|
|
19
20
|
}, hasSeparator && /*#__PURE__*/React.createElement("div", {
|
|
20
21
|
className: ax(["_195gu2gc _4t3igktf _1bsbt94y _bfhkmuej"])
|
|
21
22
|
}), children);
|
package/dist/esm/index.js
CHANGED
|
@@ -10,7 +10,9 @@ export { ToolbarKeyboardShortcutHint } from './ui/ToolbarKeyboardShortcutHint';
|
|
|
10
10
|
export { ToolbarSection } from './ui/ToolbarSection';
|
|
11
11
|
export { ToolbarTooltip } from './ui/ToolbarTooltip';
|
|
12
12
|
export { ToolbarColorSwatch } from './ui/ToolbarColorSwatch';
|
|
13
|
-
export { useToolbarDropdownMenu } from './ui/ToolbarDropdownMenuContext';
|
|
13
|
+
export { useToolbarDropdownMenu, ToolbarDropdownMenuProvider } from './ui/ToolbarDropdownMenuContext';
|
|
14
|
+
export { ResponsiveContainer } from './ui/ResponsiveContainer';
|
|
15
|
+
export { Show } from './ui/Show';
|
|
14
16
|
export { AIAdjustLengthIcon } from './ui/icons/AIAdjustLengthIcon';
|
|
15
17
|
export { AIChatIcon } from './ui/icons/AIChatIcon';
|
|
16
18
|
export { AIBriefcaseIcon } from './ui/icons/AIProfessionalIcon';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
._1bsb1osq{width:100%}
|
|
2
|
+
._1bx91ule .show-above-lg, ._1ehg1ule .show-above-md, ._1onx1ule .show-above-sm, ._1xt01ule .show-above-xl{display:block}
|
|
3
|
+
._1f38ptqj{container-name:toolbar-container}
|
|
4
|
+
._7cca15wb{container-type:inline-size}
|
|
5
|
+
._zg9wglyw .show-below-lg, ._1a2cglyw .show-below-md, ._sum2glyw .show-below-sm, ._1vtcglyw .show-below-xl{display:none}
|
|
6
|
+
@container toolbar-container (max-width: 1024px){._t3a8glyw .show-above-xl{display:none}._1x5z1ule .show-below-xl{display:block}}
|
|
7
|
+
@container toolbar-container (max-width: 210px){._48suglyw .show-above-sm{display:none}._j2p61ule .show-below-sm{display:block}}
|
|
8
|
+
@container toolbar-container (max-width: 350px){._1vg1glyw .show-above-md{display:none}._1ei51ule .show-below-md{display:block}}
|
|
9
|
+
@container toolbar-container (max-width: 410px){._6nrqglyw .show-above-sm{display:none}._1fq21ule .show-below-sm{display:block}}
|
|
10
|
+
@container toolbar-container (max-width: 476px){._1ireglyw .show-above-md{display:none}._zy2m1ule .show-below-md{display:block}}
|
|
11
|
+
@container toolbar-container (max-width: 500px){._pjeuglyw .show-above-lg{display:none}._3bio1ule .show-below-lg{display:block}}
|
|
12
|
+
@container toolbar-container (max-width: 768px){._hfbeglyw .show-above-lg{display:none}._gw6d1ule .show-below-lg{display:block}}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/* ResponsiveContainer.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
/* eslint-disable @atlaskit/ui-styling-standard/no-unsafe-selectors */
|
|
3
|
+
/* eslint-disable @atlaskit/ui-styling-standard/no-container-queries */
|
|
4
|
+
/* eslint-disable @atlaskit/ui-styling-standard/no-nested-selectors */
|
|
5
|
+
import "./ResponsiveContainer.compiled.css";
|
|
6
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { cx } from '@atlaskit/css';
|
|
9
|
+
import { Box } from '@atlaskit/primitives/compiled';
|
|
10
|
+
var styles = {
|
|
11
|
+
responsiveContainer: "_1bsb1osq _7cca15wb _1f38ptqj _1bx91ule _1ehg1ule _1onx1ule _1xt01ule _zg9wglyw _1a2cglyw _sum2glyw _1vtcglyw",
|
|
12
|
+
responsiveRules: "_t3a8glyw _1x5z1ule _6nrqglyw _1fq21ule _1ireglyw _zy2m1ule _hfbeglyw _gw6d1ule",
|
|
13
|
+
responsiveRulesReduced: "_t3a8glyw _1x5z1ule _48suglyw _j2p61ule _1vg1glyw _1ei51ule _pjeuglyw _3bio1ule"
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* A responsive container that enables container query-based responsive design using CSS container queries.
|
|
17
|
+
* This component establishes a containment context named 'toolbar-container' that child components can
|
|
18
|
+
* reference for responsive behavior based on the container's width rather than the viewport width.
|
|
19
|
+
*
|
|
20
|
+
* The container defines breakpoints at:
|
|
21
|
+
* - sm: 410px
|
|
22
|
+
* - md: 476px
|
|
23
|
+
* - lg: 768px
|
|
24
|
+
* - xl: 1024px
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* Basic usage with Show component for responsive visibility:
|
|
28
|
+
* ```tsx
|
|
29
|
+
* <ResponsiveContainer>
|
|
30
|
+
* <Show above="md">
|
|
31
|
+
* <Button>Only visible when container is wider than 476px</Button>
|
|
32
|
+
* </Show>
|
|
33
|
+
* <Show below="sm">
|
|
34
|
+
* <Icon>Only visible when container is narrower than 410px</Icon>
|
|
35
|
+
* </Show>
|
|
36
|
+
* </ResponsiveContainer>
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* Combining multiple Show components for different breakpoints:
|
|
41
|
+
* ```tsx
|
|
42
|
+
* <ResponsiveContainer>
|
|
43
|
+
* <Show above="lg">
|
|
44
|
+
* <FullToolbar />
|
|
45
|
+
* </Show>
|
|
46
|
+
* <Show below="lg" above="md">
|
|
47
|
+
* <CompactToolbar />
|
|
48
|
+
* </Show>
|
|
49
|
+
* <Show below="md">
|
|
50
|
+
* <MinimalToolbar />
|
|
51
|
+
* </Show>
|
|
52
|
+
* </ResponsiveContainer>
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @param children - React nodes to render within the responsive container context
|
|
56
|
+
* @returns A Box component with container query styles applied
|
|
57
|
+
*/
|
|
58
|
+
export var ResponsiveContainer = function ResponsiveContainer(_ref) {
|
|
59
|
+
var children = _ref.children,
|
|
60
|
+
reducedBreakpoints = _ref.reducedBreakpoints;
|
|
61
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
62
|
+
xcss: cx(styles.responsiveContainer, reducedBreakpoints ? styles.responsiveRulesReduced : styles.responsiveRules)
|
|
63
|
+
}, children);
|
|
64
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/* eslint-disable @atlaskit/ui-styling-standard/no-classname-prop */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Generate a className based on the breakpoints provided.
|
|
5
|
+
*
|
|
6
|
+
* **Warning** - must much classnames defined in ResponsiveContainer.tsx
|
|
7
|
+
* @param above - The breakpoint to show the element above.
|
|
8
|
+
* @param below - The breakpoint to show the element below.
|
|
9
|
+
* @returns The className to apply to the element.
|
|
10
|
+
*/
|
|
11
|
+
var generateClassName = function generateClassName(above, below) {
|
|
12
|
+
if (above) {
|
|
13
|
+
return "show-above-".concat(above);
|
|
14
|
+
}
|
|
15
|
+
if (below) {
|
|
16
|
+
return "show-below-".concat(below);
|
|
17
|
+
}
|
|
18
|
+
return;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Conditionally renders children based on responsive breakpoints.
|
|
23
|
+
* Use either `above` or `below` prop to control visibility.
|
|
24
|
+
*
|
|
25
|
+
* *note:* This component must be an ancestor of a ResponsiveContainer component to work correctly
|
|
26
|
+
* as it relies on CSS container queries.
|
|
27
|
+
*/
|
|
28
|
+
export var Show = function Show(_ref) {
|
|
29
|
+
var children = _ref.children,
|
|
30
|
+
above = _ref.above,
|
|
31
|
+
below = _ref.below;
|
|
32
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
33
|
+
className: generateClassName(above, below)
|
|
34
|
+
}, children);
|
|
35
|
+
};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
._2rko1qi0{border-radius:var(--ds-radius-medium,6px)}
|
|
3
3
|
._zulp1b66{gap:var(--ds-space-050,4px)}._16qs1cd0{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #091e4226,0 0 1px #091e424f)}
|
|
4
|
+
._18shglyw [class*=show-above-]:not(:has([data-toolbar-component=section] [data-toolbar-component=button],[data-toolbar-component=button-group] [data-toolbar-component=button])), ._ze7rglyw [class*=show-below-]:not(:has([data-toolbar-component=section] [data-toolbar-component=button],[data-toolbar-component=button-group] [data-toolbar-component=button])){display:none}
|
|
4
5
|
._19bv1b66{padding-left:var(--ds-space-050,4px)}
|
|
5
6
|
._1e0c1txw{display:flex}
|
|
6
7
|
._1tkezwfg{min-height:2pc}
|
|
7
8
|
._4cvr1h6o{align-items:center}
|
|
8
9
|
._4t3i14no{height:36px}
|
|
9
10
|
._bfhkvuon{background-color:var(--ds-surface,#fff)}
|
|
11
|
+
._fy9oglyw [data-toolbar-component=section]:not(:has([data-toolbar-component=button])){display:none}
|
|
10
12
|
._u5f31b66{padding-right:var(--ds-space-050,4px)}
|
package/dist/esm/ui/Toolbar.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
/* Toolbar.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
/* eslint-disable @atlaskit/ui-styling-standard/no-unsafe-selectors */
|
|
3
|
+
/* eslint-disable @atlaskit/ui-styling-standard/no-nested-selectors */
|
|
2
4
|
import "./Toolbar.compiled.css";
|
|
3
5
|
import { ax, ix } from "@compiled/react/runtime";
|
|
4
6
|
import React from 'react';
|
|
5
7
|
import { cx } from '@atlaskit/css';
|
|
6
8
|
import { Box } from '@atlaskit/primitives/compiled';
|
|
9
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
10
|
+
import { ResponsiveContainer } from './ResponsiveContainer';
|
|
7
11
|
var styles = {
|
|
8
12
|
toolbarBase: "_2rko1qi0 _zulp1b66 _bfhkvuon _1e0c1txw _4cvr1h6o",
|
|
9
13
|
toolbar: "_4t3i14no _u5f31b66 _19bv1b66 _16qs1cd0",
|
|
10
|
-
primaryToolbar: "_bfhkvuon _1tkezwfg"
|
|
14
|
+
primaryToolbar: "_bfhkvuon _1tkezwfg",
|
|
15
|
+
hiddenSelectors: "_fy9oglyw _18shglyw _ze7rglyw"
|
|
11
16
|
};
|
|
12
17
|
/**
|
|
13
18
|
* A simple component representing a toolbar with box shadows - used to represent a secondary/floating toolbar
|
|
@@ -16,18 +21,27 @@ export var Toolbar = function Toolbar(_ref) {
|
|
|
16
21
|
var children = _ref.children,
|
|
17
22
|
label = _ref.label;
|
|
18
23
|
return /*#__PURE__*/React.createElement(Box, {
|
|
19
|
-
xcss: cx(styles.toolbarBase, styles.toolbar),
|
|
24
|
+
xcss: cx(styles.toolbarBase, styles.toolbar, expValEquals('platform_editor_toolbar_aifc_responsive', 'isEnabled', true) && styles.hiddenSelectors),
|
|
20
25
|
role: "toolbar",
|
|
21
26
|
"aria-label": label
|
|
22
27
|
}, children);
|
|
23
28
|
};
|
|
24
|
-
|
|
25
29
|
/**
|
|
26
30
|
* A simple component representing a toolbar without box shadows - used to represent a primary toolbar
|
|
27
31
|
*/
|
|
28
32
|
export var PrimaryToolbar = function PrimaryToolbar(_ref2) {
|
|
29
33
|
var children = _ref2.children,
|
|
30
|
-
label = _ref2.label
|
|
34
|
+
label = _ref2.label,
|
|
35
|
+
reducedBreakpoints = _ref2.reducedBreakpoints;
|
|
36
|
+
if (expValEquals('platform_editor_toolbar_aifc_responsive', 'isEnabled', true)) {
|
|
37
|
+
return /*#__PURE__*/React.createElement(ResponsiveContainer, {
|
|
38
|
+
reducedBreakpoints: reducedBreakpoints
|
|
39
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
40
|
+
xcss: cx(styles.toolbarBase, styles.primaryToolbar, styles.hiddenSelectors),
|
|
41
|
+
role: "toolbar",
|
|
42
|
+
"aria-label": label
|
|
43
|
+
}, children));
|
|
44
|
+
}
|
|
31
45
|
return /*#__PURE__*/React.createElement(Box, {
|
|
32
46
|
xcss: cx(styles.toolbarBase, styles.primaryToolbar),
|
|
33
47
|
role: "toolbar",
|
|
@@ -16,7 +16,8 @@ export var ToolbarButtonGroup = function ToolbarButtonGroup(_ref) {
|
|
|
16
16
|
var LastChild = items.at(-1);
|
|
17
17
|
var middleChildren = items.slice(1, -1);
|
|
18
18
|
return /*#__PURE__*/React.createElement(Box, {
|
|
19
|
-
xcss: styles.container
|
|
19
|
+
xcss: styles.container,
|
|
20
|
+
"data-toolbar-component": "button-group"
|
|
20
21
|
}, items.length <= 1 ? children : /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
21
22
|
className: ax([styles.firstChild])
|
|
22
23
|
}, FirstChild), middleChildren, /*#__PURE__*/React.createElement("div", {
|
|
@@ -6,6 +6,7 @@ import { cx } from '@atlaskit/css';
|
|
|
6
6
|
import { DropdownItem } from '@atlaskit/dropdown-menu';
|
|
7
7
|
import { Pressable } from '@atlaskit/primitives/compiled';
|
|
8
8
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
9
|
+
import { useToolbarDropdownMenuNew } from './ToolbarDropdownMenuContext';
|
|
9
10
|
var styles = {
|
|
10
11
|
toolbarDropdownItem: "_18zrpxbi _1rjcu2gc _1e0c1txw _kqswh2mm _bfhksm61 _1bsb1osq _1tke14no _1ul9163w _1basglpi _1ah31i6y",
|
|
11
12
|
enabled: "_irr3166n _1di61dty",
|
|
@@ -48,8 +49,14 @@ export var ToolbarDropdownItem = function ToolbarDropdownItem(_ref2) {
|
|
|
48
49
|
href = _ref2.href,
|
|
49
50
|
target = _ref2.target,
|
|
50
51
|
rel = _ref2.rel;
|
|
52
|
+
var parentContext = useToolbarDropdownMenuNew();
|
|
51
53
|
return /*#__PURE__*/React.createElement(DropdownItem, {
|
|
52
|
-
onClick:
|
|
54
|
+
onClick: expValEquals('platform_editor_toolbar_aifc_patch_1', 'isEnabled', true) ? function (e) {
|
|
55
|
+
if (!hasNestedDropdownMenu) {
|
|
56
|
+
parentContext === null || parentContext === void 0 || parentContext.closeMenu();
|
|
57
|
+
}
|
|
58
|
+
onClick === null || onClick === void 0 || onClick(e);
|
|
59
|
+
} : onClick,
|
|
53
60
|
elemBefore: elemBefore,
|
|
54
61
|
elemAfter: elemAfter,
|
|
55
62
|
isSelected: isSelected,
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
._1mou1b66{margin-block:var(--ds-space-050,4px)}._18l8n7od [data-section]:first-of-type{border-block-start:unset}
|
|
2
|
+
._1mou1b66{margin-block:var(--ds-space-050,4px)}._18l8n7od [data-section]:first-of-type{border-block-start:unset}
|
|
3
|
+
._18m91wug{overflow-y:auto}
|
|
4
|
+
._c71lnklw{max-height:20pc}
|
|
@@ -2,14 +2,17 @@
|
|
|
2
2
|
import "./ToolbarDropdownMenu.compiled.css";
|
|
3
3
|
import { ax, ix } from "@compiled/react/runtime";
|
|
4
4
|
import React, { useCallback } from 'react';
|
|
5
|
+
import { cx } from '@compiled/react';
|
|
5
6
|
import DropdownMenu from '@atlaskit/dropdown-menu';
|
|
7
|
+
import { Box } from '@atlaskit/primitives/compiled';
|
|
6
8
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
9
|
import { useToolbarUI } from '../hooks/ui-context';
|
|
8
10
|
import { ToolbarButton } from './ToolbarButton';
|
|
9
11
|
import { ToolbarDropdownMenuProvider, useToolbarDropdownMenu } from './ToolbarDropdownMenuContext';
|
|
10
12
|
var styles = {
|
|
11
13
|
sectionMargin: "_1mou1b66",
|
|
12
|
-
firstSectionSeparator: "_18l8n7od"
|
|
14
|
+
firstSectionSeparator: "_18l8n7od",
|
|
15
|
+
scrollContainer: "_c71lnklw _18m91wug"
|
|
13
16
|
};
|
|
14
17
|
var ToolbarDropdownMenuContent = function ToolbarDropdownMenuContent(_ref) {
|
|
15
18
|
var iconBefore = _ref.iconBefore,
|
|
@@ -19,23 +22,20 @@ var ToolbarDropdownMenuContent = function ToolbarDropdownMenuContent(_ref) {
|
|
|
19
22
|
label = _ref.label;
|
|
20
23
|
var _useToolbarUI = useToolbarUI(),
|
|
21
24
|
onDropdownOpenChanged = _useToolbarUI.onDropdownOpenChanged;
|
|
22
|
-
var
|
|
23
|
-
closeMenu = _useToolbarDropdownMe.closeMenu,
|
|
24
|
-
isOpen = _useToolbarDropdownMe.isOpen,
|
|
25
|
-
openMenu = _useToolbarDropdownMe.openMenu;
|
|
25
|
+
var menuContext = useToolbarDropdownMenu();
|
|
26
26
|
var handleOpenChange = useCallback(function (args) {
|
|
27
27
|
onDropdownOpenChanged(args);
|
|
28
28
|
if (!args.isOpen) {
|
|
29
|
-
closeMenu();
|
|
29
|
+
menuContext === null || menuContext === void 0 || menuContext.closeMenu();
|
|
30
30
|
}
|
|
31
|
-
}, [
|
|
31
|
+
}, [menuContext, onDropdownOpenChanged]);
|
|
32
32
|
var handleClick = useCallback(function () {
|
|
33
|
-
if (!isOpen) {
|
|
34
|
-
openMenu();
|
|
33
|
+
if (!(menuContext !== null && menuContext !== void 0 && menuContext.isOpen)) {
|
|
34
|
+
menuContext === null || menuContext === void 0 || menuContext.openMenu();
|
|
35
35
|
} else {
|
|
36
|
-
closeMenu();
|
|
36
|
+
menuContext === null || menuContext === void 0 || menuContext.closeMenu();
|
|
37
37
|
}
|
|
38
|
-
}, [
|
|
38
|
+
}, [menuContext]);
|
|
39
39
|
return /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
40
40
|
trigger: function trigger(triggerProps) {
|
|
41
41
|
return /*#__PURE__*/React.createElement(ToolbarButton, {
|
|
@@ -57,7 +57,7 @@ var ToolbarDropdownMenuContent = function ToolbarDropdownMenuContent(_ref) {
|
|
|
57
57
|
});
|
|
58
58
|
},
|
|
59
59
|
onOpenChange: handleOpenChange,
|
|
60
|
-
isOpen: isOpen
|
|
60
|
+
isOpen: menuContext === null || menuContext === void 0 ? void 0 : menuContext.isOpen
|
|
61
61
|
}, children);
|
|
62
62
|
};
|
|
63
63
|
export var ToolbarDropdownMenu = function ToolbarDropdownMenu(_ref2) {
|
|
@@ -67,13 +67,26 @@ export var ToolbarDropdownMenu = function ToolbarDropdownMenu(_ref2) {
|
|
|
67
67
|
testId = _ref2.testId,
|
|
68
68
|
label = _ref2.label,
|
|
69
69
|
_ref2$hasSectionMargi = _ref2.hasSectionMargin,
|
|
70
|
-
hasSectionMargin = _ref2$hasSectionMargi === void 0 ? true : _ref2$hasSectionMargi
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
70
|
+
hasSectionMargin = _ref2$hasSectionMargi === void 0 ? true : _ref2$hasSectionMargi,
|
|
71
|
+
_ref2$enableMaxHeight = _ref2.enableMaxHeight,
|
|
72
|
+
enableMaxHeight = _ref2$enableMaxHeight === void 0 ? false : _ref2$enableMaxHeight;
|
|
73
|
+
if (expValEquals('platform_editor_toolbar_aifc_patch_1', 'isEnabled', true)) {
|
|
74
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownMenuContent, {
|
|
75
|
+
iconBefore: iconBefore,
|
|
76
|
+
isDisabled: isDisabled,
|
|
77
|
+
testId: testId,
|
|
78
|
+
label: label
|
|
79
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
80
|
+
xcss: cx(hasSectionMargin && styles.sectionMargin, enableMaxHeight && styles.scrollContainer, expValEquals('platform_editor_toolbar_migrate_loom', 'isEnabled', true) && styles.firstSectionSeparator)
|
|
81
|
+
}, children));
|
|
82
|
+
} else {
|
|
83
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownMenuProvider, null, /*#__PURE__*/React.createElement(ToolbarDropdownMenuContent, {
|
|
84
|
+
iconBefore: iconBefore,
|
|
85
|
+
isDisabled: isDisabled,
|
|
86
|
+
testId: testId,
|
|
87
|
+
label: label
|
|
88
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
89
|
+
className: ax([hasSectionMargin && styles.sectionMargin, expValEquals('platform_editor_toolbar_migrate_loom', 'isEnabled', true) && styles.firstSectionSeparator])
|
|
90
|
+
}, children)));
|
|
91
|
+
}
|
|
79
92
|
};
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import React, { createContext, useContext, useState } from 'react';
|
|
3
|
+
import { conditionalHooksFactory } from '@atlaskit/platform-feature-flags-react';
|
|
4
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
5
|
var ToolbarDropdownMenuContext = /*#__PURE__*/createContext(undefined);
|
|
4
|
-
export var
|
|
6
|
+
export var useToolbarDropdownMenuOld = function useToolbarDropdownMenuOld() {
|
|
5
7
|
var context = useContext(ToolbarDropdownMenuContext);
|
|
6
8
|
if (!context) {
|
|
7
9
|
throw new Error('useToolbarDropdownMenu must be used within ToolbarDropdownMenuProvider');
|
|
8
10
|
}
|
|
9
11
|
return context;
|
|
10
12
|
};
|
|
13
|
+
export var useToolbarDropdownMenuNew = function useToolbarDropdownMenuNew() {
|
|
14
|
+
return useContext(ToolbarDropdownMenuContext);
|
|
15
|
+
};
|
|
16
|
+
export var useToolbarDropdownMenu = conditionalHooksFactory(function () {
|
|
17
|
+
return expValEquals('platform_editor_toolbar_aifc_patch_1', 'isEnabled', true);
|
|
18
|
+
}, useToolbarDropdownMenuNew, useToolbarDropdownMenuOld);
|
|
11
19
|
export var ToolbarDropdownMenuProvider = function ToolbarDropdownMenuProvider(_ref) {
|
|
12
20
|
var children = _ref.children;
|
|
13
21
|
var _useState = useState(false),
|
|
@@ -14,7 +14,8 @@ export var ToolbarSection = function ToolbarSection(_ref) {
|
|
|
14
14
|
hasSeparator = _ref.hasSeparator;
|
|
15
15
|
return /*#__PURE__*/React.createElement(Box, {
|
|
16
16
|
xcss: cx(styles.container),
|
|
17
|
-
testId: testId
|
|
17
|
+
testId: testId,
|
|
18
|
+
"data-toolbar-component": "section"
|
|
18
19
|
}, hasSeparator && /*#__PURE__*/React.createElement("div", {
|
|
19
20
|
className: ax(["_195gu2gc _4t3igktf _1bsbt94y _bfhkmuej"])
|
|
20
21
|
}), children);
|
package/dist/types/index.d.ts
CHANGED
|
@@ -9,7 +9,9 @@ export { ToolbarKeyboardShortcutHint } from './ui/ToolbarKeyboardShortcutHint';
|
|
|
9
9
|
export { ToolbarSection } from './ui/ToolbarSection';
|
|
10
10
|
export { ToolbarTooltip } from './ui/ToolbarTooltip';
|
|
11
11
|
export { ToolbarColorSwatch } from './ui/ToolbarColorSwatch';
|
|
12
|
-
export { useToolbarDropdownMenu } from './ui/ToolbarDropdownMenuContext';
|
|
12
|
+
export { useToolbarDropdownMenu, ToolbarDropdownMenuProvider, } from './ui/ToolbarDropdownMenuContext';
|
|
13
|
+
export { ResponsiveContainer } from './ui/ResponsiveContainer';
|
|
14
|
+
export { Show } from './ui/Show';
|
|
13
15
|
export { AIAdjustLengthIcon } from './ui/icons/AIAdjustLengthIcon';
|
|
14
16
|
export { AIChatIcon } from './ui/icons/AIChatIcon';
|
|
15
17
|
export { AIBriefcaseIcon } from './ui/icons/AIProfessionalIcon';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
export type ResponsiveContainerProps = {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
/**
|
|
5
|
+
* This flag changes the breakpoint definitions, which reduces them to cater for smaller editor widths.
|
|
6
|
+
*
|
|
7
|
+
* Usages - for smaller editors such as comments
|
|
8
|
+
*/
|
|
9
|
+
reducedBreakpoints?: boolean;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* A responsive container that enables container query-based responsive design using CSS container queries.
|
|
13
|
+
* This component establishes a containment context named 'toolbar-container' that child components can
|
|
14
|
+
* reference for responsive behavior based on the container's width rather than the viewport width.
|
|
15
|
+
*
|
|
16
|
+
* The container defines breakpoints at:
|
|
17
|
+
* - sm: 410px
|
|
18
|
+
* - md: 476px
|
|
19
|
+
* - lg: 768px
|
|
20
|
+
* - xl: 1024px
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* Basic usage with Show component for responsive visibility:
|
|
24
|
+
* ```tsx
|
|
25
|
+
* <ResponsiveContainer>
|
|
26
|
+
* <Show above="md">
|
|
27
|
+
* <Button>Only visible when container is wider than 476px</Button>
|
|
28
|
+
* </Show>
|
|
29
|
+
* <Show below="sm">
|
|
30
|
+
* <Icon>Only visible when container is narrower than 410px</Icon>
|
|
31
|
+
* </Show>
|
|
32
|
+
* </ResponsiveContainer>
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* Combining multiple Show components for different breakpoints:
|
|
37
|
+
* ```tsx
|
|
38
|
+
* <ResponsiveContainer>
|
|
39
|
+
* <Show above="lg">
|
|
40
|
+
* <FullToolbar />
|
|
41
|
+
* </Show>
|
|
42
|
+
* <Show below="lg" above="md">
|
|
43
|
+
* <CompactToolbar />
|
|
44
|
+
* </Show>
|
|
45
|
+
* <Show below="md">
|
|
46
|
+
* <MinimalToolbar />
|
|
47
|
+
* </Show>
|
|
48
|
+
* </ResponsiveContainer>
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @param children - React nodes to render within the responsive container context
|
|
52
|
+
* @returns A Box component with container query styles applied
|
|
53
|
+
*/
|
|
54
|
+
export declare const ResponsiveContainer: ({ children, reducedBreakpoints }: ResponsiveContainerProps) => React.JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
type Breakpoint = 'sm' | 'md' | 'lg' | 'xl';
|
|
3
|
+
type AboveProp = {
|
|
4
|
+
above: Breakpoint;
|
|
5
|
+
below?: never;
|
|
6
|
+
};
|
|
7
|
+
type BelowProp = {
|
|
8
|
+
above?: never;
|
|
9
|
+
below: Breakpoint;
|
|
10
|
+
};
|
|
11
|
+
type ShowProps = {
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
} & (AboveProp | BelowProp);
|
|
14
|
+
/**
|
|
15
|
+
* Conditionally renders children based on responsive breakpoints.
|
|
16
|
+
* Use either `above` or `below` prop to control visibility.
|
|
17
|
+
*
|
|
18
|
+
* *note:* This component must be an ancestor of a ResponsiveContainer component to work correctly
|
|
19
|
+
* as it relies on CSS container queries.
|
|
20
|
+
*/
|
|
21
|
+
export declare const Show: ({ children, above, below }: ShowProps) => React.JSX.Element;
|
|
22
|
+
export {};
|