react-ink-scripter 0.0.4 → 0.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.
@@ -0,0 +1,121 @@
1
+
2
+ .inks-root {
3
+ display: flex;
4
+ flex-direction: column;
5
+ overflow: hidden;
6
+ padding: 4px;
7
+ }
8
+
9
+ .inks-title{
10
+ text-align: center;
11
+ flex: 1 0;
12
+ padding: 16px;
13
+ font-size: 20px;
14
+ }
15
+
16
+ .inks-footer {
17
+ margin-left: -8px;
18
+ }
19
+
20
+ .inks-grid {
21
+ --Grid-Columns: 12;
22
+ --Grid-RowSpacing: 8px;
23
+ --Grid-ColumnSpacing: 32px;
24
+
25
+ display: -webkit-box;
26
+ display: -webkit-flex;
27
+ display: -ms-flexbox;
28
+ display: flex;
29
+
30
+ flex-direction: row;
31
+
32
+ flex-wrap: wrap;
33
+
34
+ min-width: 0;
35
+ box-sizing: border-box;
36
+ }
37
+
38
+ .inks-grid-item {
39
+ flex-basis: auto;
40
+ flex-grow: 0;
41
+ padding: calc(var(--Grid-RowSpacing) / 2) calc(var(--Grid-ColumnSpacing) / 2);
42
+ }
43
+
44
+ .inks-field {
45
+ display: flex;
46
+ flex-direction: row;
47
+ }
48
+
49
+ .inks-field-label {
50
+ }
51
+
52
+ .inks-field-value{
53
+ margin-left: 16px;
54
+ }
55
+
56
+ .inks-span-1 {
57
+ width: calc(100% * 1 / var(--Grid-Columns));
58
+ }
59
+ .inks-span-2 {
60
+ width: calc(100% * 2 / var(--Grid-Columns));
61
+ }
62
+ .inks-span-3 {
63
+ width: calc(100% * 3 / var(--Grid-Columns));
64
+ }
65
+ .inks-span-4 {
66
+ width: calc(100% * 4 / var(--Grid-Columns));
67
+ }
68
+ .inks-span-5 {
69
+ width: calc(100% * 5 / var(--Grid-Columns));
70
+ }
71
+ .inks-span-6 {
72
+ width: calc(100% * 6 / var(--Grid-Columns));
73
+ }
74
+ .inks-span-7 {
75
+ width: calc(100% * 7 / var(--Grid-Columns));
76
+ }
77
+ .inks-span-8 {
78
+ width: calc(100% * 8 / var(--Grid-Columns));
79
+ }
80
+ .inks-span-9 {
81
+ width: calc(100% * 9 / var(--Grid-Columns));
82
+ }
83
+ .inks-span-10 {
84
+ width: calc(100% * 10 / var(--Grid-Columns));
85
+ }
86
+ .inks-span-11 {
87
+ width: calc(100% * 11 / var(--Grid-Columns));
88
+ }
89
+ .inks-span-12 {
90
+ width: calc(100% * 12 / var(--Grid-Columns));
91
+ }
92
+
93
+ .inks-table {
94
+ --Border-Props: 0.8px solid #bbb;
95
+ margin: 8px 0;
96
+ padding: 0;
97
+ text-align: left;
98
+ border-spacing: 0;
99
+
100
+ border-top: var(--Border-Props);
101
+ border-left: var(--Border-Props);
102
+ }
103
+
104
+
105
+ .inks-table-head {
106
+ }
107
+ .inks-table-body{
108
+ }
109
+ .inks-table-foot{
110
+ }
111
+
112
+ .inks-table-row {
113
+ }
114
+
115
+ .inks-cell {
116
+ padding: 8px 4px;
117
+ margin: 0;
118
+ border-right: var(--Border-Props);
119
+ border-bottom: var(--Border-Props);
120
+ }
121
+
@@ -0,0 +1,21 @@
1
+ .inks-iframe-root {
2
+ position: fixed;
3
+ z-index: 1300;
4
+ top: 0;
5
+ left: 0;
6
+ width: 0;
7
+ height: 0;
8
+ background: #fff;
9
+
10
+ opacity: 0;
11
+ transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
12
+ }
13
+
14
+ .inks-iframe-root-open {
15
+ width: 100%;
16
+ height: 100%;
17
+
18
+ opacity: 1;
19
+ transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
20
+ }
21
+
package/dist/cjs/index.js CHANGED
@@ -1,27 +1,60 @@
1
1
  'use strict';
