Bin
2025-12-16 9e0b2ba2c317b1a86212f24cbae3195ad1f3dbfa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import { IconLockLocked, IconLockUnlocked } from "@humansignal/icons";
import type { ButtonProps } from "@humansignal/ui";
import type { HotkeyList } from "libs/editor/src/core/Hotkey";
import { observer } from "mobx-react";
import type { FC } from "react";
import { FF_DEV_3873, isFF } from "../../../utils/feature-flags";
import { RegionControlButton } from "./RegionControlButton";
 
export const LockButton: FC<{
  item: any;
  annotation: any;
  hovered: boolean;
  locked: boolean;
  hotkey?: string;
  variant?: ButtonProps["variant"];
  look?: ButtonProps["look"];
  ariaLabel?: string;
  tooltip?: string;
  style?: ButtonProps["style"];
  displayedHotkey?: string;
  onClick: () => void;
}> = observer(
  ({
    item,
    annotation,
    hovered,
    locked,
    hotkey,
    variant,
    displayedHotkey,
    look,
    ariaLabel,
    tooltip,
    style,
    onClick,
  }) => {
    if (!item) return null;
    const isLocked = locked || item.isReadOnly() || annotation.isReadOnly();
    const isRegionReadonly = item.isReadOnly() && !locked;
 
    if (isFF(FF_DEV_3873)) {
      const styles = {
        ...style,
        display: item.isReadOnly() || locked ? undefined : "none",
      };
 
      return (
        <RegionControlButton
          disabled={isRegionReadonly}
          onClick={onClick}
          hotkey={hotkey as HotkeyList}
          variant={variant}
          look={look}
          style={styles}
          aria-label={ariaLabel}
          tooltip={tooltip}
        >
          {isLocked ? <IconLockLocked /> : <IconLockUnlocked />}
        </RegionControlButton>
      );
    }
 
    return (
      <RegionControlButton
        disabled={isRegionReadonly}
        onClick={onClick}
        displayedHotkey={displayedHotkey}
        hotkey={hotkey}
        variant={variant}
        look={look}
        style={style}
        aria-label={ariaLabel}
        tooltip={tooltip}
      >
        {isLocked ? <IconLockLocked /> : <IconLockUnlocked />}
      </RegionControlButton>
    );
  },
);