@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.mjs CHANGED
@@ -10,15 +10,16 @@ import { Slot } from '@radix-ui/react-slot';
10
10
  import * as SwitchPrimitive from '@radix-ui/react-switch';
11
11
  import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
12
12
  import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
13
+ import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
13
14
  import { Virtuoso, VirtuosoGrid } from 'react-virtuoso';
14
15
  import * as SliderPrimitive from '@radix-ui/react-slider';
15
16
  import * as DialogPrimitive from '@radix-ui/react-dialog';
16
- import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
17
17
  import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group';
18
18
  import '@radix-ui/react-toggle';
19
19
  import * as TooltipPrimitive from '@radix-ui/react-tooltip';
20
20
  import Editor from '@toast-ui/editor';
21
21
  import '@toast-ui/editor/dist/toastui-editor.css';
22
+ import '@toast-ui/editor/dist/theme/toastui-editor-dark.css';
22
23
  import Ajv from 'ajv';
23
24
  import { Icon as Icon$1 } from '@iconify/react';
24
25
  import * as LabelPrimitive from '@radix-ui/react-label';
@@ -10740,6 +10741,7 @@ var Input = React74.forwardRef(
10740
10741
  "data-size": sizeKey,
10741
10742
  "data-density": densityKey,
10742
10743
  placeholder,
10744
+ ...rest,
10743
10745
  value: displayValue,
10744
10746
  onChange,
10745
10747
  onBlur,
@@ -10747,8 +10749,7 @@ var Input = React74.forwardRef(
10747
10749
  onKeyDown: handleKeyDownWrapped,
10748
10750
  onKeyPress: handleKeyPressWrapped,
10749
10751
  onBeforeInput: handleBeforeInputWrapped,
10750
- onPaste: handlePasteWrapped,
10751
- ...rest
10752
+ onPaste: handlePasteWrapped
10752
10753
  }
10753
10754
  )
10754
10755
  );
@@ -11025,6 +11026,12 @@ var Input = React74.forwardRef(
11025
11026
  ] });
11026
11027
  }
11027
11028
  );
