@thx/controls 16.3.0 → 17.0.0-mantine.0

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.
Files changed (159) hide show
  1. package/dist/esm/date/LocalDatePicker/LocalDatePicker.js +11 -54
  2. package/dist/esm/date/LocalDatePicker/LocalDatePicker.js.map +1 -1
  3. package/dist/esm/date/LocalMonthSelect/LocalMonthSelect.js +19 -23
  4. package/dist/esm/date/LocalMonthSelect/LocalMonthSelect.js.map +1 -1
  5. package/dist/esm/date/LocalTimePicker/LocalTimePicker.js +6 -55
  6. package/dist/esm/date/LocalTimePicker/LocalTimePicker.js.map +1 -1
  7. package/dist/esm/date/MonthDayPicker/MonthDayPicker.js +13 -69
  8. package/dist/esm/date/MonthDayPicker/MonthDayPicker.js.map +1 -1
  9. package/dist/esm/date/MonthYearPicker/MonthYearPicker.js +14 -57
  10. package/dist/esm/date/MonthYearPicker/MonthYearPicker.js.map +1 -1
  11. package/dist/esm/date/YearSelect/YearSelect.js +25 -39
  12. package/dist/esm/date/YearSelect/YearSelect.js.map +1 -1
  13. package/dist/esm/form/TForm/useTForm.js +12 -8
  14. package/dist/esm/form/TForm/useTForm.js.map +1 -1
  15. package/dist/esm/form/TMForm/TMForm.js +55 -0
  16. package/dist/esm/form/TMForm/TMForm.js.map +1 -0
  17. package/dist/esm/form/TMForm/errorMessages.js +39 -0
  18. package/dist/esm/form/TMForm/errorMessages.js.map +1 -0
  19. package/dist/esm/form/TMForm/graphqlErrorTypes.js +6 -0
  20. package/dist/esm/form/TMForm/graphqlErrorTypes.js.map +1 -0
  21. package/dist/esm/index.js +1 -23
  22. package/dist/esm/index.js.map +1 -1
  23. package/dist/esm/inputs/MaskedInput/MaskedInput.js +5 -8
  24. package/dist/esm/inputs/MaskedInput/MaskedInput.js.map +1 -1
  25. package/dist/esm/inputs/MaskedInput/useMaskedInput.js +2 -3
  26. package/dist/esm/inputs/MaskedInput/useMaskedInput.js.map +1 -1
  27. package/dist/esm/inputs/PhoneInput/PhoneInput.js.map +1 -1
  28. package/dist/stats.html +1 -1
  29. package/dist/stats.txt +26 -86
  30. package/dist/types/commonTypes.d.ts +1 -0
  31. package/dist/types/date/LocalDatePicker/LocalDatePicker.d.ts +5 -7
  32. package/dist/types/date/LocalDatePicker/localdatepicker.stories.d.ts +6 -0
  33. package/dist/types/date/LocalMonthSelect/LocalMonthSelect.d.ts +2 -3
  34. package/dist/types/date/LocalMonthSelect/localmonthselect.stories.d.ts +5 -0
  35. package/dist/types/date/LocalTimePicker/LocalTimePicker.d.ts +2 -6
  36. package/dist/types/date/LocalTimePicker/localtimepicker.stories.d.ts +5 -0
  37. package/dist/types/date/MonthDayPicker/MonthDayPicker.d.ts +7 -6
  38. package/dist/types/date/MonthDayPicker/monthdaypicker.stories.d.ts +5 -0
  39. package/dist/types/date/MonthYearPicker/MonthYearPicker.d.ts +10 -11
  40. package/dist/types/date/MonthYearPicker/monthyearpicker.stories.d.ts +6 -0
  41. package/dist/types/date/YearSelect/YearSelect.d.ts +1 -3
  42. package/dist/types/date/YearSelect/yearselect.stories.d.ts +7 -0
  43. package/dist/types/form/TForm/tform.stories.d.ts +19 -0
  44. package/dist/types/form/TForm/types.d.ts +32 -0
  45. package/dist/types/form/TMForm/TMForm.d.ts +8 -0
  46. package/dist/types/form/TMForm/errorMessages.d.ts +5 -0
  47. package/dist/types/form/TMForm/graphqlErrorTypes.d.ts +50 -0
  48. package/dist/types/form/TMForm/tmform.stories.d.ts +12 -0
  49. package/dist/types/index.d.ts +2 -19
  50. package/dist/types/inputs/CreditCardInput/CreditCardInput.d.ts +3 -2
  51. package/dist/types/inputs/CreditCardInput/CreditCardNumberInput.d.ts +2 -2
  52. package/dist/types/inputs/CreditCardInput/creditcardinput.stories.d.ts +5 -0
  53. package/dist/types/inputs/CreditCardInput/creditcardnumberinput.stories.d.ts +5 -0
  54. package/dist/types/inputs/MaskedInput/MaskedInput.d.ts +2 -3
  55. package/dist/types/inputs/MaskedInput/maskedinput.stories.d.ts +6 -0
  56. package/dist/types/inputs/MaskedInput/useMaskedInput.d.ts +10 -0
  57. package/dist/types/inputs/PhoneInput/PhoneInput.d.ts +1 -2
  58. package/dist/types/inputs/PhoneInput/phoneinput.stories.d.ts +5 -0
  59. package/dist/types/inputs/RadioGroup/radiogroup.stories.d.ts +5 -0
  60. package/dist/types/inputs/SinInput/SinInput.d.ts +0 -1
  61. package/dist/types/inputs/SinInput/sininput.stories.d.ts +5 -0
  62. package/dist/types/inputs/TableInput/DropdownCell.d.ts +3 -2
  63. package/dist/types/inputs/TableInput/HoverCell.d.ts +6 -0
  64. package/dist/types/inputs/TableInput/MoneyCell.d.ts +8 -0
  65. package/dist/types/inputs/TableInput/MoneyEditCell.d.ts +2 -1
  66. package/dist/types/inputs/TableInput/MoneySumFooter.d.ts +6 -0
  67. package/dist/types/inputs/TableInput/StringEditCell.d.ts +2 -2
  68. package/dist/types/inputs/TableInput/TableInput.d.ts +5 -2
  69. package/dist/types/inputs/TableInput/addRowOnTab.d.ts +1 -0
  70. package/dist/types/inputs/TableInput/main.story.d.ts +7 -0
  71. package/dist/types/inputs/TableInput/tableinput.stories.d.ts +5 -0
  72. package/dist/types/inputs/TableInput/withHover.story.d.ts +7 -0
  73. package/dist/types/money/MoneyCurrencyInput/MoneyCurrencyInput.d.ts +2 -4
  74. package/dist/types/money/MoneyCurrencyInput/moneycurrencyinput.stories.d.ts +5 -0
  75. package/dist/types/money/MoneyInput/MoneyInput.d.ts +4 -5
  76. package/dist/types/money/MoneyInput/moneyinput.stories.d.ts +6 -0
  77. package/dist/types/money/useMoneyInput.d.ts +13 -0
  78. package/dist/types/storyDecorator.d.ts +6 -0
  79. package/package.json +13 -10
  80. package/dist/esm/date/DatePicker/styles.css.js +0 -7
  81. package/dist/esm/date/DatePicker/styles.css.js.map +0 -1
  82. package/dist/esm/date/LocalDatePicker/MaskedDateInput.js +0 -22
  83. package/dist/esm/date/LocalDatePicker/MaskedDateInput.js.map +0 -1
  84. package/dist/esm/date/LocalTimePicker/MaskedTimeInput.js +0 -21
  85. package/dist/esm/date/LocalTimePicker/MaskedTimeInput.js.map +0 -1
  86. package/dist/esm/external/style-inject/dist/style-inject.es.js +0 -29
  87. package/dist/esm/external/style-inject/dist/style-inject.es.js.map +0 -1
  88. package/dist/esm/inputs/CreditCardInput/CreditCardInput.js +0 -71
  89. package/dist/esm/inputs/CreditCardInput/CreditCardInput.js.map +0 -1
  90. package/dist/esm/inputs/CreditCardInput/CreditCardNumberInput.js +0 -76
  91. package/dist/esm/inputs/CreditCardInput/CreditCardNumberInput.js.map +0 -1
  92. package/dist/esm/inputs/CreditCardInput/styles.css.js +0 -7
  93. package/dist/esm/inputs/CreditCardInput/styles.css.js.map +0 -1
  94. package/dist/esm/inputs/RadioGroup/RadioGroup.js +0 -25
  95. package/dist/esm/inputs/RadioGroup/RadioGroup.js.map +0 -1
  96. package/dist/esm/inputs/Scriptel/Scriptel.js +0 -52
  97. package/dist/esm/inputs/Scriptel/Scriptel.js.map +0 -1
  98. package/dist/esm/inputs/Scriptel/ScriptelContext.js +0 -6
  99. package/dist/esm/inputs/Scriptel/ScriptelContext.js.map +0 -1
  100. package/dist/esm/inputs/Scriptel/scriptel/enums.js +0 -21
  101. package/dist/esm/inputs/Scriptel/scriptel/enums.js.map +0 -1
  102. package/dist/esm/inputs/Scriptel/scriptel/index.js +0 -93
  103. package/dist/esm/inputs/Scriptel/scriptel/index.js.map +0 -1
  104. package/dist/esm/inputs/Scriptel/withScriptel.js +0 -15
  105. package/dist/esm/inputs/Scriptel/withScriptel.js.map +0 -1
  106. package/dist/esm/inputs/ScriptelInput/ScriptelInput.js +0 -67
  107. package/dist/esm/inputs/ScriptelInput/ScriptelInput.js.map +0 -1
  108. package/dist/esm/inputs/SinInput/SinInput.js +0 -54
  109. package/dist/esm/inputs/SinInput/SinInput.js.map +0 -1
  110. package/dist/esm/inputs/TableInput/DropdownCell.js +0 -26
  111. package/dist/esm/inputs/TableInput/DropdownCell.js.map +0 -1
  112. package/dist/esm/inputs/TableInput/HoverCell.js +0 -20
  113. package/dist/esm/inputs/TableInput/HoverCell.js.map +0 -1
  114. package/dist/esm/inputs/TableInput/LocalDateCell.js +0 -13
  115. package/dist/esm/inputs/TableInput/LocalDateCell.js.map +0 -1
  116. package/dist/esm/inputs/TableInput/LocalDateEditCell.js +0 -29
  117. package/dist/esm/inputs/TableInput/LocalDateEditCell.js.map +0 -1
  118. package/dist/esm/inputs/TableInput/MoneyCell.js +0 -13
  119. package/dist/esm/inputs/TableInput/MoneyCell.js.map +0 -1
  120. package/dist/esm/inputs/TableInput/MoneyEditCell.js +0 -30
  121. package/dist/esm/inputs/TableInput/MoneyEditCell.js.map +0 -1
  122. package/dist/esm/inputs/TableInput/MoneySumFooter.js +0 -15
  123. package/dist/esm/inputs/TableInput/MoneySumFooter.js.map +0 -1
  124. package/dist/esm/inputs/TableInput/StringEditCell.js +0 -34
  125. package/dist/esm/inputs/TableInput/StringEditCell.js.map +0 -1
  126. package/dist/esm/inputs/TableInput/TableInput.js +0 -75
  127. package/dist/esm/inputs/TableInput/TableInput.js.map +0 -1
  128. package/dist/esm/inputs/TableInput/addRowOnTab.js +0 -13
  129. package/dist/esm/inputs/TableInput/addRowOnTab.js.map +0 -1
  130. package/dist/esm/money/MoneyCurrencyInput/MoneyCurrencyInput.js +0 -51
  131. package/dist/esm/money/MoneyCurrencyInput/MoneyCurrencyInput.js.map +0 -1
  132. package/dist/esm/money/MoneyInput/MoneyInput.js +0 -31
  133. package/dist/esm/money/MoneyInput/MoneyInput.js.map +0 -1
  134. package/dist/esm/money/useMoneyInput.js +0 -75
  135. package/dist/esm/money/useMoneyInput.js.map +0 -1
  136. package/dist/esm/step/FormStep.js +0 -17
  137. package/dist/esm/step/FormStep.js.map +0 -1
  138. package/dist/esm/step/Step.js +0 -10
  139. package/dist/esm/step/Step.js.map +0 -1
  140. package/dist/esm/step/StepProvider.js +0 -95
  141. package/dist/esm/step/StepProvider.js.map +0 -1
  142. package/dist/esm/step/stepContext.js +0 -10
  143. package/dist/esm/step/stepContext.js.map +0 -1
  144. package/dist/esm/step/useStep.js +0 -10
  145. package/dist/esm/step/useStep.js.map +0 -1
  146. package/dist/types/date/LocalDatePicker/MaskedDateInput.d.ts +0 -12
  147. package/dist/types/date/LocalTimePicker/MaskedTimeInput.d.ts +0 -11
  148. package/dist/types/inputs/CreditCardInput/index.d.ts +0 -2
  149. package/dist/types/inputs/RadioGroup/RadioGroup.d.ts +0 -8
  150. package/dist/types/inputs/RadioGroup/index.d.ts +0 -2
  151. package/dist/types/inputs/ScriptelInput/ScriptelInput.d.ts +0 -8
  152. package/dist/types/inputs/ScriptelInput/index.d.ts +0 -2
  153. package/dist/types/inputs/SinInput/index.d.ts +0 -2
  154. package/dist/types/inputs/TableInput/LocalDateCell.d.ts +0 -8
  155. package/dist/types/inputs/TableInput/LocalDateEditCell.d.ts +0 -3
  156. package/dist/types/inputs/TableInput/index.d.ts +0 -11
  157. package/dist/types/money/MoneyCurrencyInput/index.d.ts +0 -2
  158. package/dist/types/step/StepProvider.d.ts +0 -10
  159. package/dist/types/step/index.d.ts +0 -4
