@timeax/form-palette 0.1.35 → 0.2.1

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.
package/dist/extra.js CHANGED
@@ -11,15 +11,16 @@ var reactSlot = require('@radix-ui/react-slot');
11
11
  var SwitchPrimitive = require('@radix-ui/react-switch');
12
12
  var RadioGroupPrimitive = require('@radix-ui/react-radio-group');
13
13
  var CheckboxPrimitive = require('@radix-ui/react-checkbox');
14
+ var ScrollAreaPrimitive = require('@radix-ui/react-scroll-area');
14
15
  var reactVirtuoso = require('react-virtuoso');
15
16
  var SliderPrimitive = require('@radix-ui/react-slider');
16
17
  var DialogPrimitive = require('@radix-ui/react-dialog');
17
- var ScrollAreaPrimitive = require('@radix-ui/react-scroll-area');
18
18
  var ToggleGroupPrimitive = require('@radix-ui/react-toggle-group');
19
19
  require('@radix-ui/react-toggle');
20
20
  var TooltipPrimitive = require('@radix-ui/react-tooltip');
21
21
  var Editor = require('@toast-ui/editor');
22
22
  require('@toast-ui/editor/dist/toastui-editor.css');
23
+ require('@toast-ui/editor/dist/theme/toastui-editor-dark.css');
23
24
  var Ajv = require('ajv');
24
25
  var react = require('@iconify/react');
25
26
  var LabelPrimitive = require('@radix-ui/react-label');
@@ -52,9 +53,9 @@ var PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespace(PopoverPrimitiv
52
53
  var SwitchPrimitive__namespace = /*#__PURE__*/_interopNamespace(SwitchPrimitive);
53
54
  var RadioGroupPrimitive__namespace = /*#__PURE__*/_interopNamespace(RadioGroupPrimitive);
54
55
  var CheckboxPrimitive__namespace = /*#__PURE__*/_interopNamespace(CheckboxPrimitive);
56
+ var ScrollAreaPrimitive__namespace = /*#__PURE__*/_interopNamespace(ScrollAreaPrimitive);
55
57
  var SliderPrimitive__namespace = /*#__PURE__*/_interopNamespace(SliderPrimitive);
56
58
  var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive);
57
- var ScrollAreaPrimitive__namespace = /*#__PURE__*/_interopNamespace(ScrollAreaPrimitive);
58
59
  var ToggleGroupPrimitive__namespace = /*#__PURE__*/_interopNamespace(ToggleGroupPrimitive);
59
60
  var TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespace(TooltipPrimitive);
60
61
  var Editor__default = /*#__PURE__*/_interopDefault(Editor);
@@ -10778,6 +10779,7 @@ var Input = React74__namespace.forwardRef(
10778
10779
  "data-size": sizeKey,
10779
10780
  "data-density": densityKey,
10780
10781
  placeholder,
10782
+ ...rest,
10781
10783
  value: displayValue,
10782
10784
  onChange,
10783
10785
  onBlur,
@@ -10785,8 +10787,7 @@ var Input = React74__namespace.forwardRef(
10785
10787
  onKeyDown: handleKeyDownWrapped,
10786
10788
  onKeyPress: handleKeyPressWrapped,
10787
10789
  onBeforeInput: handleBeforeInputWrapped,
10788
- onPaste: handlePasteWrapped,
10789
- ...rest
10790
+ onPaste: handlePasteWrapped
10790
10791
  }
10791
10792
  )
10792
10793
  );
@@ -11063,6 +11064,12 @@ var Input = React74__namespace.forwardRef(
11063
11064
  ] });
11064
11065
  }
11065
11066
  );
