Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/designer-modes/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import { useState } from 'react';
import { Designer, type DesignerMode } from '@object-ui/designer';
import type { SchemaNode } from '@object-ui/core';

Expand Down
10 changes: 5 additions & 5 deletions examples/designer-modes/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import App from './App';
import './index.css';

ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
createRoot(document.getElementById('root')!).render(
<StrictMode>
<App />
</React.StrictMode>,
</StrictMode>,
);
1 change: 1 addition & 0 deletions examples/designer-modes/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"types": ["vite/client"],
"skipLibCheck": true,

/* Bundler mode */
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"scripts": {
"dev": "pnpm --filter prototype dev",
"start": "pnpm --filter prototype dev",
"build": "pnpm -r build",
"build": "pnpm --filter './packages/*' -r build && pnpm --filter './examples/*' -r build",
"pretest": "pnpm --filter @object-ui/types build && pnpm --filter @object-ui/core build && pnpm --filter @object-ui/react build && pnpm --filter @object-ui/components build",
"test": "vitest run",
"docs:dev": "pnpm --filter object-ui-docs dev",
Expand Down
8 changes: 4 additions & 4 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
"version": "0.2.0",
"type": "module",
"license": "MIT",
"main": "dist/index.umd.js",
"module": "dist/index.mjs",
"main": "dist/index.umd.cjs",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.umd.js"
"import": "./dist/index.js",
"require": "./dist/index.umd.cjs"
},
"./dist/style.css": "./dist/style.css"
},
Expand Down
23 changes: 19 additions & 4 deletions packages/designer/src/components/CanvasDesigner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { useKeyboardShortcuts } from '../hooks/useKeyboardShortcuts';
import type { SchemaNode } from '@object-ui/core';
import type { CanvasDesignerConfig } from '../types/designer-modes';
import { SchemaRenderer } from '@object-ui/react';
import { ResizeHandles } from './ResizeHandle';
import { ResizeHandles, type ResizeDirection } from './ResizeHandle';
import { ComponentRegistry } from '@object-ui/core';
import { cn } from '@object-ui/components';

Expand Down Expand Up @@ -158,7 +158,22 @@ const FreeFormCanvas: React.FC<{ showGrid?: boolean; gridSize?: number }> = ({

return nodes.map((node) => {
const isSelected = node.id === selectedNodeId;
const isResizable = ComponentRegistry.getConfig(node.type)?.resizable || false;
const config = ComponentRegistry.getConfig(node.type);
const isResizable = config?.resizable || false;

// Determine which directions to show based on constraints
const constraints = config?.resizeConstraints || {};
const directions: ResizeDirection[] = [];

if (constraints.width !== false) {
directions.push('e', 'w');
}
if (constraints.height !== false) {
directions.push('n', 's');
}
if (constraints.width !== false && constraints.height !== false) {
directions.push('ne', 'nw', 'se', 'sw');
}

return (
<div
Expand Down Expand Up @@ -186,8 +201,8 @@ const FreeFormCanvas: React.FC<{ showGrid?: boolean; gridSize?: number }> = ({
{/* Resize handles for selected node */}
{isSelected && isResizable && (
<ResizeHandles
nodeId={node.id || ''}
onResizeStart={(direction) => {
directions={directions}
onResizeStart={(direction, e) => {
const element = document.querySelector(`[data-obj-id="${node.id}"]`) as HTMLElement;
if (element) {
setResizingNode({
Expand Down