@cratis/components 1.0.4 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/CommandDialog/CommandDialog.js +2 -2
- package/dist/cjs/CommandDialog/CommandDialog.js.map +1 -1
- package/dist/cjs/Common/Tooltip.css +10 -0
- package/dist/cjs/Common/Tooltip.js +17 -0
- package/dist/cjs/Common/Tooltip.js.map +1 -0
- package/dist/cjs/Common/index.js +2 -0
- package/dist/cjs/Common/index.js.map +1 -1
- package/dist/cjs/ObjectContentEditor/ObjectContentEditor.js +3 -16
- package/dist/cjs/ObjectContentEditor/ObjectContentEditor.js.map +1 -1
- package/dist/cjs/ObjectContentEditor/objectHelpers.js +19 -0
- package/dist/cjs/ObjectContentEditor/objectHelpers.js.map +1 -0
- package/dist/cjs/ObjectNavigationalBar/ObjectNavigationalBar.js +2 -10
- package/dist/cjs/ObjectNavigationalBar/ObjectNavigationalBar.js.map +1 -1
- package/dist/cjs/ObjectNavigationalBar/breadcrumbHelpers.js +15 -0
- package/dist/cjs/ObjectNavigationalBar/breadcrumbHelpers.js.map +1 -0
- package/dist/cjs/SchemaEditor/SchemaEditor.js +4 -35
- package/dist/cjs/SchemaEditor/SchemaEditor.js.map +1 -1
- package/dist/cjs/SchemaEditor/schemaHelpers.js +33 -0
- package/dist/cjs/SchemaEditor/schemaHelpers.js.map +1 -0
- package/dist/cjs/TimeMachine/Properties.js +2 -7
- package/dist/cjs/TimeMachine/Properties.js.map +1 -1
- package/dist/cjs/TimeMachine/propertiesHelpers.js +11 -0
- package/dist/cjs/TimeMachine/propertiesHelpers.js.map +1 -0
- package/dist/cjs/Toolbar/Toolbar.css +131 -0
- package/dist/cjs/Toolbar/Toolbar.js +9 -0
- package/dist/cjs/Toolbar/Toolbar.js.map +1 -0
- package/dist/cjs/Toolbar/ToolbarButton.js +12 -0
- package/dist/cjs/Toolbar/ToolbarButton.js.map +1 -0
- package/dist/cjs/Toolbar/ToolbarContext.js +6 -0
- package/dist/cjs/Toolbar/ToolbarContext.js.map +1 -0
- package/dist/cjs/Toolbar/ToolbarFanOutItem.js +33 -0
- package/dist/cjs/Toolbar/ToolbarFanOutItem.js.map +1 -0
- package/dist/cjs/Toolbar/ToolbarSection.js +32 -0
- package/dist/cjs/Toolbar/ToolbarSection.js.map +1 -0
- package/dist/cjs/Toolbar/index.js +16 -0
- package/dist/cjs/Toolbar/index.js.map +1 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/CommandDialog/CommandDialog.d.ts.map +1 -1
- package/dist/esm/CommandDialog/CommandDialog.js +2 -2
- package/dist/esm/CommandDialog/CommandDialog.js.map +1 -1
- package/dist/esm/Common/Tooltip.css +10 -0
- package/dist/esm/Common/Tooltip.d.ts +10 -0
- package/dist/esm/Common/Tooltip.d.ts.map +1 -0
- package/dist/esm/Common/Tooltip.js +15 -0
- package/dist/esm/Common/Tooltip.js.map +1 -0
- package/dist/esm/Common/index.d.ts +1 -0
- package/dist/esm/Common/index.d.ts.map +1 -1
- package/dist/esm/Common/index.js +1 -0
- package/dist/esm/Common/index.js.map +1 -1
- package/dist/esm/ObjectContentEditor/ObjectContentEditor.d.ts.map +1 -1
- package/dist/esm/ObjectContentEditor/ObjectContentEditor.js +1 -14
- package/dist/esm/ObjectContentEditor/ObjectContentEditor.js.map +1 -1
- package/dist/esm/ObjectContentEditor/objectHelpers.d.ts +3 -0
- package/dist/esm/ObjectContentEditor/objectHelpers.d.ts.map +1 -0
- package/dist/esm/ObjectContentEditor/objectHelpers.js +17 -0
- package/dist/esm/ObjectContentEditor/objectHelpers.js.map +1 -0
- package/dist/esm/ObjectNavigationalBar/ObjectNavigationalBar.d.ts.map +1 -1
- package/dist/esm/ObjectNavigationalBar/ObjectNavigationalBar.js +2 -10
- package/dist/esm/ObjectNavigationalBar/ObjectNavigationalBar.js.map +1 -1
- package/dist/esm/ObjectNavigationalBar/breadcrumbHelpers.d.ts +5 -0
- package/dist/esm/ObjectNavigationalBar/breadcrumbHelpers.d.ts.map +1 -0
- package/dist/esm/ObjectNavigationalBar/breadcrumbHelpers.js +13 -0
- package/dist/esm/ObjectNavigationalBar/breadcrumbHelpers.js.map +1 -0
- package/dist/esm/SchemaEditor/SchemaEditor.d.ts.map +1 -1
- package/dist/esm/SchemaEditor/SchemaEditor.js +2 -33
- package/dist/esm/SchemaEditor/SchemaEditor.js.map +1 -1
- package/dist/esm/SchemaEditor/schemaHelpers.d.ts +4 -0
- package/dist/esm/SchemaEditor/schemaHelpers.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/schemaHelpers.js +30 -0
- package/dist/esm/SchemaEditor/schemaHelpers.js.map +1 -0
- package/dist/esm/TimeMachine/Properties.d.ts.map +1 -1
- package/dist/esm/TimeMachine/Properties.js +1 -6
- package/dist/esm/TimeMachine/Properties.js.map +1 -1
- package/dist/esm/TimeMachine/propertiesHelpers.d.ts +2 -0
- package/dist/esm/TimeMachine/propertiesHelpers.d.ts.map +1 -0
- package/dist/esm/TimeMachine/propertiesHelpers.js +9 -0
- package/dist/esm/TimeMachine/propertiesHelpers.js.map +1 -0
- package/dist/esm/Toolbar/Toolbar.css +131 -0
- package/dist/esm/Toolbar/Toolbar.d.ts +8 -0
- package/dist/esm/Toolbar/Toolbar.d.ts.map +1 -0
- package/dist/esm/Toolbar/Toolbar.js +7 -0
- package/dist/esm/Toolbar/Toolbar.js.map +1 -0
- package/dist/esm/Toolbar/Toolbar.stories.d.ts +11 -0
- package/dist/esm/Toolbar/Toolbar.stories.d.ts.map +1 -0
- package/dist/esm/Toolbar/Toolbar.stories.js +53 -0
- package/dist/esm/Toolbar/Toolbar.stories.js.map +1 -0
- package/dist/esm/Toolbar/ToolbarButton.d.ts +10 -0
- package/dist/esm/Toolbar/ToolbarButton.d.ts.map +1 -0
- package/dist/esm/Toolbar/ToolbarButton.js +10 -0
- package/dist/esm/Toolbar/ToolbarButton.js.map +1 -0
- package/dist/esm/Toolbar/ToolbarContext.d.ts +7 -0
- package/dist/esm/Toolbar/ToolbarContext.d.ts.map +1 -0
- package/dist/esm/Toolbar/ToolbarContext.js +4 -0
- package/dist/esm/Toolbar/ToolbarContext.js.map +1 -0
- package/dist/esm/Toolbar/ToolbarFanOutItem.d.ts +11 -0
- package/dist/esm/Toolbar/ToolbarFanOutItem.d.ts.map +1 -0
- package/dist/esm/Toolbar/ToolbarFanOutItem.js +31 -0
- package/dist/esm/Toolbar/ToolbarFanOutItem.js.map +1 -0
- package/dist/esm/Toolbar/ToolbarSection.d.ts +8 -0
- package/dist/esm/Toolbar/ToolbarSection.d.ts.map +1 -0
- package/dist/esm/Toolbar/ToolbarSection.js +30 -0
- package/dist/esm/Toolbar/ToolbarSection.js.map +1 -0
- package/dist/esm/Toolbar/index.d.ts +11 -0
- package/dist/esm/Toolbar/index.d.ts.map +1 -0
- package/dist/esm/Toolbar/index.js +6 -0
- package/dist/esm/Toolbar/index.js.map +1 -0
- package/dist/esm/given.d.ts +5 -0
- package/dist/esm/given.d.ts.map +1 -0
- package/dist/esm/given.js +7 -0
- package/dist/esm/given.js.map +1 -0
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -4
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import type { TooltipPosition } from '../Common/Tooltip';
|
|
3
|
+
export interface ToolbarFanOutItemProps {
|
|
4
|
+
icon: string;
|
|
5
|
+
tooltip: string;
|
|
6
|
+
tooltipPosition?: TooltipPosition;
|
|
7
|
+
fanOutDirection?: 'right' | 'left';
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
export declare const ToolbarFanOutItem: ({ icon, tooltip, tooltipPosition, fanOutDirection, children, }: ToolbarFanOutItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=ToolbarFanOutItem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolbarFanOutItem.d.ts","sourceRoot":"","sources":["../../../Toolbar/ToolbarFanOutItem.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAA+B,MAAM,OAAO,CAAC;AAE/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD,MAAM,WAAW,sBAAsB;IAEnC,IAAI,EAAE,MAAM,CAAC;IAGb,OAAO,EAAE,MAAM,CAAC;IAGhB,eAAe,CAAC,EAAE,eAAe,CAAC;IAGlC,eAAe,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAGnC,QAAQ,EAAE,SAAS,CAAC;CACvB;AAYD,eAAO,MAAM,iBAAiB,GAAI,gEAM/B,sBAAsB,4CA8CxB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useState, useRef, useEffect } from 'react';
|
|
3
|
+
import { Tooltip } from '../Common/Tooltip.js';
|
|
4
|
+
|
|
5
|
+
const ToolbarFanOutItem = ({ icon, tooltip, tooltipPosition = 'right', fanOutDirection = 'right', children, }) => {
|
|
6
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
7
|
+
const containerRef = useRef(null);
|
|
8
|
+
const handleToggle = () => {
|
|
9
|
+
setIsExpanded(!isExpanded);
|
|
10
|
+
};
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (!isExpanded)
|
|
13
|
+
return;
|
|
14
|
+
const handleClickOutside = (event) => {
|
|
15
|
+
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
16
|
+
setIsExpanded(false);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
20
|
+
return () => {
|
|
21
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
22
|
+
};
|
|
23
|
+
}, [isExpanded]);
|
|
24
|
+
const activeClass = isExpanded ? 'toolbar-button--active' : '';
|
|
25
|
+
const panelVisibleClass = isExpanded ? 'toolbar-fanout-panel--visible' : '';
|
|
26
|
+
const directionClass = `toolbar-fanout-panel--${fanOutDirection}`;
|
|
27
|
+
return (jsxs("div", { className: 'toolbar-fanout-item', ref: containerRef, children: [jsx(Tooltip, { content: tooltip, position: tooltipPosition, children: jsx("button", { type: 'button', "aria-label": tooltip, "aria-expanded": isExpanded, onClick: handleToggle, className: `toolbar-button w-10 h-10 flex items-center justify-center rounded-lg cursor-pointer ${activeClass}`, children: jsx("i", { className: `${icon} text-lg` }) }) }), jsx("div", { className: `toolbar-fanout-panel ${directionClass} ${panelVisibleClass}`, children: children })] }));
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { ToolbarFanOutItem };
|
|
31
|
+
//# sourceMappingURL=ToolbarFanOutItem.js.map
|
|
@@ -0,0 +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 { ReactNode, useEffect, useRef, useState } from 'react';\nimport { Tooltip } from '../Common/Tooltip';\nimport type { TooltipPosition } from '../Common/Tooltip';\n\n/** Props for the {@link ToolbarFanOutItem} component. */\nexport interface ToolbarFanOutItemProps {\n /** The PrimeIcons CSS class to use as the trigger icon (e.g. 'pi pi-home'). */\n icon: string;\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';\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 children,\n}: ToolbarFanOutItemProps) => {\n const [isExpanded, setIsExpanded] = useState(false);\n const containerRef = useRef<HTMLDivElement>(null);\n\n const handleToggle = () => {\n setIsExpanded(!isExpanded);\n };\n\n // Close the fan-out when clicking outside\n useEffect(() => {\n if (!isExpanded) return;\n\n const handleClickOutside = (event: MouseEvent) => {\n if (containerRef.current && !containerRef.current.contains(event.target as Node)) {\n setIsExpanded(false);\n }\n };\n\n document.addEventListener('mousedown', handleClickOutside);\n return () => {\n document.removeEventListener('mousedown', handleClickOutside);\n };\n }, [isExpanded]);\n\n const activeClass = isExpanded ? 'toolbar-button--active' : '';\n const panelVisibleClass = isExpanded ? 'toolbar-fanout-panel--visible' : '';\n const directionClass = `toolbar-fanout-panel--${fanOutDirection}`;\n\n return (\n <div className='toolbar-fanout-item' ref={containerRef}>\n <Tooltip content={tooltip} position={tooltipPosition}>\n <button\n type='button'\n aria-label={tooltip}\n aria-expanded={isExpanded}\n onClick={handleToggle}\n className={`toolbar-button w-10 h-10 flex items-center justify-center rounded-lg cursor-pointer ${activeClass}`}\n >\n <i className={`${icon} text-lg`} />\n </button>\n </Tooltip>\n <div className={`toolbar-fanout-panel ${directionClass} ${panelVisibleClass}`}>\n {children}\n </div>\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;MAmCa,iBAAiB,GAAG,CAAC,EAC9B,IAAI,EACJ,OAAO,EACP,eAAe,GAAG,OAAO,EACzB,eAAe,GAAG,OAAO,EACzB,QAAQ,GACa,KAAI;IACzB,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;AACnD,IAAA,MAAM,YAAY,GAAG,MAAM,CAAiB,IAAI,CAAC;IAEjD,MAAM,YAAY,GAAG,MAAK;AACtB,QAAA,aAAa,CAAC,CAAC,UAAU,CAAC;AAC9B,IAAA,CAAC;IAGD,SAAS,CAAC,MAAK;AACX,QAAA,IAAI,CAAC,UAAU;YAAE;AAEjB,QAAA,MAAM,kBAAkB,GAAG,CAAC,KAAiB,KAAI;AAC7C,YAAA,IAAI,YAAY,CAAC,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAc,CAAC,EAAE;gBAC9E,aAAa,CAAC,KAAK,CAAC;YACxB;AACJ,QAAA,CAAC;AAED,QAAA,QAAQ,CAAC,gBAAgB,CAAC,WAAW,EAAE,kBAAkB,CAAC;AAC1D,QAAA,OAAO,MAAK;AACR,YAAA,QAAQ,CAAC,mBAAmB,CAAC,WAAW,EAAE,kBAAkB,CAAC;AACjE,QAAA,CAAC;AACL,IAAA,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC;IAEhB,MAAM,WAAW,GAAG,UAAU,GAAG,wBAAwB,GAAG,EAAE;IAC9D,MAAM,iBAAiB,GAAG,UAAU,GAAG,+BAA+B,GAAG,EAAE;AAC3E,IAAA,MAAM,cAAc,GAAG,CAAA,sBAAA,EAAyB,eAAe,EAAE;AAEjE,IAAA,QACIA,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,qBAAqB,EAAC,GAAG,EAAE,YAAY,EAAA,QAAA,EAAA,CAClDC,GAAA,CAAC,OAAO,EAAA,EAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAA,QAAA,EAChDA,GAAA,CAAA,QAAA,EAAA,EACI,IAAI,EAAC,QAAQ,EAAA,YAAA,EACD,OAAO,EAAA,eAAA,EACJ,UAAU,EACzB,OAAO,EAAE,YAAY,EACrB,SAAS,EAAE,CAAA,oFAAA,EAAuF,WAAW,CAAA,CAAE,EAAA,QAAA,EAE/GA,GAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAE,CAAA,EAAG,IAAI,UAAU,EAAA,CAAI,EAAA,CAC9B,EAAA,CACH,EACVA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,CAAA,qBAAA,EAAwB,cAAc,CAAA,CAAA,EAAI,iBAAiB,CAAA,CAAE,EAAA,QAAA,EACxE,QAAQ,EAAA,CACP,CAAA,EAAA,CACJ;AAEd;;;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface ToolbarSectionProps {
|
|
3
|
+
activeContext?: string;
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
orientation?: 'vertical' | 'horizontal';
|
|
6
|
+
}
|
|
7
|
+
export declare const ToolbarSection: ({ activeContext, children, orientation }: ToolbarSectionProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=ToolbarSection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolbarSection.d.ts","sourceRoot":"","sources":["../../../Toolbar/ToolbarSection.tsx"],"names":[],"mappings":"AAGA,OAAO,EAA0B,SAAS,EAA6E,MAAM,OAAO,CAAC;AAKrI,MAAM,WAAW,mBAAmB;IAMhC,aAAa,CAAC,EAAE,MAAM,CAAC;IAGvB,QAAQ,EAAE,SAAS,CAAC;IAGpB,WAAW,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;CAC3C;AAaD,eAAO,MAAM,cAAc,GAAI,0CAAuD,mBAAmB,4CAyDxG,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useRef, useState, Children, isValidElement, useCallback, useLayoutEffect, useEffect } from 'react';
|
|
3
|
+
|
|
4
|
+
const ToolbarSection = ({ activeContext, children, orientation = 'vertical' }) => {
|
|
5
|
+
const contextRefs = useRef({});
|
|
6
|
+
const [size, setSize] = useState(null);
|
|
7
|
+
const contexts = Children.toArray(children).filter((child) => isValidElement(child) && typeof child.props.name === 'string');
|
|
8
|
+
const effectiveContext = activeContext ?? contexts[0]?.props?.name ?? '';
|
|
9
|
+
const flexClass = orientation === 'horizontal' ? 'flex-row' : 'flex-col';
|
|
10
|
+
const measureAndSetSize = useCallback((contextName) => {
|
|
11
|
+
const ref = contextRefs.current[contextName];
|
|
12
|
+
if (ref) {
|
|
13
|
+
setSize({ width: ref.offsetWidth, height: ref.offsetHeight });
|
|
14
|
+
}
|
|
15
|
+
}, []);
|
|
16
|
+
useLayoutEffect(() => {
|
|
17
|
+
measureAndSetSize(effectiveContext);
|
|
18
|
+
}, []);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
measureAndSetSize(effectiveContext);
|
|
21
|
+
}, [effectiveContext, measureAndSetSize]);
|
|
22
|
+
return (jsx("div", { className: 'toolbar-section', style: size ? { width: size.width, height: size.height } : undefined, children: contexts.map((child) => {
|
|
23
|
+
const { name, children: contextChildren } = child.props;
|
|
24
|
+
const isActive = name === effectiveContext;
|
|
25
|
+
return (jsx("div", { ref: (element) => { contextRefs.current[name] = element; }, className: `toolbar-context inline-flex ${flexClass} items-center gap-1 ${isActive ? 'toolbar-context--active' : 'toolbar-context--inactive'}`, children: contextChildren }, name));
|
|
26
|
+
}) }));
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { ToolbarSection };
|
|
30
|
+
//# sourceMappingURL=ToolbarSection.js.map
|
|
@@ -0,0 +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 { Children, ReactElement, ReactNode, isValidElement, useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';\n\nimport type { ToolbarContextProps } from './ToolbarContext';\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\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 = ({ activeContext, children, orientation = 'vertical' }: ToolbarSectionProps) => {\n const contextRefs = useRef<Record<string, HTMLDivElement | null>>({});\n const [size, setSize] = useState<{ width: number; height: number } | null>(null);\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' ? 'flex-row' : '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({ width: ref.offsetWidth, height: ref.offsetHeight });\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 // 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 return (\n <div\n className='toolbar-section'\n style={size ? { width: size.width, height: size.height } : undefined}\n >\n {contexts.map((child) => {\n const { name, children: contextChildren } = child.props as ToolbarContextProps;\n const isActive = name === effectiveContext;\n\n return (\n <div\n key={name}\n ref={(element) => { contextRefs.current[name] = element; }}\n className={`toolbar-context inline-flex ${flexClass} items-center gap-1 ${\n isActive ? 'toolbar-context--active' : 'toolbar-context--inactive'\n }`}\n >\n {contextChildren}\n </div>\n );\n })}\n </div>\n );\n};\n"],"names":["_jsx"],"mappings":";;;AAkCO,MAAM,cAAc,GAAG,CAAC,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,GAAG,UAAU,EAAuB,KAAI;AACzG,IAAA,MAAM,WAAW,GAAG,MAAM,CAAwC,EAAE,CAAC;IACrE,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAA2C,IAAI,CAAC;AAEhF,IAAA,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAC9C,CAAC,KAAK,KACF,cAAc,CAAC,KAAK,CAAC,IAAI,OAAQ,KAAK,CAAC,KAA6B,CAAC,IAAI,KAAK,QAAQ,CAC7F;AAGD,IAAA,MAAM,gBAAgB,GAAG,aAAa,IAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,KAA6B,EAAE,IAAI,IAAI,EAAE;AAEjG,IAAA,MAAM,SAAS,GAAG,WAAW,KAAK,YAAY,GAAG,UAAU,GAAG,UAAU;AAGxE,IAAA,MAAM,iBAAiB,GAAG,WAAW,CAAC,CAAC,WAAmB,KAAI;QAC1D,MAAM,GAAG,GAAG,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC;QAC5C,IAAI,GAAG,EAAE;AACL,YAAA,OAAO,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,CAAC,YAAY,EAAE,CAAC;QACjE;IACJ,CAAC,EAAE,EAAE,CAAC;IAIN,eAAe,CAAC,MAAK;QACjB,iBAAiB,CAAC,gBAAgB,CAAC;IACvC,CAAC,EAAE,EAAE,CAAC;IAIN,SAAS,CAAC,MAAK;QACX,iBAAiB,CAAC,gBAAgB,CAAC;AACvC,IAAA,CAAC,EAAE,CAAC,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;AAEzC,IAAA,QACIA,GAAA,CAAA,KAAA,EAAA,EACI,SAAS,EAAC,iBAAiB,EAC3B,KAAK,EAAE,IAAI,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,GAAG,SAAS,EAAA,QAAA,EAEnE,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,KAAI;YACpB,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,GAAG,KAAK,CAAC,KAA4B;AAC9E,YAAA,MAAM,QAAQ,GAAG,IAAI,KAAK,gBAAgB;AAE1C,YAAA,QACIA,GAAA,CAAA,KAAA,EAAA,EAEI,GAAG,EAAE,CAAC,OAAO,KAAI,EAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAC1D,SAAS,EAAE,+BAA+B,SAAS,CAAA,oBAAA,EAC/C,QAAQ,GAAG,yBAAyB,GAAG,2BAC3C,EAAE,EAAA,QAAA,EAED,eAAe,IANX,IAAI,CAOP;QAEd,CAAC,CAAC,EAAA,CACA;AAEd;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { Toolbar } from './Toolbar';
|
|
2
|
+
export type { ToolbarProps } from './Toolbar';
|
|
3
|
+
export { ToolbarButton } from './ToolbarButton';
|
|
4
|
+
export type { ToolbarButtonProps } from './ToolbarButton';
|
|
5
|
+
export { ToolbarContext } from './ToolbarContext';
|
|
6
|
+
export type { ToolbarContextProps } from './ToolbarContext';
|
|
7
|
+
export { ToolbarSection } from './ToolbarSection';
|
|
8
|
+
export type { ToolbarSectionProps } from './ToolbarSection';
|
|
9
|
+
export { ToolbarFanOutItem } from './ToolbarFanOutItem';
|
|
10
|
+
export type { ToolbarFanOutItemProps } from './ToolbarFanOutItem';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../Toolbar/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,YAAY,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { Toolbar } from './Toolbar.js';
|
|
2
|
+
export { ToolbarButton } from './ToolbarButton.js';
|
|
3
|
+
export { ToolbarContext } from './ToolbarContext.js';
|
|
4
|
+
export { ToolbarSection } from './ToolbarSection.js';
|
|
5
|
+
export { ToolbarFanOutItem } from './ToolbarFanOutItem.js';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Constructor } from '@cratis/fundamentals';
|
|
2
|
+
import { Suite } from 'mocha';
|
|
3
|
+
export type ContextForSuite<TContext extends object> = (this: Suite, context: TContext) => void;
|
|
4
|
+
export declare function given<TContext extends object>(contextType: Constructor<TContext>, callback: ContextForSuite<TContext>): (this: Suite) => void;
|
|
5
|
+
//# sourceMappingURL=given.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"given.d.ts","sourceRoot":"","sources":["../../given.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE9B,MAAM,MAAM,eAAe,CAAC,QAAQ,SAAS,MAAM,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,KAAK,IAAI,CAAC;AAEhG,wBAAgB,KAAK,CAAC,QAAQ,SAAS,MAAM,EAAE,WAAW,EAAE,WAAW,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,eAAe,CAAC,QAAQ,CAAC,IACjG,MAAM,KAAK,UAI/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"given.js","sourceRoot":"","sources":["../../given.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,KAAK,CAA0B,WAAkC,EAAE,QAAmC;IAClH,OAAO;QACH,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;QACtC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC,CAAC;AACN,CAAC"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -10,5 +10,6 @@ import * as ObjectNavigationalBar from './ObjectNavigationalBar';
|
|
|
10
10
|
import * as PivotViewer from './PivotViewer';
|
|
11
11
|
import * as SchemaEditor from './SchemaEditor';
|
|
12
12
|
import * as TimeMachine from './TimeMachine';
|
|
13
|
-
|
|
13
|
+
import * as Toolbar from './Toolbar';
|
|
14
|
+
export { CommandDialog, CommandForm, Common, DataPage, DataTables, Dialogs, Dropdown, ObjectContentEditor, ObjectNavigationalBar, PivotViewer, SchemaEditor, TimeMachine, Toolbar, };
|
|
14
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,aAAa,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,WAAW,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,mBAAmB,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,qBAAqB,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,WAAW,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,YAAY,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,WAAW,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,aAAa,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,WAAW,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,mBAAmB,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,qBAAqB,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,WAAW,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,YAAY,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,WAAW,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,OAAO,EACH,aAAa,EACb,WAAW,EACX,MAAM,EACN,QAAQ,EACR,UAAU,EACV,OAAO,EACP,QAAQ,EACR,mBAAmB,EACnB,qBAAqB,EACrB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,OAAO,GACV,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -22,4 +22,6 @@ import * as index$a from './SchemaEditor/index.js';
|
|
|
22
22
|
export { index$a as SchemaEditor };
|
|
23
23
|
import * as index$b from './TimeMachine/index.js';
|
|
24
24
|
export { index$b as TimeMachine };
|
|
25
|
+
import * as index$c from './Toolbar/index.js';
|
|
26
|
+
export { index$c as Toolbar };
|
|
25
27
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;"}
|