react-ink-scripter 0.0.10 → 0.0.11
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/InkScripter.css +5 -5
- package/dist/cjs/index.js +41 -59
- package/dist/esm/InkScripter.d.ts +11 -16
- package/dist/esm/index.js +13 -23
- package/package.json +1 -1
package/dist/InkScripter.css
CHANGED
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
padding: 4px;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
.inks-title{
|
|
9
|
+
.inks-root > #title {
|
|
10
10
|
text-align: center;
|
|
11
11
|
flex: 1 0;
|
|
12
12
|
padding: 16px;
|
|
13
13
|
font-size: 20px;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
.inks-footer {
|
|
16
|
+
.inks-root > #footer {
|
|
17
17
|
margin-left: -8px;
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -41,15 +41,15 @@
|
|
|
41
41
|
padding: calc(var(--Grid-RowSpacing) / 2) calc(var(--Grid-ColumnSpacing) / 2);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
.inks-
|
|
44
|
+
.inks-pair {
|
|
45
45
|
display: flex;
|
|
46
46
|
flex-direction: row;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
.inks-
|
|
49
|
+
.inks-pair-label {
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
.inks-
|
|
52
|
+
.inks-pair-value{
|
|
53
53
|
margin-left: 16px;
|
|
54
54
|
}
|
|
55
55
|
|
package/dist/cjs/index.js
CHANGED
|
@@ -60,27 +60,18 @@ var PrinterFrame = function PrinterFrame(props) {
|
|
|
60
60
|
});
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
var
|
|
64
|
-
var
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
className: "inks-title",
|
|
69
|
-
children: value
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
|
-
var Container = function Container(_ref2) {
|
|
73
|
-
var id = _ref2.id,
|
|
74
|
-
_ref2$content = _ref2.content,
|
|
75
|
-
content = _ref2$content === void 0 ? [] : _ref2$content,
|
|
76
|
-
className = _ref2.className;
|
|
63
|
+
var Container = function Container(_ref) {
|
|
64
|
+
var id = _ref.id,
|
|
65
|
+
_ref$content = _ref.content,
|
|
66
|
+
content = _ref$content === void 0 ? [] : _ref$content,
|
|
67
|
+
className = _ref.className;
|
|
77
68
|
return jsxRuntime.jsx("div", {
|
|
78
69
|
id: id,
|
|
79
70
|
className: clsx("inks-grid", className),
|
|
80
71
|
children: content.map(function (item, idx) {
|
|
81
72
|
switch (item.type) {
|
|
82
|
-
case "
|
|
83
|
-
return jsxRuntime.jsx(
|
|
73
|
+
case "pair":
|
|
74
|
+
return jsxRuntime.jsx(Pair, _extends({
|
|
84
75
|
className: "inks-grid-item"
|
|
85
76
|
}, item), idx);
|
|
86
77
|
case "text":
|
|
@@ -94,13 +85,8 @@ var Container = function Container(_ref2) {
|
|
|
94
85
|
var Grid = function Grid(props) {
|
|
95
86
|
return jsxRuntime.jsx(Container, _extends({}, props));
|
|
96
87
|
};
|
|
97
|
-
var
|
|
98
|
-
|
|
99
|
-
className: "inks-footer"
|
|
100
|
-
}));
|
|
101
|
-
};
|
|
102
|
-
var TableCell = function TableCell(_ref3) {
|
|
103
|
-
var item = _ref3.item;
|
|
88
|
+
var TableCell = function TableCell(_ref2) {
|
|
89
|
+
var item = _ref2.item;
|
|
104
90
|
if (typeof item === "string") {
|
|
105
91
|
return jsxRuntime.jsx("td", {
|
|
106
92
|
className: "inks-cell",
|
|
@@ -129,8 +115,8 @@ var TableCell = function TableCell(_ref3) {
|
|
|
129
115
|
children: value
|
|
130
116
|
});
|
|
131
117
|
};
|
|
132
|
-
var TableRow = function TableRow(
|
|
133
|
-
var cells =
|
|
118
|
+
var TableRow = function TableRow(_ref3) {
|
|
119
|
+
var cells = _ref3.cells;
|
|
134
120
|
if (!cells.length) {
|
|
135
121
|
return null;
|
|
136
122
|
}
|
|
@@ -144,31 +130,31 @@ var TableRow = function TableRow(_ref4) {
|
|
|
144
130
|
});
|
|
145
131
|
};
|
|
146
132
|
var TableHead = function TableHead(props) {
|
|
147
|
-
var
|
|
148
|
-
if (!
|
|
133
|
+
var rows = props.rows;
|
|
134
|
+
if (!rows || !rows.length) {
|
|
149
135
|
return null;
|
|
150
136
|
}
|
|
151
137
|
return jsxRuntime.jsx("thead", {
|
|
152
138
|
className: "inks-table-head",
|
|
153
|
-
children:
|
|
154
|
-
return jsxRuntime.jsx(
|
|
155
|
-
|
|
139
|
+
children: rows.map(function (v, idx) {
|
|
140
|
+
return jsxRuntime.jsx(TableRow, {
|
|
141
|
+
cells: v
|
|
156
142
|
}, idx);
|
|
157
143
|
})
|
|
158
144
|
});
|
|
159
145
|
};
|
|
160
146
|
var TableFoot = function TableFoot(props) {
|
|
161
|
-
var
|
|
162
|
-
if (!
|
|
147
|
+
var rows = props.rows;
|
|
148
|
+
if (!rows || !rows.length) {
|
|
163
149
|
return null;
|
|
164
150
|
}
|
|
165
|
-
return jsxRuntime.
|
|
151
|
+
return jsxRuntime.jsx("tfoot", {
|
|
166
152
|
className: "inks-table-foot",
|
|
167
|
-
children:
|
|
168
|
-
return jsxRuntime.jsx(
|
|
169
|
-
|
|
153
|
+
children: rows.map(function (v, idx) {
|
|
154
|
+
return jsxRuntime.jsx(TableRow, {
|
|
155
|
+
cells: v
|
|
170
156
|
}, idx);
|
|
171
|
-
})
|
|
157
|
+
})
|
|
172
158
|
});
|
|
173
159
|
};
|
|
174
160
|
var TableBody = function TableBody(props) {
|
|
@@ -197,39 +183,39 @@ var Table = function Table(props) {
|
|
|
197
183
|
id: id,
|
|
198
184
|
className: "inks-table",
|
|
199
185
|
children: [jsxRuntime.jsx(TableHead, {
|
|
200
|
-
|
|
186
|
+
rows: head
|
|
201
187
|
}), jsxRuntime.jsx(TableBody, {
|
|
202
188
|
rows: body
|
|
203
189
|
}), jsxRuntime.jsx(TableFoot, {
|
|
204
|
-
|
|
190
|
+
rows: foot
|
|
205
191
|
})]
|
|
206
192
|
});
|
|
207
193
|
};
|
|
208
|
-
var Text = function Text(
|
|
209
|
-
var id =
|
|
210
|
-
value =
|
|
211
|
-
span =
|
|
212
|
-
className =
|
|
194
|
+
var Text = function Text(_ref4) {
|
|
195
|
+
var id = _ref4.id,
|
|
196
|
+
value = _ref4.value,
|
|
197
|
+
span = _ref4.span,
|
|
198
|
+
className = _ref4.className;
|
|
213
199
|
return jsxRuntime.jsx("div", {
|
|
214
200
|
id: id,
|
|
215
201
|
className: clsx("inks-text", span && "inks-grid", span && "inks-span-".concat(span), className),
|
|
216
202
|
children: value
|
|
217
203
|
});
|
|
218
204
|
};
|
|
219
|
-
var
|
|
220
|
-
var id =
|
|
221
|
-
value =
|
|
222
|
-
label =
|
|
223
|
-
span =
|
|
224
|
-
className =
|
|
205
|
+
var Pair = function Pair(_ref5) {
|
|
206
|
+
var id = _ref5.id,
|
|
207
|
+
value = _ref5.value,
|
|
208
|
+
label = _ref5.label,
|
|
209
|
+
span = _ref5.span,
|
|
210
|
+
className = _ref5.className;
|
|
225
211
|
return jsxRuntime.jsxs("div", {
|
|
226
212
|
id: id,
|
|
227
|
-
className: clsx("inks-
|
|
213
|
+
className: clsx("inks-pair", span && "inks-grid", span && "inks-span-".concat(span), className),
|
|
228
214
|
children: [jsxRuntime.jsxs("label", {
|
|
229
|
-
className: "inks-
|
|
215
|
+
className: "inks-pair-label",
|
|
230
216
|
children: [label, ":"]
|
|
231
217
|
}), jsxRuntime.jsx("div", {
|
|
232
|
-
className: "inks-
|
|
218
|
+
className: "inks-pair-value",
|
|
233
219
|
children: value
|
|
234
220
|
})]
|
|
235
221
|
});
|
|
@@ -242,18 +228,14 @@ var InkScripter = function InkScripter(props) {
|
|
|
242
228
|
className: clsx("inks-root", className),
|
|
243
229
|
children: value.map(function (item, index) {
|
|
244
230
|
switch (item.type) {
|
|
245
|
-
case "title":
|
|
246
|
-
return jsxRuntime.jsx(Title, _extends({}, item), index);
|
|
247
|
-
case "footer":
|
|
248
|
-
return jsxRuntime.jsx(Footer, _extends({}, item), index);
|
|
249
231
|
case "grid":
|
|
250
232
|
return jsxRuntime.jsx(Grid, _extends({}, item), index);
|
|
251
233
|
case "table":
|
|
252
234
|
return jsxRuntime.jsx(Table, _extends({}, item), index);
|
|
253
235
|
case "text":
|
|
254
236
|
return jsxRuntime.jsx(Text, _extends({}, item), index);
|
|
255
|
-
case "
|
|
256
|
-
return jsxRuntime.jsx(
|
|
237
|
+
case "pair":
|
|
238
|
+
return jsxRuntime.jsx(Pair, _extends({}, item), index);
|
|
257
239
|
}
|
|
258
240
|
})
|
|
259
241
|
});
|
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ClassValue } from "clsx";
|
|
3
|
-
export type
|
|
4
|
-
id?: string;
|
|
5
|
-
type: "title";
|
|
6
|
-
value: string;
|
|
7
|
-
};
|
|
8
|
-
export type ContentFieldItem = {
|
|
3
|
+
export type ContentTextItem = {
|
|
9
4
|
id?: string;
|
|
10
|
-
type: "
|
|
11
|
-
label: string;
|
|
5
|
+
type: "text";
|
|
12
6
|
value: string;
|
|
13
7
|
span?: number;
|
|
14
8
|
};
|
|
15
|
-
export type
|
|
9
|
+
export type ContentPairItem = {
|
|
16
10
|
id?: string;
|
|
17
|
-
type: "
|
|
11
|
+
type: "pair";
|
|
12
|
+
label: string;
|
|
18
13
|
value: string;
|
|
19
14
|
span?: number;
|
|
20
15
|
};
|
|
21
|
-
export type
|
|
16
|
+
export type ContentGridItem = {
|
|
22
17
|
id?: string;
|
|
23
|
-
type: "grid"
|
|
24
|
-
content: (
|
|
18
|
+
type: "grid";
|
|
19
|
+
content: (ContentPairItem | ContentTextItem)[];
|
|
25
20
|
};
|
|
26
21
|
export type ContentTableCellItem = {
|
|
27
22
|
id?: string;
|
|
@@ -33,11 +28,11 @@ export type ContentTableCellItem = {
|
|
|
33
28
|
export type ContentTableItem = {
|
|
34
29
|
id?: string;
|
|
35
30
|
type: "table";
|
|
36
|
-
head?: ContentTableCellItem[];
|
|
31
|
+
head?: ContentTableCellItem[][];
|
|
37
32
|
body?: ContentTableCellItem[][];
|
|
38
|
-
foot?: ContentTableCellItem[];
|
|
33
|
+
foot?: ContentTableCellItem[][];
|
|
39
34
|
};
|
|
40
|
-
export type ContentItemType =
|
|
35
|
+
export type ContentItemType = ContentGridItem | ContentTableItem | ContentTextItem | ContentPairItem;
|
|
41
36
|
export type ContentType = ContentItemType[];
|
|
42
37
|
export type ReactInkScripterProps = {
|
|
43
38
|
value?: ContentType;
|
package/dist/esm/index.js
CHANGED
|
@@ -42,14 +42,11 @@ const PrinterFrame = (props) => {
|
|
|
42
42
|
`, styleCss] }), attachStyle), !!attachNode && createPortal(children, attachNode)] }));
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
const Title = ({ value, id }) => {
|
|
46
|
-
return (jsx("div", { id: id, className: "inks-title", children: value }));
|
|
47
|
-
};
|
|
48
45
|
const Container = ({ id, content = [], className, }) => {
|
|
49
46
|
return (jsx("div", { id: id, className: clsx("inks-grid", className), children: content.map((item, idx) => {
|
|
50
47
|
switch (item.type) {
|
|
51
|
-
case "
|
|
52
|
-
return jsx(
|
|
48
|
+
case "pair":
|
|
49
|
+
return jsx(Pair, { className: "inks-grid-item", ...item }, idx);
|
|
53
50
|
case "text":
|
|
54
51
|
return jsx(Text, { className: "inks-grid-item", ...item }, idx);
|
|
55
52
|
}
|
|
@@ -58,9 +55,6 @@ const Container = ({ id, content = [], className, }) => {
|
|
|
58
55
|
const Grid = (props) => {
|
|
59
56
|
return jsx(Container, { ...props });
|
|
60
57
|
};
|
|
61
|
-
const Footer = (props) => {
|
|
62
|
-
return jsx(Container, { ...props, className: "inks-footer" });
|
|
63
|
-
};
|
|
64
58
|
const TableCell = ({ item }) => {
|
|
65
59
|
if (typeof item === "string") {
|
|
66
60
|
return jsx("td", { className: "inks-cell", children: item });
|
|
@@ -78,18 +72,18 @@ const TableRow = ({ cells }) => {
|
|
|
78
72
|
return (jsx("tr", { className: "inks-table-row", children: cells.map((v, idx) => (jsx(TableCell, { item: v }, idx))) }));
|
|
79
73
|
};
|
|
80
74
|
const TableHead = (props) => {
|
|
81
|
-
const {
|
|
82
|
-
if (!
|
|
75
|
+
const { rows } = props;
|
|
76
|
+
if (!rows || !rows.length) {
|
|
83
77
|
return null;
|
|
84
78
|
}
|
|
85
|
-
return (jsx("thead", { className: "inks-table-head", children:
|
|
79
|
+
return (jsx("thead", { className: "inks-table-head", children: rows.map((v, idx) => (jsx(TableRow, { cells: v }, idx))) }));
|
|
86
80
|
};
|
|
87
81
|
const TableFoot = (props) => {
|
|
88
|
-
const {
|
|
89
|
-
if (!
|
|
82
|
+
const { rows } = props;
|
|
83
|
+
if (!rows || !rows.length) {
|
|
90
84
|
return null;
|
|
91
85
|
}
|
|
92
|
-
return (
|
|
86
|
+
return (jsx("tfoot", { className: "inks-table-foot", children: rows.map((v, idx) => (jsx(TableRow, { cells: v }, idx))) }));
|
|
93
87
|
};
|
|
94
88
|
const TableBody = (props) => {
|
|
95
89
|
const { rows } = props;
|
|
@@ -103,30 +97,26 @@ const Table = (props) => {
|
|
|
103
97
|
if (!head?.length && !body?.length && !foot?.length) {
|
|
104
98
|
return null;
|
|
105
99
|
}
|
|
106
|
-
return (jsxs("table", { id: id, className: "inks-table", children: [jsx(TableHead, {
|
|
100
|
+
return (jsxs("table", { id: id, className: "inks-table", children: [jsx(TableHead, { rows: head }), jsx(TableBody, { rows: body }), jsx(TableFoot, { rows: foot })] }));
|
|
107
101
|
};
|
|
108
102
|
const Text = ({ id, value, span, className, }) => {
|
|
109
103
|
return (jsx("div", { id: id, className: clsx("inks-text", span && "inks-grid", span && `inks-span-${span}`, className), children: value }));
|
|
110
104
|
};
|
|
111
|
-
const
|
|
112
|
-
return (jsxs("div", { id: id, className: clsx("inks-
|
|
105
|
+
const Pair = ({ id, value, label, span, className, }) => {
|
|
106
|
+
return (jsxs("div", { id: id, className: clsx("inks-pair", span && "inks-grid", span && `inks-span-${span}`, className), children: [jsxs("label", { className: "inks-pair-label", children: [label, ":"] }), jsx("div", { className: "inks-pair-value", children: value })] }));
|
|
113
107
|
};
|
|
114
108
|
const InkScripter = (props) => {
|
|
115
109
|
const { value = [], className } = props;
|
|
116
110
|
return (jsx("div", { className: clsx("inks-root", className), children: value.map((item, index) => {
|
|
117
111
|
switch (item.type) {
|
|
118
|
-
case "title":
|
|
119
|
-
return jsx(Title, { ...item }, index);
|
|
120
|
-
case "footer":
|
|
121
|
-
return jsx(Footer, { ...item }, index);
|
|
122
112
|
case "grid":
|
|
123
113
|
return jsx(Grid, { ...item }, index);
|
|
124
114
|
case "table":
|
|
125
115
|
return jsx(Table, { ...item }, index);
|
|
126
116
|
case "text":
|
|
127
117
|
return jsx(Text, { ...item }, index);
|
|
128
|
-
case "
|
|
129
|
-
return jsx(
|
|
118
|
+
case "pair":
|
|
119
|
+
return jsx(Pair, { ...item }, index);
|
|
130
120
|
}
|
|
131
121
|
}) }));
|
|
132
122
|
};
|