@tailor-cms/ce-table-manifest 0.1.0 → 2.0.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.
@@ -0,0 +1,13 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, no_symbols) => {
4
+ let target = {};
5
+ for (var name in all) __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true
8
+ });
9
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
10
+ return target;
11
+ };
12
+ //#endregion
13
+ export { __exportAll as t };
package/dist/index.cjs CHANGED
@@ -1,123 +1,192 @@
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
5
+ //#region \0rolldown/runtime.js
1
6
  var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name2 in all)
7
- __defProp(target, name2, { get: all[name2], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
7
+ var __exportAll = (all, no_symbols) => {
8
+ let target = {};
9
+ for (var name in all) __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true
12
+ });
13
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
14
+ return target;
16
15
  };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/index.ts
20
- var index_exports = {};
21
- __export(index_exports, {
22
- Direction: () => Direction,
23
- default: () => index_default,
24
- initState: () => initState,
25
- name: () => name,
26
- type: () => type,
27
- utils: () => utils_exports,
28
- version: () => version
16
+ //#endregion
17
+ let lodash_es = require("lodash-es");
18
+ let uuid = require("uuid");
19
+ //#region src/utils.ts
20
+ var utils_exports = /* @__PURE__ */ __exportAll({
21
+ addCell: () => addCell,
22
+ addEmbed: () => addEmbed,
23
+ removeCell: () => removeCell,
24
+ removeEmbed: () => removeEmbed
29
25
  });
30
- module.exports = __toCommonJS(index_exports);
31
- var import_lodash_es2 = require("lodash-es");
32
- var import_uuid = require("uuid");
33
-
34
- // src/utils.ts
35
- var utils_exports = {};
36
- __export(utils_exports, {
37
- addCell: () => addCell,
38
- addEmbed: () => addEmbed,
39
- removeCell: () => removeCell,
40
- removeEmbed: () => removeEmbed
41
- });
42
- var import_lodash_es = require("lodash-es");
43
26
  function addCell(row, cell) {
44
- if (!row.cells) row.cells = {};
45
- row.cells[cell.id] = cell;
46
- return cell;
27
+ if (!row.cells) row.cells = {};
28
+ row.cells[cell.id] = cell;
29
+ return cell;
47
30
  }
48
31
  function removeCell(row, predicate = {}) {
49
- const cell = (0, import_lodash_es.find)(row.cells, predicate);
50
- if (!cell) return;
51
- delete row.cells[cell.id];
52
- return cell;
32
+ const cell = (0, lodash_es.find)(row.cells, predicate);
33
+ if (!cell) return;
34
+ delete row.cells[cell.id];
35
+ return cell;
53
36
  }
54
37
  function addEmbed(embeds, cellId, tableId) {
55
- const embed = {
56
- id: cellId,
57
- type: "JODIT_HTML",
58
- embedded: true,
59
- data: { tableId, cellId }
60
- };
61
- embeds[cellId] = embed;
62
- return embed;
38
+ const embed = {
39
+ id: cellId,
40
+ type: "JODIT_HTML",
41
+ embedded: true,
42
+ data: {
43
+ tableId,
44
+ cellId
45
+ }
46
+ };
47
+ embeds[cellId] = embed;
48
+ return embed;
63
49
  }
64
50
  function removeEmbed(embeds, predicate = {}) {
65
- const embed = (0, import_lodash_es.find)(embeds, predicate);
66
- if (!embed) return;
67
- delete embeds[embed.id];
68
- return embed;
51
+ const embed = (0, lodash_es.find)(embeds, predicate);
52
+ if (!embed) return;
53
+ delete embeds[embed.id];
54
+ return embed;
69
55
  }
70
-
71
- // src/interfaces.ts
72
- var Direction = /* @__PURE__ */ ((Direction2) => {
73
- Direction2[Direction2["Before"] = -1] = "Before";
74
- Direction2[Direction2["After"] = 1] = "After";
75
- return Direction2;
76
- })(Direction || {});
77
-
78
- // src/index.ts
79
- var type = "TABLE";
80
- var name = "Table";
81
- var initState = () => {
82
- const tableId = (0, import_uuid.v4)();
83
- const embeds = {};
84
- const rows = {};
85
- (0, import_lodash_es2.times)(2, (position) => {
86
- const rowId = (0, import_uuid.v4)();
87
- const row = { id: rowId, position, cells: {} };
88
- rows[rowId] = row;
89
- (0, import_lodash_es2.times)(3, (position2) => {
90
- const cellId = (0, import_uuid.v4)();
91
- addCell(row, { id: cellId, position: position2, data: {} });
92
- addEmbed(embeds, cellId, tableId);
93
- });
94
- });
95
- return { tableId, embeds, rows };
56
+ //#endregion
57
+ //#region src/interfaces.ts
58
+ let Direction = /* @__PURE__ */ function(Direction) {
59
+ Direction[Direction["Before"] = -1] = "Before";
60
+ Direction[Direction["After"] = 1] = "After";
61
+ return Direction;
62
+ }({});
63
+ //#endregion
64
+ //#region src/index.ts
65
+ const type = "TABLE";
66
+ const name = "Table";
67
+ const initState = () => {
68
+ const tableId = (0, uuid.v4)();
69
+ const embeds = {};
70
+ const rows = {};
71
+ (0, lodash_es.times)(2, (position) => {
72
+ const rowId = (0, uuid.v4)();
73
+ const row = {
74
+ id: rowId,
75
+ position,
76
+ cells: {}
77
+ };
78
+ rows[rowId] = row;
79
+ (0, lodash_es.times)(3, (position) => {
80
+ const cellId = (0, uuid.v4)();
81
+ addCell(row, {
82
+ id: cellId,
83
+ position,
84
+ data: {}
85
+ });
86
+ addEmbed(embeds, cellId, tableId);
87
+ });
88
+ });
89
+ return {
90
+ tableId,
91
+ embeds,
92
+ rows
93
+ };
94
+ };
95
+ const version = "1.0";
96
+ const ui = {
97
+ icon: "mdi-table",
98
+ forceFullWidth: true
96
99
  };
97
- var version = "1.0";
98
- var ui = {
99
- // Display icon, https://pictogrammers.com/library/mdi/
100
- icon: "mdi-table",
101
- // Does element support only full width or can be used within layouts
102
- // (e.g. 50/50 layout)
103
- forceFullWidth: true
100
+ const isEmpty = (data) => !data?.rows || Object.keys(data.rows).length === 0;
101
+ const ai = {
102
+ Schema: {
103
+ type: "json_schema",
104
+ name: "ce_table",
105
+ schema: {
106
+ type: "object",
107
+ properties: { rows: {
108
+ type: "array",
109
+ minItems: 1,
110
+ items: {
111
+ type: "object",
112
+ properties: { cells: {
113
+ type: "array",
114
+ minItems: 1,
115
+ items: { type: "string" }
116
+ } },
117
+ required: ["cells"],
118
+ additionalProperties: false
119
+ }
120
+ } },
121
+ required: ["rows"],
122
+ additionalProperties: false
123
+ }
124
+ },
125
+ getPrompt: () => `
126
+ Generate a table content element as an object with the following
127
+ properties:
128
+ {
129
+ "rows": [
130
+ { "cells": ["", ""] }
131
+ ]
132
+ }
133
+ where:
134
+ - 'rows' is an array of row objects.
135
+ - each row has a 'cells' array of plain text strings (one per cell).
136
+ Every row must have the same number of cells.
137
+ `,
138
+ processResponse: (val) => {
139
+ const tableId = (0, uuid.v4)();
140
+ const rows = {};
141
+ const embeds = {};
142
+ val.rows.forEach((row, rowPosition) => {
143
+ const rowId = (0, uuid.v4)();
144
+ rows[rowId] = {
145
+ id: rowId,
146
+ position: rowPosition,
147
+ cells: {}
148
+ };
149
+ row.cells.forEach((content, cellPosition) => {
150
+ const cellId = (0, uuid.v4)();
151
+ addCell(rows[rowId], {
152
+ id: cellId,
153
+ position: cellPosition,
154
+ data: {}
155
+ });
156
+ const embed = addEmbed(embeds, cellId, tableId);
157
+ embed.data.content = content;
158
+ });
159
+ });
160
+ return {
161
+ tableId,
162
+ rows,
163
+ embeds
164
+ };
165
+ }
104
166
  };
105
- var manifest = {
106
- type,
107
- version: "1.0",
108
- name,
109
- ssr: false,
110
- isComposite: true,
111
- initState,
112
- ui
167
+ const manifest = {
168
+ type,
169
+ version: "1.0",
170
+ name,
171
+ ssr: false,
172
+ isComposite: true,
173
+ initState,
174
+ isEmpty,
175
+ ui,
176
+ ai
113
177
  };
114
- var index_default = manifest;
115
- // Annotate the CommonJS export names for ESM import in node:
116
- 0 && (module.exports = {
117
- Direction,
118
- initState,
119
- name,
120
- type,
121
- utils,
122
- version
178
+ //#endregion
179
+ exports.Direction = Direction;
180
+ exports.ai = ai;
181
+ exports.default = manifest;
182
+ exports.initState = initState;
183
+ exports.isEmpty = isEmpty;
184
+ exports.name = name;
185
+ exports.type = type;
186
+ Object.defineProperty(exports, "utils", {
187
+ enumerable: true,
188
+ get: function() {
189
+ return utils_exports;
190
+ }
123
191
  });
192
+ exports.version = version;
package/dist/index.d.cts CHANGED
@@ -1,57 +1,50 @@
1
- import * as common from '@tailor-cms/cek-common';
1
+ import * as common from "@tailor-cms/cek-common";
2
+ import { AiConfig } from "@tailor-cms/cek-common";
2
3
 
4
+ //#region \0rolldown/runtime.js
5
+ //#endregion
6
+ //#region src/interfaces.d.ts
3
7
  declare enum Direction {
4
- Before = -1,
5
- After = 1
8
+ Before = -1,
9
+ After = 1
6
10
  }
7
11
  type Embed = any;
8
12
  type Embeds = Record<string, Embed>;
9
13
  interface Cell {
10
- id: string;
11
- data: Record<string, any>;
12
- position: number;
14
+ id: string;
15
+ data: Record<string, any>;
16
+ position: number;
13
17
  }
14
18
  type Cells = Record<string, Cell>;
15
19
  interface Row {
16
- id: string;
17
- position: number;
18
- cells: Cells;
20
+ id: string;
21
+ position: number;
22
+ cells: Cells;
19
23
  }
20
24
  type Rows = Record<string, Row>;
21
25
  interface ElementData extends common.ElementConfig {
22
- tableId: string;
23
- embeds: Embeds;
24
- rows: Rows;
26
+ tableId: string;
27
+ embeds: Embeds;
28
+ rows: Rows;
25
29
  }
26
30
  type DataInitializer = common.DataInitializer<ElementData>;
27
31
  type Element = common.Element<ElementData>;
28
32
  type ElementManifest = common.ElementManifest<ElementData>;
29
-
30
- declare function addCell(row: Row, cell: Cell): Cell;
31
- declare function removeCell(row: Row, predicate?: {}): Cell;
32
- declare function addEmbed(embeds: Embeds, cellId: string, tableId: string): {
33
- id: string;
34
- type: string;
35
- embedded: boolean;
36
- data: {
37
- tableId: string;
38
- cellId: string;
39
- };
40
- };
41
- declare function removeEmbed(embeds: Embeds, predicate?: {}): any;
42
-
43
- declare const utils_addCell: typeof addCell;
44
- declare const utils_addEmbed: typeof addEmbed;
45
- declare const utils_removeCell: typeof removeCell;
46
- declare const utils_removeEmbed: typeof removeEmbed;
47
- declare namespace utils {
48
- export { utils_addCell as addCell, utils_addEmbed as addEmbed, utils_removeCell as removeCell, utils_removeEmbed as removeEmbed };
33
+ declare namespace utils_d_exports {
34
+ export { addCell, addEmbed, removeCell, removeEmbed };
49
35
  }
50
-
36
+ declare function addCell(row: Row, cell: Cell): Cell;
37
+ declare function removeCell(row: Row, predicate?: object): Cell | undefined;
38
+ declare function addEmbed(embeds: Embeds, cellId: string, tableId: string): Embed;
39
+ declare function removeEmbed(embeds: Embeds, predicate?: object): Embed | undefined;
40
+ //#endregion
41
+ //#region src/index.d.ts
51
42
  declare const type = "TABLE";
52
43
  declare const name = "Table";
53
44
  declare const initState: DataInitializer;
54
45
  declare const version = "1.0";
46
+ declare const isEmpty: (data: ElementData) => boolean;
47
+ declare const ai: AiConfig;
55
48
  declare const manifest: ElementManifest;
56
-
57
- export { type Cell, type Cells, type DataInitializer, Direction, type Element, type ElementData, type ElementManifest, type Embed, type Embeds, type Row, type Rows, manifest as default, initState, name, type, utils, version };
49
+ //#endregion
50
+ export { Cell, Cells, DataInitializer, Direction, Element, ElementData, ElementManifest, Embed, Embeds, Row, Rows, ai, manifest as default, initState, isEmpty, name, type, utils_d_exports as utils, version };
@@ -0,0 +1,48 @@
1
+ import * as common from "@tailor-cms/cek-common";
2
+ import { AiConfig } from "@tailor-cms/cek-common";
3
+
4
+ //#region src/interfaces.d.ts
5
+ declare enum Direction {
6
+ Before = -1,
7
+ After = 1
8
+ }
9
+ type Embed = any;
10
+ type Embeds = Record<string, Embed>;
11
+ interface Cell {
12
+ id: string;
13
+ data: Record<string, any>;
14
+ position: number;
15
+ }
16
+ type Cells = Record<string, Cell>;
17
+ interface Row {
18
+ id: string;
19
+ position: number;
20
+ cells: Cells;
21
+ }
22
+ type Rows = Record<string, Row>;
23
+ interface ElementData extends common.ElementConfig {
24
+ tableId: string;
25
+ embeds: Embeds;
26
+ rows: Rows;
27
+ }
28
+ type DataInitializer = common.DataInitializer<ElementData>;
29
+ type Element = common.Element<ElementData>;
30
+ type ElementManifest = common.ElementManifest<ElementData>;
31
+ declare namespace utils_d_exports {
32
+ export { addCell, addEmbed, removeCell, removeEmbed };
33
+ }
34
+ declare function addCell(row: Row, cell: Cell): Cell;
35
+ declare function removeCell(row: Row, predicate?: object): Cell | undefined;
36
+ declare function addEmbed(embeds: Embeds, cellId: string, tableId: string): Embed;
37
+ declare function removeEmbed(embeds: Embeds, predicate?: object): Embed | undefined;
38
+ //#endregion
39
+ //#region src/index.d.ts
40
+ declare const type = "TABLE";
41
+ declare const name = "Table";
42
+ declare const initState: DataInitializer;
43
+ declare const version = "1.0";
44
+ declare const isEmpty: (data: ElementData) => boolean;
45
+ declare const ai: AiConfig;
46
+ declare const manifest: ElementManifest;
47
+ //#endregion
48
+ export { Cell, Cells, DataInitializer, Direction, Element, ElementData, ElementManifest, Embed, Embeds, Row, Rows, ai, manifest as default, initState, isEmpty, name, type, utils_d_exports as utils, version };
package/dist/index.mjs ADDED
@@ -0,0 +1,164 @@
1
+ import { t as __exportAll } from "./chunk-CfYAbeIz.mjs";
2
+ import { find, times } from "lodash-es";
3
+ import { v4 } from "uuid";
4
+ //#region src/utils.ts
5
+ var utils_exports = /* @__PURE__ */ __exportAll({
6
+ addCell: () => addCell,
7
+ addEmbed: () => addEmbed,
8
+ removeCell: () => removeCell,
9
+ removeEmbed: () => removeEmbed
10
+ });
11
+ function addCell(row, cell) {
12
+ if (!row.cells) row.cells = {};
13
+ row.cells[cell.id] = cell;
14
+ return cell;
15
+ }
16
+ function removeCell(row, predicate = {}) {
17
+ const cell = find(row.cells, predicate);
18
+ if (!cell) return;
19
+ delete row.cells[cell.id];
20
+ return cell;
21
+ }
22
+ function addEmbed(embeds, cellId, tableId) {
23
+ const embed = {
24
+ id: cellId,
25
+ type: "JODIT_HTML",
26
+ embedded: true,
27
+ data: {
28
+ tableId,
29
+ cellId
30
+ }
31
+ };
32
+ embeds[cellId] = embed;
33
+ return embed;
34
+ }
35
+ function removeEmbed(embeds, predicate = {}) {
36
+ const embed = find(embeds, predicate);
37
+ if (!embed) return;
38
+ delete embeds[embed.id];
39
+ return embed;
40
+ }
41
+ //#endregion
42
+ //#region src/interfaces.ts
43
+ let Direction = /* @__PURE__ */ function(Direction) {
44
+ Direction[Direction["Before"] = -1] = "Before";
45
+ Direction[Direction["After"] = 1] = "After";
46
+ return Direction;
47
+ }({});
48
+ //#endregion
49
+ //#region src/index.ts
50
+ const type = "TABLE";
51
+ const name = "Table";
52
+ const initState = () => {
53
+ const tableId = v4();
54
+ const embeds = {};
55
+ const rows = {};
56
+ times(2, (position) => {
57
+ const rowId = v4();
58
+ const row = {
59
+ id: rowId,
60
+ position,
61
+ cells: {}
62
+ };
63
+ rows[rowId] = row;
64
+ times(3, (position) => {
65
+ const cellId = v4();
66
+ addCell(row, {
67
+ id: cellId,
68
+ position,
69
+ data: {}
70
+ });
71
+ addEmbed(embeds, cellId, tableId);
72
+ });
73
+ });
74
+ return {
75
+ tableId,
76
+ embeds,
77
+ rows
78
+ };
79
+ };
80
+ const version = "1.0";
81
+ const ui = {
82
+ icon: "mdi-table",
83
+ forceFullWidth: true
84
+ };
85
+ const isEmpty = (data) => !data?.rows || Object.keys(data.rows).length === 0;
86
+ const ai = {
87
+ Schema: {
88
+ type: "json_schema",
89
+ name: "ce_table",
90
+ schema: {
91
+ type: "object",
92
+ properties: { rows: {
93
+ type: "array",
94
+ minItems: 1,
95
+ items: {
96
+ type: "object",
97
+ properties: { cells: {
98
+ type: "array",
99
+ minItems: 1,
100
+ items: { type: "string" }
101
+ } },
102
+ required: ["cells"],
103
+ additionalProperties: false
104
+ }
105
+ } },
106
+ required: ["rows"],
107
+ additionalProperties: false
108
+ }
109
+ },
110
+ getPrompt: () => `
111
+ Generate a table content element as an object with the following
112
+ properties:
113
+ {
114
+ "rows": [
115
+ { "cells": ["", ""] }
116
+ ]
117
+ }
118
+ where:
119
+ - 'rows' is an array of row objects.
120
+ - each row has a 'cells' array of plain text strings (one per cell).
121
+ Every row must have the same number of cells.
122
+ `,
123
+ processResponse: (val) => {
124
+ const tableId = v4();
125
+ const rows = {};
126
+ const embeds = {};
127
+ val.rows.forEach((row, rowPosition) => {
128
+ const rowId = v4();
129
+ rows[rowId] = {
130
+ id: rowId,
131
+ position: rowPosition,
132
+ cells: {}
133
+ };
134
+ row.cells.forEach((content, cellPosition) => {
135
+ const cellId = v4();
136
+ addCell(rows[rowId], {
137
+ id: cellId,
138
+ position: cellPosition,
139
+ data: {}
140
+ });
141
+ const embed = addEmbed(embeds, cellId, tableId);
142
+ embed.data.content = content;
143
+ });
144
+ });
145
+ return {
146
+ tableId,
147
+ rows,
148
+ embeds
149
+ };
150
+ }
151
+ };
152
+ const manifest = {
153
+ type,
154
+ version: "1.0",
155
+ name,
156
+ ssr: false,
157
+ isComposite: true,
158
+ initState,
159
+ isEmpty,
160
+ ui,
161
+ ai
162
+ };
163
+ //#endregion
164
+ export { Direction, ai, manifest as default, initState, isEmpty, name, type, utils_exports as utils, version };
package/package.json CHANGED
@@ -3,52 +3,45 @@
3
3
  "description": "Tailor CMS table manifest",
4
4
  "author": "Studion <info@gostudion.com> (https://github.com/tailor-cms)",
5
5
  "type": "module",
6
- "version": "0.1.0",
6
+ "version": "2.0.1",
7
7
  "exports": {
8
8
  ".": {
9
- "import": "./dist/index.js",
9
+ "import": "./dist/index.mjs",
10
10
  "require": "./dist/index.cjs"
11
11
  }
12
12
  },
13
13
  "main": "./dist/index.cjs",
14
- "types": "./dist/index.d.ts",
14
+ "types": "./dist/index.d.mts",
15
15
  "files": [
16
16
  "dist"
17
17
  ],
18
+ "dependencies": {
19
+ "@tailor-cms/cek-common": "2.0.1",
20
+ "lodash-es": "^4.18.1",
21
+ "uuid": "^14.0.0"
22
+ },
18
23
  "devDependencies": {
19
- "@tailor-cms/cek-common": "^1.3.2",
20
- "@tailor-cms/eslint-config": "1.1.2",
24
+ "@tailor-cms/eslint-config": "2.0.1",
21
25
  "@types/lodash-es": "^4.17.12",
22
- "tsup": "^8.5.0",
23
- "typescript": "^5.8.3"
26
+ "tsdown": "^0.21.10",
27
+ "typescript": "^6.0.3"
24
28
  },
25
- "dependencies": {
26
- "lodash-es": "^4.17.21",
27
- "uuid": "^11.1.0"
28
- },
29
- "tsup": {
30
- "entry": [
31
- "src/index.ts"
32
- ],
33
- "target": [
34
- "node14",
35
- "es2022"
36
- ],
29
+ "tsdown": {
30
+ "target": "node24",
37
31
  "format": [
38
32
  "cjs",
39
33
  "esm"
40
- ],
41
- "bundle": true,
42
- "minify": false,
43
- "clean": false,
44
- "dts": true
34
+ ]
45
35
  },
46
36
  "publishConfig": {
47
37
  "access": "public"
48
38
  },
39
+ "engines": {
40
+ "node": ">=24"
41
+ },
49
42
  "scripts": {
50
- "dev": "tsup --watch",
51
- "build": "pnpm nuke:dist && tsup",
43
+ "dev": "tsdown --watch",
44
+ "build": "pnpm nuke:dist && tsdown",
52
45
  "lint": "eslint .",
53
46
  "lint:fix": "pnpm lint --fix",
54
47
  "nuke": "pnpm dlx del-cli dist node_modules",
package/dist/index.d.ts DELETED
@@ -1,57 +0,0 @@
1
- import * as common from '@tailor-cms/cek-common';
2
-
3
- declare enum Direction {
4
- Before = -1,
5
- After = 1
6
- }
7
- type Embed = any;
8
- type Embeds = Record<string, Embed>;
9
- interface Cell {
10
- id: string;
11
- data: Record<string, any>;
12
- position: number;
13
- }
14
- type Cells = Record<string, Cell>;
15
- interface Row {
16
- id: string;
17
- position: number;
18
- cells: Cells;
19
- }
20
- type Rows = Record<string, Row>;
21
- interface ElementData extends common.ElementConfig {
22
- tableId: string;
23
- embeds: Embeds;
24
- rows: Rows;
25
- }
26
- type DataInitializer = common.DataInitializer<ElementData>;
27
- type Element = common.Element<ElementData>;
28
- type ElementManifest = common.ElementManifest<ElementData>;
29
-
30
- declare function addCell(row: Row, cell: Cell): Cell;
31
- declare function removeCell(row: Row, predicate?: {}): Cell;
32
- declare function addEmbed(embeds: Embeds, cellId: string, tableId: string): {
33
- id: string;
34
- type: string;
35
- embedded: boolean;
36
- data: {
37
- tableId: string;
38
- cellId: string;
39
- };
40
- };
41
- declare function removeEmbed(embeds: Embeds, predicate?: {}): any;
42
-
43
- declare const utils_addCell: typeof addCell;
44
- declare const utils_addEmbed: typeof addEmbed;
45
- declare const utils_removeCell: typeof removeCell;
46
- declare const utils_removeEmbed: typeof removeEmbed;
47
- declare namespace utils {
48
- export { utils_addCell as addCell, utils_addEmbed as addEmbed, utils_removeCell as removeCell, utils_removeEmbed as removeEmbed };
49
- }
50
-
51
- declare const type = "TABLE";
52
- declare const name = "Table";
53
- declare const initState: DataInitializer;
54
- declare const version = "1.0";
55
- declare const manifest: ElementManifest;
56
-
57
- export { type Cell, type Cells, type DataInitializer, Direction, type Element, type ElementData, type ElementManifest, type Embed, type Embeds, type Row, type Rows, manifest as default, initState, name, type, utils, version };
package/dist/index.js DELETED
@@ -1,100 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __export = (target, all) => {
3
- for (var name2 in all)
4
- __defProp(target, name2, { get: all[name2], enumerable: true });
5
- };
6
-
7
- // src/index.ts
8
- import { times } from "lodash-es";
9
- import { v4 as uuid } from "uuid";
10
-
11
- // src/utils.ts
12
- var utils_exports = {};
13
- __export(utils_exports, {
14
- addCell: () => addCell,
15
- addEmbed: () => addEmbed,
16
- removeCell: () => removeCell,
17
- removeEmbed: () => removeEmbed
18
- });
19
- import { find } from "lodash-es";
20
- function addCell(row, cell) {
21
- if (!row.cells) row.cells = {};
22
- row.cells[cell.id] = cell;
23
- return cell;
24
- }
25
- function removeCell(row, predicate = {}) {
26
- const cell = find(row.cells, predicate);
27
- if (!cell) return;
28
- delete row.cells[cell.id];
29
- return cell;
30
- }
31
- function addEmbed(embeds, cellId, tableId) {
32
- const embed = {
33
- id: cellId,
34
- type: "JODIT_HTML",
35
- embedded: true,
36
- data: { tableId, cellId }
37
- };
38
- embeds[cellId] = embed;
39
- return embed;
40
- }
41
- function removeEmbed(embeds, predicate = {}) {
42
- const embed = find(embeds, predicate);
43
- if (!embed) return;
44
- delete embeds[embed.id];
45
- return embed;
46
- }
47
-
48
- // src/interfaces.ts
49
- var Direction = /* @__PURE__ */ ((Direction2) => {
50
- Direction2[Direction2["Before"] = -1] = "Before";
51
- Direction2[Direction2["After"] = 1] = "After";
52
- return Direction2;
53
- })(Direction || {});
54
-
55
- // src/index.ts
56
- var type = "TABLE";
57
- var name = "Table";
58
- var initState = () => {
59
- const tableId = uuid();
60
- const embeds = {};
61
- const rows = {};
62
- times(2, (position) => {
63
- const rowId = uuid();
64
- const row = { id: rowId, position, cells: {} };
65
- rows[rowId] = row;
66
- times(3, (position2) => {
67
- const cellId = uuid();
68
- addCell(row, { id: cellId, position: position2, data: {} });
69
- addEmbed(embeds, cellId, tableId);
70
- });
71
- });
72
- return { tableId, embeds, rows };
73
- };
74
- var version = "1.0";
75
- var ui = {
76
- // Display icon, https://pictogrammers.com/library/mdi/
77
- icon: "mdi-table",
78
- // Does element support only full width or can be used within layouts
79
- // (e.g. 50/50 layout)
80
- forceFullWidth: true
81
- };
82
- var manifest = {
83
- type,
84
- version: "1.0",
85
- name,
86
- ssr: false,
87
- isComposite: true,
88
- initState,
89
- ui
90
- };
91
- var index_default = manifest;
92
- export {
93
- Direction,
94
- index_default as default,
95
- initState,
96
- name,
97
- type,
98
- utils_exports as utils,
99
- version
100
- };