11067
+ function stripAffixes(value, prefix, suffix) {
11068
+ let out = value != null ? value : "";
11069
+ if (prefix && out.startsWith(prefix)) out = out.slice(prefix.length);
11070
+ if (suffix && out.endsWith(suffix)) out = out.slice(0, -suffix.length);
11071
+ return out;
11072
+ }
11066
11073
  var ShadcnTextVariant = React74__namespace.forwardRef(function ShadcnTextVariant2(props, forwardedRef) {
11067
11074
  const {
11068
11075
  // form-level props
@@ -11146,7 +11153,12 @@ var ShadcnTextVariant = React74__namespace.forwardRef(function ShadcnTextVariant
11146
11153
  (e4) => {
11147
11154
  var _a, _b, _c;
11148
11155
  const maskedValue = (_a = e4.value) != null ? _a : "";
11149
- const unmaskedInner = (_c = (_b = maskedValue.match(/[0-9A-Za-z]/g)) == null ? void 0 : _b.join("")) != null ? _c : "";
11156
+ const maskedValueWithoutAffixes = stripAffixes(
11157
+ maskedValue,
11158
+ prefix,
11159
+ suffix
11160
+ );
11161
+ const unmaskedInner = (_c = (_b = maskedValueWithoutAffixes.match(/[0-9A-Za-z]/g)) == null ? void 0 : _b.join("")) != null ? _c : "";
11150
11162
  const mode = unmask === true || unmask === "raw" ? "raw" : "masked";
11151
11163
  const detail = {
11152
11164
  source: "variant",
@@ -11285,7 +11297,7 @@ function getDecimalSeparator(locale) {
11285
11297
  const m2 = s3.match(/1(.?)1/);
11286
11298
  return (m2 == null ? void 0 : m2[1]) || ".";
11287
11299
  }
11288
- function stripAffixes(text, prefix, suffix) {
11300
+ function stripAffixes2(text, prefix, suffix) {
11289
11301
  let t4 = text != null ? text : "";
11290
11302
  if (prefix && t4.startsWith(prefix)) t4 = t4.slice(prefix.length);
11291
11303
  if (suffix && t4.endsWith(suffix)) t4 = t4.slice(0, -suffix.length);
@@ -11479,7 +11491,7 @@ var InputNumber = React74__namespace.memo(
11479
11491
  );
11480
11492
  const getModelFromDisplay = React74__namespace.useCallback(
11481
11493
  (text) => {
11482
- const stripped = stripAffixes(text, props.prefix, props.suffix);
11494
+ const stripped = stripAffixes2(text, props.prefix, props.suffix);
11483
11495
  const withoutGroup = stripGrouping(stripped, locale);
11484
11496
  const candidate = decimalSep !== "." ? withoutGroup.replace(".", decimalSep) : withoutGroup;
11485
11497
  const n3 = parseEditable(candidate, locale, decimalSep);
@@ -11517,7 +11529,7 @@ var InputNumber = React74__namespace.memo(
11517
11529
  setFocused(true);
11518
11530
  (_a2 = props.onFocus) == null ? void 0 : _a2.call(props, e4);
11519
11531
  const model = isFiniteNumber(props.value) ? clampModel(props.value) : getModelFromDisplay(display);
11520
- const editable = model == null ? stripAffixes(display, props.prefix, props.suffix) : toEditableFromNumber(model);
11532
+ const editable = model == null ? stripAffixes2(display, props.prefix, props.suffix) : toEditableFromNumber(model);
11521
11533
  const normalized = normalizeEditable(
11522
11534
  editable,
11523
11535
  locale,
@@ -11534,7 +11546,7 @@ var InputNumber = React74__namespace.memo(
11534
11546
  var _a2, _b;
11535
11547
  setFocused(false);
11536
11548
  const el = e4.currentTarget;
11537
- const raw = stripAffixes(el.value, props.prefix, props.suffix);
11549
+ const raw = stripAffixes2(el.value, props.prefix, props.suffix);
11538
11550
  const normalized = normalizeEditable(
11539
11551
  raw,
11540
11552
  locale,
@@ -11556,7 +11568,7 @@ var InputNumber = React74__namespace.memo(
11556
11568
  if (props.disabled || props.readOnly) return;
11557
11569
  const el = e4.currentTarget;
11558
11570
  const caretBefore = (_a2 = el.selectionStart) != null ? _a2 : el.value.length;
11559
- const stripped = stripAffixes(el.value, props.prefix, props.suffix);
11571
+ const stripped = stripAffixes2(el.value, props.prefix, props.suffix);
11560
11572
  let next = normalizeEditable(
11561
11573
  stripped,
11562
11574
  locale,
@@ -12480,14 +12492,18 @@ function applyMask(mask, raw, keepCharPositions) {
12480
12492
  function digitsOnly(input) {
12481
12493
  return (input != null ? input : "").replace(/\D+/g, "");
12482
12494
  }
12495
+ function normalizeDial(dial) {
12496
+ return digitsOnly(dial != null ? dial : "");
12497
+ }
12483
12498
  function dialPrefixFor(country) {
12484
- return `+${country.dial} `;
12499
+ return `+${normalizeDial(country.dial)} `;
12485
12500
  }
12486
12501
  function valueToNationalDigits(value, country) {
12487
12502
  const digits = digitsOnly(value);
12488
12503
  if (!digits) return "";
12489
- if (digits.startsWith(country.dial)) {
12490
- return digits.slice(country.dial.length);
12504
+ const dial = normalizeDial(country.dial);
12505
+ if (dial && digits.startsWith(dial)) {
12506
+ return digits.slice(dial.length);
12491
12507
  }
12492
12508
  return digits;
12493
12509
  }
@@ -12507,8 +12523,9 @@ function computeDisplayFromValue(value, country, keepCharPositions) {
12507
12523
  function computeNextFromInput(rawInput, country, mode, keepCharPositions) {
12508
12524
  const prefix = dialPrefixFor(country);
12509
12525
  let national = digitsOnly(rawInput);
12510
- if (national.startsWith(country.dial)) {
12511
- national = national.slice(country.dial.length);
12526
+ const dial = normalizeDial(country.dial);
12527
+ if (dial && national.startsWith(dial)) {
12528
+ national = national.slice(dial.length);
12512
12529
  }
12513
12530
  const mask = compileMask(country.mask);
12514
12531
  const maskedNational = applyMask(mask, national, keepCharPositions);
@@ -12519,7 +12536,7 @@ function computeNextFromInput(rawInput, country, mode, keepCharPositions) {
12519
12536
  } else if (mode === "masked") {
12520
12537
  nextValue = display;
12521
12538
  } else if (mode === "e164") {
12522
- nextValue = country.dial + national;
12539
+ nextValue = dial + national;
12523
12540
  } else {
12524
12541
  nextValue = national;
12525
12542
  }
@@ -12532,8 +12549,10 @@ function remapToCountry(value, from, to, mode, keepCharPositions) {
12532
12549
  }
12533
12550
  const digitsAll = digitsOnly(value);
12534
12551
  let national = digitsAll;
12535
- if (digitsAll.startsWith(from.dial)) {
12536
- national = digitsAll.slice(from.dial.length);
12552
+ const fromDial = normalizeDial(from.dial);
12553
+ const toDial = normalizeDial(to.dial);
12554
+ if (fromDial && digitsAll.startsWith(fromDial)) {
12555
+ national = digitsAll.slice(fromDial.length);
12537
12556
  }
12538
12557
  const prefix = dialPrefixFor(to);
12539
12558
  const mask = compileMask(to.mask);
@@ -12545,7 +12564,7 @@ function remapToCountry(value, from, to, mode, keepCharPositions) {
12545
12564
  } else if (mode === "masked") {
12546
12565
  nextValue = display;
12547
12566
  } else if (mode === "e164") {
12548
- nextValue = to.dial + national;
12567
+ nextValue = toDial + national;
12549
12568
  } else {
12550
12569
  nextValue = national;
12551
12570
  }
@@ -12574,7 +12593,7 @@ var CountrySelect = ({
12574
12593
  const selected = (_b = (_a = countries.find((c2) => c2.code === value)) != null ? _a : countries[0]) != null ? _b : null;
12575
12594
  const triggerLabel = selected ? [
12576
12595
  showFlag && selected.flag ? selected.flag : null,
12577
- showSelectedDial ? `+${selected.dial}` : null,
12596
+ showSelectedDial ? `+${normalizeDial(selected.dial)}` : null,
12578
12597
  showSelectedLabel ? selected.label : null
12579
12598
  ].filter(Boolean).join(" ") : "";
12580
12599
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: countrySelectClassName, children: /* @__PURE__ */ jsxRuntime.jsxs(Select, { value: (_c = selected == null ? void 0 : selected.code) != null ? _c : "", onValueChange: onChange, children: [
@@ -12601,7 +12620,7 @@ var CountrySelect = ({
12601
12620
  parts.push(String(c2.flag));
12602
12621
  }
12603
12622
  if (showDialInList) {
12604
- parts.push(`${c2.dial}`);
12623
+ parts.push(`+${normalizeDial(c2.dial)}`);
12605
12624
  }
12606
12625
  parts.push(c2.label);
12607
12626
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -20544,6 +20563,7 @@ function normalizeItems2(items, mappers, optionValueKey, optionLabelKey, optionT
20544
20563
  });
20545
20564
  }
20546
20565
  return items.map((item, index) => {
20566
+ var _a;
20547
20567
  if (typeof item === "string" || typeof item === "number" || typeof item === "boolean") {
20548
20568
  const v2 = item;
20549
20569
  return {
@@ -20556,12 +20576,19 @@ function normalizeItems2(items, mappers, optionValueKey, optionLabelKey, optionT
20556
20576
  raw: item
20557
20577
  };
20558
20578
  }
20559
- return item;
20579
+ const existing = item;
20580
+ return {
20581
+ ...existing,
20582
+ raw: (_a = existing.raw) != null ? _a : item
20583
+ };
20560
20584
  });
20561
20585
  }
20562
20586
  function isEqualValue2(a3, b2) {
20563
20587
  return Object.is(a3, b2);
20564
20588
  }
20589
+ function valueLookupKey(value) {
20590
+ return `${typeof value}:${String(value)}`;
20591
+ }
20565
20592
  function asGroupValue(value) {
20566
20593
  if (!value) return void 0;
20567
20594
  if (Array.isArray(value)) {
@@ -20575,13 +20602,14 @@ function asGroupValue(value) {
20575
20602
  state: true
20576
20603
  }));
20577
20604
  }
20578
- if (typeof value == "object")
20579
- return Object.keys(value).map(
20605
+ if (typeof value == "object") {
20606
+ return Reflect.ownKeys(value).map(
20580
20607
  (key) => ({
20581
20608
  value: key,
20582
20609
  state: value[key]
20583
20610
  })
20584
20611
  );
20612
+ }
20585
20613
  return void 0;
20586
20614
  }
20587
20615
  function asSingleValue(value) {
@@ -20740,7 +20768,32 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
20740
20768
  }
20741
20769
  );
20742
20770
  }
20743
- const groupValue = asGroupValue(value);
20771
+ const normalizedByValueKey = React74__namespace.useMemo(() => {
20772
+ const lookup = /* @__PURE__ */ new Map();
20773
+ normalized.forEach((item) => {
20774
+ lookup.set(valueLookupKey(item.value), item);
20775
+ });
20776
+ return lookup;
20777
+ }, [normalized]);
20778
+ const groupValue = React74__namespace.useMemo(() => {
20779
+ const source = asGroupValue(value);
20780
+ if (!(source == null ? void 0 : source.length)) return source;
20781
+ return source.map((entry) => {
20782
+ const byExact = normalized.find(
20783
+ (item) => isEqualValue2(item.value, entry.value)
20784
+ );
20785
+ if (byExact) return { ...entry, value: byExact.value };
20786
+ const byKey = normalizedByValueKey.get(valueLookupKey(entry.value));
20787
+ if (byKey) return { ...entry, value: byKey.value };
20788
+ if (typeof entry.value === "string") {
20789
+ const byString = normalized.find(
20790
+ (item) => typeof item.value !== "object" && String(item.value) === entry.value
20791
+ );
20792
+ if (byString) return { ...entry, value: byString.value };
20793
+ }
20794
+ return entry;
20795
+ });
20796
+ }, [value, normalized, normalizedByValueKey]);
20744
20797
  const {
20745
20798
  groupStyle,
20746
20799
  groupClasses,
@@ -20841,10 +20894,13 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
20841
20894
  raw: nextList,
20842
20895
  selectedOptions: nextList.map(
20843
20896
  (entry) => {
20844
- var _a, _b;
20845
- return (_b = (_a = normalized.find(
20897
+ var _a, _b, _c;
20898
+ const normalizedItem = (_a = normalizedByValueKey.get(
20899
+ valueLookupKey(entry.value)
20900
+ )) != null ? _a : normalized.find(
20846
20901
  (item) => isEqualValue2(item.value, entry.value)
20847
- )) == null ? void 0 : _a.raw) != null ? _b : entry.value;
20902
+ );
20903
+ return (_c = (_b = normalizedItem == null ? void 0 : normalizedItem.raw) != null ? _b : normalizedItem) != null ? _c : entry.value;
20848
20904
  }
20849
20905
  ),
20850
20906
  nativeEvent: void 0,
@@ -20860,7 +20916,7 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
20860
20916
  }
20861
20917
  onValue(nextList.map((item) => item.value), detail);
20862
20918
  },
20863
- [onValue, disabled, groupValue, normalized, hasAnyTristate]
20919
+ [onValue, disabled, groupValue, normalizedByValueKey, normalized, hasAnyTristate]
20864
20920
  );
20865
20921
  return /* @__PURE__ */ jsxRuntime.jsx(
20866
20922
  "div",
@@ -21032,6 +21088,59 @@ var checkboxModule = {
21032
21088
  tags: ["checkbox", "group", "boolean", "tri-state"]
21033
21089
  }
21034
21090
  };
21091
+ function ScrollArea({
21092
+ className,
21093
+ children,
21094
+ ...props
21095
+ }) {
21096
+ return /* @__PURE__ */ jsxRuntime.jsxs(
21097
+ ScrollAreaPrimitive__namespace.Root,
21098
+ {
21099
+ "data-slot": "scroll-area",
21100
+ className: cn("relative", className),
21101
+ ...props,
21102
+ children: [
21103
+ /* @__PURE__ */ jsxRuntime.jsx(
21104
+ ScrollAreaPrimitive__namespace.Viewport,
21105
+ {
21106
+ "data-slot": "scroll-area-viewport",
21107
+ className: "focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",
21108
+ children
21109
+ }
21110
+ ),
21111
+ /* @__PURE__ */ jsxRuntime.jsx(ScrollBar, {}),
21112
+ /* @__PURE__ */ jsxRuntime.jsx(ScrollAreaPrimitive__namespace.Corner, {})
21113
+ ]
21114
+ }
21115
+ );
21116
+ }
21117
+ function ScrollBar({
21118
+ className,
21119
+ orientation = "vertical",
21120
+ ...props
21121
+ }) {
21122
+ return /* @__PURE__ */ jsxRuntime.jsx(
21123
+ ScrollAreaPrimitive__namespace.ScrollAreaScrollbar,
21124
+ {
21125
+ "data-slot": "scroll-area-scrollbar",
21126
+ orientation,
21127
+ className: cn(
21128
+ "flex touch-none p-px transition-colors select-none",
21129
+ orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent",
21130
+ orientation === "horizontal" && "h-2.5 flex-col border-t border-t-transparent",
21131
+ className
21132
+ ),
21133
+ ...props,
21134
+ children: /* @__PURE__ */ jsxRuntime.jsx(
21135
+ ScrollAreaPrimitive__namespace.ScrollAreaThumb,
21136
+ {
21137
+ "data-slot": "scroll-area-thumb",
21138
+ className: "bg-border relative flex-1 rounded-full"
21139
+ }
21140
+ )
21141
+ }
21142
+ );
21143
+ }
21035
21144
  function normalizeOptions(opts, config) {
21036
21145
  return globalNormalizeOptions(opts, config);
21037
21146
  }
@@ -21445,7 +21554,7 @@ var ShadcnSelectVariant = React74__namespace.forwardRef(function ShadcnSelectVar
21445
21554
  }
21446
21555
  }
21447
21556
  )
21448
- ) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "max-h-60 overflow-auto", children: filteredItems.map((item, index) => {
21557
+ ) : /* @__PURE__ */ jsxRuntime.jsx(ScrollArea, { className: "max-h-60", children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: filteredItems.map((item, index) => {
21449
21558
  var _a2, _b2;
21450
21559
  const optionNode = /* @__PURE__ */ jsxRuntime.jsx(
21451
21560
  SelectItem,
@@ -21500,7 +21609,7 @@ var ShadcnSelectVariant = React74__namespace.forwardRef(function ShadcnSelectVar
21500
21609
  setQuery("");
21501
21610
  }
21502
21611
  });
21503
- }) })
21612
+ }) }) })
21504
21613
  )
21505
21614
  ] })
21506
21615
  ]
@@ -23504,7 +23613,7 @@ var ShadcnKeyValueVariant = React74__namespace.forwardRef(function ShadcnKeyValu
23504
23613
  }
23505
23614
  )
23506
23615
  ] }),
23507
- items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-md border border-border/50 px-3 py-6 text-center text-sm text-muted-foreground", children: emptyLabel }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "max-h-64 overflow-auto rounded-md border border-border/50", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "divide-y divide-border/50", children: items.map((pair, index) => /* @__PURE__ */ jsxRuntime.jsxs(
23616
+ items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-md border border-border/50 px-3 py-6 text-center text-sm text-muted-foreground", children: emptyLabel }) : /* @__PURE__ */ jsxRuntime.jsx(ScrollArea, { className: "max-h-64 rounded-md border border-border/50", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "divide-y divide-border/50", children: items.map((pair, index) => /* @__PURE__ */ jsxRuntime.jsxs(
23508
23617
  "div",
23509
23618
  {
23510
23619
  className: "flex items-center justify-between gap-2 px-2 py-1.5",
@@ -24443,59 +24552,6 @@ var treeselectModule = {
24443
24552
  Variant: treeselect_default
24444
24553
  };
24445
24554
  var treeselect_default2 = treeselectModule;
24446
- function ScrollArea({
24447
- className,
24448
- children,
24449
- ...props
24450
- }) {
24451
- return /* @__PURE__ */ jsxRuntime.jsxs(
24452
- ScrollAreaPrimitive__namespace.Root,
24453
- {
24454
- "data-slot": "scroll-area",
24455
- className: cn("relative", className),
24456
- ...props,
24457
- children: [
24458
- /* @__PURE__ */ jsxRuntime.jsx(
24459
- ScrollAreaPrimitive__namespace.Viewport,
24460
- {
24461
- "data-slot": "scroll-area-viewport",
24462
- className: "focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",
24463
- children
24464
- }
24465
- ),
24466
- /* @__PURE__ */ jsxRuntime.jsx(ScrollBar, {}),
24467
- /* @__PURE__ */ jsxRuntime.jsx(ScrollAreaPrimitive__namespace.Corner, {})
24468
- ]
24469
- }
24470
- );
24471
- }
24472
- function ScrollBar({
24473
- className,
24474
- orientation = "vertical",
24475
- ...props
24476
- }) {
24477
- return /* @__PURE__ */ jsxRuntime.jsx(
24478
- ScrollAreaPrimitive__namespace.ScrollAreaScrollbar,
24479
- {
24480
- "data-slot": "scroll-area-scrollbar",
24481
- orientation,
24482
- className: cn(
24483
- "flex touch-none p-px transition-colors select-none",
24484
- orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent",
24485
- orientation === "horizontal" && "h-2.5 flex-col border-t border-t-transparent",
24486
- className
24487
- ),
24488
- ...props,
24489
- children: /* @__PURE__ */ jsxRuntime.jsx(
24490
- ScrollAreaPrimitive__namespace.ScrollAreaThumb,
24491
- {
24492
- "data-slot": "scroll-area-thumb",
24493
- className: "bg-border relative flex-1 rounded-full"
24494
- }
24495
- )
24496
- }
24497
- );
24498
- }
24499
24555
  function fileId() {
24500
24556
  return `file_${Math.random().toString(36).slice(2)}`;
24501
24557
  }
@@ -25806,7 +25862,7 @@ var ShadcnToggleVariant3 = React74__namespace.forwardRef(function ShadcnToggleVa
25806
25862
  size = "md",
25807
25863
  options = [],
25808
25864
  multiple = false,
25809
- variant = "default",
25865
+ design = "default",
25810
25866
  layout = "horizontal",
25811
25867
  gridCols = 2,
25812
25868
  fillWidth: fullWidth = false,
@@ -25910,7 +25966,6 @@ var ShadcnToggleVariant3 = React74__namespace.forwardRef(function ShadcnToggleVa
25910
25966
  fullWidth && layout === "vertical" && "[&>*]:w-full",
25911
25967
  className
25912
25968
  );
25913
- console.log(layoutClasses, fullWidth, autoCap);
25914
25969
  const groupStyle = React74__namespace.useMemo(() => {
25915
25970
  const style = {};
25916
25971
  if (layout === "grid") {
@@ -25929,7 +25984,7 @@ var ShadcnToggleVariant3 = React74__namespace.forwardRef(function ShadcnToggleVa
25929
25984
  value: currentValue,
25930
25985
  onValueChange: handleChange,
25931
25986
  disabled: isDisabled,
25932
- variant,
25987
+ variant: design,
25933
25988
  size: toggleSize,
25934
25989
  className: layoutClasses,
25935
25990
  style: groupStyle,
@@ -25971,7 +26026,7 @@ var ShadcnToggleVariant3 = React74__namespace.forwardRef(function ShadcnToggleVa
25971
26026
  // Error State
25972
26027
  error && "border-destructive/50 hover:bg-destructive/10 data-[state=on]:bg-destructive data-[state=on]:text-destructive-foreground",
25973
26028
  // Variant: Outline specific tweaks
25974
- variant === "outline" && layout === "horizontal" && !fullWidth && "first:rounded-l-md last:rounded-r-md rounded-none border-l-0 first:border-l",
26029
+ design === "outline" && layout === "horizontal" && !fullWidth && "first:rounded-l-md last:rounded-r-md rounded-none border-l-0 first:border-l",
25975
26030
  // Layout tweaks
25976
26031
  fullWidth && "justify-center",
25977
26032
  // Custom Item Class
@@ -26006,6 +26061,30 @@ var toggleGroupModule = {
26006
26061
  tags: ["buttons", "toggle"]
26007
26062
  }
26008
26063
  };
26064
+ function isDarkThemedElement(el) {
26065
+ if (!el) return false;
26066
+ if (el.classList.contains("dark")) return true;
26067
+ const dataTheme = el.getAttribute("data-theme");
26068
+ return dataTheme === "dark";
26069
+ }
26070
+ function resolveAutoDarkFromHost(host, target) {
26071
+ if (typeof document === "undefined") return false;
26072
+ if (target === "document") {
26073
+ return isDarkThemedElement(document.documentElement) || isDarkThemedElement(document.body);
26074
+ }
26075
+ let node = host != null ? host : null;
26076
+ while (node) {
26077
+ const isEditorMarker = node.hasAttribute("data-editor-theme");
26078
+ if (!isEditorMarker) {
26079
+ if (node.classList.contains("dark")) return true;
26080
+ if (node.hasAttribute("data-theme")) {
26081
+ return node.getAttribute("data-theme") === "dark";
26082
+ }
26083
+ }
26084
+ node = node.parentElement;
26085
+ }
26086
+ return isDarkThemedElement(document.documentElement) || isDarkThemedElement(document.body);
26087
+ }
26009
26088
  function ShadcnEditorVariant(props) {
26010
26089
  const {
26011
26090
  value,
@@ -26024,7 +26103,9 @@ function ShadcnEditorVariant(props) {
26024
26103
  useCommandShortcut = true,
26025
26104
  format: format2 = "html",
26026
26105
  toolbar = "default",
26027
- pastePlainText = false
26106
+ pastePlainText = false,
26107
+ theme = "auto",
26108
+ themeTarget = "nearest"
26028
26109
  } = props;
26029
26110
  const mountRef = React74__namespace.useRef(null);
26030
26111
  const editorRef = React74__namespace.useRef(null);
@@ -26032,9 +26113,13 @@ function ShadcnEditorVariant(props) {
26032
26113
  const onValueRef = React74__namespace.useRef(onValue);
26033
26114
  const syncingRef = React74__namespace.useRef(false);
26034
26115
  const loadedRef = React74__namespace.useRef(false);
26116
+ const lastContentRef = React74__namespace.useRef(value != null ? value : "");
26117
+ const [autoDark, setAutoDark] = React74__namespace.useState(false);
26035
26118
  formatRef.current = format2;
26036
26119
  onValueRef.current = onValue;
26120
+ if (value !== void 0) lastContentRef.current = value;
26037
26121
  const effectiveReadOnly = Boolean(disabled || readOnly);
26122
+ const effectiveTheme = theme === "auto" ? autoDark ? "dark" : "light" : theme;
26038
26123
  const readContent = React74__namespace.useCallback((ed) => {
26039
26124
  var _a, _b;
26040
26125
  return formatRef.current === "markdown" ? (_a = ed.getMarkdown()) != null ? _a : "" : (_b = ed.getHTML()) != null ? _b : "";
@@ -26046,9 +26131,40 @@ function ShadcnEditorVariant(props) {
26046
26131
  }, []);
26047
26132
  const structuralKey = React74__namespace.useMemo(() => {
26048
26133
  const hideModeSwitch = toolbar === "none" || pastePlainText;
26049
- return JSON.stringify({ toolbar, useCommandShortcut, hideModeSwitch });
26050
- }, [toolbar, useCommandShortcut, pastePlainText]);
26134
+ return JSON.stringify({
26135
+ toolbar,
26136
+ useCommandShortcut,
26137
+ hideModeSwitch,
26138
+ effectiveTheme
26139
+ });
26140
+ }, [toolbar, useCommandShortcut, pastePlainText, effectiveTheme]);
26051
26141
  React74__namespace.useEffect(() => {
26142
+ if (theme !== "auto") return;
26143
+ if (typeof document === "undefined") return;
26144
+ const host = mountRef.current;
26145
+ const recompute = () => {
26146
+ setAutoDark(resolveAutoDarkFromHost(host, themeTarget));
26147
+ };
26148
+ recompute();
26149
+ const observer = new MutationObserver(() => {
26150
+ recompute();
26151
+ });
26152
+ observer.observe(document.documentElement, {
26153
+ attributes: true,
26154
+ subtree: true,
26155
+ attributeFilter: ["class", "data-theme"]
26156
+ });
26157
+ if (document.body) {
26158
+ observer.observe(document.body, {
26159
+ attributes: true,
26160
+ subtree: true,
26161
+ attributeFilter: ["class", "data-theme"]
26162
+ });
26163
+ }
26164
+ return () => observer.disconnect();
26165
+ }, [theme, themeTarget]);
26166
+ React74__namespace.useEffect(() => {
26167
+ var _a;
26052
26168
  const el = mountRef.current;
26053
26169
  if (!el) return;
26054
26170
  if (editorRef.current) {
@@ -26072,13 +26188,14 @@ function ShadcnEditorVariant(props) {
26072
26188
  const options = {
26073
26189
  el,
26074
26190
  height,
26075
- initialValue: value != null ? value : "",
26191
+ initialValue: (_a = value != null ? value : lastContentRef.current) != null ? _a : "",
26076
26192
  previewStyle,
26077
26193
  initialEditType: editType,
26078
26194
  useCommandShortcut,
26079
26195
  usageStatistics: false,
26080
26196
  placeholder,
26081
26197
  hideModeSwitch,
26198
+ ...effectiveTheme === "dark" ? { theme: "dark" } : {},
26082
26199
  ...toolbar === "none" ? { toolbarItems: [] } : Array.isArray(toolbar) ? { toolbarItems: toolbar } : {},
26083
26200
  events: {
26084
26201
  load: () => {
@@ -26089,7 +26206,9 @@ function ShadcnEditorVariant(props) {
26089
26206
  const ed = editorRef.current;
26090
26207
  if (!ed) return;
26091
26208
  if (syncingRef.current) return;
26092
- emit(readContent(ed));
26209
+ const next = readContent(ed);
26210
+ lastContentRef.current = next;
26211
+ emit(next);
26093
26212
  }
26094
26213
  }
26095
26214
  };
@@ -26150,6 +26269,7 @@ function ShadcnEditorVariant(props) {
26150
26269
  const cur = (_d = (_c = ed.getHTML) == null ? void 0 : _c.call(ed)) != null ? _d : "";
26151
26270
  if (cur !== next) ed.setHTML(next, false);
26152
26271
  }
26272
+ lastContentRef.current = next;
26153
26273
  Promise.resolve().then(() => {
26154
26274
  syncingRef.current = false;
26155
26275
  });
@@ -26173,6 +26293,8 @@ function ShadcnEditorVariant(props) {
26173
26293
  {
26174
26294
  "data-size": size,
26175
26295
  "data-density": density,
26296
+ "data-theme": effectiveTheme,
26297
+ "data-editor-theme": effectiveTheme,
26176
26298
  className: cn(
26177
26299
  "rounded-md border border-input bg-background overflow-hidden",
26178
26300
  effectiveReadOnly && "opacity-60 pointer-events-none",
@@ -29066,16 +29188,16 @@ function OptionList(props) {
29066
29188
  [draft, isMulti]
29067
29189
  );
29068
29190
  if (s3 == null ? void 0 : s3.errorCode) {
29069
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("h-full min-h-0 overflow-y-auto", className), children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-3 py-4 text-sm opacity-70", children: [
29191
+ return /* @__PURE__ */ jsxRuntime.jsx(ScrollArea, { className: cn("h-full min-h-0", className), children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-3 py-4 text-sm opacity-70", children: [
29070
29192
  "Error: ",
29071
29193
  String(s3.errorCode)
29072
29194
  ] }) });
29073
29195
  }
29074
29196
  if ((s3 == null ? void 0 : s3.loading) && !((_b = s3 == null ? void 0 : s3.optionsList) == null ? void 0 : _b.length)) {
29075
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("h-full min-h-0 overflow-y-auto", className), children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-3 py-4 text-sm opacity-70", children: "Loading\u2026" }) });
29197
+ return /* @__PURE__ */ jsxRuntime.jsx(ScrollArea, { className: cn("h-full min-h-0", className), children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-3 py-4 text-sm opacity-70", children: "Loading\u2026" }) });
29076
29198
  }
29077
29199
  if (!options.length) {
29078
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("h-full min-h-0 overflow-y-auto", className), children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-3 py-4 text-sm opacity-70", children: "No results" }) });
29200
+ return /* @__PURE__ */ jsxRuntime.jsx(ScrollArea, { className: cn("h-full min-h-0", className), children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-3 py-4 text-sm opacity-70", children: "No results" }) });
29079
29201
  }
29080
29202
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("h-full min-h-0 overflow-hidden", className), children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full min-h-0 p-1", children: /* @__PURE__ */ jsxRuntime.jsx(
29081
29203
  reactVirtuoso.Virtuoso,