@timeax/form-palette 0.1.35 → 0.2.0
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/{core-B34a6gqM.d.ts → core-Cg8uXa6v.d.ts} +11 -1
- package/dist/{core-Bb5eVTa4.d.mts → core-DQr56obQ.d.mts} +11 -1
- package/dist/extra.d.mts +2 -2
- package/dist/extra.d.ts +2 -2
- package/dist/extra.js +158 -36
- package/dist/extra.js.map +1 -1
- package/dist/extra.mjs +158 -36
- package/dist/extra.mjs.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +158 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +158 -36
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -16,6 +16,7 @@ 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
|
|
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
|
|
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 =
|
|
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 ?
|
|
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 =
|
|
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 =
|
|
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
|
-
|
|
13096
|
-
|
|
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
|
-
|
|
13117
|
-
|
|
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 =
|
|
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
|
-
|
|
13142
|
-
|
|
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 =
|
|
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(
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
)
|
|
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",
|
|
@@ -26412,7 +26468,7 @@ var ShadcnToggleVariant3 = React66.forwardRef(function ShadcnToggleVariant4(prop
|
|
|
26412
26468
|
size = "md",
|
|
26413
26469
|
options = [],
|
|
26414
26470
|
multiple = false,
|
|
26415
|
-
|
|
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
|
-
|
|
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({
|
|
26656
|
-
|
|
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
|
-
|
|
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",
|