@bettercms-ai/kit 2.0.3 → 2.0.5
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/adapters/prod-types.d.ts +2 -2
- package/dist/controls/media.js +33 -25
- package/dist/controls/media.js.map +1 -1
- package/dist/engine/array.js +9 -3
- package/dist/engine/array.js.map +1 -1
- package/dist/engine/bits.d.ts +15 -2
- package/dist/engine/bits.js +32 -4
- package/dist/engine/bits.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/lib/media-fit.d.ts +41 -0
- package/dist/lib/media-fit.js +37 -0
- package/dist/lib/media-fit.js.map +1 -0
- package/dist/lib/schema.d.ts +3 -0
- package/dist/lib/schema.js +4 -0
- package/dist/lib/schema.js.map +1 -1
- package/dist/library/entries/advanced.entries.js +2 -2
- package/dist/library/entries/advanced.entries.js.map +1 -1
- package/dist/library/entries/commerce.entries.js +1 -1
- package/dist/library/entries/commerce.entries.js.map +1 -1
- package/dist/library/entries/company.entries.js +1 -1
- package/dist/library/entries/company.entries.js.map +1 -1
- package/dist/library/entries/features.entries.js +2 -2
- package/dist/library/entries/features.entries.js.map +1 -1
- package/dist/library/entries/heroes.entries.js +1 -1
- package/dist/library/entries/heroes.entries.js.map +1 -1
- package/dist/library/entries/listings.entries.js +1 -1
- package/dist/library/entries/listings.entries.js.map +1 -1
- package/dist/library/entries/media.entries.js +5 -5
- package/dist/library/entries/media.entries.js.map +1 -1
- package/dist/library/entries/navigation.entries.js +4 -4
- package/dist/library/entries/navigation.entries.js.map +1 -1
- package/dist/library/kit-catalog.json +13 -13
- package/package.json +2 -2
|
@@ -20,8 +20,8 @@ export declare const TAB_NAME_MAX = 40;
|
|
|
20
20
|
export declare const FIELDSETS_MAX = 30;
|
|
21
21
|
export declare const FIELDSET_NAME_MAX = 60;
|
|
22
22
|
export declare const FIELDSET_DESCRIPTION_MAX: 500;
|
|
23
|
-
export declare const FIELD_HELP_MAX:
|
|
24
|
-
export declare const PROP_HELP_MAX:
|
|
23
|
+
export declare const FIELD_HELP_MAX: 80;
|
|
24
|
+
export declare const PROP_HELP_MAX: 80;
|
|
25
25
|
export declare const PROP_PLACEHOLDER_MAX: 120;
|
|
26
26
|
export declare const HELP_MORE_MAX: 2000;
|
|
27
27
|
export declare const LOCK_REASON_MAX = 200;
|
package/dist/controls/media.js
CHANGED
|
@@ -5,7 +5,8 @@ import { isObj } from "../lib/path.js";
|
|
|
5
5
|
import { Button, IconButton } from "../ui/button.js";
|
|
6
6
|
import { Progress } from "../ui/controls.js";
|
|
7
7
|
import { Menu, MenuContent, MenuItem, MenuSeparator, MenuTrigger, Popover, PopoverAnchor, PopoverContent, Tooltip } from "../ui/overlay.js";
|
|
8
|
-
import {
|
|
8
|
+
import { CHECKER, fitOf, storedSize } from "../lib/media-fit.js";
|
|
9
|
+
import { RowChrome, useLoadedFit } from "../engine/bits.js";
|
|
9
10
|
import { isIconImage } from "../lib/icon-image.js";
|
|
10
11
|
import { Input, Textarea } from "../ui/input.js";
|
|
11
12
|
import { Select } from "../ui/select.js";
|
|
@@ -295,8 +296,6 @@ function DropWell({ id, title, hint, accept, multiple, icon, disabled, onFiles,
|
|
|
295
296
|
var NO_SOURCE = "No media library or upload is connected to this editor, so nothing can be chosen here.";
|
|
296
297
|
var NO_LIBRARY = "No media library is connected to this editor, so nothing can be picked from it here.";
|
|
297
298
|
var NO_UPLOAD = "No upload is connected to this editor, so files can't be uploaded here.";
|
|
298
|
-
/** Transparency checker on the kit tokens (white in light, dimmed in dark), as the media grid draws it. */
|
|
299
|
-
var CHECKER = "bg-kit-checker-a [background-image:conic-gradient(var(--kit-checker-b)_25%,var(--kit-checker-a)_0_50%,var(--kit-checker-b)_0_75%,var(--kit-checker-a)_0)] [background-size:12px_12px]";
|
|
300
299
|
/** V2's five crops (kit media.tsx CROPS, D46). */
|
|
301
300
|
var CROPS = [
|
|
302
301
|
{
|
|
@@ -353,7 +352,7 @@ function withCrop(v, choice, size) {
|
|
|
353
352
|
if (rect) next.crop = rect;
|
|
354
353
|
return next;
|
|
355
354
|
}
|
|
356
|
-
function ImageDetails({ v, onChange, readOnly, label, urlOnly, altOnly = false, size, asset }) {
|
|
355
|
+
function ImageDetails({ v, onChange, readOnly, label, urlOnly, altOnly = false, size, asset, fit = "cover" }) {
|
|
357
356
|
const { src } = useMedia();
|
|
358
357
|
const focal = v.focal ?? {
|
|
359
358
|
x: 50,
|
|
@@ -362,6 +361,11 @@ function ImageDetails({ v, onChange, readOnly, label, urlOnly, altOnly = false,
|
|
|
362
361
|
const choice = cropChoice(v.crop, size);
|
|
363
362
|
const crop = CROPS.find((c) => c.value === choice);
|
|
364
363
|
const padRatio = crop && crop.ratio !== "auto" ? crop.ratio : customRatio(v.crop, size) ?? "3/2";
|
|
364
|
+
const [pw, ph = 1] = padRatio.split("/").map(Number);
|
|
365
|
+
const rPad = pw / ph;
|
|
366
|
+
const rImg = size ? size.w / size.h : rPad;
|
|
367
|
+
const fx = fit === "contain" ? Math.min(1, rImg / rPad) : 1;
|
|
368
|
+
const fy = fit === "contain" ? Math.min(1, rPad / rImg) : 1;
|
|
365
369
|
const setFocal = (x, y) => {
|
|
366
370
|
const next = {
|
|
367
371
|
...v,
|
|
@@ -375,7 +379,7 @@ function ImageDetails({ v, onChange, readOnly, label, urlOnly, altOnly = false,
|
|
|
375
379
|
const fromPointer = (e) => {
|
|
376
380
|
const r = e.currentTarget.getBoundingClientRect();
|
|
377
381
|
if (!r.width || !r.height) return;
|
|
378
|
-
setFocal((e.clientX - r.left) / r.width * 100, (e.clientY - r.top) / r.height * 100);
|
|
382
|
+
setFocal(50 + ((e.clientX - r.left) / r.width * 100 - 50) / fx, 50 + ((e.clientY - r.top) / r.height * 100 - 50) / fy);
|
|
379
383
|
};
|
|
380
384
|
return /* @__PURE__ */ jsxs("div", {
|
|
381
385
|
className: "flex flex-col gap-3",
|
|
@@ -502,9 +506,15 @@ function ImageDetails({ v, onChange, readOnly, label, urlOnly, altOnly = false,
|
|
|
502
506
|
setFocal(focal.x + step[0], focal.y + step[1]);
|
|
503
507
|
},
|
|
504
508
|
"data-pad-ratio": padRatio,
|
|
505
|
-
|
|
509
|
+
"data-fit": fit,
|
|
510
|
+
className: cn("relative mt-1 cursor-crosshair overflow-hidden rounded-kit-md border border-kit-line", fit === "contain" ? CHECKER : "bg-kit-muted"),
|
|
506
511
|
style: { aspectRatio: padRatio },
|
|
507
|
-
children: [/* @__PURE__ */ jsx("img", {
|
|
512
|
+
children: [fit === "contain" ? /* @__PURE__ */ jsx("img", {
|
|
513
|
+
src: src(v.url),
|
|
514
|
+
alt: "",
|
|
515
|
+
draggable: false,
|
|
516
|
+
className: "pointer-events-none size-full select-none object-contain"
|
|
517
|
+
}) : /* @__PURE__ */ jsx("img", {
|
|
508
518
|
src: src(v.url),
|
|
509
519
|
alt: "",
|
|
510
520
|
draggable: false,
|
|
@@ -514,8 +524,8 @@ function ImageDetails({ v, onChange, readOnly, label, urlOnly, altOnly = false,
|
|
|
514
524
|
"aria-hidden": true,
|
|
515
525
|
className: "pointer-events-none absolute size-5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-kit-media-handle bg-kit-media-handle-ring shadow-kit-md transition-[left,top] duration-150",
|
|
516
526
|
style: {
|
|
517
|
-
left: `${focal.x}%`,
|
|
518
|
-
top: `${focal.y}%`
|
|
527
|
+
left: `${50 + (focal.x - 50) * fx}%`,
|
|
528
|
+
top: `${50 + (focal.y - 50) * fy}%`
|
|
519
529
|
}
|
|
520
530
|
})]
|
|
521
531
|
}),
|
|
@@ -558,15 +568,6 @@ function ImageDetails({ v, onChange, readOnly, label, urlOnly, altOnly = false,
|
|
|
558
568
|
]
|
|
559
569
|
});
|
|
560
570
|
}
|
|
561
|
-
/** The width × height a stored image value carries (positive numbers only), else undefined. */
|
|
562
|
-
function storedSize(value) {
|
|
563
|
-
if (!value || typeof value !== "object") return void 0;
|
|
564
|
-
const { width, height } = value;
|
|
565
|
-
return typeof width === "number" && typeof height === "number" && width > 0 && height > 0 ? {
|
|
566
|
-
w: width,
|
|
567
|
-
h: height
|
|
568
|
-
} : void 0;
|
|
569
|
-
}
|
|
570
571
|
/**
|
|
571
572
|
* V2's icon control shape (controls/icon.tsx): ONE button — a 24px glyph tile, the field's name, a quiet replace cue —
|
|
572
573
|
* that opens the library. No Replace pill, no ×, no alt text, crop or details: an icon's alt text is "" (aria-hidden on
|
|
@@ -671,6 +672,7 @@ function ImageControl({ field, value, onChange: write, readOnly, id, path }) {
|
|
|
671
672
|
w: asset.width,
|
|
672
673
|
h: asset.height
|
|
673
674
|
} : stored ?? natural;
|
|
675
|
+
const fit = fitOf(value, field);
|
|
674
676
|
const onChange = (n) => {
|
|
675
677
|
if (!n) return write(urlOnly ? "" : null);
|
|
676
678
|
if (urlOnly) return write(n.url);
|
|
@@ -794,7 +796,8 @@ function ImageControl({ field, value, onChange: write, readOnly, id, path }) {
|
|
|
794
796
|
children: [
|
|
795
797
|
/* @__PURE__ */ jsxs("div", {
|
|
796
798
|
"data-slot": "kit-image-frame",
|
|
797
|
-
|
|
799
|
+
"data-fit": fit,
|
|
800
|
+
className: cn("group/img relative overflow-hidden rounded-kit-lg border border-kit-line", fit === "contain" ? CHECKER : "bg-kit-muted"),
|
|
798
801
|
style: { aspectRatio: frameRatio && frameRatio !== "auto" ? frameRatio : "16/9" },
|
|
799
802
|
children: [
|
|
800
803
|
/* @__PURE__ */ jsx("button", {
|
|
@@ -809,8 +812,8 @@ function ImageControl({ field, value, onChange: write, readOnly, id, path }) {
|
|
|
809
812
|
alt: alt ?? "",
|
|
810
813
|
ref: readNatural,
|
|
811
814
|
onLoad: (e) => readNatural(e.currentTarget),
|
|
812
|
-
className: "size-full object-cover",
|
|
813
|
-
style: { objectPosition: `${focal.x}% ${focal.y}%` }
|
|
815
|
+
className: fit === "contain" ? "size-full object-contain" : "size-full object-cover",
|
|
816
|
+
style: fit === "contain" ? void 0 : { objectPosition: `${focal.x}% ${focal.y}%` }
|
|
814
817
|
})
|
|
815
818
|
}),
|
|
816
819
|
readOnly ? null : /* @__PURE__ */ jsxs("div", {
|
|
@@ -932,7 +935,8 @@ function ImageControl({ field, value, onChange: write, readOnly, id, path }) {
|
|
|
932
935
|
urlOnly,
|
|
933
936
|
altOnly,
|
|
934
937
|
size,
|
|
935
|
-
asset
|
|
938
|
+
asset,
|
|
939
|
+
fit
|
|
936
940
|
})
|
|
937
941
|
}),
|
|
938
942
|
/* @__PURE__ */ jsx(MediaPicker, {
|
|
@@ -944,14 +948,15 @@ function ImageControl({ field, value, onChange: write, readOnly, id, path }) {
|
|
|
944
948
|
]
|
|
945
949
|
});
|
|
946
950
|
}
|
|
947
|
-
function Thumb({ item, label, readOnly, sort, onRemove, onOpen }) {
|
|
951
|
+
function Thumb({ item, label, readOnly, sort, onRemove, onOpen, fit: known }) {
|
|
948
952
|
const { src } = useMedia();
|
|
953
|
+
const { fit, ref, onLoad } = useLoadedFit(known, item.v.url);
|
|
949
954
|
const handle = sort.handle(item.key);
|
|
950
955
|
return /* @__PURE__ */ jsxs("div", {
|
|
951
956
|
ref: sort.register(item.key),
|
|
952
957
|
role: "listitem",
|
|
953
958
|
style: sort.style(item.key),
|
|
954
|
-
className: cn("group/thumb relative aspect-square cursor-grab touch-none overflow-hidden rounded-kit-md border border-kit-line
|
|
959
|
+
className: cn("group/thumb relative aspect-square cursor-grab touch-none overflow-hidden rounded-kit-md border border-kit-line active:cursor-grabbing", fit === "contain" ? CHECKER : "bg-kit-muted", sort.active === item.key && "z-10 opacity-90 shadow-kit-lg ring-2 ring-kit-line-strong"),
|
|
955
960
|
children: [
|
|
956
961
|
/* @__PURE__ */ jsx("div", {
|
|
957
962
|
...readOnly ? {} : handle,
|
|
@@ -976,8 +981,10 @@ function Thumb({ item, label, readOnly, sort, onRemove, onOpen }) {
|
|
|
976
981
|
children: /* @__PURE__ */ jsx("img", {
|
|
977
982
|
src: src(item.v.url),
|
|
978
983
|
alt: item.v.alt ?? "",
|
|
984
|
+
ref,
|
|
985
|
+
onLoad,
|
|
979
986
|
"data-slot": "kit-gallery-thumb",
|
|
980
|
-
className: "pointer-events-none size-full select-none object-cover",
|
|
987
|
+
className: cn("pointer-events-none size-full select-none", fit === "contain" ? "object-contain" : "object-cover"),
|
|
981
988
|
draggable: false
|
|
982
989
|
})
|
|
983
990
|
}),
|
|
@@ -1050,6 +1057,7 @@ function GalleryControl({ value, onChange, readOnly, field, id, path }) {
|
|
|
1050
1057
|
className: "grid grid-cols-3 gap-1.5 @[520px]:grid-cols-5",
|
|
1051
1058
|
children: [items.map((it, i) => /* @__PURE__ */ jsx(Thumb, {
|
|
1052
1059
|
item: it,
|
|
1060
|
+
fit: fitOf(it.raw, field, void 0, true),
|
|
1053
1061
|
label: noun(i, it),
|
|
1054
1062
|
readOnly,
|
|
1055
1063
|
sort,
|