@thx/controls 17.3.5 → 17.3.6

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 (144) hide show
  1. package/dist/esm/date/DatePicker/styles.css.js +7 -0
  2. package/dist/esm/date/DatePicker/styles.css.js.map +1 -0
  3. package/dist/esm/date/LocalDatePicker/LocalDatePicker.js +151 -0
  4. package/dist/esm/date/LocalDatePicker/LocalDatePicker.js.map +1 -0
  5. package/dist/esm/date/LocalDatePicker/MaskedDateInput.js +22 -0
  6. package/dist/esm/date/LocalDatePicker/MaskedDateInput.js.map +1 -0
  7. package/dist/esm/date/LocalMonthSelect/LocalMonthSelect.js +43 -0
  8. package/dist/esm/date/LocalMonthSelect/LocalMonthSelect.js.map +1 -0
  9. package/dist/esm/date/LocalTimePicker/LocalTimePicker.js +96 -0
  10. package/dist/esm/date/LocalTimePicker/LocalTimePicker.js.map +1 -0
  11. package/dist/esm/date/LocalTimePicker/MaskedTimeInput.js +22 -0
  12. package/dist/esm/date/LocalTimePicker/MaskedTimeInput.js.map +1 -0
  13. package/dist/esm/date/MonthDayPicker/MonthDayPicker.js +86 -0
  14. package/dist/esm/date/MonthDayPicker/MonthDayPicker.js.map +1 -0
  15. package/dist/esm/date/MonthYearPicker/MonthYearPicker.js +73 -0
  16. package/dist/esm/date/MonthYearPicker/MonthYearPicker.js.map +1 -0
  17. package/dist/esm/date/YearSelect/YearSelect.js +62 -0
  18. package/dist/esm/date/YearSelect/YearSelect.js.map +1 -0
  19. package/dist/esm/external/style-inject/dist/style-inject.es.js +29 -0
  20. package/dist/esm/external/style-inject/dist/style-inject.es.js.map +1 -0
  21. package/dist/esm/form/TForm/TForm.js +29 -0
  22. package/dist/esm/form/TForm/TForm.js.map +1 -0
  23. package/dist/esm/form/TForm/useTForm.js +90 -0
  24. package/dist/esm/form/TForm/useTForm.js.map +1 -0
  25. package/dist/esm/index.js +34 -0
  26. package/dist/esm/index.js.map +1 -0
  27. package/dist/esm/inputs/CreditCardInput/CreditCardInput.js +71 -0
  28. package/dist/esm/inputs/CreditCardInput/CreditCardInput.js.map +1 -0
  29. package/dist/esm/inputs/CreditCardInput/CreditCardNumberInput.js +76 -0
  30. package/dist/esm/inputs/CreditCardInput/CreditCardNumberInput.js.map +1 -0
  31. package/dist/esm/inputs/CreditCardInput/styles.css.js +7 -0
  32. package/dist/esm/inputs/CreditCardInput/styles.css.js.map +1 -0
  33. package/dist/esm/inputs/MaskedInput/MaskedInput.js +26 -0
  34. package/dist/esm/inputs/MaskedInput/MaskedInput.js.map +1 -0
  35. package/dist/esm/inputs/MaskedInput/useMaskedInput.js +57 -0
  36. package/dist/esm/inputs/MaskedInput/useMaskedInput.js.map +1 -0
  37. package/dist/esm/inputs/PhoneInput/PhoneInput.js +59 -0
  38. package/dist/esm/inputs/PhoneInput/PhoneInput.js.map +1 -0
  39. package/dist/esm/inputs/RadioGroup/RadioGroup.js +25 -0
  40. package/dist/esm/inputs/RadioGroup/RadioGroup.js.map +1 -0
  41. package/dist/esm/inputs/SinInput/SinInput.js +54 -0
  42. package/dist/esm/inputs/SinInput/SinInput.js.map +1 -0
  43. package/dist/esm/inputs/TableInput/CheckboxEditCell.js +32 -0
  44. package/dist/esm/inputs/TableInput/CheckboxEditCell.js.map +1 -0
  45. package/dist/esm/inputs/TableInput/DropdownCell.js +26 -0
  46. package/dist/esm/inputs/TableInput/DropdownCell.js.map +1 -0
  47. package/dist/esm/inputs/TableInput/HoverCell.js +20 -0
  48. package/dist/esm/inputs/TableInput/HoverCell.js.map +1 -0
  49. package/dist/esm/inputs/TableInput/LocalDateCell.js +13 -0
  50. package/dist/esm/inputs/TableInput/LocalDateCell.js.map +1 -0
  51. package/dist/esm/inputs/TableInput/LocalDateEditCell.js +33 -0
  52. package/dist/esm/inputs/TableInput/LocalDateEditCell.js.map +1 -0
  53. package/dist/esm/inputs/TableInput/LocalTimeEditCell.js +31 -0
  54. package/dist/esm/inputs/TableInput/LocalTimeEditCell.js.map +1 -0
  55. package/dist/esm/inputs/TableInput/MoneyCell.js +13 -0
  56. package/dist/esm/inputs/TableInput/MoneyCell.js.map +1 -0
  57. package/dist/esm/inputs/TableInput/MoneyEditCell.js +37 -0
  58. package/dist/esm/inputs/TableInput/MoneyEditCell.js.map +1 -0
  59. package/dist/esm/inputs/TableInput/MoneySumFooter.js +20 -0
  60. package/dist/esm/inputs/TableInput/MoneySumFooter.js.map +1 -0
  61. package/dist/esm/inputs/TableInput/NumberEditCell.js +35 -0
  62. package/dist/esm/inputs/TableInput/NumberEditCell.js.map +1 -0
  63. package/dist/esm/inputs/TableInput/StringEditCell.js +34 -0
  64. package/dist/esm/inputs/TableInput/StringEditCell.js.map +1 -0
  65. package/dist/esm/inputs/TableInput/TableInput.js +79 -0
  66. package/dist/esm/inputs/TableInput/TableInput.js.map +1 -0
  67. package/dist/esm/inputs/TableInput/addRowOnTab.js +13 -0
  68. package/dist/esm/inputs/TableInput/addRowOnTab.js.map +1 -0
  69. package/dist/esm/money/MoneyCurrencyInput/MoneyCurrencyInput.js +51 -0
  70. package/dist/esm/money/MoneyCurrencyInput/MoneyCurrencyInput.js.map +1 -0
  71. package/dist/esm/money/MoneyInput/MoneyInput.js +31 -0
  72. package/dist/esm/money/MoneyInput/MoneyInput.js.map +1 -0
  73. package/dist/esm/money/useMoneyInput.js +75 -0
  74. package/dist/esm/money/useMoneyInput.js.map +1 -0
  75. package/dist/esm/step/FormStep.js +17 -0
  76. package/dist/esm/step/FormStep.js.map +1 -0
  77. package/dist/esm/step/Step.js +10 -0
  78. package/dist/esm/step/Step.js.map +1 -0
  79. package/dist/esm/step/StepProvider.js +95 -0
  80. package/dist/esm/step/StepProvider.js.map +1 -0
  81. package/dist/esm/step/stepContext.js +10 -0
  82. package/dist/esm/step/stepContext.js.map +1 -0
  83. package/dist/esm/step/useStep.js +10 -0
  84. package/dist/esm/step/useStep.js.map +1 -0
  85. package/dist/stats.html +2689 -0
  86. package/dist/stats.txt +92 -0
  87. package/dist/types/date/DatePicker/index.d.ts +3 -0
  88. package/dist/types/date/LocalDatePicker/LocalDatePicker.d.ts +20 -0
  89. package/dist/types/date/LocalDatePicker/MaskedDateInput.d.ts +13 -0
  90. package/dist/types/date/LocalDatePicker/index.d.ts +2 -0
  91. package/dist/types/date/LocalMonthSelect/LocalMonthSelect.d.ts +11 -0
  92. package/dist/types/date/LocalMonthSelect/index.d.ts +2 -0
  93. package/dist/types/date/LocalTimePicker/LocalTimePicker.d.ts +13 -0
  94. package/dist/types/date/LocalTimePicker/MaskedTimeInput.d.ts +12 -0
  95. package/dist/types/date/LocalTimePicker/index.d.ts +2 -0
  96. package/dist/types/date/MonthDayPicker/MonthDayPicker.d.ts +13 -0
  97. package/dist/types/date/MonthDayPicker/index.d.ts +2 -0
  98. package/dist/types/date/MonthYearPicker/MonthYearPicker.d.ts +15 -0
  99. package/dist/types/date/MonthYearPicker/index.d.ts +2 -0
  100. package/dist/types/date/YearSelect/YearSelect.d.ts +10 -0
  101. package/dist/types/date/YearSelect/index.d.ts +2 -0
  102. package/dist/types/form/TForm/TForm.d.ts +3 -0
  103. package/dist/types/form/TForm/index.d.ts +3 -0
  104. package/dist/types/form/TForm/types.d.ts +32 -0
  105. package/dist/types/form/TForm/useTForm.d.ts +57 -0
  106. package/dist/types/index.d.ts +32 -0
  107. package/dist/types/inputs/CreditCardInput/CreditCardInput.d.ts +15 -0
  108. package/dist/types/inputs/CreditCardInput/CreditCardNumberInput.d.ts +7 -0
  109. package/dist/types/inputs/CreditCardInput/index.d.ts +2 -0
  110. package/dist/types/inputs/MaskedInput/MaskedInput.d.ts +11 -0
  111. package/dist/types/inputs/MaskedInput/index.d.ts +3 -0
  112. package/dist/types/inputs/MaskedInput/useMaskedInput.d.ts +7 -0
  113. package/dist/types/inputs/PhoneInput/PhoneInput.d.ts +6 -0
  114. package/dist/types/inputs/PhoneInput/index.d.ts +2 -0
  115. package/dist/types/inputs/RadioGroup/RadioGroup.d.ts +7 -0
  116. package/dist/types/inputs/RadioGroup/index.d.ts +2 -0
  117. package/dist/types/inputs/SinInput/SinInput.d.ts +6 -0
  118. package/dist/types/inputs/SinInput/index.d.ts +2 -0
  119. package/dist/types/inputs/TableInput/CheckboxEditCell.d.ts +11 -0
  120. package/dist/types/inputs/TableInput/DropdownCell.d.ts +3 -0
  121. package/dist/types/inputs/TableInput/HoverCell.d.ts +6 -0
  122. package/dist/types/inputs/TableInput/LocalDateCell.d.ts +10 -0
  123. package/dist/types/inputs/TableInput/LocalDateEditCell.d.ts +3 -0
  124. package/dist/types/inputs/TableInput/LocalTimeEditCell.d.ts +3 -0
  125. package/dist/types/inputs/TableInput/MoneyCell.d.ts +8 -0
  126. package/dist/types/inputs/TableInput/MoneyEditCell.d.ts +10 -0
  127. package/dist/types/inputs/TableInput/MoneySumFooter.d.ts +6 -0
  128. package/dist/types/inputs/TableInput/NumberEditCell.d.ts +11 -0
  129. package/dist/types/inputs/TableInput/StringEditCell.d.ts +11 -0
  130. package/dist/types/inputs/TableInput/TableInput.d.ts +32 -0
  131. package/dist/types/inputs/TableInput/addRowOnTab.d.ts +10 -0
  132. package/dist/types/inputs/TableInput/index.d.ts +14 -0
  133. package/dist/types/money/MoneyCurrencyInput/MoneyCurrencyInput.d.ts +10 -0
  134. package/dist/types/money/MoneyCurrencyInput/index.d.ts +2 -0
  135. package/dist/types/money/MoneyInput/MoneyInput.d.ts +14 -0
  136. package/dist/types/money/MoneyInput/index.d.ts +2 -0
  137. package/dist/types/money/useMoneyInput.d.ts +13 -0
  138. package/dist/types/step/FormStep.d.ts +8 -0
  139. package/dist/types/step/Step.d.ts +8 -0
  140. package/dist/types/step/StepProvider.d.ts +9 -0
  141. package/dist/types/step/index.d.ts +4 -0
  142. package/dist/types/step/stepContext.d.ts +4 -0
  143. package/dist/types/step/useStep.d.ts +1 -0
  144. package/package.json +4 -4