2
2
 
3
- var _extends = require('@babel/runtime/helpers/extends');
3
+ var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
4
+ var react = require('react');
5
+ var reactDom = require('react-dom');
4
6
  var clsx = require('clsx');
5
7
  var jsxRuntime = require('react/jsx-runtime');
8
+ var _extends = require('@babel/runtime/helpers/extends');
9
+
10
+ var PrinterFrame = function PrinterFrame(props) {
11
+ var _node$contentWindow, _node$contentWindow$d, _node$contentWindow2, _node$contentWindow2$;
12
+ var styleCss = props.styleCss,
13
+ open = props.open,
14
+ className = props.className,
15
+ children = props.children;
16
+ var _useState = react.useState(),
17
+ _useState2 = _slicedToArray(_useState, 2),
18
+ node = _useState2[0],
19
+ setNode = _useState2[1];
20
+ var attachBody = node === null || node === void 0 ? void 0 : (_node$contentWindow = node.contentWindow) === null || _node$contentWindow === void 0 ? void 0 : (_node$contentWindow$d = _node$contentWindow.document) === null || _node$contentWindow$d === void 0 ? void 0 : _node$contentWindow$d.body;
21
+ var attachHead = node === null || node === void 0 ? void 0 : (_node$contentWindow2 = node.contentWindow) === null || _node$contentWindow2 === void 0 ? void 0 : (_node$contentWindow2$ = _node$contentWindow2.document) === null || _node$contentWindow2$ === void 0 ? void 0 : _node$contentWindow2$.head;
22
+ return jsxRuntime.jsxs("iframe", {
23
+ ref: setNode,
24
+ className: clsx("inks-iframe-root", !!open && "inks-iframe-root-open", className),
25
+ children: [attachBody && reactDom.createPortal(children, attachBody), attachHead && reactDom.createPortal(jsxRuntime.jsxs("style", {
26
+ children: ["@media print {\n .hidden-print {\n display: none !important;\n }\n }", styleCss]
27
+ }), attachHead)]
28
+ });
29
+ };
6
30
 
7
31
  var Title = function Title(_ref) {
8
- var value = _ref.value;
32
+ var value = _ref.value,
33
+ id = _ref.id;
9
34
  return jsxRuntime.jsx("div", {
35
+ id: id,
36
+ className: "inks-title",
10
37
  children: value
11
38
  });
12
39
  };