@@ -1,21 +0,0 @@
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 };
21
- //# sourceMappingURL=enums.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"enums.js","sources":["../../../../../src/inputs/Scriptel/scriptel/enums.ts"],"sourcesContent":["export enum ScriptelPenStyle {\n\tPlain = 'PlainPenStyle',\n\tChisel = 'ChiselPenStyle',\n\tInkwell = 'InkwellPenStyle',\n}\n\nexport enum ScriptelMessageClass {\n\tConnectionOpen = 'ConnectionOpen',\n\tDeviceOpenRequest = 'DeviceOpenRequest',\n\tDeviceOpenResponse = 'DeviceOpenResponse',\n\tRenderedImage = 'RenderedImage',\n\tScriptelException = 'ScriptelException',\n\tButtonDown = 'ButtonDown',\n\tButtonPress = 'ButtonPress',\n\tPenMove = 'PenMove',\n\tPenUp = 'PenUp',\n}\n"],"names":[],"mappings":"AAAY,IAAA,gBAAA,qBAAA,iBAAL,KAAA;AACN,EAAQ,iBAAA,CAAA,OAAA,CAAA,GAAA,eAAA,CAAA;AACR,EAAS,iBAAA,CAAA,QAAA,CAAA,GAAA,gBAAA,CAAA;AACT,EAAU,iBAAA,CAAA,SAAA,CAAA,GAAA,iBAAA,CAAA;AAHC,EAAA,OAAA,iBAAA,CAAA;AAAA,CAAA,EAAA,gBAAA,IAAA,EAAA,EAAA;AAMA,IAAA,oBAAA,qBAAA,qBAAL,KAAA;AACN,EAAiB,qBAAA,CAAA,gBAAA,CAAA,GAAA,gBAAA,CAAA;AACjB,EAAoB,qBAAA,CAAA,mBAAA,CAAA,GAAA,mBAAA,CAAA;AACpB,EAAqB,qBAAA,CAAA,oBAAA,CAAA,GAAA,oBAAA,CAAA;AACrB,EAAgB,qBAAA,CAAA,eAAA,CAAA,GAAA,eAAA,CAAA;AAChB,EAAoB,qBAAA,CAAA,mBAAA,CAAA,GAAA,mBAAA,CAAA;AACpB,EAAa,qBAAA,CAAA,YAAA,CAAA,GAAA,YAAA,CAAA;AACb,EAAc,qBAAA,CAAA,aAAA,CAAA,GAAA,aAAA,CAAA;AACd,EAAU,qBAAA,CAAA,SAAA,CAAA,GAAA,SAAA,CAAA;AACV,EAAQ,qBAAA,CAAA,OAAA,CAAA,GAAA,OAAA,CAAA;AATG,EAAA,OAAA,qBAAA,CAAA;AAAA,CAAA,EAAA,oBAAA,IAAA,EAAA;;;;"}
@@ -1,93 +0,0 @@
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 };
93
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../src/inputs/Scriptel/scriptel/index.ts"],"sourcesContent":["/* globals WebSocket: true */\nimport debug from 'debug';\nimport EventEmitter from 'eventemitter3';\nimport {ScriptelMessageClass, ScriptelPenStyle} from './enums';\nimport type {ConnectionOpen, DeviceOpenResponse, Message, RenderedImage} from './messages';\n\nconst d = debug('thx.controls.inputs.Scriptel.scriptel');\n\nexport interface ScriptelSocketArgs {\n\tomniscriptUrl?: string; // Defaults to 'ws://localhost:8080'\n\timageType?: string; // Defaults to 'image/svg+xml'.\n\tscale?: number; // Defaults to 1\n\tcrop?: boolean; // Defaults to false\n\tpenStyle?: ScriptelPenStyle; // Defaults to 'PlainPenStyle'\n\trender?: () => void;\n}\n\nfunction serverConnected(msg: ConnectionOpen, socket: WebSocket) {\n\td('Server connected');\n\tif (msg.serverInfo.devices.length > 0) {\n\t\t// Grab the first available device\n\t\tconst device = msg.serverInfo.devices[0];\n\t\tsocket.send(\n\t\t\tJSON.stringify({\n\t\t\t\t_class: 'DeviceOpenRequest',\n\t\t\t\tuuid: device.uuid,\n\t\t\t}),\n\t\t);\n\t}\n}\n\nfunction deviceConnected(msg: DeviceOpenResponse, socket: WebSocket, args: ScriptelSocketArgs) {\n\td(`Device connected: ${msg.device.uuid}`);\n\tconst {imageType, scale, crop, penStyle} = args;\n\tsocket.send(\n\t\tJSON.stringify({\n\t\t\t_class: 'RenderSettingsUpdateRequest',\n\t\t\trenderSettings: {\n\t\t\t\t_class: 'RenderSettings',\n\t\t\t\ttype: imageType || 'image/svg+xml',\n\t\t\t\tscale: scale || 1,\n\t\t\t\tcrop: crop || false,\n\t\t\t\tpenStyle: penStyle\n\t\t\t\t\t? {\n\t\t\t\t\t\t\trenderFunction: penStyle,\n\t\t\t\t\t }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\trenderFunction: ScriptelPenStyle.Plain,\n\t\t\t\t\t },\n\t\t\t},\n\t\t}),\n\t);\n}\n\nfunction render(msg: RenderedImage, args: ScriptelSocketArgs, eventEmitter: EventEmitter) {\n\td(`Rendered image: ${msg.type} ${msg.width}x${msg.height}`);\n\teventEmitter.emit('render', msg);\n}\n\nexport class ScriptelSocket extends EventEmitter {\n\tprivate socket: WebSocket;\n\tprivate options: ScriptelSocketArgs;\n\n\tconstructor(args: ScriptelSocketArgs) {\n\t\tsuper();\n\n\t\tthis.options = args;\n\n\t\tthis.socket = new WebSocket(args.omniscriptUrl || 'ws://localhost:8080');\n\n\t\tthis.socket.onopen = () => {\n\t\t\td('Socket open');\n\t\t};\n\n\t\tthis.socket.onclose = () => {\n\t\t\td('Socket closed');\n\t\t};\n\n\t\tthis.socket.onmessage = ev => {\n\t\t\tconst msg = JSON.parse(ev.data) as Message;\n\t\t\tif (!msg._class) return; // A message with no class.\n\n\t\t\tswitch (msg._class) {\n\t\t\t\tcase ScriptelMessageClass.ConnectionOpen:\n\t\t\t\t\tserverConnected(msg, this.socket);\n\t\t\t\t\tbreak;\n\t\t\t\tcase ScriptelMessageClass.DeviceOpenResponse:\n\t\t\t\t\tdeviceConnected(msg, this.socket, this.options);\n\t\t\t\t\tbreak;\n\t\t\t\tcase ScriptelMessageClass.RenderedImage:\n\t\t\t\t\trender(msg, this.options, this);\n\t\t\t\t\tbreak;\n\t\t\t\tcase ScriptelMessageClass.ScriptelException:\n\t\t\t\t\td(`Scriptel Exception Error: ${msg.message}`);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase ScriptelMessageClass.ButtonPress:\n\t\t\t\t\tif (msg.label === 'Cancel') this.emit('cancel');\n\t\t\t\t\tbreak;\n\t\t\t\tcase ScriptelMessageClass.ButtonDown:\n\t\t\t\t\tif (msg.label === 'OK') this.emit('okButtonDown');\n\t\t\t\t\tbreak;\n\t\t\t\tcase ScriptelMessageClass.PenMove:\n\t\t\t\t\tthis.emit('penMove');\n\t\t\t\t\tbreak;\n\t\t\t\tcase ScriptelMessageClass.PenUp:\n\t\t\t\t\tthis.emit('penUp');\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t}\n\t\t};\n\t}\n\n\tcalibrate() {\n\t\td('calibrate');\n\t\tthis.socket.send(JSON.stringify({_class: 'ForceRecalibrate'}));\n\t}\n\n\tclose() {\n\t\tthis.socket.close();\n\t}\n}\n"],"names":[],"mappings":";;;;AAMA,MAAM,CAAA,GAAI,MAAM,uCAAuC,CAAA,CAAA;AAWvD,SAAA,eAAA,CAAyB,KAAqB,MAAmB,EAAA;AAChE,EAAA,CAAA,CAAE,kBAAkB,CAAA,CAAA;AACpB,EAAA,IAAI,GAAI,CAAA,UAAA,CAAW,OAAQ,CAAA,MAAA,GAAS,CAAG,EAAA;AAEtC,IAAM,MAAA,MAAA,GA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AACzB,UAAA,IAAI,IAAI,KAAU,KAAA,QAAA;AAAU,YAAA,IAAA,CAAK,KAAK,QAAQ,CAAA,CAAA;AAC9C,UAAA,MAAA;AAAA,QAAA,KACI,oBAAqB,CAAA,UAAA;AACzB,UAAA,IAAI,IAAI,KAAU,KAAA,IAAA;AAAM,YAAA,IAAA,CAAK,KAAK,cAAc,CAAA,CAAA;AAChD,UAAA,MAAA;AAAA,QAAA,KACI,oBAAqB,CAAA,OAAA;AACzB,UAAA,IAAA,CAAK,KAAK,SAAS,CAAA,CAAA;AACnB,UAAA,MAAA;AAAA,QAAA,KACI,oBAAqB,CAAA,KAAA;AACzB,UAAA,IAAA,CAAK,KAAK,OAAO,CAAA,CAAA;AACjB,UAAA,MAAA;AAAA,OAAA;AAAA,KAGH,CAAA;AAAA,GACD;AAAA,EAEA,SAAY,GAAA;AACX,IAAA,CAAA,CAAE,WAAW,CAAA,CAAA;AACb,IAAK,IAAA,CAAA,MAAA,CAAO,KAAK,IAAK,CAAA,SAAA,CAAU,EAAC,MAAQ,EAAA,kBAAA,EAAmB,CAAC,CAAA,CAAA;AAAA,GAC9D;AAAA,EAEA,KAAQ,GAAA;AACP,IAAA,IAAA,CAAK,OAAO,KAAM,EAAA,CAAA;AAAA,GACnB;AACD;;;;"}
@@ -1,15 +0,0 @@
1
- import React from 'react';
2
- import { Scriptel } from './Scriptel.js';
3
-
4
- function withScriptel(WrappedComponent, scriptelProps) {
5
- return function withScriptelHoC(props) {
6
- return /* @__PURE__ */ React.createElement(Scriptel, {
7
- ...scriptelProps
8
- }, /* @__PURE__ */ React.createElement(WrappedComponent, {
9
- ...props
10
- }));
11
- };
12
- }
13
-
14
- export { withScriptel };
15
- //# sourceMappingURL=withScriptel.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"withScriptel.js","sources":["../../../../src/inputs/Scriptel/withScriptel.tsx"],"sourcesContent":["import {Scriptel, ScriptelProps} from './Scriptel';\n\n/**\n * A HoC that provides a connection to a Scriptel Omniscript device.\n * You can only have a single connection open at a time.\n * @param WrappedComponent\n * @return {Object}\n */\nexport function withScriptel(WrappedComponent: any, scriptelProps: ScriptelProps) {\n\treturn function withScriptelHoC(props: any) {\n\t\treturn (\n\t\t\t<Scriptel {...scriptelProps}>\n\t\t\t\t<WrappedComponent {...props} />\n\t\t\t</Scriptel>\n\t\t);\n\t};\n}\n"],"names":[],"mappings":";;;AAQO,SAAA,YAAA,CAAsB,kBAAuB,aAA8B,EAAA;AACjF,EAAA,OAAO,yBAAyB,KAAY,EAAA;AAC3C,IAAA,uBACE,KAAA,CAAA,aAAA,CAAA,QAAA,EAAA;AAAA,MAAa,GAAA,aAAA;AAAA,KAAA,kBACZ,KAAA,CAAA,aAAA,CAAA,gBAAA,EAAA;AAAA,MAAqB,GAAA,KAAA;AAAA,KAAO,CAC9B,CAAA,CAAA;AAAA,GAEF,CAAA;AACD;;;;"}
@@ -1,67 +0,0 @@
1
- import React, { useContext, useState, useEffect } from 'react';
2
- import debug from 'debug';
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?.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?.isSigning ? "signing..." : "Enter a signature and click OK."), /* @__PURE__ */ React.createElement(Button, {
32
- onClick: () => {
33
- setEnterSignature(false);
34
- },
35
- color: "black",
36
- loading: ctx?.loading,
37
- disabled: ctx?.loading
38
- }, "Cancel"), /* @__PURE__ */ React.createElement(Button, {
39
- size: "mini",
40
- as: "a",
41
- basic: true,
42
- onClick: () => ctx?.socket.current?.calibrate(),
43
- disabled: ctx?.loading
44
- }, "Calibrate"));
45
- }
46
- if (value && value.data) {
47
- return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Image, {
48
- size: "medium",
49
- src: value.data,
50
- bordered: true
51
- }), /* @__PURE__ */ React.createElement(Button, {
52
- size: "mini",
53
- compact: true,
54
- onClick: () => {
55
- setEnterSignature(false);
56
- if (onChange)
57
- onChange();
58
- }
59
- }, "Reset"));
60
- }
61
- return /* @__PURE__ */ React.createElement(Button, {
62
- onClick: () => setEnterSignature(true)
63
- }, buttonText);
64
- }
65
-
66
- export { ScriptelInput };
67
- //# sourceMappingURL=ScriptelInput.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ScriptelInput.js","sources":["../../../../src/inputs/ScriptelInput/ScriptelInput.tsx"],"sourcesContent":["import type {ScriptelSchemaType} from '@thx/yup-types';\nimport debug from 'debug';\nimport {useContext, useEffect, useState} from 'react';\nimport {Button, Image} from 'semantic-ui-react';\nimport {ScriptelContext} from '../Scriptel/ScriptelContext';\n\nconst d = debug('thx.controls.inputs.ScriptelInput');\n\nexport interface ScriptelInputProps {\n\tvalue?: ScriptelSchemaType;\n\tonChange?: (value?: ScriptelSchemaType) => void;\n\tbuttonText?: string;\n}\n\nexport function ScriptelInput(props: ScriptelInputProps) {\n\tconst {value, onChange, buttonText = 'Enter Signature'} = props;\n\tconst ctx = useContext(ScriptelContext);\n\n\tconst [enterSignature, setEnterSignature] = useState(false);\n\n\tuseEffect(() => {\n\t\tif (enterSignature) {\n\t\t\tif (onChange && ctx?.renderImage) {\n\t\t\t\tsetEnterSignature(false);\n\t\t\t\tif (ctx.renderImage.type === 'image/svg+xml' || ctx.renderImage.type === 'image/png') {\n\t\t\t\t\tonChange({\n\t\t\t\t\t\ttype: ctx.renderImage.type,\n\t\t\t\t\t\twidth: ctx.renderImage.width,\n\t\t\t\t\t\theight: ctx.renderImage.height,\n\t\t\t\t\t\ttimestamp: new Date(),\n\t\t\t\t\t\tdata: ctx.renderImage.data,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (onChange && !ctx) {\n\t\t\t\tonChange();\n\t\t\t}\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ctx]);\n\n\tif (enterSignature) {\n\t\treturn (\n\t\t\t<div>\n\t\t\t\t<div>{ctx?.isSigning ? 'signing...' : 'Enter a signature and click OK.'}</div>\n\t\t\t\t<Button\n\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\tsetEnterSignature(false);\n\t\t\t\t\t}}\n\t\t\t\t\tcolor=\"black\"\n\t\t\t\t\tloading={ctx?.loading}\n\t\t\t\t\tdisabled={ctx?.loading}\n\t\t\t\t>\n\t\t\t\t\tCancel\n\t\t\t\t</Button>\n\t\t\t\t<Button size=\"mini\" as=\"a\" basic onClick={() => ctx?.socket.current?.calibrate()} disabled={ctx?.loading}>\n\t\t\t\t\tCalibrate\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tif (value && value.data) {\n\t\treturn (\n\t\t\t<div>\n\t\t\t\t<Image size=\"medium\" src={value.data} bordered />\n\t\t\t\t<Button\n\t\t\t\t\tsize=\"mini\"\n\t\t\t\t\tcompact\n\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\tsetEnterSignature(false);\n\t\t\t\t\t\tif (onChange) onChange();\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\tReset\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn <Button onClick={() => setEnterSignature(true)}>{buttonText}</Button>;\n}\n"],"names":[],"m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2
- import debug from 'debug';
3
- import { Input, Icon } from 'semantic-ui-react';
4
- import SIN from 'social-insurance-number';
5
- import { useMaskedInput } from '../MaskedInput/useMaskedInput.js';
6
-
7
- debug("thx.controls.inputs.SinInput");
8
- function SinInput(props) {
9
- const { value, onChange, ...rest } = props;
10
- const [color, setColor] = useState("black");
11
- const checkValidation = useCallback((valueArray) => {
12
- const num = valueArray.join("").replaceAll(/(_|\s|-)/g, "");
13
- const validate = new SIN(num);
14
- if (num.length > 0) {
15
- if (validate.isValid()) {
16
- setColor("green");
17
- } else {
18
- setColor("red");
19
- }
20
- } else {
21
- setColor("black");
22
- }
23
- return validate.isValid();
24
- }, []);
25
- const mask = useMemo(() => ({
26
- mask: "999-999-999",
27
- isComplete: checkValidation,
28
- greedy: false,
29
- autoUnmask: true
30
- }), [checkValidation]);
31
- const cardNumberRef = useMaskedInput({
32
- mask,
33
- value,
34
- onChange: (v) => {
35
- onChange && onChange(v);
36
- },
37
- onSet: (v) => {
38
- checkValidation([v || ""]);
39
- }
40
- });
41
- return /* @__PURE__ */ React.createElement(Input, {
42
- ...rest,
43
- icon: true
44
- }, /* @__PURE__ */ React.createElement("input", {
45
- ref: cardNumberRef
46
- }), /* @__PURE__ */ React.createElement(Icon, {
47
- name: "id badge",
48
- color,
49
- size: "large"
50
- }));
51
- }
52
-
53
- export { SinInput };
54
- //# sourceMappingURL=SinInput.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SinInput.js","sources":["../../../../src/inputs/SinInput/SinInput.tsx"],"sourcesContent":["import debug from 'debug';\nimport {useCallback, useMemo, useState} from 'react';\nimport {Icon, Input, SemanticCOLORS} from 'semantic-ui-react';\nimport SIN from 'social-insurance-number';\nimport type {MaskedInputProps} from '../MaskedInput';\nimport {useMaskedInput} from '../MaskedInput/useMaskedInput';\n\nconst d = debug('thx.controls.inputs.SinInput');\n\nexport interface SinInputProps extends Omit<MaskedInputProps, 'mask'> {\n\tvalue?: string;\n\tonChange(value?: string): void;\n}\n\nexport function SinInput(props: SinInputProps) {\n\tconst {value, onChange, ...rest} = props;\n\tconst [color, setColor] = useState<SemanticCOLORS>('black');\n\n\tconst checkValidation = useCallback((valueArray: string[]) => {\n\t\tconst num = valueArray.join('').replaceAll(/(_|\\s|-)/g, '');\n\t\tconst validate = new SIN(num);\n\t\tif (num.length > 0) {\n\t\t\tif (validate.isValid()) {\n\t\t\t\tsetColor('green');\n\t\t\t} else {\n\t\t\t\tsetColor('red');\n\t\t\t}\n\t\t} else {\n\t\t\tsetColor('black');\n\t\t}\n\t\treturn validate.isValid();\n\t}, []);\n\n\tconst mask: MaskedInputProps['mask'] = useMemo(\n\t\t() => ({\n\t\t\tmask: '999-999-999',\n\t\t\tisComplete: checkValidation,\n\t\t\tgreedy: false,\n\t\t\tautoUnmask: true,\n\t\t}),\n\t\t[checkValidation],\n\t);\n\n\tconst cardNumberRef = useMaskedInput({\n\t\tmask,\n\t\tvalue,\n\t\tonChange: v => {\n\t\t\tonChange && onChange(v);\n\t\t},\n\t\tonSet: v => {\n\t\t\tcheckValidation([v || '']);\n\t\t},\n\t});\n\n\treturn (\n\t\t<Input {...rest} icon>\n\t\t\t<input ref={cardNumberRef} />\n\t\t\t<Icon name=\"id badge\" color={color} size=\"large\" />\n\t\t</Input>\n\t);\n}\n"],"names":[],"mappings":";;;;;;AAOU,MAAM,8BAA8B,EAAA;AAOvC,SAAA,QAAA,CAAkB,KAAsB,EAAA;AAC9C,EAAM,MAAA,EAAC,KAAO,EAAA,QAAA,EAAA,GAAa,IAAQ,EAAA,GAAA,KAAA,CAAA;AACnC,EAAA,MAAM,CAAC,KAAA,EAAO,QAAY,CAAA,GAAA,QAAA,CAAyB,OAAO,CAAA,CAAA;AAE1D,EAAM,MAAA,eAAA,GAAkB,WAAY,CAAA,CAAC,UAAyB,KAAA;AAC7D,IAAA,MAAM,MAAM,UAAW,CAAA,IAAA,CAAK,EAAE,CAAE,CAAA,UAAA,CAAW,aAAa,EAAE,CAAA,CAAA;AAC1D,IA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c,IAAK,EAAA,OAAA;AAAA,GAAQ,CAClD,CAAA,CAAA;AAEF;;;;"}
@@ -1,26 +0,0 @@
1
- import React from 'react';
2
- import { Dropdown } from 'semantic-ui-react';
3
-
4
- function DropdownCell(dropdownProps) {
5
- return function DropdownCellFn(props) {
6
- const {
7
- value,
8
- row: { index: rowIndex },
9
- column: { id },
10
- updateData
11
- } = props;
12
- const { value: v, onChange, ...rest } = dropdownProps;
13
- return /* @__PURE__ */ React.createElement(Dropdown, {
14
- ...rest,
15
- value,
16
- onChange: (event, val) => {
17
- updateData(rowIndex, id, val.value);
18
- if (onChange)
19
- onChange(event, val);
20
- }
21
- });
22
- };
23
- }
24
-
25
- export { DropdownCell };
26
- //# sourceMappingURL=DropdownCell.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DropdownCell.js","sources":["../../../../src/inputs/TableInput/DropdownCell.tsx"],"sourcesContent":["import {Dropdown} from 'semantic-ui-react';\nimport type {DropdownProps} from 'semantic-ui-react';\nimport type {TableCellProps} from './TableInput';\n\nexport function DropdownCell<D extends Record<string, unknown>>(dropdownProps: DropdownProps) {\n\treturn function DropdownCellFn(props: TableCellProps<D>) {\n\t\tconst {\n\t\t\tvalue,\n\t\t\trow: {index: rowIndex},\n\t\t\tcolumn: {id},\n\t\t\tupdateData,\n\t\t} = props;\n\n\t\t// eslint-disable-next-line no-unused-vars,@typescript-eslint/no-unused-vars\n\t\tconst {value: v, onChange, ...rest} = dropdownProps;\n\n\t\treturn (\n\t\t\t<Dropdown\n\t\t\t\t{...rest}\n\t\t\t\tvalue={value}\n\t\t\t\tonChange={(event, val) => {\n\t\t\t\t\tupdateData(rowIndex, id, val.value);\n\t\t\t\t\tif (onChange) onChange(event, val);\n\t\t\t\t}}\n\t\t\t/>\n\t\t);\n\t};\n}\n"],"names":[],"mappings":";;;AAIO,SAAA,YAAA,CAAyD,aAA8B,EAAA;AAC7F,EAAA,OAAO,wBAAwB,KAA0B,EAAA;AACxD,IAAM,MAAA;AAAA,MACL,KAAA;AAAA,MACA,GAAA,EAAK,EAAC,KAAO,EAAA,QAAA,EAAA;AAAA,MACb,QAAQ,EAAC,EAAA,EAAA;AAAA,MACT,UAAA;AAAA,KACG,GAAA,KAAA,CAAA;AAGJ,IAAA,MAAM,EAAC,KAAA,EAAO,CAAG,EAAA,QAAA,EAAA,GAAa,IAAQ,EAAA,GAAA,aAAA,CAAA;AAEtC,IAAA,uBACE,KAAA,CAAA,aAAA,CAAA,QAAA,EAAA;AAAA,MACI,GAAA,IAAA;AAAA,MACJ,KAAA;AAAA,MACA,QAAA,EAAU,CAAC,KAAA,EAAO,GAAQ,KAAA;AACzB,QAAW,UAAA,CAAA,QAAA,EAAU,EAAI,EAAA,GAAA,CAAI,KAAK,CAAA,CAAA;AAClC,QAAI,IAAA,QAAA;AAAU,UAAA,QAAA,CAAS,OAAO,GAAG,CAAA,CAAA;AAAA,OAClC;AAAA,KACD,CAAA,CAAA;AAAA,GAEF,CAAA;AACD;;;;"}
@@ -1,20 +0,0 @@
1
- import React from 'react';
2
- import debug from 'debug';
3
-
4
- debug("thx.controls.inputs.TableInput.HoverCell");
5
- function HoverCell(options) {
6
- return function HoverCellFn(props) {
7
- const { Action } = options;
8
- if (props.hoverRow === props.row.id) {
9
- return /* @__PURE__ */ React.createElement("div", {
10
- style: { textAlign: "right" }
11
- }, /* @__PURE__ */ React.createElement(Action, {
12
- ...props
13
- }));
14
- }
15
- return null;
16
- };
17
- }
18
-
19
- export { HoverCell };
20
- //# sourceMappingURL=HoverCell.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HoverCell.js","sources":["../../../../src/inputs/TableInput/HoverCell.tsx"],"sourcesContent":["import debug from 'debug';\nimport type {CellProps, Renderer} from 'react-table';\n\nconst d = debug('thx.controls.inputs.TableInput.HoverCell');\n\ninterface HoverCellOptions<D extends Record<string, unknown>> {\n\tAction: Renderer<CellProps<D>>;\n}\n\nexport function HoverCell<D extends Record<string, unknown>>(options: HoverCellOptions<D>) {\n\treturn function HoverCellFn(props: CellProps<D>) {\n\t\tconst {Action} = options;\n\n\t\t// @ts-expect-error\n\t\tif (props.hoverRow === props.row.id) {\n\t\t\treturn (\n\t\t\t\t<div style={{textAlign: 'right'}}>\n\t\t\t\t\t{/* @ts-expect-error */}\n\t\t\t\t\t<Action {...props} />\n\t\t\t\t</div>\n\t\t\t);\n\t\t}\n\t\treturn null;\n\t};\n}\n"],"names":[],"mappings":";;;AAGU,MAAM,0CAA0C,EAAA;AAMnD,SAAA,SAAA,CAAsD,OAA8B,EAAA;AAC1F,EAAA,OAAO,qBAAqB,KAAqB,EAAA;AAChD,IAAA,MAAM,EAAC,MAAU,EAAA,GAAA,OAAA,CAAA;AAGjB,IAAA,IAAI,KAAM,CAAA,QAAA,KAAa,KAAM,CAAA,GAAA,CAAI,EAAI,EAAA;AACpC,MAAA,uBACE,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,QAAI,KAAA,EAAO,EAAC,SAAA,EAAW,OAAO,EAAA;AAAA,OAAA,kBAE7B,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA;AAAA,QAAW,GAAA,KAAA;AAAA,OAAO,CACpB,CAAA,CAAA;AAAA,KAEF;AACA,IAAO,OAAA,IAAA,CAAA;AAAA,GACR,CAAA;AACD;;;;"}
@@ -1,13 +0,0 @@
1
- import React from 'react';
2
- import { formatDate } from '@thx/date';
3
-
4
- function LocalDateCell(options) {
5
- return function LocalDateCellFn(props) {
6
- return /* @__PURE__ */ React.createElement("div", {
7
- style: { textAlign: "right" }
8
- }, formatDate(options?.overrideValue ? options.overrideValue(props) : props.value));
9
- };
10
- }
11
-
12
- export { LocalDateCell };
13
- //# sourceMappingURL=LocalDateCell.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LocalDateCell.js","sources":["../../../../src/inputs/TableInput/LocalDateCell.tsx"],"sourcesContent":["import type {LocalDate} from '@js-joda/core';\nimport {formatDate} from '@thx/date';\nimport type {CellProps} from 'react-table';\n\ninterface LocalDateCellOptions<D extends Record<string, unknown>> {\n\t/** If provided, this function will override the LocalDate value displayed */\n\toverrideValue?: (props: CellProps<D, LocalDate>) => LocalDate;\n}\n\nexport function LocalDateCell<D extends Record<string, unknown>>(options?: LocalDateCellOptions<D>) {\n\treturn function LocalDateCellFn(props: CellProps<D, LocalDate>) {\n\t\treturn <div style={{textAlign: 'right'}}>{formatDate(options?.overrideValue ? options.overrideValue(props) : props.value)}</div>;\n\t};\n}\n"],"names":[],"mappings":";;;AASO,SAAA,aAAA,CAA0D,OAAmC,EAAA;AACnG,EAAA,OAAO,yBAAyB,KAAgC,EAAA;AAC/D,IAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,MAAI,KAAA,EAAO,EAAC,SAAA,EAAW,OAAO,EAAA;AAAA,KAAI,EAAA,UAAA,CAAW,SAAS,aAAgB,GAAA,OAAA,CAAQ,cAAc,KAAK,CAAA,GAAI,KAAM,CAAA,KAAK,CAAE,CAAA,CAAA;AAAA,GAC3H,CAAA;AACD;;;;"}
@@ -1,29 +0,0 @@
1
- import React, { useState } from 'react';
2
- import { LocalDate } from '@js-joda/core';
3
- import debug from 'debug';
4
- import { LocalDatePicker } from '../../date/LocalDatePicker/LocalDatePicker.js';
5
-
6
- debug("thx.controls.inputs.TableInput.LocalDateEditCell");
7
- function LocalDateEditCell() {
8
- return function LocalDateEditCellFn(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(LocalDatePicker, {
17
- fluid: true,
18
- transparent: true,
19
- value,
20
- onChange: (val) => setValue(val || LocalDate.now()),
21
- onBlur: () => {
22
- updateData(rowIndex, id, value);
23
- }
24
- });
25
- };
26
- }
27
-
28
- export { LocalDateEditCell };
29
- //# sourceMappingURL=LocalDateEditCell.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LocalDateEditCell.js","sources":["../../../../src/inputs/TableInput/LocalDateEditCell.tsx"],"sourcesContent":["import {LocalDate} from '@js-joda/core';\nimport debug from 'debug';\nimport {useState} from 'react';\nimport {LocalDatePicker} from '../../date/LocalDatePicker';\nimport type {TableCellProps} from './TableInput';\n\nconst d = debug('thx.controls.inputs.TableInput.LocalDateEditCell');\n\nexport function LocalDateEditCell<D extends Record<string, unknown>>() {\n\treturn function LocalDateEditCellFn(props: TableCellProps<D, LocalDate>) {\n\t\tconst {\n\t\t\tvalue: initialValue,\n\t\t\trow: {index: rowIndex},\n\t\t\tcolumn: {id},\n\t\t\tupdateData,\n\t\t} = props;\n\n\t\tconst [value, setValue] = useState(initialValue);\n\n\t\treturn (\n\t\t\t<LocalDatePicker\n\t\t\t\tfluid\n\t\t\t\ttransparent\n\t\t\t\tvalue={value}\n\t\t\t\tonChange={val => setValue(val || LocalDate.now())}\n\t\t\t\tonBlur={() => {\n\t\t\t\t\tupdateData(rowIndex, id, value);\n\t\t\t\t}}\n\t\t\t/>\n\t\t);\n\t};\n}\n"],"names":[],"mappings":";;;;;AAMU,MAAM,kDAAkD,EAAA;AAEK,SAAA,iBAAA,GAAA;AACtE,EAAA,OAAO,6BAA6B,KAAqC,EAAA;AACxE,IAAM,MAAA;AAAA,MACL,KAAO,EAAA,YAAA;AAAA,MACP,GAAA,EAAK,EAAC,KAAO,EAAA,QAAA,EAAA;AAAA,MACb,QAAQ,EAAC,EAAA,EAAA;AAAA,MACT,UAAA;AAAA,KACG,GAAA,KAAA,CAAA;AAEJ,IAAA,MAAM,CAAC,KAAA,EAAO,QAAY,CAAA,GAAA,QAAA,CAAS,YAAY,CAAA,CAAA;AAE/C,IAAA,uBACE,KAAA,CAAA,aAAA,CAAA,eAAA,EAAA;AAAA,MACA,KAAK,EAAA,IAAA;AAAA,MACL,WAAW,EAAA,IAAA;AAAA,MACX,KAAA;AAAA,MACA,UAAU,CAAO,GAAA,KAAA,QAAA,CAAS,GAAO,IAAA,SAAA,CAAU,KAAK,CAAA;AAAA,MAChD,QAAQ,MAAM;AACb,QAAW,UAAA,CAAA,QAAA,EAAU,IAAI,KAAK,CAAA,CAAA;AAAA,OAC/B;AAAA,KACD,CAAA,CAAA;AAAA,GAEF,CAAA;AACD;;;;"}
@@ -1,13 +0,0 @@
1
- import React from 'react';
2
- import { formatMoney } from '@thx/money';
3
-
4
- function MoneyCell(options) {
5
- return function MoneyCellFn(props) {
6
- return /* @__PURE__ */ React.createElement("div", {
7
- style: { textAlign: "right" }
8
- }, formatMoney(options?.overrideValue ? options.overrideValue(props) : props.value));
9
- };
10
- }
11
-
12
- export { MoneyCell };
13
- //# sourceMappingURL=MoneyCell.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MoneyCell.js","sources":["../../../../src/inputs/TableInput/MoneyCell.tsx"],"sourcesContent":["import {formatMoney} from '@thx/money';\nimport type Money from 'js-money';\nimport type {CellProps} from 'react-table';\n\ninterface MoneyCellOptions<D extends Record<string, unknown>> {\n\t/** If provided, this function will override the Money value displayed */\n\toverrideValue?: (props: CellProps<D, Money>) => Money;\n}\n\nexport function MoneyCell<D extends Record<string, unknown>>(options?: MoneyCellOptions<D>) {\n\treturn function MoneyCellFn(props: CellProps<D, Money>) {\n\t\treturn <div style={{textAlign: 'right'}}>{formatMoney(options?.overrideValue ? options.overrideValue(props) : props.value)}</div>;\n\t};\n}\n"],"names":[],"mappings":";;;AASO,SAAA,SAAA,CAAsD,OAA+B,EAAA;AAC3F,EAAA,OAAO,qBAAqB,KAA4B,EAAA;AACvD,IAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,MAAI,KAAA,EAAO,EAAC,SAAA,EAAW,OAAO,EAAA;AAAA,KAAI,EAAA,WAAA,CAAY,SAAS,aAAgB,GAAA,OAAA,CAAQ,cAAc,KAAK,CAAA,GAAI,KAAM,CAAA,KAAK,CAAE,CAAA,CAAA;AAAA,GAC5H,CAAA;AACD;;;;"}
@@ -1,30 +0,0 @@
1
- import React, { useState } from 'react';
2
- import debug from 'debug';
3
- import { MoneyInput } from '../../money/MoneyInput/MoneyInput.js';
4
- import { addRowOnTab } from './addRowOnTab.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?.addRowOnTabIf)
25
- });
26
- };
27
- }
28
-
29
- export { MoneyEditCell };
30
- //# sourceMappingURL=MoneyEditCell.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MoneyEditCell.js","sources":["../../../../src/inputs/TableInput/MoneyEditCell.tsx"],"sourcesContent":["import debug from 'debug';\nimport type Money from 'js-money';\nimport {useState} from 'react';\nimport {MoneyInput} from '../../money/MoneyInput';\nimport type {TableCellProps} from './TableInput';\nimport type {AddRowOnTabIf} from './addRowOnTab';\nimport {addRowOnTab} from './addRowOnTab';\n\nconst d = debug('thx.controls.inputs.TableInput.MoneyEditCell');\n\ninterface MoneyEditCellOptions<D extends Record<string, unknown>> {\n\t/** If function is present, and returns true, will add a new row if tab is pressed on the last row */\n\taddRowOnTabIf?: AddRowOnTabIf<D, Money>;\n}\n\nexport function MoneyEditCell<D extends Record<string, unknown>>(opts?: MoneyEditCellOptions<D>) {\n\treturn function MoneyEditCellFn(props: TableCellProps<D, Money>) {\n\t\tconst {\n\t\t\tvalue: initialValue,\n\t\t\trow: {index: rowIndex},\n\t\t\tcolumn: {id},\n\t\t\tupdateData,\n\t\t} = props;\n\n\t\tconst [value, setValue] = useState(initialValue);\n\n\t\treturn (\n\t\t\t<MoneyInput\n\t\t\t\tfluid\n\t\t\t\ttransparent\n\t\t\t\tvalue={value}\n\t\t\t\tonChange={setValue}\n\t\t\t\tonBlur={() => {\n\t\t\t\t\tupdateData(rowIndex, id, value);\n\t\t\t\t}}\n\t\t\t\tonKeyDown={(event: KeyboardEvent) => addRowOnTab(event, value, props, opts?.addRowOnTabIf)}\n\t\t\t/>\n\t\t);\n\t};\n}\n"],"names":[],"mappings":";;;;;AAQU,MAAM,8CAA8C,EAAA;AAOvD,SAAA,aAAA,CAA0D,IAAgC,EAAA;AAChG,EAAA,OAAO,yBAAyB,KAAiC,EAAA;AAChE,IAAM,MAAA;AAAA,MACL,KAAO,EAAA,YAAA;AAAA,MACP,GAAA,EAAK,EAAC,KAAO,EAAA,QAAA,EAAA;AAAA,MACb,QAAQ,EAAC,EAAA,EAAA;AAAA,MACT,UAAA;AAAA,KACG,GAAA,KAAA,CAAA;AAEJ,IAAA,MAAM,CAAC,KAAA,EAAO,QAAY,CAAA,GAAA,QAAA,CAAS,YAAY,CAAA,CAAA;AAE/C,IAAA,uBACE,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA;AAAA,MACA,KAAK,EAAA,IAAA;AAAA,MACL,WAAW,EAAA,IAAA;AAAA,MACX,KAAA;AAAA,MACA,QAAU,EAAA,QAAA;AAAA,MACV,QAAQ,MAAM;AACb,QAAW,UAAA,CAAA,QAAA,EAAU,IAAI,KAAK,CAAA,CAAA;AAAA,OAC/B;AAAA,MACA,SAAA,EAAW,CAAC,KAAyB,KAAA,WAAA,CAAY,OAAO,KAAO,EAAA,KAAA,EAAO,MAAM,aAAa,CAAA;AAAA,KAC1F,CAAA,CAAA;AAAA,GAEF,CAAA;AACD;;;;"}
@@ -1,15 +0,0 @@
1
- import React from 'react';
2
- import { toMoney, formatMoney } from '@thx/money';
3
-
4
- function MoneySumFooter(options) {
5
- const { id } = options || {};
6
- return function MoneySumFooterInstance(info) {
7
- const sum = info.rows.reduce((memo, row) => memo.add(row.values[id]), toMoney());
8
- return /* @__PURE__ */ React.createElement("div", {
9
- style: { textAlign: "right" }
10
- }, formatMoney(sum));
11
- };
12
- }
13
-
14
- export { MoneySumFooter };
15
- //# sourceMappingURL=MoneySumFooter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MoneySumFooter.js","sources":["../../../../src/inputs/TableInput/MoneySumFooter.tsx"],"sourcesContent":["import {formatMoney, toMoney} from '@thx/money';\nimport type {IdType, TableInstance} from 'react-table';\n\ninterface MoneySumFooterOptions<A extends Record<string, unknown>> {\n\tid: IdType<A>;\n}\n\nexport function MoneySumFooter<A extends Record<string, unknown>>(options: MoneySumFooterOptions<A>) {\n\tconst {id} = options || {};\n\n\treturn function MoneySumFooterInstance(info: TableInstance<A>) {\n\t\tconst sum = info.rows.reduce((memo, row) => memo.add(row.values[id]), toMoney());\n\t\treturn <div style={{textAlign: 'right'}}>{formatMoney(sum)}</div>;\n\t};\n}\n"],"names":[],"mappings":";;;AAOO,SAAA,cAAA,CAA2D,OAAmC,EAAA;AACpG,EAAM,MAAA,EAAC,EAAM,EAAA,GAAA,OAAA,IAAW,EAAC,CAAA;AAEzB,EAAA,OAAO,gCAAgC,IAAwB,EAAA;AAC9D,IAAA,MAAM,GAAM,GAAA,IAAA,CAAK,IAAK,CAAA,MAAA,CAAO,CAAC,IAAM,EAAA,GAAA,KAAQ,IAAK,CAAA,GAAA,CAAI,GAAI,CAAA,MAAA,CAAO,EAAG,CAAA,CAAA,EAAG,SAAS,CAAA,CAAA;AAC/E,IAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,MAAI,KAAA,EAAO,EAAC,SAAA,EAAW,OAAO,EAAA;AAAA,KAAI,EAAA,WAAA,CAAY,GAAG,CAAE,CAAA,CAAA;AAAA,GAC5D,CAAA;AACD;;;;"}
@@ -1,34 +0,0 @@
1
- import React, { useState } from 'react';
2
- import debug from 'debug';
3
- import { Input } from 'semantic-ui-react';
4
- import { addRowOnTab } from './addRowOnTab.js';
5
-
6
- debug("thx.controls.inputs.TableInput.StringEditCell");
7
- function StringEditCell(options) {
8
- const { inputProps, addRowOnTabIf } = options || {};
9
- return function StringEditCellFn(props) {
10
- const {
11
- value: initialValue,
12
- row: { index },
13
- column: { id },
14
- updateData
15
- } = props;
16
- const [value, setValue] = useState(initialValue);
17
- return /* @__PURE__ */ React.createElement(Input, {
18
- fluid: true,
19
- transparent: true,
20
- ...inputProps,
21
- value,
22
- onChange: (ev, v) => {
23
- setValue(v.value);
24
- },
25
- onBlur: () => {
26
- updateData(index, id, value);
27
- },
28
- onKeyDown: (event) => addRowOnTab(event, value, props, addRowOnTabIf)
29
- });
30
- };
31
- }
32
-
33
- export { StringEditCell };
34
- //# sourceMappingURL=StringEditCell.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StringEditCell.js","sources":["../../../../src/inputs/TableInput/StringEditCell.tsx"],"sourcesContent":["import debug from 'debug';\nimport {useState} from 'react';\nimport {Input, InputProps} from 'semantic-ui-react';\nimport type {TableCellProps} from './TableInput';\nimport type {AddRowOnTabIf} from './addRowOnTab';\nimport {addRowOnTab} from './addRowOnTab';\n\nconst d = debug('thx.controls.inputs.TableInput.StringEditCell');\n\ninterface StringEditCellOptions<D extends Record<string, unknown>> {\n\t/** Override SemanticUI Input props */\n\tinputProps?: InputProps;\n\t/** If function is present, and returns true, will add a new row if tab is pressed on the last row */\n\taddRowOnTabIf?: AddRowOnTabIf<D, string>;\n}\n\nexport function StringEditCell<D extends Record<string, unknown>>(options?: StringEditCellOptions<D>) {\n\tconst {inputProps, addRowOnTabIf} = options || {};\n\n\treturn function StringEditCellFn(props: TableCellProps<D, string>) {\n\t\tconst {\n\t\t\tvalue: initialValue,\n\t\t\trow: {index},\n\t\t\tcolumn: {id},\n\t\t\tupdateData,\n\t\t} = props;\n\n\t\tconst [value, setValue] = useState(initialValue);\n\n\t\treturn (\n\t\t\t<Input\n\t\t\t\tfluid\n\t\t\t\ttransparent\n\t\t\t\t{...inputProps}\n\t\t\t\tvalue={value}\n\t\t\t\tonChange={(ev, v) => {\n\t\t\t\t\tsetValue(v.value);\n\t\t\t\t}}\n\t\t\t\tonBlur={() => {\n\t\t\t\t\tupdateData(index, id, value);\n\t\t\t\t}}\n\t\t\t\tonKeyDown={(event: KeyboardEvent) => addRowOnTab(event, value, props, addRowOnTabIf)}\n\t\t\t/>\n\t\t);\n\t};\n}\n"],"names":[],"mappings":";;;;;AAOU,MAAM,+CAA+C,EAAA;AASxD,SAAA,cAAA,CAA2D,OAAoC,EAAA;AACrG,EAAA,MAAM,EAAC,UAAA,EAAY,aAAiB,EAAA,GAAA,OAAA,IAAW,EAAC,CAAA;AAEhD,EAAA,OAAO,0BAA0B,KAAkC,EAAA;AAClE,IAAM,MAAA;AAAA,MACL,KAAO,EAAA,YAAA;AAAA,MACP,KAAK,EAAC,KAAA,EAAA;AAAA,MACN,QAAQ,EAAC,EAAA,EAAA;AAAA,MACT,UAAA;AAAA,KACG,GAAA,KAAA,CAAA;AAEJ,IAAA,MAAM,CAAC,KAAA,EAAO,QAAY,CAAA,GAAA,QAAA,CAAS,YAAY,CAAA,CAAA;AAE/C,IAAA,uBACE,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,MACA,KAAK,EAAA,IAAA;AAAA,MACL,WAAW,EAAA,IAAA;AAAA,MACP,GAAA,UAAA;AAAA,MACJ,KAAA;AAAA,MACA,QAAA,EAAU,CAAC,EAAA,EAAI,CAAM,KAAA;AACpB,QAAA,QAAA,CAAS,EAAE,KAAK,CAAA,CAAA;AAAA,OACjB;AAAA,MACA,QAAQ,MAAM;AACb,QAAW,UAAA,CAAA,KAAA,EAAO,IAAI,KAAK,CAAA,CAAA;AAAA,OAC5B;AAAA,MACA,WAAW,CAAC,KAAA,KAAyB,YAAY,KAAO,EAAA,KAAA,EAAO,OAAO,aAAa,CAAA;AAAA,KACpF,CAAA,CAAA;AAAA,GAEF,CAAA;AACD;;;;"}
@@ -1,75 +0,0 @@
1
- import React, { useMemo, useState } from 'react';
2
- import debug from 'debug';
3
- import { FieldArray } from 'formik';
4
- import { useTable } from 'react-table';
5
- import { Table } from 'semantic-ui-react';
6
-
7
- debug("thx.controls.inputs.TableInput");
8
- function TableInputTable(props) {
9
- const {
10
- name,
11
- columns,
12
- values,
13
- arrayHelpers,
14
- setFieldValue,
15
- createRow,
16
- tableProps,
17
- headerRowProps,
18
- headerCellProps,
19
- bodyProps,
20
- rowProps,
21
- cellProps,
22
- footerCellProps,
23
- footerRowProps
24
- } = props;
25
- const cols = useMemo(() => columns, [columns]);
26
- const vals = useMemo(() => values, [values]);
27
- const [hoverRow, setHoverRow] = useState("");
28
- const { getTableProps, getTableBodyProps, headerGroups, prepareRow, rows, footerGroups } = useTable({
29
- columns: cols,
30
- data: vals,
31
- updateData(rowIndex, columnId, value) {
32
- setFieldValue(`${name}[${rowIndex}].${columnId}`, value);
33
- },
34
- addRow() {
35
- arrayHelpers.push(createRow());
36
- },
37
- arrayHelpers
38
- });
39
- const hasFooter = footerGroups.some((fg) => fg.headers.some((fgh) => fgh.Footer.name !== "emptyRenderer"));
40
- const footer = hasFooter ? /* @__PURE__ */ React.createElement(Table.Footer, null, footerGroups.map((group) => /* @__PURE__ */ React.createElement(Table.Row, {
41
- ...{ ...group.getFooterGroupProps(), ...group.getFooterGroupProps(footerRowProps) }
42
- }, group.headers.map((column) => /* @__PURE__ */ React.createElement(Table.HeaderCell, {
43
- ...{ ...column.getFooterProps(), ...column.getFooterProps(footerCellProps) }
44
- }, column.render("Footer")))))) : null;
45
- return /* @__PURE__ */ React.createElement(Table, {
46
- ...{ ...getTableProps(), ...getTableProps(tableProps) }
47
- }, /* @__PURE__ */ React.createElement(Table.Header, null, headerGroups.map((headerGroup) => /* @__PURE__ */ React.createElement(Table.Row, {
48
- ...{ ...headerGroup.getHeaderGroupProps(), ...headerGroup.getHeaderGroupProps(headerRowProps) }
49
- }, headerGroup.headers.map((column) => /* @__PURE__ */ React.createElement(Table.HeaderCell, {
50
- ...{ ...column.getHeaderProps(), ...column.getHeaderProps(headerCellProps) }
51
- }, column.render("Header")))))), /* @__PURE__ */ React.createElement(Table.Body, {
52
- ...{ ...getTableBodyProps(), ...getTableBodyProps(bodyProps) }
53
- }, rows.map((row) => {
54
- prepareRow(row);
55
- return /* @__PURE__ */ React.createElement(Table.Row, {
56
- ...{ ...row.getRowProps(), ...row.getRowProps(rowProps) },
57
- onMouseEnter: () => setHoverRow(row.id),
58
- onMouseLeave: () => setHoverRow("")
59
- }, row.cells.map((cell) => /* @__PURE__ */ React.createElement(Table.Cell, {
60
- ...{ ...cell.getCellProps(), ...cell.getCellProps(cellProps) }
61
- }, cell.render("Cell", { hoverRow }))));
62
- })), footer);
63
- }
64
- function TableInput(props) {
65
- return /* @__PURE__ */ React.createElement(FieldArray, {
66
- name: props.name,
67
- render: (arrayHelpers) => /* @__PURE__ */ React.createElement(TableInputTable, {
68
- arrayHelpers,
69
- ...props
70
- })
71
- });
72
- }
73
-
74
- export { TableInput };
75
- //# sourceMappingURL=TableInput.js.map