Skip to content

Commit 57459b7

Browse files
committed
feat(workflow-block): new block, edge
1 parent 0c37140 commit 57459b7

File tree

28 files changed

+1302
-1343
lines changed

28 files changed

+1302
-1343
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/components/dropdown/dropdown.tsx

Lines changed: 341 additions & 170 deletions
Large diffs are not rendered by default.

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/components/long-input/long-input.tsx

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,59 @@ import { useTagSelection } from '@/hooks/use-tag-selection'
1818

1919
const logger = createLogger('LongInput')
2020

21+
/**
22+
* Default number of rows for the textarea
23+
*/
24+
const DEFAULT_ROWS = 5
25+
26+
/**
27+
* Height of each row in pixels
28+
*/
29+
const ROW_HEIGHT_PX = 24
30+
31+
/**
32+
* Minimum height constraint for the textarea in pixels
33+
*/
34+
const MIN_HEIGHT_PX = 80
35+
36+
/**
37+
* Props for the LongInput component
38+
*/
2139
interface LongInputProps {
40+
/** Placeholder text to display when empty */
2241
placeholder?: string
42+
/** Unique identifier for the block */
2343
blockId: string
44+
/** Unique identifier for the sub-block */
2445
subBlockId: string
46+
/** Whether a connection is being dragged */
2547
isConnecting: boolean
48+
/** Configuration object for the sub-block */
2649
config: SubBlockConfig
50+
/** Number of rows to display */
2751
rows?: number
52+
/** Whether component is in preview mode */
2853
isPreview?: boolean
54+
/** Value to display in preview mode */
2955
previewValue?: string | null
56+
/** Controlled value from parent */
3057
value?: string
58+
/** Callback when value changes */
3159
onChange?: (value: string) => void
60+
/** Whether the input is disabled */
3261
disabled?: boolean
3362
}
3463

35-
// Constants
36-
const DEFAULT_ROWS = 5
37-
const ROW_HEIGHT_PX = 24
38-
const MIN_HEIGHT_PX = 80
39-
64+
/**
65+
* Multi-line text input component with AI generation support and variable reference handling
66+
*
67+
* @remarks
68+
* - Supports AI-powered content generation via Wand functionality
69+
* - Handles drag-and-drop for connections and variable references
70+
* - Provides environment variable and tag autocomplete
71+
* - Resizable with custom drag handle
72+
* - Integrates with ReactFlow for zoom control
73+
*/
4074
export function LongInput({
4175
placeholder,
4276
blockId,

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/components/short-input/short-input.tsx

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,52 @@ import { useWebhookManagement } from '@/hooks/use-webhook-management'
1919

2020
const logger = createLogger('ShortInput')
2121

22+
/**
23+
* Props for the ShortInput component
24+
*/
2225
interface ShortInputProps {
26+
/** Placeholder text to display when empty */
2327
placeholder?: string
28+
/** Whether to mask the input as a password field */
2429
password?: boolean
30+
/** Unique identifier for the block */
2531
blockId: string
32+
/** Unique identifier for the sub-block */
2633
subBlockId: string
34+
/** Whether a connection is being dragged */
2735
isConnecting: boolean
36+
/** Configuration object for the sub-block */
2837
config: SubBlockConfig
38+
/** Controlled value from parent */
2939
value?: string
40+
/** Callback when value changes */
3041
onChange?: (value: string) => void
42+
/** Whether component is in preview mode */
3143
isPreview?: boolean
44+
/** Value to display in preview mode */
3245
previewValue?: string | null
46+
/** Whether the input is disabled */
3347
disabled?: boolean
48+
/** Whether the input is read-only */
3449
readOnly?: boolean
50+
/** Whether to show a copy button */
3551
showCopyButton?: boolean
52+
/** Whether to use webhook URL as value */
3653
useWebhookUrl?: boolean
3754
}
3855

56+
/**
57+
* Single-line text input component with advanced features
58+
*
59+
* @remarks
60+
* - Supports AI-powered content generation via Wand functionality
61+
* - Auto-detects API key fields and provides environment variable suggestions
62+
* - Handles drag-and-drop for connections and variable references
63+
* - Provides environment variable and tag autocomplete
64+
* - Password masking with reveal on focus
65+
* - Copy to clipboard functionality
66+
* - Integrates with ReactFlow for zoom control
67+
*/
3968
export function ShortInput({
4069
blockId,
4170
subBlockId,
@@ -59,13 +88,12 @@ export function ShortInput({
5988
const [showTags, setShowTags] = useState(false)
6089
const [copied, setCopied] = useState(false)
6190

62-
const webhookManagement = useWebhookUrl
63-
? useWebhookManagement({
64-
blockId,
65-
triggerId: undefined,
66-
isPreview,
67-
})
68-
: null
91+
// Always call the hook - hooks must be called unconditionally
92+
const webhookManagement = useWebhookManagement({
93+
blockId,
94+
triggerId: undefined,
95+
isPreview,
96+
})
6997

7098
// Wand functionality - always call the hook unconditionally
7199
const wandHook = useWand({
@@ -141,7 +169,7 @@ export function ShortInput({
141169
}
142170
}, [localContent, wandHook.isStreaming, isPreview, disabled, setStoreValue])
143171

144-
// Check if this input is API key related
172+
// Check if this input is API key related - memoized to prevent recalculation
145173
const isApiKeyField = useMemo(() => {
146174
const normalizedId = config?.id?.replace(/\s+/g, '').toLowerCase() || ''
147175
const normalizedTitle = config?.title?.replace(/\s+/g, '').toLowerCase() || ''
@@ -400,14 +428,14 @@ export function ShortInput({
400428
/**
401429
* Handles copying the value to the clipboard.
402430
*/
403-
const handleCopy = () => {
431+
const handleCopy = useCallback(() => {
404432
const textToCopy = useWebhookUrl ? webhookManagement?.webhookUrl : value?.toString()
405433
if (textToCopy) {
406434
navigator.clipboard.writeText(textToCopy)
407435
setCopied(true)
408436
setTimeout(() => setCopied(false), 2000)
409437
}
410-
}
438+
}, [useWebhookUrl, webhookManagement?.webhookUrl, value])
411439

412440
// Handle key combinations
413441
const handleKeyDown = useCallback(

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/components/text/text.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
1+
/**
2+
* Props for the Text component
3+
*/
14
interface TextProps {
5+
/** Unique identifier for the block */
26
blockId: string
7+
/** Unique identifier for the sub-block */
38
subBlockId: string
9+
/** Text or HTML content to display */
410
content: string
11+
/** Additional CSS classes to apply */
512
className?: string
613
}
714

15+
/**
16+
* Text display component with HTML rendering support
17+
*
18+
* @remarks
19+
* - Automatically detects and renders HTML content safely
20+
* - Applies prose styling for HTML content (links, code, lists, etc.)
21+
* - Falls back to plain text rendering for non-HTML content
22+
*/
823
export function Text({ blockId, subBlockId, content, className }: TextProps) {
924
const containsHtml = /<[^>]+>/.test(content)
1025

0 commit comments

Comments
 (0)