11029
+ function stripAffixes(value, prefix, suffix) {
11030
+ let out = value != null ? value : "";
11031
+ if (prefix && out.startsWith(prefix)) out = out.slice(prefix.length);
11032
+ if (suffix && out.endsWith(suffix)) out = out.slice(0, -suffix.length);
11033
+ return out;
11034
+ }
11028
11035
  var ShadcnTextVariant = React74.forwardRef(function ShadcnTextVariant2(props, forwardedRef) {
11029
11036
  const {
11030
11037
  // form-level props
@@ -11108,7 +11115,12 @@ var ShadcnTextVariant = React74.forwardRef(function ShadcnTextVariant2(props, fo
11108
11115
  (e4) => {
11109
11116
  var _a, _b, _c;
11110
11117
  const maskedValue = (_a = e4.value) != null ? _a : "";
11111
- const unmaskedInner = (_c = (_b = maskedValue.match(/[0-9A-Za-z]/g)) == null ? void 0 : _b.join("")) != null ? _c : "";
11118
+ const maskedValueWithoutAffixes = stripAffixes(
11119
+ maskedValue,
11120
+ prefix,
11121
+ suffix
11122
+ );
11123
+ const unmaskedInner = (_c = (_b = maskedValueWithoutAffixes.match(/[0-9A-Za-z]/g)) == null ? void 0 : _b.join("")) != null ? _c : "";
11112
11124
  const mode = unmask === true || unmask === "raw" ? "raw" : "masked";
11113
11125
  const detail = {
11114
11126
  source: "variant",
@@ -11247,7 +11259,7 @@ function getDecimalSeparator(locale) {
11247
11259
  const m2 = s3.match(/1(.?)1/);
11248
11260
  return (m2 == null ? void 0 : m2[1]) || ".";
11249
11261
  }
11250
- function stripAffixes(text, prefix, suffix) {
11262
+ function stripAffixes2(text, prefix, suffix) {
11251
11263
  let t4 = text != null ? text : "";
11252
11264
  if (prefix && t4.startsWith(prefix)) t4 = t4.slice(prefix.length);
11253
11265
  if (suffix && t4.endsWith(suffix)) t4 = t4.slice(0, -suffix.length);
@@ -11441,7 +11453,7 @@ var InputNumber = React74.memo(
11441
11453
  );
11442
11454
  const getModelFromDisplay = React74.useCallback(
11443
11455
  (text) => {
11444
- const stripped = stripAffixes(text, props.prefix, props.suffix);
11456
+ const stripped = stripAffixes2(text, props.prefix, props.suffix);
11445
11457
  const withoutGroup = stripGrouping(stripped, locale);
11446
11458
  const candidate = decimalSep !== "." ? withoutGroup.replace(".", decimalSep) : withoutGroup;
11447
11459
  const n3 = parseEditable(candidate, locale, decimalSep);
@@ -11479,7 +11491,7 @@ var InputNumber = React74.memo(
11479
11491
  setFocused(true);
11480
11492
  (_a2 = props.onFocus) == null ? void 0 : _a2.call(props, e4);
11481
11493
  const model = isFiniteNumber(props.value) ? clampModel(props.value) : getModelFromDisplay(display);
11482
- const editable = model == null ? stripAffixes(display, props.prefix, props.suffix) : toEditableFromNumber(model);
11494
+ const editable = model == null ? stripAffixes2(display, props.prefix, props.suffix) : toEditableFromNumber(model);
11483
11495
  const normalized = normalizeEditable(
11484
11496
  editable,
11485
11497
  locale,
@@ -11496,7 +11508,7 @@ var InputNumber = React74.memo(
11496
11508
  var _a2, _b;
11497
11509
  setFocused(false);
11498
11510
  const el = e4.currentTarget;
11499
- const raw = stripAffixes(el.value, props.prefix, props.suffix);
11511
+ const raw = stripAffixes2(el.value, props.prefix, props.suffix);
11500
11512
  const normalized = normalizeEditable(
11501
11513
  raw,
11502
11514
  locale,
@@ -11518,7 +11530,7 @@ var InputNumber = React74.memo(
11518
11530
  if (props.disabled || props.readOnly) return;
11519
11531
  const el = e4.currentTarget;
11520
11532
  const caretBefore = (_a2 = el.selectionStart) != null ? _a2 : el.value.length;
11521
- const stripped = stripAffixes(el.value, props.prefix, props.suffix);
11533
+ const stripped = stripAffixes2(el.value, props.prefix, props.suffix);
11522
11534
  let next = normalizeEditable(
11523
11535
  stripped,
11524
11536
  locale,
@@ -12442,14 +12454,18 @@ function applyMask(mask, raw, keepCharPositions) {
12442
12454
  function digitsOnly(input) {
12443
12455
  return (input != null ? input : "").replace(/\D+/g, "");
12444
12456
  }
12457
+ function normalizeDial(dial) {
12458
+ return digitsOnly(dial != null ? dial : "");
12459
+ }
12445
12460
  function dialPrefixFor(country) {
12446
- return `+${country.dial} `;
12461
+ return `+${normalizeDial(country.dial)} `;
12447
12462
  }
12448
12463
  function valueToNationalDigits(value, country) {
12449
12464
  const digits = digitsOnly(value);
12450
12465
  if (!digits) return "";
12451
- if (digits.startsWith(country.dial)) {
12452
- return digits.slice(country.dial.length);
12466
+ const dial = normalizeDial(country.dial);
12467
+ if (dial && digits.startsWith(dial)) {
12468
+ return digits.slice(dial.length);
12453
12469
  }
12454
12470
  return digits;
12455
12471
  }
@@ -12469,8 +12485,9 @@ function computeDisplayFromValue(value, country, keepCharPositions) {
12469
12485
  function computeNextFromInput(rawInput, country, mode, keepCharPositions) {
12470
12486
  const prefix = dialPrefixFor(country);
12471
12487
  let national = digitsOnly(rawInput);
12472
- if (national.startsWith(country.dial)) {
12473
- national = national.slice(country.dial.length);
12488
+ const dial = normalizeDial(country.dial);
12489
+ if (dial && national.startsWith(dial)) {
12490
+ national = national.slice(dial.length);
12474
12491
  }
12475
12492
  const mask = compileMask(country.mask);
12476
12493
  const maskedNational = applyMask(mask, national, keepCharPositions);
@@ -12481,7 +12498,7 @@ function computeNextFromInput(rawInput, country, mode, keepCharPositions) {
12481
12498
  } else if (mode === "masked") {
12482
12499
  nextValue = display;
12483
12500
  } else if (mode === "e164") {
12484
- nextValue = country.dial + national;
12501
+ nextValue = dial + national;
12485
12502
  } else {
12486
12503
  nextValue = national;
12487
12504
  }
@@ -12494,8 +12511,10 @@ function remapToCountry(value, from, to, mode, keepCharPositions) {
12494
12511
  }
12495
12512
  const digitsAll = digitsOnly(value);
12496
12513
  let national = digitsAll;
12497
- if (digitsAll.startsWith(from.dial)) {
12498
- national = digitsAll.slice(from.dial.length);
12514
+ const fromDial = normalizeDial(from.dial);
12515
+ const toDial = normalizeDial(to.dial);
12516
+ if (fromDial && digitsAll.startsWith(fromDial)) {
12517
+ national = digitsAll.slice(fromDial.length);
12499
12518
  }
12500
12519
  const prefix = dialPrefixFor(to);
12501
12520
  const mask = compileMask(to.mask);
@@ -12507,7 +12526,7 @@ function remapToCountry(value, from, to, mode, keepCharPositions) {
12507
12526
  } else if (mode === "masked") {
12508
12527
  nextValue = display;
12509
12528
  } else if (mode === "e164") {
12510
- nextValue = to.dial + national;
12529
+ nextValue = toDial + national;
12511
12530
  } else {
12512
12531
  nextValue = national;
12513
12532
  }
@@ -12536,7 +12555,7 @@ var CountrySelect = ({
12536
12555
  const selected = (_b = (_a = countries.find((c2) => c2.code === value)) != null ? _a : countries[0]) != null ? _b : null;
12537
12556
  const triggerLabel = selected ? [
12538
12557
  showFlag && selected.flag ? selected.flag : null,
12539
- showSelectedDial ? `+${selected.dial}` : null,
12558
+ showSelectedDial ? `+${normalizeDial(selected.dial)}` : null,
12540
12559
  showSelectedLabel ? selected.label : null
12541
12560
  ].filter(Boolean).join(" ") : "";
12542
12561
  return /* @__PURE__ */ jsx("div", { className: countrySelectClassName, children: /* @__PURE__ */ jsxs(Select, { value: (_c = selected == null ? void 0 : selected.code) != null ? _c : "", onValueChange: onChange, children: [
@@ -12563,7 +12582,7 @@ var CountrySelect = ({
12563
12582
  parts.push(String(c2.flag));
12564
12583
  }
12565
12584
  if (showDialInList) {
12566
- parts.push(`${c2.dial}`);
12585
+ parts.push(`+${normalizeDial(c2.dial)}`);
12567
12586
  }
12568
12587
  parts.push(c2.label);
12569
12588
  return /* @__PURE__ */ jsx(
@@ -20506,6 +20525,7 @@ function normalizeItems2(items, mappers, optionValueKey, optionLabelKey, optionT
20506
20525
  });
20507
20526
  }
20508
20527
  return items.map((item, index) => {
20528
+ var _a;
20509
20529
  if (typeof item === "string" || typeof item === "number" || typeof item === "boolean") {
20510
20530
  const v2 = item;
20511
20531
  return {
@@ -20518,12 +20538,19 @@ function normalizeItems2(items, mappers, optionValueKey, optionLabelKey, optionT
20518
20538
  raw: item
20519
20539
  };
20520
20540
  }
20521
- return item;
20541
+ const existing = item;
20542
+ return {
20543
+ ...existing,
20544
+ raw: (_a = existing.raw) != null ? _a : item
20545
+ };
20522
20546
  });
20523
20547
  }
20524
20548
  function isEqualValue2(a3, b2) {
20525
20549
  return Object.is(a3, b2);
20526
20550
  }
20551
+ function valueLookupKey(value) {
20552
+ return `${typeof value}:${String(value)}`;
20553
+ }
20527
20554
  function asGroupValue(value) {
20528
20555
  if (!value) return void 0;
20529
20556
  if (Array.isArray(value)) {
@@ -20537,13 +20564,14 @@ function asGroupValue(value) {
20537
20564
  state: true
20538
20565
  }));
20539
20566
  }
20540
- if (typeof value == "object")
20541
- return Object.keys(value).map(
20567
+ if (typeof value == "object") {
20568
+ return Reflect.ownKeys(value).map(
20542
20569
  (key) => ({
20543
20570
  value: key,
20544
20571
  state: value[key]
20545
20572
  })
20546
20573
  );
20574
+ }
20547
20575
  return void 0;
20548
20576
  }
20549
20577
  function asSingleValue(value) {
@@ -20702,7 +20730,32 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
20702
20730
  }
20703
20731
  );
20704
20732
  }
20705
- const groupValue = asGroupValue(value);
20733
+ const normalizedByValueKey = React74.useMemo(() => {
20734
+ const lookup = /* @__PURE__ */ new Map();
20735
+ normalized.forEach((item) => {
20736
+ lookup.set(valueLookupKey(item.value), item);
20737
+ });
20738
+ return lookup;
20739
+ }, [normalized]);
20740
+ const groupValue = React74.useMemo(() => {
20741
+ const source = asGroupValue(value);
20742
+ if (!(source == null ? void 0 : source.length)) return source;
20743
+ return source.map((entry) => {
20744
+ const byExact = normalized.find(
20745
+ (item) => isEqualValue2(item.value, entry.value)
20746
+ );
20747
+ if (byExact) return { ...entry, value: byExact.value };
20748
+ const byKey = normalizedByValueKey.get(valueLookupKey(entry.value));
20749
+ if (byKey) return { ...entry, value: byKey.value };
20750
+ if (typeof entry.value === "string") {
20751
+ const byString = normalized.find(
20752
+ (item) => typeof item.value !== "object" && String(item.value) === entry.value
20753
+ );
20754
+ if (byString) return { ...entry, value: byString.value };
20755
+ }
20756
+ return entry;
20757
+ });
20758
+ }, [value, normalized, normalizedByValueKey]);
20706
20759
  const {
20707
20760
  groupStyle,
20708
20761
  groupClasses,
@@ -20803,10 +20856,13 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
20803
20856
  raw: nextList,
20804
20857
  selectedOptions: nextList.map(
20805
20858
  (entry) => {
20806
- var _a, _b;
20807
- return (_b = (_a = normalized.find(
20859
+ var _a, _b, _c;
20860
+ const normalizedItem = (_a = normalizedByValueKey.get(
20861
+ valueLookupKey(entry.value)
20862
+ )) != null ? _a : normalized.find(
20808
20863
  (item) => isEqualValue2(item.value, entry.value)
20809
- )) == null ? void 0 : _a.raw) != null ? _b : entry.value;
20864
+ );
20865
+ return (_c = (_b = normalizedItem == null ? void 0 : normalizedItem.raw) != null ? _b : normalizedItem) != null ? _c : entry.value;
20810
20866
  }
20811
20867
  ),
20812
20868
  nativeEvent: void 0,
@@ -20822,7 +20878,7 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
20822
20878
  }
20823
20879
  onValue(nextList.map((item) => item.value), detail);
20824
20880
  },
20825
- [onValue, disabled, groupValue, normalized, hasAnyTristate]
20881
+ [onValue, disabled, groupValue, normalizedByValueKey, normalized, hasAnyTristate]
20826
20882
  );
20827
20883
  return /* @__PURE__ */ jsx(
20828
20884
  "div",
@@ -20994,6 +21050,59 @@ var checkboxModule = {
20994
21050
  tags: ["checkbox", "group", "boolean", "tri-state"]
20995
21051
  }
20996
21052
  };
21053
+ function ScrollArea({
21054
+ className,
21055
+ children,
21056
+ ...props
21057
+ }) {
21058
+ return /* @__PURE__ */ jsxs(
21059
+ ScrollAreaPrimitive.Root,
21060
+ {
21061
+ "data-slot": "scroll-area",
21062
+ className: cn("relative", className),
21063
+ ...props,
21064
+ children: [
21065
+ /* @__PURE__ */ jsx(
21066
+ ScrollAreaPrimitive.Viewport,
21067
+ {
21068
+ "data-slot": "scroll-area-viewport",
21069
+ className: "focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",
21070
+ children
21071
+ }
21072
+ ),
21073
+ /* @__PURE__ */ jsx(ScrollBar, {}),
21074
+ /* @__PURE__ */ jsx(ScrollAreaPrimitive.Corner, {})
21075
+ ]
21076
+ }
21077
+ );
21078
+ }
21079
+ function ScrollBar({
21080
+ className,
21081
+ orientation = "vertical",
21082
+ ...props
21083
+ }) {
21084
+ return /* @__PURE__ */ jsx(
21085
+ ScrollAreaPrimitive.ScrollAreaScrollbar,
21086
+ {
21087
+ "data-slot": "scroll-area-scrollbar",
21088
+ orientation,
21089
+ className: cn(
21090
+ "flex touch-none p-px transition-colors select-none",
21091
+ orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent",
21092
+ orientation === "horizontal" && "h-2.5 flex-col border-t border-t-transparent",
21093
+ className
21094
+ ),
21095
+ ...props,
21096
+ children: /* @__PURE__ */ jsx(
21097
+ ScrollAreaPrimitive.ScrollAreaThumb,
21098
+ {
21099
+ "data-slot": "scroll-area-thumb",
21100
+ className: "bg-border relative flex-1 rounded-full"
21101
+ }
21102
+ )
21103
+ }
21104
+ );
21105
+ }
20997
21106
  function normalizeOptions(opts, config) {
20998
21107
  return globalNormalizeOptions(opts, config);
20999
21108
  }
@@ -21407,7 +21516,7 @@ var ShadcnSelectVariant = React74.forwardRef(function ShadcnSelectVariant2(props
21407
21516
  }
21408
21517
  }
21409
21518
  )
21410
- ) : /* @__PURE__ */ jsx("div", { className: "max-h-60 overflow-auto", children: filteredItems.map((item, index) => {
21519
+ ) : /* @__PURE__ */ jsx(ScrollArea, { className: "max-h-60", children: /* @__PURE__ */ jsx("div", { children: filteredItems.map((item, index) => {
21411
21520
  var _a2, _b2;
21412
21521
  const optionNode = /* @__PURE__ */ jsx(
21413
21522
  SelectItem,
@@ -21462,7 +21571,7 @@ var ShadcnSelectVariant = React74.forwardRef(function ShadcnSelectVariant2(props
21462
21571
  setQuery("");
21463
21572
  }
21464
21573
  });
21465
- }) })
21574
+ }) }) })
21466
21575
  )
21467
21576
  ] })
21468
21577
  ]
@@ -23466,7 +23575,7 @@ var ShadcnKeyValueVariant = React74.forwardRef(function ShadcnKeyValueVariant2(p
23466
23575
  }
23467
23576
  )
23468
23577
  ] }),
23469
- items.length === 0 ? /* @__PURE__ */ jsx("div", { className: "rounded-md border border-border/50 px-3 py-6 text-center text-sm text-muted-foreground", children: emptyLabel }) : /* @__PURE__ */ jsx("div", { className: "max-h-64 overflow-auto rounded-md border border-border/50", children: /* @__PURE__ */ jsx("div", { className: "divide-y divide-border/50", children: items.map((pair, index) => /* @__PURE__ */ jsxs(
23578
+ items.length === 0 ? /* @__PURE__ */ jsx("div", { className: "rounded-md border border-border/50 px-3 py-6 text-center text-sm text-muted-foreground", children: emptyLabel }) : /* @__PURE__ */ jsx(ScrollArea, { className: "max-h-64 rounded-md border border-border/50", children: /* @__PURE__ */ jsx("div", { className: "divide-y divide-border/50", children: items.map((pair, index) => /* @__PURE__ */ jsxs(
23470
23579
  "div",
23471
23580
  {
23472
23581
  className: "flex items-center justify-between gap-2 px-2 py-1.5",
@@ -24405,59 +24514,6 @@ var treeselectModule = {
24405
24514
  Variant: treeselect_default
24406
24515
  };
24407
24516
  var treeselect_default2 = treeselectModule;
24408
- function ScrollArea({
24409
- className,
24410
- children,
24411
- ...props
24412
- }) {
24413
- return /* @__PURE__ */ jsxs(
24414
- ScrollAreaPrimitive.Root,
24415
- {
24416
- "data-slot": "scroll-area",
24417
- className: cn("relative", className),
24418
- ...props,
24419
- children: [
24420
- /* @__PURE__ */ jsx(
24421
- ScrollAreaPrimitive.Viewport,
24422
- {
24423
- "data-slot": "scroll-area-viewport",
24424
- className: "focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",
24425
- children
24426
- }
24427
- ),
24428
- /* @__PURE__ */ jsx(ScrollBar, {}),
24429
- /* @__PURE__ */ jsx(ScrollAreaPrimitive.Corner, {})
24430
- ]
24431
- }
24432
- );
24433
- }
24434
- function ScrollBar({
24435
- className,
24436
- orientation = "vertical",
24437
- ...props
24438
- }) {
24439
- return /* @__PURE__ */ jsx(
24440
- ScrollAreaPrimitive.ScrollAreaScrollbar,
24441
- {
24442
- "data-slot": "scroll-area-scrollbar",
24443
- orientation,
24444
- className: cn(
24445
- "flex touch-none p-px transition-colors select-none",
24446
- orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent",
24447
- orientation === "horizontal" && "h-2.5 flex-col border-t border-t-transparent",
24448
- className
24449
- ),
24450
- ...props,
24451
- children: /* @__PURE__ */ jsx(
24452
- ScrollAreaPrimitive.ScrollAreaThumb,
24453
- {
24454
- "data-slot": "scroll-area-thumb",
24455
- className: "bg-border relative flex-1 rounded-full"
24456
- }
24457
- )
24458
- }
24459
- );
24460
- }
24461
24517
  function fileId() {
24462
24518
  return `file_${Math.random().toString(36).slice(2)}`;
24463
24519
  }
@@ -25768,7 +25824,7 @@ var ShadcnToggleVariant3 = React74.forwardRef(function ShadcnToggleVariant4(prop
25768
25824
  size = "md",
25769
25825
  options = [],
25770
25826
  multiple = false,
25771
- variant = "default",
25827
+ design = "default",
25772
25828
  layout = "horizontal",
25773
25829
  gridCols = 2,
25774
25830
  fillWidth: fullWidth = false,
@@ -25872,7 +25928,6 @@ var ShadcnToggleVariant3 = React74.forwardRef(function ShadcnToggleVariant4(prop
25872
25928
  fullWidth && layout === "vertical" && "[&>*]:w-full",
25873
25929
  className
25874
25930
  );
25875
- console.log(layoutClasses, fullWidth, autoCap);
25876
25931
  const groupStyle = React74.useMemo(() => {
25877
25932
  const style = {};
25878
25933
  if (layout === "grid") {
@@ -25891,7 +25946,7 @@ var ShadcnToggleVariant3 = React74.forwardRef(function ShadcnToggleVariant4(prop
25891
25946
  value: currentValue,
25892
25947
  onValueChange: handleChange,
25893
25948
  disabled: isDisabled,
25894
- variant,
25949
+ variant: design,
25895
25950
  size: toggleSize,
25896
25951
  className: layoutClasses,
25897
25952
  style: groupStyle,
@@ -25933,7 +25988,7 @@ var ShadcnToggleVariant3 = React74.forwardRef(function ShadcnToggleVariant4(prop
25933
25988
  // Error State
25934
25989
  error && "border-destructive/50 hover:bg-destructive/10 data-[state=on]:bg-destructive data-[state=on]:text-destructive-foreground",
25935
25990
  // Variant: Outline specific tweaks
25936
- variant === "outline" && layout === "horizontal" && !fullWidth && "first:rounded-l-md last:rounded-r-md rounded-none border-l-0 first:border-l",
25991
+ design === "outline" && layout === "horizontal" && !fullWidth && "first:rounded-l-md last:rounded-r-md rounded-none border-l-0 first:border-l",
25937
25992
  // Layout tweaks
25938
25993
  fullWidth && "justify-center",
25939
25994
  // Custom Item Class
@@ -25968,6 +26023,30 @@ var toggleGroupModule = {
25968
26023
  tags: ["buttons", "toggle"]
25969
26024
  }
25970
26025
  };
26026
+ function isDarkThemedElement(el) {
26027
+ if (!el) return false;
26028
+ if (el.classList.contains("dark")) return true;
26029
+ const dataTheme = el.getAttribute("data-theme");
26030
+ return dataTheme === "dark";
26031
+ }
26032
+ function resolveAutoDarkFromHost(host, target) {
26033
+ if (typeof document === "undefined") return false;
26034
+ if (target === "document") {
26035
+ return isDarkThemedElement(document.documentElement) || isDarkThemedElement(document.body);
26036
+ }
26037
+ let node = host != null ? host : null;
26038
+ while (node) {
26039
+ const isEditorMarker = node.hasAttribute("data-editor-theme");
26040
+ if (!isEditorMarker) {
26041
+ if (node.classList.contains("dark")) return true;
26042
+ if (node.hasAttribute("data-theme")) {
26043
+ return node.getAttribute("data-theme") === "dark";
26044
+ }
26045
+ }
26046
+ node = node.parentElement;
26047
+ }
26048
+ return isDarkThemedElement(document.documentElement) || isDarkThemedElement(document.body);
26049
+ }
25971
26050
  function ShadcnEditorVariant(props) {
25972
26051
  const {
25973
26052
  value,
@@ -25986,7 +26065,9 @@ function ShadcnEditorVariant(props) {
25986
26065
  useCommandShortcut = true,
25987
26066
  format: format2 = "html",
25988
26067
  toolbar = "default",
25989
- pastePlainText = false
26068
+ pastePlainText = false,
26069
+ theme = "auto",
26070
+ themeTarget = "nearest"
25990
26071
  } = props;
25991
26072
  const mountRef = React74.useRef(null);
25992
26073
  const editorRef = React74.useRef(null);
@@ -25994,9 +26075,13 @@ function ShadcnEditorVariant(props) {
25994
26075
  const onValueRef = React74.useRef(onValue);
25995
26076
  const syncingRef = React74.useRef(false);
25996
26077
  const loadedRef = React74.useRef(false);
26078
+ const lastContentRef = React74.useRef(value != null ? value : "");
26079
+ const [autoDark, setAutoDark] = React74.useState(false);
25997
26080
  formatRef.current = format2;
25998
26081
  onValueRef.current = onValue;
26082
+ if (value !== void 0) lastContentRef.current = value;
25999
26083
  const effectiveReadOnly = Boolean(disabled || readOnly);
26084
+ const effectiveTheme = theme === "auto" ? autoDark ? "dark" : "light" : theme;
26000
26085
  const readContent = React74.useCallback((ed) => {
26001
26086
  var _a, _b;
26002
26087
  return formatRef.current === "markdown" ? (_a = ed.getMarkdown()) != null ? _a : "" : (_b = ed.getHTML()) != null ? _b : "";
@@ -26008,9 +26093,40 @@ function ShadcnEditorVariant(props) {
26008
26093
  }, []);
26009
26094
  const structuralKey = React74.useMemo(() => {
26010
26095
  const hideModeSwitch = toolbar === "none" || pastePlainText;
26011
- return JSON.stringify({ toolbar, useCommandShortcut, hideModeSwitch });
26012
- }, [toolbar, useCommandShortcut, pastePlainText]);
26096
+ return JSON.stringify({
26097
+ toolbar,
26098
+ useCommandShortcut,
26099
+ hideModeSwitch,
26100
+ effectiveTheme
26101
+ });
26102
+ }, [toolbar, useCommandShortcut, pastePlainText, effectiveTheme]);
26013
26103
  React74.useEffect(() => {
26104
+ if (theme !== "auto") return;
26105
+ if (typeof document === "undefined") return;
26106
+ const host = mountRef.current;
26107
+ const recompute = () => {
26108
+ setAutoDark(resolveAutoDarkFromHost(host, themeTarget));
26109
+ };
26110
+ recompute();
26111
+ const observer = new MutationObserver(() => {
26112
+ recompute();
26113
+ });
26114
+ observer.observe(document.documentElement, {
26115
+ attributes: true,
26116
+ subtree: true,
26117
+ attributeFilter: ["class", "data-theme"]
26118
+ });
26119
+ if (document.body) {
26120
+ observer.observe(document.body, {
26121
+ attributes: true,
26122
+ subtree: true,
26123
+ attributeFilter: ["class", "data-theme"]
26124
+ });
26125
+ }
26126
+ return () => observer.disconnect();
26127
+ }, [theme, themeTarget]);
26128
+ React74.useEffect(() => {
26129
+ var _a;
26014
26130
  const el = mountRef.current;
26015
26131
  if (!el) return;
26016
26132
  if (editorRef.current) {
@@ -26034,13 +26150,14 @@ function ShadcnEditorVariant(props) {
26034
26150
  const options = {
26035
26151
  el,
26036
26152
  height,
26037
- initialValue: value != null ? value : "",
26153
+ initialValue: (_a = value != null ? value : lastContentRef.current) != null ? _a : "",
26038
26154
  previewStyle,
26039
26155
  initialEditType: editType,
26040
26156
  useCommandShortcut,
26041
26157
  usageStatistics: false,
26042
26158
  placeholder,
26043
26159
  hideModeSwitch,
26160
+ ...effectiveTheme === "dark" ? { theme: "dark" } : {},
26044
26161
  ...toolbar === "none" ? { toolbarItems: [] } : Array.isArray(toolbar) ? { toolbarItems: toolbar } : {},
26045
26162
  events: {
26046
26163
  load: () => {
@@ -26051,7 +26168,9 @@ function ShadcnEditorVariant(props) {
26051
26168
  const ed = editorRef.current;
26052
26169
  if (!ed) return;
26053
26170
  if (syncingRef.current) return;
26054
- emit(readContent(ed));
26171
+ const next = readContent(ed);
26172
+ lastContentRef.current = next;
26173
+ emit(next);
26055
26174
  }
26056
26175
  }
26057
26176
  };
@@ -26112,6 +26231,7 @@ function ShadcnEditorVariant(props) {
26112
26231
  const cur = (_d = (_c = ed.getHTML) == null ? void 0 : _c.call(ed)) != null ? _d : "";
26113
26232
  if (cur !== next) ed.setHTML(next, false);
26114
26233
  }
26234
+ lastContentRef.current = next;
26115
26235
  Promise.resolve().then(() => {
26116
26236
  syncingRef.current = false;
26117
26237
  });
@@ -26135,6 +26255,8 @@ function ShadcnEditorVariant(props) {
26135
26255
  {
26136
26256
  "data-size": size,
26137
26257
  "data-density": density,
26258
+ "data-theme": effectiveTheme,
26259
+ "data-editor-theme": effectiveTheme,
26138
26260
  className: cn(
26139
26261
  "rounded-md border border-input bg-background overflow-hidden",
26140
26262
  effectiveReadOnly && "opacity-60 pointer-events-none",
@@ -29028,16 +29150,16 @@ function OptionList(props) {
29028
29150
  [draft, isMulti]
29029
29151
  );
29030
29152
  if (s3 == null ? void 0 : s3.errorCode) {
29031
- return /* @__PURE__ */ jsx("div", { className: cn("h-full min-h-0 overflow-y-auto", className), children: /* @__PURE__ */ jsxs("div", { className: "px-3 py-4 text-sm opacity-70", children: [
29153
+ return /* @__PURE__ */ jsx(ScrollArea, { className: cn("h-full min-h-0", className), children: /* @__PURE__ */ jsxs("div", { className: "px-3 py-4 text-sm opacity-70", children: [
29032
29154
  "Error: ",
29033
29155
  String(s3.errorCode)
29034
29156
  ] }) });
29035
29157
  }
29036
29158
  if ((s3 == null ? void 0 : s3.loading) && !((_b = s3 == null ? void 0 : s3.optionsList) == null ? void 0 : _b.length)) {
29037
- return /* @__PURE__ */ jsx("div", { className: cn("h-full min-h-0 overflow-y-auto", className), children: /* @__PURE__ */ jsx("div", { className: "px-3 py-4 text-sm opacity-70", children: "Loading\u2026" }) });
29159
+ return /* @__PURE__ */ jsx(ScrollArea, { className: cn("h-full min-h-0", className), children: /* @__PURE__ */ jsx("div", { className: "px-3 py-4 text-sm opacity-70", children: "Loading\u2026" }) });
29038
29160
  }
29039
29161
  if (!options.length) {
29040
- return /* @__PURE__ */ jsx("div", { className: cn("h-full min-h-0 overflow-y-auto", className), children: /* @__PURE__ */ jsx("div", { className: "px-3 py-4 text-sm opacity-70", children: "No results" }) });
29162
+ return /* @__PURE__ */ jsx(ScrollArea, { className: cn("h-full min-h-0", className), children: /* @__PURE__ */ jsx("div", { className: "px-3 py-4 text-sm opacity-70", children: "No results" }) });
29041
29163
  }
29042
29164
  return /* @__PURE__ */ jsx("div", { className: cn("h-full min-h-0 overflow-hidden", className), children: /* @__PURE__ */ jsx("div", { className: "h-full min-h-0 p-1", children: /* @__PURE__ */ jsx(
29043
29165
  Virtuoso,