|
1 | 1 | import { type JSX, type MouseEvent, memo, useCallback, useMemo, useRef, useState } from 'react' |
2 | 2 | import { Button, cn, Input, Label, Tooltip } from '@sim/emcn' |
3 | | -import { |
4 | | - ArrowLeftRight, |
5 | | - ArrowUp, |
6 | | - Check, |
7 | | - Clipboard, |
8 | | - SquareArrowUpRight, |
9 | | - TriangleAlert, |
10 | | -} from '@sim/emcn/icons' |
| 3 | +import { ArrowUp, Check, Clipboard, SquareArrowUpRight, TriangleAlert } from '@sim/emcn/icons' |
11 | 4 | import { isEqual } from 'es-toolkit' |
12 | 5 | import { useParams } from 'next/navigation' |
13 | 6 | import type { FilterRule, SortRule } from '@/lib/table/query-builder/constants' |
@@ -54,6 +47,7 @@ import { |
54 | 47 | WorkflowSelectorInput, |
55 | 48 | WorkspaceFolderSelector, |
56 | 49 | } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components' |
| 50 | +import { FieldModeToggle } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/field-mode-toggle/field-mode-toggle' |
57 | 51 | import { MODAL_REGISTRY } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/modal-registry' |
58 | 52 | import { useDependsOnGate } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/hooks/use-depends-on-gate' |
59 | 53 | import type { SubBlockConfig } from '@/blocks/types' |
@@ -377,37 +371,14 @@ const renderLabel = ( |
377 | 371 | </Tooltip.Root> |
378 | 372 | )} |
379 | 373 | {showCanonicalToggle && ( |
380 | | - <Tooltip.Root> |
381 | | - <Tooltip.Trigger asChild> |
382 | | - <button |
383 | | - type='button' |
384 | | - className='flex size-[12px] shrink-0 items-center justify-center bg-transparent p-0 disabled:cursor-not-allowed disabled:opacity-50' |
385 | | - onClick={canonicalToggle?.onToggle} |
386 | | - disabled={canonicalToggleDisabledResolved} |
387 | | - aria-label={ |
388 | | - canonicalToggle?.mode === 'advanced' |
389 | | - ? 'Switch to selector' |
390 | | - : 'Switch to manual ID' |
391 | | - } |
392 | | - > |
393 | | - <ArrowLeftRight |
394 | | - className={cn( |
395 | | - 'h-[12px]! w-[12px]!', |
396 | | - canonicalToggle?.mode === 'advanced' |
397 | | - ? 'text-[var(--text-primary)]' |
398 | | - : 'text-[var(--text-secondary)]' |
399 | | - )} |
400 | | - /> |
401 | | - </button> |
402 | | - </Tooltip.Trigger> |
403 | | - <Tooltip.Content side='top'> |
404 | | - <p> |
405 | | - {canonicalToggle?.mode === 'advanced' |
406 | | - ? 'Switch to selector' |
407 | | - : 'Switch to manual ID'} |
408 | | - </p> |
409 | | - </Tooltip.Content> |
410 | | - </Tooltip.Root> |
| 374 | + <FieldModeToggle |
| 375 | + active={canonicalToggle?.mode === 'advanced'} |
| 376 | + label={ |
| 377 | + canonicalToggle?.mode === 'advanced' ? 'Switch to selector' : 'Switch to manual ID' |
| 378 | + } |
| 379 | + disabled={canonicalToggleDisabledResolved} |
| 380 | + onClick={canonicalToggle?.onToggle} |
| 381 | + /> |
411 | 382 | )} |
412 | 383 | </div> |
413 | 384 | </div> |
|
0 commit comments