@alexgorbatchev/shadcn 0.0.102 → 0.0.104

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.
@@ -9,7 +9,7 @@ import {
9
9
  import {
10
10
  Field2,
11
11
  FieldLabel2
12
- } from "./chunk-9n0axzd5.js";
12
+ } from "./chunk-bfv4qesg.js";
13
13
  import {
14
14
  Textarea2
15
15
  } from "./chunk-9k5b62qf.js";
@@ -68,11 +68,23 @@ function FieldContent2({ density, className, ...props }) {
68
68
  ...props
69
69
  });
70
70
  }
71
- function FieldLabel2({ density, className, ...props }) {
71
+ function hasSelectionWithin(element) {
72
+ const selection = element.ownerDocument.getSelection();
73
+ if (!selection || selection.isCollapsed || selection.rangeCount === 0)
74
+ return false;
75
+ return selection.getRangeAt(0).intersectsNode(element);
76
+ }
77
+ function FieldLabel2({ density, className, selectable = false, onClick, ...props }) {
72
78
  return /* @__PURE__ */ jsx(Label2, {
73
79
  "data-density": density,
74
80
  "data-slot": "field-label",
75
- className: cn2("group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-sm has-[>[data-slot=field]]:border has-[>[data-slot=field]]:not-has-[:disabled,[data-disabled]]:hover:bg-muted/50 has-[>[data-slot=field]]:has-[:focus-visible]:border-ring has-[>[data-slot=field]]:has-[:focus-visible]:ring-3 has-[>[data-slot=field]]:has-[:focus-visible]:ring-ring *:data-[slot=field]:p-2.5", "has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col", className),
81
+ "data-selectable": selectable || undefined,
82
+ className: cn2("group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-sm has-[>[data-slot=field]]:border has-[>[data-slot=field]]:not-has-[:disabled,[data-disabled]]:hover:bg-muted/50 has-[>[data-slot=field]]:has-[:focus-visible]:border-ring has-[>[data-slot=field]]:has-[:focus-visible]:ring-3 has-[>[data-slot=field]]:has-[:focus-visible]:ring-ring *:data-[slot=field]:p-2.5", "has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col", selectable && "select-text", className),
83
+ onClick: (event) => {
84
+ if (selectable && hasSelectionWithin(event.currentTarget))
85
+ event.preventDefault();
86
+ onClick?.(event);
87
+ },
76
88
  ...props
77
89
  });
78
90
  }
@@ -12,7 +12,7 @@ import {
12
12
  import {
13
13
  Field2,
14
14
  FieldLabel2
15
- } from "./chunk-9n0axzd5.js";
15
+ } from "./chunk-bfv4qesg.js";
16
16
  import {
17
17
  Textarea2
18
18
  } from "./chunk-9k5b62qf.js";