13
40
  var Container = function Container(_ref2) {
14
- var _ref2$content = _ref2.content,
41
+ var id = _ref2.id,
42
+ _ref2$content = _ref2.content,
15
43
  content = _ref2$content === void 0 ? [] : _ref2$content,
16
44
  className = _ref2.className;
17
45
  return jsxRuntime.jsx("div", {
18
- className: clsx("ink-scripter-container", className),
46
+ id: id,
47
+ className: clsx("inks-grid", className),
19
48
  children: content.map(function (item, idx) {
20
49
  switch (item.type) {
21
50
  case "field":
22
- return jsxRuntime.jsx(Field, _extends({}, item), idx);
51
+ return jsxRuntime.jsx(Field, _extends({
52
+ className: "inks-grid-item"
53
+ }, item), idx);
23
54
  case "text":
24
- return jsxRuntime.jsx(Text, _extends({}, item), idx);
55
+ return jsxRuntime.jsx(Text, _extends({
56
+ className: "inks-grid-item"
57
+ }, item), idx);
25
58
  }
26
59
  })
27
60
  });
@@ -31,26 +64,36 @@ var Grid = function Grid(props) {
31
64
  };
32
65
  var Footer = function Footer(props) {
33
66
  return jsxRuntime.jsx(Container, _extends({}, props, {
34
- className: "ink-scripter-footer"
67
+ className: "inks-footer"
35
68
  }));
36
69
  };
37
70
  var TableCell = function TableCell(_ref3) {
38
71
  var item = _ref3.item;
39
72
  if (typeof item === "string") {
40
73
  return jsxRuntime.jsx("td", {
74
+ className: "inks-cell",
41
75
  children: item
42
76
  });
43
77
  }
44
- var header = item.header;
45
- item.span;
46
- item.offset;
47
- var value = item.value;
78
+ var id = item.id,
79
+ header = item.header,
80
+ colSpan = item.colSpan,
81
+ rowSpan = item.rowSpan,
82
+ value = item.value;
48
83
  if (header) {
49
84
  return jsxRuntime.jsx("th", {
85
+ id: id,
86
+ className: "inks-cell",
87
+ colSpan: colSpan,
88
+ rowSpan: rowSpan,
50
89
  children: value
51
90
  });
52
91
  }
53
92
  return jsxRuntime.jsx("td", {
93
+ id: id,
94
+ className: "inks-cell",
95
+ colSpan: colSpan,
96
+ rowSpan: rowSpan,
54
97
  children: value
55
98
  });
56
99
  };
@@ -60,6 +103,7 @@ var TableRow = function TableRow(_ref4) {
60
103
  return null;
61
104
  }
62
105
  return jsxRuntime.jsx("tr", {
106
+ className: "inks-table-row",
63
107
  children: cells.map(function (v, idx) {
64
108
  return jsxRuntime.jsx(TableCell, {
65
109
  item: v
@@ -73,6 +117,7 @@ var TableHead = function TableHead(props) {
73
117
  return null;
74
118
  }
75
119
  return jsxRuntime.jsx("thead", {
120
+ className: "inks-table-head",
76
121
  children: cells.map(function (v, idx) {
77
122
  return jsxRuntime.jsx(TableCell, {
78
123
  item: v
@@ -85,12 +130,13 @@ var TableFoot = function TableFoot(props) {
85
130
  if (!cells || !cells.length) {
86
131
  return null;
87
132
  }
88
- return jsxRuntime.jsx("tfoot", {
89
- children: cells.map(function (v, idx) {
133
+ return jsxRuntime.jsxs("tfoot", {
134
+ className: "inks-table-foot",
135
+ children: [cells.map(function (v, idx) {
90
136
  return jsxRuntime.jsx(TableCell, {
91
137
  item: v
92
138
  }, idx);
93
- })
139
+ }), " "]
94
140
  });
95
141
  };
96
142
  var TableBody = function TableBody(props) {
@@ -99,6 +145,7 @@ var TableBody = function TableBody(props) {
99
145
  return null;
100
146
  }
101
147
  return jsxRuntime.jsx("tbody", {
148
+ className: "inks-table-body",
102
149
  children: rows.map(function (v, idx) {
103
150
  return jsxRuntime.jsx(TableRow, {
104
151
  cells: v
@@ -107,14 +154,16 @@ var TableBody = function TableBody(props) {
107
154
  });
108
155
  };
109
156
  var Table = function Table(props) {
110
- var head = props.head,
157
+ var id = props.id,
158
+ head = props.head,
111
159
  body = props.body,
112
160
  foot = props.foot;
113
161
  if (!(head !== null && head !== void 0 && head.length) && !(body !== null && body !== void 0 && body.length) && !(foot !== null && foot !== void 0 && foot.length)) {
114
162
  return null;
115
163
  }
116
164
  return jsxRuntime.jsxs("table", {
117
- className: "ink-scripter-table",
165
+ id: id,
166
+ className: "inks-table",
118
167
  children: [jsxRuntime.jsx(TableHead, {
119
168
  cells: head
120
169
  }), jsxRuntime.jsx(TableBody, {
@@ -125,30 +174,40 @@ var Table = function Table(props) {
125
174
  });
126
175
  };
127
176
  var Text = function Text(_ref5) {
128
- var value = _ref5.value;
129
- _ref5.span;
177
+ var id = _ref5.id,
178
+ value = _ref5.value,
179
+ span = _ref5.span,
180
+ className = _ref5.className;
130
181
  return jsxRuntime.jsx("div", {
131
- className: "ink-scripter-text",
182
+ id: id,
183
+ className: clsx("inks-text", span && "inks-grid", span && "inks-span-".concat(span), className),
132
184
  children: value
133
185
  });
134
186
  };
135
187
  var Field = function Field(_ref6) {
136
- var value = _ref6.value,
137
- label = _ref6.label;
188
+ var id = _ref6.id,
189
+ value = _ref6.value,
190
+ label = _ref6.label,
191
+ span = _ref6.span,
192
+ className = _ref6.className;
138
193
  return jsxRuntime.jsxs("div", {
139
- className: "ink-scripter-filed",
194
+ id: id,
195
+ className: clsx("inks-field", span && "inks-grid", span && "inks-span-".concat(span), className),
140
196
  children: [jsxRuntime.jsxs("label", {
197
+ className: "inks-field-label",
141
198
  children: [label, ":"]
142
- }), jsxRuntime.jsx("span", {
199
+ }), jsxRuntime.jsx("div", {
200
+ className: "inks-field-value",
143
201
  children: value
144
202
  })]
145
203
  });
146
204
  };
147
- var ReactInkScripter = function ReactInkScripter(props) {
205
+ var InkScripter = function InkScripter(props) {
148
206
  var _props$value = props.value,
149
- value = _props$value === void 0 ? [] : _props$value;
207
+ value = _props$value === void 0 ? [] : _props$value,
208
+ className = props.className;
150
209
  return jsxRuntime.jsx("div", {
151
- className: "ink-scripter-root",
210
+ className: clsx("inks-root", className),
152
211
  children: value.map(function (item, index) {
153
212
  switch (item.type) {
154
213
  case "title":
@@ -168,4 +227,5 @@ var ReactInkScripter = function ReactInkScripter(props) {
168
227
  });
169
228
  };
170
229
 
171
- exports.ReactInkScripter = ReactInkScripter;
230
+ exports.InkScripter = InkScripter;
231
+ exports.PrinterFrame = PrinterFrame;
@@ -1,30 +1,37 @@
1
1
  /// <reference types="react" />
2
+ import { ClassValue } from "clsx";
2
3
  export type ContentTitleItem = {
4
+ id?: string;
3
5
  type: "title";
4
6
  value: string;
5
7
  };
6
8
  export type ContentFieldItem = {
9
+ id?: string;
7
10
  type: "field";
8
11
  label: string;
9
12
  value: string;
10
13
  span?: number;
11
14
  };
12
15
  export type ContentTextItem = {
16
+ id?: string;
13
17
  type: "text";
14
18
  value: string;
15
19
  span?: number;
16
20
  };
17
21
  export type ContentContainerItem = {
22
+ id?: string;
18
23
  type: "grid" | "footer";
19
24
  content: (ContentFieldItem | ContentTextItem)[];
20
25
  };
21
26
  export type ContentTableCellItem = {
27
+ id?: string;
22
28
  header?: boolean;
23
- span?: number;
24
- offset?: number;
29
+ rowSpan?: number;
30
+ colSpan?: number;
25
31
  value: string;
26
32
  } | string;
27
33
  export type ContentTableItem = {
34
+ id?: string;
28
35
  type: "table";
29
36
  head?: ContentTableCellItem[];
30
37
  body?: ContentTableCellItem[][];
@@ -33,6 +40,10 @@ export type ContentTableItem = {
33
40
  export type ContentType = (ContentTitleItem | ContentContainerItem | ContentTableItem | ContentTextItem | ContentFieldItem)[];
34
41
  export type ReactInkScripterProps = {
35
42
  value?: ContentType;
43
+ className?: string;
44
+ };
45
+ export type TypeWithClassName<T> = T & {
46
+ className?: ClassValue;
36
47
  };
37
- export declare const ReactInkScripter: (props: ReactInkScripterProps) => JSX.Element;
38
- export default ReactInkScripter;
48
+ export declare const InkScripter: (props: ReactInkScripterProps) => JSX.Element;
49
+ export default InkScripter;
@@ -0,0 +1,9 @@
1
+ import { ReactNode } from "react";
2
+ export interface PrinterFrameProps {
3
+ styleCss?: string;
4
+ open?: boolean;
5
+ className?: string;
6
+ children?: ReactNode;
7
+ }
8
+ export declare const PrinterFrame: (props: PrinterFrameProps) => JSX.Element;
9
+ export default PrinterFrame;
@@ -0,0 +1,2 @@
1
+ export * from "./PrinterFrame";
2
+ export * from "./InkScripter";
@@ -0,0 +1,108 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { useState } from 'react';
3
+ import { createPortal } from 'react-dom';
4
+ import clsx from 'clsx';
5
+
6
+ const PrinterFrame = (props) => {
7
+ const { styleCss, open, className, children } = props;
8
+ const [node, setNode] = useState();
9
+ const attachBody = node?.contentWindow?.document?.body;
10
+ const attachHead = node?.contentWindow?.document?.head;
11
+ return (jsxs("iframe", { ref: setNode, className: clsx("inks-iframe-root", !!open && "inks-iframe-root-open", className), children: [attachBody && createPortal(children, attachBody), attachHead &&
12
+ createPortal(jsxs("style", { children: [`@media print {
13
+ .hidden-print {
14
+ display: none !important;
15
+ }
16
+ }`, styleCss] }), attachHead)] }));
17
+ };
18
+
19
+ const Title = ({ value, id }) => {
20
+ return (jsx("div", { id: id, className: "inks-title", children: value }));
21
+ };
22
+ const Container = ({ id, content = [], className, }) => {
23
+ return (jsx("div", { id: id, className: clsx("inks-grid", className), children: content.map((item, idx) => {
24
+ switch (item.type) {
25
+ case "field":
26
+ return jsx(Field, { className: "inks-grid-item", ...item }, idx);
27
+ case "text":
28
+ return jsx(Text, { className: "inks-grid-item", ...item }, idx);
29
+ }
30
+ }) }));
31
+ };
32
+ const Grid = (props) => {
33
+ return jsx(Container, { ...props });
34
+ };
35
+ const Footer = (props) => {
36
+ return jsx(Container, { ...props, className: "inks-footer" });
37
+ };
38
+ const TableCell = ({ item }) => {
39
+ if (typeof item === "string") {
40
+ return jsx("td", { className: "inks-cell", children: item });
41
+ }
42
+ const { id, header, colSpan, rowSpan, value } = item;
43
+ if (header) {
44
+ return (jsx("th", { id: id, className: "inks-cell", colSpan: colSpan, rowSpan: rowSpan, children: value }));
45
+ }
46
+ return (jsx("td", { id: id, className: "inks-cell", colSpan: colSpan, rowSpan: rowSpan, children: value }));
47
+ };
48
+ const TableRow = ({ cells }) => {
49
+ if (!cells.length) {
50
+ return null;
51
+ }
52
+ return (jsx("tr", { className: "inks-table-row", children: cells.map((v, idx) => (jsx(TableCell, { item: v }, idx))) }));
53
+ };
54
+ const TableHead = (props) => {
55
+ const { cells } = props;
56
+ if (!cells || !cells.length) {
57
+ return null;
58
+ }
59
+ return (jsx("thead", { className: "inks-table-head", children: cells.map((v, idx) => (jsx(TableCell, { item: v }, idx))) }));
60
+ };
61
+ const TableFoot = (props) => {
62
+ const { cells } = props;
63
+ if (!cells || !cells.length) {
64
+ return null;
65
+ }
66
+ return (jsxs("tfoot", { className: "inks-table-foot", children: [cells.map((v, idx) => (jsx(TableCell, { item: v }, idx))), " "] }));
67
+ };
68
+ const TableBody = (props) => {
69
+ const { rows } = props;
70
+ if (!rows || !rows.length) {
71
+ return null;
72
+ }
73
+ return (jsx("tbody", { className: "inks-table-body", children: rows.map((v, idx) => (jsx(TableRow, { cells: v }, idx))) }));
74
+ };
75
+ const Table = (props) => {
76
+ const { id, head, body, foot } = props;
77
+ if (!head?.length && !body?.length && !foot?.length) {
78
+ return null;
79
+ }
80
+ return (jsxs("table", { id: id, className: "inks-table", children: [jsx(TableHead, { cells: head }), jsx(TableBody, { rows: body }), jsx(TableFoot, { cells: foot })] }));
81
+ };
82
+ const Text = ({ id, value, span, className, }) => {
83
+ return (jsx("div", { id: id, className: clsx("inks-text", span && "inks-grid", span && `inks-span-${span}`, className), children: value }));
84
+ };
85
+ const Field = ({ id, value, label, span, className, }) => {
86
+ return (jsxs("div", { id: id, className: clsx("inks-field", span && "inks-grid", span && `inks-span-${span}`, className), children: [jsxs("label", { className: "inks-field-label", children: [label, ":"] }), jsx("div", { className: "inks-field-value", children: value })] }));
87
+ };
88
+ const InkScripter = (props) => {
89
+ const { value = [], className } = props;
90
+ return (jsx("div", { className: clsx("inks-root", className), children: value.map((item, index) => {
91
+ switch (item.type) {
92
+ case "title":
93
+ return jsx(Title, { ...item }, index);
94
+ case "footer":
95
+ return jsx(Footer, { ...item }, index);
96
+ case "grid":
97
+ return jsx(Grid, { ...item }, index);
98
+ case "table":
99
+ return jsx(Table, { ...item }, index);
100
+ case "text":
101
+ return jsx(Text, { ...item }, index);
102
+ case "field":
103
+ return jsx(Field, { ...item }, index);
104
+ }
105
+ }) }));
106
+ };
107
+
108
+ export { InkScripter, PrinterFrame };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "react-ink-scripter",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "a react component for generate page to print",
5
5
  "main": "dist/cjs/index.js",
6
- "module": "dist/index.js",
7
- "types": "dist/index.d.ts",
6
+ "module": "dist/esm/index.js",
7
+ "types": "dist/esm/index.d.ts",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "git+https://github.com/lawrsp/react-ink-scripter.git"
package/dist/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./ReactInkScripter";
package/dist/index.js DELETED
@@ -1,93 +0,0 @@
1
- import { jsx, jsxs } from 'react/jsx-runtime';
2
- import clsx from 'clsx';
3
-
4
- const Title = ({ value }) => {
5
- return jsx("div", { children: value });
6
- };
7
- const Container = ({ content = [], className, }) => {
8
- return (jsx("div", { className: clsx("ink-scripter-container", className), children: content.map((item, idx) => {
9
- switch (item.type) {
10
- case "field":
11
- return jsx(Field, { ...item }, idx);
12
- case "text":
13
- return jsx(Text, { ...item }, idx);
14
- }
15
- }) }));
16
- };
17
- const Grid = (props) => {
18
- return jsx(Container, { ...props });
19
- };
20
- const Footer = (props) => {
21
- return jsx(Container, { ...props, className: "ink-scripter-footer" });
22
- };
23
- const TableCell = ({ item }) => {
24
- if (typeof item === "string") {
25
- return jsx("td", { children: item });
26
- }
27
- const { header, span, offset, value } = item;
28
- if (header) {
29
- return jsx("th", { children: value });
30
- }
31
- return jsx("td", { children: value });
32
- };
33
- const TableRow = ({ cells }) => {
34
- if (!cells.length) {
35
- return null;
36
- }
37
- return (jsx("tr", { children: cells.map((v, idx) => (jsx(TableCell, { item: v }, idx))) }));
38
- };
39
- const TableHead = (props) => {
40
- const { cells } = props;
41
- if (!cells || !cells.length) {
42
- return null;
43
- }
44
- return (jsx("thead", { children: cells.map((v, idx) => (jsx(TableCell, { item: v }, idx))) }));
45
- };
46
- const TableFoot = (props) => {
47
- const { cells } = props;
48
- if (!cells || !cells.length) {
49
- return null;
50
- }
51
- return (jsx("tfoot", { children: cells.map((v, idx) => (jsx(TableCell, { item: v }, idx))) }));
52
- };
53
- const TableBody = (props) => {
54
- const { rows } = props;
55
- if (!rows || !rows.length) {
56
- return null;
57
- }
58
- return (jsx("tbody", { children: rows.map((v, idx) => (jsx(TableRow, { cells: v }, idx))) }));
59
- };
60
- const Table = (props) => {
61
- const { head, body, foot } = props;
62
- if (!head?.length && !body?.length && !foot?.length) {
63
- return null;
64
- }
65
- return (jsxs("table", { className: "ink-scripter-table", children: [jsx(TableHead, { cells: head }), jsx(TableBody, { rows: body }), jsx(TableFoot, { cells: foot })] }));
66
- };
67
- const Text = ({ value, span }) => {
68
- return jsx("div", { className: "ink-scripter-text", children: value });
69
- };
70
- const Field = ({ value, label }) => {
71
- return (jsxs("div", { className: "ink-scripter-filed", children: [jsxs("label", { children: [label, ":"] }), jsx("span", { children: value })] }));
72
- };
73
- const ReactInkScripter = (props) => {
74
- const { value = [] } = props;
75
- return (jsx("div", { className: "ink-scripter-root", children: value.map((item, index) => {
76
- switch (item.type) {
77
- case "title":
78
- return jsx(Title, { ...item }, index);
79
- case "footer":
80
- return jsx(Footer, { ...item }, index);
81
- case "grid":
82
- return jsx(Grid, { ...item }, index);
83
- case "table":
84
- return jsx(Table, { ...item }, index);
85
- case "text":
86
- return jsx(Text, { ...item }, index);
87
- case "field":
88
- return jsx(Field, { ...item }, index);
89
- }
90
- }) }));
91
- };
92
-
93
- export { ReactInkScripter };