@sutech_jp/raas-react-client 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.
@@ -1,8 +1,10 @@
1
1
  import { CustomData, Layout, PaperFormArgs, ReportOptions, UserEditability } from './types';
2
2
  declare type Ret<D> = {
3
3
  dirty: boolean;
4
+ originalData: D;
4
5
  hasRequiredBlank: boolean;
5
6
  onInitialize: (data: D) => void;
7
+ onReset: () => void;
6
8
  paperFormArgs: Required<PaperFormArgs<D>>;
7
9
  generatePdfArgs: {
8
10
  data: D;
@@ -20,18 +20,27 @@ exports.useReportPaperForm = void 0;
20
20
  var react_1 = require("react");
21
21
  var useReportPaperForm = function (initialData, options) {
22
22
  var _a = __read((0, react_1.useState)(initialData), 2), data = _a[0], setData = _a[1];
23
- var _b = __read((0, react_1.useState)([]), 2), customData = _b[0], setCustomData = _b[1];
24
- var _c = __read((0, react_1.useState)([]), 2), reportOptions = _c[0], setReportOptions = _c[1];
25
- var _d = __read((0, react_1.useState)(), 2), layout = _d[0], setLayout = _d[1];
26
- var _e = __read((0, react_1.useState)(false), 2), dirty = _e[0], setDirty = _e[1];
27
- var _f = __read((0, react_1.useState)(false), 2), hasRequiredBlank = _f[0], setHasRequiredBlank = _f[1];
23
+ var _b = __read((0, react_1.useState)(initialData), 2), originalData = _b[0], setOriginalData = _b[1];
24
+ var _c = __read((0, react_1.useState)([]), 2), customData = _c[0], setCustomData = _c[1];
25
+ var _d = __read((0, react_1.useState)([]), 2), reportOptions = _d[0], setReportOptions = _d[1];
26
+ var _e = __read((0, react_1.useState)(), 2), layout = _e[0], setLayout = _e[1];
27
+ var _f = __read((0, react_1.useState)(false), 2), dirty = _f[0], setDirty = _f[1];
28
+ var _g = __read((0, react_1.useState)(false), 2), hasRequiredBlank = _g[0], setHasRequiredBlank = _g[1];
28
29
  var onInitialize = (0, react_1.useCallback)(function (data) {
29
30
  setData(data);
31
+ setOriginalData(data);
30
32
  setCustomData([]);
31
33
  setReportOptions([]);
32
34
  setLayout(undefined);
33
35
  setDirty(false);
34
36
  }, []);
37
+ var onReset = (0, react_1.useCallback)(function () {
38
+ setData(originalData);
39
+ setCustomData([]);
40
+ setReportOptions([]);
41
+ setLayout(undefined);
42
+ setDirty(false);
43
+ }, [originalData]);
35
44
  var onDataUpdate = (0, react_1.useCallback)(function (data, options) {
36
45
  setData(data);
37
46
  setReportOptions(options);
@@ -50,7 +59,9 @@ var useReportPaperForm = function (initialData, options) {
50
59
  return {
51
60
  dirty: dirty,
52
61
  hasRequiredBlank: hasRequiredBlank,
62
+ originalData: originalData,
53
63
  onInitialize: onInitialize,
64
+ onReset: onReset,
54
65
  paperFormArgs: {
55
66
  data: data,
56
67
  onDataUpdate: onDataUpdate,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sutech_jp/raas-react-client",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "react client for raas produced by SuTech",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",