@@ -0,0 +1,54 @@
1
+ import React, { useState, useCallback, useMemo } from 'react';
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
@@ -0,0 +1 @@
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, type 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,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IAAW,KAAA;AAAA,IAAc,IAAK,EAAA,OAAA;AAAA,GAAQ,CAClD,CAAA,CAAA;AAEF;;;;"}
@@ -0,0 +1,32 @@
1
+ import React, { useState } from 'react';
2
+ import debug from 'debug';
3
+ import { Checkbox } from 'semantic-ui-react';
4
+ import { addRowOnTab } from './addRowOnTab.js';
5
+
6
+ debug("thx.controls.inputs.TableInput.CheckboxEditCell");
7
+ function CheckboxEditCell(options) {
8
+ const { inputProps, addRowOnTabIf } = options || {};
9
+ return function CheckboxEditCellFn(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(Checkbox, {
18
+ ...inputProps,
19
+ checked: value,
20
+ onChange: (ev, v) => {
21
+ setValue(v.checked || false);
22
+ },
23
+ onBlur: () => {
24
+ updateData(index, id, value);
25
+ },
26
+ onKeyDown: (event) => addRowOnTab(event, value, props, addRowOnTabIf)
27
+ });
28
+ };
29
+ }
30
+
31
+ export { CheckboxEditCell };
32
+ //# sourceMappingURL=CheckboxEditCell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CheckboxEditCell.js","sources":["../../../../src/inputs/TableInput/CheckboxEditCell.tsx"],"sourcesContent":["import debug from 'debug';\nimport {useState} from 'react';\nimport {Checkbox, type CheckboxProps} 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.CheckboxEditCell');\n\ninterface CheckboxEditCellOptions<D extends Record<string, unknown>> {\n\t/** Override SemanticUI Input props */\n\tinputProps?: CheckboxProps;\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, boolean>;\n}\n\nexport function CheckboxEditCell<D extends Record<string, unknown>>(options?: CheckboxEditCellOptions<D>) {\n\tconst {inputProps, addRowOnTabIf} = options || {};\n\n\treturn function CheckboxEditCellFn(props: TableCellProps<D, boolean>) {\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<Checkbox\n\t\t\t\t{...inputProps}\n\t\t\t\tchecked={value}\n\t\t\t\tonChange={(ev, v) => {\n\t\t\t\t\tsetValue(v.checked || false);\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,iDAAiD,EAAA;AAS1D,SAAA,gBAAA,CAA6D,OAAsC,EAAA;AACzG,EAAA,MAAM,EAAC,UAAA,EAAY,aAAiB,EAAA,GAAA,OAAA,IAAW,EAAC,CAAA;AAEhD,EAAA,OAAO,4BAA4B,KAAmC,EAAA;AACrE,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,QAAA,EAAA;AAAA,MACI,GAAA,UAAA;AAAA,MACJ,OAAS,EAAA,KAAA;AAAA,MACT,QAAA,EAAU,CAAC,EAAA,EAAI,CAAM,KAAA;AACpB,QAAS,QAAA,CAAA,CAAA,CAAE,WAAW,KAAK,CAAA,CAAA;AAAA,OAC5B;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;;;;"}
@@ -0,0 +1,26 @@
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 { 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
@@ -0,0 +1 @@
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\tconst {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;AAEJ,IAAM,MAAA,EAAC,aAAa,IAAQ,EAAA,GAAA,aAAA,CAAA;AAE5B,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;;;;"}
@@ -0,0 +1,20 @@
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
@@ -0,0 +1 @@
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;;;;"}
@@ -0,0 +1,13 @@
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, options?.dateFormat));
9
+ };
10
+ }
11
+
12
+ export { LocalDateCell };
13
+ //# sourceMappingURL=LocalDateCell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalDateCell.js","sources":["../../../../src/inputs/TableInput/LocalDateCell.tsx"],"sourcesContent":["import type {LocalDate} from '@js-joda/core';\nimport {formatDate, type FormatDateParams} 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\tdateFormat?: FormatDateParams;\n}\n\nexport function LocalDateCell<D extends Record<string, unknown>>(options?: LocalDateCellOptions<D>) {\n\treturn function LocalDateCellFn(props: CellProps<D, LocalDate>) {\n\t\treturn (\n\t\t\t<div style={{textAlign: 'right'}}>{formatDate(options?.overrideValue ? options.overrideValue(props) : props.value, options?.dateFormat)}</div>\n\t\t);\n\t};\n}\n"],"names":[],"mappings":";;;AAUO,SAAA,aAAA,CAA0D,OAAmC,EAAA;AACnG,EAAA,OAAO,yBAAyB,KAAgC,EAAA;AAC/D,IAAA,uBACE,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,MAAI,KAAA,EAAO,EAAC,SAAA,EAAW,OAAO,EAAA;AAAA,KAAI,EAAA,UAAA,CAAW,OAAS,EAAA,aAAA,GAAgB,OAAQ,CAAA,aAAA,CAAc,KAAK,CAAA,GAAI,KAAM,CAAA,KAAA,EAAO,OAAS,EAAA,UAAU,CAAE,CAAA,CAAA;AAAA,GAE1I,CAAA;AACD;;;;"}
@@ -0,0 +1,33 @@
1
+ import React, { useState } from 'react';
2
+ import debug from 'debug';
3
+ import { LocalDatePicker } from '../../date/LocalDatePicker/LocalDatePicker.js';
4
+
5
+ debug("thx.controls.inputs.TableInput.LocalDateEditCell");
6
+ function LocalDateEditCell() {
7
+ return function LocalDateEditCellFn(props) {
8
+ const {
9
+ value: initialValue,
10
+ row: { index: rowIndex },
11
+ column: { id },
12
+ updateData,
13
+ hoverRow
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) => {
21
+ setValue(val);
22
+ updateData(rowIndex, id, val);
23
+ },
24
+ onBlur: () => {
25
+ updateData(rowIndex, id, value);
26
+ },
27
+ icon: hoverRow.toString() === rowIndex.toString()
28
+ });
29
+ };
30
+ }
31
+
32
+ export { LocalDateEditCell };
33
+ //# sourceMappingURL=LocalDateEditCell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalDateEditCell.js","sources":["../../../../src/inputs/TableInput/LocalDateEditCell.tsx"],"sourcesContent":["import type {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 | null>) {\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\thoverRow,\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 => {\n\t\t\t\t\tsetValue(val);\n\t\t\t\t\tupdateData(rowIndex, id, val);\n\t\t\t\t}}\n\t\t\t\tonBlur={() => {\n\t\t\t\t\tupdateData(rowIndex, id, value);\n\t\t\t\t}}\n\t\t\t\ticon={hoverRow.toString() === rowIndex.toString()}\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,KAA4C,EAAA;AAC/E,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,MACA,QAAA;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;AAChB,QAAA,QAAA,CAAS,GAAG,CAAA,CAAA;AACZ,QAAW,UAAA,CAAA,QAAA,EAAU,IAAI,GAAG,CAAA,CAAA;AAAA,OAC7B;AAAA,MACA,QAAQ,MAAM;AACb,QAAW,UAAA,CAAA,QAAA,EAAU,IAAI,KAAK,CAAA,CAAA;AAAA,OAC/B;AAAA,MACA,IAAM,EAAA,QAAA,CAAS,QAAS,EAAA,KAAM,SAAS,QAAS,EAAA;AAAA,KACjD,CAAA,CAAA;AAAA,GAEF,CAAA;AACD;;;;"}
@@ -0,0 +1,31 @@
1
+ import React, { useState } from 'react';
2
+ import debug from 'debug';
3
+ import { LocalTimePicker } from '../../date/LocalTimePicker/LocalTimePicker.js';
4
+
5
+ debug("thx.controls.inputs.TableInput.LocalTimeEditCell");
6
+ function LocalTimeEditCell() {
7
+ return function LocalTimeEditCellFn(props) {
8
+ const {
9
+ value: initialValue,
10
+ row: { index: rowIndex },
11
+ column: { id },
12
+ updateData
13
+ } = props;
14
+ const [value, setValue] = useState(initialValue);
15
+ return /* @__PURE__ */ React.createElement(LocalTimePicker, {
16
+ fluid: true,
17
+ transparent: true,
18
+ value,
19
+ onChange: (val) => {
20
+ setValue(val);
21
+ updateData(rowIndex, id, val);
22
+ },
23
+ onBlur: () => {
24
+ updateData(rowIndex, id, value);
25
+ }
26
+ });
27
+ };
28
+ }
29
+
30
+ export { LocalTimeEditCell };
31
+ //# sourceMappingURL=LocalTimeEditCell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalTimeEditCell.js","sources":["../../../../src/inputs/TableInput/LocalTimeEditCell.tsx"],"sourcesContent":["import type {LocalTime} from '@js-joda/core';\nimport debug from 'debug';\nimport {useState} from 'react';\nimport {LocalTimePicker} from '../../date/LocalTimePicker';\nimport type {TableCellProps} from './TableInput';\n\nconst d = debug('thx.controls.inputs.TableInput.LocalTimeEditCell');\n\nexport function LocalTimeEditCell<D extends Record<string, unknown>>() {\n\treturn function LocalTimeEditCellFn(props: TableCellProps<D, LocalTime | null>) {\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<LocalTimePicker\n\t\t\t\tfluid\n\t\t\t\ttransparent\n\t\t\t\tvalue={value}\n\t\t\t\tonChange={val => {\n\t\t\t\t\tsetValue(val);\n\t\t\t\t\tupdateData(rowIndex, id, val);\n\t\t\t\t}}\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,KAA4C,EAAA;AAC/E,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;AAChB,QAAA,QAAA,CAAS,GAAG,CAAA,CAAA;AACZ,QAAW,UAAA,CAAA,QAAA,EAAU,IAAI,GAAG,CAAA,CAAA;AAAA,OAC7B;AAAA,MACA,QAAQ,MAAM;AACb,QAAW,UAAA,CAAA,QAAA,EAAU,IAAI,KAAK,CAAA,CAAA;AAAA,OAC/B;AAAA,KACD,CAAA,CAAA;AAAA,GAEF,CAAA;AACD;;;;"}
@@ -0,0 +1,13 @@
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
@@ -0,0 +1 @@
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;;;;"}
@@ -0,0 +1,37 @@
1
+ import React, { useState, useEffect } 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(moneyEditCellProps) {
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
+ const { addRowOnTabIf, ...rest } = moneyEditCellProps || {};
17
+ useEffect(() => {
18
+ if (initialValue) {
19
+ setValue(initialValue);
20
+ }
21
+ }, [initialValue]);
22
+ return /* @__PURE__ */ React.createElement(MoneyInput, {
23
+ ...rest,
24
+ fluid: true,
25
+ transparent: true,
26
+ value,
27
+ onChange: setValue,
28
+ onBlur: () => {
29
+ updateData(rowIndex, id, value);
30
+ },
31
+ onKeyDown: (event) => addRowOnTab(event, value, props, addRowOnTabIf)
32
+ });
33
+ };
34
+ }
35
+
36
+ export { MoneyEditCell };
37
+ //# sourceMappingURL=MoneyEditCell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MoneyEditCell.js","sources":["../../../../src/inputs/TableInput/MoneyEditCell.tsx"],"sourcesContent":["import debug from 'debug';\nimport type Money from 'js-money';\nimport {useEffect, 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 | undefined>;\n\ttabIndex?: number;\n}\n\nexport function MoneyEditCell<D extends Record<string, unknown>>(moneyEditCellProps?: MoneyEditCellOptions<D>) {\n\treturn function MoneyEditCellFn(props: TableCellProps<D, Money | undefined>) {\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\t\tconst {addRowOnTabIf, ...rest} = moneyEditCellProps || {};\n\n\t\tuseEffect(() => {\n\t\t\tif (initialValue) {\n\t\t\t\tsetValue(initialValue);\n\t\t\t}\n\t\t}, [initialValue]);\n\n\t\treturn (\n\t\t\t<MoneyInput\n\t\t\t\t{...rest}\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, addRowOnTabIf)}\n\t\t\t/>\n\t\t);\n\t};\n}\n"],"names":[],"mappings":";;;;;AAQU,MAAM,8CAA8C,EAAA;AAQvD,SAAA,aAAA,CAA0D,kBAA8C,EAAA;AAC9G,EAAA,OAAO,yBAAyB,KAA6C,EAAA;AAC5E,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;AAC/C,IAAA,MAAM,EAAC,aAAA,EAAA,GAAkB,IAAQ,EAAA,GAAA,kBAAA,IAAsB,EAAC,CAAA;AAExD,IAAA,SAAA,CAAU,MAAM;AACf,MAAA,IAAI,YAAc,EAAA;AACjB,QAAA,QAAA,CAAS,YAAY,CAAA,CAAA;AAAA,OACtB;AAAA,KACD,EAAG,CAAC,YAAY,CAAC,CAAA,CAAA;AAEjB,IAAA,uBACE,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA;AAAA,MACI,GAAA,IAAA;AAAA,MACJ,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,WAAW,CAAC,KAAA,KAAyB,YAAY,KAAO,EAAA,KAAA,EAAO,OAAO,aAAa,CAAA;AAAA,KACpF,CAAA,CAAA;AAAA,GAEF,CAAA;AACD;;;;"}
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import { isMoney, 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) => {
8
+ if (isMoney(row.values[id])) {
9
+ return memo.add(row.values[id]);
10
+ }
11
+ return memo;
12
+ }, toMoney());
13
+ return /* @__PURE__ */ React.createElement("div", {
14
+ style: { textAlign: "right" }
15
+ }, formatMoney(sum));
16
+ };
17
+ }
18
+
19
+ export { MoneySumFooter };
20
+ //# sourceMappingURL=MoneySumFooter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MoneySumFooter.js","sources":["../../../../src/inputs/TableInput/MoneySumFooter.tsx"],"sourcesContent":["import {formatMoney, isMoney, 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) => {\n\t\t\t// checks to make sure we have an instance of money -STT\n\t\t\tif (isMoney(row.values[id])) {\n\t\t\t\treturn memo.add(row.values[id]);\n\t\t\t}\n\t\t\treturn memo;\n\t\t}, 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,MAAM,IAAK,CAAA,IAAA,CAAK,MAAO,CAAA,CAAC,MAAM,GAAQ,KAAA;AAE3C,MAAA,IAAI,OAAQ,CAAA,GAAA,CAAI,MAAO,CAAA,EAAA,CAAG,CAAG,EAAA;AAC5B,QAAA,OAAO,IAAK,CAAA,GAAA,CAAI,GAAI,CAAA,MAAA,CAAO,EAAG,CAAA,CAAA,CAAA;AAAA,OAC/B;AACA,MAAO,OAAA,IAAA,CAAA;AAAA,KACR,EAAG,SAAS,CAAA,CAAA;AACZ,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;;;;"}
@@ -0,0 +1,35 @@
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.NumberEditCell");
7
+ function NumberEditCell(options) {
8
+ const { inputProps, addRowOnTabIf } = options || {};
9
+ return function NumberEditCellFn(props) {
10
+ const {
11
+ value: initialValue,
12
+ row: { index },
13
+ column: { id },
14
+ updateData
15
+ } = props;
16
+ const [value, setValue] = useState(initialValue?.toString());
17
+ return /* @__PURE__ */ React.createElement(Input, {
18
+ type: "number",
19
+ fluid: true,
20
+ transparent: true,
21
+ ...inputProps,
22
+ value,
23
+ onChange: (ev, v) => {
24
+ setValue(v.value);
25
+ },
26
+ onBlur: () => {
27
+ updateData(index, id, parseFloat(value || "0"));
28
+ },
29
+ onKeyDown: (event) => addRowOnTab(event, parseFloat(value), props, addRowOnTabIf)
30
+ });
31
+ };
32
+ }
33
+
34
+ export { NumberEditCell };
35
+ //# sourceMappingURL=NumberEditCell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NumberEditCell.js","sources":["../../../../src/inputs/TableInput/NumberEditCell.tsx"],"sourcesContent":["import debug from 'debug';\nimport {useState} from 'react';\nimport {Input, type 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.NumberEditCell');\n\ninterface NumberEditCellOptions<D extends Record<number, 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, number>;\n}\n\nexport function NumberEditCell<D extends Record<number, unknown>>(options?: NumberEditCellOptions<D>) {\n\tconst {inputProps, addRowOnTabIf} = options || {};\n\n\treturn function NumberEditCellFn(props: TableCellProps<D, number>) {\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?.toString());\n\n\t\treturn (\n\t\t\t<Input\n\t\t\t\ttype=\"number\"\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, parseFloat(value || '0'));\n\t\t\t\t}}\n\t\t\t\tonKeyDown={(event: KeyboardEvent) => addRowOnTab(event, parseFloat(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,KAAO,EAAA,QAAA,CAAA,GAAY,QAAS,CAAA,YAAA,EAAc,UAAU,CAAA,CAAA;AAE3D,IAAA,uBACE,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,MACA,IAAK,EAAA,QAAA;AAAA,MACL,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,QAAA,UAAA,CAAW,KAAO,EAAA,EAAA,EAAI,UAAW,CAAA,KAAA,IAAS,GAAG,CAAC,CAAA,CAAA;AAAA,OAC/C;AAAA,MACA,SAAA,EAAW,CAAC,KAAyB,KAAA,WAAA,CAAY,OAAO,UAAW,CAAA,KAAK,CAAG,EAAA,KAAA,EAAO,aAAa,CAAA;AAAA,KAChG,CAAA,CAAA;AAAA,GAEF,CAAA;AACD;;;;"}
@@ -0,0 +1,34 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StringEditCell.js","sources":["../../../../src/inputs/TableInput/StringEditCell.tsx"],"sourcesContent":["import debug from 'debug';\nimport {useState} from 'react';\nimport {Input, type 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;;;;"}
@@ -0,0 +1,79 @@
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
+ if (createRow) {
36
+ arrayHelpers.push(createRow());
37
+ }
38
+ },
39
+ arrayHelpers
40
+ });
41
+ const hasFooter = footerGroups.some((fg) => fg.headers.some((fgh) => fgh.Footer.name !== "emptyRenderer"));
42
+ const footer = hasFooter ? /* @__PURE__ */ React.createElement(Table.Footer, null, footerGroups.map((group) => /* @__PURE__ */ React.createElement(Table.Row, {
43
+ ...{ ...group.getFooterGroupProps(), ...group.getFooterGroupProps(footerRowProps) }
44
+ }, group.headers.map((column) => /* @__PURE__ */ React.createElement(Table.HeaderCell, {
45
+ ...{ ...column.getFooterProps(), ...column.getFooterProps(footerCellProps) }
46
+ }, column.render("Footer")))))) : null;
47
+ return /* @__PURE__ */ React.createElement(Table, {
48
+ ...{ ...getTableProps(), ...getTableProps(tableProps) }
49
+ }, /* @__PURE__ */ React.createElement(Table.Header, null, headerGroups.map((headerGroup) => /* @__PURE__ */ React.createElement(Table.Row, {
50
+ ...{ ...headerGroup.getHeaderGroupProps(), ...headerGroup.getHeaderGroupProps(headerRowProps) }
51
+ }, headerGroup.headers.map((column) => /* @__PURE__ */ React.createElement(Table.HeaderCell, {
52
+ ...{ ...column.getHeaderProps(), ...column.getHeaderProps(headerCellProps) }
53
+ }, column.render("Header")))))), /* @__PURE__ */ React.createElement(Table.Body, {
54
+ ...{ ...getTableBodyProps(), ...getTableBodyProps(bodyProps) }
55
+ }, rows.map((row) => {
56
+ prepareRow(row);
57
+ return /* @__PURE__ */ React.createElement(Table.Row, {
58
+ ...{ ...row.getRowProps(), ...row.getRowProps(rowProps) },
59
+ onMouseEnter: () => setHoverRow(row.id),
60
+ onMouseLeave: () => setHoverRow(""),
61
+ key: row.getRowProps().key
62
+ }, row.cells.map((cell) => /* @__PURE__ */ React.createElement(Table.Cell, {
63
+ ...{ ...cell.getCellProps(), ...cell.getCellProps(cellProps) },
64
+ key: cell.getCellProps().key
65
+ }, 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, {
72
+ arrayHelpers,
73
+ ...props
74
+ })
75
+ });
76
+ }
77
+
78
+ export { TableInput };
79
+ //# sourceMappingURL=TableInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableInput.js","sources":["../../../../src/inputs/TableInput/TableInput.tsx"],"sourcesContent":["import debug from 'debug';\nimport {FieldArray, type FieldArrayRenderProps} from 'formik';\nimport {useMemo, useState} from 'react';\nimport {\n\ttype CellPropGetter,\n\ttype CellProps,\n\ttype Column,\n\ttype FooterGroupPropGetter,\n\ttype FooterPropGetter,\n\ttype HeaderGroupPropGetter,\n\ttype HeaderPropGetter,\n\ttype RowPropGetter,\n\ttype TableBodyPropGetter,\n\tuseTable,\n} from 'react-table';\nimport {Table, type TableProps} from 'semantic-ui-react';\n\nconst d = debug('thx.controls.inputs.TableInput');\n\ntype DefaultTableType = Record<string, unknown>;\n\ninterface TableInputProps<A extends DefaultTableType> {\n\tname: string;\n\tvalues: A[];\n\tcolumns: Column<A>[];\n\tsetFieldValue: (field: string, value: any, shouldValidate?: boolean | undefined) => void;\n\tcreateRow?: () => A;\n\ttableProps?: TableProps;\n\theaderRowProps?: HeaderGroupPropGetter<A>;\n\theaderCellProps?: HeaderPropGetter<A>;\n\tfooterRowProps?: FooterGroupPropGetter<A>;\n\tfooterCellProps?: FooterPropGetter<A>;\n\tbodyProps?: TableBodyPropGetter<A>;\n\trowProps?: RowPropGetter<A>;\n\tcellProps?: CellPropGetter<A>;\n}\n\ninterface TableInputTableProps<A extends DefaultTableType> extends TableInputProps<A> {\n\tarrayHelpers: FieldArrayRenderProps;\n}\n\nexport interface TableCellProps<D extends DefaultTableType, V = any> extends CellProps<D, V> {\n\tarrayHelpers: FieldArrayRenderProps;\n\taddRow: () => void;\n\tupdateData: (index: number, id: string, value: V) => void;\n\thoverRow: string | number;\n}\n\nfunction TableInputTable<A extends DefaultTableType>(props: TableInputTableProps<A>) {\n\tconst {\n\t\tname,\n\t\tcolumns,\n\t\tvalues,\n\t\tarrayHelpers,\n\t\tsetFieldValue,\n\t\tcreateRow,\n\t\ttableProps,\n\t\theaderRowProps,\n\t\theaderCellProps,\n\t\tbodyProps,\n\t\trowProps,\n\t\tcellProps,\n\t\tfooterCellProps,\n\t\tfooterRowProps,\n\t} = props;\n\tconst cols = useMemo(() => columns, [columns]);\n\tconst vals = useMemo(() => values, [values]);\n\tconst [hoverRow, setHoverRow] = useState('');\n\n\t// React-Table hook\n\tconst {getTableProps, getTableBodyProps, headerGroups, prepareRow, rows, footerGroups} = useTable<A>({\n\t\tcolumns: cols,\n\t\tdata: vals,\n\t\t// @ts-ignore\n\t\tupdateData(rowIndex, columnId, value) {\n\t\t\tsetFieldValue(`${name}[${rowIndex}].${columnId}`, value);\n\t\t},\n\t\taddRow() {\n\t\t\tif (createRow) {\n\t\t\t\tarrayHelpers.push(createRow());\n\t\t\t}\n\t\t},\n\t\tarrayHelpers,\n\t});\n\n\t// @ts-ignore Check for the existence of a Footer that is not the default emptyRenderer()\n\tconst hasFooter = footerGroups.some(fg => fg.headers.some(fgh => fgh.Footer.name !== 'emptyRenderer'));\n\n\t// Build Footer if any footer renderers exist\n\tconst footer = hasFooter ? (\n\t\t<Table.Footer>\n\t\t\t{footerGroups.map(group => (\n\t\t\t\t// eslint-disable-next-line react/jsx-key\n\t\t\t\t<Table.Row {...{...group.getFooterGroupProps(), ...group.getFooterGroupProps(footerRowProps)}}>\n\t\t\t\t\t{group.headers.map(column => (\n\t\t\t\t\t\t// eslint-disable-next-line react/jsx-key\n\t\t\t\t\t\t<Table.HeaderCell {...{...column.getFooterProps(), ...column.getFooterProps(footerCellProps)}}>\n\t\t\t\t\t\t\t{column.render('Footer')}\n\t\t\t\t\t\t</Table.HeaderCell>\n\t\t\t\t\t))}\n\t\t\t\t</Table.Row>\n\t\t\t))}\n\t\t</Table.Footer>\n\t) : null;\n\n\treturn (\n\t\t<Table {...{...getTableProps(), ...getTableProps(tableProps)}}>\n\t\t\t<Table.Header>\n\t\t\t\t{headerGroups.map(headerGroup => (\n\t\t\t\t\t// eslint-disable-next-line react/jsx-key\n\t\t\t\t\t<Table.Row {...{...headerGroup.getHeaderGroupProps(), ...headerGroup.getHeaderGroupProps(headerRowProps)}}>\n\t\t\t\t\t\t{headerGroup.headers.map(column => (\n\t\t\t\t\t\t\t// eslint-disable-next-line react/jsx-key\n\t\t\t\t\t\t\t<Table.HeaderCell {...{...column.getHeaderProps(), ...column.getHeaderProps(headerCellProps)}}>\n\t\t\t\t\t\t\t\t{column.render('Header')}\n\t\t\t\t\t\t\t</Table.HeaderCell>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</Table.Row>\n\t\t\t\t))}\n\t\t\t</Table.Header>\n\t\t\t<Table.Body {...{...getTableBodyProps(), ...getTableBodyProps(bodyProps)}}>\n\t\t\t\t{rows.map(row => {\n\t\t\t\t\tprepareRow(row);\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Table.Row\n\t\t\t\t\t\t\t{...{...row.getRowProps(), ...row.getRowProps(rowProps)}}\n\t\t\t\t\t\t\tonMouseEnter={() => setHoverRow(row.id)}\n\t\t\t\t\t\t\tonMouseLeave={() => setHoverRow('')}\n\t\t\t\t\t\t\tkey={row.getRowProps().key}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{row.cells.map(cell => (\n\t\t\t\t\t\t\t\t<Table.Cell {...{...cell.getCellProps(), ...cell.getCellProps(cellProps)}} key={cell.getCellProps().key}>\n\t\t\t\t\t\t\t\t\t{cell.render('Cell', {hoverRow})}\n\t\t\t\t\t\t\t\t</Table.Cell>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</Table.Row>\n\t\t\t\t\t);\n\t\t\t\t})}\n\t\t\t</Table.Body>\n\t\t\t{footer}\n\t\t</Table>\n\t);\n}\n\n/**\n * Can be used in a TForm as a Table Input.\n * @param props\n * @constructor\n */\nexport function TableInput<A extends DefaultTableType>(props: TableInputProps<A>) {\n\treturn <FieldArray name={props.name} render={arrayHelpers => <TableInputTable arrayHelpers={arrayHelpers} {...props} />} />;\n}\n"],"names":[],"mappings":";;;;;;AAiBU,MAAM,gCAAgC,EAAA;AA+BhD,SAAA,eAAA,CAAqD,KAAgC,EAAA;AACpF,EAAM,MAAA;AAAA,IACL,IAAA;AAAA,IACA,OAAA;AAAA,IACA,MAAA;AAAA,IACA,YAAA;AAAA,IACA,aAAA;AAAA,IACA,SAAA;AAAA,IACA,UAAA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RowOnTab(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 };
13
+ //# sourceMappingURL=addRowOnTab.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addRowOnTab.js","sources":["../../../../src/inputs/TableInput/addRowOnTab.ts"],"sourcesContent":["import type {TableCellProps} from './TableInput';\n\nexport type AddRowOnTabIf<D extends Record<string, unknown>, V = any> = (props: TableCellProps<D, V>, newValue: V) => boolean;\n\n/**\n * Use as an onKeyDown event handler to add a new row when tab is pressed, depending on certain criteria.\n * @param event\n * @param value\n * @param props\n * @param addRowOnTabIf\n */\nexport function addRowOnTab<D extends Record<string, unknown>, V = any>(\n\tevent: KeyboardEvent,\n\tvalue: V,\n\tprops: TableCellProps<D, V>,\n\taddRowOnTabIf?: AddRowOnTabIf<D, V>,\n) {\n\tconst {\n\t\trow: {index: rowIndex},\n\t\trows: {length: rowsLength},\n\t\taddRow,\n\t} = props;\n\n\tif (event.key === 'Tab' && !event.shiftKey && rowIndex + 1 === rowsLength && (addRowOnTabIf ? addRowOnTabIf(props, value) : false)) {\n\t\taddRow();\n\t}\n}\n"],"names":[],"mappings":"AAYC,SAAA,WAAA,CAAA,KAAA,EACA,KACA,EAAA,KAAA,EACA,aACC,EAAA;AACD,EAAM,MAAA;AAAA,IACL,GAAA,EAAK,EAAC,KAAO,EAAA,QAAA,EAAA;AAAA,IACb,IAAA,EAAM,EAAC,MAAQ,EAAA,UAAA,EAAA;AAAA,IACf,MAAA;AAAA,GACG,GAAA,KAAA,CAAA;AAEJ,EAAA,IAAI,KAAM,CAAA,GAAA,KAAQ,KAAS,IAAA,CAAC,MAAM,QAAY,IAAA,QAAA,GAAW,CAAM,KAAA,UAAA,KAA+B,aAAA,GAAA,aAAA,CAAc,KAAO,EAAA,KAAK,IAAI,KAAQ,CAAA,EAAA;AACnI,IAAO,MAAA,EAAA,CAAA;AAAA,GACR;AACD;;;;"}
@@ -0,0 +1,51 @@
1
+ import React, { useCallback } from 'react';
2
+ import { toMoney } from '@thx/money';
3
+ import debug from 'debug';
4
+ import Money from 'js-money';
5
+ import { Input, Label, Dropdown } from 'semantic-ui-react';
6
+ import { useMoneyInput } from '../useMoneyInput.js';
7
+
8
+ const d = debug("thx.controls.money.MoneyCurrencyInput");
9
+ function MoneyCurrencyInput(props) {
10
+ const { name, onBlur, prefix, defaultCurrency, onChange, showPrefix, value, wholeNumber, currencies, locked, ...rest } = props;
11
+ const options = currencies || [
12
+ { key: "CAD", text: "CAD", value: "CAD" },
13
+ { key: "USD", text: "USD", value: "USD" }
14
+ ];
15
+ const handleChange = useCallback((v) => {
16
+ if (!v) {
17
+ onChange && onChange(toMoney(0, defaultCurrency));
18
+ } else {
19
+ onChange && onChange(v);
20
+ }
21
+ }, [defaultCurrency, onChange]);
22
+ const val = !(value instanceof Money) && value !== void 0 ? toMoney(value) : value;
23
+ const [inputElement] = useMoneyInput({ onChange: handleChange, prefix, showPrefix, value: val, wholeNumber });
24
+ const handleDropdownChange = useCallback((e, v) => {
25
+ const newCurrencyCode = v.value;
26
+ const newMoney = new Money(value?.amount || 0, newCurrencyCode);
27
+ d("Change", value, newCurrencyCode, newMoney);
28
+ onChange && onChange(newMoney);
29
+ }, [onChange, value]);
30
+ const currencyCode = value?.currency || defaultCurrency?.code || "CAD";
31
+ d("Render", value, currencyCode);
32
+ return /* @__PURE__ */ React.createElement(Input, {
33
+ ...rest,
34
+ labelPosition: "right"
35
+ }, /* @__PURE__ */ React.createElement("input", {
36
+ name,
37
+ ref: inputElement,
38
+ onBlur,
39
+ readOnly: locked
40
+ }), /* @__PURE__ */ React.createElement(Label, {
41
+ basic: true
42
+ }, /* @__PURE__ */ React.createElement(Dropdown, {
43
+ disabled: locked,
44
+ options,
45
+ value: currencyCode,
46
+ onChange: handleDropdownChange
47
+ })));
48
+ }
49
+
50
+ export { MoneyCurrencyInput };
51
+ //# sourceMappingURL=MoneyCurrencyInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MoneyCurrencyInput.js","sources":["../../../../src/money/MoneyCurrencyInput/MoneyCurrencyInput.tsx"],"sourcesContent":["import {toMoney} from '@thx/money';\n/* eslint-disable jsx-a11y/no-static-element-interactions */\nimport debug from 'debug';\nimport Money, {type CurrencyString} from 'js-money';\nimport {type SyntheticEvent, useCallback} from 'react';\nimport {Dropdown, type DropdownProps, Input, type InputProps, Label} from 'semantic-ui-react';\nimport type {MoneyInputProps} from '../MoneyInput';\nimport {useMoneyInput} from '../useMoneyInput';\n\nconst d = debug('thx.controls.money.MoneyCurrencyInput');\n\nexport interface MoneyCurrencyInputProps extends MoneyInputProps {\n\tcurrencies?: {key: string; value: string; text: string}[];\n}\n\nexport function MoneyCurrencyInput(props: MoneyCurrencyInputProps & Omit<InputProps, 'onChange'>) {\n\tconst {name, onBlur, prefix, defaultCurrency, onChange, showPrefix, value, wholeNumber, currencies, locked, ...rest} = props;\n\n\tconst options = currencies || [\n\t\t{key: 'CAD', text: 'CAD', value: 'CAD'},\n\t\t{key: 'USD', text: 'USD', value: 'USD'},\n\t];\n\n\tconst handleChange = useCallback(\n\t\t(v?: Money) => {\n\t\t\tif (!v) {\n\t\t\t\tonChange && onChange(toMoney(0, defaultCurrency));\n\t\t\t} else {\n\t\t\t\tonChange && onChange(v);\n\t\t\t}\n\t\t},\n\t\t[defaultCurrency, onChange],\n\t);\n\n\tconst val = !(value instanceof Money) && value !== undefined ? toMoney(value) : value;\n\n\tconst [inputElement] = useMoneyInput({onChange: handleChange, prefix, showPrefix, value: val, wholeNumber});\n\n\tconst handleDropdownChange = useCallback(\n\t\t(e: SyntheticEvent<HTMLElement, Event>, v: DropdownProps) => {\n\t\t\tconst newCurrencyCode = v.value as CurrencyString;\n\t\t\tconst newMoney = new Money(value?.amount || 0, newCurrencyCode);\n\n\t\t\td('Change', value, newCurrencyCode, newMoney);\n\t\t\t// setInputValue(newMoney);\n\t\t\tonChange && onChange(newMoney);\n\t\t\t// forceUpdate();\n\t\t},\n\t\t[onChange, value],\n\t);\n\n\tconst currencyCode = value?.currency || defaultCurrency?.code || 'CAD';\n\td('Render', value, currencyCode);\n\n\treturn (\n\t\t<Input {...rest} labelPosition=\"right\">\n\t\t\t<input name={name} ref={inputElement} onBlur={onBlur} readOnly={locked} />\n\t\t\t<Label basic>\n\t\t\t\t<Dropdown disabled={locked} options={options} value={currencyCode} onChange={handleDropdownChange} />\n\t\t\t</Label>\n\t\t</Input>\n\t);\n}\n"],"names":[],"mappings":";;;;;;;AASA,MAAM,CAAA,GAAI,MAAM,uCAAuC,CAAA,CAAA;AAMhD,SAAA,kBAAA,CAA4B,KAA+D,EAAA;AACjG,EAAM,MAAA,EAAC,IAAM,EAAA,MAAA,EAAQ,MAAQ,EAAA,eAAA,EAAiB,QAAU,EAAA,UAAA,EAAY,KAAO,EAAA,WAAA,EAAa,UAAY,EAAA,MAAA,EAAA,GAAW,IAAQ,EAAA,GAAA,KAAA,CAAA;AAEvH,EAAA,MAAM,UAAU,UAAc,IAAA;AAAA,IAC7B,EAAC,GAAK,EAAA,KAAA,EAAO,IAAM,EAAA,KAAA,EAAO,OAAO,KAAK,EAAA;AAAA,IACtC,EAAC,GAAK,EAAA,KAAA,EAAO,IAAM,EAAA,KAAA,EAAO,OAAO,KAAK,EAAA;AAAA,GACvC,CAAA;AAEA,EAAM,MAAA,YAAA,GAAe,WACpB,CAAA,CAAC,CAAc,KAAA;AACd,IAAA,IAAI,CAAC,CAAG,EAAA;AACP,MAAA,QAAA,IAAY,QAAS,CAAA,OAAA,CAAQ,CAAG,EAAA,eAAe,CAAC,CAAA,CAAA;AAAA,KAC1C,MAAA;AACN,MAAA,QAAA,IAAY,SAAS,CAAC,CAAA,CAAA;AAAA,KACvB;AAAA,GAED,EAA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