@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/index.mjs CHANGED
@@ -7,15 +7,16 @@ import { Slot } from '@radix-ui/react-slot';
7
7
  import * as SwitchPrimitive from '@radix-ui/react-switch';
8
8
  import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
9
9
  import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
10
+ import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
10
11
  import { Virtuoso, VirtuosoGrid } from 'react-virtuoso';
11
12
  import * as SliderPrimitive from '@radix-ui/react-slider';
12
13
  import * as DialogPrimitive from '@radix-ui/react-dialog';
13
- import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
14
14
  import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group';
15
15
  import '@radix-ui/react-toggle';
16
16
  import * as TooltipPrimitive from '@radix-ui/react-tooltip';
17
17
  import Editor from '@toast-ui/editor';
18
18
  import '@toast-ui/editor/dist/toastui-editor.css';
19
+ import '@toast-ui/editor/dist/theme/toastui-editor-dark.css';
19
20
  import * as SeparatorPrimitive from '@radix-ui/react-separator';
20
21
  import Ajv from 'ajv';
21
22
  import { Icon as Icon$1 } from '@iconify/react';
@@ -11817,6 +11818,7 @@ var Input = React66.forwardRef(
11817
11818
  "data-size": sizeKey,
11818
11819
  "data-density": densityKey,
11819
11820
  placeholder,
11821
+ ...rest,
11820
11822
  value: displayValue,
11821
11823
  onChange,
11822
11824
  onBlur,
@@ -11824,8 +11826,7 @@ var Input = React66.forwardRef(
11824
11826
  onKeyDown: handleKeyDownWrapped,
11825
11827
  onKeyPress: handleKeyPressWrapped,
11826
11828
  onBeforeInput: handleBeforeInputWrapped,
11827
- onPaste: handlePasteWrapped,
11828
- ...rest
11829
+ onPaste: handlePasteWrapped
11829
11830
  }
11830
11831
  )
11831
11832
  );
@@ -12102,6 +12103,12 @@ var Input = React66.forwardRef(
12102
12103
  ] });
12103
12104
  }
12104
12105
  );
