@powerhousedao/contributor-billing 0.0.13 → 0.0.14

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 (164) hide show
  1. package/dist/document-models/billing-statement/gen/actions.d.ts +8 -0
  2. package/dist/document-models/billing-statement/gen/actions.d.ts.map +1 -0
  3. package/dist/document-models/billing-statement/gen/actions.js +3 -0
  4. package/dist/document-models/billing-statement/gen/creators.d.ts +4 -0
  5. package/dist/document-models/billing-statement/gen/creators.d.ts.map +1 -0
  6. package/dist/document-models/billing-statement/gen/creators.js +3 -0
  7. package/dist/document-models/billing-statement/gen/document-model.d.ts +3 -0
  8. package/dist/document-models/billing-statement/gen/document-model.d.ts.map +1 -0
  9. package/dist/document-models/billing-statement/gen/document-model.js +117 -0
  10. package/dist/document-models/billing-statement/gen/general/actions.d.ts +7 -0
  11. package/dist/document-models/billing-statement/gen/general/actions.d.ts.map +1 -0
  12. package/dist/document-models/billing-statement/gen/general/actions.js +1 -0
  13. package/dist/document-models/billing-statement/gen/general/creators.d.ts +6 -0
  14. package/dist/document-models/billing-statement/gen/general/creators.d.ts.map +1 -0
  15. package/dist/document-models/billing-statement/gen/general/creators.js +5 -0
  16. package/dist/document-models/billing-statement/gen/general/error.d.ts +2 -0
  17. package/dist/document-models/billing-statement/gen/general/error.d.ts.map +1 -0
  18. package/dist/document-models/billing-statement/gen/general/error.js +1 -0
  19. package/dist/document-models/billing-statement/gen/general/object.d.ts +9 -0
  20. package/dist/document-models/billing-statement/gen/general/object.d.ts.map +1 -0
  21. package/dist/document-models/billing-statement/gen/general/object.js +13 -0
  22. package/dist/document-models/billing-statement/gen/general/operations.d.ts +9 -0
  23. package/dist/document-models/billing-statement/gen/general/operations.d.ts.map +1 -0
  24. package/dist/document-models/billing-statement/gen/general/operations.js +1 -0
  25. package/dist/document-models/billing-statement/gen/index.d.ts +6 -0
  26. package/dist/document-models/billing-statement/gen/index.d.ts.map +1 -0
  27. package/dist/document-models/billing-statement/gen/index.js +5 -0
  28. package/dist/document-models/billing-statement/gen/line-items/actions.d.ts +6 -0
  29. package/dist/document-models/billing-statement/gen/line-items/actions.d.ts.map +1 -0
  30. package/dist/document-models/billing-statement/gen/line-items/actions.js +1 -0
  31. package/dist/document-models/billing-statement/gen/line-items/creators.d.ts +5 -0
  32. package/dist/document-models/billing-statement/gen/line-items/creators.d.ts.map +1 -0
  33. package/dist/document-models/billing-statement/gen/line-items/creators.js +4 -0
  34. package/dist/document-models/billing-statement/gen/line-items/error.d.ts +2 -0
  35. package/dist/document-models/billing-statement/gen/line-items/error.d.ts.map +1 -0
  36. package/dist/document-models/billing-statement/gen/line-items/error.js +1 -0
  37. package/dist/document-models/billing-statement/gen/line-items/object.d.ts +8 -0
  38. package/dist/document-models/billing-statement/gen/line-items/object.d.ts.map +1 -0
  39. package/dist/document-models/billing-statement/gen/line-items/object.js +10 -0
  40. package/dist/document-models/billing-statement/gen/line-items/operations.d.ts +8 -0
  41. package/dist/document-models/billing-statement/gen/line-items/operations.d.ts.map +1 -0
  42. package/dist/document-models/billing-statement/gen/line-items/operations.js +1 -0
  43. package/dist/document-models/billing-statement/gen/object.d.ts +20 -0
  44. package/dist/document-models/billing-statement/gen/object.d.ts.map +1 -0
  45. package/dist/document-models/billing-statement/gen/object.js +33 -0
  46. package/dist/document-models/billing-statement/gen/reducer.d.ts +3 -0
  47. package/dist/document-models/billing-statement/gen/reducer.d.ts.map +1 -0
  48. package/dist/document-models/billing-statement/gen/reducer.js +39 -0
  49. package/dist/document-models/billing-statement/gen/schema/index.d.ts +3 -0
  50. package/dist/document-models/billing-statement/gen/schema/index.d.ts.map +1 -0
  51. package/dist/document-models/billing-statement/gen/schema/index.js +2 -0
  52. package/dist/document-models/billing-statement/gen/schema/types.d.ts +202 -0
  53. package/dist/document-models/billing-statement/gen/schema/types.d.ts.map +1 -0
  54. package/dist/document-models/billing-statement/gen/schema/types.js +1 -0
  55. package/dist/document-models/billing-statement/gen/schema/zod.d.ts +23 -0
  56. package/dist/document-models/billing-statement/gen/schema/zod.d.ts.map +1 -0
  57. package/dist/document-models/billing-statement/gen/schema/zod.js +117 -0
  58. package/dist/document-models/billing-statement/gen/tags/actions.d.ts +5 -0
  59. package/dist/document-models/billing-statement/gen/tags/actions.d.ts.map +1 -0
  60. package/dist/document-models/billing-statement/gen/tags/actions.js +1 -0
  61. package/dist/document-models/billing-statement/gen/tags/creators.d.ts +4 -0
  62. package/dist/document-models/billing-statement/gen/tags/creators.d.ts.map +1 -0
  63. package/dist/document-models/billing-statement/gen/tags/creators.js +3 -0
  64. package/dist/document-models/billing-statement/gen/tags/error.d.ts +2 -0
  65. package/dist/document-models/billing-statement/gen/tags/error.d.ts.map +1 -0
  66. package/dist/document-models/billing-statement/gen/tags/error.js +1 -0
  67. package/dist/document-models/billing-statement/gen/tags/object.d.ts +7 -0
  68. package/dist/document-models/billing-statement/gen/tags/object.d.ts.map +1 -0
  69. package/dist/document-models/billing-statement/gen/tags/object.js +7 -0
  70. package/dist/document-models/billing-statement/gen/tags/operations.d.ts +7 -0
  71. package/dist/document-models/billing-statement/gen/tags/operations.d.ts.map +1 -0
  72. package/dist/document-models/billing-statement/gen/tags/operations.js +1 -0
  73. package/dist/document-models/billing-statement/gen/types.d.ts +10 -0
  74. package/dist/document-models/billing-statement/gen/types.d.ts.map +1 -0
  75. package/dist/document-models/billing-statement/gen/types.js +1 -0
  76. package/dist/document-models/billing-statement/gen/utils.d.ts +7 -0
  77. package/dist/document-models/billing-statement/gen/utils.d.ts.map +1 -0
  78. package/dist/document-models/billing-statement/gen/utils.js +42 -0
  79. package/dist/document-models/billing-statement/index.d.ts +31 -0
  80. package/dist/document-models/billing-statement/index.d.ts.map +1 -0
  81. package/dist/document-models/billing-statement/index.js +21 -0
  82. package/dist/document-models/billing-statement/src/reducers/general.d.ts +8 -0
  83. package/dist/document-models/billing-statement/src/reducers/general.d.ts.map +1 -0
  84. package/dist/document-models/billing-statement/src/reducers/general.js +41 -0
  85. package/dist/document-models/billing-statement/src/reducers/line-items.d.ts +8 -0
  86. package/dist/document-models/billing-statement/src/reducers/line-items.d.ts.map +1 -0
  87. package/dist/document-models/billing-statement/src/reducers/line-items.js +49 -0
  88. package/dist/document-models/billing-statement/src/reducers/tags.d.ts +8 -0
  89. package/dist/document-models/billing-statement/src/reducers/tags.d.ts.map +1 -0
  90. package/dist/document-models/billing-statement/src/reducers/tags.js +36 -0
  91. package/dist/document-models/billing-statement/src/tests/document-model.test.d.ts +6 -0
  92. package/dist/document-models/billing-statement/src/tests/document-model.test.d.ts.map +1 -0
  93. package/dist/document-models/billing-statement/src/tests/document-model.test.js +17 -0
  94. package/dist/document-models/billing-statement/src/tests/general.test.d.ts +5 -0
  95. package/dist/document-models/billing-statement/src/tests/general.test.d.ts.map +1 -0
  96. package/dist/document-models/billing-statement/src/tests/general.test.js +93 -0
  97. package/dist/document-models/billing-statement/src/tests/line-items.test.d.ts +6 -0
  98. package/dist/document-models/billing-statement/src/tests/line-items.test.d.ts.map +1 -0
  99. package/dist/document-models/billing-statement/src/tests/line-items.test.js +131 -0
  100. package/dist/document-models/billing-statement/src/tests/tags.test.d.ts +6 -0
  101. package/dist/document-models/billing-statement/src/tests/tags.test.d.ts.map +1 -0
  102. package/dist/document-models/billing-statement/src/tests/tags.test.js +52 -0
  103. package/dist/document-models/billing-statement/src/utils.d.ts +2 -0
  104. package/dist/document-models/billing-statement/src/utils.d.ts.map +1 -0
  105. package/dist/document-models/billing-statement/src/utils.js +1 -0
  106. package/dist/document-models/index.d.ts +1 -0
  107. package/dist/document-models/index.d.ts.map +1 -1
  108. package/dist/document-models/index.js +1 -0
  109. package/dist/editors/billing-statement/components/lineItems.d.ts +3 -0
  110. package/dist/editors/billing-statement/components/lineItems.d.ts.map +1 -0
  111. package/dist/editors/billing-statement/components/lineItems.js +24 -0
  112. package/dist/editors/billing-statement/components/lineItemsTable.d.ts +6 -0
  113. package/dist/editors/billing-statement/components/lineItemsTable.d.ts.map +1 -0
  114. package/dist/editors/billing-statement/components/lineItemsTable.js +116 -0
  115. package/dist/editors/billing-statement/components/objectSetTable.d.ts +6 -0
  116. package/dist/editors/billing-statement/components/objectSetTable.d.ts.map +1 -0
  117. package/dist/editors/billing-statement/components/objectSetTable.js +96 -0
  118. package/dist/editors/billing-statement/editor.d.ts +5 -0
  119. package/dist/editors/billing-statement/editor.d.ts.map +1 -0
  120. package/dist/editors/billing-statement/editor.js +23 -0
  121. package/dist/editors/billing-statement/index.d.ts +5 -0
  122. package/dist/editors/billing-statement/index.d.ts.map +1 -0
  123. package/dist/editors/billing-statement/index.js +12 -0
  124. package/dist/editors/billing-statement/lineItemTags/lineItemTags.d.ts +16 -0
  125. package/dist/editors/billing-statement/lineItemTags/lineItemTags.d.ts.map +1 -0
  126. package/dist/editors/billing-statement/lineItemTags/lineItemTags.js +58 -0
  127. package/dist/editors/billing-statement/lineItemTags/tagMapping.d.ts +4 -0
  128. package/dist/editors/billing-statement/lineItemTags/tagMapping.d.ts.map +1 -0
  129. package/dist/editors/billing-statement/lineItemTags/tagMapping.js +44 -0
  130. package/dist/editors/contributor-billing/editor.js +1 -1
  131. package/dist/editors/index.d.ts +1 -0
  132. package/dist/editors/index.d.ts.map +1 -1
  133. package/dist/editors/index.js +1 -0
  134. package/dist/editors/invoice/components/currencyForm.d.ts.map +1 -1
  135. package/dist/editors/invoice/components/currencyForm.js +2 -4
  136. package/dist/editors/invoice/components/datePicker.d.ts.map +1 -1
  137. package/dist/editors/invoice/components/datePicker.js +2 -2
  138. package/dist/editors/invoice/components/inputField.d.ts.map +1 -1
  139. package/dist/editors/invoice/components/inputField.js +1 -3
  140. package/dist/editors/invoice/components/numberForm.d.ts +2 -1
  141. package/dist/editors/invoice/components/numberForm.d.ts.map +1 -1
  142. package/dist/editors/invoice/components/numberForm.js +2 -2
  143. package/dist/editors/invoice/editor.d.ts.map +1 -1
  144. package/dist/editors/invoice/editor.js +38 -33
  145. package/dist/editors/invoice/lineItems.d.ts +1 -1
  146. package/dist/editors/invoice/lineItems.d.ts.map +1 -1
  147. package/dist/editors/invoice/lineItems.js +21 -12
  148. package/dist/index.d.ts +2 -2
  149. package/dist/index.d.ts.map +1 -1
  150. package/dist/powerhouse.manifest.json +10 -1
  151. package/dist/style.css +102 -2
  152. package/dist/subgraphs/billing-statement/index.d.ts +10 -0
  153. package/dist/subgraphs/billing-statement/index.d.ts.map +1 -0
  154. package/dist/subgraphs/billing-statement/index.js +11 -0
  155. package/dist/subgraphs/billing-statement/resolvers.d.ts +3 -0
  156. package/dist/subgraphs/billing-statement/resolvers.d.ts.map +1 -0
  157. package/dist/subgraphs/billing-statement/resolvers.js +110 -0
  158. package/dist/subgraphs/billing-statement/schema.d.ts +3 -0
  159. package/dist/subgraphs/billing-statement/schema.d.ts.map +1 -0
  160. package/dist/subgraphs/billing-statement/schema.js +165 -0
  161. package/dist/subgraphs/index.d.ts +1 -0
  162. package/dist/subgraphs/index.d.ts.map +1 -1
  163. package/dist/subgraphs/index.js +1 -0
  164. package/package.json +4 -4
