@sqlrooms/layout-config 0.19.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/LICENSE.md ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright 2025 Ilya Boyandin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,59 @@
1
+ A central configuration and type definitions package that maintains base layout configuration schemas and Zod schema definitions for SQLRooms. It provides TypeScript types and interfaces along with essential constants and utilities used for managing layouts.
2
+
3
+ ## Features
4
+
5
+ - 📝 **Layout Configuration**: Define and manage room layout configuration schemas for Mosaic layouts
6
+ - 🔍 **Type Safety**: Strong TypeScript typing for layout configuration objects
7
+ - ✅ **Validation**: Zod schemas for runtime validation of layout configurations
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install @sqlrooms/layout-config
13
+ # or
14
+ yarn add @sqlrooms/layout-config
15
+ ```
16
+
17
+ ## Basic Usage
18
+
19
+ ### Working with Mosaic Layout Configuration
20
+
21
+ ```tsx
22
+ import {
23
+ MosaicLayoutConfig,
24
+ LayoutConfig,
25
+ MAIN_VIEW,
26
+ } from '@sqlrooms/layout-config';
27
+
28
+ // Create a new room configuration
29
+ const layoutConfig: MosaicLayoutConfig = {
30
+ type: 'mosaic',
31
+ nodes: {
32
+ direction: 'row',
33
+ first: MAIN_VIEW,
34
+ second: {
35
+ direction: 'column',
36
+ first: 'files',
37
+ second: 'tables',
38
+ },
39
+ },
40
+ };
41
+
42
+ // This can be part of a bigger room configuration
43
+ interface RoomConfig {
44
+ // ... other properties
45
+ layout: LayoutConfig;
46
+ }
47
+ ```
48
+
49
+ ## Advanced Features
50
+
51
+ - **Schema Extensions**: Extend base schemas for custom room types
52
+ - **Configuration Validation**: Validate configurations at runtime
53
+ - **Serialization**: Convert configurations to/from JSON for storage
54
+
55
+ For more information, visit the SQLRooms documentation.
56
+
57
+ ```
58
+
59
+ ```
@@ -0,0 +1,64 @@
1
+ import { z } from 'zod';
2
+ /** Main view room panel key */
3
+ export declare const MAIN_VIEW = "main";
4
+ export declare const LayoutTypes: z.ZodEnum<["mosaic"]>;
5
+ export type LayoutTypes = z.infer<typeof MosaicLayoutDirection>;
6
+ export declare const DEFAULT_MOSAIC_LAYOUT: MosaicLayoutConfig;
7
+ export declare const MosaicLayoutDirection: z.ZodEnum<["row", "column"]>;
8
+ export type MosaicLayoutDirection = z.infer<typeof MosaicLayoutDirection>;
9
+ declare const BaseMosaicLayoutParent: z.ZodObject<{
10
+ direction: z.ZodEnum<["row", "column"]>;
11
+ splitPercentage: z.ZodOptional<z.ZodNumber>;
12
+ }, "strip", z.ZodTypeAny, {
13
+ direction: "row" | "column";
14
+ splitPercentage?: number | undefined;
15
+ }, {
16
+ direction: "row" | "column";
17
+ splitPercentage?: number | undefined;
18
+ }>;
19
+ export declare const MosaicLayoutParent: z.ZodType<MosaicLayoutParent>;
20
+ export type MosaicLayoutParent = z.infer<typeof BaseMosaicLayoutParent> & {
21
+ first: MosaicLayoutNode;
22
+ second: MosaicLayoutNode;
23
+ };
24
+ export declare function isMosaicLayoutParent(node: MosaicLayoutNode | null | undefined): node is MosaicLayoutParent;
25
+ export declare const MosaicLayoutNodeKey: z.ZodString;
26
+ export type MosaicLayoutNodeKey = z.infer<typeof MosaicLayoutNodeKey>;
27
+ export type MosaicLayoutNode = z.infer<typeof MosaicLayoutNode>;
28
+ export declare const MosaicLayoutNode: z.ZodUnion<[z.ZodString, z.ZodType<MosaicLayoutParent, z.ZodTypeDef, MosaicLayoutParent>]>;
29
+ export declare const MosaicLayoutConfig: z.ZodObject<{
30
+ type: z.ZodLiteral<"mosaic">;
31
+ nodes: z.ZodNullable<z.ZodUnion<[z.ZodString, z.ZodType<MosaicLayoutParent, z.ZodTypeDef, MosaicLayoutParent>]>>;
32
+ pinned: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
33
+ fixed: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
34
+ }, "strip", z.ZodTypeAny, {
35
+ type: "mosaic";
36
+ nodes: string | MosaicLayoutParent | null;
37
+ pinned?: string[] | undefined;
38
+ fixed?: string[] | undefined;
39
+ }, {
40
+ type: "mosaic";
41
+ nodes: string | MosaicLayoutParent | null;
42
+ pinned?: string[] | undefined;
43
+ fixed?: string[] | undefined;
44
+ }>;
45
+ export type MosaicLayoutConfig = z.infer<typeof MosaicLayoutConfig>;
46
+ export declare const LayoutConfig: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
47
+ type: z.ZodLiteral<"mosaic">;
48
+ nodes: z.ZodNullable<z.ZodUnion<[z.ZodString, z.ZodType<MosaicLayoutParent, z.ZodTypeDef, MosaicLayoutParent>]>>;
49
+ pinned: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
50
+ fixed: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
51
+ }, "strip", z.ZodTypeAny, {
52
+ type: "mosaic";
53
+ nodes: string | MosaicLayoutParent | null;
54
+ pinned?: string[] | undefined;
55
+ fixed?: string[] | undefined;
56
+ }, {
57
+ type: "mosaic";
58
+ nodes: string | MosaicLayoutParent | null;
59
+ pinned?: string[] | undefined;
60
+ fixed?: string[] | undefined;
61
+ }>]>;
62
+ export type LayoutConfig = z.infer<typeof LayoutConfig>;
63
+ export {};
64
+ //# sourceMappingURL=LayoutConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LayoutConfig.d.ts","sourceRoot":"","sources":["../src/LayoutConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,+BAA+B;AAC/B,eAAO,MAAM,SAAS,SAAS,CAAC;AAEhC,eAAO,MAAM,WAAW,uBAAqB,CAAC;AAC9C,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEhE,eAAO,MAAM,qBAAqB,EAAE,kBAGnC,CAAC;AAEF,eAAO,MAAM,qBAAqB,8BAA4B,CAAC;AAC/D,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE1E,QAAA,MAAM,sBAAsB;;;;;;;;;EAG1B,CAAC;AAGH,eAAO,MAAM,kBAAkB,EAAE,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAIzD,CAAC;AACL,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,GAAG;IACxE,KAAK,EAAE,gBAAgB,CAAC;IACxB,MAAM,EAAE,gBAAgB,CAAC;CAC1B,CAAC;AAEF,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,gBAAgB,GAAG,IAAI,GAAG,SAAS,GACxC,IAAI,IAAI,kBAAkB,CAE5B;AAED,eAAO,MAAM,mBAAmB,aAAa,CAAC;AAC9C,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEtE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAChE,eAAO,MAAM,gBAAgB,4FAG3B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;EAK7B,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEpE,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;IAAqD,CAAC;AAC/E,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { z } from 'zod';
2
+ /** Main view room panel key */
3
+ export const MAIN_VIEW = 'main';
4
+ export const LayoutTypes = z.enum(['mosaic']);
5
+ export const DEFAULT_MOSAIC_LAYOUT = {
6
+ type: LayoutTypes.enum.mosaic,
7
+ nodes: MAIN_VIEW,
8
+ };
9
+ export const MosaicLayoutDirection = z.enum(['row', 'column']);
10
+ const BaseMosaicLayoutParent = z.object({
11
+ direction: MosaicLayoutDirection,
12
+ splitPercentage: z.number().optional(),
13
+ });
14
+ // See https://zod.dev/?id=recursive-types
15
+ export const MosaicLayoutParent = BaseMosaicLayoutParent.extend({
16
+ first: z.lazy(() => MosaicLayoutNode),
17
+ second: z.lazy(() => MosaicLayoutNode),
18
+ });
19
+ export function isMosaicLayoutParent(node) {
20
+ return typeof node !== 'string';
21
+ }
22
+ export const MosaicLayoutNodeKey = z.string();
23
+ export const MosaicLayoutNode = z.union([
24
+ MosaicLayoutNodeKey,
25
+ MosaicLayoutParent,
26
+ ]);
27
+ export const MosaicLayoutConfig = z.object({
28
+ type: z.literal(LayoutTypes.enum.mosaic),
29
+ nodes: MosaicLayoutNode.nullable(),
30
+ pinned: z.array(MosaicLayoutNodeKey).optional(),
31
+ fixed: z.array(MosaicLayoutNodeKey).optional(),
32
+ });
33
+ export const LayoutConfig = z.discriminatedUnion('type', [MosaicLayoutConfig]);
34
+ //# sourceMappingURL=Lay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AM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC;IACxC,KAAK,EAAE,gBAAgB,CAAC,QAAQ,EAAE;IAClC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,QAAQ,EAAE;IAC/C,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,QAAQ,EAAE;CAC/C,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC","sourcesContent":["import {z} from 'zod';\n\n/** Main view room panel key */\nexport const MAIN_VIEW = 'main';\n\nexport const LayoutTypes = z.enum(['mosaic']);\nexport type LayoutTypes = z.infer<typeof MosaicLayoutDirection>;\n\nexport const DEFAULT_MOSAIC_LAYOUT: MosaicLayoutConfig = {\n type: LayoutTypes.enum.mosaic,\n nodes: MAIN_VIEW,\n};\n\nexport const MosaicLayoutDirection = z.enum(['row', 'column']);\nexport type MosaicLayoutDirection = z.infer<typeof MosaicLayoutDirection>;\n\nconst BaseMosaicLayoutParent = z.object({\n direction: MosaicLayoutDirection,\n splitPercentage: z.number().optional(),\n});\n\n// See https://zod.dev/?id=recursive-types\nexport const MosaicLayoutParent: z.ZodType<MosaicLayoutParent> =\n BaseMosaicLayoutParent.extend({\n first: z.lazy(() => MosaicLayoutNode),\n second: z.lazy(() => MosaicLayoutNode),\n });\nexport type MosaicLayoutParent = z.infer<typeof BaseMosaicLayoutParent> & {\n first: MosaicLayoutNode;\n second: MosaicLayoutNode;\n};\n\nexport function isMosaicLayoutParent(\n node: MosaicLayoutNode | null | undefined,\n): node is MosaicLayoutParent {\n return typeof node !== 'string';\n}\n\nexport const MosaicLayoutNodeKey = z.string();\nexport type MosaicLayoutNodeKey = z.infer<typeof MosaicLayoutNodeKey>;\n\nexport type MosaicLayoutNode = z.infer<typeof MosaicLayoutNode>;\nexport const MosaicLayoutNode = z.union([\n MosaicLayoutNodeKey,\n MosaicLayoutParent,\n]);\n\nexport const MosaicLayoutConfig = z.object({\n type: z.literal(LayoutTypes.enum.mosaic),\n nodes: MosaicLayoutNode.nullable(),\n pinned: z.array(MosaicLayoutNodeKey).optional(),\n fixed: z.array(MosaicLayoutNodeKey).optional(),\n});\nexport type MosaicLayoutConfig = z.infer<typeof MosaicLayoutConfig>;\n\nexport const LayoutConfig = z.discriminatedUnion('type', [MosaicLayoutConfig]);\nexport type LayoutConfig = z.infer<typeof LayoutConfig>;\n"]}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * {@include ../README.md}
3
+ * @packageDocumentation
4
+ */
5
+ export * from './LayoutConfig';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,gBAAgB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ /**
2
+ * {@include ../README.md}
3
+ * @packageDocumentation
4
+ */
5
+ export * from './LayoutConfig';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,gBAAgB,CAAC","sourcesContent":["/**\n * {@include ../README.md}\n * @packageDocumentation\n */\n\nexport * from './LayoutConfig';\n"]}
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@sqlrooms/layout-config",
3
+ "version": "0.19.0",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "module": "dist/index.js",
7
+ "type": "module",
8
+ "author": "Ilya Boyandin <ilya@boyandin.me>",
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/sqlrooms/sqlrooms.git"
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "dependencies": {
21
+ "zod": "^3.25.57"
22
+ },
23
+ "scripts": {
24
+ "dev": "tsc -w",
25
+ "build": "tsc",
26
+ "lint": "eslint .",
27
+ "typecheck": "tsc --noEmit",
28
+ "typedoc": "typedoc"
29
+ },
30
+ "gitHead": "ba6000f1e06d3ab01e309d805b5d187b32c9ff06"
31
+ }