@luxonis/depthai-pipeline-lib 1.4.8
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/LICENSE.md +1 -0
- package/README.md +14 -0
- package/dist/index.css +3 -0
- package/dist/panda.css +1474 -0
- package/dist/src/components/Node.d.ts +5 -0
- package/dist/src/components/Node.js +42 -0
- package/dist/src/components/PipelineCanvas.d.ts +7 -0
- package/dist/src/components/PipelineCanvas.js +56 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +2 -0
- package/dist/src/services/pipeline.d.ts +51 -0
- package/dist/src/services/pipeline.js +40 -0
- package/dist/src/styled-system/chunks/src__components__Node.css +195 -0
- package/dist/src/styled-system/chunks/src__components__PipelineCanvas.css +25 -0
- package/dist/src/styled-system/css/conditions.mjs +34 -0
- package/dist/src/styled-system/css/css.d.mts +9 -0
- package/dist/src/styled-system/css/css.mjs +44 -0
- package/dist/src/styled-system/css/cva.d.mts +6 -0
- package/dist/src/styled-system/css/cva.mjs +63 -0
- package/dist/src/styled-system/css/cx.d.mts +5 -0
- package/dist/src/styled-system/css/cx.mjs +15 -0
- package/dist/src/styled-system/css/index.d.mts +5 -0
- package/dist/src/styled-system/css/index.mjs +4 -0
- package/dist/src/styled-system/css/sva.d.mts +4 -0
- package/dist/src/styled-system/css/sva.mjs +35 -0
- package/dist/src/styled-system/global.css +70 -0
- package/dist/src/styled-system/helpers.mjs +282 -0
- package/dist/src/styled-system/patterns/aspect-ratio.d.mts +21 -0
- package/dist/src/styled-system/patterns/aspect-ratio.mjs +35 -0
- package/dist/src/styled-system/patterns/bleed.d.mts +22 -0
- package/dist/src/styled-system/patterns/bleed.mjs +19 -0
- package/dist/src/styled-system/patterns/box.d.mts +21 -0
- package/dist/src/styled-system/patterns/box.mjs +12 -0
- package/dist/src/styled-system/patterns/center.d.mts +21 -0
- package/dist/src/styled-system/patterns/center.mjs +18 -0
- package/dist/src/styled-system/patterns/circle.d.mts +21 -0
- package/dist/src/styled-system/patterns/circle.mjs +22 -0
- package/dist/src/styled-system/patterns/container.d.mts +21 -0
- package/dist/src/styled-system/patterns/container.mjs +18 -0
- package/dist/src/styled-system/patterns/divider.d.mts +23 -0
- package/dist/src/styled-system/patterns/divider.mjs +21 -0
- package/dist/src/styled-system/patterns/flex.d.mts +27 -0
- package/dist/src/styled-system/patterns/flex.mjs +23 -0
- package/dist/src/styled-system/patterns/float.d.mts +24 -0
- package/dist/src/styled-system/patterns/float.mjs +45 -0
- package/dist/src/styled-system/patterns/grid-item.d.mts +26 -0
- package/dist/src/styled-system/patterns/grid-item.mjs +22 -0
- package/dist/src/styled-system/patterns/grid.d.mts +25 -0
- package/dist/src/styled-system/patterns/grid.mjs +20 -0
- package/dist/src/styled-system/patterns/hstack.d.mts +22 -0
- package/dist/src/styled-system/patterns/hstack.mjs +20 -0
- package/dist/src/styled-system/patterns/index.d.mts +21 -0
- package/dist/src/styled-system/patterns/index.mjs +20 -0
- package/dist/src/styled-system/patterns/link-box.d.mts +21 -0
- package/dist/src/styled-system/patterns/link-box.mjs +19 -0
- package/dist/src/styled-system/patterns/link-overlay.d.mts +21 -0
- package/dist/src/styled-system/patterns/link-overlay.mjs +24 -0
- package/dist/src/styled-system/patterns/spacer.d.mts +21 -0
- package/dist/src/styled-system/patterns/spacer.mjs +18 -0
- package/dist/src/styled-system/patterns/square.d.mts +21 -0
- package/dist/src/styled-system/patterns/square.mjs +21 -0
- package/dist/src/styled-system/patterns/stack.d.mts +24 -0
- package/dist/src/styled-system/patterns/stack.mjs +20 -0
- package/dist/src/styled-system/patterns/visually-hidden.d.mts +21 -0
- package/dist/src/styled-system/patterns/visually-hidden.mjs +15 -0
- package/dist/src/styled-system/patterns/vstack.d.mts +22 -0
- package/dist/src/styled-system/patterns/vstack.mjs +20 -0
- package/dist/src/styled-system/patterns/wrap.d.mts +25 -0
- package/dist/src/styled-system/patterns/wrap.mjs +22 -0
- package/dist/src/styled-system/recipes/accordion.d.mts +28 -0
- package/dist/src/styled-system/recipes/accordion.mjs +46 -0
- package/dist/src/styled-system/recipes/alert-description.d.mts +28 -0
- package/dist/src/styled-system/recipes/alert-description.mjs +19 -0
- package/dist/src/styled-system/recipes/alert-dialog.d.mts +28 -0
- package/dist/src/styled-system/recipes/alert-dialog.mjs +70 -0
- package/dist/src/styled-system/recipes/alert-title.d.mts +28 -0
- package/dist/src/styled-system/recipes/alert-title.mjs +19 -0
- package/dist/src/styled-system/recipes/alert.d.mts +28 -0
- package/dist/src/styled-system/recipes/alert.mjs +26 -0
- package/dist/src/styled-system/recipes/avatar.d.mts +28 -0
- package/dist/src/styled-system/recipes/avatar.mjs +38 -0
- package/dist/src/styled-system/recipes/badge.d.mts +28 -0
- package/dist/src/styled-system/recipes/badge.mjs +28 -0
- package/dist/src/styled-system/recipes/blockquote.d.mts +28 -0
- package/dist/src/styled-system/recipes/blockquote.mjs +19 -0
- package/dist/src/styled-system/recipes/button.d.mts +29 -0
- package/dist/src/styled-system/recipes/button.mjs +37 -0
- package/dist/src/styled-system/recipes/calendar.d.mts +28 -0
- package/dist/src/styled-system/recipes/calendar.mjs +118 -0
- package/dist/src/styled-system/recipes/card-content.d.mts +28 -0
- package/dist/src/styled-system/recipes/card-content.mjs +19 -0
- package/dist/src/styled-system/recipes/card-description.d.mts +28 -0
- package/dist/src/styled-system/recipes/card-description.mjs +19 -0
- package/dist/src/styled-system/recipes/card-footer.d.mts +28 -0
- package/dist/src/styled-system/recipes/card-footer.mjs +19 -0
- package/dist/src/styled-system/recipes/card-header.d.mts +28 -0
- package/dist/src/styled-system/recipes/card-header.mjs +19 -0
- package/dist/src/styled-system/recipes/card-title.d.mts +28 -0
- package/dist/src/styled-system/recipes/card-title.mjs +19 -0
- package/dist/src/styled-system/recipes/card.d.mts +28 -0
- package/dist/src/styled-system/recipes/card.mjs +19 -0
- package/dist/src/styled-system/recipes/checkbox.d.mts +28 -0
- package/dist/src/styled-system/recipes/checkbox.mjs +34 -0
- package/dist/src/styled-system/recipes/collapsible.d.mts +28 -0
- package/dist/src/styled-system/recipes/collapsible.mjs +38 -0
- package/dist/src/styled-system/recipes/command-dialog.d.mts +28 -0
- package/dist/src/styled-system/recipes/command-dialog.mjs +34 -0
- package/dist/src/styled-system/recipes/command.d.mts +28 -0
- package/dist/src/styled-system/recipes/command.mjs +66 -0
- package/dist/src/styled-system/recipes/context-menu.d.mts +28 -0
- package/dist/src/styled-system/recipes/context-menu.mjs +98 -0
- package/dist/src/styled-system/recipes/create-recipe.d.mts +1 -0
- package/dist/src/styled-system/recipes/create-recipe.mjs +50 -0
- package/dist/src/styled-system/recipes/dialog.d.mts +28 -0
- package/dist/src/styled-system/recipes/dialog.mjs +66 -0
- package/dist/src/styled-system/recipes/dropdown-menu.d.mts +28 -0
- package/dist/src/styled-system/recipes/dropdown-menu.mjs +90 -0
- package/dist/src/styled-system/recipes/form-control.d.mts +28 -0
- package/dist/src/styled-system/recipes/form-control.mjs +19 -0
- package/dist/src/styled-system/recipes/form-description.d.mts +28 -0
- package/dist/src/styled-system/recipes/form-description.mjs +19 -0
- package/dist/src/styled-system/recipes/form-item.d.mts +28 -0
- package/dist/src/styled-system/recipes/form-item.mjs +19 -0
- package/dist/src/styled-system/recipes/form-label.d.mts +28 -0
- package/dist/src/styled-system/recipes/form-label.mjs +19 -0
- package/dist/src/styled-system/recipes/form-message.d.mts +28 -0
- package/dist/src/styled-system/recipes/form-message.mjs +19 -0
- package/dist/src/styled-system/recipes/h1.d.mts +28 -0
- package/dist/src/styled-system/recipes/h1.mjs +19 -0
- package/dist/src/styled-system/recipes/h2.d.mts +28 -0
- package/dist/src/styled-system/recipes/h2.mjs +19 -0
- package/dist/src/styled-system/recipes/h3.d.mts +28 -0
- package/dist/src/styled-system/recipes/h3.mjs +19 -0
- package/dist/src/styled-system/recipes/h4.d.mts +28 -0
- package/dist/src/styled-system/recipes/h4.mjs +19 -0
- package/dist/src/styled-system/recipes/hover-card.d.mts +28 -0
- package/dist/src/styled-system/recipes/hover-card.mjs +38 -0
- package/dist/src/styled-system/recipes/icon.d.mts +32 -0
- package/dist/src/styled-system/recipes/icon.mjs +49 -0
- package/dist/src/styled-system/recipes/index.d.mts +74 -0
- package/dist/src/styled-system/recipes/index.mjs +73 -0
- package/dist/src/styled-system/recipes/inline-code.d.mts +28 -0
- package/dist/src/styled-system/recipes/inline-code.mjs +19 -0
- package/dist/src/styled-system/recipes/input.d.mts +28 -0
- package/dist/src/styled-system/recipes/input.mjs +19 -0
- package/dist/src/styled-system/recipes/label.d.mts +28 -0
- package/dist/src/styled-system/recipes/label.mjs +19 -0
- package/dist/src/styled-system/recipes/large.d.mts +28 -0
- package/dist/src/styled-system/recipes/large.mjs +19 -0
- package/dist/src/styled-system/recipes/lead.d.mts +28 -0
- package/dist/src/styled-system/recipes/lead.mjs +19 -0
- package/dist/src/styled-system/recipes/link.d.mts +28 -0
- package/dist/src/styled-system/recipes/link.mjs +19 -0
- package/dist/src/styled-system/recipes/list.d.mts +28 -0
- package/dist/src/styled-system/recipes/list.mjs +19 -0
- package/dist/src/styled-system/recipes/menubar.d.mts +28 -0
- package/dist/src/styled-system/recipes/menubar.mjs +94 -0
- package/dist/src/styled-system/recipes/muted.d.mts +28 -0
- package/dist/src/styled-system/recipes/muted.mjs +19 -0
- package/dist/src/styled-system/recipes/navigation-menu.d.mts +28 -0
- package/dist/src/styled-system/recipes/navigation-menu.mjs +62 -0
- package/dist/src/styled-system/recipes/p.d.mts +28 -0
- package/dist/src/styled-system/recipes/p.mjs +19 -0
- package/dist/src/styled-system/recipes/popover.d.mts +28 -0
- package/dist/src/styled-system/recipes/popover.mjs +42 -0
- package/dist/src/styled-system/recipes/progress.d.mts +28 -0
- package/dist/src/styled-system/recipes/progress.mjs +34 -0
- package/dist/src/styled-system/recipes/radio-group.d.mts +28 -0
- package/dist/src/styled-system/recipes/radio-group.mjs +42 -0
- package/dist/src/styled-system/recipes/scroll-area.d.mts +28 -0
- package/dist/src/styled-system/recipes/scroll-area.mjs +46 -0
- package/dist/src/styled-system/recipes/select.d.mts +28 -0
- package/dist/src/styled-system/recipes/select.mjs +66 -0
- package/dist/src/styled-system/recipes/separator.d.mts +28 -0
- package/dist/src/styled-system/recipes/separator.mjs +26 -0
- package/dist/src/styled-system/recipes/sheet.d.mts +28 -0
- package/dist/src/styled-system/recipes/sheet.mjs +81 -0
- package/dist/src/styled-system/recipes/skeleton.d.mts +28 -0
- package/dist/src/styled-system/recipes/skeleton.mjs +19 -0
- package/dist/src/styled-system/recipes/slider.d.mts +28 -0
- package/dist/src/styled-system/recipes/slider.mjs +42 -0
- package/dist/src/styled-system/recipes/small.d.mts +28 -0
- package/dist/src/styled-system/recipes/small.mjs +19 -0
- package/dist/src/styled-system/recipes/switch-recipe.d.mts +28 -0
- package/dist/src/styled-system/recipes/switch-recipe.mjs +34 -0
- package/dist/src/styled-system/recipes/table-body.d.mts +28 -0
- package/dist/src/styled-system/recipes/table-body.mjs +19 -0
- package/dist/src/styled-system/recipes/table-caption.d.mts +28 -0
- package/dist/src/styled-system/recipes/table-caption.mjs +19 -0
- package/dist/src/styled-system/recipes/table-cell.d.mts +28 -0
- package/dist/src/styled-system/recipes/table-cell.mjs +19 -0
- package/dist/src/styled-system/recipes/table-container.d.mts +28 -0
- package/dist/src/styled-system/recipes/table-container.mjs +19 -0
- package/dist/src/styled-system/recipes/table-footer.d.mts +28 -0
- package/dist/src/styled-system/recipes/table-footer.mjs +19 -0
- package/dist/src/styled-system/recipes/table-head.d.mts +28 -0
- package/dist/src/styled-system/recipes/table-head.mjs +19 -0
- package/dist/src/styled-system/recipes/table-header.d.mts +28 -0
- package/dist/src/styled-system/recipes/table-header.mjs +19 -0
- package/dist/src/styled-system/recipes/table-row.d.mts +28 -0
- package/dist/src/styled-system/recipes/table-row.mjs +19 -0
- package/dist/src/styled-system/recipes/table.d.mts +28 -0
- package/dist/src/styled-system/recipes/table.mjs +19 -0
- package/dist/src/styled-system/recipes/tabs.d.mts +28 -0
- package/dist/src/styled-system/recipes/tabs.mjs +42 -0
- package/dist/src/styled-system/recipes/textarea.d.mts +28 -0
- package/dist/src/styled-system/recipes/textarea.mjs +19 -0
- package/dist/src/styled-system/recipes/toast-viewport.d.mts +28 -0
- package/dist/src/styled-system/recipes/toast-viewport.mjs +19 -0
- package/dist/src/styled-system/recipes/toast.d.mts +28 -0
- package/dist/src/styled-system/recipes/toast.mjs +59 -0
- package/dist/src/styled-system/recipes/toggle.d.mts +29 -0
- package/dist/src/styled-system/recipes/toggle.mjs +32 -0
- package/dist/src/styled-system/recipes/tooltip.d.mts +28 -0
- package/dist/src/styled-system/recipes/tooltip.mjs +38 -0
- package/dist/src/styled-system/recipes/typography-table-container.d.mts +28 -0
- package/dist/src/styled-system/recipes/typography-table-container.mjs +19 -0
- package/dist/src/styled-system/recipes/typography-table.d.mts +28 -0
- package/dist/src/styled-system/recipes/typography-table.mjs +19 -0
- package/dist/src/styled-system/reset.css +206 -0
- package/dist/src/styled-system/static.css +320 -0
- package/dist/src/styled-system/tokens/index.css +620 -0
- package/dist/src/styled-system/tokens/index.d.mts +9 -0
- package/dist/src/styled-system/tokens/index.mjs +2680 -0
- package/dist/src/styled-system/tokens/keyframes.css +56 -0
- package/dist/src/styled-system/tokens/tokens.d.mts +63 -0
- package/dist/src/styled-system/types/composition.d.mts +111 -0
- package/dist/src/styled-system/types/conditions.d.mts +266 -0
- package/dist/src/styled-system/types/csstype.d.mts +20749 -0
- package/dist/src/styled-system/types/global.d.mts +19 -0
- package/dist/src/styled-system/types/helpers.d.mts +2 -0
- package/dist/src/styled-system/types/index.d.mts +8 -0
- package/dist/src/styled-system/types/parts.d.mts +6 -0
- package/dist/src/styled-system/types/pattern.d.mts +61 -0
- package/dist/src/styled-system/types/prop-type.d.mts +340 -0
- package/dist/src/styled-system/types/recipe.d.mts +148 -0
- package/dist/src/styled-system/types/selectors.d.mts +59 -0
- package/dist/src/styled-system/types/style-props.d.mts +687 -0
- package/dist/src/styled-system/types/system-types.d.mts +85 -0
- package/package.json +63 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Handle, Position } from '@xyflow/react';
|
|
3
|
+
import { clsx } from '@luxonis/common-fe-components/helpers';
|
|
4
|
+
import { Button, Flex, HelpIcon, Label, SubLabel } from '@luxonis/common-fe-components';
|
|
5
|
+
import { css } from '../styled-system/css/css.mjs';
|
|
6
|
+
const DOCS_BASE_URL = `https://docs.luxonis.com/software/depthai-components/nodes/`;
|
|
7
|
+
const NodeHandles = props => {
|
|
8
|
+
const { handles, type } = props;
|
|
9
|
+
return (_jsx(Flex, { full: true, direction: "column", align: type === 'input' ? 'start' : 'end', children: handles.map(({ type: handleType, id, blocking, queueSize, name }) => (_jsxs(Flex, { position: "relative", align: "end", direction: handleType === 'input' ? 'row' : 'row-reverse', children: [_jsx(Handle, { type: handleType === 'input' ? 'target' : 'source', position: handleType === 'input' ? Position.Left : Position.Right, id: name, isConnectable: false, className: css({
|
|
10
|
+
width: 'custom.handle.dot!',
|
|
11
|
+
height: 'custom.handle.dot!',
|
|
12
|
+
backgroundColor: blocking ? 'dark.warning!' : 'dark.success!',
|
|
13
|
+
border: 'none!',
|
|
14
|
+
}) }), _jsx(SubLabel, { className: css({
|
|
15
|
+
...(type === 'input' //
|
|
16
|
+
? { 'marginLeft': 'xs' }
|
|
17
|
+
: { 'marginRight': 'xs' }),
|
|
18
|
+
}), text: type === 'input' ? `[${queueSize}] ${name}` : name, break: "none" })] }, id))) }));
|
|
19
|
+
};
|
|
20
|
+
export const PipelineNode = props => {
|
|
21
|
+
const { data: node } = props;
|
|
22
|
+
return (_jsxs(Flex, { direction: "column", className: css({
|
|
23
|
+
'minWidth': 'container.smaller.xxs',
|
|
24
|
+
'border': 'base',
|
|
25
|
+
'rounded': 'common',
|
|
26
|
+
'backgroundColor': 'white',
|
|
27
|
+
'&:hover .node-help-icon': {
|
|
28
|
+
color: 'text.normal',
|
|
29
|
+
},
|
|
30
|
+
}), children: [_jsxs(Flex, { align: "center", justify: "space-between", gap: "xs", className: css({
|
|
31
|
+
width: 'full',
|
|
32
|
+
backgroundColor: 'light.gray',
|
|
33
|
+
roundedTop: 'common',
|
|
34
|
+
}), children: [_jsx("span", { className: css({
|
|
35
|
+
width: 'icon.sm',
|
|
36
|
+
height: 'icon.sm',
|
|
37
|
+
}) }), _jsx(Label, { text: node.name, color: "unset" }), _jsx(Button, { variant: "ghost", color: "transparent", icon: HelpIcon, onClick: () => window.open(DOCS_BASE_URL, '_blank'), className: clsx('node-help-icon', css({
|
|
38
|
+
width: 'auto',
|
|
39
|
+
height: 'auto',
|
|
40
|
+
right: 'xs',
|
|
41
|
+
})) })] }), _jsxs(Flex, { gap: "sm", paddingY: "xs", children: [_jsx(NodeHandles, { type: "input", handles: node.handles.input }), _jsx(NodeHandles, { type: "output", handles: node.handles.output })] })] }));
|
|
42
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { FlexProps } from '@luxonis/common-fe-components';
|
|
3
|
+
import type { Pipeline } from '../services/pipeline.js';
|
|
4
|
+
export type PipelineCanvasProps = FlexProps & {
|
|
5
|
+
pipeline: Pipeline | null;
|
|
6
|
+
};
|
|
7
|
+
export declare const PipelineCanvas: React.FC<PipelineCanvasProps>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ReactFlow, ReactFlowProvider, useEdgesState, useNodesState, useReactFlow, } from '@xyflow/react';
|
|
4
|
+
import { Flex, Header } from '@luxonis/common-fe-components';
|
|
5
|
+
import Dagre from '@dagrejs/dagre';
|
|
6
|
+
import { PipelineNode } from './Node.js';
|
|
7
|
+
const getLayoutedElements = (nodes, edges) => {
|
|
8
|
+
const graph = new Dagre.graphlib.Graph().setDefaultEdgeLabel(() => ({}));
|
|
9
|
+
graph.setGraph({ rankdir: 'LR' });
|
|
10
|
+
for (const edge of edges) {
|
|
11
|
+
graph.setEdge(edge.source, edge.target);
|
|
12
|
+
}
|
|
13
|
+
for (const node of nodes) {
|
|
14
|
+
graph.setNode(node.id, {
|
|
15
|
+
...node,
|
|
16
|
+
width: node.measured?.width ?? 200,
|
|
17
|
+
height: node.measured?.height ?? 100,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
Dagre.layout(graph);
|
|
21
|
+
return {
|
|
22
|
+
nodes: nodes.map((node) => {
|
|
23
|
+
const position = graph.node(node.id);
|
|
24
|
+
// Shift Dagre anchor (center) to React Flow anchor (top left)
|
|
25
|
+
const x = position.x - (node.measured?.width ?? 200) / 2;
|
|
26
|
+
const y = position.y - (node.measured?.height ?? 100) / 2;
|
|
27
|
+
return { ...node, position: { x, y } };
|
|
28
|
+
}),
|
|
29
|
+
edges,
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
const PipelineCanvasBody = ({ pipeline, ...flexProps }) => {
|
|
33
|
+
const { fitView, setViewport, getViewport } = useReactFlow();
|
|
34
|
+
const autoArrangeRef = React.useRef(true);
|
|
35
|
+
const [nodes, setNodes, onNodesChange] = useNodesState([]);
|
|
36
|
+
const [edges, setEdges] = useEdgesState([]);
|
|
37
|
+
React.useEffect(() => {
|
|
38
|
+
if (!autoArrangeRef.current) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const layouted = getLayoutedElements(pipeline?.nodes ?? [], pipeline?.edges ?? []);
|
|
42
|
+
setNodes([...layouted.nodes]);
|
|
43
|
+
setEdges([...layouted.edges]);
|
|
44
|
+
window.requestAnimationFrame(async () => {
|
|
45
|
+
await fitView({ minZoom: 1 });
|
|
46
|
+
const viewport = getViewport();
|
|
47
|
+
await setViewport({
|
|
48
|
+
x: 50,
|
|
49
|
+
y: viewport.y,
|
|
50
|
+
zoom: 1,
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}, [fitView, getViewport, pipeline?.edges, pipeline?.nodes, setEdges, setNodes, setViewport]);
|
|
54
|
+
return (_jsxs(Flex, { align: "center", justify: "center", full: true, height: "container.xs", rounded: "common", border: "base", ...flexProps, children: [!pipeline && _jsx(Header, { text: "Loading pipeline..." }), pipeline && (_jsx(ReactFlow, { nodes: nodes, edges: edges, onNodeDragStart: () => (autoArrangeRef.current = false), onNodesChange: onNodesChange, fitView: true, nodeTypes: { generic: PipelineNode } }))] }));
|
|
55
|
+
};
|
|
56
|
+
export const PipelineCanvas = props => (_jsx(ReactFlowProvider, { children: _jsx(PipelineCanvasBody, { ...props }) }));
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { parsePipeline } from './services/pipeline.js';
|
|
2
|
+
export type { Pipeline, RawPipelinePayload } from './services/pipeline.js';
|
|
3
|
+
export { PipelineCanvas } from './components/PipelineCanvas.js';
|
|
4
|
+
export type { PipelineCanvasProps } from './components/PipelineCanvas.js';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Edge, Node } from '@xyflow/react';
|
|
2
|
+
export type RawPipelineNodeIO = [
|
|
3
|
+
[
|
|
4
|
+
string,
|
|
5
|
+
string
|
|
6
|
+
],
|
|
7
|
+
{
|
|
8
|
+
id: number;
|
|
9
|
+
name: string;
|
|
10
|
+
type: 0 | 3;
|
|
11
|
+
blocking: boolean;
|
|
12
|
+
queueSize: number;
|
|
13
|
+
}
|
|
14
|
+
];
|
|
15
|
+
export type RawPipelineNode = {
|
|
16
|
+
id: number;
|
|
17
|
+
ioInfo: RawPipelineNodeIO[];
|
|
18
|
+
name: string;
|
|
19
|
+
};
|
|
20
|
+
export type RawPipelineEdge = {
|
|
21
|
+
node1Id: number;
|
|
22
|
+
node1Output: string;
|
|
23
|
+
node2Id: number;
|
|
24
|
+
node2Input: string;
|
|
25
|
+
};
|
|
26
|
+
export type RawPipelinePayload = {
|
|
27
|
+
pipeline: RawPipeline;
|
|
28
|
+
};
|
|
29
|
+
export type RawPipeline = {
|
|
30
|
+
connections: RawPipelineEdge[];
|
|
31
|
+
nodes: [number, RawPipelineNode][];
|
|
32
|
+
};
|
|
33
|
+
export type Pipeline = {
|
|
34
|
+
nodes: ParsedNode[];
|
|
35
|
+
edges: Edge[];
|
|
36
|
+
};
|
|
37
|
+
export type ParsedHandle = {
|
|
38
|
+
id: number;
|
|
39
|
+
name: string;
|
|
40
|
+
type: 'input' | 'output';
|
|
41
|
+
blocking: boolean;
|
|
42
|
+
queueSize: number;
|
|
43
|
+
};
|
|
44
|
+
export type ParsedNode = Node<{
|
|
45
|
+
name: string;
|
|
46
|
+
handles: {
|
|
47
|
+
input: ParsedHandle[];
|
|
48
|
+
output: ParsedHandle[];
|
|
49
|
+
};
|
|
50
|
+
}>;
|
|
51
|
+
export declare function parsePipeline(rawPayload: RawPipelinePayload): Pipeline;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
function parseHandles(handles) {
|
|
2
|
+
const parsedHandles = {
|
|
3
|
+
input: [],
|
|
4
|
+
output: [],
|
|
5
|
+
};
|
|
6
|
+
for (const [_, handle] of handles) {
|
|
7
|
+
const type = handle.type === 3 ? 'input' : 'output';
|
|
8
|
+
const parsed = {
|
|
9
|
+
id: handle.id,
|
|
10
|
+
name: handle.name,
|
|
11
|
+
type,
|
|
12
|
+
blocking: handle.blocking,
|
|
13
|
+
queueSize: handle.queueSize,
|
|
14
|
+
};
|
|
15
|
+
parsedHandles[type].push(parsed);
|
|
16
|
+
}
|
|
17
|
+
return parsedHandles;
|
|
18
|
+
}
|
|
19
|
+
export function parsePipeline(rawPayload) {
|
|
20
|
+
const { pipeline } = rawPayload;
|
|
21
|
+
const nodes = pipeline.nodes
|
|
22
|
+
.filter(([_, node]) => pipeline.connections.some(connection => connection.node1Id === node.id || connection.node2Id === node.id))
|
|
23
|
+
.map(([id, node]) => ({
|
|
24
|
+
type: 'generic',
|
|
25
|
+
id: id.toString(),
|
|
26
|
+
position: { x: 0, y: 0 },
|
|
27
|
+
data: {
|
|
28
|
+
name: node.name,
|
|
29
|
+
handles: parseHandles(node.ioInfo),
|
|
30
|
+
},
|
|
31
|
+
})) ?? [];
|
|
32
|
+
const edges = pipeline.connections.map(connection => ({
|
|
33
|
+
id: `${connection.node1Id}-${connection.node2Id}`,
|
|
34
|
+
source: connection.node1Id.toString(),
|
|
35
|
+
target: connection.node2Id.toString(),
|
|
36
|
+
sourceHandle: connection.node1Output,
|
|
37
|
+
targetHandle: connection.node2Input,
|
|
38
|
+
})) ?? [];
|
|
39
|
+
return { nodes, edges };
|
|
40
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
@layer utilities {
|
|
2
|
+
.bg_dark\.warning\! {
|
|
3
|
+
background-color: var(--colors-dark-warning) !important
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.bg_dark\.success\! {
|
|
7
|
+
background-color: var(--colors-dark-success) !important
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.w_custom\.handle\.dot\! {
|
|
11
|
+
width: var(--sizes-custom-handle-dot) !important
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.h_custom\.handle\.dot\! {
|
|
15
|
+
height: var(--sizes-custom-handle-dot) !important
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.border_none\! {
|
|
19
|
+
border: var(--borders-none) !important
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.ml_xs {
|
|
23
|
+
margin-left: var(--spacing-xs)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.mr_xs {
|
|
27
|
+
margin-right: var(--spacing-xs)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.min-w_container\.smaller\.xxs {
|
|
31
|
+
min-width: var(--sizes-container-smaller-xxs)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.border_base {
|
|
35
|
+
border: var(--borders-base)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.rounded_common {
|
|
39
|
+
border-radius: var(--radii-common)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.bg_white {
|
|
43
|
+
background-color: var(--colors-white)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.w_full {
|
|
47
|
+
width: var(--sizes-full)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.bg_light\.gray {
|
|
51
|
+
background-color: var(--colors-light-gray)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.rounded-t_common {
|
|
55
|
+
border-top-left-radius: var(--radii-common);
|
|
56
|
+
border-top-right-radius: var(--radii-common)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.w_icon\.sm {
|
|
60
|
+
width: var(--sizes-icon-sm)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.h_icon\.sm {
|
|
64
|
+
height: var(--sizes-icon-sm)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.w_auto {
|
|
68
|
+
width: auto
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.h_auto {
|
|
72
|
+
height: auto
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.right_xs {
|
|
76
|
+
right: var(--spacing-xs)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.text_unset {
|
|
80
|
+
color: unset
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.text_transparent {
|
|
84
|
+
color: var(--colors-transparent)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.items_start {
|
|
88
|
+
align-items: start
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.flex_row {
|
|
92
|
+
flex-direction: row
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.flex_row-reverse {
|
|
96
|
+
flex-direction: row-reverse
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.items_end {
|
|
100
|
+
align-items: end
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.pos_relative {
|
|
104
|
+
position: relative
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.flex_column {
|
|
108
|
+
flex-direction: column
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.items_center {
|
|
112
|
+
align-items: center
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.justify_space-between {
|
|
116
|
+
justify-content: space-between
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.gap_xs {
|
|
120
|
+
gap: var(--spacing-xs)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.d_flex {
|
|
124
|
+
display: flex
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.gap_sm {
|
|
128
|
+
gap: var(--spacing-sm)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.py_xs {
|
|
132
|
+
padding-block: var(--spacing-xs)
|
|
133
|
+
}
|
|
134
|
+
.\[\&\:hover_\.node-help-icon\]\:text_text\.normal:hover .node-help-icon {
|
|
135
|
+
color: var(--colors-text-normal)
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
@layer recipes {
|
|
140
|
+
.button--variant_ghost:is(:hover, [data-hover]) {
|
|
141
|
+
background: var(--colors-accent);
|
|
142
|
+
color: var(--colors-accent-foreground)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.button--size_default {
|
|
146
|
+
height: var(--sizes-10);
|
|
147
|
+
padding-inline: var(--spacing-4);
|
|
148
|
+
padding-block: var(--spacing-2)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
@layer _base {
|
|
152
|
+
.label {
|
|
153
|
+
font-size: 0.875rem;
|
|
154
|
+
line-height: var(--line-heights-none);
|
|
155
|
+
font-weight: var(--font-weights-medium);
|
|
156
|
+
}
|
|
157
|
+
.peer:is(:disabled, [disabled], [data-disabled]) ~ .label {
|
|
158
|
+
cursor: not-allowed;
|
|
159
|
+
opacity: 0.7
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
@layer _base {
|
|
164
|
+
.button {
|
|
165
|
+
display: inline-flex;
|
|
166
|
+
align-items: center;
|
|
167
|
+
justify-content: center;
|
|
168
|
+
border-radius: var(--radii-md);
|
|
169
|
+
font-size: 0.875rem;
|
|
170
|
+
line-height: 1.25rem;
|
|
171
|
+
font-weight: var(--font-weights-medium);
|
|
172
|
+
transition-property: var(--transition-prop, color, background-color, border-color, outline-color, text-decoration-color, fill, stroke);
|
|
173
|
+
transition-timing-function: var(--transition-easing, cubic-bezier(0.4, 0, 0.2, 1));
|
|
174
|
+
transition-duration: var(--transition-duration, 150ms);
|
|
175
|
+
cursor: pointer;
|
|
176
|
+
--shadow-panda-ring-offset-color: var(--colors-background);
|
|
177
|
+
gap: var(--spacing-2);
|
|
178
|
+
}
|
|
179
|
+
.button:is(:disabled, [disabled], [data-disabled]) {
|
|
180
|
+
pointer-events: none;
|
|
181
|
+
opacity: 50%
|
|
182
|
+
}
|
|
183
|
+
.button:is(:focus-visible, [data-focus-visible]) {
|
|
184
|
+
outline: 2px solid transparent;
|
|
185
|
+
outline-offset: 2px;
|
|
186
|
+
--shadow-panda-ring-offset-shadow: var(--shadow-panda-ring-inset,) 0 0 0 var(--shadow-panda-ring-offset-width, 0px) var(--shadow-panda-ring-offset-color);
|
|
187
|
+
--shadow-panda-ring-shadow: var(--shadow-panda-ring-inset,) 0 0 0 calc(2px + var(--shadow-panda-ring-offset-width, 0px)) var(--shadow-panda-ring-color);
|
|
188
|
+
box-shadow: var(--shadow-panda-ring-offset-shadow),var(--shadow-panda-ring-shadow),var(--shadow-panda-base-shadow,0 0 #0000);
|
|
189
|
+
--shadow-panda-ring-color: var(--colors-ring)
|
|
190
|
+
;
|
|
191
|
+
--shadow-panda-ring-offset-width: 2px
|
|
192
|
+
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
@layer utilities {
|
|
2
|
+
.d_flex {
|
|
3
|
+
display: flex
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.items_center {
|
|
7
|
+
align-items: center
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.justify_center {
|
|
11
|
+
justify-content: center
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.h_container\.xs {
|
|
15
|
+
height: var(--sizes-container-xs)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.rounded_common {
|
|
19
|
+
border-radius: var(--radii-common)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.border_base {
|
|
23
|
+
border: var(--borders-base)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { withoutSpace } from '../helpers.mjs';
|
|
2
|
+
|
|
3
|
+
const conditionsStr = "_hover,_focus,_focusWithin,_focusVisible,_disabled,_active,_visited,_target,_readOnly,_readWrite,_empty,_checked,_enabled,_expanded,_highlighted,_before,_after,_firstLetter,_firstLine,_marker,_selection,_file,_backdrop,_first,_last,_only,_even,_odd,_firstOfType,_lastOfType,_onlyOfType,_peerFocus,_peerHover,_peerActive,_peerFocusWithin,_peerFocusVisible,_peerDisabled,_peerChecked,_peerInvalid,_peerExpanded,_peerPlaceholderShown,_groupFocus,_groupHover,_groupActive,_groupFocusWithin,_groupFocusVisible,_groupDisabled,_groupChecked,_groupExpanded,_groupInvalid,_indeterminate,_required,_valid,_invalid,_autofill,_inRange,_outOfRange,_placeholder,_placeholderShown,_pressed,_selected,_default,_optional,_open,_fullscreen,_loading,_currentPage,_currentStep,_motionReduce,_motionSafe,_print,_landscape,_portrait,_dark,_light,_osDark,_osLight,_highContrast,_lessContrast,_moreContrast,_ltr,_rtl,_scrollbar,_scrollbarThumb,_scrollbarTrack,_horizontal,_vertical,sm,smOnly,smDown,md,mdOnly,mdDown,lg,lgOnly,lgDown,2lg,2lgOnly,2lgDown,xl,xlOnly,xlDown,2xl,2xlOnly,2xlDown,smToMd,smToLg,smTo2lg,smToXl,smTo2xl,mdToLg,mdTo2lg,mdToXl,mdTo2xl,lgTo2lg,lgToXl,lgTo2xl,2lgToXl,2lgTo2xl,xlTo2xl,base"
|
|
4
|
+
const conditions = new Set(conditionsStr.split(','))
|
|
5
|
+
|
|
6
|
+
export function isCondition(value){
|
|
7
|
+
return conditions.has(value) || /^@|&|&$/.test(value)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const underscoreRegex = /^_/
|
|
11
|
+
const conditionsSelectorRegex = /&|@/
|
|
12
|
+
|
|
13
|
+
export function finalizeConditions(paths){
|
|
14
|
+
return paths.map((path) => {
|
|
15
|
+
if (conditions.has(path)){
|
|
16
|
+
return path.replace(underscoreRegex, '')
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (conditionsSelectorRegex.test(path)){
|
|
20
|
+
return `[${withoutSpace(path.trim())}]`
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return path
|
|
24
|
+
})}
|
|
25
|
+
|
|
26
|
+
export function sortConditions(paths){
|
|
27
|
+
return paths.sort((a, b) => {
|
|
28
|
+
const aa = isCondition(a)
|
|
29
|
+
const bb = isCondition(b)
|
|
30
|
+
if (aa && !bb) return 1
|
|
31
|
+
if (!aa && bb) return -1
|
|
32
|
+
return 0
|
|
33
|
+
})
|
|
34
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import type { SystemStyleObject } from '../types/index.d.mts';
|
|
3
|
+
|
|
4
|
+
interface CssFunction {
|
|
5
|
+
(...styles: Array<SystemStyleObject | undefined | null | false>): string
|
|
6
|
+
raw: (...styles: Array<SystemStyleObject | undefined | null | false>) => SystemStyleObject
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export declare const css: CssFunction;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { createCss, createMergeCss, hypenateProperty, withoutSpace } from '../helpers.mjs';
|
|
2
|
+
import { sortConditions, finalizeConditions } from './conditions.mjs';
|
|
3
|
+
|
|
4
|
+
const utilities = "aspectRatio:aspect,boxDecorationBreak:decoration,zIndex:z,boxSizing:box,objectPosition:object,objectFit:object,overscrollBehavior:overscroll,overscrollBehaviorX:overscroll-x,overscrollBehaviorY:overscroll-y,position:pos/1,top:top,left:left,insetInline:inset-x,insetBlock:inset-y,inset:inset,insetBlockEnd:inset-b,insetBlockStart:inset-t,insetInlineEnd:end/insetEnd/1,insetInlineStart:start/insetStart/1,right:right,bottom:bottom,insetX:inset-x,insetY:inset-y,float:float,visibility:vis,display:d,hideFrom:hide,hideBelow:show,flexBasis:basis,flex:flex,flexDirection:flex/flexDir,flexGrow:grow,flexShrink:shrink,gridTemplateColumns:grid-cols,gridTemplateRows:grid-rows,gridColumn:col-span,gridRow:row-span,gridColumnStart:col-start,gridColumnEnd:col-end,gridAutoFlow:grid-flow,gridAutoColumns:auto-cols,gridAutoRows:auto-rows,gap:gap,gridGap:gap,gridRowGap:gap-x,gridColumnGap:gap-y,rowGap:gap-x,columnGap:gap-y,justifyContent:justify,alignContent:content,alignItems:items,alignSelf:self,padding:p/1,paddingLeft:pl/1,paddingRight:pr/1,paddingTop:pt/1,paddingBottom:pb/1,paddingBlock:py/1/paddingY,paddingBlockEnd:pb,paddingBlockStart:pt,paddingInline:px/paddingX/1,paddingInlineEnd:pe/1/paddingEnd,paddingInlineStart:ps/1/paddingStart,marginLeft:ml/1,marginRight:mr/1,marginTop:mt/1,marginBottom:mb/1,margin:m/1,marginBlock:my/1/marginY,marginBlockEnd:mb,marginBlockStart:mt,marginInline:mx/1/marginX,marginInlineEnd:me/1/marginEnd,marginInlineStart:ms/1/marginStart,outlineWidth:ring/ringWidth,outlineColor:ring/ringColor,outline:ring/1,outlineOffset:ring/ringOffset,divideX:divide-x,divideY:divide-y,divideColor:divide,divideStyle:divide,width:w/1,inlineSize:w,minWidth:min-w/minW,minInlineSize:min-w,maxWidth:max-w/maxW,maxInlineSize:max-w,height:h/1,blockSize:h,minHeight:min-h/minH,minBlockSize:min-h,maxHeight:max-h/maxH,maxBlockSize:max-b,color:text,fontFamily:font,fontSize:fs,fontWeight:font,fontSmoothing:smoothing,fontVariantNumeric:numeric,letterSpacing:tracking/1,lineHeight:leading/1,textAlign:text,textDecoration:text-decor,textDecorationColor:text-decor,textEmphasisColor:text-emphasis,textDecorationStyle:decoration,textDecorationThickness:decoration,textUnderlineOffset:underline-offset,textTransform:text,textIndent:indent,textShadow:text-shadow,textOverflow:text,verticalAlign:align,wordBreak:break,textWrap:text,truncate:truncate,lineClamp:clamp,listStyleType:list,listStylePosition:list,listStyleImage:list-img,backgroundPosition:bg/bgPosition,backgroundPositionX:bg-x/bgPositionX,backgroundPositionY:bg-y/bgPositionY,backgroundAttachment:bg/bgAttachment,backgroundClip:bg-clip/bgClip,background:bg/1,backgroundColor:bg/bgColor,backgroundOrigin:bg-origin/bgOrigin,backgroundImage:bg-img/bgImage,backgroundRepeat:bg-repeat/bgRepeat,backgroundBlendMode:bg-blend/bgBlendMode,backgroundSize:bg/bgSize,backgroundGradient:bg-gradient/bgGradient,textGradient:text-gradient,gradientFrom:from,gradientTo:to,gradientVia:via,borderRadius:rounded/1,borderTopLeftRadius:rounded-tl/roundedTopLeft,borderTopRightRadius:rounded-tr/roundedTopRight,borderBottomRightRadius:rounded-br/roundedBottomRight,borderBottomLeftRadius:rounded-bl/roundedBottomLeft,borderTopRadius:rounded-t/roundedTop,borderRightRadius:rounded-r/roundedRight,borderBottomRadius:rounded-b/roundedBottom,borderLeftRadius:rounded-l/roundedLeft,borderStartStartRadius:rounded-ss/roundedStartStart,borderStartEndRadius:rounded-se/roundedStartEnd,borderStartRadius:rounded-s/roundedStart,borderEndStartRadius:rounded-es/roundedEndStart,borderEndEndRadius:rounded-ee/roundedEndEnd,borderEndRadius:rounded-e/roundedEnd,border:border,borderColor:border,borderInline:border-x/borderX,borderInlineWidth:border-x/borderXWidth,borderInlineColor:border-x/borderXColor,borderBlock:border-y/borderY,borderBlockWidth:border-y/borderYWidth,borderBlockColor:border-y/borderYColor,borderLeft:border-l,borderLeftColor:border-l,borderInlineStart:border-s/borderStart,borderInlineStartWidth:border-s/borderStartWidth,borderInlineStartColor:border-s/borderStartColor,borderRight:border-r,borderRightColor:border-r,borderInlineEnd:border-e/borderEnd,borderInlineEndWidth:border-e/borderEndWidth,borderInlineEndColor:border-e/borderEndColor,borderTop:border-t,borderTopColor:border-t,borderBottom:border-b,borderBottomColor:border-b,borderBlockEnd:border-be,borderBlockEndColor:border-be,borderBlockStart:border-bs,borderBlockStartColor:border-bs,boxShadow:shadow/1,boxShadowColor:shadow/shadowColor,mixBlendMode:mix-blend,filter:filter,brightness:brightness,contrast:contrast,grayscale:grayscale,hueRotate:hue-rotate,invert:invert,saturate:saturate,sepia:sepia,dropShadow:drop-shadow,blur:blur,backdropFilter:backdrop,backdropBlur:backdrop_blur,backdropBrightness:backdrop-brightness,backdropContrast:backdrop-contrast,backdropGrayscale:backdrop-grayscale,backdropHueRotate:backdrop-hue-rotate,backdropInvert:backdrop-invert,backdropOpacity:backdrop-opacity,backdropSaturate:backdrop-saturate,backdropSepia:backdrop-sepia,borderCollapse:border,borderSpacing:border-spacing,borderSpacingX:border-spacing-x,borderSpacingY:border-spacing-y,tableLayout:table,transitionTimingFunction:ease,transitionDelay:delay,transitionDuration:duration,transitionProperty:transition-prop,transition:transition,animation:animation,animationName:animation-name,animationDelay:animation-delay,transformOrigin:origin,scale:scale,scaleX:scale-x,scaleY:scale-y,translate:translate,translateX:translate_x/x,translateY:translate_y/y,accentColor:accent,caretColor:caret,scrollBehavior:scroll,scrollbar:scrollbar,scrollMargin:scroll-m,scrollMarginX:scroll-mx,scrollMarginY:scroll-my,scrollMarginLeft:scroll-ml,scrollMarginRight:scroll-mr,scrollMarginTop:scroll-mt,scrollMarginBottom:scroll-mb,scrollMarginBlock:scroll-my,scrollMarginBlockEnd:scroll-mb,scrollMarginBlockStart:scroll-mt,scrollMarginInline:scroll-mx,scrollMarginInlineEnd:scroll-me,scrollMarginInlineStart:scroll-ms,scrollPadding:scroll-p,scrollPaddingBlock:scroll-pb,scrollPaddingBlockStart:scroll-pt,scrollPaddingBlockEnd:scroll-pb,scrollPaddingInline:scroll-px,scrollPaddingInlineEnd:scroll-pe,scrollPaddingInlineStart:scroll-ps,scrollPaddingX:scroll-px,scrollPaddingY:scroll-py,scrollPaddingLeft:scroll-pl,scrollPaddingRight:scroll-pr,scrollPaddingTop:scroll-pt,scrollPaddingBottom:scroll-pb,scrollSnapAlign:snap,scrollSnapStop:snap,scrollSnapType:snap,scrollSnapStrictness:strictness,scrollSnapMargin:snap-m,scrollSnapMarginTop:snap-mt,scrollSnapMarginBottom:snap-mb,scrollSnapMarginLeft:snap-ml,scrollSnapMarginRight:snap-mr,touchAction:touch,userSelect:select,fill:fill,stroke:stroke,srOnly:sr,debug:debug,appearance:appearance,backfaceVisibility:backface,clipPath:clip-path,hyphens:hyphens,mask:mask,maskImage:mask-image,maskSize:mask-size,textSizeAdjust:text-size-adjust,animateIn:animate_in,animateOut:animate_out,fadeIn:animate_fade_in,fadeOut:animate_fade_out,zoomIn:animate_zoom_in,zoomOut:animate_zoom_out,spinIn:animate_spin_in,spinOut:animate_spin_out,slideInFromTop:animate_slide_in_from_top,slideInFromBottom:animate_slide_in_from_bottom,slideInFromLeft:animate_slide_in_from_left,slideInFromRight:animate_slide_in_from_right,slideOutToTop:animate_slide_out_to_top,slideOutToBottom:animate_slide_out_to_bottom,slideOutToLeft:animate_slide_out_to_left,slideOutToRight:animate_slide_out_to_right,backgroundAlpha:background-alpha/bga,gradientFromAlpha:from-alpha,gradientToAlpha:to-alpha,borderAlpha:border_color_alpha/bca,container:container,focusRingWidth:focus-ring-width,focusRingColor:focus-ring-color,focusRingOffsetWidth:focus-ring-offset-width,focusRingOffsetColor:focus-ring-offset-color,focusRingInset:focus-ring-inset,spaceY:space_y,spaceX:space_x,textAlpha:text_alpha/ca,textStyle:textStyle,layerStyle:layerStyle"
|
|
5
|
+
|
|
6
|
+
const classNameByProp = new Map()
|
|
7
|
+
const shorthands = new Map()
|
|
8
|
+
utilities.split(',').forEach((utility) => {
|
|
9
|
+
const [prop, meta] = utility.split(':')
|
|
10
|
+
const [className, ...shorthandList] = meta.split('/')
|
|
11
|
+
classNameByProp.set(prop, className)
|
|
12
|
+
if (shorthandList.length) {
|
|
13
|
+
shorthandList.forEach((shorthand) => {
|
|
14
|
+
shorthands.set(shorthand === '1' ? className : shorthand, prop)
|
|
15
|
+
})
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
const resolveShorthand = (prop) => shorthands.get(prop) || prop
|
|
20
|
+
|
|
21
|
+
const context = {
|
|
22
|
+
|
|
23
|
+
conditions: {
|
|
24
|
+
shift: sortConditions,
|
|
25
|
+
finalize: finalizeConditions,
|
|
26
|
+
breakpoints: { keys: ["base","sm","md","lg","2lg","xl","2xl"] }
|
|
27
|
+
},
|
|
28
|
+
utility: {
|
|
29
|
+
|
|
30
|
+
transform: (prop, value) => {
|
|
31
|
+
const key = resolveShorthand(prop)
|
|
32
|
+
const propKey = classNameByProp.get(key) || hypenateProperty(key)
|
|
33
|
+
return { className: `${propKey}_${withoutSpace(value)}` }
|
|
34
|
+
},
|
|
35
|
+
hasShorthand: true,
|
|
36
|
+
resolveShorthand: resolveShorthand,
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const cssFn = createCss(context)
|
|
41
|
+
export const css = (...styles) => cssFn(mergeCss(...styles))
|
|
42
|
+
css.raw = (...styles) => mergeCss(...styles)
|
|
43
|
+
|
|
44
|
+
export const { mergeCss, assignCss } = createMergeCss(context)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { compact, splitProps } from '../helpers.mjs';
|
|
2
|
+
import { css, mergeCss } from './css.mjs';
|
|
3
|
+
|
|
4
|
+
export function cva(config) {
|
|
5
|
+
const { base = {}, variants = {}, defaultVariants = {}, compoundVariants = [] } = config
|
|
6
|
+
|
|
7
|
+
function resolve(props = {}) {
|
|
8
|
+
const computedVariants = { ...defaultVariants, ...compact(props) }
|
|
9
|
+
let variantCss = { ...base }
|
|
10
|
+
for (const [key, value] of Object.entries(computedVariants)) {
|
|
11
|
+
if (variants[key]?.[value]) {
|
|
12
|
+
variantCss = mergeCss(variantCss, variants[key][value])
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const compoundVariantCss = getCompoundVariantCss(compoundVariants, computedVariants)
|
|
16
|
+
return mergeCss(variantCss, compoundVariantCss)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function cvaFn(props) {
|
|
20
|
+
return css(resolve(props))
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const variantKeys = Object.keys(variants)
|
|
24
|
+
|
|
25
|
+
function splitVariantProps(props) {
|
|
26
|
+
return splitProps(props, variantKeys)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const variantMap = Object.fromEntries(Object.entries(variants).map(([key, value]) => [key, Object.keys(value)]))
|
|
30
|
+
|
|
31
|
+
return Object.assign(cvaFn, {
|
|
32
|
+
__cva__: true,
|
|
33
|
+
variantMap,
|
|
34
|
+
variantKeys,
|
|
35
|
+
raw: resolve,
|
|
36
|
+
config,
|
|
37
|
+
splitVariantProps,
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function getCompoundVariantCss(compoundVariants, variantMap) {
|
|
42
|
+
let result = {}
|
|
43
|
+
compoundVariants.forEach((compoundVariant) => {
|
|
44
|
+
const isMatching = Object.entries(compoundVariant).every(([key, value]) => {
|
|
45
|
+
if (key === 'css') return true
|
|
46
|
+
|
|
47
|
+
const values = Array.isArray(value) ? value : [value]
|
|
48
|
+
return values.some((value) => variantMap[key] === value)
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
if (isMatching) {
|
|
52
|
+
result = mergeCss(result, compoundVariant.css)
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
return result
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function assertCompoundVariant(name, compoundVariants, variants, prop) {
|
|
60
|
+
if (compoundVariants.length > 0 && typeof variants?.[prop] === 'object') {
|
|
61
|
+
throw new Error(`[recipe:${name}:${prop}] Conditions are not supported when using compound variants.`)
|
|
62
|
+
}
|
|
63
|
+
}
|