@@ -0,0 +1,6 @@
1
+ declare const ObjectSetTableComponent: (props: {
2
+ state: any;
3
+ dispatch: any;
4
+ }) => import("react/jsx-runtime").JSX.Element;
5
+ export default ObjectSetTableComponent;
6
+ //# sourceMappingURL=objectSetTable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"objectSetTable.d.ts","sourceRoot":"","sources":["../../../../editors/billing-statement/components/objectSetTable.tsx"],"names":[],"mappings":"AAsBA,QAAA,MAAM,uBAAuB,GAAI,OAAO;IAAE,KAAK,EAAE,GAAG,CAAC;IAAC,QAAQ,EAAE,GAAG,CAAA;CAAE,4CA+JpE,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
@@ -0,0 +1,96 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Tag } from "lucide-react";
3
+ import { ObjectSetTable, Select } from "@powerhousedao/document-engineering";
4
+ import { useMemo, useRef } from "react";
5
+ const ObjectSetTableComponent = (props) => {
6
+ const { state, dispatch } = props;
7
+ const tableApiRef = useRef(null);
8
+ // console.log("lineItems", state.lineItems);
9
+ const units = [
10
+ { label: "Minute", value: "Minute" },
11
+ { label: "Hour", value: "Hour" },
12
+ { label: "Day", value: "Day" },
13
+ { label: "Unit", value: "Unit" },
14
+ ];
15
+ const columns = useMemo(() => [
16
+ {
17
+ field: "description",
18
+ title: "Description",
19
+ editable: true,
20
+ type: "text",
21
+ onSave: (newValue, context) => {
22
+ console.log({ newValue, context });
23
+ console.log("id", context.row.id);
24
+ // dispatch(actions.editLineItem(
25
+ // id
26
+ // ))
27
+ },
28
+ // renderCell: (row: any, context: CellContext<any>) => {
29
+ // console.log("row", row);
30
+ // },
31
+ },
32
+ {
33
+ field: "unit",
34
+ title: "Unit",
35
+ editable: true,
36
+ type: "text",
37
+ renderCell: (row, context) => {
38
+ // let isEditingCell = context.tableConfig.apiRef?.current?.isEditing();
39
+ // if (isEditingCell) {
40
+ return (_jsx(Select, { options: units, value: units[0].value, onBlur: () => {
41
+ // context.tableConfig.apiRef?.current?.exitCellEditMode();
42
+ }, onChange: (value) => {
43
+ // isEditingCell = false
44
+ } }));
45
+ // } else {
46
+ return _jsx("div", { children: units[0].value });
47
+ // }
48
+ },
49
+ },
50
+ { field: "quantity", title: "Quantity", editable: true, type: "number" },
51
+ {
52
+ field: "unitPriceCash",
53
+ title: "Fiat/Unit",
54
+ editable: true,
55
+ type: "number",
56
+ },
57
+ {
58
+ field: "unitPricePwt",
59
+ title: "POWT/Unit",
60
+ editable: true,
61
+ type: "number",
62
+ },
63
+ {
64
+ field: "totalPriceCash",
65
+ title: "Total Fiat",
66
+ editable: false,
67
+ type: "number",
68
+ },
69
+ {
70
+ field: "totalPricePwt",
71
+ title: "Total POWT",
72
+ editable: false,
73
+ type: "number",
74
+ },
75
+ ], []);
76
+ const data = [
77
+ {
78
+ id: 1,
79
+ description: "some description",
80
+ unit: units[0],
81
+ quantity: 1,
82
+ unitPriceCash: 1,
83
+ unitPricePwt: 1,
84
+ totalPriceCash: 1,
85
+ totalPricePwt: 1,
86
+ },
87
+ ];
88
+ return (_jsxs("div", { className: "mt-6", children: [_jsxs("div", { className: "flex justify-between", children: [_jsx("div", { className: "flex items-center", children: _jsx("h1", { className: "text-1xl font-bold px-2", children: "Line Items" }) }), _jsx("div", { className: "flex items-center", children: _jsx(Tag, { onClick: () => { }, style: {
89
+ cursor: "pointer",
90
+ width: 28,
91
+ height: 28,
92
+ color: "white",
93
+ fill: "#475264",
94
+ } }) })] }), _jsx("div", {}), _jsx("div", { className: "mt-4", children: _jsx(ObjectSetTable, { columns: columns, data: state.lineItems, apiRef: tableApiRef }, state.lineItems.length) })] }));
95
+ };
96
+ export default ObjectSetTableComponent;
@@ -0,0 +1,5 @@
1
+ import type { EditorProps } from "document-model";
2
+ import { type BillingStatementDocument } from "../../document-models/billing-statement/index.js";
3
+ export type IProps = EditorProps<BillingStatementDocument>;
4
+ export default function Editor(props: IProps): import("react/jsx-runtime").JSX.Element;
5
+ //# sourceMappingURL=editor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../editors/billing-statement/editor.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EACL,KAAK,wBAAwB,EAE9B,MAAM,kDAAkD,CAAC;AAQ1D,MAAM,MAAM,MAAM,GAAG,WAAW,CAAC,wBAAwB,CAAC,CAAC;AAE3D,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAK,EAAE,MAAM,2CAyG3C"}
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { actions, } from "../../document-models/billing-statement/index.js";
4
+ import { CurrencyForm } from "../invoice/components/currencyForm.js";
5
+ import { Textarea } from "@powerhousedao/document-engineering";
6
+ import LineItemsTable from "./components/lineItemsTable.js";
7
+ import { formatNumber } from "../invoice/lineItems.js";
8
+ export default function Editor(props) {
9
+ const { document: doc, dispatch } = props;
10
+ const state = doc.state.global;
11
+ // console.log("global state", state);
12
+ const [notes, setNotes] = useState(state.notes ?? "");
13
+ return (_jsxs("div", { className: "editor-container", children: [_jsxs("div", { className: "grid grid-cols-2 gap-2 border border-gray-500 p-2 rounded-md bg-gray-1001", children: [_jsx("div", { className: "col-span-1 flex items-center", children: _jsx("h1", { className: "text-xl md:text-2xl font-bold", children: "Billing Statement" }) }), _jsxs("div", { className: "grid col-span-1 grid-rows-2 gap-2 justify-end ", children: [_jsxs("div", { className: "col-span-1 space-x-2", children: [_jsx("span", { children: "Submitter" }), _jsx("span", { children: state.contributor })] }), _jsxs("div", { className: "col-span-1 space-x-2", children: [_jsx("span", { children: "Status" }), _jsx("span", { children: state.status })] })] })] }), _jsx("div", { className: "mt-6 p-2", children: _jsxs("div", { className: "flex justify-end", children: [_jsx("span", { className: "mr-2 pt-2", children: "Currency: " }), _jsx(CurrencyForm, { currency: props.document.state.global.currency, handleInputChange: (e) => {
14
+ dispatch(actions.editBillingStatement({ currency: e.target.value }));
15
+ } })] }) }), _jsx("div", { className: "", children: _jsx(LineItemsTable, { state: state, dispatch: dispatch }) }), _jsxs("div", { className: "grid grid-cols-2 gap-2", children: [_jsx("div", { className: "mt-6 p-2 col-span-1", children: _jsx(Textarea, { label: "Notes", placeholder: "Add notes", autoExpand: false, rows: 4, multiline: true, value: notes, onBlur: (e) => {
16
+ const newValue = e.target.value;
17
+ if (newValue !== state.notes) {
18
+ dispatch(actions.editBillingStatement({ notes: newValue }));
19
+ }
20
+ }, onChange: (e) => {
21
+ setNotes(e.target.value);
22
+ }, className: "p-2 mb-4" }) }), _jsx("div", { className: "mt-6 p-2 col-span-1 flex justify-center items-center", children: _jsxs("table", { className: "border border-gray-300", children: [_jsx("thead", { children: _jsxs("tr", { className: "bg-gray-100", children: [_jsx("th", { className: "border px-4 py-2", children: "Total Fiat" }), _jsx("th", { className: "border px-4 py-2", children: "Total POW" })] }) }), _jsx("tbody", { children: _jsxs("tr", { children: [_jsx("td", { className: "border px-4 py-2 text-center", children: formatNumber(state.totalCash) }), _jsx("td", { className: "border px-4 py-2 text-center", children: formatNumber(state.totalPowt) })] }) })] }) })] })] }));
23
+ }
@@ -0,0 +1,5 @@
1
+ import type { EditorModule } from "document-model";
2
+ import type { BillingStatementDocument } from "../../document-models/billing-statement/index.js";
3
+ export declare const module: EditorModule<BillingStatementDocument>;
4
+ export default module;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../editors/billing-statement/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kDAAkD,CAAC;AAEjG,eAAO,MAAM,MAAM,EAAE,YAAY,CAAC,wBAAwB,CASzD,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -0,0 +1,12 @@
1
+ import Editor from "./editor.js";
2
+ export const module = {
3
+ Component: Editor,
4
+ documentTypes: ["powerhouse/billing-statement"],
5
+ config: {
6
+ id: "powerhouse-billing-statement-editor",
7
+ disableExternalControls: true,
8
+ documentToolbarEnabled: true,
9
+ showSwitchboardLink: true,
10
+ },
11
+ };
12
+ export default module;
@@ -0,0 +1,16 @@
1
+ import { Dispatch } from "react";
2
+ import { BillingStatementTag } from "../../../document-models/billing-statement/index.js";
3
+ interface TagAssignmentRow {
4
+ id: string;
5
+ description: string;
6
+ period: string;
7
+ lineItemTag: BillingStatementTag[];
8
+ }
9
+ interface LineItemTagsTableProps {
10
+ lineItems: TagAssignmentRow[];
11
+ onClose: () => void;
12
+ dispatch: Dispatch<any>;
13
+ }
14
+ export declare function LineItemTagsTable({ lineItems, onClose, dispatch, }: LineItemTagsTableProps): import("react/jsx-runtime").JSX.Element;
15
+ export {};
16
+ //# sourceMappingURL=lineItemTags.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lineItemTags.d.ts","sourceRoot":"","sources":["../../../../editors/billing-statement/lineItemTags/lineItemTags.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAKjC,OAAO,EAEL,mBAAmB,EACpB,MAAM,qDAAqD,CAAC;AAG7D,UAAU,gBAAgB;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,mBAAmB,EAAE,CAAC;CACpC;AAED,UAAU,sBAAsB;IAC9B,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;CACzB;AAED,wBAAgB,iBAAiB,CAAC,EAChC,SAAS,EACT,OAAO,EACP,QAAQ,GACT,EAAE,sBAAsB,2CAyKxB"}
@@ -0,0 +1,58 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { X, Tag } from "lucide-react";
3
+ import { Button } from "@powerhousedao/design-system";
4
+ import { Select, DatePicker } from "@powerhousedao/document-engineering/ui";
5
+ import { budgetOptions, expenseAccountOptions } from "./tagMapping.js";
6
+ import { actions, } from "../../../document-models/billing-statement/index.js";
7
+ import { InputField } from "../../invoice/components/inputField.js";
8
+ export function LineItemTagsTable({ lineItems, onClose, dispatch, }) {
9
+ const handleReset = () => {
10
+ // Resetting all tags to empty values
11
+ lineItems.forEach((item) => {
12
+ item.lineItemTag.forEach((tag) => {
13
+ dispatch(actions.editLineItemTag({
14
+ lineItemId: item.id,
15
+ dimension: tag.dimension,
16
+ value: "",
17
+ label: "",
18
+ }));
19
+ });
20
+ });
21
+ };
22
+ return (_jsxs("div", { className: "w-full", children: [_jsxs("div", { className: "flex items-center justify-between border-b border-gray-200 p-6 bg-white z-10", children: [_jsxs("span", { className: "flex items-center gap-2", children: [_jsx("h2", { className: "text-1xl font-semibold text-gray-900", children: "Assign Tags " }), _jsx(Tag, { style: { width: 28, height: 28, color: "white", fill: "#475264" } })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsxs(Button, { color: "light", size: "small", onClick: handleReset, children: ["Reset", " "] }), _jsx("button", { onClick: onClose, className: "rounded-full p-2 hover:bg-gray-100", children: _jsx(X, { size: 24, className: "text-gray-500" }) })] })] }), _jsx("div", { className: "overflow-x-auto rounded-sm border border-gray-200", children: _jsxs("table", { className: "w-full border-collapse bg-white", children: [_jsx("thead", { className: "bg-gray-50 z-10", children: _jsxs("tr", { children: [_jsx("th", { className: "border-b border-gray-200 p-3 text-center text-sm", children: "Item" }), _jsx("th", { className: "border-b border-gray-200 p-3 text-center text-sm", children: "Period" }), _jsx("th", { className: "border-b border-gray-200 p-3 text-center text-sm", children: "Expense Account" }), _jsx("th", { className: "border-b border-gray-200 p-3 text-center text-sm", children: "Budget" })] }) }), _jsx("tbody", { children: lineItems.map((item) => (_jsxs("tr", { className: "hover:bg-gray-50", children: [_jsx("td", { className: "border-b border-gray-200 p-2", children: _jsx(InputField, { value: item.description, handleInputChange: (e) => { }, onBlur: (e) => {
23
+ dispatch(actions.editLineItem({
24
+ id: item.id,
25
+ description: e.target.value,
26
+ }));
27
+ }, className: "w-full text-xs" }) }), _jsx("td", { className: "border-b border-gray-200 p-2", style: { width: "100px" }, children: _jsx(DatePicker, { name: "period", dateFormat: "YYYY-MM-DD", autoClose: true, placeholder: "Select Period", value: item.lineItemTag.find((tag) => tag.dimension === "accounting-period")?.label || "", onChange: (e) => dispatch(actions.editLineItemTag({
28
+ lineItemId: item.id,
29
+ dimension: "accounting-period",
30
+ value: new Date(e.target.value)
31
+ .toLocaleDateString("en-US", {
32
+ year: "numeric",
33
+ month: "numeric",
34
+ })
35
+ .split("/")
36
+ .reverse()
37
+ .join("/"),
38
+ label: new Date(e.target.value).toLocaleDateString("en-US", {
39
+ month: "long",
40
+ year: "numeric",
41
+ }),
42
+ })), className: "w-full text-xs" }) }), _jsx("td", { className: "border-b border-gray-200 p-2", children: _jsx(Select, { options: expenseAccountOptions, value: item.lineItemTag.find((tag) => tag.dimension === "expense-account")?.label || "", placeholder: "Select Expense Account", searchable: true, onChange: (value) => {
43
+ dispatch(actions.editLineItemTag({
44
+ lineItemId: item.id,
45
+ dimension: "expense-account",
46
+ value: "fusion",
47
+ label: expenseAccountOptions.find((option) => option.value === value)?.label,
48
+ }));
49
+ }, className: "w-full text-xs" }) }), _jsx("td", { className: "border-b border-gray-200 p-2", children: _jsx(Select, { options: budgetOptions, value: item.lineItemTag.find((tag) => tag.dimension === "budget")
50
+ ?.value || "", placeholder: "Select Budget", onChange: (value) => {
51
+ dispatch(actions.editLineItemTag({
52
+ lineItemId: item.id,
53
+ dimension: "budget",
54
+ value: value,
55
+ label: budgetOptions.find((option) => option.value === value)?.label,
56
+ }));
57
+ } }) })] }, item.id))) })] }) })] }));
58
+ }
@@ -0,0 +1,4 @@
1
+ import { SelectOption } from "@powerhousedao/document-engineering/ui";
2
+ export declare const expenseAccountOptions: SelectOption[];
3
+ export declare const budgetOptions: SelectOption[];
4
+ //# sourceMappingURL=tagMapping.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tagMapping.d.ts","sourceRoot":"","sources":["../../../../editors/billing-statement/lineItemTags/tagMapping.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAsCtE,eAAO,MAAM,qBAAqB,EAAE,YAAY,EAK9C,CAAA;AAEF,eAAO,MAAM,aAAa,EAAE,YAAY,EAEvC,CAAA"}
@@ -0,0 +1,44 @@
1
+ const billingTagMapping = [
2
+ { fusion: "Budget", xero: "Revenue" },
3
+ { fusion: "Current Liability", xero: "Current Liability" },
4
+ { fusion: "Interest Income", xero: "Revenue" },
5
+ { fusion: "Travel & Entertainment", xero: "Expense" },
6
+ { fusion: "Cost of Goods Sold", xero: "Direct Costs" },
7
+ { fusion: "Marketing Expense", xero: "Expense" },
8
+ { fusion: "Professional Services", xero: "Expense" },
9
+ { fusion: "Software Development Expense", xero: "Expense" },
10
+ { fusion: "Compensation & Benefits", xero: "Expense" },
11
+ { fusion: "Admin Expense", xero: "Expense" },
12
+ { fusion: "Other Income Expense (Non-operating)", xero: "Bank Revaluations" },
13
+ { fusion: "Other Income", xero: "Unrealized Currency Gains" },
14
+ { fusion: "Other Income", xero: "Realized Currency Gains" },
15
+ { fusion: "Income Tax Expense", xero: "Expense" },
16
+ { fusion: "Current Asset", xero: "Accounts Receivable" },
17
+ { fusion: "Current Asset", xero: "Current Asset" },
18
+ { fusion: "Current Asset", xero: "Inventory" },
19
+ { fusion: "Software Expense", xero: "Expense" },
20
+ { fusion: "Fixed Asset", xero: "Fixed Asset" },
21
+ { fusion: "Non-Current Asset", xero: "Fixed Asset" },
22
+ { fusion: "Current Liability", xero: "Accounts Payable" },
23
+ { fusion: "Gas Expense", xero: "Expense" },
24
+ { fusion: "Current Liability", xero: "Unpaid Expense Claims" },
25
+ { fusion: "Current Liability", xero: "Wages Payable" },
26
+ { fusion: "Current Liability", xero: "Sales Tax" },
27
+ { fusion: "Adjustment A/C", xero: "Historical Adjustment" },
28
+ { fusion: "Temporary Holding Account", xero: "Current Liability" },
29
+ { fusion: "Other", xero: "Rounding" },
30
+ { fusion: "Internal Transfers", xero: "Tracking" },
31
+ { fusion: "Owner Equity", xero: "Current Liability" },
32
+ { fusion: "Non-current Liability", xero: "Non-current Liability" },
33
+ { fusion: "Equity", xero: "Retained Earnings" },
34
+ { fusion: "Equity", xero: "Equity" }
35
+ ];
36
+ export const expenseAccountOptions = Array.from(new Set(billingTagMapping.map((tag) => tag.fusion))).map((tag) => {
37
+ return {
38
+ label: tag,
39
+ value: tag
40
+ };
41
+ });
42
+ export const budgetOptions = [
43
+ { label: "powerhouse", value: "PH-001" },
44
+ ];
@@ -41,7 +41,7 @@ export function BaseEditor(props) {
41
41
  dispatch(copyNodeAction);
42
42
  }
