@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.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as Dict, C as CoreProps, a as CoreContext, F as Field, V as VariantKey, L as LabelPlacement, S as SublabelPlacement, b as DescriptionPlacement, H as HelpTextPlacement, E as ErrorTextPlacement, c as SlotPlacement, d as FieldSize, e as FieldDensity, f as ValidateResult, g as ChangeDetail, h as VariantValueFor, i as VariantPropsFor, j as VariantModule, P as PhoneCountry, k as PasswordDefinitionMap, l as CustomFileLoader, m as FileItem } from './core-
|
|
2
|
-
export { B as BaseProps, s as ButtonRef, z as EffectiveFieldLayout, y as FieldLayoutConfig, x as FieldOrdering, w as FieldRootId, u as FieldRoots, v as FieldSlotId, t as FieldSlots, p as FormProps, n as InferFromSchema, I as InputNumber, r as InputStore, A as LayoutResolveContext, G as LayoutResolver, R as RelativeRootsMap, o as SubmitEvent, T as Textarea, q as ValuesResult, J as VariantEntry, N as VariantLayoutDefaults, O as VariantModuleFor, M as VariantValidateFn, K as Variants } from './core-
|
|
1
|
+
import { D as Dict, C as CoreProps, a as CoreContext, F as Field, V as VariantKey, L as LabelPlacement, S as SublabelPlacement, b as DescriptionPlacement, H as HelpTextPlacement, E as ErrorTextPlacement, c as SlotPlacement, d as FieldSize, e as FieldDensity, f as ValidateResult, g as ChangeDetail, h as VariantValueFor, i as VariantPropsFor, j as VariantModule, P as PhoneCountry, k as PasswordDefinitionMap, l as CustomFileLoader, m as FileItem } from './core-DQr56obQ.mjs';
|
|
2
|
+
export { B as BaseProps, s as ButtonRef, z as EffectiveFieldLayout, y as FieldLayoutConfig, x as FieldOrdering, w as FieldRootId, u as FieldRoots, v as FieldSlotId, t as FieldSlots, p as FormProps, n as InferFromSchema, I as InputNumber, r as InputStore, A as LayoutResolveContext, G as LayoutResolver, R as RelativeRootsMap, o as SubmitEvent, T as Textarea, q as ValuesResult, J as VariantEntry, N as VariantLayoutDefaults, O as VariantModuleFor, M as VariantValidateFn, K as Variants } from './core-DQr56obQ.mjs';
|
|
3
3
|
import { A as AdapterKey } from './adapter-CvjXO9Gi.mjs';
|
|
4
4
|
export { a as AdapterCallbacks, c as AdapterConfig, h as AdapterError, d as AdapterFactory, g as AdapterOk, f as AdapterProps, b as AdapterResult, i as AdapterSubmit, e as Adapters, M as Method, N as NamedAdapterConfig, j as NamedAdapterFactory } from './adapter-CvjXO9Gi.mjs';
|
|
5
5
|
export { createAxiosAdapter, createInertiaAdapter, getAdapter, hasAdapter, localAdapter, registerAdapter, registerAllAdapters, registerAxiosAdapter, registerInertiaAdapter, registerKnownAdapter } from './adapters.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as Dict, C as CoreProps, a as CoreContext, F as Field, V as VariantKey, L as LabelPlacement, S as SublabelPlacement, b as DescriptionPlacement, H as HelpTextPlacement, E as ErrorTextPlacement, c as SlotPlacement, d as FieldSize, e as FieldDensity, f as ValidateResult, g as ChangeDetail, h as VariantValueFor, i as VariantPropsFor, j as VariantModule, P as PhoneCountry, k as PasswordDefinitionMap, l as CustomFileLoader, m as FileItem } from './core-
|
|
2
|
-
export { B as BaseProps, s as ButtonRef, z as EffectiveFieldLayout, y as FieldLayoutConfig, x as FieldOrdering, w as FieldRootId, u as FieldRoots, v as FieldSlotId, t as FieldSlots, p as FormProps, n as InferFromSchema, I as InputNumber, r as InputStore, A as LayoutResolveContext, G as LayoutResolver, R as RelativeRootsMap, o as SubmitEvent, T as Textarea, q as ValuesResult, J as VariantEntry, N as VariantLayoutDefaults, O as VariantModuleFor, M as VariantValidateFn, K as Variants } from './core-
|
|
1
|
+
import { D as Dict, C as CoreProps, a as CoreContext, F as Field, V as VariantKey, L as LabelPlacement, S as SublabelPlacement, b as DescriptionPlacement, H as HelpTextPlacement, E as ErrorTextPlacement, c as SlotPlacement, d as FieldSize, e as FieldDensity, f as ValidateResult, g as ChangeDetail, h as VariantValueFor, i as VariantPropsFor, j as VariantModule, P as PhoneCountry, k as PasswordDefinitionMap, l as CustomFileLoader, m as FileItem } from './core-Cg8uXa6v.js';
|
|
2
|
+
export { B as BaseProps, s as ButtonRef, z as EffectiveFieldLayout, y as FieldLayoutConfig, x as FieldOrdering, w as FieldRootId, u as FieldRoots, v as FieldSlotId, t as FieldSlots, p as FormProps, n as InferFromSchema, I as InputNumber, r as InputStore, A as LayoutResolveContext, G as LayoutResolver, R as RelativeRootsMap, o as SubmitEvent, T as Textarea, q as ValuesResult, J as VariantEntry, N as VariantLayoutDefaults, O as VariantModuleFor, M as VariantValidateFn, K as Variants } from './core-Cg8uXa6v.js';
|
|
3
3
|
import { A as AdapterKey } from './adapter-CvjXO9Gi.js';
|
|
4
4
|
export { a as AdapterCallbacks, c as AdapterConfig, h as AdapterError, d as AdapterFactory, g as AdapterOk, f as AdapterProps, b as AdapterResult, i as AdapterSubmit, e as Adapters, M as Method, N as NamedAdapterConfig, j as NamedAdapterFactory } from './adapter-CvjXO9Gi.js';
|
|
5
5
|
export { createAxiosAdapter, createInertiaAdapter, getAdapter, hasAdapter, localAdapter, registerAdapter, registerAllAdapters, registerAxiosAdapter, registerInertiaAdapter, registerKnownAdapter } from './adapters.js';
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,7 @@ require('@radix-ui/react-toggle');
|
|
|
17
17
|
var TooltipPrimitive = require('@radix-ui/react-tooltip');
|
|
18
18
|
var Editor = require('@toast-ui/editor');
|
|
19
19
|
require('@toast-ui/editor/dist/toastui-editor.css');
|
|
20
|
+
require('@toast-ui/editor/dist/theme/toastui-editor-dark.css');
|
|
20
21
|
var SeparatorPrimitive = require('@radix-ui/react-separator');
|
|
21
22
|
var Ajv = require('ajv');
|
|
22
23
|
var react = require('@iconify/react');
|
|
@@ -11855,6 +11856,7 @@ var Input = React66__namespace.forwardRef(
|
|
|
11855
11856
|
"data-size": sizeKey,
|
|
11856
11857
|
"data-density": densityKey,
|
|
11857
11858
|
placeholder,
|
|
11859
|
+
...rest,
|
|
11858
11860
|
value: displayValue,
|
|
11859
11861
|
onChange,
|
|
11860
11862
|
onBlur,
|
|
@@ -11862,8 +11864,7 @@ var Input = React66__namespace.forwardRef(
|
|
|
11862
11864
|
onKeyDown: handleKeyDownWrapped,
|
|
11863
11865
|
onKeyPress: handleKeyPressWrapped,
|
|
11864
11866
|
onBeforeInput: handleBeforeInputWrapped,
|
|
11865
|
-
onPaste: handlePasteWrapped
|
|
11866
|
-
...rest
|
|
11867
|
+
onPaste: handlePasteWrapped
|
|
11867
11868
|
}
|
|
11868
11869
|
)
|
|
11869
11870
|
);
|
|
@@ -12140,6 +12141,12 @@ var Input = React66__namespace.forwardRef(
|
|
|
12140
12141
|
] });
|
|
12141
12142
|
}
|
|
12142
12143
|
);
|
|
12144
|
+
function stripAffixes(value, prefix, suffix) {
|
|
12145
|
+
let out = value != null ? value : "";
|
|
12146
|
+
if (prefix && out.startsWith(prefix)) out = out.slice(prefix.length);
|
|
12147
|
+
if (suffix && out.endsWith(suffix)) out = out.slice(0, -suffix.length);
|
|
12148
|
+
return out;
|
|
12149
|
+
}
|
|
12143
12150
|
var ShadcnTextVariant = React66__namespace.forwardRef(function ShadcnTextVariant2(props, forwardedRef) {
|
|
12144
12151
|
const {
|
|
12145
12152
|
// form-level props
|
|
@@ -12223,7 +12230,12 @@ var ShadcnTextVariant = React66__namespace.forwardRef(function ShadcnTextVariant
|
|
|
12223
12230
|
(e4) => {
|
|
12224
12231
|
var _a, _b, _c;
|
|
12225
12232
|
const maskedValue = (_a = e4.value) != null ? _a : "";
|
|
12226
|
-
const
|
|
12233
|
+
const maskedValueWithoutAffixes = stripAffixes(
|
|
12234
|
+
maskedValue,
|
|
12235
|
+
prefix,
|
|
12236
|
+
suffix
|
|
12237
|
+
);
|
|
12238
|
+
const unmaskedInner = (_c = (_b = maskedValueWithoutAffixes.match(/[0-9A-Za-z]/g)) == null ? void 0 : _b.join("")) != null ? _c : "";
|
|
12227
12239
|
const mode = unmask === true || unmask === "raw" ? "raw" : "masked";
|
|
12228
12240
|
const detail = {
|
|
12229
12241
|
source: "variant",
|
|
@@ -12362,7 +12374,7 @@ function getDecimalSeparator(locale) {
|
|
|
12362
12374
|
const m2 = s3.match(/1(.?)1/);
|
|
12363
12375
|
return (m2 == null ? void 0 : m2[1]) || ".";
|
|
12364
12376
|
}
|
|
12365
|
-
function
|
|
12377
|
+
function stripAffixes2(text, prefix, suffix) {
|
|
12366
12378
|
let t4 = text != null ? text : "";
|
|
12367
12379
|
if (prefix && t4.startsWith(prefix)) t4 = t4.slice(prefix.length);
|
|
12368
12380
|
if (suffix && t4.endsWith(suffix)) t4 = t4.slice(0, -suffix.length);
|
|
@@ -12556,7 +12568,7 @@ var InputNumber = React66__namespace.memo(
|
|
|
12556
12568
|
);
|
|
12557
12569
|
const getModelFromDisplay = React66__namespace.useCallback(
|
|
12558
12570
|
(text) => {
|
|
12559
|
-
const stripped =
|
|
12571
|
+
const stripped = stripAffixes2(text, props.prefix, props.suffix);
|
|
12560
12572
|
const withoutGroup = stripGrouping(stripped, locale);
|
|
12561
12573
|
const candidate = decimalSep !== "." ? withoutGroup.replace(".", decimalSep) : withoutGroup;
|
|
12562
12574
|
const n3 = parseEditable(candidate, locale, decimalSep);
|
|
@@ -12594,7 +12606,7 @@ var InputNumber = React66__namespace.memo(
|
|
|
12594
12606
|
setFocused(true);
|
|
12595
12607
|
(_a2 = props.onFocus) == null ? void 0 : _a2.call(props, e4);
|
|
12596
12608
|
const model = isFiniteNumber(props.value) ? clampModel(props.value) : getModelFromDisplay(display);
|
|
12597
|
-
const editable = model == null ?
|
|
12609
|
+
const editable = model == null ? stripAffixes2(display, props.prefix, props.suffix) : toEditableFromNumber(model);
|
|
12598
12610
|
const normalized = normalizeEditable(
|
|
12599
12611
|
editable,
|
|
12600
12612
|
locale,
|
|
@@ -12611,7 +12623,7 @@ var InputNumber = React66__namespace.memo(
|
|
|
12611
12623
|
var _a2, _b;
|
|
12612
12624
|
setFocused(false);
|
|
12613
12625
|
const el = e4.currentTarget;
|
|
12614
|
-
const raw =
|
|
12626
|
+
const raw = stripAffixes2(el.value, props.prefix, props.suffix);
|
|
12615
12627
|
const normalized = normalizeEditable(
|
|
12616
12628
|
raw,
|
|
12617
12629
|
locale,
|
|
@@ -12633,7 +12645,7 @@ var InputNumber = React66__namespace.memo(
|
|
|
12633
12645
|
if (props.disabled || props.readOnly) return;
|
|
12634
12646
|
const el = e4.currentTarget;
|
|
12635
12647
|
const caretBefore = (_a2 = el.selectionStart) != null ? _a2 : el.value.length;
|
|
12636
|
-
const stripped =
|
|
12648
|
+
const stripped = stripAffixes2(el.value, props.prefix, props.suffix);
|
|
12637
12649
|
let next = normalizeEditable(
|
|
12638
12650
|
stripped,
|
|
12639
12651
|
locale,
|
|
@@ -13124,14 +13136,18 @@ function applyMask(mask, raw, keepCharPositions) {
|
|
|
13124
13136
|
function digitsOnly(input) {
|
|
13125
13137
|
return (input != null ? input : "").replace(/\D+/g, "");
|
|
13126
13138
|
}
|
|
13139
|
+
function normalizeDial(dial) {
|
|
13140
|
+
return digitsOnly(dial != null ? dial : "");
|
|
13141
|
+
}
|
|
13127
13142
|
function dialPrefixFor(country) {
|
|
13128
|
-
return `+${country.dial} `;
|
|
13143
|
+
return `+${normalizeDial(country.dial)} `;
|
|
13129
13144
|
}
|
|
13130
13145
|
function valueToNationalDigits(value, country) {
|
|
13131
13146
|
const digits = digitsOnly(value);
|
|
13132
13147
|
if (!digits) return "";
|
|
13133
|
-
|
|
13134
|
-
|
|
13148
|
+
const dial = normalizeDial(country.dial);
|
|
13149
|
+
if (dial && digits.startsWith(dial)) {
|
|
13150
|
+
return digits.slice(dial.length);
|
|
13135
13151
|
}
|
|
13136
13152
|
return digits;
|
|
13137
13153
|
}
|
|
@@ -13151,8 +13167,9 @@ function computeDisplayFromValue(value, country, keepCharPositions) {
|
|
|
13151
13167
|
function computeNextFromInput(rawInput, country, mode, keepCharPositions) {
|
|
13152
13168
|
const prefix = dialPrefixFor(country);
|
|
13153
13169
|
let national = digitsOnly(rawInput);
|
|
13154
|
-
|
|
13155
|
-
|
|
13170
|
+
const dial = normalizeDial(country.dial);
|
|
13171
|
+
if (dial && national.startsWith(dial)) {
|
|
13172
|
+
national = national.slice(dial.length);
|
|
13156
13173
|
}
|
|
13157
13174
|
const mask = compileMask(country.mask);
|
|
13158
13175
|
const maskedNational = applyMask(mask, national, keepCharPositions);
|
|
@@ -13163,7 +13180,7 @@ function computeNextFromInput(rawInput, country, mode, keepCharPositions) {
|
|
|
13163
13180
|
} else if (mode === "masked") {
|
|
13164
13181
|
nextValue = display;
|
|
13165
13182
|
} else if (mode === "e164") {
|
|
13166
|
-
nextValue =
|
|
13183
|
+
nextValue = dial + national;
|
|
13167
13184
|
} else {
|
|
13168
13185
|
nextValue = national;
|
|
13169
13186
|
}
|
|
@@ -13176,8 +13193,10 @@ function remapToCountry(value, from, to, mode, keepCharPositions) {
|
|
|
13176
13193
|
}
|
|
13177
13194
|
const digitsAll = digitsOnly(value);
|
|
13178
13195
|
let national = digitsAll;
|
|
13179
|
-
|
|
13180
|
-
|
|
13196
|
+
const fromDial = normalizeDial(from.dial);
|
|
13197
|
+
const toDial = normalizeDial(to.dial);
|
|
13198
|
+
if (fromDial && digitsAll.startsWith(fromDial)) {
|
|
13199
|
+
national = digitsAll.slice(fromDial.length);
|
|
13181
13200
|
}
|
|
13182
13201
|
const prefix = dialPrefixFor(to);
|
|
13183
13202
|
const mask = compileMask(to.mask);
|
|
@@ -13189,7 +13208,7 @@ function remapToCountry(value, from, to, mode, keepCharPositions) {
|
|
|
13189
13208
|
} else if (mode === "masked") {
|
|
13190
13209
|
nextValue = display;
|
|
13191
13210
|
} else if (mode === "e164") {
|
|
13192
|
-
nextValue =
|
|
13211
|
+
nextValue = toDial + national;
|
|
13193
13212
|
} else {
|
|
13194
13213
|
nextValue = national;
|
|
13195
13214
|
}
|
|
@@ -13218,7 +13237,7 @@ var CountrySelect = ({
|
|
|
13218
13237
|
const selected = (_b = (_a = countries.find((c2) => c2.code === value)) != null ? _a : countries[0]) != null ? _b : null;
|
|
13219
13238
|
const triggerLabel = selected ? [
|
|
13220
13239
|
showFlag && selected.flag ? selected.flag : null,
|
|
13221
|
-
showSelectedDial ? `+${selected.dial}` : null,
|
|
13240
|
+
showSelectedDial ? `+${normalizeDial(selected.dial)}` : null,
|
|
13222
13241
|
showSelectedLabel ? selected.label : null
|
|
13223
13242
|
].filter(Boolean).join(" ") : "";
|
|
13224
13243
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: countrySelectClassName, children: /* @__PURE__ */ jsxRuntime.jsxs(Select, { value: (_c = selected == null ? void 0 : selected.code) != null ? _c : "", onValueChange: onChange, children: [
|
|
@@ -13245,7 +13264,7 @@ var CountrySelect = ({
|
|
|
13245
13264
|
parts.push(String(c2.flag));
|
|
13246
13265
|
}
|
|
13247
13266
|
if (showDialInList) {
|
|
13248
|
-
parts.push(
|
|
13267
|
+
parts.push(`+${normalizeDial(c2.dial)}`);
|
|
13249
13268
|
}
|
|
13250
13269
|
parts.push(c2.label);
|
|
13251
13270
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -21188,6 +21207,7 @@ function normalizeItems2(items, mappers, optionValueKey, optionLabelKey, optionT
|
|
|
21188
21207
|
});
|
|
21189
21208
|
}
|
|
21190
21209
|
return items.map((item, index) => {
|
|
21210
|
+
var _a;
|
|
21191
21211
|
if (typeof item === "string" || typeof item === "number" || typeof item === "boolean") {
|
|
21192
21212
|
const v2 = item;
|
|
21193
21213
|
return {
|
|
@@ -21200,12 +21220,19 @@ function normalizeItems2(items, mappers, optionValueKey, optionLabelKey, optionT
|
|
|
21200
21220
|
raw: item
|
|
21201
21221
|
};
|
|
21202
21222
|
}
|
|
21203
|
-
|
|
21223
|
+
const existing = item;
|
|
21224
|
+
return {
|
|
21225
|
+
...existing,
|
|
21226
|
+
raw: (_a = existing.raw) != null ? _a : item
|
|
21227
|
+
};
|
|
21204
21228
|
});
|
|
21205
21229
|
}
|
|
21206
21230
|
function isEqualValue2(a3, b2) {
|
|
21207
21231
|
return Object.is(a3, b2);
|
|
21208
21232
|
}
|
|
21233
|
+
function valueLookupKey(value) {
|
|
21234
|
+
return `${typeof value}:${String(value)}`;
|
|
21235
|
+
}
|
|
21209
21236
|
function asGroupValue(value) {
|
|
21210
21237
|
if (!value) return void 0;
|
|
21211
21238
|
if (Array.isArray(value)) {
|
|
@@ -21219,13 +21246,14 @@ function asGroupValue(value) {
|
|
|
21219
21246
|
state: true
|
|
21220
21247
|
}));
|
|
21221
21248
|
}
|
|
21222
|
-
if (typeof value == "object")
|
|
21223
|
-
return
|
|
21249
|
+
if (typeof value == "object") {
|
|
21250
|
+
return Reflect.ownKeys(value).map(
|
|
21224
21251
|
(key) => ({
|
|
21225
21252
|
value: key,
|
|
21226
21253
|
state: value[key]
|
|
21227
21254
|
})
|
|
21228
21255
|
);
|
|
21256
|
+
}
|
|
21229
21257
|
return void 0;
|
|
21230
21258
|
}
|
|
21231
21259
|
function asSingleValue(value) {
|
|
@@ -21384,7 +21412,32 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
|
|
|
21384
21412
|
}
|
|
21385
21413
|
);
|
|
21386
21414
|
}
|
|
21387
|
-
const
|
|
21415
|
+
const normalizedByValueKey = React66__namespace.useMemo(() => {
|
|
21416
|
+
const lookup = /* @__PURE__ */ new Map();
|
|
21417
|
+
normalized.forEach((item) => {
|
|
21418
|
+
lookup.set(valueLookupKey(item.value), item);
|
|
21419
|
+
});
|
|
21420
|
+
return lookup;
|
|
21421
|
+
}, [normalized]);
|
|
21422
|
+
const groupValue = React66__namespace.useMemo(() => {
|
|
21423
|
+
const source = asGroupValue(value);
|
|
21424
|
+
if (!(source == null ? void 0 : source.length)) return source;
|
|
21425
|
+
return source.map((entry) => {
|
|
21426
|
+
const byExact = normalized.find(
|
|
21427
|
+
(item) => isEqualValue2(item.value, entry.value)
|
|
21428
|
+
);
|
|
21429
|
+
if (byExact) return { ...entry, value: byExact.value };
|
|
21430
|
+
const byKey = normalizedByValueKey.get(valueLookupKey(entry.value));
|
|
21431
|
+
if (byKey) return { ...entry, value: byKey.value };
|
|
21432
|
+
if (typeof entry.value === "string") {
|
|
21433
|
+
const byString = normalized.find(
|
|
21434
|
+
(item) => typeof item.value !== "object" && String(item.value) === entry.value
|
|
21435
|
+
);
|
|
21436
|
+
if (byString) return { ...entry, value: byString.value };
|
|
21437
|
+
}
|
|
21438
|
+
return entry;
|
|
21439
|
+
});
|
|
21440
|
+
}, [value, normalized, normalizedByValueKey]);
|
|
21388
21441
|
const {
|
|
21389
21442
|
groupStyle,
|
|
21390
21443
|
groupClasses,
|
|
@@ -21485,10 +21538,13 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
|
|
|
21485
21538
|
raw: nextList,
|
|
21486
21539
|
selectedOptions: nextList.map(
|
|
21487
21540
|
(entry) => {
|
|
21488
|
-
var _a, _b;
|
|
21489
|
-
|
|
21541
|
+
var _a, _b, _c;
|
|
21542
|
+
const normalizedItem = (_a = normalizedByValueKey.get(
|
|
21543
|
+
valueLookupKey(entry.value)
|
|
21544
|
+
)) != null ? _a : normalized.find(
|
|
21490
21545
|
(item) => isEqualValue2(item.value, entry.value)
|
|
21491
|
-
)
|
|
21546
|
+
);
|
|
21547
|
+
return (_c = (_b = normalizedItem == null ? void 0 : normalizedItem.raw) != null ? _b : normalizedItem) != null ? _c : entry.value;
|
|
21492
21548
|
}
|
|
21493
21549
|
),
|
|
21494
21550
|
nativeEvent: void 0,
|
|
@@ -21504,7 +21560,7 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
|
|
|
21504
21560
|
}
|
|
21505
21561
|
onValue(nextList.map((item) => item.value), detail);
|
|
21506
21562
|
},
|
|
21507
|
-
[onValue, disabled, groupValue, normalized, hasAnyTristate]
|
|
21563
|
+
[onValue, disabled, groupValue, normalizedByValueKey, normalized, hasAnyTristate]
|
|
21508
21564
|
);
|
|
21509
21565
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
21510
21566
|
"div",
|
|
@@ -26450,7 +26506,7 @@ var ShadcnToggleVariant3 = React66__namespace.forwardRef(function ShadcnToggleVa
|
|
|
26450
26506
|
size = "md",
|
|
26451
26507
|
options = [],
|
|
26452
26508
|
multiple = false,
|
|
26453
|
-
|
|
26509
|
+
design = "default",
|
|
26454
26510
|
layout = "horizontal",
|
|
26455
26511
|
gridCols = 2,
|
|
26456
26512
|
fillWidth: fullWidth = false,
|
|
@@ -26554,7 +26610,6 @@ var ShadcnToggleVariant3 = React66__namespace.forwardRef(function ShadcnToggleVa
|
|
|
26554
26610
|
fullWidth && layout === "vertical" && "[&>*]:w-full",
|
|
26555
26611
|
className
|
|
26556
26612
|
);
|
|
26557
|
-
console.log(layoutClasses, fullWidth, autoCap);
|
|
26558
26613
|
const groupStyle = React66__namespace.useMemo(() => {
|
|
26559
26614
|
const style = {};
|
|
26560
26615
|
if (layout === "grid") {
|
|
@@ -26573,7 +26628,7 @@ var ShadcnToggleVariant3 = React66__namespace.forwardRef(function ShadcnToggleVa
|
|
|
26573
26628
|
value: currentValue,
|
|
26574
26629
|
onValueChange: handleChange,
|
|
26575
26630
|
disabled: isDisabled,
|
|
26576
|
-
variant,
|
|
26631
|
+
variant: design,
|
|
26577
26632
|
size: toggleSize,
|
|
26578
26633
|
className: layoutClasses,
|
|
26579
26634
|
style: groupStyle,
|
|
@@ -26615,7 +26670,7 @@ var ShadcnToggleVariant3 = React66__namespace.forwardRef(function ShadcnToggleVa
|
|
|
26615
26670
|
// Error State
|
|
26616
26671
|
error && "border-destructive/50 hover:bg-destructive/10 data-[state=on]:bg-destructive data-[state=on]:text-destructive-foreground",
|
|
26617
26672
|
// Variant: Outline specific tweaks
|
|
26618
|
-
|
|
26673
|
+
design === "outline" && layout === "horizontal" && !fullWidth && "first:rounded-l-md last:rounded-r-md rounded-none border-l-0 first:border-l",
|
|
26619
26674
|
// Layout tweaks
|
|
26620
26675
|
fullWidth && "justify-center",
|
|
26621
26676
|
// Custom Item Class
|
|
@@ -26650,6 +26705,30 @@ var toggleGroupModule = {
|
|
|
26650
26705
|
tags: ["buttons", "toggle"]
|
|
26651
26706
|
}
|
|
26652
26707
|
};
|
|
26708
|
+
function isDarkThemedElement(el) {
|
|
26709
|
+
if (!el) return false;
|
|
26710
|
+
if (el.classList.contains("dark")) return true;
|
|
26711
|
+
const dataTheme = el.getAttribute("data-theme");
|
|
26712
|
+
return dataTheme === "dark";
|
|
26713
|
+
}
|
|
26714
|
+
function resolveAutoDarkFromHost(host, target) {
|
|
26715
|
+
if (typeof document === "undefined") return false;
|
|
26716
|
+
if (target === "document") {
|
|
26717
|
+
return isDarkThemedElement(document.documentElement) || isDarkThemedElement(document.body);
|
|
26718
|
+
}
|
|
26719
|
+
let node = host != null ? host : null;
|
|
26720
|
+
while (node) {
|
|
26721
|
+
const isEditorMarker = node.hasAttribute("data-editor-theme");
|
|
26722
|
+
if (!isEditorMarker) {
|
|
26723
|
+
if (node.classList.contains("dark")) return true;
|
|
26724
|
+
if (node.hasAttribute("data-theme")) {
|
|
26725
|
+
return node.getAttribute("data-theme") === "dark";
|
|
26726
|
+
}
|
|
26727
|
+
}
|
|
26728
|
+
node = node.parentElement;
|
|
26729
|
+
}
|
|
26730
|
+
return isDarkThemedElement(document.documentElement) || isDarkThemedElement(document.body);
|
|
26731
|
+
}
|
|
26653
26732
|
function ShadcnEditorVariant(props) {
|
|
26654
26733
|
const {
|
|
26655
26734
|
value,
|
|
@@ -26668,7 +26747,9 @@ function ShadcnEditorVariant(props) {
|
|
|
26668
26747
|
useCommandShortcut = true,
|
|
26669
26748
|
format: format2 = "html",
|
|
26670
26749
|
toolbar = "default",
|
|
26671
|
-
pastePlainText = false
|
|
26750
|
+
pastePlainText = false,
|
|
26751
|
+
theme = "auto",
|
|
26752
|
+
themeTarget = "nearest"
|
|
26672
26753
|
} = props;
|
|
26673
26754
|
const mountRef = React66__namespace.useRef(null);
|
|
26674
26755
|
const editorRef = React66__namespace.useRef(null);
|
|
@@ -26676,9 +26757,13 @@ function ShadcnEditorVariant(props) {
|
|
|
26676
26757
|
const onValueRef = React66__namespace.useRef(onValue);
|
|
26677
26758
|
const syncingRef = React66__namespace.useRef(false);
|
|
26678
26759
|
const loadedRef = React66__namespace.useRef(false);
|
|
26760
|
+
const lastContentRef = React66__namespace.useRef(value != null ? value : "");
|
|
26761
|
+
const [autoDark, setAutoDark] = React66__namespace.useState(false);
|
|
26679
26762
|
formatRef.current = format2;
|
|
26680
26763
|
onValueRef.current = onValue;
|
|
26764
|
+
if (value !== void 0) lastContentRef.current = value;
|
|
26681
26765
|
const effectiveReadOnly = Boolean(disabled || readOnly);
|
|
26766
|
+
const effectiveTheme = theme === "auto" ? autoDark ? "dark" : "light" : theme;
|
|
26682
26767
|
const readContent = React66__namespace.useCallback((ed) => {
|
|
26683
26768
|
var _a, _b;
|
|
26684
26769
|
return formatRef.current === "markdown" ? (_a = ed.getMarkdown()) != null ? _a : "" : (_b = ed.getHTML()) != null ? _b : "";
|
|
@@ -26690,9 +26775,40 @@ function ShadcnEditorVariant(props) {
|
|
|
26690
26775
|
}, []);
|
|
26691
26776
|
const structuralKey = React66__namespace.useMemo(() => {
|
|
26692
26777
|
const hideModeSwitch = toolbar === "none" || pastePlainText;
|
|
26693
|
-
return JSON.stringify({
|
|
26694
|
-
|
|
26778
|
+
return JSON.stringify({
|
|
26779
|
+
toolbar,
|
|
26780
|
+
useCommandShortcut,
|
|
26781
|
+
hideModeSwitch,
|
|
26782
|
+
effectiveTheme
|
|
26783
|
+
});
|
|
26784
|
+
}, [toolbar, useCommandShortcut, pastePlainText, effectiveTheme]);
|
|
26695
26785
|
React66__namespace.useEffect(() => {
|
|
26786
|
+
if (theme !== "auto") return;
|
|
26787
|
+
if (typeof document === "undefined") return;
|
|
26788
|
+
const host = mountRef.current;
|
|
26789
|
+
const recompute = () => {
|
|
26790
|
+
setAutoDark(resolveAutoDarkFromHost(host, themeTarget));
|
|
26791
|
+
};
|
|
26792
|
+
recompute();
|
|
26793
|
+
const observer = new MutationObserver(() => {
|
|
26794
|
+
recompute();
|
|
26795
|
+
});
|
|
26796
|
+
observer.observe(document.documentElement, {
|
|
26797
|
+
attributes: true,
|
|
26798
|
+
subtree: true,
|
|
26799
|
+
attributeFilter: ["class", "data-theme"]
|
|
26800
|
+
});
|
|
26801
|
+
if (document.body) {
|
|
26802
|
+
observer.observe(document.body, {
|
|
26803
|
+
attributes: true,
|
|
26804
|
+
subtree: true,
|
|
26805
|
+
attributeFilter: ["class", "data-theme"]
|
|
26806
|
+
});
|
|
26807
|
+
}
|
|
26808
|
+
return () => observer.disconnect();
|
|
26809
|
+
}, [theme, themeTarget]);
|
|
26810
|
+
React66__namespace.useEffect(() => {
|
|
26811
|
+
var _a;
|
|
26696
26812
|
const el = mountRef.current;
|
|
26697
26813
|
if (!el) return;
|
|
26698
26814
|
if (editorRef.current) {
|
|
@@ -26716,13 +26832,14 @@ function ShadcnEditorVariant(props) {
|
|
|
26716
26832
|
const options = {
|
|
26717
26833
|
el,
|
|
26718
26834
|
height,
|
|
26719
|
-
initialValue: value != null ? value : "",
|
|
26835
|
+
initialValue: (_a = value != null ? value : lastContentRef.current) != null ? _a : "",
|
|
26720
26836
|
previewStyle,
|
|
26721
26837
|
initialEditType: editType,
|
|
26722
26838
|
useCommandShortcut,
|
|
26723
26839
|
usageStatistics: false,
|
|
26724
26840
|
placeholder,
|
|
26725
26841
|
hideModeSwitch,
|
|
26842
|
+
...effectiveTheme === "dark" ? { theme: "dark" } : {},
|
|
26726
26843
|
...toolbar === "none" ? { toolbarItems: [] } : Array.isArray(toolbar) ? { toolbarItems: toolbar } : {},
|
|
26727
26844
|
events: {
|
|
26728
26845
|
load: () => {
|
|
@@ -26733,7 +26850,9 @@ function ShadcnEditorVariant(props) {
|
|
|
26733
26850
|
const ed = editorRef.current;
|
|
26734
26851
|
if (!ed) return;
|
|
26735
26852
|
if (syncingRef.current) return;
|
|
26736
|
-
|
|
26853
|
+
const next = readContent(ed);
|
|
26854
|
+
lastContentRef.current = next;
|
|
26855
|
+
emit(next);
|
|
26737
26856
|
}
|
|
26738
26857
|
}
|
|
26739
26858
|
};
|
|
@@ -26794,6 +26913,7 @@ function ShadcnEditorVariant(props) {
|
|
|
26794
26913
|
const cur = (_d = (_c = ed.getHTML) == null ? void 0 : _c.call(ed)) != null ? _d : "";
|
|
26795
26914
|
if (cur !== next) ed.setHTML(next, false);
|
|
26796
26915
|
}
|
|
26916
|
+
lastContentRef.current = next;
|
|
26797
26917
|
Promise.resolve().then(() => {
|
|
26798
26918
|
syncingRef.current = false;
|
|
26799
26919
|
});
|
|
@@ -26817,6 +26937,8 @@ function ShadcnEditorVariant(props) {
|
|
|
26817
26937
|
{
|
|
26818
26938
|
"data-size": size,
|
|
26819
26939
|
"data-density": density,
|
|
26940
|
+
"data-theme": effectiveTheme,
|
|
26941
|
+
"data-editor-theme": effectiveTheme,
|
|
26820
26942
|
className: cn(
|
|
26821
26943
|
"rounded-md border border-input bg-background overflow-hidden",
|
|
26822
26944
|
effectiveReadOnly && "opacity-60 pointer-events-none",
|