react-ink-scripter 0.0.24 → 0.0.26

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.
@@ -4,24 +4,34 @@
4
4
  flex-direction: column;
5
5
  overflow: hidden;
6
6
  padding: 4px;
7
- font-size: 14px;
7
+ font-size: 14pt;
8
8
  }
9
9
 
10
10
  .inks-root > #title {
11
11
  text-align: center;
12
12
  flex: 1 0;
13
13
  padding: 16px;
14
- font-size: 28px;
14
+ font-size: 28pt;
15
15
  }
16
16
 
17
17
  .inks-root > #footer {
18
18
  margin: 0;
19
19
  }
20
20
 
21
+ .inks-root > #footer > .inks-grid-item {
22
+ padding: 0;
23
+ }
24
+
25
+ .inks-line {
26
+ display: flex;
27
+ flex-direction: row;
28
+ column-gap: 3em;
29
+ }
30
+
21
31
  .inks-grid {
22
- --Grid-Columns: 12;
32
+ --Grid-Columns: 24;
23
33
  --Grid-RowSpacing: 8px;
24
- --Grid-ColumnSpacing: 32px;
34
+ --Grid-ColumnSpacing: 8px;
25
35
 
26
36
  display: -webkit-box;
27
37
  display: -webkit-flex;
@@ -40,6 +50,7 @@
40
50
  flex-basis: auto;
41
51
  flex-grow: 0;
42
52
  padding: calc(var(--Grid-RowSpacing) / 2) calc(var(--Grid-ColumnSpacing) / 2);
53
+ box-sizing: border-box;
43
54
  }
44
55
 
45
56
  .inks-pair {
@@ -51,9 +62,12 @@
51
62
  }
52
63
 
53
64
  .inks-pair-value{
54
- margin-left: 16px;
65
+ margin-left: 0.5em;
55
66
  }
56
67
 
68
+ .inks-span-0 {
69
+ width: 0;
70
+ }
57
71
  .inks-span-1 {
58
72
  width: calc(100% * 1 / var(--Grid-Columns));
59
73
  }
@@ -90,6 +104,45 @@
90
104
  .inks-span-12 {
91
105
  width: calc(100% * 12 / var(--Grid-Columns));
92
106
  }
107
+ .inks-span-13 {
108
+ width: calc(100% * 13 / var(--Grid-Columns));
109
+ }
110
+ .inks-span-14 {
111
+ width: calc(100% * 14 / var(--Grid-Columns));
112
+ }
113
+ .inks-span-15 {
114
+ width: calc(100% * 15 / var(--Grid-Columns));
115
+ }
116
+ .inks-span-16 {
117
+ width: calc(100% * 16 / var(--Grid-Columns));
118
+ }
119
+ .inks-span-17 {
120
+ width: calc(100% * 17 / var(--Grid-Columns));
121
+ }
122
+ .inks-span-18 {
123
+ width: calc(100% * 18 / var(--Grid-Columns));
124
+ }
125
+ .inks-span-18 {
126
+ width: calc(100% * 18 / var(--Grid-Columns));
127
+ }
128
+ .inks-span-19 {
129
+ width: calc(100% * 19 / var(--Grid-Columns));
130
+ }
131
+ .inks-span-20 {
132
+ width: calc(100% * 20 / var(--Grid-Columns));
133
+ }
134
+ .inks-span-21 {
135
+ width: calc(100% * 21 / var(--Grid-Columns));
136
+ }
137
+ .inks-span-22 {
138
+ width: calc(100% * 22 / var(--Grid-Columns));
139
+ }
140
+ .inks-span-23 {
141
+ width: calc(100% * 23 / var(--Grid-Columns));
142
+ }
143
+ .inks-span-24 {
144
+ width: calc(100% * 24 / var(--Grid-Columns));
145
+ }
93
146
 
