@sqlrooms/layout 0.16.3 → 0.17.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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { MAIN_VIEW } from '@sqlrooms/
|
|
2
|
+
import { MAIN_VIEW } from '@sqlrooms/room-config';
|
|
3
3
|
import { cn } from '@sqlrooms/ui';
|
|
4
4
|
import { MosaicWindow } from 'react-mosaic-component';
|
|
5
5
|
const ENABLE_LAYOUT_REARRANGE = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MosaicTile.js","sourceRoot":"","sources":["../../src/mosaic/MosaicTile.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"MosaicTile.js","sourceRoot":"","sources":["../../src/mosaic/MosaicTile.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAC,EAAE,EAAC,MAAM,cAAc,CAAC;AAEhC,OAAO,EAAe,YAAY,EAAC,MAAM,wBAAwB,CAAC;AAElE,MAAM,uBAAuB,GAAG,KAAK,CAAC;AAEtC,MAAM,UAAU,GAMX,CAAC,KAAK,EAAE,EAAE;IACb,MAAM,EAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAC,GAAG,KAAK,CAAC;IACzD,MAAM,IAAI,GAAG,CACX,cACE,SAAS,EAAE,EAAE,CACX,uDAAuD,EACvD,SAAS,EACT,UAAU,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAAE,CACxC,YAEA,OAAO,GACJ,CACP,CAAC;IACF,IAAI,CAAC,uBAAuB,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;QACjD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,CACL,KAAC,YAAY,IACX,KAAK,EAAE,EAAE;QACT,uBAAuB;QACvB,IAAI;QACJ,qCAAqC;QACrC,IAAI,EAAE,IAAI;QACV,8DAA8D;QAC9D,oEAAoE;QACpE,aAAa,EAAE,GAAG,EAAE,CAClB,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,CACjB,eAAO,CACR,CAAC,CAAC,CAAC,CACF,cAAK,KAAK,EAAE,EAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAC,GAEtD,CACP,YAGF,IAAI,GACQ,CAChB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import {MAIN_VIEW} from '@sqlrooms/room-config';\nimport {cn} from '@sqlrooms/ui';\nimport {FC} from 'react';\nimport {MosaicBranch, MosaicWindow} from 'react-mosaic-component';\n\nconst ENABLE_LAYOUT_REARRANGE = false;\n\nconst MosaicTile: FC<{\n id: string;\n path: MosaicBranch[];\n content: React.ReactNode;\n isDragging: boolean;\n className?: string;\n}> = (props) => {\n const {id, content, path, isDragging, className} = props;\n const body = (\n <div\n className={cn(\n 'h-full flex-1 flex-col overflow-hidden rounded-md p-2',\n className,\n isDragging ? 'pointer-events-none' : '',\n )}\n >\n {content}\n </div>\n );\n if (!ENABLE_LAYOUT_REARRANGE || id === MAIN_VIEW) {\n return body;\n }\n return (\n <MosaicWindow<string>\n title={id}\n // additionalControls={\n // }\n // createNode={() => genRandomStr(6)}\n path={path}\n // onDragStart={() => console.log('MosaicWindow.onDragStart')}\n // onDragEnd={(type) => console.log('MosaicWindow.onDragEnd', type)}\n renderToolbar={() =>\n id === MAIN_VIEW ? (\n <div />\n ) : (\n <div style={{display: 'flex', width: '100%', height: '100%'}}>\n {/* <RoomPanelHeader panelKey={id as RoomPanelTypes} /> */}\n </div>\n )\n }\n >\n {body}\n </MosaicWindow>\n );\n};\n\nexport default MosaicTile;\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MosaicLayoutNode } from '@sqlrooms/
|
|
1
|
+
import { MosaicLayoutNode } from '@sqlrooms/room-config';
|
|
2
2
|
import { MosaicDirection, MosaicNode, MosaicPath } from 'react-mosaic-component';
|
|
3
3
|
export declare function makeMosaicStack(direction: MosaicDirection, children: {
|
|
4
4
|
node: string | MosaicNode<string> | null;
|
|
@@ -6,7 +6,7 @@ export declare function makeMosaicStack(direction: MosaicDirection, children: {
|
|
|
6
6
|
}[]): MosaicNode<string> | null;
|
|
7
7
|
export declare function visitMosaicLeafNodes<T = void>(root: MosaicLayoutNode | undefined | null, visitor: (node: string, path: MosaicPath) => T, // return a truthy value to stop visiting
|
|
8
8
|
path?: MosaicPath): T | undefined;
|
|
9
|
-
export declare function getVisibleMosaicLayoutPanels(root?: string | import("@sqlrooms/
|
|
9
|
+
export declare function getVisibleMosaicLayoutPanels(root?: string | import("@sqlrooms/room-config").MosaicLayoutParent | null): string[];
|
|
10
10
|
export declare function findMosaicNodePathByKey(root: MosaicLayoutNode | undefined | null, key: string): MosaicPath | undefined;
|
|
11
11
|
export declare function removeMosaicNodeByKey(root: MosaicLayoutNode | undefined | null, key: string): {
|
|
12
12
|
success: true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mosaic-utils.d.ts","sourceRoot":"","sources":["../../src/mosaic/mosaic-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,gBAAgB,EACjB,MAAM,
|
|
1
|
+
{"version":3,"file":"mosaic-utils.d.ts","sourceRoot":"","sources":["../../src/mosaic/mosaic-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEL,eAAe,EACf,UAAU,EACV,UAAU,EAEX,MAAM,wBAAwB,CAAC;AAEhC,wBAAgB,eAAe,CAC7B,SAAS,EAAE,eAAe,EAC1B,QAAQ,EAAE;IAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAC,EAAE,GACrE,UAAU,CAAC,MAAM,CAAC,GAAG,IAAI,CA8B3B;AAED,wBAAgB,oBAAoB,CAAC,CAAC,GAAG,IAAI,EAC3C,IAAI,EAAE,gBAAgB,GAAG,SAAS,GAAG,IAAI,EACzC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,KAAK,CAAC,EAAE,yCAAyC;AACzF,IAAI,GAAE,UAAe,GACpB,CAAC,GAAG,SAAS,CAaf;AAED,wBAAgB,4BAA4B,CAC1C,IAAI,qEAA8B,GACjC,MAAM,EAAE,CAQV;AAED,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,gBAAgB,GAAG,SAAS,GAAG,IAAI,EACzC,GAAG,EAAE,MAAM,GACV,UAAU,GAAG,SAAS,CAMxB;AAED,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,gBAAgB,GAAG,SAAS,GAAG,IAAI,EACzC,GAAG,EAAE,MAAM,GACV;IAAC,OAAO,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,gBAAgB,CAAA;CAAC,GAAG;IAAC,OAAO,EAAE,KAAK,CAAA;CAAC,CAehE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_MOSAIC_LAYOUT, isMosaicLayoutParent, } from '@sqlrooms/
|
|
1
|
+
import { DEFAULT_MOSAIC_LAYOUT, isMosaicLayoutParent, } from '@sqlrooms/room-config';
|
|
2
2
|
import { createRemoveUpdate, updateTree, } from 'react-mosaic-component';
|
|
3
3
|
export function makeMosaicStack(direction, children) {
|
|
4
4
|
const childrenWithoutEmpty = children.filter(({ node }) => node !== null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mosaic-utils.js","sourceRoot":"","sources":["../../src/mosaic/mosaic-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,oBAAoB,GAEr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IAAI,EAAE,EAAE;QACvE,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YACjB,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,IAAyC,EACzC,GAAW;IAEX,MAAM,IAAI,GAAG,uBAAuB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAChD,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI;QAAE,OAAO,EAAC,OAAO,EAAE,KAAK,EAAC,CAAC;IAC5C,IAAI,CAAC;QACH,OAAO;YACL,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,UAAU,CAAS,IAAI,EAAE;gBACjC,kBAAkB,CAAS,IAAI,EAAE,IAAI,CAAC;aACvC,CAAC;SACH,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,uCAAuC;QACvC,OAAO,EAAC,OAAO,EAAE,KAAK,EAAC,CAAC;IAC1B,CAAC;AACH,CAAC","sourcesContent":["import {\n DEFAULT_MOSAIC_LAYOUT,\n isMosaicLayoutParent,\n MosaicLayoutNode,\n} from '@sqlrooms/room-config';\nimport {\n createRemoveUpdate,\n MosaicDirection,\n MosaicNode,\n MosaicPath,\n updateTree,\n} from 'react-mosaic-component';\n\nexport function makeMosaicStack(\n direction: MosaicDirection,\n children: {node: string | MosaicNode<string> | null; weight: number}[],\n): MosaicNode<string> | null {\n const childrenWithoutEmpty = children.filter(({node}) => node !== null) as {\n node: string | MosaicNode<string>;\n weight: number;\n }[];\n if (!childrenWithoutEmpty?.length) {\n return null;\n }\n if (childrenWithoutEmpty.length === 1) {\n return childrenWithoutEmpty[0]?.node ?? null;\n }\n\n let stack = childrenWithoutEmpty[0]?.node;\n if (!stack) return null;\n let accumulatedWeight = childrenWithoutEmpty[0]?.weight ?? 0;\n for (let i = 1; i < childrenWithoutEmpty.length; i++) {\n const child = childrenWithoutEmpty[i];\n if (!child) continue;\n const {node, weight} = child;\n const splitPercentage =\n (accumulatedWeight * 100) / (accumulatedWeight + weight);\n accumulatedWeight += weight;\n stack = {\n direction,\n first: stack,\n second: node,\n splitPercentage: Math.round(splitPercentage),\n };\n }\n return stack;\n}\n\nexport function visitMosaicLeafNodes<T = void>(\n root: MosaicLayoutNode | undefined | null,\n visitor: (node: string, path: MosaicPath) => T, // return a truthy value to stop visiting\n path: MosaicPath = [],\n): T | undefined {\n if (!root) return undefined;\n if (isMosaicLayoutParent(root)) {\n if (root.direction) {\n const rv: T | undefined =\n visitMosaicLeafNodes(root.first, visitor, [...path, 'first']) ||\n visitMosaicLeafNodes(root.second, visitor, [...path, 'second']);\n if (rv) return rv;\n }\n return undefined;\n } else {\n return visitor(root, path);\n }\n}\n\nexport function getVisibleMosaicLayoutPanels(\n root = DEFAULT_MOSAIC_LAYOUT.nodes,\n): string[] {\n const visiblePanels: string[] = [];\n if (root) {\n visitMosaicLeafNodes(root, (node) => {\n visiblePanels.push(node);\n });\n }\n return visiblePanels;\n}\n\nexport function findMosaicNodePathByKey(\n root: MosaicLayoutNode | undefined | null,\n key: string,\n): MosaicPath | undefined {\n return visitMosaicLeafNodes<MosaicPath | undefined>(root, (node, path) => {\n if (node === key) {\n return path;\n }\n });\n}\n\nexport function removeMosaicNodeByKey(\n root: MosaicLayoutNode | undefined | null,\n key: string,\n): {success: true; nextTree: MosaicLayoutNode} | {success: false} {\n const path = findMosaicNodePathByKey(root, key);\n if (!root || !path) return {success: false};\n try {\n return {\n success: true,\n nextTree: updateTree<string>(root, [\n createRemoveUpdate<string>(root, path),\n ]),\n };\n } catch (err) {\n console.error(err);\n // might happen when removing main view\n return {success: false};\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqlrooms/layout",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"access": "public"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@sqlrooms/
|
|
22
|
-
"@sqlrooms/ui": "0.
|
|
21
|
+
"@sqlrooms/room-config": "0.17.0",
|
|
22
|
+
"@sqlrooms/ui": "0.17.0"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"react": ">=18",
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"typecheck": "tsc --noEmit",
|
|
33
33
|
"typedoc": "typedoc"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "1f2a306da771481e2c89d8bfbd0507772167b1b5"
|
|
36
36
|
}
|