@cratis/components 4.39.2 → 4.39.3
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/compat-manifest.json +11 -11
- package/dist/esm/Toolbar/ToolbarButton.d.ts.map +1 -1
- package/dist/esm/Toolbar/ToolbarButton.js +4 -3
- package/dist/esm/Toolbar/ToolbarButton.js.map +1 -1
- package/dist/esm/Toolbar/ToolbarFanOutItem.d.ts.map +1 -1
- package/dist/esm/Toolbar/ToolbarFanOutItem.js +1 -1
- package/dist/esm/Toolbar/ToolbarFanOutItem.js.map +1 -1
- package/dist/esm/Toolbar/ToolbarFolder.d.ts.map +1 -1
- package/dist/esm/Toolbar/ToolbarFolder.js +1 -1
- package/dist/esm/Toolbar/ToolbarFolder.js.map +1 -1
- package/dist/esm/Toolbar/ToolbarGroup.d.ts.map +1 -1
- package/dist/esm/Toolbar/ToolbarGroup.js +1 -1
- package/dist/esm/Toolbar/ToolbarGroup.js.map +1 -1
- package/dist/esm/Toolbar/ToolbarLayout.d.ts.map +1 -1
- package/dist/esm/Toolbar/ToolbarLayout.js +1 -1
- package/dist/esm/Toolbar/ToolbarLayout.js.map +1 -1
- package/dist/esm/Toolbar/ToolbarSection.d.ts.map +1 -1
- package/dist/esm/Toolbar/ToolbarSection.js +1 -1
- package/dist/esm/Toolbar/ToolbarSection.js.map +1 -1
- package/dist/esm/Toolbar/ToolbarSeparator.d.ts.map +1 -1
- package/dist/esm/Toolbar/ToolbarSeparator.js +1 -1
- package/dist/esm/Toolbar/ToolbarSeparator.js.map +1 -1
- package/package.json +1 -1
package/compat-manifest.json
CHANGED
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
{
|
|
69
69
|
"name": "@cratis/components",
|
|
70
70
|
"role": "core",
|
|
71
|
-
"version": "4.39.
|
|
71
|
+
"version": "4.39.3",
|
|
72
72
|
"releaseMajorRange": ">=4 <5",
|
|
73
73
|
"independentRelease": false,
|
|
74
74
|
"private": false,
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
{
|
|
93
93
|
"name": "@cratis/eslint-plugin-components",
|
|
94
94
|
"role": "eslint",
|
|
95
|
-
"version": "4.39.
|
|
95
|
+
"version": "4.39.3",
|
|
96
96
|
"releaseMajorRange": ">=4 <5",
|
|
97
97
|
"independentRelease": false,
|
|
98
98
|
"private": false,
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
{
|
|
106
106
|
"name": "@cratis/components.migrator",
|
|
107
107
|
"role": "migrator",
|
|
108
|
-
"version": "4.39.
|
|
108
|
+
"version": "4.39.3",
|
|
109
109
|
"releaseMajorRange": ">=4 <5",
|
|
110
110
|
"independentRelease": false,
|
|
111
111
|
"private": false,
|
|
@@ -116,13 +116,13 @@
|
|
|
116
116
|
{
|
|
117
117
|
"name": "@cratis/components.conformance",
|
|
118
118
|
"role": "conformance",
|
|
119
|
-
"version": "4.39.
|
|
119
|
+
"version": "4.39.3",
|
|
120
120
|
"releaseMajorRange": ">=4 <5",
|
|
121
121
|
"independentRelease": false,
|
|
122
122
|
"private": false,
|
|
123
123
|
"packageAccess": "public",
|
|
124
124
|
"peerDependencies": {
|
|
125
|
-
"@cratis/components": "4.39.
|
|
125
|
+
"@cratis/components": "4.39.3",
|
|
126
126
|
"react": "^19.0.0",
|
|
127
127
|
"react-dom": "^19.0.0"
|
|
128
128
|
},
|
|
@@ -132,13 +132,13 @@
|
|
|
132
132
|
{
|
|
133
133
|
"name": "@cratis/components.mui",
|
|
134
134
|
"role": "renderer-adapter",
|
|
135
|
-
"version": "4.39.
|
|
135
|
+
"version": "4.39.3",
|
|
136
136
|
"releaseMajorRange": ">=4 <5",
|
|
137
137
|
"independentRelease": false,
|
|
138
138
|
"private": false,
|
|
139
139
|
"packageAccess": "public",
|
|
140
140
|
"peerDependencies": {
|
|
141
|
-
"@cratis/components": "4.39.
|
|
141
|
+
"@cratis/components": "4.39.3",
|
|
142
142
|
"@emotion/react": ">=11.5 <12",
|
|
143
143
|
"@emotion/styled": ">=11.11 <12",
|
|
144
144
|
"@mui/material": ">=9 <10",
|
|
@@ -188,13 +188,13 @@
|
|
|
188
188
|
{
|
|
189
189
|
"name": "@cratis/components.primereact",
|
|
190
190
|
"role": "renderer-adapter",
|
|
191
|
-
"version": "4.39.
|
|
191
|
+
"version": "4.39.3",
|
|
192
192
|
"releaseMajorRange": ">=4 <5",
|
|
193
193
|
"independentRelease": false,
|
|
194
194
|
"private": false,
|
|
195
195
|
"packageAccess": "public",
|
|
196
196
|
"peerDependencies": {
|
|
197
|
-
"@cratis/components": "4.39.
|
|
197
|
+
"@cratis/components": "4.39.3",
|
|
198
198
|
"@primereact/core": ">=11 <12",
|
|
199
199
|
"@primereact/ui": ">=11 <12",
|
|
200
200
|
"@primeuix/themes": ">=3 <4",
|
|
@@ -256,13 +256,13 @@
|
|
|
256
256
|
{
|
|
257
257
|
"name": "@cratis/components.primereact10",
|
|
258
258
|
"role": "renderer-adapter",
|
|
259
|
-
"version": "4.39.
|
|
259
|
+
"version": "4.39.3",
|
|
260
260
|
"releaseMajorRange": ">=4 <5",
|
|
261
261
|
"independentRelease": false,
|
|
262
262
|
"private": false,
|
|
263
263
|
"packageAccess": "public",
|
|
264
264
|
"peerDependencies": {
|
|
265
|
-
"@cratis/components": "4.39.
|
|
265
|
+
"@cratis/components": "4.39.3",
|
|
266
266
|
"primereact": ">=10.9.9 <11",
|
|
267
267
|
"react": "^19.0.0",
|
|
268
268
|
"react-dom": "^19.0.0"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolbarButton.d.ts","sourceRoot":"","sources":["../../../Toolbar/ToolbarButton.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACR,oBAAoB,EACpB,cAAc,EACjB,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAgB,CAAC;AAE3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file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AMG;AACH,eAAO,MAAM,aAAa,UAAW,kBAAkB,gCAuBtD,CAAC"}
|
|
@@ -8,6 +8,7 @@ import { useToolbarFolderMode } from './ToolbarFolderContext.js';
|
|
|
8
8
|
import { useToolbarItemVisibility } from './ToolbarItemVisibilityContext.js';
|
|
9
9
|
import { useRovingTool } from '../Common/ToolbarRovingContext.js';
|
|
10
10
|
|
|
11
|
+
const drawerTileMarker = { 'data-cratis-component': 'ToolbarButton' };
|
|
11
12
|
const ToolbarButtonContent = ({ icon, text, title, active, onClick, tooltipPosition = 'right', draggable, data, onDragStart, className, pt, }) => {
|
|
12
13
|
const dragContext = useToolbarDragContext();
|
|
13
14
|
const folderMode = useToolbarFolderMode();
|
|
@@ -26,11 +27,11 @@ const ToolbarButtonContent = ({ icon, text, title, active, onClick, tooltipPosit
|
|
|
26
27
|
const hasText = typeof text === 'string' && text.length > 0;
|
|
27
28
|
const resolvedIcon = icon !== undefined && icon !== null && (typeof icon !== 'string' || icon.length > 0) ? icon : null;
|
|
28
29
|
if (isListMode) {
|
|
29
|
-
return (jsxs("button", { "aria-pressed": active, ...pt?.root, ...rovingTool, type: 'button', "aria-label": title, onClick: onClick, draggable: isDraggable, onDragStart: isDraggable ? handleDragStart : undefined, className: `toolbar-button toolbar-button--list cratis:h-10 cratis:px-3 cratis:w-full cratis:flex cratis:items-center cratis:justify-start cratis:gap-2 cratis:rounded-lg cratis:cursor-pointer ${activeClass} ${draggableClass} ${pt?.root?.className ?? ''} ${className ?? ''}`, "data-cratis-part": 'button', "data-active": active || undefined, "data-selected": active || undefined, children: [resolvedIcon !== null && (jsx("span", { ...pt?.icon, className: pt?.icon?.className, "data-cratis-part": 'icon', children: jsx(IconDisplay, { icon: resolvedIcon, className: 'cratis:text-lg cratis:flex-shrink-0' }) })), jsx("span", { ...pt?.label, className: `toolbar-button__label ${pt?.label?.className ?? ''}`, "data-cratis-part": 'label', children: title })] }));
|
|
30
|
+
return (jsxs("button", { "aria-pressed": active, ...pt?.root, ...rovingTool, type: 'button', "aria-label": title, onClick: onClick, draggable: isDraggable, onDragStart: isDraggable ? handleDragStart : undefined, className: `toolbar-button toolbar-button--list cratis:h-10 cratis:px-3 cratis:w-full cratis:flex cratis:items-center cratis:justify-start cratis:gap-2 cratis:rounded-lg cratis:cursor-pointer ${activeClass} ${draggableClass} ${pt?.root?.className ?? ''} ${className ?? ''}`, "data-cratis-part": 'button', "data-cratis-component": 'ToolbarButton', "data-active": active || undefined, "data-selected": active || undefined, children: [resolvedIcon !== null && (jsx("span", { ...pt?.icon, className: pt?.icon?.className, "data-cratis-part": 'icon', children: jsx(IconDisplay, { icon: resolvedIcon, className: 'cratis:text-lg cratis:flex-shrink-0' }) })), jsx("span", { ...pt?.label, className: `toolbar-button__label ${pt?.label?.className ?? ''}`, "data-cratis-part": 'label', children: title })] }));
|
|
30
31
|
}
|
|
31
32
|
const buttonSizeClass = hasText ? 'cratis:h-10 cratis:px-3 cratis:min-w-[4rem]' : 'cratis:w-10 cratis:h-10';
|
|
32
33
|
const buttonContent = hasText ? (jsx("span", { ...pt?.label, className: `toolbar-button__text ${pt?.label?.className ?? ''}`, "data-cratis-part": 'label', children: text })) : resolvedIcon === null ? null : (jsx("span", { ...pt?.icon, className: pt?.icon?.className, "data-cratis-part": 'icon', children: jsx(IconDisplay, { icon: resolvedIcon, className: 'cratis:text-lg' }) }));
|
|
33
|
-
return (jsx(Tooltip, { content: title, position: tooltipPosition, disabled: !isToolbarItemVisible, children: jsx("button", { "aria-pressed": active, ...pt?.root, ...rovingTool, type: 'button', "aria-label": title, onClick: onClick, draggable: isDraggable, onDragStart: isDraggable ? handleDragStart : undefined, className: `toolbar-button ${buttonSizeClass} cratis:flex cratis:items-center cratis:justify-center cratis:rounded-lg cratis:cursor-pointer ${activeClass} ${draggableClass} ${pt?.root?.className ?? ''} ${className ?? ''}`, "data-cratis-part": 'button', "data-active": active || undefined, "data-selected": active || undefined, children: buttonContent }) }));
|
|
34
|
+
return (jsx(Tooltip, { content: title, position: tooltipPosition, disabled: !isToolbarItemVisible, children: jsx("button", { "aria-pressed": active, ...pt?.root, ...rovingTool, type: 'button', "aria-label": title, onClick: onClick, draggable: isDraggable, onDragStart: isDraggable ? handleDragStart : undefined, className: `toolbar-button ${buttonSizeClass} cratis:flex cratis:items-center cratis:justify-center cratis:rounded-lg cratis:cursor-pointer ${activeClass} ${draggableClass} ${pt?.root?.className ?? ''} ${className ?? ''}`, "data-cratis-part": 'button', "data-cratis-component": 'ToolbarButton', "data-active": active || undefined, "data-selected": active || undefined, children: buttonContent }) }));
|
|
34
35
|
};
|
|
35
36
|
const ToolbarButton = (props) => {
|
|
36
37
|
const drawer = useToolbarDrawer();
|
|
@@ -38,7 +39,7 @@ const ToolbarButton = (props) => {
|
|
|
38
39
|
if (drawer === null) {
|
|
39
40
|
return jsx(ToolbarButtonContent, { ...props });
|
|
40
41
|
}
|
|
41
|
-
return (jsx(ToolbarDrawerTile, { title: props.title, icon: props.icon, active: props.active, draggable: props.draggable ?? dragContext.draggable, data: props.data, onClick: props.onClick, onDragStart: props.onDragStart, className: props.className, root: props.pt?.root, iconPart: props.pt?.icon, label: props.pt?.label }));
|
|
42
|
+
return (jsx(ToolbarDrawerTile, { title: props.title, icon: props.icon, active: props.active, draggable: props.draggable ?? dragContext.draggable, data: props.data, onClick: props.onClick, onDragStart: props.onDragStart, className: props.className, root: { ...props.pt?.root, ...drawerTileMarker }, iconPart: props.pt?.icon, label: props.pt?.label }));
|
|
42
43
|
};
|
|
43
44
|
|
|
44
45
|
export { ToolbarButton };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolbarButton.js","sources":["../../../Toolbar/ToolbarButton.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type {\n ButtonHTMLAttributes,\n HTMLAttributes,\n} from 'react';\nimport { IconDisplay } from '../Common/Icon';\nimport type { Icon } from '../Common/Icon';\nimport { Tooltip } from '../Common/Tooltip';\nimport type { TooltipPosition } from '../Common/Tooltip';\nimport { useToolbarDragContext } from './ToolbarDragContext';\nimport { useToolbarDrawer } from './ToolbarDrawerContext';\nimport { ToolbarDrawerTile } from './ToolbarDrawerTile';\nimport { useToolbarFolderMode } from './ToolbarFolderContext';\nimport { useToolbarItemVisibility } from './ToolbarItemVisibilityContext';\nimport { useRovingTool } from '../Common/ToolbarRovingContext';\n\n/** Stable part attributes for {@link ToolbarButton}. */\nexport interface ToolbarButtonParts {\n /** Native button root. */\n root?: ButtonHTMLAttributes<HTMLButtonElement>;\n /** Icon wrapper. */\n icon?: HTMLAttributes<HTMLSpanElement>;\n /** Text/title label wrapper. */\n label?: HTMLAttributes<HTMLSpanElement>;\n}\n\n/** Props for the {@link ToolbarButton} component. */\nexport interface ToolbarButtonProps {\n /** React icon node or consumer-owned icon-font class. Components installs no icon font. */\n icon?: Icon;\n\n /** Optional text-first content (for example `120%`); when non-empty it renders instead of {@link icon}. */\n text?: string;\n\n /** Title text shown when the user hovers over the button. */\n title: string;\n\n /** Whether the button is currently in the active/selected state. */\n active?: boolean;\n\n /** Callback invoked when the button is clicked. */\n onClick?: () => void;\n\n /** Position of the tooltip relative to the button (default: 'right'). */\n tooltipPosition?: TooltipPosition;\n\n /** Extra class name for the native button. */\n className?: string;\n\n /** Stable button part attributes. */\n pt?: ToolbarButtonParts;\n\n /**\n * Whether this button can be dragged onto a surface.\n * When omitted the value is inherited from the parent {@link Toolbar}'s `draggable` prop.\n */\n draggable?: boolean;\n\n /**\n * Optional data associated with this button for identification during drag & drop.\n * The value is passed to {@link onDragStart} and serialised onto the HTML5\n * `DataTransfer` object as `application/json` so drop targets can read it.\n */\n data?: unknown;\n\n /**\n * Callback invoked when a drag operation starts on this button.\n * Receives the button's {@link data} and the originating drag event.\n */\n onDragStart?: (data: unknown, event: React.DragEvent<HTMLButtonElement>) => void;\n}\n\nconst ToolbarButtonContent = ({\n icon,\n text,\n title,\n active,\n onClick,\n tooltipPosition = 'right',\n draggable,\n data,\n onDragStart,\n className,\n pt,\n}: ToolbarButtonProps) => {\n const dragContext = useToolbarDragContext();\n const folderMode = useToolbarFolderMode();\n const isToolbarItemVisible = useToolbarItemVisibility();\n const rovingTool = useRovingTool<HTMLButtonElement>(pt?.root?.tabIndex, pt?.root?.onFocus);\n const isListMode = folderMode === 'list';\n const isDraggable = draggable ?? dragContext.draggable;\n\n const handleDragStart = (event: React.DragEvent<HTMLButtonElement>) => {\n event.dataTransfer.setData('application/json', JSON.stringify(data ?? null));\n event.dataTransfer.effectAllowed = 'copy';\n onDragStart?.(data, event);\n dragContext.onItemDragStart?.(data, event);\n };\n\n const activeClass = active ? 'toolbar-button--active' : '';\n const draggableClass = isDraggable ? 'toolbar-button--draggable' : '';\n const hasText = typeof text === 'string' && text.length > 0;\n const resolvedIcon = icon !== undefined && icon !== null && (typeof icon !== 'string' || icon.length > 0) ? icon : null;\n\n // List mode: icon + title label rendered side by side (no floating tooltip needed).\n if (isListMode) {\n return (\n <button\n aria-pressed={active}\n {...pt?.root}\n {...rovingTool}\n type='button'\n aria-label={title}\n onClick={onClick}\n draggable={isDraggable}\n onDragStart={isDraggable ? handleDragStart : undefined}\n className={`toolbar-button toolbar-button--list cratis:h-10 cratis:px-3 cratis:w-full cratis:flex cratis:items-center cratis:justify-start cratis:gap-2 cratis:rounded-lg cratis:cursor-pointer ${activeClass} ${draggableClass} ${pt?.root?.className ?? ''} ${className ?? ''}`}\n data-cratis-part='button'\n data-active={active || undefined}\n data-selected={active || undefined}\n >\n {resolvedIcon !== null && (\n <span\n {...pt?.icon}\n className={pt?.icon?.className}\n data-cratis-part='icon'\n >\n <IconDisplay\n icon={resolvedIcon}\n className='cratis:text-lg cratis:flex-shrink-0'\n />\n </span>\n )}\n <span\n {...pt?.label}\n className={`toolbar-button__label ${pt?.label?.className ?? ''}`}\n data-cratis-part='label'\n >\n {title}\n </span>\n </button>\n );\n }\n\n const buttonSizeClass = hasText ? 'cratis:h-10 cratis:px-3 cratis:min-w-[4rem]' : 'cratis:w-10 cratis:h-10';\n const buttonContent = hasText ? (\n <span\n {...pt?.label}\n className={`toolbar-button__text ${pt?.label?.className ?? ''}`}\n data-cratis-part='label'\n >\n {text}\n </span>\n ) : resolvedIcon === null ? null : (\n <span\n {...pt?.icon}\n className={pt?.icon?.className}\n data-cratis-part='icon'\n >\n <IconDisplay icon={resolvedIcon} className='cratis:text-lg' />\n </span>\n );\n\n return (\n <Tooltip\n content={title}\n position={tooltipPosition}\n disabled={!isToolbarItemVisible}\n >\n <button\n aria-pressed={active}\n {...pt?.root}\n {...rovingTool}\n type='button'\n aria-label={title}\n onClick={onClick}\n draggable={isDraggable}\n onDragStart={isDraggable ? handleDragStart : undefined}\n className={`toolbar-button ${buttonSizeClass} cratis:flex cratis:items-center cratis:justify-center cratis:rounded-lg cratis:cursor-pointer ${activeClass} ${draggableClass} ${pt?.root?.className ?? ''} ${className ?? ''}`}\n data-cratis-part='button'\n data-active={active || undefined}\n data-selected={active || undefined}\n >\n {buttonContent}\n </button>\n </Tooltip>\n );\n};\n\n/**\n * An icon button with a tooltip, intended to be placed inside a {@link Toolbar}.\n * Uses the shared {@link Tooltip} component for consistent hover labels.\n *\n * Inside a drawer {@link ToolbarFolder} the button renders as a labeled tile instead, with its\n * `title` always visible, so a drawer can be composed from children as well as from `items`.\n */\nexport const ToolbarButton = (props: ToolbarButtonProps) => {\n const drawer = useToolbarDrawer();\n const dragContext = useToolbarDragContext();\n\n if (drawer === null) {\n return <ToolbarButtonContent {...props} />;\n }\n\n return (\n <ToolbarDrawerTile\n title={props.title}\n icon={props.icon}\n active={props.active}\n draggable={props.draggable ?? dragContext.draggable}\n data={props.data}\n onClick={props.onClick}\n onDragStart={props.onDragStart}\n className={props.className}\n root={props.pt?.root}\n iconPart={props.pt?.icon}\n label={props.pt?.label}\n />\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;AA0EA,MAAM,oBAAoB,GAAG,CAAC,EAC1B,IAAI,EACJ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AAG,qBAAqB,EAAE;AAE3C,IAAA,IAAI,MAAM,KAAK,IAAI,EAAE;AACjB,QAAA,OAAOA,GAAA,CAAC,oBAAoB,EAAA,EAAA,GAAK,KAAK,GAAI;IAC9C;AAEA,IAAA,QACIA,GAAA,CAAC,iBAAiB,EAAA,EACd,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,WAAW,CAAC,SAAS,EACnD,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,IAAI,EACpB,QAAQ,EAAE,KAAK,CAAC,EAAE,EAAE,IAAI,EACxB,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,EAAA,CACxB;AAEV;;"}
|
|
1
|
+
{"version":3,"file":"ToolbarButton.js","sources":["../../../Toolbar/ToolbarButton.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type {\n ButtonHTMLAttributes,\n HTMLAttributes,\n} from 'react';\nimport { IconDisplay } from '../Common/Icon';\nimport type { Icon } from '../Common/Icon';\nimport { Tooltip } from '../Common/Tooltip';\nimport type { TooltipPosition } from '../Common/Tooltip';\nimport { useToolbarDragContext } from './ToolbarDragContext';\nimport { useToolbarDrawer } from './ToolbarDrawerContext';\nimport { ToolbarDrawerTile } from './ToolbarDrawerTile';\nimport { useToolbarFolderMode } from './ToolbarFolderContext';\nimport { useToolbarItemVisibility } from './ToolbarItemVisibilityContext';\nimport { useRovingTool } from '../Common/ToolbarRovingContext';\n\n// SAFETY: A data-* attribute is not part of the typed button attributes; the drawer tile spreads it onto its button root.\nconst drawerTileMarker = { 'data-cratis-component': 'ToolbarButton' } as ButtonHTMLAttributes<HTMLButtonElement>;\n\n/** Stable part attributes for {@link ToolbarButton}. */\nexport interface ToolbarButtonParts {\n /** Native button root. */\n root?: ButtonHTMLAttributes<HTMLButtonElement>;\n /** Icon wrapper. */\n icon?: HTMLAttributes<HTMLSpanElement>;\n /** Text/title label wrapper. */\n label?: HTMLAttributes<HTMLSpanElement>;\n}\n\n/** Props for the {@link ToolbarButton} component. */\nexport interface ToolbarButtonProps {\n /** React icon node or consumer-owned icon-font class. Components installs no icon font. */\n icon?: Icon;\n\n /** Optional text-first content (for example `120%`); when non-empty it renders instead of {@link icon}. */\n text?: string;\n\n /** Title text shown when the user hovers over the button. */\n title: string;\n\n /** Whether the button is currently in the active/selected state. */\n active?: boolean;\n\n /** Callback invoked when the button is clicked. */\n onClick?: () => void;\n\n /** Position of the tooltip relative to the button (default: 'right'). */\n tooltipPosition?: TooltipPosition;\n\n /** Extra class name for the native button. */\n className?: string;\n\n /** Stable button part attributes. */\n pt?: ToolbarButtonParts;\n\n /**\n * Whether this button can be dragged onto a surface.\n * When omitted the value is inherited from the parent {@link Toolbar}'s `draggable` prop.\n */\n draggable?: boolean;\n\n /**\n * Optional data associated with this button for identification during drag & drop.\n * The value is passed to {@link onDragStart} and serialised onto the HTML5\n * `DataTransfer` object as `application/json` so drop targets can read it.\n */\n data?: unknown;\n\n /**\n * Callback invoked when a drag operation starts on this button.\n * Receives the button's {@link data} and the originating drag event.\n */\n onDragStart?: (data: unknown, event: React.DragEvent<HTMLButtonElement>) => void;\n}\n\nconst ToolbarButtonContent = ({\n icon,\n text,\n title,\n active,\n onClick,\n tooltipPosition = 'right',\n draggable,\n data,\n onDragStart,\n className,\n pt,\n}: ToolbarButtonProps) => {\n const dragContext = useToolbarDragContext();\n const folderMode = useToolbarFolderMode();\n const isToolbarItemVisible = useToolbarItemVisibility();\n const rovingTool = useRovingTool<HTMLButtonElement>(pt?.root?.tabIndex, pt?.root?.onFocus);\n const isListMode = folderMode === 'list';\n const isDraggable = draggable ?? dragContext.draggable;\n\n const handleDragStart = (event: React.DragEvent<HTMLButtonElement>) => {\n event.dataTransfer.setData('application/json', JSON.stringify(data ?? null));\n event.dataTransfer.effectAllowed = 'copy';\n onDragStart?.(data, event);\n dragContext.onItemDragStart?.(data, event);\n };\n\n const activeClass = active ? 'toolbar-button--active' : '';\n const draggableClass = isDraggable ? 'toolbar-button--draggable' : '';\n const hasText = typeof text === 'string' && text.length > 0;\n const resolvedIcon = icon !== undefined && icon !== null && (typeof icon !== 'string' || icon.length > 0) ? icon : null;\n\n // List mode: icon + title label rendered side by side (no floating tooltip needed).\n if (isListMode) {\n return (\n <button\n aria-pressed={active}\n {...pt?.root}\n {...rovingTool}\n type='button'\n aria-label={title}\n onClick={onClick}\n draggable={isDraggable}\n onDragStart={isDraggable ? handleDragStart : undefined}\n className={`toolbar-button toolbar-button--list cratis:h-10 cratis:px-3 cratis:w-full cratis:flex cratis:items-center cratis:justify-start cratis:gap-2 cratis:rounded-lg cratis:cursor-pointer ${activeClass} ${draggableClass} ${pt?.root?.className ?? ''} ${className ?? ''}`}\n data-cratis-part='button'\n data-cratis-component='ToolbarButton'\n data-active={active || undefined}\n data-selected={active || undefined}\n >\n {resolvedIcon !== null && (\n <span\n {...pt?.icon}\n className={pt?.icon?.className}\n data-cratis-part='icon'\n >\n <IconDisplay\n icon={resolvedIcon}\n className='cratis:text-lg cratis:flex-shrink-0'\n />\n </span>\n )}\n <span\n {...pt?.label}\n className={`toolbar-button__label ${pt?.label?.className ?? ''}`}\n data-cratis-part='label'\n >\n {title}\n </span>\n </button>\n );\n }\n\n const buttonSizeClass = hasText ? 'cratis:h-10 cratis:px-3 cratis:min-w-[4rem]' : 'cratis:w-10 cratis:h-10';\n const buttonContent = hasText ? (\n <span\n {...pt?.label}\n className={`toolbar-button__text ${pt?.label?.className ?? ''}`}\n data-cratis-part='label'\n >\n {text}\n </span>\n ) : resolvedIcon === null ? null : (\n <span\n {...pt?.icon}\n className={pt?.icon?.className}\n data-cratis-part='icon'\n >\n <IconDisplay icon={resolvedIcon} className='cratis:text-lg' />\n </span>\n );\n\n return (\n <Tooltip\n content={title}\n position={tooltipPosition}\n disabled={!isToolbarItemVisible}\n >\n <button\n aria-pressed={active}\n {...pt?.root}\n {...rovingTool}\n type='button'\n aria-label={title}\n onClick={onClick}\n draggable={isDraggable}\n onDragStart={isDraggable ? handleDragStart : undefined}\n className={`toolbar-button ${buttonSizeClass} cratis:flex cratis:items-center cratis:justify-center cratis:rounded-lg cratis:cursor-pointer ${activeClass} ${draggableClass} ${pt?.root?.className ?? ''} ${className ?? ''}`}\n data-cratis-part='button'\n data-cratis-component='ToolbarButton'\n data-active={active || undefined}\n data-selected={active || undefined}\n >\n {buttonContent}\n </button>\n </Tooltip>\n );\n};\n\n/**\n * An icon button with a tooltip, intended to be placed inside a {@link Toolbar}.\n * Uses the shared {@link Tooltip} component for consistent hover labels.\n *\n * Inside a drawer {@link ToolbarFolder} the button renders as a labeled tile instead, with its\n * `title` always visible, so a drawer can be composed from children as well as from `items`.\n */\nexport const ToolbarButton = (props: ToolbarButtonProps) => {\n const drawer = useToolbarDrawer();\n const dragContext = useToolbarDragContext();\n\n if (drawer === null) {\n return <ToolbarButtonContent {...props} />;\n }\n\n return (\n <ToolbarDrawerTile\n title={props.title}\n icon={props.icon}\n active={props.active}\n draggable={props.draggable ?? dragContext.draggable}\n data={props.data}\n onClick={props.onClick}\n onDragStart={props.onDragStart}\n className={props.className}\n root={{ ...props.pt?.root, ...drawerTileMarker }}\n iconPart={props.pt?.icon}\n label={props.pt?.label}\n />\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;AAmBA,MAAM,gBAAgB,GAAG,EAAE,uBAAuB,EAAE,eAAe,EAA6C;AA0DhH,MAAM,oBAAoB,GAAG,CAAC,EAC1B,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,MAAM,EACN,OAAO,EACP,eAAe,GA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,EAAE,IAAI,CAAC;IAEX,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAC;IAEhB,iFAAiF;IACjF,eAAe,CAAC,EAAE,eAAe,CAAC;IAElC,+EAA+E;IAC/E,eAAe,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,GAAG,MAAM,CAAC;IAEnD,6CAA6C;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,sCAAsC;IACtC,EAAE,CAAC,EAAE,kBAAkB,CAAC;IAExB,4DAA4D;IAC5D,QAAQ,EAAE,SAAS,CAAC;CACvB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,kFAQ3B,sBAAsB,sBA4IxB,CAAC"}
|
|
@@ -76,7 +76,7 @@ const ToolbarFanOutItem = ({ icon, tooltip, tooltipPosition = 'right', fanOutDir
|
|
|
76
76
|
const panelVisibleClass = isExpanded ? 'toolbar-fanout-panel--visible' : '';
|
|
77
77
|
const panelSettledClass = isExpanded && isSettled ? 'toolbar-fanout-panel--settled' : '';
|
|
78
78
|
const directionClass = `toolbar-fanout-panel--${fanOutDirection}`;
|
|
79
|
-
return (jsxs("div", { ...pt?.root, className: `toolbar-fanout-item ${pt?.root?.className ?? ''} ${className ?? ''}`, "data-cratis-part": 'fanout-root', "data-open": isExpanded || undefined, ref: containerRef, children: [jsx(Tooltip, { content: tooltip, position: tooltipPosition, disabled: isExpanded || !isToolbarItemVisible, children: jsx("button", { ...pt?.trigger, tabIndex: rovingTrigger.tabIndex, onFocus: rovingTrigger.onFocus, ref: setTriggerRef, type: 'button', "aria-label": tooltip, "aria-expanded": isExpanded, "aria-controls": panelId, onClick: handleToggle, className: `toolbar-button cratis:w-10 cratis:h-10 cratis:flex cratis:items-center cratis:justify-center cratis:rounded-lg cratis:cursor-pointer ${activeClass} ${pt?.trigger?.className ?? ''}`, "data-cratis-part": 'fanout-trigger', "data-open": isExpanded || undefined, children: jsx(IconDisplay, { icon: icon, className: 'cratis:text-lg' }) }) }), jsx("div", { ...pt?.panel, id: panelId, role: 'group', "aria-label": tooltip, ref: panelRef, className: `toolbar-fanout-panel ${directionClass} ${panelVisibleClass} ${panelSettledClass} ${pt?.panel?.className ?? ''}`, "data-cratis-part": 'fanout-panel', "data-expanded": isExpanded || undefined, "data-open": isExpanded || undefined, "data-direction": fanOutDirection, "data-settled": isSettled || undefined, "aria-hidden": !isExpanded, inert: !isExpanded, onTransitionEnd: handleTransitionEnd, children: jsx(ToolbarItemVisibilityProvider, { value: isExpanded && isToolbarItemVisible, children: children }) })] }));
|
|
79
|
+
return (jsxs("div", { ...pt?.root, className: `toolbar-fanout-item ${pt?.root?.className ?? ''} ${className ?? ''}`, "data-cratis-part": 'fanout-root', "data-cratis-component": 'ToolbarFanOutItem', "data-open": isExpanded || undefined, ref: containerRef, children: [jsx(Tooltip, { content: tooltip, position: tooltipPosition, disabled: isExpanded || !isToolbarItemVisible, children: jsx("button", { ...pt?.trigger, tabIndex: rovingTrigger.tabIndex, onFocus: rovingTrigger.onFocus, ref: setTriggerRef, type: 'button', "aria-label": tooltip, "aria-expanded": isExpanded, "aria-controls": panelId, onClick: handleToggle, className: `toolbar-button cratis:w-10 cratis:h-10 cratis:flex cratis:items-center cratis:justify-center cratis:rounded-lg cratis:cursor-pointer ${activeClass} ${pt?.trigger?.className ?? ''}`, "data-cratis-part": 'fanout-trigger', "data-open": isExpanded || undefined, children: jsx(IconDisplay, { icon: icon, className: 'cratis:text-lg' }) }) }), jsx("div", { ...pt?.panel, id: panelId, role: 'group', "aria-label": tooltip, ref: panelRef, className: `toolbar-fanout-panel ${directionClass} ${panelVisibleClass} ${panelSettledClass} ${pt?.panel?.className ?? ''}`, "data-cratis-part": 'fanout-panel', "data-expanded": isExpanded || undefined, "data-open": isExpanded || undefined, "data-direction": fanOutDirection, "data-settled": isSettled || undefined, "aria-hidden": !isExpanded, inert: !isExpanded, onTransitionEnd: handleTransitionEnd, children: jsx(ToolbarItemVisibilityProvider, { value: isExpanded && isToolbarItemVisible, children: children }) })] }));
|
|
80
80
|
};
|
|
81
81
|
|
|
82
82
|
export { ToolbarFanOutItem };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolbarFanOutItem.js","sources":["../../../Toolbar/ToolbarFanOutItem.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport React, {\n type ButtonHTMLAttributes,\n type HTMLAttributes,\n type ReactNode,\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n} from 'react';\nimport { useRovingTool } from '../Common/ToolbarRovingContext';\nimport { IconDisplay } from '../Common/Icon';\nimport type { Icon } from '../Common/Icon';\nimport { Tooltip } from '../Common/Tooltip';\nimport type { TooltipPosition } from '../Common/Tooltip';\nimport {\n ToolbarItemVisibilityProvider,\n useToolbarItemVisibility,\n} from './ToolbarItemVisibilityContext';\n\n/** Stable part attributes for {@link ToolbarFanOutItem}. */\nexport interface ToolbarFanOutParts {\n /** Fan-out composition root. */\n root?: HTMLAttributes<HTMLDivElement>;\n /** Native trigger button. */\n trigger?: ButtonHTMLAttributes<HTMLButtonElement>;\n /** Expanded tool panel. */\n panel?: HTMLAttributes<HTMLDivElement>;\n}\n\n/** Props for the {@link ToolbarFanOutItem} component. */\nexport interface ToolbarFanOutItemProps {\n /** React icon node or consumer-owned icon-font class for the trigger. */\n icon: Icon;\n\n /** Tooltip text shown when hovering over the trigger button. */\n tooltip: string;\n\n /** Position of the tooltip relative to the trigger button (default: 'right'). */\n tooltipPosition?: TooltipPosition;\n\n /** Direction the panel fans out from the trigger button (default: 'right'). */\n fanOutDirection?: 'right' | 'left' | 'up' | 'down';\n\n /** Extra class name for the fan-out root. */\n className?: string;\n\n /** Stable fan-out part attributes. */\n pt?: ToolbarFanOutParts;\n\n /** The toolbar items to render inside the fan-out panel. */\n children: ReactNode;\n}\n\n/**\n * A toolbar button that fans out a horizontal panel of sub-tool buttons when clicked.\n *\n * Place this inside a vertical {@link Toolbar}. When the button is clicked, a pill-shaped\n * panel slides out to the side (right by default) containing the provided children.\n * The panel animates in/out using a clip-path reveal transition.\n *\n * - Clicking the button again closes the panel\n * - Clicking anywhere outside the panel also closes it\n */\nexport const ToolbarFanOutItem = ({\n icon,\n tooltip,\n tooltipPosition = 'right',\n fanOutDirection = 'right',\n className,\n pt,\n children,\n}: ToolbarFanOutItemProps) => {\n const [isExpanded, setIsExpanded] = useState(false);\n const [isSettled, setIsSettled] = useState(false);\n const isToolbarItemVisible = useToolbarItemVisibility();\n const containerRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const rovingTrigger = useRovingTool<HTMLButtonElement>(pt?.trigger?.tabIndex, pt?.trigger?.onFocus);\n const rovingTriggerRef = rovingTrigger.ref;\n const setTriggerRef = useCallback((element: HTMLButtonElement | null) => {\n triggerRef.current = element;\n if (typeof rovingTriggerRef === 'function') rovingTriggerRef(element);\n }, [rovingTriggerRef]);\n const panelRef = useRef<HTMLDivElement>(null);\n const generatedPanelId = useId();\n const panelId = pt?.panel?.id ?? generatedPanelId;\n\n // A settled panel has `clip-path: none`, which cannot interpolate — closing\n // straight from it would snap the panel shut instead of wiping it closed.\n // Put an equivalent inset back and let the browser observe it (the forced\n // reflow) before React removes the visible class, so the close transition\n // has an interpolable starting value.\n const collapse = useCallback(() => {\n const panel = panelRef.current;\n if (panel && panel.classList.contains('toolbar-fanout-panel--settled')) {\n panel.style.setProperty('clip-path', 'inset(0 0 0 0 round 1rem)');\n panel.style.setProperty('transition', 'none');\n void panel.offsetWidth;\n panel.style.removeProperty('transition');\n panel.style.removeProperty('clip-path');\n }\n setIsSettled(false);\n setIsExpanded(false);\n }, []);\n\n const handleToggle = () => {\n if (isExpanded) {\n collapse();\n } else {\n setIsExpanded(true);\n }\n };\n\n const handleTransitionEnd = (event: React.TransitionEvent<HTMLDivElement>) => {\n if (\n event.target === panelRef.current &&\n event.propertyName === 'clip-path' &&\n isExpanded\n ) {\n setIsSettled(true);\n }\n };\n\n // Close the fan-out when clicking outside\n useEffect(() => {\n if (!isExpanded) return;\n\n const handleClickOutside = (event: MouseEvent) => {\n if (\n containerRef.current &&\n !containerRef.current.contains(event.target as Node)\n ) {\n collapse();\n }\n };\n\n const handleEscape = (event: KeyboardEvent) => {\n if (event.key !== 'Escape') return;\n event.preventDefault();\n event.stopPropagation();\n collapse();\n window.setTimeout(() => triggerRef.current?.focus(), 0);\n };\n\n document.addEventListener('mousedown', handleClickOutside);\n document.addEventListener('keydown', handleEscape, true);\n return () => {\n document.removeEventListener('mousedown', handleClickOutside);\n document.removeEventListener('keydown', handleEscape, true);\n };\n }, [isExpanded, collapse]);\n\n const activeClass = isExpanded ? 'toolbar-button--active' : '';\n const panelVisibleClass = isExpanded ? 'toolbar-fanout-panel--visible' : '';\n const panelSettledClass =\n isExpanded && isSettled ? 'toolbar-fanout-panel--settled' : '';\n const directionClass = `toolbar-fanout-panel--${fanOutDirection}`;\n\n return (\n <div\n {...pt?.root}\n className={`toolbar-fanout-item ${pt?.root?.className ?? ''} ${className ?? ''}`}\n data-cratis-part='fanout-root'\n data-open={isExpanded || undefined}\n ref={containerRef}\n >\n <Tooltip\n content={tooltip}\n position={tooltipPosition}\n disabled={isExpanded || !isToolbarItemVisible}\n >\n <button\n {...pt?.trigger}\n tabIndex={rovingTrigger.tabIndex}\n onFocus={rovingTrigger.onFocus}\n ref={setTriggerRef}\n type='button'\n aria-label={tooltip}\n aria-expanded={isExpanded}\n aria-controls={panelId}\n onClick={handleToggle}\n className={`toolbar-button cratis:w-10 cratis:h-10 cratis:flex cratis:items-center cratis:justify-center cratis:rounded-lg cratis:cursor-pointer ${activeClass} ${pt?.trigger?.className ?? ''}`}\n data-cratis-part='fanout-trigger'\n data-open={isExpanded || undefined}\n >\n <IconDisplay icon={icon} className='cratis:text-lg' />\n </button>\n </Tooltip>\n <div\n {...pt?.panel}\n id={panelId}\n role='group'\n aria-label={tooltip}\n ref={panelRef}\n className={`toolbar-fanout-panel ${directionClass} ${panelVisibleClass} ${panelSettledClass} ${pt?.panel?.className ?? ''}`}\n data-cratis-part='fanout-panel'\n data-expanded={isExpanded || undefined}\n data-open={isExpanded || undefined}\n data-direction={fanOutDirection}\n data-settled={isSettled || undefined}\n aria-hidden={!isExpanded}\n inert={!isExpanded}\n onTransitionEnd={handleTransitionEnd}\n >\n <ToolbarItemVisibilityProvider value={isExpanded && isToolbarItemVisible}>\n {children}\n </ToolbarItemVisibilityProvider>\n </div>\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;AAmEO,MAAM,iBAAiB,GAAG,CAAC,EAC9B,IAAI,EACJ,OAAO,EACP,eAAe,GAAG,OAAO,EACzB,eAAe,GAAG,OAAO,EACzB,SAAS,EACT,EAAE,EACF,QAAQ,GACa,KAAI;IACzB,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;IACnD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;AACjD,IAAA,MAAM,oBAAoB,GAAG,wBAAwB,EAAE;AACvD,IAAA,MAAM,YAAY,GAAG,MAAM,CAAiB,IAAI,CAAC;AACjD,IAAA,MAAM,UAAU,GAAG,MAAM,CAAoB,IAAI,CAAC;AAClD,IAAA,MAAM,aAAa,GAAG,aAAa,CAAoB,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC;AACnG,IAAA,MAAM,gBAAgB,GAAG,aAAa,CAAC,GAAG;AAC1C,IAAA,MAAM,aAAa,GAAG,WAAW,CAAC,CAAC,OAAiC,KAAI;AACpE,QAAA,UAAU,CAAC,OAAO,GAAG,OAAO;QAC5B,IAAI,OAAO,gBAAgB,KAAK,UAAU;YAAE,gBAAgB,CAAC,OAAO,CAAC;AACzE,IAAA,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC;AACtB,IAAA,MAAM,QAAQ,GAAG,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AAK,EAAE,CAAC,UAAU,EAClB,eAAe,EAAE,mBAAmB,EAAA,QAAA,EAEpCA,GAAA,CAAC,6BAA6B,EAAA,EAAC,KAAK,EAAE,UAAU,IAAI,oBAAoB,EAAA,QAAA,EACnE,QAAQ,EAAA,CACmB,EAAA,CAC9B,CAAA,EAAA,CACJ;AAEd;;"}
|
|
1
|
+
{"version":3,"file":"ToolbarFanOutItem.js","sources":["../../../Toolbar/ToolbarFanOutItem.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport React, {\n type ButtonHTMLAttributes,\n type HTMLAttributes,\n type ReactNode,\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n} from 'react';\nimport { useRovingTool } from '../Common/ToolbarRovingContext';\nimport { IconDisplay } from '../Common/Icon';\nimport type { Icon } from '../Common/Icon';\nimport { Tooltip } from '../Common/Tooltip';\nimport type { TooltipPosition } from '../Common/Tooltip';\nimport {\n ToolbarItemVisibilityProvider,\n useToolbarItemVisibility,\n} from './ToolbarItemVisibilityContext';\n\n/** Stable part attributes for {@link ToolbarFanOutItem}. */\nexport interface ToolbarFanOutParts {\n /** Fan-out composition root. */\n root?: HTMLAttributes<HTMLDivElement>;\n /** Native trigger button. */\n trigger?: ButtonHTMLAttributes<HTMLButtonElement>;\n /** Expanded tool panel. */\n panel?: HTMLAttributes<HTMLDivElement>;\n}\n\n/** Props for the {@link ToolbarFanOutItem} component. */\nexport interface ToolbarFanOutItemProps {\n /** React icon node or consumer-owned icon-font class for the trigger. */\n icon: Icon;\n\n /** Tooltip text shown when hovering over the trigger button. */\n tooltip: string;\n\n /** Position of the tooltip relative to the trigger button (default: 'right'). */\n tooltipPosition?: TooltipPosition;\n\n /** Direction the panel fans out from the trigger button (default: 'right'). */\n fanOutDirection?: 'right' | 'left' | 'up' | 'down';\n\n /** Extra class name for the fan-out root. */\n className?: string;\n\n /** Stable fan-out part attributes. */\n pt?: ToolbarFanOutParts;\n\n /** The toolbar items to render inside the fan-out panel. */\n children: ReactNode;\n}\n\n/**\n * A toolbar button that fans out a horizontal panel of sub-tool buttons when clicked.\n *\n * Place this inside a vertical {@link Toolbar}. When the button is clicked, a pill-shaped\n * panel slides out to the side (right by default) containing the provided children.\n * The panel animates in/out using a clip-path reveal transition.\n *\n * - Clicking the button again closes the panel\n * - Clicking anywhere outside the panel also closes it\n */\nexport const ToolbarFanOutItem = ({\n icon,\n tooltip,\n tooltipPosition = 'right',\n fanOutDirection = 'right',\n className,\n pt,\n children,\n}: ToolbarFanOutItemProps) => {\n const [isExpanded, setIsExpanded] = useState(false);\n const [isSettled, setIsSettled] = useState(false);\n const isToolbarItemVisible = useToolbarItemVisibility();\n const containerRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const rovingTrigger = useRovingTool<HTMLButtonElement>(pt?.trigger?.tabIndex, pt?.trigger?.onFocus);\n const rovingTriggerRef = rovingTrigger.ref;\n const setTriggerRef = useCallback((element: HTMLButtonElement | null) => {\n triggerRef.current = element;\n if (typeof rovingTriggerRef === 'function') rovingTriggerRef(element);\n }, [rovingTriggerRef]);\n const panelRef = useRef<HTMLDivElement>(null);\n const generatedPanelId = useId();\n const panelId = pt?.panel?.id ?? generatedPanelId;\n\n // A settled panel has `clip-path: none`, which cannot interpolate — closing\n // straight from it would snap the panel shut instead of wiping it closed.\n // Put an equivalent inset back and let the browser observe it (the forced\n // reflow) before React removes the visible class, so the close transition\n // has an interpolable starting value.\n const collapse = useCallback(() => {\n const panel = panelRef.current;\n if (panel && panel.classList.contains('toolbar-fanout-panel--settled')) {\n panel.style.setProperty('clip-path', 'inset(0 0 0 0 round 1rem)');\n panel.style.setProperty('transition', 'none');\n void panel.offsetWidth;\n panel.style.removeProperty('transition');\n panel.style.removeProperty('clip-path');\n }\n setIsSettled(false);\n setIsExpanded(false);\n }, []);\n\n const handleToggle = () => {\n if (isExpanded) {\n collapse();\n } else {\n setIsExpanded(true);\n }\n };\n\n const handleTransitionEnd = (event: React.TransitionEvent<HTMLDivElement>) => {\n if (\n event.target === panelRef.current &&\n event.propertyName === 'clip-path' &&\n isExpanded\n ) {\n setIsSettled(true);\n }\n };\n\n // Close the fan-out when clicking outside\n useEffect(() => {\n if (!isExpanded) return;\n\n const handleClickOutside = (event: MouseEvent) => {\n if (\n containerRef.current &&\n !containerRef.current.contains(event.target as Node)\n ) {\n collapse();\n }\n };\n\n const handleEscape = (event: KeyboardEvent) => {\n if (event.key !== 'Escape') return;\n event.preventDefault();\n event.stopPropagation();\n collapse();\n window.setTimeout(() => triggerRef.current?.focus(), 0);\n };\n\n document.addEventListener('mousedown', handleClickOutside);\n document.addEventListener('keydown', handleEscape, true);\n return () => {\n document.removeEventListener('mousedown', handleClickOutside);\n document.removeEventListener('keydown', handleEscape, true);\n };\n }, [isExpanded, collapse]);\n\n const activeClass = isExpanded ? 'toolbar-button--active' : '';\n const panelVisibleClass = isExpanded ? 'toolbar-fanout-panel--visible' : '';\n const panelSettledClass =\n isExpanded && isSettled ? 'toolbar-fanout-panel--settled' : '';\n const directionClass = `toolbar-fanout-panel--${fanOutDirection}`;\n\n return (\n <div\n {...pt?.root}\n className={`toolbar-fanout-item ${pt?.root?.className ?? ''} ${className ?? ''}`}\n data-cratis-part='fanout-root'\n data-cratis-component='ToolbarFanOutItem'\n data-open={isExpanded || undefined}\n ref={containerRef}\n >\n <Tooltip\n content={tooltip}\n position={tooltipPosition}\n disabled={isExpanded || !isToolbarItemVisible}\n >\n <button\n {...pt?.trigger}\n tabIndex={rovingTrigger.tabIndex}\n onFocus={rovingTrigger.onFocus}\n ref={setTriggerRef}\n type='button'\n aria-label={tooltip}\n aria-expanded={isExpanded}\n aria-controls={panelId}\n onClick={handleToggle}\n className={`toolbar-button cratis:w-10 cratis:h-10 cratis:flex cratis:items-center cratis:justify-center cratis:rounded-lg cratis:cursor-pointer ${activeClass} ${pt?.trigger?.className ?? ''}`}\n data-cratis-part='fanout-trigger'\n data-open={isExpanded || undefined}\n >\n <IconDisplay icon={icon} className='cratis:text-lg' />\n </button>\n </Tooltip>\n <div\n {...pt?.panel}\n id={panelId}\n role='group'\n aria-label={tooltip}\n ref={panelRef}\n className={`toolbar-fanout-panel ${directionClass} ${panelVisibleClass} ${panelSettledClass} ${pt?.panel?.className ?? ''}`}\n data-cratis-part='fanout-panel'\n data-expanded={isExpanded || undefined}\n data-open={isExpanded || undefined}\n data-direction={fanOutDirection}\n data-settled={isSettled || undefined}\n aria-hidden={!isExpanded}\n inert={!isExpanded}\n onTransitionEnd={handleTransitionEnd}\n >\n <ToolbarItemVisibilityProvider value={isExpanded && isToolbarItemVisible}>\n {children}\n </ToolbarItemVisibilityProvider>\n </div>\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;AAmEO,MAAM,iBAAiB,GAAG,CAAC,EAC9B,IAAI,EACJ,OAAO,EACP,eAAe,GAAG,OAAO,EACzB,eAAe,GAAG,OAAO,EACzB,SAAS,EACT,EAAE,EACF,QAAQ,GACa,KAAI;IACzB,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;IACnD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;AACjD,IAAA,MAAM,oBAAoB,GAAG,wBAAwB,EAAE;AACvD,IAAA,MAAM,YAAY,GAAG,MAAM,CAAiB,IAAI,CAAC;AACjD,IAAA,MAAM,UAAU,GAAG,MAAM,CAAoB,IAAI,CAAC;AAClD,IAAA,MAAM,aAAa,GAAG,aAAa,CAAoB,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC;AACnG,IAAA,MAAM,gBAAgB,GAAG,aAAa,CAAC,GAAG;AAC1C,IAAA,MAAM,aAAa,GAAG,WAAW,CAAC,CAAC,OAAiC,KAAI;AACpE,QAAA,UAAU,CAAC,OAAO,GAAG,OAAO;QAC5B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,CAAC,KAAK,IAAI,CAAC;IAEvF,qFAAqF;IACrF,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,gCAAgC;IAChC,EAAE,CAAC,EAAE,kBAAkB,CAAC;IAExB,sGAAsG;IACtG,QAAQ,CAAC,EAAE,SAAS,CAAC;CACxB;AAKD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,aAAa,6NAmBvB,kBAAkB,gCAsRpB,CAAC"}
|
|
@@ -155,7 +155,7 @@ const ToolbarFolder = ({ icon, title, tooltipPosition = 'right', folderDirection
|
|
|
155
155
|
: {}),
|
|
156
156
|
}
|
|
157
157
|
: {};
|
|
158
|
-
return (jsx(ToolbarFolderContext.Provider, { value: mode, children: jsxs("div", { ...pt?.root, className: `toolbar-folder-item ${pt?.root?.className ?? ''} ${className ?? ''}`, "data-cratis-part": 'toolbar-folder', "data-open": isExpanded || undefined, ref: containerRef, children: [jsx(Tooltip, { content: title, position: tooltipPosition, disabled: isExpanded || !isToolbarItemVisible, children: jsx("button", { ...pt?.trigger, tabIndex: rovingTrigger.tabIndex, onFocus: rovingTrigger.onFocus, ref: setTriggerRef, type: 'button', "aria-label": title, "aria-expanded": isExpanded, "aria-controls": panelId, onClick: toggleExpanded, className: `toolbar-button cratis:w-10 cratis:h-10 cratis:flex cratis:items-center cratis:justify-center cratis:rounded-lg cratis:cursor-pointer ${activeClass} ${pt?.trigger?.className ?? ''}`, "data-cratis-part": 'toolbar-folder-trigger', "data-open": isExpanded || undefined, children: jsx(IconDisplay, { icon: icon, className: 'cratis:text-lg' }) }) }), jsx("div", { ...pt?.panel, ref: panelRef, id: panelId, role: 'group', "aria-label": isDrawer ? undefined : title, "aria-labelledby": isDrawer ? titleId : undefined, className: `toolbar-folder-panel ${directionClass} ${panelVisibleClass} ${modeClass} ${drawerClass} ${pt?.panel?.className ?? ''}`, style: {
|
|
158
|
+
return (jsx(ToolbarFolderContext.Provider, { value: mode, children: jsxs("div", { ...pt?.root, className: `toolbar-folder-item ${pt?.root?.className ?? ''} ${className ?? ''}`, "data-cratis-part": 'toolbar-folder', "data-cratis-component": 'ToolbarFolder', "data-open": isExpanded || undefined, ref: containerRef, children: [jsx(Tooltip, { content: title, position: tooltipPosition, disabled: isExpanded || !isToolbarItemVisible, children: jsx("button", { ...pt?.trigger, tabIndex: rovingTrigger.tabIndex, onFocus: rovingTrigger.onFocus, ref: setTriggerRef, type: 'button', "aria-label": title, "aria-expanded": isExpanded, "aria-controls": panelId, onClick: toggleExpanded, className: `toolbar-button cratis:w-10 cratis:h-10 cratis:flex cratis:items-center cratis:justify-center cratis:rounded-lg cratis:cursor-pointer ${activeClass} ${pt?.trigger?.className ?? ''}`, "data-cratis-part": 'toolbar-folder-trigger', "data-open": isExpanded || undefined, children: jsx(IconDisplay, { icon: icon, className: 'cratis:text-lg' }) }) }), jsx("div", { ...pt?.panel, ref: panelRef, id: panelId, role: 'group', "aria-label": isDrawer ? undefined : title, "aria-labelledby": isDrawer ? titleId : undefined, className: `toolbar-folder-panel ${directionClass} ${panelVisibleClass} ${modeClass} ${drawerClass} ${pt?.panel?.className ?? ''}`, style: {
|
|
159
159
|
...pt?.panel?.style,
|
|
160
160
|
...(mode === 'grid' && !isDrawer
|
|
161
161
|
? {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolbarFolder.js","sources":["../../../Toolbar/ToolbarFolder.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport {\n Children,\n type ButtonHTMLAttributes,\n type CSSProperties,\n type DragEvent,\n type HTMLAttributes,\n type ReactNode,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useCallback,\n useState,\n} from 'react';\nimport { useRovingTool } from '../Common/ToolbarRovingContext';\nimport { IconDisplay } from '../Common/Icon';\nimport type { Icon } from '../Common/Icon';\nimport { Tooltip } from '../Common/Tooltip';\nimport type { TooltipPosition } from '../Common/Tooltip';\nimport { useCratisComponentsConfig } from '../Common/CratisComponentsProvider';\nimport { useCratisIcon } from '../configuration/useCratisIcon';\nimport { ToolbarDrawerContext } from './ToolbarDrawerContext';\nimport { resolveToolbarDrawerPlacement } from './ToolbarDrawerPlacement';\nimport type { ToolbarDrawerPlacement } from './ToolbarDrawerPlacement';\nimport type { ToolbarDrawerItem } from './ToolbarDrawerItem';\nimport { ToolbarDrawerTile } from './ToolbarDrawerTile';\nimport type { ToolbarFolderPresentation } from './ToolbarFolderPresentation';\nimport { ToolbarFolderContext } from './ToolbarFolderContext';\nimport {\n ToolbarItemVisibilityProvider,\n useToolbarItemVisibility,\n} from './ToolbarItemVisibilityContext';\nimport type { ToolbarFolderMode } from './ToolbarFolderContext';\n\n/** Stable part attributes for {@link ToolbarFolder}. */\nexport interface ToolbarFolderParts {\n /** Folder composition and measurement root. */\n root?: HTMLAttributes<HTMLDivElement>;\n /** Native folder trigger. */\n trigger?: ButtonHTMLAttributes<HTMLButtonElement>;\n /** Expanded item panel. */\n panel?: HTMLAttributes<HTMLDivElement>;\n /** Drawer presentation: the header row holding the title and the close action. */\n drawerHeader?: HTMLAttributes<HTMLDivElement>;\n /** Drawer presentation: the visible heading. */\n drawerTitle?: HTMLAttributes<HTMLSpanElement>;\n /** Drawer presentation: the native close button. */\n drawerClose?: ButtonHTMLAttributes<HTMLButtonElement>;\n /** Drawer presentation: each labeled tile rendered from `items`. */\n tile?: ButtonHTMLAttributes<HTMLButtonElement>;\n /** Drawer presentation: the icon wrapper inside each tile rendered from `items`. */\n tileIcon?: HTMLAttributes<HTMLSpanElement>;\n /** Drawer presentation: the label inside each tile rendered from `items`. */\n tileLabel?: HTMLAttributes<HTMLSpanElement>;\n}\n\n/** Props for the {@link ToolbarFolder} component. */\nexport interface ToolbarFolderProps {\n /** The icon to display on the folder trigger button. */\n icon: Icon;\n\n /** Title text shown when hovering over the folder trigger button. */\n title: string;\n\n /** Position of the tooltip relative to the trigger button (default: 'right'). */\n tooltipPosition?: TooltipPosition;\n\n /** Direction the folder opens from the trigger button (default: 'right'). */\n folderDirection?: 'right' | 'left';\n\n /**\n * Display mode for the folder's expanded panel (default: `'grid'`).\n *\n * - `'grid'` — items are arranged in a balanced grid (existing behaviour).\n * - `'list'` — items are stacked vertically with the icon and title label shown side by side.\n */\n mode?: ToolbarFolderMode;\n\n /**\n * How the expanded panel is presented (default: `'compact'`, the existing popout).\n * Set `'drawer'` for a headed panel with a visible title, a close action and labeled tiles.\n */\n presentation?: ToolbarFolderPresentation;\n\n /** Maximum number of columns to render before adding more rows (default: 5, or 3 for the drawer). Not used in `list` mode. */\n maxColumns?: number;\n\n /** Drawer presentation: visible heading. Defaults to {@link title}. */\n heading?: string;\n\n /** Drawer presentation: accessible name of the close button. Falls back to `messages.toolbar.closeDrawer`, then `Close`. */\n closeLabel?: string;\n\n /**\n * Drawer presentation: a data-driven catalogue rendered as labeled tiles before any `children`.\n * Each item's `payload` is delivered unchanged to {@link onActivate} and on drag; items are never\n * normalized or filtered.\n */\n items?: ReadonlyArray<ToolbarDrawerItem>;\n\n /** Drawer presentation: called when a catalogue tile is activated by click, Enter or Space. The consumer decides the insertion target. */\n onActivate?: (item: ToolbarDrawerItem) => void;\n\n /** Drawer presentation: called when a drag of a catalogue tile starts. */\n onItemDragStart?: (item: ToolbarDrawerItem, event: DragEvent<HTMLButtonElement>) => void;\n\n /** Drawer presentation: called when a drag of a catalogue tile ends, whether it was dropped or cancelled. */\n onItemDragEnd?: (item: ToolbarDrawerItem, event: DragEvent<HTMLButtonElement>) => void;\n\n /** Drawer presentation: whether catalogue tiles can be dragged (default: `true`). */\n draggable?: boolean;\n\n /**\n * Drawer presentation: close the drawer after a tile is activated or a drag is dropped\n * (default: `false`, so several items can be inserted in a row). A cancelled drag never closes it.\n */\n closeOnInsert?: boolean;\n\n /** Extra class name for the folder root. */\n className?: string;\n\n /** Stable folder attributes. */\n pt?: ToolbarFolderParts;\n\n /** The toolbar buttons shown when the folder is expanded. Optional when a drawer supplies `items`. */\n children?: ReactNode;\n}\n\nconst drawerPlacementGap = 12;\nconst drawerViewportMargin = 8;\n\n/**\n * A toolbar folder that reveals a panel of buttons when clicked.\n *\n * **Grid mode** (default): items are arranged in a balanced grid that grows naturally as\n * more items are added and keeps a compact footprint for small sets.\n *\n * **List mode**: items are stacked vertically with their icon and title label rendered\n * side by side — useful when labels add important context to icon-only buttons.\n *\n * **Drawer presentation** (`presentation='drawer'`): a headed panel with a visible title, a close\n * action and labeled icon tiles. Tiles come from a data-driven `items` catalogue and/or `children`.\n * The drawer only presents the palette: dropping a tile and deciding what it creates stay with the consumer.\n */\nexport const ToolbarFolder = ({\n icon,\n title,\n tooltipPosition = 'right',\n folderDirection = 'right',\n mode = 'grid',\n presentation = 'compact',\n maxColumns,\n heading,\n closeLabel,\n items: catalogue,\n onActivate,\n onItemDragStart,\n onItemDragEnd,\n draggable = true,\n closeOnInsert = false,\n className,\n pt,\n children,\n}: ToolbarFolderProps) => {\n const isDrawer = presentation === 'drawer';\n const [isExpanded, setIsExpanded] = useState(false);\n const [isDragging, setIsDragging] = useState(false);\n const [placement, setPlacement] = useState<ToolbarDrawerPlacement | null>(null);\n const isToolbarItemVisible = useToolbarItemVisibility();\n const { messages } = useCratisComponentsConfig();\n const resolveIcon = useCratisIcon();\n const containerRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const panelRef = useRef<HTMLDivElement>(null);\n const rovingTrigger = useRovingTool<HTMLButtonElement>(pt?.trigger?.tabIndex, pt?.trigger?.onFocus);\n const rovingTriggerRef = rovingTrigger.ref;\n const setTriggerRef = useCallback((element: HTMLButtonElement | null) => {\n triggerRef.current = element;\n if (typeof rovingTriggerRef === 'function') rovingTriggerRef(element);\n }, [rovingTriggerRef]);\n const generatedPanelId = useId();\n const generatedTitleId = useId();\n const titleId = pt?.drawerTitle?.id ?? generatedTitleId;\n const panelId = pt?.panel?.id ?? generatedPanelId;\n\n const catalogueItems = useMemo(() => (isDrawer ? catalogue ?? [] : []), [isDrawer, catalogue]);\n const items = useMemo(\n () =>\n Children.toArray(children).filter(\n (child) => child !== null && child !== undefined,\n ),\n [children],\n );\n const itemCount = Math.max(1, items.length + catalogueItems.length);\n const resolvedMaxColumns = maxColumns ?? (isDrawer ? 3 : 5);\n\n const columns = useMemo(() => {\n const upperBound = Math.max(1, resolvedMaxColumns);\n const balancedColumns = Math.ceil(Math.sqrt(itemCount));\n return Math.min(upperBound, balancedColumns);\n }, [itemCount, resolvedMaxColumns]);\n\n const toggleExpanded = () => {\n setIsExpanded((current) => !current);\n };\n\n const close = useCallback((restoreFocus: boolean) => {\n setIsExpanded(false);\n if (restoreFocus) window.setTimeout(() => triggerRef.current?.focus(), 0);\n }, []);\n\n const drawerContext = useMemo(() => ({ setDragging: setIsDragging }), []);\n\n useEffect(() => {\n if (!isExpanded) {\n return;\n }\n\n const handleClickOutside = (event: Event) => {\n if (\n containerRef.current &&\n !containerRef.current.contains(event.target as Node)\n ) {\n setIsExpanded(false);\n }\n };\n\n const handleEscape = (event: KeyboardEvent) => {\n if (event.key !== 'Escape') return;\n event.preventDefault();\n event.stopPropagation();\n close(true);\n };\n\n document.addEventListener('mousedown', handleClickOutside);\n if (isDrawer) document.addEventListener('pointerdown', handleClickOutside);\n document.addEventListener('keydown', handleEscape, true);\n return () => {\n document.removeEventListener('mousedown', handleClickOutside);\n document.removeEventListener('pointerdown', handleClickOutside);\n document.removeEventListener('keydown', handleEscape, true);\n };\n }, [isExpanded, isDrawer, close]);\n\n useEffect(() => {\n if (!isExpanded) setIsDragging(false);\n }, [isExpanded]);\n\n useLayoutEffect(() => {\n const trigger = triggerRef.current;\n const panel = panelRef.current;\n if (!isDrawer || !isExpanded || !trigger || !panel) return;\n\n const measure = () => {\n const toolbar = containerRef.current?.closest('[role=\"toolbar\"]');\n const orientation = toolbar?.getAttribute('aria-orientation') === 'horizontal' ? 'horizontal' : 'vertical';\n const rectangle = trigger.getBoundingClientRect();\n const next = resolveToolbarDrawerPlacement({\n trigger: { left: rectangle.left, top: rectangle.top, right: rectangle.right, bottom: rectangle.bottom },\n panel: {\n width: panel.scrollWidth + (panel.offsetWidth - panel.clientWidth),\n height: panel.scrollHeight + (panel.offsetHeight - panel.clientHeight),\n },\n viewport: { width: window.innerWidth, height: window.innerHeight },\n orientation,\n preferredHorizontalSide: folderDirection,\n gap: drawerPlacementGap,\n margin: drawerViewportMargin,\n });\n setPlacement((current) =>\n current &&\n current.side === next.side &&\n current.shift === next.shift &&\n current.mainShift === next.mainShift &&\n current.maxHeight === next.maxHeight &&\n current.maxWidth === next.maxWidth\n ? current\n : next,\n );\n };\n\n measure();\n window.addEventListener('resize', measure);\n return () => window.removeEventListener('resize', measure);\n }, [isDrawer, isExpanded, folderDirection, catalogueItems.length, items.length]);\n\n const handleTileActivate = (item: ToolbarDrawerItem) => {\n onActivate?.(item);\n if (closeOnInsert) close(true);\n };\n\n const handleTileDragEnd = (item: ToolbarDrawerItem, event: DragEvent<HTMLButtonElement>) => {\n onItemDragEnd?.(item, event);\n if (closeOnInsert && event.dataTransfer?.dropEffect !== 'none') close(false);\n };\n\n const activeClass = isExpanded ? 'toolbar-button--active' : '';\n const panelVisibleClass = isExpanded ? 'toolbar-folder-panel--visible' : '';\n const directionClass = `toolbar-folder-panel--${folderDirection}`;\n const modeClass = mode === 'list' ? 'toolbar-folder-panel--list' : '';\n const drawerClass = isDrawer ? 'toolbar-folder-panel--drawer' : '';\n const resolvedHeading = heading ?? title;\n const resolvedCloseLabel = closeLabel ?? messages?.toolbar?.closeDrawer ?? 'Close';\n const resolvedCloseIcon = resolveIcon('close', '×');\n\n const drawerStyle: CSSProperties = isDrawer\n ? ({\n '--toolbar-drawer-columns': columns,\n ...(placement\n ? {\n '--toolbar-drawer-shift': `${placement.shift}px`,\n '--toolbar-drawer-main-shift': `${placement.mainShift}px`,\n '--toolbar-drawer-max-height': `${placement.maxHeight}px`,\n '--toolbar-drawer-max-width': `${placement.maxWidth}px`,\n }\n : {}),\n } as CSSProperties)\n : {};\n\n return (\n <ToolbarFolderContext.Provider value={mode}>\n <div\n {...pt?.root}\n className={`toolbar-folder-item ${pt?.root?.className ?? ''} ${className ?? ''}`}\n data-cratis-part='toolbar-folder'\n data-open={isExpanded || undefined}\n ref={containerRef}\n >\n <Tooltip\n content={title}\n position={tooltipPosition}\n disabled={isExpanded || !isToolbarItemVisible}\n >\n <button\n {...pt?.trigger}\n tabIndex={rovingTrigger.tabIndex}\n onFocus={rovingTrigger.onFocus}\n ref={setTriggerRef}\n type='button'\n aria-label={title}\n aria-expanded={isExpanded}\n aria-controls={panelId}\n onClick={toggleExpanded}\n className={`toolbar-button cratis:w-10 cratis:h-10 cratis:flex cratis:items-center cratis:justify-center cratis:rounded-lg cratis:cursor-pointer ${activeClass} ${pt?.trigger?.className ?? ''}`}\n data-cratis-part='toolbar-folder-trigger'\n data-open={isExpanded || undefined}\n >\n <IconDisplay icon={icon} className='cratis:text-lg' />\n </button>\n </Tooltip>\n <div\n {...pt?.panel}\n ref={panelRef}\n id={panelId}\n role='group'\n aria-label={isDrawer ? undefined : title}\n aria-labelledby={isDrawer ? titleId : undefined}\n className={`toolbar-folder-panel ${directionClass} ${panelVisibleClass} ${modeClass} ${drawerClass} ${pt?.panel?.className ?? ''}`}\n style={{\n ...pt?.panel?.style,\n ...(mode === 'grid' && !isDrawer\n ? {\n gridTemplateColumns: `repeat(${columns}, minmax(2.5rem, 2.5rem))`,\n }\n : {}),\n ...drawerStyle,\n }}\n data-cratis-part='toolbar-folder-panel'\n data-expanded={isExpanded || undefined}\n data-open={isExpanded || undefined}\n data-direction={folderDirection}\n data-mode={mode}\n data-presentation={isDrawer ? 'drawer' : undefined}\n data-side={isDrawer ? placement?.side ?? folderDirection : undefined}\n data-dragging={isDrawer && isDragging ? '' : undefined}\n aria-hidden={!isExpanded}\n inert={!isExpanded}\n >\n <ToolbarItemVisibilityProvider\n value={isExpanded && isToolbarItemVisible}\n >\n {isDrawer ? (\n <ToolbarDrawerContext.Provider value={drawerContext}>\n <div\n {...pt?.drawerHeader}\n className={`toolbar-drawer-header ${pt?.drawerHeader?.className ?? ''}`}\n data-cratis-part='toolbar-folder-header'\n >\n <span\n {...pt?.drawerTitle}\n id={titleId}\n className={`toolbar-drawer-title ${pt?.drawerTitle?.className ?? ''}`}\n data-cratis-part='toolbar-folder-title'\n >\n {resolvedHeading}\n </span>\n <button\n {...pt?.drawerClose}\n type='button'\n aria-label={resolvedCloseLabel}\n onClick={(event) => {\n pt?.drawerClose?.onClick?.(event);\n close(true);\n }}\n className={`toolbar-button toolbar-drawer-close ${pt?.drawerClose?.className ?? ''}`}\n data-cratis-part='toolbar-folder-close'\n >\n {resolvedCloseIcon}\n </button>\n </div>\n <div className='toolbar-drawer-tiles'>\n {catalogueItems.map((item) => (\n <ToolbarDrawerTile\n key={item.id}\n title={item.title}\n icon={item.icon}\n disabled={item.disabled}\n disabledReason={item.disabledReason}\n draggable={draggable}\n data={item.payload}\n onClick={() => handleTileActivate(item)}\n onDragStart={(_, event) => onItemDragStart?.(item, event)}\n onDragEnd={(_, event) => handleTileDragEnd(item, event)}\n itemId={item.id}\n root={pt?.tile}\n iconPart={pt?.tileIcon}\n label={pt?.tileLabel}\n />\n ))}\n {items}\n </div>\n </ToolbarDrawerContext.Provider>\n ) : (\n items\n )}\n </ToolbarItemVisibilityProvider>\n </div>\n </div>\n </ToolbarFolderContext.Provider>\n );\n};\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;AAoIA,MAAM,kBAAkB,GAAG,EAAE;AAC7B,MAAM,oBAAoB,GAAG,CAAC;AAevB,MAAM,aAAa,GAAG,CAAC,EAC1B,IAAI,EACJ,KAAK,EACL,eAAe,GAAG,OAAO,EACzB,eAAe,GAAG,OAAO,EACzB,IAAI,GAAG,MAAM,EACb,YAAY,GAAG,SAAS,EACxB,U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\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport {\n Children,\n type ButtonHTMLAttributes,\n type CSSProperties,\n type DragEvent,\n type HTMLAttributes,\n type ReactNode,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useCallback,\n useState,\n} from 'react';\nimport { useRovingTool } from '../Common/ToolbarRovingContext';\nimport { IconDisplay } from '../Common/Icon';\nimport type { Icon } from '../Common/Icon';\nimport { Tooltip } from '../Common/Tooltip';\nimport type { TooltipPosition } from '../Common/Tooltip';\nimport { useCratisComponentsConfig } from '../Common/CratisComponentsProvider';\nimport { useCratisIcon } from '../configuration/useCratisIcon';\nimport { ToolbarDrawerContext } from './ToolbarDrawerContext';\nimport { resolveToolbarDrawerPlacement } from './ToolbarDrawerPlacement';\nimport type { ToolbarDrawerPlacement } from './ToolbarDrawerPlacement';\nimport type { ToolbarDrawerItem } from './ToolbarDrawerItem';\nimport { ToolbarDrawerTile } from './ToolbarDrawerTile';\nimport type { ToolbarFolderPresentation } from './ToolbarFolderPresentation';\nimport { ToolbarFolderContext } from './ToolbarFolderContext';\nimport {\n ToolbarItemVisibilityProvider,\n useToolbarItemVisibility,\n} from './ToolbarItemVisibilityContext';\nimport type { ToolbarFolderMode } from './ToolbarFolderContext';\n\n/** Stable part attributes for {@link ToolbarFolder}. */\nexport interface ToolbarFolderParts {\n /** Folder composition and measurement root. */\n root?: HTMLAttributes<HTMLDivElement>;\n /** Native folder trigger. */\n trigger?: ButtonHTMLAttributes<HTMLButtonElement>;\n /** Expanded item panel. */\n panel?: HTMLAttributes<HTMLDivElement>;\n /** Drawer presentation: the header row holding the title and the close action. */\n drawerHeader?: HTMLAttributes<HTMLDivElement>;\n /** Drawer presentation: the visible heading. */\n drawerTitle?: HTMLAttributes<HTMLSpanElement>;\n /** Drawer presentation: the native close button. */\n drawerClose?: ButtonHTMLAttributes<HTMLButtonElement>;\n /** Drawer presentation: each labeled tile rendered from `items`. */\n tile?: ButtonHTMLAttributes<HTMLButtonElement>;\n /** Drawer presentation: the icon wrapper inside each tile rendered from `items`. */\n tileIcon?: HTMLAttributes<HTMLSpanElement>;\n /** Drawer presentation: the label inside each tile rendered from `items`. */\n tileLabel?: HTMLAttributes<HTMLSpanElement>;\n}\n\n/** Props for the {@link ToolbarFolder} component. */\nexport interface ToolbarFolderProps {\n /** The icon to display on the folder trigger button. */\n icon: Icon;\n\n /** Title text shown when hovering over the folder trigger button. */\n title: string;\n\n /** Position of the tooltip relative to the trigger button (default: 'right'). */\n tooltipPosition?: TooltipPosition;\n\n /** Direction the folder opens from the trigger button (default: 'right'). */\n folderDirection?: 'right' | 'left';\n\n /**\n * Display mode for the folder's expanded panel (default: `'grid'`).\n *\n * - `'grid'` — items are arranged in a balanced grid (existing behaviour).\n * - `'list'` — items are stacked vertically with the icon and title label shown side by side.\n */\n mode?: ToolbarFolderMode;\n\n /**\n * How the expanded panel is presented (default: `'compact'`, the existing popout).\n * Set `'drawer'` for a headed panel with a visible title, a close action and labeled tiles.\n */\n presentation?: ToolbarFolderPresentation;\n\n /** Maximum number of columns to render before adding more rows (default: 5, or 3 for the drawer). Not used in `list` mode. */\n maxColumns?: number;\n\n /** Drawer presentation: visible heading. Defaults to {@link title}. */\n heading?: string;\n\n /** Drawer presentation: accessible name of the close button. Falls back to `messages.toolbar.closeDrawer`, then `Close`. */\n closeLabel?: string;\n\n /**\n * Drawer presentation: a data-driven catalogue rendered as labeled tiles before any `children`.\n * Each item's `payload` is delivered unchanged to {@link onActivate} and on drag; items are never\n * normalized or filtered.\n */\n items?: ReadonlyArray<ToolbarDrawerItem>;\n\n /** Drawer presentation: called when a catalogue tile is activated by click, Enter or Space. The consumer decides the insertion target. */\n onActivate?: (item: ToolbarDrawerItem) => void;\n\n /** Drawer presentation: called when a drag of a catalogue tile starts. */\n onItemDragStart?: (item: ToolbarDrawerItem, event: DragEvent<HTMLButtonElement>) => void;\n\n /** Drawer presentation: called when a drag of a catalogue tile ends, whether it was dropped or cancelled. */\n onItemDragEnd?: (item: ToolbarDrawerItem, event: DragEvent<HTMLButtonElement>) => void;\n\n /** Drawer presentation: whether catalogue tiles can be dragged (default: `true`). */\n draggable?: boolean;\n\n /**\n * Drawer presentation: close the drawer after a tile is activated or a drag is dropped\n * (default: `false`, so several items can be inserted in a row). A cancelled drag never closes it.\n */\n closeOnInsert?: boolean;\n\n /** Extra class name for the folder root. */\n className?: string;\n\n /** Stable folder attributes. */\n pt?: ToolbarFolderParts;\n\n /** The toolbar buttons shown when the folder is expanded. Optional when a drawer supplies `items`. */\n children?: ReactNode;\n}\n\nconst drawerPlacementGap = 12;\nconst drawerViewportMargin = 8;\n\n/**\n * A toolbar folder that reveals a panel of buttons when clicked.\n *\n * **Grid mode** (default): items are arranged in a balanced grid that grows naturally as\n * more items are added and keeps a compact footprint for small sets.\n *\n * **List mode**: items are stacked vertically with their icon and title label rendered\n * side by side — useful when labels add important context to icon-only buttons.\n *\n * **Drawer presentation** (`presentation='drawer'`): a headed panel with a visible title, a close\n * action and labeled icon tiles. Tiles come from a data-driven `items` catalogue and/or `children`.\n * The drawer only presents the palette: dropping a tile and deciding what it creates stay with the consumer.\n */\nexport const ToolbarFolder = ({\n icon,\n title,\n tooltipPosition = 'right',\n folderDirection = 'right',\n mode = 'grid',\n presentation = 'compact',\n maxColumns,\n heading,\n closeLabel,\n items: catalogue,\n onActivate,\n onItemDragStart,\n onItemDragEnd,\n draggable = true,\n closeOnInsert = false,\n className,\n pt,\n children,\n}: ToolbarFolderProps) => {\n const isDrawer = presentation === 'drawer';\n const [isExpanded, setIsExpanded] = useState(false);\n const [isDragging, setIsDragging] = useState(false);\n const [placement, setPlacement] = useState<ToolbarDrawerPlacement | null>(null);\n const isToolbarItemVisible = useToolbarItemVisibility();\n const { messages } = useCratisComponentsConfig();\n const resolveIcon = useCratisIcon();\n const containerRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const panelRef = useRef<HTMLDivElement>(null);\n const rovingTrigger = useRovingTool<HTMLButtonElement>(pt?.trigger?.tabIndex, pt?.trigger?.onFocus);\n const rovingTriggerRef = rovingTrigger.ref;\n const setTriggerRef = useCallback((element: HTMLButtonElement | null) => {\n triggerRef.current = element;\n if (typeof rovingTriggerRef === 'function') rovingTriggerRef(element);\n }, [rovingTriggerRef]);\n const generatedPanelId = useId();\n const generatedTitleId = useId();\n const titleId = pt?.drawerTitle?.id ?? generatedTitleId;\n const panelId = pt?.panel?.id ?? generatedPanelId;\n\n const catalogueItems = useMemo(() => (isDrawer ? catalogue ?? [] : []), [isDrawer, catalogue]);\n const items = useMemo(\n () =>\n Children.toArray(children).filter(\n (child) => child !== null && child !== undefined,\n ),\n [children],\n );\n const itemCount = Math.max(1, items.length + catalogueItems.length);\n const resolvedMaxColumns = maxColumns ?? (isDrawer ? 3 : 5);\n\n const columns = useMemo(() => {\n const upperBound = Math.max(1, resolvedMaxColumns);\n const balancedColumns = Math.ceil(Math.sqrt(itemCount));\n return Math.min(upperBound, balancedColumns);\n }, [itemCount, resolvedMaxColumns]);\n\n const toggleExpanded = () => {\n setIsExpanded((current) => !current);\n };\n\n const close = useCallback((restoreFocus: boolean) => {\n setIsExpanded(false);\n if (restoreFocus) window.setTimeout(() => triggerRef.current?.focus(), 0);\n }, []);\n\n const drawerContext = useMemo(() => ({ setDragging: setIsDragging }), []);\n\n useEffect(() => {\n if (!isExpanded) {\n return;\n }\n\n const handleClickOutside = (event: Event) => {\n if (\n containerRef.current &&\n !containerRef.current.contains(event.target as Node)\n ) {\n setIsExpanded(false);\n }\n };\n\n const handleEscape = (event: KeyboardEvent) => {\n if (event.key !== 'Escape') return;\n event.preventDefault();\n event.stopPropagation();\n close(true);\n };\n\n document.addEventListener('mousedown', handleClickOutside);\n if (isDrawer) document.addEventListener('pointerdown', handleClickOutside);\n document.addEventListener('keydown', handleEscape, true);\n return () => {\n document.removeEventListener('mousedown', handleClickOutside);\n document.removeEventListener('pointerdown', handleClickOutside);\n document.removeEventListener('keydown', handleEscape, true);\n };\n }, [isExpanded, isDrawer, close]);\n\n useEffect(() => {\n if (!isExpanded) setIsDragging(false);\n }, [isExpanded]);\n\n useLayoutEffect(() => {\n const trigger = triggerRef.current;\n const panel = panelRef.current;\n if (!isDrawer || !isExpanded || !trigger || !panel) return;\n\n const measure = () => {\n const toolbar = containerRef.current?.closest('[role=\"toolbar\"]');\n const orientation = toolbar?.getAttribute('aria-orientation') === 'horizontal' ? 'horizontal' : 'vertical';\n const rectangle = trigger.getBoundingClientRect();\n const next = resolveToolbarDrawerPlacement({\n trigger: { left: rectangle.left, top: rectangle.top, right: rectangle.right, bottom: rectangle.bottom },\n panel: {\n width: panel.scrollWidth + (panel.offsetWidth - panel.clientWidth),\n height: panel.scrollHeight + (panel.offsetHeight - panel.clientHeight),\n },\n viewport: { width: window.innerWidth, height: window.innerHeight },\n orientation,\n preferredHorizontalSide: folderDirection,\n gap: drawerPlacementGap,\n margin: drawerViewportMargin,\n });\n setPlacement((current) =>\n current &&\n current.side === next.side &&\n current.shift === next.shift &&\n current.mainShift === next.mainShift &&\n current.maxHeight === next.maxHeight &&\n current.maxWidth === next.maxWidth\n ? current\n : next,\n );\n };\n\n measure();\n window.addEventListener('resize', measure);\n return () => window.removeEventListener('resize', measure);\n }, [isDrawer, isExpanded, folderDirection, catalogueItems.length, items.length]);\n\n const handleTileActivate = (item: ToolbarDrawerItem) => {\n onActivate?.(item);\n if (closeOnInsert) close(true);\n };\n\n const handleTileDragEnd = (item: ToolbarDrawerItem, event: DragEvent<HTMLButtonElement>) => {\n onItemDragEnd?.(item, event);\n if (closeOnInsert && event.dataTransfer?.dropEffect !== 'none') close(false);\n };\n\n const activeClass = isExpanded ? 'toolbar-button--active' : '';\n const panelVisibleClass = isExpanded ? 'toolbar-folder-panel--visible' : '';\n const directionClass = `toolbar-folder-panel--${folderDirection}`;\n const modeClass = mode === 'list' ? 'toolbar-folder-panel--list' : '';\n const drawerClass = isDrawer ? 'toolbar-folder-panel--drawer' : '';\n const resolvedHeading = heading ?? title;\n const resolvedCloseLabel = closeLabel ?? messages?.toolbar?.closeDrawer ?? 'Close';\n const resolvedCloseIcon = resolveIcon('close', '×');\n\n const drawerStyle: CSSProperties = isDrawer\n ? ({\n '--toolbar-drawer-columns': columns,\n ...(placement\n ? {\n '--toolbar-drawer-shift': `${placement.shift}px`,\n '--toolbar-drawer-main-shift': `${placement.mainShift}px`,\n '--toolbar-drawer-max-height': `${placement.maxHeight}px`,\n '--toolbar-drawer-max-width': `${placement.maxWidth}px`,\n }\n : {}),\n } as CSSProperties)\n : {};\n\n return (\n <ToolbarFolderContext.Provider value={mode}>\n <div\n {...pt?.root}\n className={`toolbar-folder-item ${pt?.root?.className ?? ''} ${className ?? ''}`}\n data-cratis-part='toolbar-folder'\n data-cratis-component='ToolbarFolder'\n data-open={isExpanded || undefined}\n ref={containerRef}\n >\n <Tooltip\n content={title}\n position={tooltipPosition}\n disabled={isExpanded || !isToolbarItemVisible}\n >\n <button\n {...pt?.trigger}\n tabIndex={rovingTrigger.tabIndex}\n onFocus={rovingTrigger.onFocus}\n ref={setTriggerRef}\n type='button'\n aria-label={title}\n aria-expanded={isExpanded}\n aria-controls={panelId}\n onClick={toggleExpanded}\n className={`toolbar-button cratis:w-10 cratis:h-10 cratis:flex cratis:items-center cratis:justify-center cratis:rounded-lg cratis:cursor-pointer ${activeClass} ${pt?.trigger?.className ?? ''}`}\n data-cratis-part='toolbar-folder-trigger'\n data-open={isExpanded || undefined}\n >\n <IconDisplay icon={icon} className='cratis:text-lg' />\n </button>\n </Tooltip>\n <div\n {...pt?.panel}\n ref={panelRef}\n id={panelId}\n role='group'\n aria-label={isDrawer ? undefined : title}\n aria-labelledby={isDrawer ? titleId : undefined}\n className={`toolbar-folder-panel ${directionClass} ${panelVisibleClass} ${modeClass} ${drawerClass} ${pt?.panel?.className ?? ''}`}\n style={{\n ...pt?.panel?.style,\n ...(mode === 'grid' && !isDrawer\n ? {\n gridTemplateColumns: `repeat(${columns}, minmax(2.5rem, 2.5rem))`,\n }\n : {}),\n ...drawerStyle,\n }}\n data-cratis-part='toolbar-folder-panel'\n data-expanded={isExpanded || undefined}\n data-open={isExpanded || undefined}\n data-direction={folderDirection}\n data-mode={mode}\n data-presentation={isDrawer ? 'drawer' : undefined}\n data-side={isDrawer ? placement?.side ?? folderDirection : undefined}\n data-dragging={isDrawer && isDragging ? '' : undefined}\n aria-hidden={!isExpanded}\n inert={!isExpanded}\n >\n <ToolbarItemVisibilityProvider\n value={isExpanded && isToolbarItemVisible}\n >\n {isDrawer ? (\n <ToolbarDrawerContext.Provider value={drawerContext}>\n <div\n {...pt?.drawerHeader}\n className={`toolbar-drawer-header ${pt?.drawerHeader?.className ?? ''}`}\n data-cratis-part='toolbar-folder-header'\n >\n <span\n {...pt?.drawerTitle}\n id={titleId}\n className={`toolbar-drawer-title ${pt?.drawerTitle?.className ?? ''}`}\n data-cratis-part='toolbar-folder-title'\n >\n {resolvedHeading}\n </span>\n <button\n {...pt?.drawerClose}\n type='button'\n aria-label={resolvedCloseLabel}\n onClick={(event) => {\n pt?.drawerClose?.onClick?.(event);\n close(true);\n }}\n className={`toolbar-button toolbar-drawer-close ${pt?.drawerClose?.className ?? ''}`}\n data-cratis-part='toolbar-folder-close'\n >\n {resolvedCloseIcon}\n </button>\n </div>\n <div className='toolbar-drawer-tiles'>\n {catalogueItems.map((item) => (\n <ToolbarDrawerTile\n key={item.id}\n title={item.title}\n icon={item.icon}\n disabled={item.disabled}\n disabledReason={item.disabledReason}\n draggable={draggable}\n data={item.payload}\n onClick={() => handleTileActivate(item)}\n onDragStart={(_, event) => onItemDragStart?.(item, event)}\n onDragEnd={(_, event) => handleTileDragEnd(item, event)}\n itemId={item.id}\n root={pt?.tile}\n iconPart={pt?.tileIcon}\n label={pt?.tileLabel}\n />\n ))}\n {items}\n </div>\n </ToolbarDrawerContext.Provider>\n ) : (\n items\n )}\n </ToolbarItemVisibilityProvider>\n </div>\n </div>\n </ToolbarFolderContext.Provider>\n );\n};\n"],"names":["_j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EAAA,CACJ,CAAA,EAAA,CACsB,KAEhC,KAAK,CACR,EAAA,CAC2B,GAC9B,CAAA,EAAA,CACJ,EAAA,CACsB;AAExC;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolbarGroup.d.ts","sourceRoot":"","sources":["../../../Toolbar/ToolbarGroup.tsx"],"names":[],"mappings":"AAGA,OAAO,EACH,KAAK,cAAc,EACnB,KAAK,SAAS,EAMjB,MAAM,OAAO,CAAC;AAkIf,uDAAuD;AACvD,MAAM,WAAW,iBAAiB;IAC9B,2DAA2D;IAC3D,IAAI,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;IACtC,yFAAyF;IACzF,IAAI,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;IACtC,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;IAC1C,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;CAC7C;AAED,oDAAoD;AACpD,MAAM,WAAW,iBAAiB;IAC9B,qDAAqD;IACrD,QAAQ,CAAC,EAAE,SAAS,CAAC;IAErB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,sGAAsG;IACtG,WAAW,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;IAExC,wDAAwD;IACxD,EAAE,CAAC,EAAE,iBAAiB,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,YAAY,6CAKtB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"ToolbarGroup.d.ts","sourceRoot":"","sources":["../../../Toolbar/ToolbarGroup.tsx"],"names":[],"mappings":"AAGA,OAAO,EACH,KAAK,cAAc,EACnB,KAAK,SAAS,EAMjB,MAAM,OAAO,CAAC;AAkIf,uDAAuD;AACvD,MAAM,WAAW,iBAAiB;IAC9B,2DAA2D;IAC3D,IAAI,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;IACtC,yFAAyF;IACzF,IAAI,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;IACtC,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;IAC1C,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;CAC7C;AAED,oDAAoD;AACpD,MAAM,WAAW,iBAAiB;IAC9B,qDAAqD;IACrD,QAAQ,CAAC,EAAE,SAAS,CAAC;IAErB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,sGAAsG;IACtG,WAAW,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;IAExC,wDAAwD;IACxD,EAAE,CAAC,EAAE,iBAAiB,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,YAAY,6CAKtB,iBAAiB,gCAenB,CAAC"}
|
|
@@ -56,7 +56,7 @@ const SlotTransition = ({ slotName, flexClass, pt, }) => {
|
|
|
56
56
|
};
|
|
57
57
|
const ToolbarGroup = ({ children, slotName, orientation = 'vertical', pt, }) => {
|
|
58
58
|
const flexClass = orientation === 'horizontal' ? 'cratis:flex-row' : 'cratis:flex-col';
|
|
59
|
-
return (jsxs("div", { ...pt?.root, className: `toolbar-group cratis:inline-flex ${flexClass} cratis:items-center cratis:gap-1 cratis:p-2 cratis:rounded-2xl ${pt?.root?.className ?? ''}`, "data-cratis-part": 'toolbar-group', "data-orientation": orientation, children: [children, slotName && jsx(SlotTransition, { slotName: slotName, flexClass: flexClass, pt: pt })] }));
|
|
59
|
+
return (jsxs("div", { ...pt?.root, className: `toolbar-group cratis:inline-flex ${flexClass} cratis:items-center cratis:gap-1 cratis:p-2 cratis:rounded-2xl ${pt?.root?.className ?? ''}`, "data-cratis-part": 'toolbar-group', "data-cratis-component": 'ToolbarGroup', "data-orientation": orientation, children: [children, slotName && jsx(SlotTransition, { slotName: slotName, flexClass: flexClass, pt: pt })] }));
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
export { ToolbarGroup };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolbarGroup.js","sources":["../../../Toolbar/ToolbarGroup.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport {\n type HTMLAttributes,\n type ReactNode,\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\nimport { useToolbarSlot } from './ToolbarSlot';\n\n/** How long the fade-out animation runs (ms). React unmounts exiting content after this. */\nconst SLOT_TRANSITION_MS = 220;\n\n/**\n * Renders slot items with a cross-fade and size-morph transition that mirrors the\n * {@link ToolbarSection} / {@link ToolbarContext} animation:\n *\n * - The slot container resizes smoothly to fit the incoming content.\n * - The outgoing content fades out while the incoming content fades in simultaneously.\n *\n * The size update is intentionally deferred to {@link useEffect} (after paint) so that\n * the opacity animations start one frame before the resize — matching the feel of\n * {@link ToolbarSection} context switching.\n */\nconst SlotTransition = ({\n slotName,\n flexClass,\n pt,\n}: {\n slotName: string;\n flexClass: string;\n pt?: ToolbarGroupParts;\n}) => {\n const liveItems = useToolbarSlot(slotName);\n\n // `current` is the content fading in (or already settled at full opacity).\n // `exiting` is the previous content fading out, kept alive until its animation completes.\n const [current, setCurrent] = useState<ReactNode[]>(liveItems);\n const [exiting, setExiting] = useState<ReactNode[]>([]);\n const [exitRevision, setExitRevision] = useState(0);\n\n // Track `current` in a ref so the liveItems effect can read the latest value\n // without needing it in its dependency array (avoids an unnecessary re-run loop).\n const currentRef = useRef<ReactNode[]>(current);\n currentRef.current = current;\n\n const incomingRef = useRef<HTMLDivElement>(null);\n const [size, setSize] = useState<{ width: number; height: number } | null>(null);\n const timerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const hasMountedRef = useRef(false);\n\n const measureIncoming = useCallback(() => {\n if (incomingRef.current) {\n setSize({\n width: incomingRef.current.offsetWidth,\n height: incomingRef.current.offsetHeight,\n });\n }\n }, []);\n\n // Set the initial size synchronously before the first paint — no layout flash.\n useLayoutEffect(() => {\n measureIncoming();\n }, []); // mount only\n\n // Detect live-items reference change → start cross-fade transition.\n useEffect(() => {\n if (liveItems === currentRef.current) return;\n const old = currentRef.current;\n\n if (timerRef.current !== undefined) clearTimeout(timerRef.current);\n setCurrent(liveItems);\n\n if (old.length > 0) {\n setExiting(old);\n setExitRevision(r => r + 1);\n timerRef.current = setTimeout(() => setExiting([]), SLOT_TRANSITION_MS);\n }\n }, [liveItems]);\n\n // Re-measure the incoming content whenever `current` changes so the container\n // can size-morph. useEffect (not useLayoutEffect) is intentional: we let the\n // opacity animation start one frame before the resize — matching ToolbarSection.\n useEffect(() => {\n if (!hasMountedRef.current) {\n hasMountedRef.current = true;\n return; // initial measurement handled by useLayoutEffect above\n }\n measureIncoming();\n }, [current, measureIncoming]);\n\n useEffect(() => () => {\n if (timerRef.current !== undefined) clearTimeout(timerRef.current);\n }, []);\n\n if (current.length === 0 && exiting.length === 0) return null;\n\n // The section is only clipped while outgoing content is fading out, so it\n // doesn't bleed outside the container. Once the transition is complete the\n // section must be overflow:visible so fan-out and folder panels (which are\n // position:absolute children) can escape the slot section's bounds.\n const transitioningClass = exiting.length > 0 ? 'toolbar-slot-section--transitioning' : '';\n\n return (\n <div\n {...pt?.slot}\n className={`toolbar-slot-section ${transitioningClass} ${pt?.slot?.className ?? ''}`}\n style={{ ...pt?.slot?.style, ...(size ? { width: size.width, height: size.height } : {}) }}\n data-cratis-part='toolbar-slot'\n data-transitioning={exiting.length > 0 || undefined}\n >\n {/* Incoming content — fades in via @keyframes animation on mount */}\n <div\n {...pt?.incoming}\n ref={incomingRef}\n className={`toolbar-slot-incoming cratis:inline-flex ${flexClass} cratis:items-center cratis:gap-1 ${pt?.incoming?.className ?? ''}`}\n data-cratis-part='toolbar-slot-incoming'\n >\n {current}\n </div>\n {/* Exiting content — fades out, then React unmounts it after SLOT_TRANSITION_MS */}\n {exiting.length > 0 && (\n <div\n key={exitRevision}\n {...pt?.outgoing}\n className={`toolbar-slot-outgoing cratis:inline-flex ${flexClass} cratis:items-center cratis:gap-1 ${pt?.outgoing?.className ?? ''}`}\n data-cratis-part='toolbar-slot-outgoing'\n aria-hidden='true'\n inert\n >\n {exiting}\n </div>\n )}\n </div>\n );\n};\n\n/** Stable part attributes for {@link ToolbarGroup}. */\nexport interface ToolbarGroupParts {\n /** Group root used as one logical measurement boundary. */\n root?: HTMLAttributes<HTMLDivElement>;\n /** Slot-transition boundary rendered when {@link ToolbarGroupProps.slotName} is used. */\n slot?: HTMLAttributes<HTMLDivElement>;\n /** Current slot content. */\n incoming?: HTMLAttributes<HTMLDivElement>;\n /** Previous slot content while it exits. */\n outgoing?: HTMLAttributes<HTMLDivElement>;\n}\n\n/** Props for the {@link ToolbarGroup} component. */\nexport interface ToolbarGroupProps {\n /** The toolbar items to render inside this group. */\n children?: ReactNode;\n\n /**\n * Optional slot name. When provided, any {@link ToolbarSlot} with a matching `slotName`\n * within the nearest {@link ToolbarSlotProvider} will render its content inside this group.\n *\n * Slot entries are appended after the group's own children and sorted by their `order` value.\n */\n slotName?: string;\n\n /** Layout direction of the group, should match the parent {@link Toolbar} (default: `'vertical'`). */\n orientation?: 'vertical' | 'horizontal';\n\n /** Stable group and slot-transition part attributes. */\n pt?: ToolbarGroupParts;\n}\n\n/**\n * A logical sub-grouping of toolbar items within a {@link Toolbar}.\n *\n * Use `ToolbarGroup` to cluster related buttons into a visually cohesive unit.\n * Groups can participate in the slot system by providing a `slotName` — external\n * components anywhere in the {@link ToolbarSlotProvider} tree can then inject additional\n * buttons at a chosen position via {@link ToolbarSlot}.\n *\n * @example\n * ```tsx\n * <Toolbar>\n * <ToolbarGroup slotName=\"canvas-tools\">\n * <ToolbarButton icon={<span aria-hidden='true'>◆</span>} title=\"Draw\" />\n * </ToolbarGroup>\n * </Toolbar>\n * ```\n */\nexport const ToolbarGroup = ({\n children,\n slotName,\n orientation = 'vertical',\n pt,\n}: ToolbarGroupProps) => {\n const flexClass = orientation === 'horizontal' ? 'cratis:flex-row' : 'cratis:flex-col';\n\n return (\n <div\n {...pt?.root}\n className={`toolbar-group cratis:inline-flex ${flexClass} cratis:items-center cratis:gap-1 cratis:p-2 cratis:rounded-2xl ${pt?.root?.className ?? ''}`}\n data-cratis-part='toolbar-group'\n data-orientation={orientation}\n >\n {children}\n {slotName && <SlotTransition slotName={slotName} flexClass={flexClass} pt={pt} />}\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;AAeA,MAAM,kBAAkB,GAAG,GAAG;AAa9B,MAAM,cAAc,GAAG,CAAC,EACpB,QAAQ,EACR,SAAS,EACT,EAAE,GAKL,KAAI;AACD,IAAA,MAAM,SAAS,GAAG,cAAc,CAAC,QAAQ,CAAC;IAI1C,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAc,SAAS,CAAC;IAC9D,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAc,EAAE,CAAC;IACvD,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;AAInD,IAAA,MAAM,UAAU,GAAG,MAAM,CAAc,OAAO,CAAC;AAC/C,IAAA,UAAU,CAAC,OAAO,GAAG,OAAO;AAE5B,IAAA,MAAM,WAAW,GAAG,MAAM,CAAiB,IAAI,CAAC;IAChD,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAA2C,IAAI,CAAC;AAChF,IAAA,MAAM,QAAQ,GAAG,MAAM,CAA4C,SAAS,CAAC;AAC7E,IAAA,MAAM,aAAa,GAAG,MAAM,CAAC,KAAK,CAAC;AAEnC,IAAA,MAAM,eAAe,GAAG,WAAW,CAAC,MAAK;AACrC,QAAA,IAAI,WAAW,CAAC,OAAO,EAAE;AACrB,YAAA,OAAO,CAAC;AACJ,gBAAA,KAAK,EAA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CAAC;AAmDM,MAAM,YAAY,GAAG,CAAC,EACzB,QAAQ,EACR,QAAQ,EACR,WAAW,GAAG,UAAU,EACxB,EAAE,GACc,KAAI;AACpB,IAAA,MAAM,SAAS,GAAG,WAAW,KAAK,YAAY,GAAG,iBAAiB,GAAG,iBAAiB;IAEtF,QACID,iBACQ,EAAE,EAAE,IAAI,EACZ,SAAS,EAAE,CAAA,iCAAA,EAAoC,SAAS,mEAAmE,EAAE,EAAE,IAAI,EAAE,SAAS,IAAI,EAAE,CAAA,CAAE,sBACrI,eAAe,EAAA,kBAAA,EACd,WAAW,EAAA,QAAA,EAAA,CAE5B,QAAQ,EACR,QAAQ,IAAIC,IAAC,cAAc,EAAA,EAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,EAAA,CAAI,CAAA,EAAA,CAC/E;AAEd;;"}
|
|
1
|
+
{"version":3,"file":"ToolbarGroup.js","sources":["../../../Toolbar/ToolbarGroup.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport {\n type HTMLAttributes,\n type ReactNode,\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\nimport { useToolbarSlot } from './ToolbarSlot';\n\n/** How long the fade-out animation runs (ms). React unmounts exiting content after this. */\nconst SLOT_TRANSITION_MS = 220;\n\n/**\n * Renders slot items with a cross-fade and size-morph transition that mirrors the\n * {@link ToolbarSection} / {@link ToolbarContext} animation:\n *\n * - The slot container resizes smoothly to fit the incoming content.\n * - The outgoing content fades out while the incoming content fades in simultaneously.\n *\n * The size update is intentionally deferred to {@link useEffect} (after paint) so that\n * the opacity animations start one frame before the resize — matching the feel of\n * {@link ToolbarSection} context switching.\n */\nconst SlotTransition = ({\n slotName,\n flexClass,\n pt,\n}: {\n slotName: string;\n flexClass: string;\n pt?: ToolbarGroupParts;\n}) => {\n const liveItems = useToolbarSlot(slotName);\n\n // `current` is the content fading in (or already settled at full opacity).\n // `exiting` is the previous content fading out, kept alive until its animation completes.\n const [current, setCurrent] = useState<ReactNode[]>(liveItems);\n const [exiting, setExiting] = useState<ReactNode[]>([]);\n const [exitRevision, setExitRevision] = useState(0);\n\n // Track `current` in a ref so the liveItems effect can read the latest value\n // without needing it in its dependency array (avoids an unnecessary re-run loop).\n const currentRef = useRef<ReactNode[]>(current);\n currentRef.current = current;\n\n const incomingRef = useRef<HTMLDivElement>(null);\n const [size, setSize] = useState<{ width: number; height: number } | null>(null);\n const timerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const hasMountedRef = useRef(false);\n\n const measureIncoming = useCallback(() => {\n if (incomingRef.current) {\n setSize({\n width: incomingRef.current.offsetWidth,\n height: incomingRef.current.offsetHeight,\n });\n }\n }, []);\n\n // Set the initial size synchronously before the first paint — no layout flash.\n useLayoutEffect(() => {\n measureIncoming();\n }, []); // mount only\n\n // Detect live-items reference change → start cross-fade transition.\n useEffect(() => {\n if (liveItems === currentRef.current) return;\n const old = currentRef.current;\n\n if (timerRef.current !== undefined) clearTimeout(timerRef.current);\n setCurrent(liveItems);\n\n if (old.length > 0) {\n setExiting(old);\n setExitRevision(r => r + 1);\n timerRef.current = setTimeout(() => setExiting([]), SLOT_TRANSITION_MS);\n }\n }, [liveItems]);\n\n // Re-measure the incoming content whenever `current` changes so the container\n // can size-morph. useEffect (not useLayoutEffect) is intentional: we let the\n // opacity animation start one frame before the resize — matching ToolbarSection.\n useEffect(() => {\n if (!hasMountedRef.current) {\n hasMountedRef.current = true;\n return; // initial measurement handled by useLayoutEffect above\n }\n measureIncoming();\n }, [current, measureIncoming]);\n\n useEffect(() => () => {\n if (timerRef.current !== undefined) clearTimeout(timerRef.current);\n }, []);\n\n if (current.length === 0 && exiting.length === 0) return null;\n\n // The section is only clipped while outgoing content is fading out, so it\n // doesn't bleed outside the container. Once the transition is complete the\n // section must be overflow:visible so fan-out and folder panels (which are\n // position:absolute children) can escape the slot section's bounds.\n const transitioningClass = exiting.length > 0 ? 'toolbar-slot-section--transitioning' : '';\n\n return (\n <div\n {...pt?.slot}\n className={`toolbar-slot-section ${transitioningClass} ${pt?.slot?.className ?? ''}`}\n style={{ ...pt?.slot?.style, ...(size ? { width: size.width, height: size.height } : {}) }}\n data-cratis-part='toolbar-slot'\n data-transitioning={exiting.length > 0 || undefined}\n >\n {/* Incoming content — fades in via @keyframes animation on mount */}\n <div\n {...pt?.incoming}\n ref={incomingRef}\n className={`toolbar-slot-incoming cratis:inline-flex ${flexClass} cratis:items-center cratis:gap-1 ${pt?.incoming?.className ?? ''}`}\n data-cratis-part='toolbar-slot-incoming'\n >\n {current}\n </div>\n {/* Exiting content — fades out, then React unmounts it after SLOT_TRANSITION_MS */}\n {exiting.length > 0 && (\n <div\n key={exitRevision}\n {...pt?.outgoing}\n className={`toolbar-slot-outgoing cratis:inline-flex ${flexClass} cratis:items-center cratis:gap-1 ${pt?.outgoing?.className ?? ''}`}\n data-cratis-part='toolbar-slot-outgoing'\n aria-hidden='true'\n inert\n >\n {exiting}\n </div>\n )}\n </div>\n );\n};\n\n/** Stable part attributes for {@link ToolbarGroup}. */\nexport interface ToolbarGroupParts {\n /** Group root used as one logical measurement boundary. */\n root?: HTMLAttributes<HTMLDivElement>;\n /** Slot-transition boundary rendered when {@link ToolbarGroupProps.slotName} is used. */\n slot?: HTMLAttributes<HTMLDivElement>;\n /** Current slot content. */\n incoming?: HTMLAttributes<HTMLDivElement>;\n /** Previous slot content while it exits. */\n outgoing?: HTMLAttributes<HTMLDivElement>;\n}\n\n/** Props for the {@link ToolbarGroup} component. */\nexport interface ToolbarGroupProps {\n /** The toolbar items to render inside this group. */\n children?: ReactNode;\n\n /**\n * Optional slot name. When provided, any {@link ToolbarSlot} with a matching `slotName`\n * within the nearest {@link ToolbarSlotProvider} will render its content inside this group.\n *\n * Slot entries are appended after the group's own children and sorted by their `order` value.\n */\n slotName?: string;\n\n /** Layout direction of the group, should match the parent {@link Toolbar} (default: `'vertical'`). */\n orientation?: 'vertical' | 'horizontal';\n\n /** Stable group and slot-transition part attributes. */\n pt?: ToolbarGroupParts;\n}\n\n/**\n * A logical sub-grouping of toolbar items within a {@link Toolbar}.\n *\n * Use `ToolbarGroup` to cluster related buttons into a visually cohesive unit.\n * Groups can participate in the slot system by providing a `slotName` — external\n * components anywhere in the {@link ToolbarSlotProvider} tree can then inject additional\n * buttons at a chosen position via {@link ToolbarSlot}.\n *\n * @example\n * ```tsx\n * <Toolbar>\n * <ToolbarGroup slotName=\"canvas-tools\">\n * <ToolbarButton icon={<span aria-hidden='true'>◆</span>} title=\"Draw\" />\n * </ToolbarGroup>\n * </Toolbar>\n * ```\n */\nexport const ToolbarGroup = ({\n children,\n slotName,\n orientation = 'vertical',\n pt,\n}: ToolbarGroupProps) => {\n const flexClass = orientation === 'horizontal' ? 'cratis:flex-row' : 'cratis:flex-col';\n\n return (\n <div\n {...pt?.root}\n className={`toolbar-group cratis:inline-flex ${flexClass} cratis:items-center cratis:gap-1 cratis:p-2 cratis:rounded-2xl ${pt?.root?.className ?? ''}`}\n data-cratis-part='toolbar-group'\n data-cratis-component='ToolbarGroup'\n data-orientation={orientation}\n >\n {children}\n {slotName && <SlotTransition slotName={slotName} flexClass={flexClass} pt={pt} />}\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;AAeA,MAAM,kBAAkB,GAAG,GAAG;AAa9B,MAAM,cAAc,GAAG,CAAC,EACpB,QAAQ,EACR,SAAS,EACT,EAAE,GAKL,KAAI;AACD,IAAA,MAAM,SAAS,GAAG,cAAc,CAAC,QAAQ,CAAC;IAI1C,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAc,SAAS,CAAC;IAC9D,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAc,EAAE,CAAC;IACvD,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;AA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AqD;AACrD,MAAM,WAAW,kBAAkB;IAC/B;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;OAIG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IAErB,oFAAoF;IACpF,WAAW,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;IAExC,+CAA+C;IAC/C,EAAE,CAAC,EAAE,kBAAkB,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,eAAO,MAAM,aAAa,yCAKvB,kBAAkB,uCAoBpB,CAAC"}
|
|
@@ -52,7 +52,7 @@ const ToolbarLayout = ({ name, children, orientation = 'vertical', pt, }) => {
|
|
|
52
52
|
const items = slotItems.length > 0 ? slotItems : fallbackItems;
|
|
53
53
|
if (items.length === 0)
|
|
54
54
|
return null;
|
|
55
|
-
return (jsx("div", { ...pt?.root, className: `toolbar-layout cratis:inline-flex ${flexClass} cratis:items-center cratis:gap-1 ${pt?.root?.className ?? ''}`, "data-cratis-part": 'toolbar-layout', "data-layout-name": name, "data-orientation": orientation, children: jsx(LayoutTransition, { items: items, flexClass: flexClass, pt: pt }) }));
|
|
55
|
+
return (jsx("div", { ...pt?.root, className: `toolbar-layout cratis:inline-flex ${flexClass} cratis:items-center cratis:gap-1 ${pt?.root?.className ?? ''}`, "data-cratis-part": 'toolbar-layout', "data-cratis-component": 'ToolbarLayout', "data-layout-name": name, "data-orientation": orientation, children: jsx(LayoutTransition, { items: items, flexClass: flexClass, pt: pt }) }));
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
export { ToolbarLayout };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolbarLayout.js","sources":["../../../Toolbar/ToolbarLayout.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport {\n Children,\n type HTMLAttributes,\n type ReactNode,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useToolbarSlot } from './ToolbarSlot';\nimport { ToolbarItemVisibilityProvider } from './ToolbarItemVisibilityContext';\n\n/** How long the fade-out animation runs (ms). React unmounts exiting content after this. */\nconst LAYOUT_TRANSITION_MS = 220;\n\n/**\n * Renders toolbar layout content with a cross-fade and size-morph transition.\n *\n * - The container resizes smoothly to fit incoming layout content.\n * - Outgoing content fades out while incoming content fades in.\n */\nconst LayoutTransition = ({\n items,\n flexClass,\n pt,\n}: {\n items: ReactNode[];\n flexClass: string;\n pt?: ToolbarLayoutParts;\n}) => {\n const [current, setCurrent] = useState<ReactNode[]>(items);\n const [exiting, setExiting] = useState<ReactNode[]>([]);\n const [exitRevision, setExitRevision] = useState(0);\n\n const currentRef = useRef<ReactNode[]>(current);\n currentRef.current = current;\n\n const incomingRef = useRef<HTMLDivElement>(null);\n const [size, setSize] = useState<{ width: number; height: number } | null>(null);\n const timerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n\n // ResizeObserver keeps the container size in sync with the actual rendered\n // content, including when nested ToolbarLayouts finish their own transitions.\n // A one-shot offsetHeight read in useEffect misses those deferred size changes.\n useEffect(() => {\n const el = incomingRef.current;\n if (!el) return;\n\n const sync = () => setSize({ width: el.offsetWidth, height: el.offsetHeight });\n\n const observer = new ResizeObserver(sync);\n observer.observe(el);\n sync(); // capture initial size immediately\n\n return () => observer.disconnect();\n }, []); // mount only — observer tracks all subsequent changes automatically\n\n useEffect(() => {\n if (items === currentRef.current) return;\n const old = currentRef.current;\n\n if (timerRef.current !== undefined) clearTimeout(timerRef.current);\n setCurrent(items);\n\n if (old.length > 0) {\n setExiting(old);\n setExitRevision(revision => revision + 1);\n timerRef.current = setTimeout(() => setExiting([]), LAYOUT_TRANSITION_MS);\n }\n }, [items]);\n\n useEffect(() => () => {\n if (timerRef.current !== undefined) clearTimeout(timerRef.current);\n }, []);\n\n if (current.length === 0 && exiting.length === 0) return null;\n\n // The section is only clipped while outgoing content is fading out, so it\n // doesn't bleed outside the container. Once the transition is complete the\n // section must be overflow:visible so fan-out and folder panels (which are\n // position:absolute children) can escape the slot section's bounds.\n const transitioningClass = exiting.length > 0 ? 'toolbar-slot-section--transitioning' : '';\n\n return (\n <div\n {...pt?.slot}\n className={`toolbar-slot-section ${transitioningClass} ${pt?.slot?.className ?? ''}`}\n style={{ ...pt?.slot?.style, ...(size ? { width: size.width, height: size.height } : {}) }}\n data-cratis-part='toolbar-slot'\n data-transitioning={exiting.length > 0 || undefined}\n >\n <div\n {...pt?.incoming}\n ref={incomingRef}\n className={`toolbar-slot-incoming cratis:inline-flex ${flexClass} cratis:items-center cratis:gap-1 ${pt?.incoming?.className ?? ''}`}\n data-cratis-part='toolbar-slot-incoming'\n >\n {current}\n </div>\n {exiting.length > 0 && (\n <div\n key={exitRevision}\n {...pt?.outgoing}\n className={`toolbar-slot-outgoing cratis:inline-flex ${flexClass} cratis:items-center cratis:gap-1 ${pt?.outgoing?.className ?? ''}`}\n data-cratis-part='toolbar-slot-outgoing'\n aria-hidden='true'\n inert\n >\n <ToolbarItemVisibilityProvider value={false}>\n {exiting}\n </ToolbarItemVisibilityProvider>\n </div>\n )}\n </div>\n );\n};\n\n/** Stable part attributes for {@link ToolbarLayout}. */\nexport interface ToolbarLayoutParts {\n /** Named layout root. */\n root?: HTMLAttributes<HTMLDivElement>;\n /** Slot-transition measurement boundary. */\n slot?: HTMLAttributes<HTMLDivElement>;\n /** Current layout content. */\n incoming?: HTMLAttributes<HTMLDivElement>;\n /** Previous layout content while it exits. */\n outgoing?: HTMLAttributes<HTMLDivElement>;\n}\n\n/** Props for the {@link ToolbarLayout} component. */\nexport interface ToolbarLayoutProps {\n /**\n * The name identifying this layout region.\n * External components use this as the `slotName` on a {@link ToolbarSlot} to inject content.\n */\n name: string;\n\n /**\n * Default content shown when no slot content has been registered for this layout.\n * Can include {@link ToolbarGroup}, {@link ToolbarSection}, {@link ToolbarSeparator},\n * or any other toolbar elements.\n */\n children?: ReactNode;\n\n /** Layout direction matching the parent {@link Toolbar} (default: `'vertical'`). */\n orientation?: 'vertical' | 'horizontal';\n\n /** Stable layout and transition attributes. */\n pt?: ToolbarLayoutParts;\n}\n\n/**\n * A named, transparent layout region inside a {@link Toolbar} that enables decoupled,\n * dynamically swappable toolbar content.\n *\n * Unlike {@link ToolbarGroup}, `ToolbarLayout` has no visual container of its own.\n * It acts as a transparent mount point: external components inject complete toolbar\n * structures — multiple {@link ToolbarGroup}s, {@link ToolbarSection}s,\n * {@link ToolbarSeparator}s — using a {@link ToolbarSlot} with a matching `slotName`.\n *\n * When any slot content is registered it replaces the fallback `children`. Multiple\n * independent contributors can register into the same layout using different `order`\n * values on their {@link ToolbarSlot}.\n *\n * Wrap the toolbar and contributing components in a {@link ToolbarSlotProvider}:\n *\n * @example\n * ```tsx\n * // Application shell — define the layout region with optional fallback content:\n * <ToolbarSlotProvider>\n * <Toolbar>\n * <ToolbarButton icon={<span aria-hidden='true'>◆</span>} title=\"Select\" />\n * <ToolbarLayout name=\"canvas-tools\">\n * <ToolbarGroup>\n * <ToolbarButton icon={<span aria-hidden='true'>◆</span>} title=\"Draw (default)\" />\n * </ToolbarGroup>\n * </ToolbarLayout>\n * </Toolbar>\n *\n * <CanvasFeature />\n * </ToolbarSlotProvider>\n *\n * // Feature component — inject complete groups:\n * const CanvasFeature = () => (\n * <ToolbarSlot slotName=\"canvas-tools\">\n * <ToolbarGroup>\n * <ToolbarButton icon={<span aria-hidden='true'>◆</span>} title=\"Feature tool\" />\n * </ToolbarGroup>\n * <ToolbarSeparator />\n * <ToolbarGroup>\n * <ToolbarButton icon={<span aria-hidden='true'>◆</span>} title=\"Quick action\" />\n * </ToolbarGroup>\n * </ToolbarSlot>\n * );\n * ```\n */\nexport const ToolbarLayout = ({\n name,\n children,\n orientation = 'vertical',\n pt,\n}: ToolbarLayoutProps) => {\n const slotItems = useToolbarSlot(name);\n const flexClass = orientation === 'horizontal' ? 'cratis:flex-row' : 'cratis:flex-col';\n const fallbackItems = useMemo(() => Children.toArray(children), [children]);\n const items = slotItems.length > 0 ? slotItems : fallbackItems;\n\n if (items.length === 0) return null;\n\n return (\n <div\n {...pt?.root}\n className={`toolbar-layout cratis:inline-flex ${flexClass} cratis:items-center cratis:gap-1 ${pt?.root?.className ?? ''}`}\n data-cratis-part='toolbar-layout'\n data-layout-name={name}\n data-orientation={orientation}\n >\n <LayoutTransition items={items} flexClass={flexClass} pt={pt} />\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;AAgBA,MAAM,oBAAoB,GAAG,GAAG;AAQhC,MAAM,gBAAgB,GAAG,CAAC,EACtB,KAAK,EACL,SAAS,EACT,EAAE,GAKL,KAAI;IACD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAc,KAAK,CAAC;IAC1D,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAc,EAAE,CAAC;IACvD,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;AAEnD,IAAA,MAAM,UAAU,GAAG,MAAM,CAAc,OAAO,CAAC;AAC/C,IAAA,UAAU,CAAC,OAAO,GAAG,OAAO;AAE5B,IAAA,MAAM,WAAW,GAAG,MAAM,CAAiB,IAAI,CAAC;IAChD,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAA2C,IAAI,CAAC;AAChF,IAAA,MAAM,QAAQ,GAAG,MAAM,CAA4C,SAAS,CAAC;IAK7E,SAAS,CAAC,MAAK;AACX,QAAA,MAAM,EAAE,GAAG,WAAW,CAAC,OAAO;AAC9B,QAAA,IAAI,CAAC,EAAE;YAAE;QAET,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,CAAC,YAAY,EAAE,CAAC;AAE9E,QAAA,MAAM,QAAQ,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC;AACz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,iBAAiB,GAAG,iBAAiB;AACtF,IAAA,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;AAC3E,IAAA,MAAM,KAAK,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,GAAG,SAAS,GAAG,aAAa;AAE9D,IAAA,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;AAAE,QAAA,OAAO,IAAI;AAEnC,IAAA,QACIA,GAAA,CAAA,KAAA,EAAA,EAAA,GACQ,EAAE,EAAE,IAAI,EACZ,SAAS,EAAE,CAAA,kCAAA,EAAqC,SAAS,CAAA,kCAAA,EAAqC,EAAE,EAAE,IAAI,EAAE,SAAS,IAAI,EAAE,EAAE,EAAA,kBAAA,EACxG,gBAAgB,sBACf,IAAI,EAAA,kBAAA,EACJ,WAAW,EAAA,QAAA,EAE7BA,GAAA,CAAC,gBAAgB,EAAA,EAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,EAAA,CAAI,EAAA,CAC9D;AAEd;;"}
|
|
1
|
+
{"version":3,"file":"ToolbarLayout.js","sources":["../../../Toolbar/ToolbarLayout.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport {\n Children,\n type HTMLAttributes,\n type ReactNode,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useToolbarSlot } from './ToolbarSlot';\nimport { ToolbarItemVisibilityProvider } from './ToolbarItemVisibilityContext';\n\n/** How long the fade-out animation runs (ms). React unmounts exiting content after this. */\nconst LAYOUT_TRANSITION_MS = 220;\n\n/**\n * Renders toolbar layout content with a cross-fade and size-morph transition.\n *\n * - The container resizes smoothly to fit incoming layout content.\n * - Outgoing content fades out while incoming content fades in.\n */\nconst LayoutTransition = ({\n items,\n flexClass,\n pt,\n}: {\n items: ReactNode[];\n flexClass: string;\n pt?: ToolbarLayoutParts;\n}) => {\n const [current, setCurrent] = useState<ReactNode[]>(items);\n const [exiting, setExiting] = useState<ReactNode[]>([]);\n const [exitRevision, setExitRevision] = useState(0);\n\n const currentRef = useRef<ReactNode[]>(current);\n currentRef.current = current;\n\n const incomingRef = useRef<HTMLDivElement>(null);\n const [size, setSize] = useState<{ width: number; height: number } | null>(null);\n const timerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n\n // ResizeObserver keeps the container size in sync with the actual rendered\n // content, including when nested ToolbarLayouts finish their own transitions.\n // A one-shot offsetHeight read in useEffect misses those deferred size changes.\n useEffect(() => {\n const el = incomingRef.current;\n if (!el) return;\n\n const sync = () => setSize({ width: el.offsetWidth, height: el.offsetHeight });\n\n const observer = new ResizeObserver(sync);\n observer.observe(el);\n sync(); // capture initial size immediately\n\n return () => observer.disconnect();\n }, []); // mount only — observer tracks all subsequent changes automatically\n\n useEffect(() => {\n if (items === currentRef.current) return;\n const old = currentRef.current;\n\n if (timerRef.current !== undefined) clearTimeout(timerRef.current);\n setCurrent(items);\n\n if (old.length > 0) {\n setExiting(old);\n setExitRevision(revision => revision + 1);\n timerRef.current = setTimeout(() => setExiting([]), LAYOUT_TRANSITION_MS);\n }\n }, [items]);\n\n useEffect(() => () => {\n if (timerRef.current !== undefined) clearTimeout(timerRef.current);\n }, []);\n\n if (current.length === 0 && exiting.length === 0) return null;\n\n // The section is only clipped while outgoing content is fading out, so it\n // doesn't bleed outside the container. Once the transition is complete the\n // section must be overflow:visible so fan-out and folder panels (which are\n // position:absolute children) can escape the slot section's bounds.\n const transitioningClass = exiting.length > 0 ? 'toolbar-slot-section--transitioning' : '';\n\n return (\n <div\n {...pt?.slot}\n className={`toolbar-slot-section ${transitioningClass} ${pt?.slot?.className ?? ''}`}\n style={{ ...pt?.slot?.style, ...(size ? { width: size.width, height: size.height } : {}) }}\n data-cratis-part='toolbar-slot'\n data-transitioning={exiting.length > 0 || undefined}\n >\n <div\n {...pt?.incoming}\n ref={incomingRef}\n className={`toolbar-slot-incoming cratis:inline-flex ${flexClass} cratis:items-center cratis:gap-1 ${pt?.incoming?.className ?? ''}`}\n data-cratis-part='toolbar-slot-incoming'\n >\n {current}\n </div>\n {exiting.length > 0 && (\n <div\n key={exitRevision}\n {...pt?.outgoing}\n className={`toolbar-slot-outgoing cratis:inline-flex ${flexClass} cratis:items-center cratis:gap-1 ${pt?.outgoing?.className ?? ''}`}\n data-cratis-part='toolbar-slot-outgoing'\n aria-hidden='true'\n inert\n >\n <ToolbarItemVisibilityProvider value={false}>\n {exiting}\n </ToolbarItemVisibilityProvider>\n </div>\n )}\n </div>\n );\n};\n\n/** Stable part attributes for {@link ToolbarLayout}. */\nexport interface ToolbarLayoutParts {\n /** Named layout root. */\n root?: HTMLAttributes<HTMLDivElement>;\n /** Slot-transition measurement boundary. */\n slot?: HTMLAttributes<HTMLDivElement>;\n /** Current layout content. */\n incoming?: HTMLAttributes<HTMLDivElement>;\n /** Previous layout content while it exits. */\n outgoing?: HTMLAttributes<HTMLDivElement>;\n}\n\n/** Props for the {@link ToolbarLayout} component. */\nexport interface ToolbarLayoutProps {\n /**\n * The name identifying this layout region.\n * External components use this as the `slotName` on a {@link ToolbarSlot} to inject content.\n */\n name: string;\n\n /**\n * Default content shown when no slot content has been registered for this layout.\n * Can include {@link ToolbarGroup}, {@link ToolbarSection}, {@link ToolbarSeparator},\n * or any other toolbar elements.\n */\n children?: ReactNode;\n\n /** Layout direction matching the parent {@link Toolbar} (default: `'vertical'`). */\n orientation?: 'vertical' | 'horizontal';\n\n /** Stable layout and transition attributes. */\n pt?: ToolbarLayoutParts;\n}\n\n/**\n * A named, transparent layout region inside a {@link Toolbar} that enables decoupled,\n * dynamically swappable toolbar content.\n *\n * Unlike {@link ToolbarGroup}, `ToolbarLayout` has no visual container of its own.\n * It acts as a transparent mount point: external components inject complete toolbar\n * structures — multiple {@link ToolbarGroup}s, {@link ToolbarSection}s,\n * {@link ToolbarSeparator}s — using a {@link ToolbarSlot} with a matching `slotName`.\n *\n * When any slot content is registered it replaces the fallback `children`. Multiple\n * independent contributors can register into the same layout using different `order`\n * values on their {@link ToolbarSlot}.\n *\n * Wrap the toolbar and contributing components in a {@link ToolbarSlotProvider}:\n *\n * @example\n * ```tsx\n * // Application shell — define the layout region with optional fallback content:\n * <ToolbarSlotProvider>\n * <Toolbar>\n * <ToolbarButton icon={<span aria-hidden='true'>◆</span>} title=\"Select\" />\n * <ToolbarLayout name=\"canvas-tools\">\n * <ToolbarGroup>\n * <ToolbarButton icon={<span aria-hidden='true'>◆</span>} title=\"Draw (default)\" />\n * </ToolbarGroup>\n * </ToolbarLayout>\n * </Toolbar>\n *\n * <CanvasFeature />\n * </ToolbarSlotProvider>\n *\n * // Feature component — inject complete groups:\n * const CanvasFeature = () => (\n * <ToolbarSlot slotName=\"canvas-tools\">\n * <ToolbarGroup>\n * <ToolbarButton icon={<span aria-hidden='true'>◆</span>} title=\"Feature tool\" />\n * </ToolbarGroup>\n * <ToolbarSeparator />\n * <ToolbarGroup>\n * <ToolbarButton icon={<span aria-hidden='true'>◆</span>} title=\"Quick action\" />\n * </ToolbarGroup>\n * </ToolbarSlot>\n * );\n * ```\n */\nexport const ToolbarLayout = ({\n name,\n children,\n orientation = 'vertical',\n pt,\n}: ToolbarLayoutProps) => {\n const slotItems = useToolbarSlot(name);\n const flexClass = orientation === 'horizontal' ? 'cratis:flex-row' : 'cratis:flex-col';\n const fallbackItems = useMemo(() => Children.toArray(children), [children]);\n const items = slotItems.length > 0 ? slotItems : fallbackItems;\n\n if (items.length === 0) return null;\n\n return (\n <div\n {...pt?.root}\n className={`toolbar-layout cratis:inline-flex ${flexClass} cratis:items-center cratis:gap-1 ${pt?.root?.className ?? ''}`}\n data-cratis-part='toolbar-layout'\n data-cratis-component='ToolbarLayout'\n data-layout-name={name}\n data-orientation={orientation}\n >\n <LayoutTransition items={items} flexClass={flexClass} pt={pt} />\n </div>\n );\n};\n"],"names":["_jsxs","_js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AAI;IAEnC,QACIA,gBACQ,EAAE,EAAE,IAAI,EACZ,SAAS,EAAE,CAAA,kCAAA,EAAqC,SAAS,qCAAqC,EAAE,EAAE,IAAI,EAAE,SAAS,IAAI,EAAE,CAAA,CAAE,sBACxG,gBAAgB,EAAA,uBAAA,EACX,eAAe,EAAA,kBAAA,EACnB,IAAI,sBACJ,WAAW,EAAA,QAAA,EAE7BA,IAAC,gBAAgB,EAAA,EAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,EAAA,CAAI,EAAA,CAC9D;AAEd;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolbarSection.d.ts","sourceRoot":"","sources":["../../../Toolbar/ToolbarSection.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEH,KAAK,cAAc,EAEnB,KAAK,SAAS,EAOjB,MAAM,OAAO,CAAC;AA0Bf,yDAAyD;AACzD,MAAM,WAAW,mBAAmB;IAChC,6BAA6B;IAC7B,IAAI,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;IACtC,4EAA4E;IAC5E,OAAO,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;CAC5C;AAED,sDAAsD;AACtD,MAAM,WAAW,mBAAmB;IAChC;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,gFAAgF;IAChF,QAAQ,EAAE,SAAS,CAAC;IAEpB,kFAAkF;IAClF,WAAW,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;IAExC,6CAA6C;IAC7C,EAAE,CAAC,EAAE,mBAAmB,CAAC;CAC5B;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,kDAKxB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"ToolbarSection.d.ts","sourceRoot":"","sources":["../../../Toolbar/ToolbarSection.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEH,KAAK,cAAc,EAEnB,KAAK,SAAS,EAOjB,MAAM,OAAO,CAAC;AA0Bf,yDAAyD;AACzD,MAAM,WAAW,mBAAmB;IAChC,6BAA6B;IAC7B,IAAI,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;IACtC,4EAA4E;IAC5E,OAAO,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;CAC5C;AAED,sDAAsD;AACtD,MAAM,WAAW,mBAAmB;IAChC;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,gFAAgF;IAChF,QAAQ,EAAE,SAAS,CAAC;IAEpB,kFAAkF;IAClF,WAAW,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;IAExC,6CAA6C;IAC7C,EAAE,CAAC,EAAE,mBAAmB,CAAC;CAC5B;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,kDAKxB,mBAAmB,gCAkJrB,CAAC"}
|
|
@@ -87,7 +87,7 @@ const ToolbarSection = ({ activeContext, children, orientation = 'vertical', pt,
|
|
|
87
87
|
if (transitionTimeoutRef.current)
|
|
88
88
|
clearTimeout(transitionTimeoutRef.current);
|
|
89
89
|
}, []);
|
|
90
|
-
return (jsx("div", { ...pt?.root, className: `toolbar-section ${isTransitioning ? 'toolbar-section--transitioning' : ''} ${pt?.root?.className ?? ''}`, style: { ...pt?.root?.style, ...(size ? { width: size.width, height: size.height } : {}) }, "data-cratis-part": 'toolbar-section', "data-transitioning": isTransitioning || undefined, "data-orientation": orientation, children: contexts.map((child) => {
|
|
90
|
+
return (jsx("div", { ...pt?.root, className: `toolbar-section ${isTransitioning ? 'toolbar-section--transitioning' : ''} ${pt?.root?.className ?? ''}`, style: { ...pt?.root?.style, ...(size ? { width: size.width, height: size.height } : {}) }, "data-cratis-part": 'toolbar-section', "data-cratis-component": 'ToolbarSection', "data-transitioning": isTransitioning || undefined, "data-orientation": orientation, children: contexts.map((child) => {
|
|
91
91
|
const { name, children: contextChildren, slotName } = child.props;
|
|
92
92
|
const isActive = name === effectiveContext;
|
|
93
93
|
return (jsx("div", { ...pt?.context, ref: (element) => { contextRefs.current[name] = element; }, className: `toolbar-context cratis:inline-flex ${flexClass} cratis:items-center cratis:gap-1 ${isActive ? 'toolbar-context--active' : 'toolbar-context--inactive'} ${pt?.context?.className ?? ''}`, "data-cratis-part": 'toolbar-context', "data-context-name": name, "data-active": isActive || undefined, "data-selected": isActive || undefined, "aria-hidden": !isActive, inert: !isActive, children: jsx(ToolbarItemVisibilityProvider, { value: isActive, children: jsx(ContextRenderer, { slotName: slotName, children: contextChildren }) }) }, name));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolbarSection.js","sources":["../../../Toolbar/ToolbarSection.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport {\n Children,\n type HTMLAttributes,\n type ReactElement,\n type ReactNode,\n isValidElement,\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport type { ToolbarContextProps } from './ToolbarContext';\nimport { useToolbarSlot } from './ToolbarSlot';\nimport { ToolbarItemVisibilityProvider } from './ToolbarItemVisibilityContext';\n\n/** Width/height transition duration used by the section resize animation (ms). */\nconst SECTION_TRANSITION_MS = 350;\n\n/**\n * Renders the children of a single {@link ToolbarContext} together with any slot items\n * that have been registered under the context's `slotName`.\n *\n * Extracted into its own component so that the `useToolbarSlot` hook can be called\n * inside it — hooks cannot be called inside a callback or loop in the parent.\n */\nconst ContextRenderer = ({ children, slotName }: { children: ReactNode; slotName?: string }) => {\n const slotItems = useToolbarSlot(slotName ?? '');\n return (\n <>\n {children}\n {slotName && slotItems.length > 0 && slotItems}\n </>\n );\n};\n\n/** Stable part attributes for {@link ToolbarSection}. */\nexport interface ToolbarSectionParts {\n /** Animated section root. */\n root?: HTMLAttributes<HTMLDivElement>;\n /** One named context, with active state exposed through data attributes. */\n context?: HTMLAttributes<HTMLDivElement>;\n}\n\n/** Props for the {@link ToolbarSection} component. */\nexport interface ToolbarSectionProps {\n /**\n * The name of the currently active context.\n * Change this to trigger the fade-out / morph / fade-in animation.\n * Defaults to the first context if not specified.\n */\n activeContext?: string;\n\n /** {@link ToolbarContext} elements that define each context's toolbar items. */\n children: ReactNode;\n\n /** Layout direction matching the parent {@link Toolbar} (default: 'vertical'). */\n orientation?: 'vertical' | 'horizontal';\n\n /** Stable section and context attributes. */\n pt?: ToolbarSectionParts;\n}\n\n/**\n * A section within a {@link Toolbar} that supports multiple named contexts.\n *\n * When {@link activeContext} changes:\n * - The current items fade out.\n * - The section smoothly morphs to the dimensions required by the new context.\n * - The new items fade in.\n *\n * Contexts are defined by placing {@link ToolbarContext} children inside this section.\n * Switching contexts only affects this section; other sections are unaffected.\n */\nexport const ToolbarSection = ({\n activeContext,\n children,\n orientation = 'vertical',\n pt,\n}: ToolbarSectionProps) => {\n const contextRefs = useRef<Record<string, HTMLDivElement | null>>({});\n const resizeObserverRef = useRef<ResizeObserver | null>(null);\n const mutationObserverRef = useRef<MutationObserver | null>(null);\n const transitionTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const previousContextRef = useRef<string | null>(null);\n const [size, setSize] = useState<{ width: number; height: number } | null>(null);\n const [isTransitioning, setIsTransitioning] = useState(false);\n\n const contexts = Children.toArray(children).filter(\n (child): child is ReactElement<ToolbarContextProps> =>\n isValidElement(child) && typeof (child.props as ToolbarContextProps).name === 'string'\n );\n\n // Default to the first context if activeContext is not provided\n const effectiveContext = activeContext ?? (contexts[0]?.props as ToolbarContextProps)?.name ?? '';\n\n const flexClass = orientation === 'horizontal' ? 'cratis:flex-row' : 'cratis:flex-col';\n\n /** Measure the given context's natural dimensions and update the section size. */\n const measureAndSetSize = useCallback((contextName: string) => {\n const ref = contextRefs.current[contextName];\n if (ref) {\n setSize({\n width: ref.offsetWidth,\n height: ref.offsetHeight,\n });\n }\n }, []);\n\n // Set the initial size synchronously before the first browser paint so there is no layout flash.\n // Empty dependency array is intentional: ongoing context changes are handled by the useEffect below.\n useLayoutEffect(() => {\n measureAndSetSize(effectiveContext);\n }, []); // run only on mount\n\n // Clip content only while the section is morphing between contexts so incoming\n // buttons do not float outside the current bounds during growth.\n useEffect(() => {\n if (previousContextRef.current === null) {\n previousContextRef.current = effectiveContext;\n return;\n }\n if (previousContextRef.current === effectiveContext) return;\n\n previousContextRef.current = effectiveContext;\n setIsTransitioning(true);\n\n if (transitionTimeoutRef.current) clearTimeout(transitionTimeoutRef.current);\n transitionTimeoutRef.current = setTimeout(() => {\n setIsTransitioning(false);\n transitionTimeoutRef.current = null;\n }, SECTION_TRANSITION_MS);\n }, [effectiveContext]);\n\n // After a context switch, let the browser paint the opacity transition first,\n // then update the explicit size so the CSS width/height transition kicks in.\n useEffect(() => {\n measureAndSetSize(effectiveContext);\n }, [effectiveContext, measureAndSetSize]);\n\n // Keep section dimensions in sync when the active context's content changes size after render.\n useEffect(() => {\n const activeContextElement = contextRefs.current[effectiveContext];\n if (!activeContextElement || typeof ResizeObserver === 'undefined') {\n return;\n }\n\n measureAndSetSize(effectiveContext);\n\n mutationObserverRef.current?.disconnect();\n resizeObserverRef.current?.disconnect();\n\n const observer = new ResizeObserver(() => {\n measureAndSetSize(effectiveContext);\n });\n\n observer.observe(activeContextElement);\n resizeObserverRef.current = observer;\n\n if (typeof MutationObserver !== 'undefined') {\n const mutationObserver = new MutationObserver(() => {\n measureAndSetSize(effectiveContext);\n });\n mutationObserver.observe(activeContextElement, {\n childList: true,\n subtree: true,\n attributes: true,\n });\n mutationObserverRef.current = mutationObserver;\n }\n\n return () => {\n observer.disconnect();\n if (resizeObserverRef.current === observer) {\n resizeObserverRef.current = null;\n }\n\n mutationObserverRef.current?.disconnect();\n mutationObserverRef.current = null;\n };\n }, [effectiveContext, measureAndSetSize]);\n\n useEffect(() => () => {\n if (transitionTimeoutRef.current) clearTimeout(transitionTimeoutRef.current);\n }, []);\n\n return (\n <div\n {...pt?.root}\n className={`toolbar-section ${isTransitioning ? 'toolbar-section--transitioning' : ''} ${pt?.root?.className ?? ''}`}\n style={{ ...pt?.root?.style, ...(size ? { width: size.width, height: size.height } : {}) }}\n data-cratis-part='toolbar-section'\n data-transitioning={isTransitioning || undefined}\n data-orientation={orientation}\n >\n {contexts.map((child) => {\n const { name, children: contextChildren, slotName } = child.props as ToolbarContextProps;\n const isActive = name === effectiveContext;\n\n return (\n <div\n key={name}\n {...pt?.context}\n ref={(element) => { contextRefs.current[name] = element; }}\n className={`toolbar-context cratis:inline-flex ${flexClass} cratis:items-center cratis:gap-1 ${\n isActive ? 'toolbar-context--active' : 'toolbar-context--inactive'\n } ${pt?.context?.className ?? ''}`}\n data-cratis-part='toolbar-context'\n data-context-name={name}\n data-active={isActive || undefined}\n data-selected={isActive || undefined}\n aria-hidden={!isActive}\n inert={!isActive}\n >\n <ToolbarItemVisibilityProvider value={isActive}>\n <ContextRenderer slotName={slotName}>\n {contextChildren}\n </ContextRenderer>\n </ToolbarItemVisibilityProvider>\n </div>\n );\n })}\n </div>\n );\n};\n"],"names":["_jsxs","_Fragment","_jsx"],"mappings":";;;;;AAqBA,MAAM,qBAAqB,GAAG,GAAG;AASjC,MAAM,eAAe,GAAG,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAA8C,KAAI;IAC3F,MAAM,SAAS,GAAG,cAAc,CAAC,QAAQ,IAAI,EAAE,CAAC;AAChD,IAAA,QACIA,IAAA,CAAAC,QAAA,EAAA,EAAA,QAAA,EAAA,CACK,QAAQ,EACR,QAAQ,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,SAAS,CAAA,EAAA,CAC/C;AAEX,CAAC;AAwCM,MAAM,cAAc,GAAG,CAAC,EAC3B,aAAa,EACb,QAAQ,EACR,WAAW,GAAG,UAAU,EACxB,EAAE,GACgB,KAAI;AACtB,IAAA,MAAM,WAAW,GAAG,MAAM,CAAwC,EAAE,CAAC;AACrE,IAAA,MAAM,iBAAiB,GAAG,MAAM,CAAwB,IAAI,CAAC;AAC7D,IAAA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AQ,CAAC,GAAG,CAAC,CAAC,KAAK,KAAI;AACpB,YAAA,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC,KAA4B;AACxF,YAAA,MAAM,QAAQ,GAAG,IAAI,KAAK,gBAAgB;AAE1C,YAAA,QACIA,GAAA,CAAA,KAAA,EAAA,EAAA,GAEQ,EAAE,EAAE,OAAO,EACf,GAAG,EAAE,CAAC,OAAO,OAAO,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAC1D,SAAS,EAAE,sCAAsC,SAAS,CAAA,kCAAA,EACtD,QAAQ,GAAG,yBAAyB,GAAG,2BAC3C,IAAI,EAAE,EAAE,OAAO,EAAE,SAAS,IAAI,EAAE,EAAE,EAAA,kBAAA,EACjB,iBAAiB,uBACf,IAAI,EAAA,aAAA,EACV,QAAQ,IAAI,SAAS,mBACnB,QAAQ,IAAI,SAAS,EAAA,aAAA,EACvB,CAAC,QAAQ,EACtB,KAAK,EAAE,CAAC,QAAQ,YAEhBA,GAAA,CAAC,6BAA6B,IAAC,KAAK,EAAE,QAAQ,EAAA,QAAA,EAC1CA,GAAA,CAAC,eAAe,EAAA,EAAC,QAAQ,EAAE,QAAQ,EAAA,QAAA,EAC9B,eAAe,EAAA,CACF,EAAA,CACU,IAjB3B,IAAI,CAkBP;QAEd,CAAC,CAAC,EAAA,CACA;AAEd;;"}
|
|
1
|
+
{"version":3,"file":"ToolbarSection.js","sources":["../../../Toolbar/ToolbarSection.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport {\n Children,\n type HTMLAttributes,\n type ReactElement,\n type ReactNode,\n isValidElement,\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport type { ToolbarContextProps } from './ToolbarContext';\nimport { useToolbarSlot } from './ToolbarSlot';\nimport { ToolbarItemVisibilityProvider } from './ToolbarItemVisibilityContext';\n\n/** Width/height transition duration used by the section resize animation (ms). */\nconst SECTION_TRANSITION_MS = 350;\n\n/**\n * Renders the children of a single {@link ToolbarContext} together with any slot items\n * that have been registered under the context's `slotName`.\n *\n * Extracted into its own component so that the `useToolbarSlot` hook can be called\n * inside it — hooks cannot be called inside a callback or loop in the parent.\n */\nconst ContextRenderer = ({ children, slotName }: { children: ReactNode; slotName?: string }) => {\n const slotItems = useToolbarSlot(slotName ?? '');\n return (\n <>\n {children}\n {slotName && slotItems.length > 0 && slotItems}\n </>\n );\n};\n\n/** Stable part attributes for {@link ToolbarSection}. */\nexport interface ToolbarSectionParts {\n /** Animated section root. */\n root?: HTMLAttributes<HTMLDivElement>;\n /** One named context, with active state exposed through data attributes. */\n context?: HTMLAttributes<HTMLDivElement>;\n}\n\n/** Props for the {@link ToolbarSection} component. */\nexport interface ToolbarSectionProps {\n /**\n * The name of the currently active context.\n * Change this to trigger the fade-out / morph / fade-in animation.\n * Defaults to the first context if not specified.\n */\n activeContext?: string;\n\n /** {@link ToolbarContext} elements that define each context's toolbar items. */\n children: ReactNode;\n\n /** Layout direction matching the parent {@link Toolbar} (default: 'vertical'). */\n orientation?: 'vertical' | 'horizontal';\n\n /** Stable section and context attributes. */\n pt?: ToolbarSectionParts;\n}\n\n/**\n * A section within a {@link Toolbar} that supports multiple named contexts.\n *\n * When {@link activeContext} changes:\n * - The current items fade out.\n * - The section smoothly morphs to the dimensions required by the new context.\n * - The new items fade in.\n *\n * Contexts are defined by placing {@link ToolbarContext} children inside this section.\n * Switching contexts only affects this section; other sections are unaffected.\n */\nexport const ToolbarSection = ({\n activeContext,\n children,\n orientation = 'vertical',\n pt,\n}: ToolbarSectionProps) => {\n const contextRefs = useRef<Record<string, HTMLDivElement | null>>({});\n const resizeObserverRef = useRef<ResizeObserver | null>(null);\n const mutationObserverRef = useRef<MutationObserver | null>(null);\n const transitionTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const previousContextRef = useRef<string | null>(null);\n const [size, setSize] = useState<{ width: number; height: number } | null>(null);\n const [isTransitioning, setIsTransitioning] = useState(false);\n\n const contexts = Children.toArray(children).filter(\n (child): child is ReactElement<ToolbarContextProps> =>\n isValidElement(child) && typeof (child.props as ToolbarContextProps).name === 'string'\n );\n\n // Default to the first context if activeContext is not provided\n const effectiveContext = activeContext ?? (contexts[0]?.props as ToolbarContextProps)?.name ?? '';\n\n const flexClass = orientation === 'horizontal' ? 'cratis:flex-row' : 'cratis:flex-col';\n\n /** Measure the given context's natural dimensions and update the section size. */\n const measureAndSetSize = useCallback((contextName: string) => {\n const ref = contextRefs.current[contextName];\n if (ref) {\n setSize({\n width: ref.offsetWidth,\n height: ref.offsetHeight,\n });\n }\n }, []);\n\n // Set the initial size synchronously before the first browser paint so there is no layout flash.\n // Empty dependency array is intentional: ongoing context changes are handled by the useEffect below.\n useLayoutEffect(() => {\n measureAndSetSize(effectiveContext);\n }, []); // run only on mount\n\n // Clip content only while the section is morphing between contexts so incoming\n // buttons do not float outside the current bounds during growth.\n useEffect(() => {\n if (previousContextRef.current === null) {\n previousContextRef.current = effectiveContext;\n return;\n }\n if (previousContextRef.current === effectiveContext) return;\n\n previousContextRef.current = effectiveContext;\n setIsTransitioning(true);\n\n if (transitionTimeoutRef.current) clearTimeout(transitionTimeoutRef.current);\n transitionTimeoutRef.current = setTimeout(() => {\n setIsTransitioning(false);\n transitionTimeoutRef.current = null;\n }, SECTION_TRANSITION_MS);\n }, [effectiveContext]);\n\n // After a context switch, let the browser paint the opacity transition first,\n // then update the explicit size so the CSS width/height transition kicks in.\n useEffect(() => {\n measureAndSetSize(effectiveContext);\n }, [effectiveContext, measureAndSetSize]);\n\n // Keep section dimensions in sync when the active context's content changes size after render.\n useEffect(() => {\n const activeContextElement = contextRefs.current[effectiveContext];\n if (!activeContextElement || typeof ResizeObserver === 'undefined') {\n return;\n }\n\n measureAndSetSize(effectiveContext);\n\n mutationObserverRef.current?.disconnect();\n resizeObserverRef.current?.disconnect();\n\n const observer = new ResizeObserver(() => {\n measureAndSetSize(effectiveContext);\n });\n\n observer.observe(activeContextElement);\n resizeObserverRef.current = observer;\n\n if (typeof MutationObserver !== 'undefined') {\n const mutationObserver = new MutationObserver(() => {\n measureAndSetSize(effectiveContext);\n });\n mutationObserver.observe(activeContextElement, {\n childList: true,\n subtree: true,\n attributes: true,\n });\n mutationObserverRef.current = mutationObserver;\n }\n\n return () => {\n observer.disconnect();\n if (resizeObserverRef.current === observer) {\n resizeObserverRef.current = null;\n }\n\n mutationObserverRef.current?.disconnect();\n mutationObserverRef.current = null;\n };\n }, [effectiveContext, measureAndSetSize]);\n\n useEffect(() => () => {\n if (transitionTimeoutRef.current) clearTimeout(transitionTimeoutRef.current);\n }, []);\n\n return (\n <div\n {...pt?.root}\n className={`toolbar-section ${isTransitioning ? 'toolbar-section--transitioning' : ''} ${pt?.root?.className ?? ''}`}\n style={{ ...pt?.root?.style, ...(size ? { width: size.width, height: size.height } : {}) }}\n data-cratis-part='toolbar-section'\n data-cratis-component='ToolbarSection'\n data-transitioning={isTransitioning || undefined}\n data-orientation={orientation}\n >\n {contexts.map((child) => {\n const { name, children: contextChildren, slotName } = child.props as ToolbarContextProps;\n const isActive = name === effectiveContext;\n\n return (\n <div\n key={name}\n {...pt?.context}\n ref={(element) => { contextRefs.current[name] = element; }}\n className={`toolbar-context cratis:inline-flex ${flexClass} cratis:items-center cratis:gap-1 ${\n isActive ? 'toolbar-context--active' : 'toolbar-context--inactive'\n } ${pt?.context?.className ?? ''}`}\n data-cratis-part='toolbar-context'\n data-context-name={name}\n data-active={isActive || undefined}\n data-selected={isActive || undefined}\n aria-hidden={!isActive}\n inert={!isActive}\n >\n <ToolbarItemVisibilityProvider value={isActive}>\n <ContextRenderer slotName={slotName}>\n {contextChildren}\n </ContextRenderer>\n </ToolbarItemVisibilityProvider>\n </div>\n );\n })}\n </div>\n );\n};\n"],"names":["_jsxs","_Fragment","_jsx"],"mappings":";;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AAE,CAAC,QAAQ,YAEhBA,GAAA,CAAC,6BAA6B,IAAC,KAAK,EAAE,QAAQ,EAAA,QAAA,EAC1CA,GAAA,CAAC,eAAe,EAAA,EAAC,QAAQ,EAAE,QAAQ,EAAA,QAAA,EAC9B,eAAe,EAAA,CACF,EAAA,CACU,IAjB3B,IAAI,CAkBP;QAEd,CAAC,CAAC,EAAA,CACA;AAEd;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolbarSeparator.d.ts","sourceRoot":"","sources":["../../../Toolbar/ToolbarSeparator.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C,2DAA2D;AAC3D,MAAM,WAAW,qBAAqB;IAClC,6BAA6B;IAC7B,IAAI,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;CACzC;AAED,wDAAwD;AACxD,MAAM,WAAW,qBAAqB;IAClC,kFAAkF;IAClF,WAAW,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;IACxC,mCAAmC;IACnC,EAAE,CAAC,EAAE,qBAAqB,CAAC;CAC9B;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,yBAG1B,qBAAqB,
|
|
1
|
+
{"version":3,"file":"ToolbarSeparator.d.ts","sourceRoot":"","sources":["../../../Toolbar/ToolbarSeparator.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C,2DAA2D;AAC3D,MAAM,WAAW,qBAAqB;IAClC,6BAA6B;IAC7B,IAAI,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;CACzC;AAED,wDAAwD;AACxD,MAAM,WAAW,qBAAqB;IAClC,kFAAkF;IAClF,WAAW,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;IACxC,mCAAmC;IACnC,EAAE,CAAC,EAAE,qBAAqB,CAAC;CAC9B;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,yBAG1B,qBAAqB,gCAUvB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
|
|
3
|
-
const ToolbarSeparator = ({ orientation = 'vertical', pt, }) => (jsx("div", { ...pt?.root, role: 'separator', "aria-orientation": orientation === 'horizontal' ? 'vertical' : 'horizontal', className: `${orientation === 'horizontal' ? 'toolbar-separator toolbar-separator--in-horizontal' : 'toolbar-separator toolbar-separator--in-vertical'} ${pt?.root?.className ?? ''}`, "data-cratis-part": 'toolbar-separator', "data-orientation": orientation }));
|
|
3
|
+
const ToolbarSeparator = ({ orientation = 'vertical', pt, }) => (jsx("div", { ...pt?.root, role: 'separator', "aria-orientation": orientation === 'horizontal' ? 'vertical' : 'horizontal', className: `${orientation === 'horizontal' ? 'toolbar-separator toolbar-separator--in-horizontal' : 'toolbar-separator toolbar-separator--in-vertical'} ${pt?.root?.className ?? ''}`, "data-cratis-part": 'toolbar-separator', "data-cratis-component": 'ToolbarSeparator', "data-orientation": orientation }));
|
|
4
4
|
|
|
5
5
|
export { ToolbarSeparator };
|
|
6
6
|
//# sourceMappingURL=ToolbarSeparator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolbarSeparator.js","sources":["../../../Toolbar/ToolbarSeparator.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { HTMLAttributes } from 'react';\n\n/** Stable part attributes for {@link ToolbarSeparator}. */\nexport interface ToolbarSeparatorParts {\n /** Native separator root. */\n root?: HTMLAttributes<HTMLDivElement>;\n}\n\n/** Props for the {@link ToolbarSeparator} component. */\nexport interface ToolbarSeparatorProps {\n /** Layout direction matching the parent {@link Toolbar} (default: 'vertical'). */\n orientation?: 'vertical' | 'horizontal';\n /** Stable separator attributes. */\n pt?: ToolbarSeparatorParts;\n}\n\n/**\n * A visual divider for use inside a {@link Toolbar}.\n *\n * In a vertical toolbar (default) the separator renders as a horizontal rule.\n * In a horizontal toolbar it renders as a vertical rule.\n */\nexport const ToolbarSeparator = ({\n orientation = 'vertical',\n pt,\n}: ToolbarSeparatorProps) => (\n <div\n {...pt?.root}\n role='separator'\n aria-orientation={orientation === 'horizontal' ? 'vertical' : 'horizontal'}\n className={`${orientation === 'horizontal' ? 'toolbar-separator toolbar-separator--in-horizontal' : 'toolbar-separator toolbar-separator--in-vertical'} ${pt?.root?.className ?? ''}`}\n data-cratis-part='toolbar-separator'\n data-orientation={orientation}\n />\n);\n"],"names":["_jsx"],"mappings":";;AAyBO,MAAM,gBAAgB,GAAG,CAAC,EAC7B,WAAW,GAAG,UAAU,EACxB,EAAE,GACkB,MACpBA,GAAA,CAAA,KAAA,EAAA,EAAA,GACQ,EAAE,EAAE,IAAI,EACZ,IAAI,EAAC,WAAW,EAAA,kBAAA,EACE,WAAW,KAAK,YAAY,GAAG,UAAU,GAAG,YAAY,EAC1E,SAAS,EAAE,CAAA,EAAG,WAAW,KAAK,YAAY,GAAG,oDAAoD,GAAG,kDAAkD,CAAA,CAAA,EAAI,EAAE,EAAE,IAAI,EAAE,SAAS,IAAI,EAAE,CAAA,CAAE,EAAA,kBAAA,EACpK,mBAAmB,EAAA,kBAAA,
|
|
1
|
+
{"version":3,"file":"ToolbarSeparator.js","sources":["../../../Toolbar/ToolbarSeparator.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { HTMLAttributes } from 'react';\n\n/** Stable part attributes for {@link ToolbarSeparator}. */\nexport interface ToolbarSeparatorParts {\n /** Native separator root. */\n root?: HTMLAttributes<HTMLDivElement>;\n}\n\n/** Props for the {@link ToolbarSeparator} component. */\nexport interface ToolbarSeparatorProps {\n /** Layout direction matching the parent {@link Toolbar} (default: 'vertical'). */\n orientation?: 'vertical' | 'horizontal';\n /** Stable separator attributes. */\n pt?: ToolbarSeparatorParts;\n}\n\n/**\n * A visual divider for use inside a {@link Toolbar}.\n *\n * In a vertical toolbar (default) the separator renders as a horizontal rule.\n * In a horizontal toolbar it renders as a vertical rule.\n */\nexport const ToolbarSeparator = ({\n orientation = 'vertical',\n pt,\n}: ToolbarSeparatorProps) => (\n <div\n {...pt?.root}\n role='separator'\n aria-orientation={orientation === 'horizontal' ? 'vertical' : 'horizontal'}\n className={`${orientation === 'horizontal' ? 'toolbar-separator toolbar-separator--in-horizontal' : 'toolbar-separator toolbar-separator--in-vertical'} ${pt?.root?.className ?? ''}`}\n data-cratis-part='toolbar-separator'\n data-cratis-component='ToolbarSeparator'\n data-orientation={orientation}\n />\n);\n"],"names":["_jsx"],"mappings":";;AAyBO,MAAM,gBAAgB,GAAG,CAAC,EAC7B,WAAW,GAAG,UAAU,EACxB,EAAE,GACkB,MACpBA,GAAA,CAAA,KAAA,EAAA,EAAA,GACQ,EAAE,EAAE,IAAI,EACZ,IAAI,EAAC,WAAW,EAAA,kBAAA,EACE,WAAW,KAAK,YAAY,GAAG,UAAU,GAAG,YAAY,EAC1E,SAAS,EAAE,CAAA,EAAG,WAAW,KAAK,YAAY,GAAG,oDAAoD,GAAG,kDAAkD,CAAA,CAAA,EAAI,EAAE,EAAE,IAAI,EAAE,SAAS,IAAI,EAAE,CAAA,CAAE,EAAA,kBAAA,EACpK,mBAAmB,EAAA,uBAAA,EACd,kBAAkB,EAAA,kBAAA,EACtB,WAAW,EAAA,CAC/B;;"}
|
package/package.json
CHANGED