@almadar/ui 4.40.0 → 4.41.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/avl/index.cjs
CHANGED
|
@@ -52646,13 +52646,16 @@ function layoutOrbitals(count, containerW, containerH) {
|
|
|
52646
52646
|
if (count === 1) return [{ cx: containerW / 2, cy: containerH / 2 }];
|
|
52647
52647
|
const cols = Math.min(count, Math.ceil(Math.sqrt(count)));
|
|
52648
52648
|
const rows = Math.ceil(count / cols);
|
|
52649
|
-
const
|
|
52650
|
-
const
|
|
52651
|
-
const
|
|
52652
|
-
const
|
|
52649
|
+
const edgePad = 24;
|
|
52650
|
+
const minCx = UNIT_DISPLAY_W / 2 + edgePad;
|
|
52651
|
+
const minCy = UNIT_DISPLAY_H / 2 + edgePad;
|
|
52652
|
+
const maxCx = Math.max(minCx, containerW - UNIT_DISPLAY_W / 2 - edgePad);
|
|
52653
|
+
const maxCy = Math.max(minCy, containerH - UNIT_DISPLAY_H / 2 - edgePad);
|
|
52654
|
+
const stepX = cols > 1 ? (maxCx - minCx) / (cols - 1) : 0;
|
|
52655
|
+
const stepY = rows > 1 ? (maxCy - minCy) / (rows - 1) : 0;
|
|
52653
52656
|
return Array.from({ length: count }, (_, i) => ({
|
|
52654
|
-
cx:
|
|
52655
|
-
cy:
|
|
52657
|
+
cx: minCx + i % cols * stepX,
|
|
52658
|
+
cy: minCy + Math.floor(i / cols) * stepY
|
|
52656
52659
|
}));
|
|
52657
52660
|
}
|
|
52658
52661
|
var avlOczWireId = 0;
|
|
@@ -52828,8 +52831,24 @@ var AvlOrbitalsCosmicZoom = ({
|
|
|
52828
52831
|
() => parseApplicationLevel(parsedSchema),
|
|
52829
52832
|
[parsedSchema]
|
|
52830
52833
|
);
|
|
52831
|
-
const
|
|
52832
|
-
const
|
|
52834
|
+
const outerRef = React119.useRef(null);
|
|
52835
|
+
const [measured, setMeasured] = React119.useState(null);
|
|
52836
|
+
React119.useLayoutEffect(() => {
|
|
52837
|
+
const el = outerRef.current;
|
|
52838
|
+
if (!el) return;
|
|
52839
|
+
const update = () => {
|
|
52840
|
+
const r2 = el.getBoundingClientRect();
|
|
52841
|
+
if (r2.width > 0 && r2.height > 0) setMeasured({ w: r2.width, h: r2.height });
|
|
52842
|
+
};
|
|
52843
|
+
update();
|
|
52844
|
+
const ro = new ResizeObserver(update);
|
|
52845
|
+
ro.observe(el);
|
|
52846
|
+
return () => ro.disconnect();
|
|
52847
|
+
}, []);
|
|
52848
|
+
const fallbackW = typeof width === "number" ? width : 800;
|
|
52849
|
+
const fallbackH = typeof height === "number" ? height : 450;
|
|
52850
|
+
const containerW = measured?.w ?? fallbackW;
|
|
52851
|
+
const containerH = measured?.h ?? fallbackH;
|
|
52833
52852
|
const positions = React119.useMemo(
|
|
52834
52853
|
() => layoutOrbitals(orbitals.length, containerW, containerH),
|
|
52835
52854
|
[orbitals.length, containerW, containerH]
|
|
@@ -52985,10 +53004,11 @@ var AvlOrbitalsCosmicZoom = ({
|
|
|
52985
53004
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
52986
53005
|
Box,
|
|
52987
53006
|
{
|
|
53007
|
+
ref: outerRef,
|
|
52988
53008
|
className,
|
|
52989
53009
|
position: "relative",
|
|
52990
53010
|
overflow: "visible",
|
|
52991
|
-
style: { width, height
|
|
53011
|
+
style: { width, height },
|
|
52992
53012
|
children: [
|
|
52993
53013
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
52994
53014
|
Box,
|
package/dist/avl/index.js
CHANGED
|
@@ -52600,13 +52600,16 @@ function layoutOrbitals(count, containerW, containerH) {
|
|
|
52600
52600
|
if (count === 1) return [{ cx: containerW / 2, cy: containerH / 2 }];
|
|
52601
52601
|
const cols = Math.min(count, Math.ceil(Math.sqrt(count)));
|
|
52602
52602
|
const rows = Math.ceil(count / cols);
|
|
52603
|
-
const
|
|
52604
|
-
const
|
|
52605
|
-
const
|
|
52606
|
-
const
|
|
52603
|
+
const edgePad = 24;
|
|
52604
|
+
const minCx = UNIT_DISPLAY_W / 2 + edgePad;
|
|
52605
|
+
const minCy = UNIT_DISPLAY_H / 2 + edgePad;
|
|
52606
|
+
const maxCx = Math.max(minCx, containerW - UNIT_DISPLAY_W / 2 - edgePad);
|
|
52607
|
+
const maxCy = Math.max(minCy, containerH - UNIT_DISPLAY_H / 2 - edgePad);
|
|
52608
|
+
const stepX = cols > 1 ? (maxCx - minCx) / (cols - 1) : 0;
|
|
52609
|
+
const stepY = rows > 1 ? (maxCy - minCy) / (rows - 1) : 0;
|
|
52607
52610
|
return Array.from({ length: count }, (_, i) => ({
|
|
52608
|
-
cx:
|
|
52609
|
-
cy:
|
|
52611
|
+
cx: minCx + i % cols * stepX,
|
|
52612
|
+
cy: minCy + Math.floor(i / cols) * stepY
|
|
52610
52613
|
}));
|
|
52611
52614
|
}
|
|
52612
52615
|
var avlOczWireId = 0;
|
|
@@ -52782,8 +52785,24 @@ var AvlOrbitalsCosmicZoom = ({
|
|
|
52782
52785
|
() => parseApplicationLevel(parsedSchema),
|
|
52783
52786
|
[parsedSchema]
|
|
52784
52787
|
);
|
|
52785
|
-
const
|
|
52786
|
-
const
|
|
52788
|
+
const outerRef = useRef(null);
|
|
52789
|
+
const [measured, setMeasured] = useState(null);
|
|
52790
|
+
useLayoutEffect(() => {
|
|
52791
|
+
const el = outerRef.current;
|
|
52792
|
+
if (!el) return;
|
|
52793
|
+
const update = () => {
|
|
52794
|
+
const r2 = el.getBoundingClientRect();
|
|
52795
|
+
if (r2.width > 0 && r2.height > 0) setMeasured({ w: r2.width, h: r2.height });
|
|
52796
|
+
};
|
|
52797
|
+
update();
|
|
52798
|
+
const ro = new ResizeObserver(update);
|
|
52799
|
+
ro.observe(el);
|
|
52800
|
+
return () => ro.disconnect();
|
|
52801
|
+
}, []);
|
|
52802
|
+
const fallbackW = typeof width === "number" ? width : 800;
|
|
52803
|
+
const fallbackH = typeof height === "number" ? height : 450;
|
|
52804
|
+
const containerW = measured?.w ?? fallbackW;
|
|
52805
|
+
const containerH = measured?.h ?? fallbackH;
|
|
52787
52806
|
const positions = useMemo(
|
|
52788
52807
|
() => layoutOrbitals(orbitals.length, containerW, containerH),
|
|
52789
52808
|
[orbitals.length, containerW, containerH]
|
|
@@ -52939,10 +52958,11 @@ var AvlOrbitalsCosmicZoom = ({
|
|
|
52939
52958
|
return /* @__PURE__ */ jsxs(
|
|
52940
52959
|
Box,
|
|
52941
52960
|
{
|
|
52961
|
+
ref: outerRef,
|
|
52942
52962
|
className,
|
|
52943
52963
|
position: "relative",
|
|
52944
52964
|
overflow: "visible",
|
|
52945
|
-
style: { width, height
|
|
52965
|
+
style: { width, height },
|
|
52946
52966
|
children: [
|
|
52947
52967
|
/* @__PURE__ */ jsx(
|
|
52948
52968
|
Box,
|
|
@@ -26895,6 +26895,16 @@ function nextBlockId(prefix = "blk") {
|
|
|
26895
26895
|
const random = Math.random().toString(36).slice(2, 8);
|
|
26896
26896
|
return `${prefix}-${Date.now().toString(36)}-${_idSeq}-${random}`;
|
|
26897
26897
|
}
|
|
26898
|
+
function normalizeBlocks(raw) {
|
|
26899
|
+
if (!raw || raw.length === 0) return [createBlock("paragraph")];
|
|
26900
|
+
return raw.map((row) => {
|
|
26901
|
+
const r = row;
|
|
26902
|
+
const rawType = r.type;
|
|
26903
|
+
const type = typeof rawType === "string" && BLOCK_TYPES.has(rawType) ? rawType : "paragraph";
|
|
26904
|
+
const id = typeof r.id === "string" && r.id ? r.id : nextBlockId(type);
|
|
26905
|
+
return { ...r, id, type };
|
|
26906
|
+
});
|
|
26907
|
+
}
|
|
26898
26908
|
function createBlock(type) {
|
|
26899
26909
|
switch (type) {
|
|
26900
26910
|
case "bullet-list":
|
|
@@ -27445,7 +27455,7 @@ function BlockRow({
|
|
|
27445
27455
|
}
|
|
27446
27456
|
);
|
|
27447
27457
|
}
|
|
27448
|
-
var TOOLBAR_ENTRIES, BLOCK_TYPE_LABEL, CHANGEABLE_TYPES, _idSeq; exports.RichBlockEditor = void 0;
|
|
27458
|
+
var TOOLBAR_ENTRIES, BLOCK_TYPE_LABEL, CHANGEABLE_TYPES, _idSeq, BLOCK_TYPES; exports.RichBlockEditor = void 0;
|
|
27449
27459
|
var init_RichBlockEditor = __esm({
|
|
27450
27460
|
"components/molecules/RichBlockEditor.tsx"() {
|
|
27451
27461
|
"use client";
|
|
@@ -27492,6 +27502,18 @@ var init_RichBlockEditor = __esm({
|
|
|
27492
27502
|
"code"
|
|
27493
27503
|
];
|
|
27494
27504
|
_idSeq = 0;
|
|
27505
|
+
BLOCK_TYPES = /* @__PURE__ */ new Set([
|
|
27506
|
+
"paragraph",
|
|
27507
|
+
"heading-1",
|
|
27508
|
+
"heading-2",
|
|
27509
|
+
"heading-3",
|
|
27510
|
+
"bullet-list",
|
|
27511
|
+
"numbered-list",
|
|
27512
|
+
"quote",
|
|
27513
|
+
"code",
|
|
27514
|
+
"divider",
|
|
27515
|
+
"image"
|
|
27516
|
+
]);
|
|
27495
27517
|
exports.RichBlockEditor = ({
|
|
27496
27518
|
initialBlocks,
|
|
27497
27519
|
onChange,
|
|
@@ -27502,7 +27524,7 @@ var init_RichBlockEditor = __esm({
|
|
|
27502
27524
|
className
|
|
27503
27525
|
}) => {
|
|
27504
27526
|
const [blocks, setBlocks] = React121.useState(
|
|
27505
|
-
() => initialBlocks
|
|
27527
|
+
() => normalizeBlocks(initialBlocks)
|
|
27506
27528
|
);
|
|
27507
27529
|
const onChangeRef = React121.useRef(onChange);
|
|
27508
27530
|
React121.useEffect(() => {
|
package/dist/components/index.js
CHANGED
|
@@ -26850,6 +26850,16 @@ function nextBlockId(prefix = "blk") {
|
|
|
26850
26850
|
const random = Math.random().toString(36).slice(2, 8);
|
|
26851
26851
|
return `${prefix}-${Date.now().toString(36)}-${_idSeq}-${random}`;
|
|
26852
26852
|
}
|
|
26853
|
+
function normalizeBlocks(raw) {
|
|
26854
|
+
if (!raw || raw.length === 0) return [createBlock("paragraph")];
|
|
26855
|
+
return raw.map((row) => {
|
|
26856
|
+
const r = row;
|
|
26857
|
+
const rawType = r.type;
|
|
26858
|
+
const type = typeof rawType === "string" && BLOCK_TYPES.has(rawType) ? rawType : "paragraph";
|
|
26859
|
+
const id = typeof r.id === "string" && r.id ? r.id : nextBlockId(type);
|
|
26860
|
+
return { ...r, id, type };
|
|
26861
|
+
});
|
|
26862
|
+
}
|
|
26853
26863
|
function createBlock(type) {
|
|
26854
26864
|
switch (type) {
|
|
26855
26865
|
case "bullet-list":
|
|
@@ -27400,7 +27410,7 @@ function BlockRow({
|
|
|
27400
27410
|
}
|
|
27401
27411
|
);
|
|
27402
27412
|
}
|
|
27403
|
-
var TOOLBAR_ENTRIES, BLOCK_TYPE_LABEL, CHANGEABLE_TYPES, _idSeq, RichBlockEditor;
|
|
27413
|
+
var TOOLBAR_ENTRIES, BLOCK_TYPE_LABEL, CHANGEABLE_TYPES, _idSeq, BLOCK_TYPES, RichBlockEditor;
|
|
27404
27414
|
var init_RichBlockEditor = __esm({
|
|
27405
27415
|
"components/molecules/RichBlockEditor.tsx"() {
|
|
27406
27416
|
"use client";
|
|
@@ -27447,6 +27457,18 @@ var init_RichBlockEditor = __esm({
|
|
|
27447
27457
|
"code"
|
|
27448
27458
|
];
|
|
27449
27459
|
_idSeq = 0;
|
|
27460
|
+
BLOCK_TYPES = /* @__PURE__ */ new Set([
|
|
27461
|
+
"paragraph",
|
|
27462
|
+
"heading-1",
|
|
27463
|
+
"heading-2",
|
|
27464
|
+
"heading-3",
|
|
27465
|
+
"bullet-list",
|
|
27466
|
+
"numbered-list",
|
|
27467
|
+
"quote",
|
|
27468
|
+
"code",
|
|
27469
|
+
"divider",
|
|
27470
|
+
"image"
|
|
27471
|
+
]);
|
|
27450
27472
|
RichBlockEditor = ({
|
|
27451
27473
|
initialBlocks,
|
|
27452
27474
|
onChange,
|
|
@@ -27457,7 +27479,7 @@ var init_RichBlockEditor = __esm({
|
|
|
27457
27479
|
className
|
|
27458
27480
|
}) => {
|
|
27459
27481
|
const [blocks, setBlocks] = useState(
|
|
27460
|
-
() => initialBlocks
|
|
27482
|
+
() => normalizeBlocks(initialBlocks)
|
|
27461
27483
|
);
|
|
27462
27484
|
const onChangeRef = useRef(onChange);
|
|
27463
27485
|
useEffect(() => {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* scope for the Phase 10 scaffold.
|
|
9
9
|
*/
|
|
10
10
|
import React from "react";
|
|
11
|
-
import type { EventEmit, EventPayloadValue } from '@almadar/core';
|
|
11
|
+
import type { EntityRow, EventEmit, EventPayloadValue } from '@almadar/core';
|
|
12
12
|
export type BlockType = "paragraph" | "heading-1" | "heading-2" | "heading-3" | "bullet-list" | "numbered-list" | "quote" | "code" | "divider" | "image";
|
|
13
13
|
export interface RichBlock {
|
|
14
14
|
id: string;
|
|
@@ -19,7 +19,14 @@ export interface RichBlock {
|
|
|
19
19
|
[key: string]: EventPayloadValue;
|
|
20
20
|
}
|
|
21
21
|
export interface RichBlockEditorProps {
|
|
22
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Initial block payload. Accepts strongly-typed RichBlock[] from native
|
|
24
|
+
* callers and the wider EntityRow[] shape that orb-bound traits emit
|
|
25
|
+
* (orb `[object]` lowers to `Record<string, FieldValue | undefined>[]`,
|
|
26
|
+
* which is structurally EntityRow[]). Items missing id/type are normalized
|
|
27
|
+
* into paragraph blocks at mount.
|
|
28
|
+
*/
|
|
29
|
+
initialBlocks?: readonly RichBlock[] | readonly EntityRow[];
|
|
23
30
|
onChange?: (blocks: RichBlock[]) => void;
|
|
24
31
|
changeEvent?: EventEmit<{
|
|
25
32
|
blocks: RichBlock[];
|