@thx/controls 16.0.0-alpha.0 → 16.0.0-alpha.23
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/LICENSE +1 -1
- package/dist/esm/date/LocalDatePicker/LocalDatePicker.js +118 -0
- package/dist/esm/date/LocalDatePicker/MaskedDateInput.js +50 -0
- package/dist/esm/date/LocalMonthSelect/LocalMonthSelect.js +68 -0
- package/dist/esm/date/LocalTimePicker/LocalTimePicker.js +120 -0
- package/dist/esm/date/LocalTimePicker/MaskedTimeInput.js +46 -0
- package/dist/esm/date/MonthDayPicker/MonthDayPicker.js +130 -0
- package/dist/esm/date/MonthYearPicker/MonthYearPicker.js +119 -0
- package/dist/esm/date/YearSelect/YearSelect.js +87 -0
- package/dist/esm/form/TForm/TForm.js +28 -0
- package/dist/esm/form/TForm/useTForm.js +121 -0
- package/dist/esm/index.js +31 -0
- package/dist/esm/inputs/CreditCardInput/CreditCardInput.js +69 -0
- package/dist/esm/inputs/CreditCardInput/CreditCardNumberInput.js +105 -0
- package/dist/esm/inputs/MaskedInput/MaskedInput.js +45 -0
- package/dist/esm/inputs/MaskedInput/useMaskedInput.js +76 -0
- package/dist/esm/inputs/PhoneInput/PhoneInput.js +48 -0
- package/dist/esm/inputs/RadioGroup/RadioGroup.js +50 -0
- package/dist/esm/inputs/Scriptel/Scriptel.js +51 -0
- package/dist/esm/inputs/Scriptel/ScriptelContext.js +5 -0
- package/dist/esm/inputs/Scriptel/scriptel/enums.js +20 -0
- package/dist/esm/inputs/Scriptel/scriptel/index.js +92 -0
- package/dist/esm/inputs/Scriptel/withScriptel.js +25 -0
- package/dist/esm/inputs/ScriptelInput/ScriptelInput.js +69 -0
- package/dist/esm/inputs/SinInput/SinInput.js +83 -0
- package/dist/esm/inputs/TableInput/DropdownCell.js +54 -0
- package/dist/esm/inputs/TableInput/HoverCell.js +32 -0
- package/dist/esm/inputs/TableInput/MoneyCell.js +11 -0
- package/dist/esm/inputs/TableInput/MoneyEditCell.js +29 -0
- package/dist/esm/inputs/TableInput/MoneySumFooter.js +13 -0
- package/dist/esm/inputs/TableInput/StringEditCell.js +52 -0
- package/dist/esm/inputs/TableInput/TableInput.js +77 -0
- package/dist/esm/inputs/TableInput/addRowOnTab.js +12 -0
- package/dist/esm/money/MoneyCurrencyInput/MoneyCurrencyInput.js +80 -0
- package/dist/esm/money/MoneyInput/MoneyInput.js +56 -0
- package/dist/esm/money/useMoneyInput.js +76 -0
- package/dist/esm/step/FormStep.js +16 -0
- package/dist/esm/step/Step.js +8 -0
- package/dist/esm/step/StepProvider.js +114 -0
- package/dist/esm/step/stepContext.js +9 -0
- package/dist/esm/step/useStep.js +9 -0
- package/dist/{date → types/date}/DatePicker/index.d.ts +0 -0
- package/dist/{date → types/date}/LocalDatePicker/LocalDatePicker.d.ts +0 -0
- package/dist/{date → types/date}/LocalDatePicker/MaskedDateInput.d.ts +0 -0
- package/dist/{date → types/date}/LocalDatePicker/index.d.ts +0 -0
- package/dist/{date → types/date}/LocalMonthSelect/LocalMonthSelect.d.ts +0 -0
- package/dist/{date → types/date}/LocalMonthSelect/index.d.ts +0 -0
- package/dist/{date → types/date}/LocalTimePicker/LocalTimePicker.d.ts +0 -0
- package/dist/{date → types/date}/LocalTimePicker/MaskedTimeInput.d.ts +0 -0
- package/dist/{date → types/date}/LocalTimePicker/index.d.ts +0 -0
- package/dist/{date → types/date}/MonthDayPicker/MonthDayPicker.d.ts +0 -0
- package/dist/{date → types/date}/MonthDayPicker/index.d.ts +0 -0
- package/dist/{date → types/date}/MonthYearPicker/MonthYearPicker.d.ts +0 -0
- package/dist/{date → types/date}/MonthYearPicker/index.d.ts +0 -0
- package/dist/{date → types/date}/YearSelect/YearSelect.d.ts +0 -0
- package/dist/{date → types/date}/YearSelect/index.d.ts +0 -0
- package/dist/{form → types/form}/TForm/TForm.d.ts +0 -0
- package/dist/{form → types/form}/TForm/index.d.ts +0 -0
- package/dist/{form → types/form}/TForm/types.d.ts +0 -0
- package/dist/{form → types/form}/TForm/useTForm.d.ts +0 -0
- package/dist/{index.d.ts → types/index.d.ts} +2 -1
- package/dist/{inputs → types/inputs}/CreditCardInput/CreditCardInput.d.ts +0 -0
- package/dist/{inputs → types/inputs}/CreditCardInput/CreditCardNumberInput.d.ts +0 -0
- package/dist/{inputs → types/inputs}/CreditCardInput/index.d.ts +0 -0
- package/dist/{inputs → types/inputs}/MaskedInput/MaskedInput.d.ts +0 -0
- package/dist/{inputs → types/inputs}/MaskedInput/index.d.ts +0 -0
- package/dist/{inputs → types/inputs}/MaskedInput/useMaskedInput.d.ts +0 -0
- package/dist/{inputs → types/inputs}/PhoneInput/PhoneInput.d.ts +0 -0
- package/dist/{inputs → types/inputs}/PhoneInput/index.d.ts +0 -0
- package/dist/{inputs → types/inputs}/RadioGroup/RadioGroup.d.ts +0 -0
- package/dist/{inputs → types/inputs}/RadioGroup/index.d.ts +0 -0
- package/dist/{inputs → types/inputs}/Scriptel/Scriptel.d.ts +0 -0
- package/dist/{inputs → types/inputs}/Scriptel/ScriptelContext.d.ts +0 -0
- package/dist/{inputs → types/inputs}/Scriptel/index.d.ts +0 -0
- package/dist/{inputs → types/inputs}/Scriptel/scriptel/classes.d.ts +0 -0
- package/dist/{inputs → types/inputs}/Scriptel/scriptel/enums.d.ts +0 -0
- package/dist/{inputs → types/inputs}/Scriptel/scriptel/index.d.ts +0 -0
- package/dist/{inputs → types/inputs}/Scriptel/scriptel/messages.d.ts +0 -0
- package/dist/{inputs → types/inputs}/Scriptel/withScriptel.d.ts +0 -0
- package/dist/{inputs → types/inputs}/ScriptelInput/ScriptelInput.d.ts +0 -0
- package/dist/{inputs → types/inputs}/ScriptelInput/index.d.ts +0 -0
- package/dist/{inputs → types/inputs}/SinInput/SinInput.d.ts +0 -0
- package/dist/{inputs → types/inputs}/SinInput/index.d.ts +0 -0
- package/dist/{inputs → types/inputs}/TableInput/DropdownCell.d.ts +0 -0
- package/dist/{inputs → types/inputs}/TableInput/HoverCell.d.ts +0 -0
- package/dist/{inputs → types/inputs}/TableInput/MoneyCell.d.ts +0 -0
- package/dist/{inputs → types/inputs}/TableInput/MoneyEditCell.d.ts +0 -0
- package/dist/{inputs → types/inputs}/TableInput/MoneySumFooter.d.ts +0 -0
- package/dist/{inputs → types/inputs}/TableInput/StringEditCell.d.ts +0 -0
- package/dist/{inputs → types/inputs}/TableInput/TableInput.d.ts +0 -0
- package/dist/{inputs → types/inputs}/TableInput/addRowOnTab.d.ts +0 -0
- package/dist/{inputs → types/inputs}/TableInput/index.d.ts +0 -0
- package/dist/{money → types/money}/MoneyCurrencyInput/MoneyCurrencyInput.d.ts +0 -0
- package/dist/{money → types/money}/MoneyCurrencyInput/index.d.ts +0 -0
- package/dist/{money → types/money}/MoneyInput/MoneyInput.d.ts +0 -0
- package/dist/{money → types/money}/MoneyInput/index.d.ts +0 -0
- package/dist/{money → types/money}/useMoneyInput.d.ts +0 -0
- package/dist/{step → types/step}/FormStep.d.ts +0 -0
- package/dist/{step → types/step}/Step.d.ts +0 -0
- package/dist/{step → types/step}/StepProvider.d.ts +0 -0
- package/dist/{step → types/step}/index.d.ts +0 -0
- package/dist/{step → types/step}/stepContext.d.ts +0 -0
- package/dist/{step → types/step}/useStep.d.ts +0 -0
- package/package.json +25 -26
- package/dist/index.js +0 -5460
- package/dist/index.min.js +0 -2
- package/dist/index.min.js.map +0 -1
- package/index.js +0 -7
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
import { useRef, useState, useEffect, useMemo } from 'react';
|
|
3
|
+
import { ScriptelContext } from './ScriptelContext.js';
|
|
4
|
+
import { ScriptelSocket } from './scriptel/index.js';
|
|
5
|
+
|
|
6
|
+
debug("thx.controls.inputs.Scriptel");
|
|
7
|
+
function Scriptel({ omniscriptUrl, imageType, scale, crop, penStyle, children }) {
|
|
8
|
+
const socket = useRef();
|
|
9
|
+
const [render, setRender] = useState();
|
|
10
|
+
const [loading, setLoading] = useState(false);
|
|
11
|
+
const [isSigning, setIsSigning] = useState(false);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
socket.current = new ScriptelSocket({
|
|
14
|
+
omniscriptUrl,
|
|
15
|
+
imageType,
|
|
16
|
+
scale,
|
|
17
|
+
crop,
|
|
18
|
+
penStyle
|
|
19
|
+
});
|
|
20
|
+
socket.current.on("render", (msg) => {
|
|
21
|
+
setRender(msg);
|
|
22
|
+
setLoading(false);
|
|
23
|
+
setRender(void 0);
|
|
24
|
+
});
|
|
25
|
+
socket.current.on("okButtonDown", () => {
|
|
26
|
+
setLoading(true);
|
|
27
|
+
});
|
|
28
|
+
socket.current.on("cancel", () => {
|
|
29
|
+
setLoading(false);
|
|
30
|
+
setRender(void 0);
|
|
31
|
+
});
|
|
32
|
+
socket.current.on("penMove", () => {
|
|
33
|
+
setIsSigning(true);
|
|
34
|
+
});
|
|
35
|
+
socket.current.on("penUp", () => {
|
|
36
|
+
setIsSigning(false);
|
|
37
|
+
});
|
|
38
|
+
return () => {
|
|
39
|
+
if (socket.current)
|
|
40
|
+
socket.current.close();
|
|
41
|
+
};
|
|
42
|
+
}, [omniscriptUrl, imageType, scale, crop, penStyle]);
|
|
43
|
+
const scriptel = useMemo(() => {
|
|
44
|
+
return { socket, renderImage: render, loading, isSigning };
|
|
45
|
+
}, [isSigning, loading, render]);
|
|
46
|
+
return /* @__PURE__ */ React.createElement(ScriptelContext.Provider, {
|
|
47
|
+
value: scriptel
|
|
48
|
+
}, children);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { Scriptel };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var ScriptelPenStyle = /* @__PURE__ */ ((ScriptelPenStyle2) => {
|
|
2
|
+
ScriptelPenStyle2["Plain"] = "PlainPenStyle";
|
|
3
|
+
ScriptelPenStyle2["Chisel"] = "ChiselPenStyle";
|
|
4
|
+
ScriptelPenStyle2["Inkwell"] = "InkwellPenStyle";
|
|
5
|
+
return ScriptelPenStyle2;
|
|
6
|
+
})(ScriptelPenStyle || {});
|
|
7
|
+
var ScriptelMessageClass = /* @__PURE__ */ ((ScriptelMessageClass2) => {
|
|
8
|
+
ScriptelMessageClass2["ConnectionOpen"] = "ConnectionOpen";
|
|
9
|
+
ScriptelMessageClass2["DeviceOpenRequest"] = "DeviceOpenRequest";
|
|
10
|
+
ScriptelMessageClass2["DeviceOpenResponse"] = "DeviceOpenResponse";
|
|
11
|
+
ScriptelMessageClass2["RenderedImage"] = "RenderedImage";
|
|
12
|
+
ScriptelMessageClass2["ScriptelException"] = "ScriptelException";
|
|
13
|
+
ScriptelMessageClass2["ButtonDown"] = "ButtonDown";
|
|
14
|
+
ScriptelMessageClass2["ButtonPress"] = "ButtonPress";
|
|
15
|
+
ScriptelMessageClass2["PenMove"] = "PenMove";
|
|
16
|
+
ScriptelMessageClass2["PenUp"] = "PenUp";
|
|
17
|
+
return ScriptelMessageClass2;
|
|
18
|
+
})(ScriptelMessageClass || {});
|
|
19
|
+
|
|
20
|
+
export { ScriptelMessageClass, ScriptelPenStyle };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
import EventEmitter from 'eventemitter3';
|
|
3
|
+
import { ScriptelMessageClass, ScriptelPenStyle } from './enums.js';
|
|
4
|
+
|
|
5
|
+
const d = debug("thx.controls.inputs.Scriptel.scriptel");
|
|
6
|
+
function serverConnected(msg, socket) {
|
|
7
|
+
d("Server connected");
|
|
8
|
+
if (msg.serverInfo.devices.length > 0) {
|
|
9
|
+
const device = msg.serverInfo.devices[0];
|
|
10
|
+
socket.send(JSON.stringify({
|
|
11
|
+
_class: "DeviceOpenRequest",
|
|
12
|
+
uuid: device.uuid
|
|
13
|
+
}));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function deviceConnected(msg, socket, args) {
|
|
17
|
+
d(`Device connected: ${msg.device.uuid}`);
|
|
18
|
+
const { imageType, scale, crop, penStyle } = args;
|
|
19
|
+
socket.send(JSON.stringify({
|
|
20
|
+
_class: "RenderSettingsUpdateRequest",
|
|
21
|
+
renderSettings: {
|
|
22
|
+
_class: "RenderSettings",
|
|
23
|
+
type: imageType || "image/svg+xml",
|
|
24
|
+
scale: scale || 1,
|
|
25
|
+
crop: crop || false,
|
|
26
|
+
penStyle: penStyle ? {
|
|
27
|
+
renderFunction: penStyle
|
|
28
|
+
} : {
|
|
29
|
+
renderFunction: ScriptelPenStyle.Plain
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
function render(msg, args, eventEmitter) {
|
|
35
|
+
d(`Rendered image: ${msg.type} ${msg.width}x${msg.height}`);
|
|
36
|
+
eventEmitter.emit("render", msg);
|
|
37
|
+
}
|
|
38
|
+
class ScriptelSocket extends EventEmitter {
|
|
39
|
+
constructor(args) {
|
|
40
|
+
super();
|
|
41
|
+
this.options = args;
|
|
42
|
+
this.socket = new WebSocket(args.omniscriptUrl || "ws://localhost:8080");
|
|
43
|
+
this.socket.onopen = () => {
|
|
44
|
+
d("Socket open");
|
|
45
|
+
};
|
|
46
|
+
this.socket.onclose = () => {
|
|
47
|
+
d("Socket closed");
|
|
48
|
+
};
|
|
49
|
+
this.socket.onmessage = (ev) => {
|
|
50
|
+
const msg = JSON.parse(ev.data);
|
|
51
|
+
if (!msg._class)
|
|
52
|
+
return;
|
|
53
|
+
switch (msg._class) {
|
|
54
|
+
case ScriptelMessageClass.ConnectionOpen:
|
|
55
|
+
serverConnected(msg, this.socket);
|
|
56
|
+
break;
|
|
57
|
+
case ScriptelMessageClass.DeviceOpenResponse:
|
|
58
|
+
deviceConnected(msg, this.socket, this.options);
|
|
59
|
+
break;
|
|
60
|
+
case ScriptelMessageClass.RenderedImage:
|
|
61
|
+
render(msg, this.options, this);
|
|
62
|
+
break;
|
|
63
|
+
case ScriptelMessageClass.ScriptelException:
|
|
64
|
+
d(`Scriptel Exception Error: ${msg.message}`);
|
|
65
|
+
break;
|
|
66
|
+
case ScriptelMessageClass.ButtonPress:
|
|
67
|
+
if (msg.label === "Cancel")
|
|
68
|
+
this.emit("cancel");
|
|
69
|
+
break;
|
|
70
|
+
case ScriptelMessageClass.ButtonDown:
|
|
71
|
+
if (msg.label === "OK")
|
|
72
|
+
this.emit("okButtonDown");
|
|
73
|
+
break;
|
|
74
|
+
case ScriptelMessageClass.PenMove:
|
|
75
|
+
this.emit("penMove");
|
|
76
|
+
break;
|
|
77
|
+
case ScriptelMessageClass.PenUp:
|
|
78
|
+
this.emit("penUp");
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
calibrate() {
|
|
84
|
+
d("calibrate");
|
|
85
|
+
this.socket.send(JSON.stringify({ _class: "ForceRecalibrate" }));
|
|
86
|
+
}
|
|
87
|
+
close() {
|
|
88
|
+
this.socket.close();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export { ScriptelSocket };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Scriptel } from './Scriptel.js';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
function withScriptel(WrappedComponent, scriptelProps) {
|
|
20
|
+
return function withScriptelHoC(props) {
|
|
21
|
+
return /* @__PURE__ */ React.createElement(Scriptel, __spreadValues({}, scriptelProps), /* @__PURE__ */ React.createElement(WrappedComponent, __spreadValues({}, props)));
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { withScriptel };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
import { useContext, useState, useEffect } from 'react';
|
|
3
|
+
import { Button, Image } from 'semantic-ui-react';
|
|
4
|
+
import { ScriptelContext } from '../Scriptel/ScriptelContext.js';
|
|
5
|
+
|
|
6
|
+
debug("thx.controls.inputs.ScriptelInput");
|
|
7
|
+
function ScriptelInput(props) {
|
|
8
|
+
const { value, onChange, buttonText = "Enter Signature" } = props;
|
|
9
|
+
const ctx = useContext(ScriptelContext);
|
|
10
|
+
const [enterSignature, setEnterSignature] = useState(false);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (enterSignature) {
|
|
13
|
+
if (onChange && (ctx == null ? void 0 : ctx.renderImage)) {
|
|
14
|
+
setEnterSignature(false);
|
|
15
|
+
if (ctx.renderImage.type === "image/svg+xml" || ctx.renderImage.type === "image/png") {
|
|
16
|
+
onChange({
|
|
17
|
+
type: ctx.renderImage.type,
|
|
18
|
+
width: ctx.renderImage.width,
|
|
19
|
+
height: ctx.renderImage.height,
|
|
20
|
+
timestamp: new Date(),
|
|
21
|
+
data: ctx.renderImage.data
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (onChange && !ctx) {
|
|
26
|
+
onChange();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}, [ctx]);
|
|
30
|
+
if (enterSignature) {
|
|
31
|
+
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", null, (ctx == null ? void 0 : ctx.isSigning) ? "signing..." : "Enter a signature and click OK."), /* @__PURE__ */ React.createElement(Button, {
|
|
32
|
+
onClick: () => {
|
|
33
|
+
setEnterSignature(false);
|
|
34
|
+
},
|
|
35
|
+
color: "black",
|
|
36
|
+
loading: ctx == null ? void 0 : ctx.loading,
|
|
37
|
+
disabled: ctx == null ? void 0 : ctx.loading
|
|
38
|
+
}, "Cancel"), /* @__PURE__ */ React.createElement(Button, {
|
|
39
|
+
size: "mini",
|
|
40
|
+
as: "a",
|
|
41
|
+
basic: true,
|
|
42
|
+
onClick: () => {
|
|
43
|
+
var _a;
|
|
44
|
+
return (_a = ctx == null ? void 0 : ctx.socket.current) == null ? void 0 : _a.calibrate();
|
|
45
|
+
},
|
|
46
|
+
disabled: ctx == null ? void 0 : ctx.loading
|
|
47
|
+
}, "Calibrate"));
|
|
48
|
+
}
|
|
49
|
+
if (value && value.data) {
|
|
50
|
+
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Image, {
|
|
51
|
+
size: "medium",
|
|
52
|
+
src: value.data,
|
|
53
|
+
bordered: true
|
|
54
|
+
}), /* @__PURE__ */ React.createElement(Button, {
|
|
55
|
+
size: "mini",
|
|
56
|
+
compact: true,
|
|
57
|
+
onClick: () => {
|
|
58
|
+
setEnterSignature(false);
|
|
59
|
+
if (onChange)
|
|
60
|
+
onChange();
|
|
61
|
+
}
|
|
62
|
+
}, "Reset"));
|
|
63
|
+
}
|
|
64
|
+
return /* @__PURE__ */ React.createElement(Button, {
|
|
65
|
+
onClick: () => setEnterSignature(true)
|
|
66
|
+
}, buttonText);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export { ScriptelInput };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
import { useState, useCallback, useMemo } from 'react';
|
|
3
|
+
import { Input, Icon } from 'semantic-ui-react';
|
|
4
|
+
import SIN from 'social-insurance-number';
|
|
5
|
+
import { useMaskedInput } from '../MaskedInput/useMaskedInput.js';
|
|
6
|
+
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __defProps = Object.defineProperties;
|
|
9
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
10
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
11
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
13
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
14
|
+
var __spreadValues = (a, b) => {
|
|
15
|
+
for (var prop in b || (b = {}))
|
|
16
|
+
if (__hasOwnProp.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
if (__getOwnPropSymbols)
|
|
19
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
20
|
+
if (__propIsEnum.call(b, prop))
|
|
21
|
+
__defNormalProp(a, prop, b[prop]);
|
|
22
|
+
}
|
|
23
|
+
return a;
|
|
24
|
+
};
|
|
25
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
26
|
+
var __objRest = (source, exclude) => {
|
|
27
|
+
var target = {};
|
|
28
|
+
for (var prop in source)
|
|
29
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
30
|
+
target[prop] = source[prop];
|
|
31
|
+
if (source != null && __getOwnPropSymbols)
|
|
32
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
33
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
34
|
+
target[prop] = source[prop];
|
|
35
|
+
}
|
|
36
|
+
return target;
|
|
37
|
+
};
|
|
38
|
+
debug("thx.controls.inputs.SinInput");
|
|
39
|
+
function SinInput(props) {
|
|
40
|
+
const _a = props, { value, onChange } = _a, rest = __objRest(_a, ["value", "onChange"]);
|
|
41
|
+
const [color, setColor] = useState("black");
|
|
42
|
+
const checkValidation = useCallback((valueArray) => {
|
|
43
|
+
const num = valueArray.join("").replaceAll(/(_|\s|-)/g, "");
|
|
44
|
+
const validate = new SIN(num);
|
|
45
|
+
if (num.length > 0) {
|
|
46
|
+
if (validate.isValid()) {
|
|
47
|
+
setColor("green");
|
|
48
|
+
} else {
|
|
49
|
+
setColor("red");
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
setColor("black");
|
|
53
|
+
}
|
|
54
|
+
return validate.isValid();
|
|
55
|
+
}, []);
|
|
56
|
+
const mask = useMemo(() => ({
|
|
57
|
+
mask: "999-999-999",
|
|
58
|
+
isComplete: checkValidation,
|
|
59
|
+
greedy: false,
|
|
60
|
+
autoUnmask: true
|
|
61
|
+
}), [checkValidation]);
|
|
62
|
+
const cardNumberRef = useMaskedInput({
|
|
63
|
+
mask,
|
|
64
|
+
value,
|
|
65
|
+
onChange: (v) => {
|
|
66
|
+
onChange && onChange(v);
|
|
67
|
+
},
|
|
68
|
+
onSet: (v) => {
|
|
69
|
+
checkValidation([v || ""]);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
return /* @__PURE__ */ React.createElement(Input, __spreadProps(__spreadValues({}, rest), {
|
|
73
|
+
icon: true
|
|
74
|
+
}), /* @__PURE__ */ React.createElement("input", {
|
|
75
|
+
ref: cardNumberRef
|
|
76
|
+
}), /* @__PURE__ */ React.createElement(Icon, {
|
|
77
|
+
name: "id badge",
|
|
78
|
+
color,
|
|
79
|
+
size: "large"
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export { SinInput };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Dropdown } from 'semantic-ui-react';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __spreadValues = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
21
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
|
+
var __objRest = (source, exclude) => {
|
|
23
|
+
var target = {};
|
|
24
|
+
for (var prop in source)
|
|
25
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
26
|
+
target[prop] = source[prop];
|
|
27
|
+
if (source != null && __getOwnPropSymbols)
|
|
28
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
29
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
30
|
+
target[prop] = source[prop];
|
|
31
|
+
}
|
|
32
|
+
return target;
|
|
33
|
+
};
|
|
34
|
+
function DropdownCell(dropdownProps) {
|
|
35
|
+
return function DropdownCellFn(props) {
|
|
36
|
+
const {
|
|
37
|
+
value,
|
|
38
|
+
row: { index: rowIndex },
|
|
39
|
+
column: { id },
|
|
40
|
+
updateData
|
|
41
|
+
} = props;
|
|
42
|
+
const _a = dropdownProps, { value: v, onChange } = _a, rest = __objRest(_a, ["value", "onChange"]);
|
|
43
|
+
return /* @__PURE__ */ React.createElement(Dropdown, __spreadProps(__spreadValues({}, rest), {
|
|
44
|
+
value,
|
|
45
|
+
onChange: (event, val) => {
|
|
46
|
+
updateData(rowIndex, id, val.value);
|
|
47
|
+
if (onChange)
|
|
48
|
+
onChange(event, val);
|
|
49
|
+
}
|
|
50
|
+
}));
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { DropdownCell };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
debug("thx.controls.inputs.TableInput.HoverCell");
|
|
20
|
+
function HoverCell(options) {
|
|
21
|
+
return function HoverCellFn(props) {
|
|
22
|
+
const { Action } = options;
|
|
23
|
+
if (props.hoverRow === props.row.id) {
|
|
24
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
25
|
+
style: { textAlign: "right" }
|
|
26
|
+
}, /* @__PURE__ */ React.createElement(Action, __spreadValues({}, props)));
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { HoverCell };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { formatMoney } from '@thx/money';
|
|
2
|
+
|
|
3
|
+
function MoneyCell(options) {
|
|
4
|
+
return function MoneyCellFn(props) {
|
|
5
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
6
|
+
style: { textAlign: "right" }
|
|
7
|
+
}, formatMoney((options == null ? void 0 : options.overrideValue) ? options.overrideValue(props) : props.value));
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { MoneyCell };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { addRowOnTab } from './addRowOnTab.js';
|
|
4
|
+
import { MoneyInput } from '../../money/MoneyInput/MoneyInput.js';
|
|
5
|
+
|
|
6
|
+
debug("thx.controls.inputs.TableInput.MoneyEditCell");
|
|
7
|
+
function MoneyEditCell(opts) {
|
|
8
|
+
return function MoneyEditCellFn(props) {
|
|
9
|
+
const {
|
|
10
|
+
value: initialValue,
|
|
11
|
+
row: { index: rowIndex },
|
|
12
|
+
column: { id },
|
|
13
|
+
updateData
|
|
14
|
+
} = props;
|
|
15
|
+
const [value, setValue] = useState(initialValue);
|
|
16
|
+
return /* @__PURE__ */ React.createElement(MoneyInput, {
|
|
17
|
+
fluid: true,
|
|
18
|
+
transparent: true,
|
|
19
|
+
value,
|
|
20
|
+
onChange: setValue,
|
|
21
|
+
onBlur: () => {
|
|
22
|
+
updateData(rowIndex, id, value);
|
|
23
|
+
},
|
|
24
|
+
onKeyDown: (event) => addRowOnTab(event, value, props, opts == null ? void 0 : opts.addRowOnTabIf)
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { MoneyEditCell };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { toMoney, formatMoney } from '@thx/money';
|
|
2
|
+
|
|
3
|
+
function MoneySumFooter(options) {
|
|
4
|
+
const { id } = options || {};
|
|
5
|
+
return function MoneySumFooterInstance(info) {
|
|
6
|
+
const sum = info.rows.reduce((memo, row) => memo.add(row.values[id]), toMoney());
|
|
7
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
8
|
+
style: { textAlign: "right" }
|
|
9
|
+
}, formatMoney(sum));
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { MoneySumFooter };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { Input } from 'semantic-ui-react';
|
|
4
|
+
import { addRowOnTab } from './addRowOnTab.js';
|
|
5
|
+
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __defProps = Object.defineProperties;
|
|
8
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
9
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
+
var __spreadValues = (a, b) => {
|
|
14
|
+
for (var prop in b || (b = {}))
|
|
15
|
+
if (__hasOwnProp.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
if (__getOwnPropSymbols)
|
|
18
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
+
if (__propIsEnum.call(b, prop))
|
|
20
|
+
__defNormalProp(a, prop, b[prop]);
|
|
21
|
+
}
|
|
22
|
+
return a;
|
|
23
|
+
};
|
|
24
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
+
debug("thx.controls.inputs.TableInput.StringEditCell");
|
|
26
|
+
function StringEditCell(options) {
|
|
27
|
+
const { inputProps, addRowOnTabIf } = options || {};
|
|
28
|
+
return function StringEditCellFn(props) {
|
|
29
|
+
const {
|
|
30
|
+
value: initialValue,
|
|
31
|
+
row: { index },
|
|
32
|
+
column: { id },
|
|
33
|
+
updateData
|
|
34
|
+
} = props;
|
|
35
|
+
const [value, setValue] = useState(initialValue);
|
|
36
|
+
return /* @__PURE__ */ React.createElement(Input, __spreadProps(__spreadValues({
|
|
37
|
+
fluid: true,
|
|
38
|
+
transparent: true
|
|
39
|
+
}, inputProps), {
|
|
40
|
+
value,
|
|
41
|
+
onChange: (ev, v) => {
|
|
42
|
+
setValue(v.value);
|
|
43
|
+
},
|
|
44
|
+
onBlur: () => {
|
|
45
|
+
updateData(index, id, value);
|
|
46
|
+
},
|
|
47
|
+
onKeyDown: (event) => addRowOnTab(event, value, props, addRowOnTabIf)
|
|
48
|
+
}));
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { StringEditCell };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
import { FieldArray } from 'formik';
|
|
3
|
+
import { useMemo, useState } from 'react';
|
|
4
|
+
import { useTable } from 'react-table';
|
|
5
|
+
import { Table } from 'semantic-ui-react';
|
|
6
|
+
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __defProps = Object.defineProperties;
|
|
9
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
10
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
11
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
13
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
14
|
+
var __spreadValues = (a, b) => {
|
|
15
|
+
for (var prop in b || (b = {}))
|
|
16
|
+
if (__hasOwnProp.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
if (__getOwnPropSymbols)
|
|
19
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
20
|
+
if (__propIsEnum.call(b, prop))
|
|
21
|
+
__defNormalProp(a, prop, b[prop]);
|
|
22
|
+
}
|
|
23
|
+
return a;
|
|
24
|
+
};
|
|
25
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
26
|
+
debug("thx.controls.inputs.TableInput");
|
|
27
|
+
function TableInputTable(props) {
|
|
28
|
+
const {
|
|
29
|
+
name,
|
|
30
|
+
columns,
|
|
31
|
+
values,
|
|
32
|
+
arrayHelpers,
|
|
33
|
+
setFieldValue,
|
|
34
|
+
createRow,
|
|
35
|
+
tableProps,
|
|
36
|
+
headerRowProps,
|
|
37
|
+
headerCellProps,
|
|
38
|
+
bodyProps,
|
|
39
|
+
rowProps,
|
|
40
|
+
cellProps,
|
|
41
|
+
footerCellProps,
|
|
42
|
+
footerRowProps
|
|
43
|
+
} = props;
|
|
44
|
+
const cols = useMemo(() => columns, [columns]);
|
|
45
|
+
const vals = useMemo(() => values, [values]);
|
|
46
|
+
const [hoverRow, setHoverRow] = useState("");
|
|
47
|
+
const { getTableProps, getTableBodyProps, headerGroups, prepareRow, rows, footerGroups } = useTable({
|
|
48
|
+
columns: cols,
|
|
49
|
+
data: vals,
|
|
50
|
+
updateData(rowIndex, columnId, value) {
|
|
51
|
+
setFieldValue(`${name}[${rowIndex}].${columnId}`, value);
|
|
52
|
+
},
|
|
53
|
+
addRow() {
|
|
54
|
+
arrayHelpers.push(createRow());
|
|
55
|
+
},
|
|
56
|
+
arrayHelpers
|
|
57
|
+
});
|
|
58
|
+
const hasFooter = footerGroups.some((fg) => fg.headers.some((fgh) => fgh.Footer.name !== "emptyRenderer"));
|
|
59
|
+
const footer = hasFooter ? /* @__PURE__ */ React.createElement(Table.Footer, null, footerGroups.map((group) => /* @__PURE__ */ React.createElement(Table.Row, __spreadValues({}, __spreadValues(__spreadValues({}, group.getFooterGroupProps()), group.getFooterGroupProps(footerRowProps))), group.headers.map((column) => /* @__PURE__ */ React.createElement(Table.HeaderCell, __spreadValues({}, __spreadValues(__spreadValues({}, column.getFooterProps()), column.getFooterProps(footerCellProps))), column.render("Footer")))))) : null;
|
|
60
|
+
return /* @__PURE__ */ React.createElement(Table, __spreadValues({}, __spreadValues(__spreadValues({}, getTableProps()), getTableProps(tableProps))), /* @__PURE__ */ React.createElement(Table.Header, null, headerGroups.map((headerGroup) => /* @__PURE__ */ React.createElement(Table.Row, __spreadValues({}, __spreadValues(__spreadValues({}, headerGroup.getHeaderGroupProps()), headerGroup.getHeaderGroupProps(headerRowProps))), headerGroup.headers.map((column) => /* @__PURE__ */ React.createElement(Table.HeaderCell, __spreadValues({}, __spreadValues(__spreadValues({}, column.getHeaderProps()), column.getHeaderProps(headerCellProps))), column.render("Header")))))), /* @__PURE__ */ React.createElement(Table.Body, __spreadValues({}, __spreadValues(__spreadValues({}, getTableBodyProps()), getTableBodyProps(bodyProps))), rows.map((row) => {
|
|
61
|
+
prepareRow(row);
|
|
62
|
+
return /* @__PURE__ */ React.createElement(Table.Row, __spreadProps(__spreadValues({}, __spreadValues(__spreadValues({}, row.getRowProps()), row.getRowProps(rowProps))), {
|
|
63
|
+
onMouseEnter: () => setHoverRow(row.id),
|
|
64
|
+
onMouseLeave: () => setHoverRow("")
|
|
65
|
+
}), row.cells.map((cell) => /* @__PURE__ */ React.createElement(Table.Cell, __spreadValues({}, __spreadValues(__spreadValues({}, cell.getCellProps()), cell.getCellProps(cellProps))), cell.render("Cell", { hoverRow }))));
|
|
66
|
+
})), footer);
|
|
67
|
+
}
|
|
68
|
+
function TableInput(props) {
|
|
69
|
+
return /* @__PURE__ */ React.createElement(FieldArray, {
|
|
70
|
+
name: props.name,
|
|
71
|
+
render: (arrayHelpers) => /* @__PURE__ */ React.createElement(TableInputTable, __spreadValues({
|
|
72
|
+
arrayHelpers
|
|
73
|
+
}, props))
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export { TableInput };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
function addRowOnTab(event, value, props, addRowOnTabIf) {
|
|
2
|
+
const {
|
|
3
|
+
row: { index: rowIndex },
|
|
4
|
+
rows: { length: rowsLength },
|
|
5
|
+
addRow
|
|
6
|
+
} = props;
|
|
7
|
+
if (event.key === "Tab" && !event.shiftKey && rowIndex + 1 === rowsLength && (addRowOnTabIf ? addRowOnTabIf(props, value) : false)) {
|
|
8
|
+
addRow();
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { addRowOnTab };
|