43
43
  }, [dispatch, props.document.state.global.nodes]);
44
- return (_jsx("div", { className: "new-drive-explorer", style: { height: "100%" }, children: _jsx(DriveExplorer, { driveId: props.document.state.global.id, nodes: nodes, onAddFolder: onAddFolder, onDeleteNode: onDeleteNode, renameNode: renameNode, onCopyNode: onCopyNode, context: context, document: props.document, dispatch: dispatch }, nodes.length) }));
44
+ return (_jsx("div", { className: "new-drive-explorer", children: _jsx(DriveExplorer, { driveId: props.document.state.global.id, nodes: nodes, onAddFolder: onAddFolder, onDeleteNode: onDeleteNode, renameNode: renameNode, onCopyNode: onCopyNode, context: context, document: props.document, dispatch: dispatch }, nodes.length) }));
45
45
  }
46
46
  export default function Editor(props) {
47
47
  return (_jsx(DriveContextProvider, { value: props.context, children: _jsx(WagmiContext, { children: _jsx(BaseEditor, { ...props }) }) }));
@@ -1,3 +1,4 @@
1
1
  export { module as Invoice } from "./invoice/index.js";
2
2
  export { module as ContributorBilling } from "./contributor-billing/index.js";
3
+ export { module as BillingStatement } from "./billing-statement/index.js";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../editors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,MAAM,IAAI,kBAAkB,EAAE,MAAM,gCAAgC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../editors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,MAAM,IAAI,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,MAAM,IAAI,gBAAgB,EAAE,MAAM,8BAA8B,CAAC"}
@@ -1,2 +1,3 @@
1
1
  export { module as Invoice } from "./invoice/index.js";
2
2
  export { module as ContributorBilling } from "./contributor-billing/index.js";
3
+ export { module as BillingStatement } from "./billing-statement/index.js";
@@ -1 +1 @@
1
- {"version":3,"file":"currencyForm.d.ts","sourceRoot":"","sources":["../../../../editors/invoice/components/currencyForm.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEtE,UAAU,iBAAiB;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IACpE,UAAU,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;CACtC;AAED,eAAO,MAAM,YAAY;;;GAUxB,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,8CAI1B,iBAAiB,4CA8BnB,CAAC"}
1
+ {"version":3,"file":"currencyForm.d.ts","sourceRoot":"","sources":["../../../../editors/invoice/components/currencyForm.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEtE,UAAU,iBAAiB;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IACpE,UAAU,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;CACtC;AAED,eAAO,MAAM,YAAY;;;GAUxB,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,8CAI1B,iBAAiB,4CA4BnB,CAAC"}
@@ -13,14 +13,12 @@ export const currencyList = [
13
13
  ];
14
14
  export const CurrencyForm = ({ currency, handleInputChange, validation, }) => {
15
15
  const warnings = validation && !validation.isValid ? [validation.message] : undefined;
16
- return (_jsx(Form, { defaultValues: { currency }, onSubmit: () => { }, resetOnSuccessfulSubmit: true, children: _jsx(CurrencyCodeField, { style: {
17
- width: "100px",
18
- }, name: "currency", placeholder: "Currency", currencies: currencyList, searchable: false, value: currency, onChange: (value) => {
16
+ return (_jsx(Form, { defaultValues: { currency }, onSubmit: () => { }, resetOnSuccessfulSubmit: true, children: _jsx(CurrencyCodeField, { name: "currency", placeholder: "Currency", currencies: currencyList, searchable: false, value: currency, onChange: (value) => {
19
17
  const syntheticEvent = {
20
18
  target: {
21
19
  value: value,
22
20
  },
23
21
  };
24
22
  handleInputChange(syntheticEvent);
25
- }, warnings: warnings }) }));
23
+ }, warnings: warnings, className: "w-32" }) }));
26
24
  };
@@ -1 +1 @@
1
- {"version":3,"file":"datePicker.d.ts","sourceRoot":"","sources":["../../../../editors/invoice/components/datePicker.tsx"],"names":[],"mappings":"AAGA,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;CAC5D;AAED,eAAO,MAAM,UAAU,GAAI,OAAO,eAAe,4CAqBhD,CAAC"}
1
+ {"version":3,"file":"datePicker.d.ts","sourceRoot":"","sources":["../../../../editors/invoice/components/datePicker.tsx"],"names":[],"mappings":"AAMA,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;CAC5D;AAED,eAAO,MAAM,UAAU,GAAI,OAAO,eAAe,4CAqBhD,CAAC"}
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { DatePickerField, Form } from "@powerhousedao/document-engineering/scalars";
2
+ import { DatePickerField, Form, } from "@powerhousedao/document-engineering/scalars";
3
3
  import { twMerge } from "tailwind-merge";
4
4
  export const DatePicker = (props) => {
5
5
  return (_jsx(Form, { defaultValues: {
6
6
  input: props.value,
7
- }, onSubmit: () => { }, resetOnSuccessfulSubmit: false, className: twMerge(props.className), children: _jsx(DatePickerField, { name: props.name, value: props.value, label: props.label, placeholder: props.placeholder, onChange: props.onChange, dateFormat: "YYYY-MM-DD" }) }, props.value));
7
+ }, onSubmit: () => { }, resetOnSuccessfulSubmit: false, children: _jsx(DatePickerField, { name: props.name, value: props.value, label: props.label, placeholder: props.placeholder, onChange: props.onChange, dateFormat: "YYYY-MM-DD", className: twMerge(props.className) }) }, props.value));
8
8
  };