94
147
  .inks-table {
95
148
  --Border-Props: 0.8px solid #bbb;
package/dist/cjs/index.js CHANGED
@@ -4,7 +4,7 @@ var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
4
4
  var react = require('react');
5
5
  var reactDom = require('react-dom');
6
6
  var jsxRuntime = require('react/jsx-runtime');
7
- var clsx = require('clsx');
7
+ var _typeof = require('@babel/runtime/helpers/typeof');
8
8
  var _extends = require('@babel/runtime/helpers/extends');
9
9
 
10
10
  var IFrame = react.forwardRef(function (props, ref) {
@@ -24,7 +24,7 @@ var IFrame = react.forwardRef(function (props, ref) {
24
24
  var attachBody = iframeRef === null || iframeRef === void 0 ? void 0 : (_iframeRef$current = iframeRef.current) === null || _iframeRef$current === void 0 ? void 0 : (_iframeRef$current$co = _iframeRef$current.contentWindow) === null || _iframeRef$current$co === void 0 ? void 0 : (_iframeRef$current$co2 = _iframeRef$current$co.document) === null || _iframeRef$current$co2 === void 0 ? void 0 : _iframeRef$current$co2.body;
25
25
  var attachHead = iframeRef === null || iframeRef === void 0 ? void 0 : (_iframeRef$current2 = iframeRef.current) === null || _iframeRef$current2 === void 0 ? void 0 : (_iframeRef$current2$c = _iframeRef$current2.contentWindow) === null || _iframeRef$current2$c === void 0 ? void 0 : (_iframeRef$current2$c2 = _iframeRef$current2$c.document) === null || _iframeRef$current2$c2 === void 0 ? void 0 : _iframeRef$current2$c2.head;
26
26
  react.useImperativeHandle(ref, function () {
27
- return iframeRef === null || iframeRef === void 0 ? void 0 : iframeRef.current;
27
+ return (iframeRef === null || iframeRef === void 0 ? void 0 : iframeRef.current) || undefined;
28
28
  }, []);
29
29
  return jsxRuntime.jsxs("iframe", {
30
30
  ref: iframeRef,
@@ -37,6 +37,18 @@ var IFrame = react.forwardRef(function (props, ref) {
37
37
  });
38
38
  });
39
39
 
40
+ function r(e) {
41
+ var t,
42
+ f,
43
+ n = "";
44
+ if ("string" == typeof e || "number" == typeof e) n += e;else if ("object" == _typeof(e)) if (Array.isArray(e)) for (t = 0; t < e.length; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);else for (t in e) e[t] && (n && (n += " "), n += t);
45
+ return n;
46
+ }
47
+ function clsx() {
48
+ for (var e, t, f = 0, n = ""; f < arguments.length;) (e = arguments[f++]) && (t = r(e)) && (n && (n += " "), n += t);
49
+ return n;
50
+ }
51
+
40
52
  var PrinterFrame = react.forwardRef(function (props, ref) {
41
53
  var _iframeRef$current2, _iframeRef$current2$c, _iframeRef$current2$c2, _iframeRef$current3, _iframeRef$current3$c, _iframeRef$current3$c2, _iframeRef$current4, _iframeRef$current4$c, _iframeRef$current4$c2;
42
54
  var styleCss = props.styleCss,
@@ -160,29 +172,48 @@ var Container = function Container(_ref) {
160
172
  var id = _ref.id,
161
173
  _ref$content = _ref.content,
162
174
  content = _ref$content === void 0 ? [] : _ref$content,
163
- className = _ref.className;
175
+ className = _ref.className,
176
+ itemClass = _ref.itemClass;
164
177
  return jsxRuntime.jsx("div", {
165
178
  id: id,
166
- className: clsx('inks-grid', className),
179
+ className: className,
167
180
  children: content.map(function (item, idx) {
168
181
  switch (item.type) {
169
182
  case 'pair':
170
183
  return jsxRuntime.jsx(Pair, _extends({}, item, {
171
- className: clsx('inks-grid-item', item.className)
184
+ className: clsx(itemClass, item.className)
172
185
  }), idx);
173
186
  case 'text':
174
187
  return jsxRuntime.jsx(Text, _extends({}, item, {
175
- className: clsx('inks-grid-item', item.className)
188
+ className: clsx(itemClass, item.className)
189
+ }), idx);
190
+ case 'line':
191
+ return jsxRuntime.jsx(Line, _extends({}, item, {
192
+ className: clsx(itemClass, item.className)
176
193
  }), idx);
177
194
  }
178
195
  })
179
196
  });
180
197
  };
181
198
  var Grid = function Grid(props) {
182
- return jsxRuntime.jsx(Container, _extends({}, props));
199
+ return jsxRuntime.jsx(Container, _extends({
200
+ className: "inks-grid",
201
+ itemClass: "inks-grid-item"
202
+ }, props));
183
203
  };
184
- var TableCell = function TableCell(_ref2) {
185
- var item = _ref2.item;
204
+ var Line = function Line(_ref2) {
205
+ var id = _ref2.id,
206
+ content = _ref2.content,
207
+ span = _ref2.span,
208
+ className = _ref2.className;
209
+ return jsxRuntime.jsx(Container, {
210
+ id: id,
211
+ className: clsx('inks-line', span && "inks-span-".concat(span), className),
212
+ content: content
213
+ });
214
+ };
215
+ var TableCell = function TableCell(_ref3) {
216
+ var item = _ref3.item;
186
217
  if (typeof item === 'string') {
187
218
  return jsxRuntime.jsx("td", {
188
219
  className: "inks-cell",
@@ -212,8 +243,8 @@ var TableCell = function TableCell(_ref2) {
212
243
  children: value
213
244
  });
214
245
  };
215
- var TableRow = function TableRow(_ref3) {
216
- var cells = _ref3.cells;
246
+ var TableRow = function TableRow(_ref4) {
247
+ var cells = _ref4.cells;
217
248
  if (!cells.length) {
218
249
  return null;
219
250
  }
@@ -288,23 +319,23 @@ var Table = function Table(props) {
288
319
  })]
289
320
  });
290
321
  };
291
- var Text = function Text(_ref4) {
292
- var id = _ref4.id,
293
- value = _ref4.value,
294
- span = _ref4.span,
295
- className = _ref4.className;
322
+ var Text = function Text(_ref5) {
323
+ var id = _ref5.id,
324
+ value = _ref5.value,
325
+ span = _ref5.span,
326
+ className = _ref5.className;
296
327
  return jsxRuntime.jsx("div", {
297
328
  id: id,
298
329
  className: clsx('inks-text', span && "inks-span-".concat(span), className),
299
330
  children: value
300
331
  });
301
332
  };
302
- var Pair = function Pair(_ref5) {
303
- var id = _ref5.id,
304
- value = _ref5.value,
305
- label = _ref5.label,
306
- span = _ref5.span,
307
- className = _ref5.className;
333
+ var Pair = function Pair(_ref6) {
334
+ var id = _ref6.id,
335
+ value = _ref6.value,
336
+ label = _ref6.label,
337
+ span = _ref6.span,
338
+ className = _ref6.className;
308
339
  return jsxRuntime.jsxs("div", {
309
340
  id: id,
310
341
  className: clsx('inks-pair', span && "inks-span-".concat(span), className),
@@ -334,6 +365,8 @@ var InkScripter = react.forwardRef(function (props, ref) {
334
365
  return jsxRuntime.jsx(Text, _extends({}, item), index);
335
366
  case 'pair':
336
367
  return jsxRuntime.jsx(Pair, _extends({}, item), index);
368
+ case 'line':
369
+ return jsxRuntime.jsx(Line, _extends({}, item), index);
337
370
  }
338
371
  })
339
372
  });
@@ -1,4 +1,4 @@
1
- import type { ReactNode, ForwardRefExoticComponent, RefAttributes } from 'react';
1
+ import type { ReactNode } from 'react';
2
2
  export interface IFrameProps {
3
3
  className?: string;
4
4
  styleCss?: string;
@@ -6,4 +6,4 @@ export interface IFrameProps {
6
6
  width?: string | number;
7
7
  height?: string | number;
8
8
  }
9
- export declare const IFrame: ForwardRefExoticComponent<IFrameProps & RefAttributes<any>>;
9
+ export declare const IFrame: import("react").ForwardRefExoticComponent<IFrameProps & import("react").RefAttributes<HTMLIFrameElement | undefined>>;
@@ -14,10 +14,17 @@ export type ContentPairItem = {
14
14
  value: string;
15
15
  span?: number;
16
16
  };
17
+ export type ContentLineItem = {
18
+ id?: string;
19
+ type: 'line';
20
+ span?: number;
21
+ className?: string;
22
+ content: (ContentPairItem | ContentTextItem)[];
23
+ };
17
24
  export type ContentGridItem = {
18
25
  id?: string;
19
26
  type: 'grid';
20
- content: (ContentPairItem | ContentTextItem)[];
27
+ content: (ContentPairItem | ContentTextItem | ContentLineItem)[];
21
28
  };
22
29
  export type ContentTableCellItem = {
23
30
  id?: string;
@@ -34,7 +41,7 @@ export type ContentTableItem = {
34
41
  body?: ContentTableCellItem[][];
35
42
  foot?: ContentTableCellItem[][];
36
43
  };
37
- export type ContentItemType = ContentGridItem | ContentTableItem | ContentTextItem | ContentPairItem;
44
+ export type ContentItemType = ContentGridItem | ContentTableItem | ContentTextItem | ContentPairItem | ContentLineItem;
38
45
  export type ContentType = ContentItemType[];
39
46
  export type InkScripterProps = {
40
47
  value?: ContentType;
package/dist/esm/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import { forwardRef, useRef, useMemo, useImperativeHandle, useState, useCallback, useLayoutEffect } from 'react';
3
3
  import { createPortal } from 'react-dom';
4
- import clsx from 'clsx';
5
4
 
6
5
  const IFrame = forwardRef((props, ref) => {
7
6
  const { styleCss, className, children, width, height } = props;
@@ -12,11 +11,13 @@ const IFrame = forwardRef((props, ref) => {
12
11
  const attachBody = iframeRef?.current?.contentWindow?.document?.body;
13
12
  const attachHead = iframeRef?.current?.contentWindow?.document?.head;
14
13
  useImperativeHandle(ref, () => {
15
- return iframeRef?.current;
14
+ return iframeRef?.current || undefined;
16
15
  }, []);
17
16
  return (jsxs("iframe", { ref: iframeRef, className: className, width: frameWidth, height: frameHeight, children: [attachBody && createPortal(children, attachBody), attachHead && createPortal(jsx("style", { children: styleCss }), attachHead)] }));
18
17
  });
19
18
 
19
+ function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);else for(t in e)e[t]&&(n&&(n+=" "),n+=t);return n}function clsx(){for(var e,t,f=0,n="";f<arguments.length;)(e=arguments[f++])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
20
+
20
21
  const PrinterFrame = forwardRef((props, ref) => {
21
22
  const { styleCss, open, className, children, actionRef, src, containerId, width, height, } = props;
22
23
  const iframeRef = useRef(null);
@@ -117,18 +118,23 @@ padding-top: ${marginTop}mm;
117
118
  return pageStyle;
118
119
  };
119
120
 
120
- const Container = ({ id, content = [], className, }) => {
121
- return (jsx("div", { id: id, className: clsx('inks-grid', className), children: content.map((item, idx) => {
121
+ const Container = ({ id, content = [], className, itemClass, }) => {
122
+ return (jsx("div", { id: id, className: className, children: content.map((item, idx) => {
122
123
  switch (item.type) {
123
124
  case 'pair':
124
- return (jsx(Pair, { ...item, className: clsx('inks-grid-item', item.className) }, idx));
125
+ return (jsx(Pair, { ...item, className: clsx(itemClass, item.className) }, idx));
125
126
  case 'text':
126
- return (jsx(Text, { ...item, className: clsx('inks-grid-item', item.className) }, idx));
127
+ return (jsx(Text, { ...item, className: clsx(itemClass, item.className) }, idx));
128
+ case 'line':
129
+ return (jsx(Line, { ...item, className: clsx(itemClass, item.className) }, idx));
127
130
  }
128
131
  }) }));
129
132
  };
130
133
  const Grid = (props) => {
131
- return jsx(Container, { ...props });
134
+ return jsx(Container, { className: "inks-grid", itemClass: "inks-grid-item", ...props });
135
+ };
136
+ const Line = ({ id, content, span, className }) => {
137
+ return (jsx(Container, { id: id, className: clsx('inks-line', span && `inks-span-${span}`, className), content: content }));
132
138
  };
133
139
  const TableCell = ({ item }) => {
134
140
  if (typeof item === 'string') {
@@ -192,6 +198,8 @@ const InkScripter = forwardRef((props, ref) => {
192
198
  return jsx(Text, { ...item }, index);
193
199
  case 'pair':
194
200
  return jsx(Pair, { ...item }, index);
201
+ case 'line':
202
+ return jsx(Line, { ...item }, index);
195
203
  }
196
204
  }) }));
197
205
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-ink-scripter",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "description": "a react component for generate page to print",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -23,16 +23,13 @@
23
23
  },
24
24
  "homepage": "https://github.com/lawrsp/react-ink-scripter#readme",
25
25
  "scripts": {
26
- "dev": "start-storybook -p 6016",
26
+ "dev": "storybook dev -p 6016",
27
27
  "prepack": "json -f package.json -I -e \"delete this.devDependencies;delete this.scripts;\"",
28
28
  "build": "rimraf dist && rollup -c && yarn copy-styles",
29
29
  "copy-styles": "node ./copy-styles.mjs",
30
30
  "preview": "vite preview",
31
- "storybook": "start-storybook -p 6006",
32
- "build-storybook": "build-storybook"
33
- },
34
- "dependencies": {
35
- "clsx": "^1.2.1"
31
+ "storybook": "storybook dev -p 6006",
32
+ "build-storybook": "storybook build"
36
33
  },
37
34
  "devDependencies": {
38
35
  "@babel/core": "^7.21.0",
@@ -47,32 +44,30 @@
47
44
  "@rollup/plugin-node-resolve": "^15.0.1",
48
45
  "@rollup/plugin-strip": "^3.0.2",
49
46
  "@rollup/plugin-typescript": "^11.0.0",
50
- "@storybook/addon-actions": "^6.5.16",
51
- "@storybook/addon-essentials": "^6.5.16",
52
- "@storybook/addon-interactions": "^6.5.16",
53
- "@storybook/addon-links": "^6.5.16",
54
- "@storybook/builder-vite": "^0.4.2",
55
- "@storybook/react": "^6.5.16",
56
- "@storybook/testing-library": "^0.0.13",
57
- "@types/react": "^18.0.27",
58
- "@types/react-dom": "^18.0.10",
59
- "@vitejs/plugin-react": "^3.1.0",
47
+ "@storybook/addon-docs": "^10.1.2",
48
+ "@storybook/react-vite": "^10.1.2",
49
+ "@types/react": "^19.2.7",
50
+ "@types/react-dom": "^19.2.3",
51
+ "@vitejs/plugin-react": "^5.1.1",
60
52
  "babel-loader": "^8.3.0",
53
+ "clsx": "^1.2.1",
61
54
  "json": "^11.0.0",
62
- "react": "^18.2.0",
63
- "react-dom": "^18.2.0",
55
+ "react": "^19.2.0",
56
+ "react-dom": "^19.2.0",
64
57
  "rimraf": "^4.1.3",
65
58
  "rollup": "^3.18.0",
66
59
  "rollup-plugin-sizes": "^1.0.5",
60
+ "storybook": "^10.1.2",
67
61
  "tslib": "^2.8.1",
68
62
  "typescript": "^4.9.3",
69
- "vite": "^4.1.0"
63
+ "vite": "^7.2.4"
70
64
  },
71
65
  "peerDependencies": {
72
- "@types/react": "^17.0.0 || ^18.0.0",
73
- "@types/react-dom": "^17.0.0 || ^18.0.0",
74
- "react": "^17.0.0 || ^18.0.0",
75
- "react-dom": "^17.0.0 || ^18.0.0"
66
+ "@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0",
67
+ "@types/react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0",
68
+ "clsx": "^1.2.0 || ^2.1.0",
69
+ "react": "^17.0.0 || ^18.0.0 || ^19.0.0",
70
+ "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"
76
71
  },
77
72
  "peerDependenciesMeta": {
78
73
  "@types/react": {