@timeax/form-palette 0.1.34 → 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 +159 -37
- package/dist/extra.js.map +1 -1
- package/dist/extra.mjs +159 -37
- 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/extra.mjs
CHANGED
|
@@ -19,6 +19,7 @@ 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
|
|
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
|
|
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 =
|
|
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 ?
|
|
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 =
|
|
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 =
|
|
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
|
-
|
|
12452
|
-
|
|
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
|
-
|
|
12473
|
-
|
|
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 =
|
|
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
|
-
|
|
12498
|
-
|
|
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 =
|
|
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(
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
)
|
|
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",
|
|
@@ -25768,7 +25824,7 @@ var ShadcnToggleVariant3 = React74.forwardRef(function ShadcnToggleVariant4(prop
|
|
|
25768
25824
|
size = "md",
|
|
25769
25825
|
options = [],
|
|
25770
25826
|
multiple = false,
|
|
25771
|
-
|
|
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
|
-
|
|
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({
|
|
26012
|
-
|
|
26096
|
+
return JSON.stringify({
|
|
26097
|
+
toolbar,
|
|
26098
|
+
useCommandShortcut,
|
|
26099
|
+
hideModeSwitch,
|
|
26100
|
+
effectiveTheme
|
|
26101
|
+
});
|
|
26102
|
+
}, [toolbar, useCommandShortcut, pastePlainText, effectiveTheme]);
|
|
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]);
|
|
26013
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
|
-
|
|
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",
|
|
@@ -34064,6 +34186,7 @@ function useData(opts, deps = []) {
|
|
|
34064
34186
|
signal,
|
|
34065
34187
|
requestId
|
|
34066
34188
|
});
|
|
34189
|
+
setRes(resBody);
|
|
34067
34190
|
const list = extractArray(resBody, opts.selector);
|
|
34068
34191
|
if (!inflight.isLatest(inflightKey, requestId)) return list;
|
|
34069
34192
|
commitSelectedCache(list);
|
|
@@ -34077,7 +34200,6 @@ function useData(opts, deps = []) {
|
|
|
34077
34200
|
(prev) => prev.filter((x2) => nextIds.has(x2))
|
|
34078
34201
|
);
|
|
34079
34202
|
}
|
|
34080
|
-
setRes(resBody);
|
|
34081
34203
|
setData(list);
|
|
34082
34204
|
setLoading(false);
|
|
34083
34205
|
return list;
|