12106
+ function stripAffixes(value, prefix, suffix) {
12107
+ let out = value != null ? value : "";
12108
+ if (prefix && out.startsWith(prefix)) out = out.slice(prefix.length);
12109
+ if (suffix && out.endsWith(suffix)) out = out.slice(0, -suffix.length);
12110
+ return out;
12111
+ }
12105
12112
  var ShadcnTextVariant = React66.forwardRef(function ShadcnTextVariant2(props, forwardedRef) {
12106
12113
  const {
12107
12114
  // form-level props
@@ -12185,7 +12192,12 @@ var ShadcnTextVariant = React66.forwardRef(function ShadcnTextVariant2(props, fo
12185
12192
  (e4) => {
12186
12193
  var _a, _b, _c;
12187
12194
  const maskedValue = (_a = e4.value) != null ? _a : "";
12188
- const unmaskedInner = (_c = (_b = maskedValue.match(/[0-9A-Za-z]/g)) == null ? void 0 : _b.join("")) != null ? _c : "";
12195
+ const maskedValueWithoutAffixes = stripAffixes(
12196
+ maskedValue,
12197
+ prefix,
12198
+ suffix
12199
+ );
12200
+ const unmaskedInner = (_c = (_b = maskedValueWithoutAffixes.match(/[0-9A-Za-z]/g)) == null ? void 0 : _b.join("")) != null ? _c : "";
12189
12201
  const mode = unmask === true || unmask === "raw" ? "raw" : "masked";
12190
12202
  const detail = {
12191
12203
  source: "variant",
@@ -12324,7 +12336,7 @@ function getDecimalSeparator(locale) {
12324
12336
  const m2 = s3.match(/1(.?)1/);
12325
12337
  return (m2 == null ? void 0 : m2[1]) || ".";
12326
12338
  }
12327
- function stripAffixes(text, prefix, suffix) {
12339
+ function stripAffixes2(text, prefix, suffix) {
12328
12340
  let t4 = text != null ? text : "";
12329
12341
  if (prefix && t4.startsWith(prefix)) t4 = t4.slice(prefix.length);
12330
12342
  if (suffix && t4.endsWith(suffix)) t4 = t4.slice(0, -suffix.length);
@@ -12518,7 +12530,7 @@ var InputNumber = React66.memo(
12518
12530
  );
12519
12531
  const getModelFromDisplay = React66.useCallback(
12520
12532
  (text) => {
12521
- const stripped = stripAffixes(text, props.prefix, props.suffix);
12533
+ const stripped = stripAffixes2(text, props.prefix, props.suffix);
12522
12534
  const withoutGroup = stripGrouping(stripped, locale);
12523
12535
  const candidate = decimalSep !== "." ? withoutGroup.replace(".", decimalSep) : withoutGroup;
12524
12536
  const n3 = parseEditable(candidate, locale, decimalSep);
@@ -12556,7 +12568,7 @@ var InputNumber = React66.memo(
12556
12568
  setFocused(true);
12557
12569
  (_a2 = props.onFocus) == null ? void 0 : _a2.call(props, e4);
12558
12570
  const model = isFiniteNumber(props.value) ? clampModel(props.value) : getModelFromDisplay(display);
12559
- const editable = model == null ? stripAffixes(display, props.prefix, props.suffix) : toEditableFromNumber(model);
12571
+ const editable = model == null ? stripAffixes2(display, props.prefix, props.suffix) : toEditableFromNumber(model);
12560
12572
  const normalized = normalizeEditable(
12561
12573
  editable,
12562
12574
  locale,
@@ -12573,7 +12585,7 @@ var InputNumber = React66.memo(
12573
12585
  var _a2, _b;
12574
12586
  setFocused(false);
12575
12587
  const el = e4.currentTarget;
12576
- const raw = stripAffixes(el.value, props.prefix, props.suffix);
12588
+ const raw = stripAffixes2(el.value, props.prefix, props.suffix);
12577
12589
  const normalized = normalizeEditable(
12578
12590
  raw,
12579
12591
  locale,
@@ -12595,7 +12607,7 @@ var InputNumber = React66.memo(
12595
12607
  if (props.disabled || props.readOnly) return;
12596
12608
  const el = e4.currentTarget;
12597
12609
  const caretBefore = (_a2 = el.selectionStart) != null ? _a2 : el.value.length;
12598
- const stripped = stripAffixes(el.value, props.prefix, props.suffix);
12610
+ const stripped = stripAffixes2(el.value, props.prefix, props.suffix);
12599
12611
  let next = normalizeEditable(
12600
12612
  stripped,
12601
12613
  locale,
@@ -13086,14 +13098,18 @@ function applyMask(mask, raw, keepCharPositions) {
13086
13098
  function digitsOnly(input) {
13087
13099
  return (input != null ? input : "").replace(/\D+/g, "");
13088
13100
  }
13101
+ function normalizeDial(dial) {
13102
+ return digitsOnly(dial != null ? dial : "");
13103
+ }
13089
13104
  function dialPrefixFor(country) {
13090
- return `+${country.dial} `;
13105
+ return `+${normalizeDial(country.dial)} `;
13091
13106
  }
13092
13107
  function valueToNationalDigits(value, country) {
13093
13108
  const digits = digitsOnly(value);
13094
13109
  if (!digits) return "";
13095
- if (digits.startsWith(country.dial)) {
13096
- return digits.slice(country.dial.length);
13110
+ const dial = normalizeDial(country.dial);
13111
+ if (dial && digits.startsWith(dial)) {
13112
+ return digits.slice(dial.length);
13097
13113
  }
13098
13114
  return digits;
13099
13115
  }
@@ -13113,8 +13129,9 @@ function computeDisplayFromValue(value, country, keepCharPositions) {
13113
13129
  function computeNextFromInput(rawInput, country, mode, keepCharPositions) {
13114
13130
  const prefix = dialPrefixFor(country);
13115
13131
  let national = digitsOnly(rawInput);
13116
- if (national.startsWith(country.dial)) {
13117
- national = national.slice(country.dial.length);
13132
+ const dial = normalizeDial(country.dial);
13133
+ if (dial && national.startsWith(dial)) {
13134
+ national = national.slice(dial.length);
13118
13135
  }
13119
13136
  const mask = compileMask(country.mask);
13120
13137
  const maskedNational = applyMask(mask, national, keepCharPositions);
@@ -13125,7 +13142,7 @@ function computeNextFromInput(rawInput, country, mode, keepCharPositions) {
13125
13142
  } else if (mode === "masked") {
13126
13143
  nextValue = display;
13127
13144
  } else if (mode === "e164") {
13128
- nextValue = country.dial + national;
13145
+ nextValue = dial + national;
13129
13146
  } else {
13130
13147
  nextValue = national;
13131
13148
  }
@@ -13138,8 +13155,10 @@ function remapToCountry(value, from, to, mode, keepCharPositions) {
13138
13155
  }
13139
13156
  const digitsAll = digitsOnly(value);
13140
13157
  let national = digitsAll;
13141
- if (digitsAll.startsWith(from.dial)) {
13142
- national = digitsAll.slice(from.dial.length);
13158
+ const fromDial = normalizeDial(from.dial);
13159
+ const toDial = normalizeDial(to.dial);
13160
+ if (fromDial && digitsAll.startsWith(fromDial)) {
13161
+ national = digitsAll.slice(fromDial.length);
13143
13162
  }
13144
13163
  const prefix = dialPrefixFor(to);
13145
13164
  const mask = compileMask(to.mask);
@@ -13151,7 +13170,7 @@ function remapToCountry(value, from, to, mode, keepCharPositions) {
13151
13170
  } else if (mode === "masked") {
13152
13171
  nextValue = display;
13153
13172
  } else if (mode === "e164") {
13154
- nextValue = to.dial + national;
13173
+ nextValue = toDial + national;
13155
13174
  } else {
13156
13175
  nextValue = national;
13157
13176
  }
@@ -13180,7 +13199,7 @@ var CountrySelect = ({
13180
13199
  const selected = (_b = (_a = countries.find((c2) => c2.code === value)) != null ? _a : countries[0]) != null ? _b : null;
13181
13200
  const triggerLabel = selected ? [
13182
13201
  showFlag && selected.flag ? selected.flag : null,
13183
- showSelectedDial ? `+${selected.dial}` : null,
13202
+ showSelectedDial ? `+${normalizeDial(selected.dial)}` : null,
13184
13203
  showSelectedLabel ? selected.label : null
13185
13204
  ].filter(Boolean).join(" ") : "";
13186
13205
  return /* @__PURE__ */ jsx("div", { className: countrySelectClassName, children: /* @__PURE__ */ jsxs(Select, { value: (_c = selected == null ? void 0 : selected.code) != null ? _c : "", onValueChange: onChange, children: [
@@ -13207,7 +13226,7 @@ var CountrySelect = ({
13207
13226
  parts.push(String(c2.flag));
13208
13227
  }
13209
13228
  if (showDialInList) {
13210
- parts.push(`${c2.dial}`);
13229
+ parts.push(`+${normalizeDial(c2.dial)}`);
13211
13230
  }
13212
13231
  parts.push(c2.label);
13213
13232
  return /* @__PURE__ */ jsx(
@@ -21150,6 +21169,7 @@ function normalizeItems2(items, mappers, optionValueKey, optionLabelKey, optionT
21150
21169
  });
21151
21170
  }
21152
21171
  return items.map((item, index) => {
21172
+ var _a;
21153
21173
  if (typeof item === "string" || typeof item === "number" || typeof item === "boolean") {
21154
21174
  const v2 = item;
21155
21175
  return {
@@ -21162,12 +21182,19 @@ function normalizeItems2(items, mappers, optionValueKey, optionLabelKey, optionT
21162
21182
  raw: item
21163
21183
  };
21164
21184
  }
21165
- return item;
21185
+ const existing = item;
21186
+ return {
21187
+ ...existing,
21188
+ raw: (_a = existing.raw) != null ? _a : item
21189
+ };
21166
21190
  });
21167
21191
  }
21168
21192
  function isEqualValue2(a3, b2) {
21169
21193
  return Object.is(a3, b2);
21170
21194
  }
21195
+ function valueLookupKey(value) {
21196
+ return `${typeof value}:${String(value)}`;
21197
+ }
21171
21198
  function asGroupValue(value) {
21172
21199
  if (!value) return void 0;
21173
21200
  if (Array.isArray(value)) {
@@ -21181,13 +21208,14 @@ function asGroupValue(value) {
21181
21208
  state: true
21182
21209
  }));
21183
21210
  }
21184
- if (typeof value == "object")
21185
- return Object.keys(value).map(
21211
+ if (typeof value == "object") {
21212
+ return Reflect.ownKeys(value).map(
21186
21213
  (key) => ({
21187
21214
  value: key,
21188
21215
  state: value[key]
21189
21216
  })
21190
21217
  );
21218
+ }
21191
21219
  return void 0;
21192
21220
  }
21193
21221
  function asSingleValue(value) {
@@ -21346,7 +21374,32 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
21346
21374
  }
21347
21375
  );
21348
21376
  }
21349
- const groupValue = asGroupValue(value);
21377
+ const normalizedByValueKey = React66.useMemo(() => {
21378
+ const lookup = /* @__PURE__ */ new Map();
21379
+ normalized.forEach((item) => {
21380
+ lookup.set(valueLookupKey(item.value), item);
21381
+ });
21382
+ return lookup;
21383
+ }, [normalized]);
21384
+ const groupValue = React66.useMemo(() => {
21385
+ const source = asGroupValue(value);
21386
+ if (!(source == null ? void 0 : source.length)) return source;
21387
+ return source.map((entry) => {
21388
+ const byExact = normalized.find(
21389
+ (item) => isEqualValue2(item.value, entry.value)
21390
+ );
21391
+ if (byExact) return { ...entry, value: byExact.value };
21392
+ const byKey = normalizedByValueKey.get(valueLookupKey(entry.value));
21393
+ if (byKey) return { ...entry, value: byKey.value };
21394
+ if (typeof entry.value === "string") {
21395
+ const byString = normalized.find(
21396
+ (item) => typeof item.value !== "object" && String(item.value) === entry.value
21397
+ );
21398
+ if (byString) return { ...entry, value: byString.value };
21399
+ }
21400
+ return entry;
21401
+ });
21402
+ }, [value, normalized, normalizedByValueKey]);
21350
21403
  const {
21351
21404
  groupStyle,
21352
21405
  groupClasses,
@@ -21447,10 +21500,13 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
21447
21500
  raw: nextList,
21448
21501
  selectedOptions: nextList.map(
21449
21502
  (entry) => {
21450
- var _a, _b;
21451
- return (_b = (_a = normalized.find(
21503
+ var _a, _b, _c;
21504
+ const normalizedItem = (_a = normalizedByValueKey.get(
21505
+ valueLookupKey(entry.value)
21506
+ )) != null ? _a : normalized.find(
21452
21507
  (item) => isEqualValue2(item.value, entry.value)
21453
- )) == null ? void 0 : _a.raw) != null ? _b : entry.value;
21508
+ );
21509
+ return (_c = (_b = normalizedItem == null ? void 0 : normalizedItem.raw) != null ? _b : normalizedItem) != null ? _c : entry.value;
21454
21510
  }
21455
21511
  ),
21456
21512
  nativeEvent: void 0,
@@ -21466,7 +21522,7 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
21466
21522
  }
21467
21523
  onValue(nextList.map((item) => item.value), detail);
21468
21524
  },
21469
- [onValue, disabled, groupValue, normalized, hasAnyTristate]
21525
+ [onValue, disabled, groupValue, normalizedByValueKey, normalized, hasAnyTristate]
21470
21526
  );
21471
21527
  return /* @__PURE__ */ jsx(
21472
21528
  "div",
@@ -21638,6 +21694,59 @@ var checkboxModule = {
21638
21694
  tags: ["checkbox", "group", "boolean", "tri-state"]
21639
21695
  }
21640
21696
  };
21697
+ function ScrollArea({
21698
+ className,
21699
+ children,
21700
+ ...props
21701
+ }) {
21702
+ return /* @__PURE__ */ jsxs(
21703
+ ScrollAreaPrimitive.Root,
21704
+ {
21705
+ "data-slot": "scroll-area",
21706
+ className: cn("relative", className),
21707
+ ...props,
21708
+ children: [
21709
+ /* @__PURE__ */ jsx(
21710
+ ScrollAreaPrimitive.Viewport,
21711
+ {
21712
+ "data-slot": "scroll-area-viewport",
21713
+ className: "focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",
21714
+ children
21715
+ }
21716
+ ),
21717
+ /* @__PURE__ */ jsx(ScrollBar, {}),
21718
+ /* @__PURE__ */ jsx(ScrollAreaPrimitive.Corner, {})
21719
+ ]
21720
+ }
21721
+ );
21722
+ }
21723
+ function ScrollBar({
21724
+ className,
21725
+ orientation = "vertical",
21726
+ ...props
21727
+ }) {
21728
+ return /* @__PURE__ */ jsx(
21729
+ ScrollAreaPrimitive.ScrollAreaScrollbar,
21730
+ {
21731
+ "data-slot": "scroll-area-scrollbar",
21732
+ orientation,
21733
+ className: cn(
21734
+ "flex touch-none p-px transition-colors select-none",
21735
+ orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent",
21736
+ orientation === "horizontal" && "h-2.5 flex-col border-t border-t-transparent",
21737
+ className
21738
+ ),
21739
+ ...props,
21740
+ children: /* @__PURE__ */ jsx(
21741
+ ScrollAreaPrimitive.ScrollAreaThumb,
21742
+ {
21743
+ "data-slot": "scroll-area-thumb",
21744
+ className: "bg-border relative flex-1 rounded-full"
21745
+ }
21746
+ )
21747
+ }
21748
+ );
21749
+ }
21641
21750
  function normalizeOptions(opts, config) {
21642
21751
  return globalNormalizeOptions(opts, config);
21643
21752
  }
@@ -22051,7 +22160,7 @@ var ShadcnSelectVariant = React66.forwardRef(function ShadcnSelectVariant2(props
22051
22160
  }
22052
22161
  }
22053
22162
  )
22054
- ) : /* @__PURE__ */ jsx("div", { className: "max-h-60 overflow-auto", children: filteredItems.map((item, index) => {
22163
+ ) : /* @__PURE__ */ jsx(ScrollArea, { className: "max-h-60", children: /* @__PURE__ */ jsx("div", { children: filteredItems.map((item, index) => {
22055
22164
  var _a2, _b2;
22056
22165
  const optionNode = /* @__PURE__ */ jsx(
22057
22166
  SelectItem,
@@ -22106,7 +22215,7 @@ var ShadcnSelectVariant = React66.forwardRef(function ShadcnSelectVariant2(props
22106
22215
  setQuery("");
22107
22216
  }
22108
22217
  });
22109
- }) })
22218
+ }) }) })
22110
22219
  )
22111
22220
  ] })
22112
22221
  ]
@@ -24110,7 +24219,7 @@ var ShadcnKeyValueVariant = React66.forwardRef(function ShadcnKeyValueVariant2(p
24110
24219
  }
24111
24220
  )
24112
24221
  ] }),
24113
- 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(
24222
+ 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(
24114
24223
  "div",
24115
24224
  {
24116
24225
  className: "flex items-center justify-between gap-2 px-2 py-1.5",
@@ -25049,59 +25158,6 @@ var treeselectModule = {
25049
25158
  Variant: treeselect_default
25050
25159
  };
25051
25160
  var treeselect_default2 = treeselectModule;
25052
- function ScrollArea({
25053
- className,
25054
- children,
25055
- ...props
25056
- }) {
25057
- return /* @__PURE__ */ jsxs(
25058
- ScrollAreaPrimitive.Root,
25059
- {
25060
- "data-slot": "scroll-area",
25061
- className: cn("relative", className),
25062
- ...props,
25063
- children: [
25064
- /* @__PURE__ */ jsx(
25065
- ScrollAreaPrimitive.Viewport,
25066
- {
25067
- "data-slot": "scroll-area-viewport",
25068
- className: "focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",
25069
- children
25070
- }
25071
- ),
25072
- /* @__PURE__ */ jsx(ScrollBar, {}),
25073
- /* @__PURE__ */ jsx(ScrollAreaPrimitive.Corner, {})
25074
- ]
25075
- }
25076
- );
25077
- }
25078
- function ScrollBar({
25079
- className,
25080
- orientation = "vertical",
25081
- ...props
25082
- }) {
25083
- return /* @__PURE__ */ jsx(
25084
- ScrollAreaPrimitive.ScrollAreaScrollbar,
25085
- {
25086
- "data-slot": "scroll-area-scrollbar",
25087
- orientation,
25088
- className: cn(
25089
- "flex touch-none p-px transition-colors select-none",
25090
- orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent",
25091
- orientation === "horizontal" && "h-2.5 flex-col border-t border-t-transparent",
25092
- className
25093
- ),
25094
- ...props,
25095
- children: /* @__PURE__ */ jsx(
25096
- ScrollAreaPrimitive.ScrollAreaThumb,
25097
- {
25098
- "data-slot": "scroll-area-thumb",
25099
- className: "bg-border relative flex-1 rounded-full"
25100
- }
25101
- )
25102
- }
25103
- );
25104
- }
25105
25161
  function fileId() {
25106
25162
  return `file_${Math.random().toString(36).slice(2)}`;
25107
25163
  }
@@ -26412,7 +26468,7 @@ var ShadcnToggleVariant3 = React66.forwardRef(function ShadcnToggleVariant4(prop
26412
26468
  size = "md",
26413
26469
  options = [],
26414
26470
  multiple = false,
26415
- variant = "default",
26471
+ design = "default",
26416
26472
  layout = "horizontal",
26417
26473
  gridCols = 2,
26418
26474
  fillWidth: fullWidth = false,
@@ -26516,7 +26572,6 @@ var ShadcnToggleVariant3 = React66.forwardRef(function ShadcnToggleVariant4(prop
26516
26572
  fullWidth && layout === "vertical" && "[&>*]:w-full",
26517
26573
  className
26518
26574
  );
26519
- console.log(layoutClasses, fullWidth, autoCap);
26520
26575
  const groupStyle = React66.useMemo(() => {
26521
26576
  const style = {};
26522
26577
  if (layout === "grid") {
@@ -26535,7 +26590,7 @@ var ShadcnToggleVariant3 = React66.forwardRef(function ShadcnToggleVariant4(prop
26535
26590
  value: currentValue,
26536
26591
  onValueChange: handleChange,
26537
26592
  disabled: isDisabled,
26538
- variant,
26593
+ variant: design,
26539
26594
  size: toggleSize,
26540
26595
  className: layoutClasses,
26541
26596
  style: groupStyle,
@@ -26577,7 +26632,7 @@ var ShadcnToggleVariant3 = React66.forwardRef(function ShadcnToggleVariant4(prop
26577
26632
  // Error State
26578
26633
  error && "border-destructive/50 hover:bg-destructive/10 data-[state=on]:bg-destructive data-[state=on]:text-destructive-foreground",
26579
26634
  // Variant: Outline specific tweaks
26580
- variant === "outline" && layout === "horizontal" && !fullWidth && "first:rounded-l-md last:rounded-r-md rounded-none border-l-0 first:border-l",
26635
+ design === "outline" && layout === "horizontal" && !fullWidth && "first:rounded-l-md last:rounded-r-md rounded-none border-l-0 first:border-l",
26581
26636
  // Layout tweaks
26582
26637
  fullWidth && "justify-center",
26583
26638
  // Custom Item Class
@@ -26612,6 +26667,30 @@ var toggleGroupModule = {
26612
26667
  tags: ["buttons", "toggle"]
26613
26668
  }
26614
26669
  };
26670
+ function isDarkThemedElement(el) {
26671
+ if (!el) return false;
26672
+ if (el.classList.contains("dark")) return true;
26673
+ const dataTheme = el.getAttribute("data-theme");
26674
+ return dataTheme === "dark";
26675
+ }
26676
+ function resolveAutoDarkFromHost(host, target) {
26677
+ if (typeof document === "undefined") return false;
26678
+ if (target === "document") {
26679
+ return isDarkThemedElement(document.documentElement) || isDarkThemedElement(document.body);
26680
+ }
26681
+ let node = host != null ? host : null;
26682
+ while (node) {
26683
+ const isEditorMarker = node.hasAttribute("data-editor-theme");
26684
+ if (!isEditorMarker) {
26685
+ if (node.classList.contains("dark")) return true;
26686
+ if (node.hasAttribute("data-theme")) {
26687
+ return node.getAttribute("data-theme") === "dark";
26688
+ }
26689
+ }
26690
+ node = node.parentElement;
26691
+ }
26692
+ return isDarkThemedElement(document.documentElement) || isDarkThemedElement(document.body);
26693
+ }
26615
26694
  function ShadcnEditorVariant(props) {
26616
26695
  const {
26617
26696
  value,
@@ -26630,7 +26709,9 @@ function ShadcnEditorVariant(props) {
26630
26709
  useCommandShortcut = true,
26631
26710
  format: format2 = "html",
26632
26711
  toolbar = "default",
26633
- pastePlainText = false
26712
+ pastePlainText = false,
26713
+ theme = "auto",
26714
+ themeTarget = "nearest"
26634
26715
  } = props;
26635
26716
  const mountRef = React66.useRef(null);
26636
26717
  const editorRef = React66.useRef(null);
@@ -26638,9 +26719,13 @@ function ShadcnEditorVariant(props) {
26638
26719
  const onValueRef = React66.useRef(onValue);
26639
26720
  const syncingRef = React66.useRef(false);
26640
26721
  const loadedRef = React66.useRef(false);
26722
+ const lastContentRef = React66.useRef(value != null ? value : "");
26723
+ const [autoDark, setAutoDark] = React66.useState(false);
26641
26724
  formatRef.current = format2;
26642
26725
  onValueRef.current = onValue;
26726
+ if (value !== void 0) lastContentRef.current = value;
26643
26727
  const effectiveReadOnly = Boolean(disabled || readOnly);
26728
+ const effectiveTheme = theme === "auto" ? autoDark ? "dark" : "light" : theme;
26644
26729
  const readContent = React66.useCallback((ed) => {
26645
26730
  var _a, _b;
26646
26731
  return formatRef.current === "markdown" ? (_a = ed.getMarkdown()) != null ? _a : "" : (_b = ed.getHTML()) != null ? _b : "";
@@ -26652,9 +26737,40 @@ function ShadcnEditorVariant(props) {
26652
26737
  }, []);
26653
26738
  const structuralKey = React66.useMemo(() => {
26654
26739
  const hideModeSwitch = toolbar === "none" || pastePlainText;
26655
- return JSON.stringify({ toolbar, useCommandShortcut, hideModeSwitch });
26656
- }, [toolbar, useCommandShortcut, pastePlainText]);
26740
+ return JSON.stringify({
26741
+ toolbar,
26742
+ useCommandShortcut,
26743
+ hideModeSwitch,
26744
+ effectiveTheme
26745
+ });
26746
+ }, [toolbar, useCommandShortcut, pastePlainText, effectiveTheme]);
26657
26747
  React66.useEffect(() => {
26748
+ if (theme !== "auto") return;
26749
+ if (typeof document === "undefined") return;
26750
+ const host = mountRef.current;
26751
+ const recompute = () => {
26752
+ setAutoDark(resolveAutoDarkFromHost(host, themeTarget));
26753
+ };
26754
+ recompute();
26755
+ const observer = new MutationObserver(() => {
26756
+ recompute();
26757
+ });
26758
+ observer.observe(document.documentElement, {
26759
+ attributes: true,
26760
+ subtree: true,
26761
+ attributeFilter: ["class", "data-theme"]
26762
+ });
26763
+ if (document.body) {
26764
+ observer.observe(document.body, {
26765
+ attributes: true,
26766
+ subtree: true,
26767
+ attributeFilter: ["class", "data-theme"]
26768
+ });
26769
+ }
26770
+ return () => observer.disconnect();
26771
+ }, [theme, themeTarget]);
26772
+ React66.useEffect(() => {
26773
+ var _a;
26658
26774
  const el = mountRef.current;
26659
26775
  if (!el) return;
26660
26776
  if (editorRef.current) {
@@ -26678,13 +26794,14 @@ function ShadcnEditorVariant(props) {
26678
26794
  const options = {
26679
26795
  el,
26680
26796
  height,
26681
- initialValue: value != null ? value : "",
26797
+ initialValue: (_a = value != null ? value : lastContentRef.current) != null ? _a : "",
26682
26798
  previewStyle,
26683
26799
  initialEditType: editType,
26684
26800
  useCommandShortcut,
26685
26801
  usageStatistics: false,
26686
26802
  placeholder,
26687
26803
  hideModeSwitch,
26804
+ ...effectiveTheme === "dark" ? { theme: "dark" } : {},
26688
26805
  ...toolbar === "none" ? { toolbarItems: [] } : Array.isArray(toolbar) ? { toolbarItems: toolbar } : {},
26689
26806
  events: {
26690
26807
  load: () => {
@@ -26695,7 +26812,9 @@ function ShadcnEditorVariant(props) {
26695
26812
  const ed = editorRef.current;
26696
26813
  if (!ed) return;
26697
26814
  if (syncingRef.current) return;
26698
- emit(readContent(ed));
26815
+ const next = readContent(ed);
26816
+ lastContentRef.current = next;
26817
+ emit(next);
26699
26818
  }
26700
26819
  }
26701
26820
  };
@@ -26756,6 +26875,7 @@ function ShadcnEditorVariant(props) {
26756
26875
  const cur = (_d = (_c = ed.getHTML) == null ? void 0 : _c.call(ed)) != null ? _d : "";
26757
26876
  if (cur !== next) ed.setHTML(next, false);
26758
26877
  }
26878
+ lastContentRef.current = next;
26759
26879
  Promise.resolve().then(() => {
26760
26880
  syncingRef.current = false;
26761
26881
  });
@@ -26779,6 +26899,8 @@ function ShadcnEditorVariant(props) {
26779
26899
  {
26780
26900
  "data-size": size,
26781
26901
  "data-density": density,
26902
+ "data-theme": effectiveTheme,
26903
+ "data-editor-theme": effectiveTheme,
26782
26904
  className: cn(
26783
26905
  "rounded-md border border-input bg-background overflow-hidden",
26784
26906
  effectiveReadOnly && "opacity-60 pointer-events-none",
@@ -31110,16 +31232,16 @@ function OptionList(props) {
31110
31232
  [draft, isMulti]
31111
31233
  );
31112
31234
  if (s3 == null ? void 0 : s3.errorCode) {
31113
- 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: [
31235
+ 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: [
31114
31236
  "Error: ",
31115
31237
  String(s3.errorCode)
31116
31238
  ] }) });
31117
31239
  }
31118
31240
  if ((s3 == null ? void 0 : s3.loading) && !((_b = s3 == null ? void 0 : s3.optionsList) == null ? void 0 : _b.length)) {
31119
- 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" }) });
31241
+ 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" }) });
31120
31242
  }
31121
31243
  if (!options.length) {
31122
- 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" }) });
31244
+ 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" }) });
31123
31245
  }
31124
31246
  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(
31125
31247
  Virtuoso,