@@ -1 +1 @@
1
- {"version":3,"file":"inputField.d.ts","sourceRoot":"","sources":["../../../../editors/invoice/components/inputField.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAGtE,UAAU,eAAe;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,mBAAmB,CAAC,KAAK,IAAI,CAAC;IAC3D,iBAAiB,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,mBAAmB,CAAC,KAAK,IAAI,CAAC;IACvE,UAAU,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,UAAU,GAAI,OAAO,eAAe,4CAsDhD,CAAC"}
1
+ {"version":3,"file":"inputField.d.ts","sourceRoot":"","sources":["../../../../editors/invoice/components/inputField.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAGtE,UAAU,eAAe;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,mBAAmB,CAAC,KAAK,IAAI,CAAC;IAC3D,iBAAiB,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,mBAAmB,CAAC,KAAK,IAAI,CAAC;IACvE,UAAU,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,UAAU,GAAI,OAAO,eAAe,4CAmDhD,CAAC"}
@@ -6,9 +6,7 @@ export const InputField = (props) => {
6
6
  const warnings = validation && !validation.isValid ? [validation.message] : undefined;
7
7
  return (_jsx(Form, { defaultValues: {
8
8
  input: input,
9
- }, onSubmit: () => { }, resetOnSuccessfulSubmit: true, children: _jsx(StringField, { style: {
10
- color: "black",
11
- }, label: label, placeholder: placeholder, name: "input", value: value, onBlur: onBlur, onChange: (e) => {
9
+ }, onSubmit: () => { }, resetOnSuccessfulSubmit: true, children: _jsx(StringField, { label: label, placeholder: placeholder, name: "input", value: value, onBlur: onBlur, onChange: (e) => {
12
10
  handleInputChange(e);
13
11
  }, onKeyDown: (e) => {
14
12
  if (e.key === 'Enter') {
@@ -3,10 +3,11 @@ interface NumberFormProps {
3
3
  precision?: number;
4
4
  min?: number;
5
5
  max?: number;
6
+ pattern?: string;
6
7
  handleInputChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
7
8
  placeholder?: string;
8
9
  className?: string;
9
10
  }
10
- export declare const NumberForm: ({ number, precision, min, max, handleInputChange, placeholder, className, }: NumberFormProps) => import("react/jsx-runtime").JSX.Element;
11
+ export declare const NumberForm: ({ number, precision, min, max, pattern, handleInputChange, placeholder, className, }: NumberFormProps) => import("react/jsx-runtime").JSX.Element;
11
12
  export {};
12
13
  //# sourceMappingURL=numberForm.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"numberForm.d.ts","sourceRoot":"","sources":["../../../../editors/invoice/components/numberForm.tsx"],"names":[],"mappings":"AAGA,UAAU,eAAe;IACvB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,iBAAiB,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IACpE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,UAAU,GAAI,6EAQxB,eAAe,4CAqBjB,CAAC"}
1
+ {"version":3,"file":"numberForm.d.ts","sourceRoot":"","sources":["../../../../editors/invoice/components/numberForm.tsx"],"names":[],"mappings":"AAGA,UAAU,eAAe;IACvB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IACpE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,UAAU,GAAI,sFASxB,eAAe,4CAmBjB,CAAC"}
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Form, NumberField } from "@powerhousedao/document-engineering/scalars";
3
3
  import { twMerge } from "tailwind-merge";
4
- export const NumberForm = ({ number, precision, min, max, handleInputChange, placeholder, className, }) => {
4
+ export const NumberForm = ({ number, precision, min, max, pattern, handleInputChange, placeholder, className, }) => {
5
5
  return (_jsx(Form, { defaultValues: { number }, onSubmit: () => { }, resetOnSuccessfulSubmit: true, children: _jsx(NumberField, { name: "number", onChange: (e) => {
6
6
  handleInputChange(e);
7
- }, precision: precision, min: min, max: max, value: Number(number), placeholder: placeholder, className: twMerge(className) }) }));
7
+ }, precision: precision, value: typeof number === "string" && number === "-" ? 0 : Number(number), placeholder: placeholder, className: twMerge(className) }) }));
8
8
  };
@@ -1 +1 @@
1
- {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../editors/invoice/editor.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EACL,KAAK,eAAe,EAGrB,MAAM,wCAAwC,CAAC;AA4BhD,MAAM,MAAM,MAAM,GAAG,WAAW,CAAC,eAAe,CAAC,CAAC;AAElD,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAK,EAAE,MAAM,2CAsyB3C"}
1
+ {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../editors/invoice/editor.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EACL,KAAK,eAAe,EAGrB,MAAM,wCAAwC,CAAC;AA4BhD,MAAM,MAAM,MAAM,GAAG,WAAW,CAAC,eAAe,CAAC,CAAC;AAqClD,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAK,EAAE,MAAM,2CAixB3C"}
@@ -22,9 +22,43 @@ import { Textarea } from "@powerhousedao/document-engineering/ui";
22
22
  function isFiatCurrency(currency) {
23
23
  return currencyList.find((c) => c.ticker === currency)?.crypto === false;
24
24
  }
25
+ const useResponsiveEditorStyle = (options = { scale: 0.9, maxWidth: "1280px" }) => {
26
+ const baseStyle = {
27
+ width: "100vw",
28
+ minHeight: "100vh",
29
+ margin: 0,
30
+ padding: 0,
31
+ boxSizing: "border-box",
32
+ transform: `scale(${options.scale})`,
33
+ transformOrigin: "top left",
34
+ };
35
+ const [responsiveStyle, setResponsiveStyle] = useState(baseStyle);
36
+ useEffect(() => {
37
+ function handleResize() {
38
+ if (window.innerWidth >= 1024) {
39
+ setResponsiveStyle({
40
+ ...baseStyle,
41
+ maxWidth: options.maxWidth,
42
+ marginLeft: "auto",
43
+ marginRight: "auto",
44
+ padding: "1rem",
45
+ });
46
+ }
47
+ else {
48
+ setResponsiveStyle(baseStyle);
49
+ }
50
+ }
51
+ handleResize();
52
+ window.addEventListener("resize", handleResize);
53
+ return () => window.removeEventListener("resize", handleResize);
54
+ }, [options.scale, options.maxWidth]);
55
+ return responsiveStyle;
56
+ };
25
57
  export default function Editor(props) {
26
58
  const { document: doc, dispatch } = props;
27
59
  const state = doc.state.global;
60
+ // Only use the hook if you need custom scaling or maxWidth
61
+ const customStyle = useResponsiveEditorStyle({ scale: 0.9, maxWidth: "1280px" });
28
62
  const [fiatMode, setFiatMode] = useState(isFiatCurrency(state.currency));
29
63
  const [uploadDropdownOpen, setUploadDropdownOpen] = useState(false);
30
64
  const [exportDropdownOpen, setExportDropdownOpen] = useState(false);
@@ -48,35 +82,6 @@ export default function Editor(props) {
48
82
  const [mainCountryValidation, setMainCountryValidation] = useState(null);
49
83
  const [bankCountryValidation, setBankCountryValidation] = useState(null);
50
84
  const prevStatus = useRef(state.status);
51
- const invoiceRootStyle = {
52
- width: "100vw",
53
- minHeight: "100vh",
54
- margin: 0,
55
- padding: 0,
56
- boxSizing: "border-box",
57
- transform: "scale(0.9)",
58
- transformOrigin: "top left",
59
- };
60
- const [responsiveStyle, setResponsiveStyle] = useState(invoiceRootStyle);
61
- useEffect(() => {
62
- function handleResize() {
63
- if (window.innerWidth >= 1024) {
64
- setResponsiveStyle({
65
- ...invoiceRootStyle,
66
- maxWidth: "1280px",
67
- marginLeft: "auto",
68
- marginRight: "auto",
69
- padding: "1rem",
70
- });
71
- }
72
- else {
73
- setResponsiveStyle(invoiceRootStyle);
74
- }
75
- }
76
- handleResize();
77
- window.addEventListener("resize", handleResize);
78
- return () => window.removeEventListener("resize", handleResize);
79
- }, []);
80
85
  useEffect(() => {
81
86
  setFiatMode(isFiatCurrency(state.currency));
82
87
  }, [state.currency, state]);
@@ -363,7 +368,7 @@ export default function Editor(props) {
363
368
  }
364
369
  dispatch(actions.editInvoice({ currency }));
365
370
  };
366
- return (_jsxs("div", { style: responsiveStyle, children: [_jsx(ToastContainer, { position: "bottom-right", autoClose: 5000, hideProgressBar: false, newestOnTop: false, closeOnClick: false, rtl: false, pauseOnFocusLoss: true, draggable: true, pauseOnHover: true, theme: "light" }), _jsxs("div", { className: "flex items-center justify-between gap-4 mb-6", children: [_jsxs("div", { className: "flex items-center gap-4 flex-nowrap", children: [_jsx("h1", { className: "text-3xl font-bold whitespace-nowrap", children: "Invoice" }), _jsx(InputField, { placeholder: "Add invoice number", value: invoiceNoInput, handleInputChange: (e) => setInvoiceNoInput(e.target.value), onBlur: (e) => {
371
+ return (_jsxs("div", { className: "editor-container", children: [_jsx(ToastContainer, { position: "bottom-right", autoClose: 5000, hideProgressBar: false, newestOnTop: false, closeOnClick: false, rtl: false, pauseOnFocusLoss: true, draggable: true, pauseOnHover: true, theme: "light" }), _jsxs("div", { className: "flex items-center justify-between gap-4 mb-6", children: [_jsxs("div", { className: "flex items-center gap-4 flex-nowrap", children: [_jsx("h1", { className: "text-3xl font-bold whitespace-nowrap", children: "Invoice" }), _jsx(InputField, { placeholder: "Add invoice number", value: invoiceNoInput, handleInputChange: (e) => setInvoiceNoInput(e.target.value), onBlur: (e) => {
367
372
  const newValue = e.target.value;
368
373
  if (newValue !== state.invoiceNo) {
369
374
  dispatch(actions.editInvoice({ invoiceNo: newValue }));
@@ -379,19 +384,19 @@ export default function Editor(props) {
379
384
  setExportDropdownOpen(false);
380
385
  }, className: "block w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 cursor-pointer", children: "Export PDF" })] }) }))] })] }), _jsx("div", { className: "flex items-center gap-2", children: _jsx(CurrencyForm, { currency: state.currency, handleInputChange: (e) => {
381
386
  handleCurrencyChange(e.target.value);
382
- }, validation: currencyValidation }) }), _jsx(SelectField, { options: STATUS_OPTIONS, value: state.status, onChange: (value) => handleStatusChange(value) })] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "border border-gray-200 rounded-lg p-6", children: [_jsx("h3", { className: "text-lg font-semibold mb-4", children: "Issuer" }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "mb-2", children: [_jsx("label", { className: "block mb-1 text-sm", children: "Issue Date:" }), _jsx(DatePicker, { name: "issueDate", className: "w-full", onChange: (e) => {
387
+ }, validation: currencyValidation }) }), _jsx(SelectField, { options: STATUS_OPTIONS, value: state.status, onChange: (value) => handleStatusChange(value) })] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "border border-gray-200 rounded-lg p-4", children: [_jsx("h3", { className: "text-lg font-semibold mb-4", children: "Issuer" }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "mb-2", children: [_jsx("label", { className: "block mb-1 text-sm", children: "Issue Date:" }), _jsx(DatePicker, { name: "issueDate", className: String.raw `w-full p-0`, onChange: (e) => {
383
388
  const newDate = e.target.value.split("T")[0];
384
389
  dispatch(actions.editInvoice({
385
390
  dateIssued: newDate,
386
391
  }));
387
- }, value: state.dateIssued })] }), _jsxs("div", { className: "mb-2", children: [_jsx("label", { className: "block mb-1 text-sm", children: "Delivery Date:" }), _jsx(DatePicker, { name: "deliveryDate", className: "w-full", onChange: (e) => {
392
+ }, value: state.dateIssued })] }), _jsxs("div", { className: "mb-2", children: [_jsx("label", { className: "block mb-1 text-sm", children: "Delivery Date:" }), _jsx(DatePicker, { name: "deliveryDate", className: String.raw `w-full p-0`, onChange: (e) => {
388
393
  const newValue = e.target.value.split("T")[0];
389
394
  if (newValue !== state.dateDelivered) {
390
395
  dispatch(actions.editInvoice({
391
396
  dateDelivered: newValue,
392
397
  }));
393
398
  }
394
- }, value: state.dateDelivered || "" })] })] }), _jsx(LegalEntityForm, { legalEntity: state.issuer, onChangeInfo: (input) => dispatch(actions.editIssuer(input)), onChangeBank: (input) => dispatch(actions.editIssuerBank(input)), onChangeWallet: (input) => dispatch(actions.editIssuerWallet(input)), basicInfoDisabled: false, bankDisabled: !fiatMode, walletDisabled: fiatMode, currency: state.currency, status: state.status, walletvalidation: walletValidation, mainCountryValidation: mainCountryValidation, bankCountryValidation: bankCountryValidation, ibanvalidation: ibanValidation, bicvalidation: bicValidation, banknamevalidation: bankNameValidation, streetaddressvalidation: streetAddressValidation, cityvalidation: cityValidation, postalcodevalidation: postalCodeValidation, payeremailvalidation: payerEmailValidation })] }), _jsxs("div", { className: "border border-gray-200 rounded-lg p-6", children: [_jsx("h3", { className: "text-lg font-semibold mb-4", children: "Payer" }), _jsxs("div", { className: "mb-2", children: [_jsx("label", { className: "block mb-1 text-sm", children: "Due Date:" }), _jsx(DatePicker, { name: "dateDue", className: "w-full", onChange: (e) => dispatch(actions.editInvoice({
399
+ }, value: state.dateDelivered || "" })] })] }), _jsx(LegalEntityForm, { legalEntity: state.issuer, onChangeInfo: (input) => dispatch(actions.editIssuer(input)), onChangeBank: (input) => dispatch(actions.editIssuerBank(input)), onChangeWallet: (input) => dispatch(actions.editIssuerWallet(input)), basicInfoDisabled: false, bankDisabled: !fiatMode, walletDisabled: fiatMode, currency: state.currency, status: state.status, walletvalidation: walletValidation, mainCountryValidation: mainCountryValidation, bankCountryValidation: bankCountryValidation, ibanvalidation: ibanValidation, bicvalidation: bicValidation, banknamevalidation: bankNameValidation, streetaddressvalidation: streetAddressValidation, cityvalidation: cityValidation, postalcodevalidation: postalCodeValidation, payeremailvalidation: payerEmailValidation })] }), _jsxs("div", { className: "border border-gray-200 rounded-lg p-4", children: [_jsx("h3", { className: "text-lg font-semibold mb-4", children: "Payer" }), _jsxs("div", { className: "mb-2", children: [_jsx("label", { className: "block mb-1 text-sm", children: "Due Date:" }), _jsx(DatePicker, { name: "dateDue", className: String.raw `w-full p-0`, onChange: (e) => dispatch(actions.editInvoice({
395
400
  dateDue: e.target.value.split("T")[0],
396
401
  })), value: state.dateDue })] }), _jsx(LegalEntityForm, { bankDisabled: true, legalEntity: state.payer, onChangeInfo: (input) => dispatch(actions.editPayer(input)), currency: state.currency, status: state.status, payeremailvalidation: payerEmailValidation })] })] }), _jsx("div", { className: "mb-8", children: _jsx(LineItemsTable, { currency: state.currency, lineItems: state.lineItems.map((item) => ({
397
402
  ...item,
@@ -23,6 +23,6 @@ type LineItemsTableProps = {
23
23
  readonly dispatch: Dispatch<any>;
24
24
  readonly paymentAccounts: InvoiceTag[];
25
25
  };
26
- export declare function LineItemsTable({ lineItems, currency, onAddItem, onUpdateItem, onDeleteItem, onUpdateCurrency, dispatch, paymentAccounts }: LineItemsTableProps): import("react/jsx-runtime").JSX.Element;
26
+ export declare function LineItemsTable({ lineItems, currency, onAddItem, onUpdateItem, onDeleteItem, onUpdateCurrency, dispatch, paymentAccounts, }: LineItemsTableProps): import("react/jsx-runtime").JSX.Element;
27
27
  export {};
28
28
  //# sourceMappingURL=lineItems.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lineItems.d.ts","sourceRoot":"","sources":["../../../editors/invoice/lineItems.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAC3G,OAAO,EAA0D,QAAQ,EAAE,MAAM,OAAO,CAAC;AAqBzF,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAsBlD;AAED,KAAK,QAAQ,GAAG;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B,CAAC;AAuNF,KAAK,mBAAmB,GAAG;IACzB,QAAQ,CAAC,SAAS,EAAE,QAAQ,EAAE,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IAC7C,QAAQ,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IAChD,QAAQ,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC5D,QAAQ,CAAC,gBAAgB,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAC7D,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;IACjC,QAAQ,CAAC,eAAe,EAAE,UAAU,EAAE,CAAC;CACxC,CAAC;AAEF,wBAAgB,cAAc,CAAC,EAC7B,SAAS,EACT,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,QAAQ,EACR,eAAe,EAChB,EAAE,mBAAmB,2CA+IrB"}
1
+ {"version":3,"file":"lineItems.d.ts","sourceRoot":"","sources":["../../../editors/invoice/lineItems.tsx"],"names":[],"mappings":"AAIA,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,UAAU,EACX,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAML,QAAQ,EACT,MAAM,OAAO,CAAC;AAqBf,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAsBlD;AAED,KAAK,QAAQ,GAAG;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B,CAAC;AAwNF,KAAK,mBAAmB,GAAG;IACzB,QAAQ,CAAC,SAAS,EAAE,QAAQ,EAAE,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IAC7C,QAAQ,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IAChD,QAAQ,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC5D,QAAQ,CAAC,gBAAgB,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAC7D,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;IACjC,QAAQ,CAAC,eAAe,EAAE,UAAU,EAAE,CAAC;CACxC,CAAC;AAEF,wBAAgB,cAAc,CAAC,EAC7B,SAAS,EACT,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,QAAQ,EACR,eAAe,GAChB,EAAE,mBAAmB,2CA6LrB"}