@baack-software/baack-ts-crm 0.0.0-stage → 0.0.3

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 (234) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +74 -2
  3. package/dist/account.d.ts +36 -0
  4. package/dist/account.d.ts.map +1 -0
  5. package/dist/account.js +48 -0
  6. package/dist/account.js.map +1 -0
  7. package/dist/backend.d.ts +104 -0
  8. package/dist/backend.d.ts.map +1 -0
  9. package/dist/backend.js +328 -0
  10. package/dist/backend.js.map +1 -0
  11. package/dist/crm-client.d.ts +164 -0
  12. package/dist/crm-client.d.ts.map +1 -0
  13. package/dist/crm-client.js +252 -0
  14. package/dist/crm-client.js.map +1 -0
  15. package/dist/deal-order.d.ts +42 -0
  16. package/dist/deal-order.d.ts.map +1 -0
  17. package/dist/deal-order.js +80 -0
  18. package/dist/deal-order.js.map +1 -0
  19. package/dist/errors.d.ts +21 -0
  20. package/dist/errors.d.ts.map +1 -0
  21. package/dist/errors.js +33 -0
  22. package/dist/errors.js.map +1 -0
  23. package/dist/index.d.ts +14 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +14 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/invoices.d.ts +53 -0
  28. package/dist/invoices.d.ts.map +1 -0
  29. package/dist/invoices.js +155 -0
  30. package/dist/invoices.js.map +1 -0
  31. package/dist/leads.d.ts +29 -0
  32. package/dist/leads.d.ts.map +1 -0
  33. package/dist/leads.js +56 -0
  34. package/dist/leads.js.map +1 -0
  35. package/dist/mock/index.d.ts +43 -0
  36. package/dist/mock/index.d.ts.map +1 -0
  37. package/dist/mock/index.js +303 -0
  38. package/dist/mock/index.js.map +1 -0
  39. package/dist/money.d.ts +29 -0
  40. package/dist/money.d.ts.map +1 -0
  41. package/dist/money.js +82 -0
  42. package/dist/money.js.map +1 -0
  43. package/dist/period.d.ts +30 -0
  44. package/dist/period.d.ts.map +1 -0
  45. package/dist/period.js +49 -0
  46. package/dist/period.js.map +1 -0
  47. package/dist/pipeline.d.ts +36 -0
  48. package/dist/pipeline.d.ts.map +1 -0
  49. package/dist/pipeline.js +58 -0
  50. package/dist/pipeline.js.map +1 -0
  51. package/dist/react/Charts.d.ts +19 -0
  52. package/dist/react/Charts.d.ts.map +1 -0
  53. package/dist/react/Charts.js +38 -0
  54. package/dist/react/Charts.js.map +1 -0
  55. package/dist/react/ChoiceCombobox.d.ts +36 -0
  56. package/dist/react/ChoiceCombobox.d.ts.map +1 -0
  57. package/dist/react/ChoiceCombobox.js +105 -0
  58. package/dist/react/ChoiceCombobox.js.map +1 -0
  59. package/dist/react/CompanyAccountView.d.ts +21 -0
  60. package/dist/react/CompanyAccountView.d.ts.map +1 -0
  61. package/dist/react/CompanyAccountView.js +27 -0
  62. package/dist/react/CompanyAccountView.js.map +1 -0
  63. package/dist/react/DashboardCards.d.ts +32 -0
  64. package/dist/react/DashboardCards.d.ts.map +1 -0
  65. package/dist/react/DashboardCards.js +38 -0
  66. package/dist/react/DashboardCards.js.map +1 -0
  67. package/dist/react/DealsBoard.d.ts +49 -0
  68. package/dist/react/DealsBoard.d.ts.map +1 -0
  69. package/dist/react/DealsBoard.js +82 -0
  70. package/dist/react/DealsBoard.js.map +1 -0
  71. package/dist/react/Details.d.ts +85 -0
  72. package/dist/react/Details.d.ts.map +1 -0
  73. package/dist/react/Details.js +268 -0
  74. package/dist/react/Details.js.map +1 -0
  75. package/dist/react/Forms.d.ts +190 -0
  76. package/dist/react/Forms.d.ts.map +1 -0
  77. package/dist/react/Forms.js +494 -0
  78. package/dist/react/Forms.js.map +1 -0
  79. package/dist/react/LeadsTable.d.ts +22 -0
  80. package/dist/react/LeadsTable.d.ts.map +1 -0
  81. package/dist/react/LeadsTable.js +79 -0
  82. package/dist/react/LeadsTable.js.map +1 -0
  83. package/dist/react/Sales.d.ts +68 -0
  84. package/dist/react/Sales.d.ts.map +1 -0
  85. package/dist/react/Sales.js +270 -0
  86. package/dist/react/Sales.js.map +1 -0
  87. package/dist/react/SidePanel.d.ts +31 -0
  88. package/dist/react/SidePanel.d.ts.map +1 -0
  89. package/dist/react/SidePanel.js +49 -0
  90. package/dist/react/SidePanel.js.map +1 -0
  91. package/dist/react/format.d.ts +28 -0
  92. package/dist/react/format.d.ts.map +1 -0
  93. package/dist/react/format.js +30 -0
  94. package/dist/react/format.js.map +1 -0
  95. package/dist/react/index.d.ts +15 -0
  96. package/dist/react/index.d.ts.map +1 -0
  97. package/dist/react/index.js +15 -0
  98. package/dist/react/index.js.map +1 -0
  99. package/dist/react/parts.d.ts +55 -0
  100. package/dist/react/parts.d.ts.map +1 -0
  101. package/dist/react/parts.js +82 -0
  102. package/dist/react/parts.js.map +1 -0
  103. package/dist/react/pipeline-choice.d.ts +19 -0
  104. package/dist/react/pipeline-choice.d.ts.map +1 -0
  105. package/dist/react/pipeline-choice.js +39 -0
  106. package/dist/react/pipeline-choice.js.map +1 -0
  107. package/dist/react/text.d.ts +232 -0
  108. package/dist/react/text.d.ts.map +1 -0
  109. package/dist/react/text.js +229 -0
  110. package/dist/react/text.js.map +1 -0
  111. package/dist/react/ui/alert.d.ts +11 -0
  112. package/dist/react/ui/alert.d.ts.map +1 -0
  113. package/dist/react/ui/alert.js +29 -0
  114. package/dist/react/ui/alert.js.map +1 -0
  115. package/dist/react/ui/badge.d.ts +10 -0
  116. package/dist/react/ui/badge.d.ts.map +1 -0
  117. package/dist/react/ui/badge.js +26 -0
  118. package/dist/react/ui/badge.js.map +1 -0
  119. package/dist/react/ui/button.d.ts +11 -0
  120. package/dist/react/ui/button.d.ts.map +1 -0
  121. package/dist/react/ui/button.js +37 -0
  122. package/dist/react/ui/button.js.map +1 -0
  123. package/dist/react/ui/card.d.ts +12 -0
  124. package/dist/react/ui/card.d.ts.map +1 -0
  125. package/dist/react/ui/card.js +26 -0
  126. package/dist/react/ui/card.js.map +1 -0
  127. package/dist/react/ui/chart.d.ts +45 -0
  128. package/dist/react/ui/chart.d.ts.map +1 -0
  129. package/dist/react/ui/chart.js +116 -0
  130. package/dist/react/ui/chart.js.map +1 -0
  131. package/dist/react/ui/input.d.ts +4 -0
  132. package/dist/react/ui/input.d.ts.map +1 -0
  133. package/dist/react/ui/input.js +8 -0
  134. package/dist/react/ui/input.js.map +1 -0
  135. package/dist/react/ui/label.d.ts +5 -0
  136. package/dist/react/ui/label.d.ts.map +1 -0
  137. package/dist/react/ui/label.js +10 -0
  138. package/dist/react/ui/label.js.map +1 -0
  139. package/dist/react/ui/progress.d.ts +5 -0
  140. package/dist/react/ui/progress.d.ts.map +1 -0
  141. package/dist/react/ui/progress.js +10 -0
  142. package/dist/react/ui/progress.js.map +1 -0
  143. package/dist/react/ui/select.d.ts +16 -0
  144. package/dist/react/ui/select.d.ts.map +1 -0
  145. package/dist/react/ui/select.js +37 -0
  146. package/dist/react/ui/select.js.map +1 -0
  147. package/dist/react/ui/separator.d.ts +5 -0
  148. package/dist/react/ui/separator.d.ts.map +1 -0
  149. package/dist/react/ui/separator.js +10 -0
  150. package/dist/react/ui/separator.js.map +1 -0
  151. package/dist/react/ui/sheet.d.ts +15 -0
  152. package/dist/react/ui/sheet.d.ts.map +1 -0
  153. package/dist/react/ui/sheet.js +38 -0
  154. package/dist/react/ui/sheet.js.map +1 -0
  155. package/dist/react/ui/skeleton.d.ts +3 -0
  156. package/dist/react/ui/skeleton.d.ts.map +1 -0
  157. package/dist/react/ui/skeleton.js +7 -0
  158. package/dist/react/ui/skeleton.js.map +1 -0
  159. package/dist/react/ui/table.d.ts +11 -0
  160. package/dist/react/ui/table.d.ts.map +1 -0
  161. package/dist/react/ui/table.js +29 -0
  162. package/dist/react/ui/table.js.map +1 -0
  163. package/dist/react/ui/tabs.d.ts +12 -0
  164. package/dist/react/ui/tabs.d.ts.map +1 -0
  165. package/dist/react/ui/tabs.js +31 -0
  166. package/dist/react/ui/tabs.js.map +1 -0
  167. package/dist/react/views.d.ts +82 -0
  168. package/dist/react/views.d.ts.map +1 -0
  169. package/dist/react/views.js +241 -0
  170. package/dist/react/views.js.map +1 -0
  171. package/dist/sales.d.ts +82 -0
  172. package/dist/sales.d.ts.map +1 -0
  173. package/dist/sales.js +87 -0
  174. package/dist/sales.js.map +1 -0
  175. package/dist/store.d.ts +159 -0
  176. package/dist/store.d.ts.map +1 -0
  177. package/dist/store.js +305 -0
  178. package/dist/store.js.map +1 -0
  179. package/dist/target.d.ts +22 -0
  180. package/dist/target.d.ts.map +1 -0
  181. package/dist/target.js +40 -0
  182. package/dist/target.js.map +1 -0
  183. package/dist/types.d.ts +204 -0
  184. package/dist/types.d.ts.map +1 -0
  185. package/dist/types.js +2 -0
  186. package/dist/types.js.map +1 -0
  187. package/package.json +100 -4
  188. package/src/account.ts +79 -0
  189. package/src/backend.ts +501 -0
  190. package/src/crm-client.ts +393 -0
  191. package/src/deal-order.ts +116 -0
  192. package/src/errors.ts +34 -0
  193. package/src/index.ts +13 -0
  194. package/src/invoices.ts +177 -0
  195. package/src/leads.ts +78 -0
  196. package/src/mock/index.ts +398 -0
  197. package/src/money.ts +104 -0
  198. package/src/period.ts +71 -0
  199. package/src/pipeline.ts +82 -0
  200. package/src/react/Charts.tsx +143 -0
  201. package/src/react/ChoiceCombobox.tsx +227 -0
  202. package/src/react/CompanyAccountView.tsx +198 -0
  203. package/src/react/DashboardCards.tsx +171 -0
  204. package/src/react/DealsBoard.tsx +344 -0
  205. package/src/react/Details.tsx +870 -0
  206. package/src/react/Forms.tsx +1486 -0
  207. package/src/react/LeadsTable.tsx +234 -0
  208. package/src/react/Sales.tsx +827 -0
  209. package/src/react/SidePanel.tsx +104 -0
  210. package/src/react/format.ts +53 -0
  211. package/src/react/index.ts +14 -0
  212. package/src/react/parts.tsx +183 -0
  213. package/src/react/pipeline-choice.ts +54 -0
  214. package/src/react/text.ts +232 -0
  215. package/src/react/ui/README.md +6 -0
  216. package/src/react/ui/alert.tsx +75 -0
  217. package/src/react/ui/badge.tsx +48 -0
  218. package/src/react/ui/button.tsx +66 -0
  219. package/src/react/ui/card.tsx +102 -0
  220. package/src/react/ui/chart.tsx +304 -0
  221. package/src/react/ui/input.tsx +18 -0
  222. package/src/react/ui/label.tsx +23 -0
  223. package/src/react/ui/progress.tsx +30 -0
  224. package/src/react/ui/select.tsx +189 -0
  225. package/src/react/ui/separator.tsx +27 -0
  226. package/src/react/ui/sheet.tsx +145 -0
  227. package/src/react/ui/skeleton.tsx +13 -0
  228. package/src/react/ui/table.tsx +113 -0
  229. package/src/react/ui/tabs.tsx +89 -0
  230. package/src/react/views.tsx +633 -0
  231. package/src/sales.ts +167 -0
  232. package/src/store.ts +528 -0
  233. package/src/target.ts +54 -0
  234. package/src/types.ts +230 -0
@@ -0,0 +1,268 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useId, useState } from 'react';
3
+ import { LEAD_SOURCES, LEAD_STATUS_LABELS, SOURCE_LABELS, leadOutcome } from "../leads.js";
4
+ import { minorOf, toDecimal } from "../money.js";
5
+ import { dealOutcome, dealProbability, orderedStages, pipelineOf, stageOf } from "../pipeline.js";
6
+ import { ChoiceSelect, Field, moneyOf, MoneyInput, NewCompanyStep, NewContactStep, PipelineStageFields, } from "./Forms.js";
7
+ import { ChoiceCombobox } from "./ChoiceCombobox.js";
8
+ import { StageSelect } from "./DealsBoard.js";
9
+ import { companyNameOf, formatDate, formatMaybeMoney, personNameOf } from "./format.js";
10
+ import { leadCompany } from "./LeadsTable.js";
11
+ import { CrmCard, LeadStatusBadge, OutcomeBadge } from "./parts.js";
12
+ import { withText } from "./text.js";
13
+ import { Button } from "./ui/button.js";
14
+ import { Input } from "./ui/input.js";
15
+ import { Label } from "./ui/label.js";
16
+ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./ui/select.js";
17
+ /** Label and value pairs as a description list. */
18
+ export function DetailList({ items }) {
19
+ return (_jsx("dl", { className: "grid grid-cols-[minmax(7rem,auto)_minmax(0,1fr)] gap-x-4 gap-y-2 text-sm", children: items.map(({ label, value }) => (_jsxs("div", { className: "contents", children: [_jsx("dt", { className: "text-muted-foreground", children: label }), _jsx("dd", { children: value })] }, label))) }));
20
+ }
21
+ /** A text field that saves when it loses focus or Enter is pressed, and only when it changed. */
22
+ function CommitInput({ id, value, onCommit, ...props }) {
23
+ const [draft, setDraft] = useState(value);
24
+ useEffect(() => setDraft(value), [value]);
25
+ const commit = () => {
26
+ if (draft.trim() !== value)
27
+ onCommit(draft.trim());
28
+ };
29
+ return (_jsx(Input, { id: id, value: draft, onChange: (event) => setDraft(event.target.value), onBlur: commit, onKeyDown: (event) => {
30
+ if (event.key === 'Enter')
31
+ commit();
32
+ }, ...props }));
33
+ }
34
+ /**
35
+ * A record's money, saved as it changes: when the amount loses focus or Enter is pressed, or the currency is chosen.
36
+ * `onInvalid` is told when the amount isn't a number of at least zero.
37
+ */
38
+ function CommitMoney({ id, value, onCommit, onInvalid, text, }) {
39
+ const savedCurrency = value?.currencyCode ?? 'GBP';
40
+ const savedAmount = value ? toDecimal(minorOf(value), savedCurrency) : '';
41
+ const [amount, setAmount] = useState(savedAmount);
42
+ const [currency, setCurrency] = useState(savedCurrency);
43
+ useEffect(() => {
44
+ setAmount(savedAmount);
45
+ setCurrency(savedCurrency);
46
+ }, [savedAmount, savedCurrency]);
47
+ const commit = (nextAmount, nextCurrency) => {
48
+ if (nextAmount.trim() === savedAmount && nextCurrency === savedCurrency)
49
+ return;
50
+ const money = moneyOf(nextAmount, nextCurrency);
51
+ if (money === undefined)
52
+ return onInvalid();
53
+ // No amount yet: the currency is kept here until there's an amount to save in it.
54
+ if (money === null && !value)
55
+ return;
56
+ onCommit(money);
57
+ };
58
+ return (_jsx(MoneyInput, { id: id, amount: amount, currencyCode: currency, onAmount: setAmount, onCurrency: (next) => {
59
+ setCurrency(next);
60
+ commit(amount, next);
61
+ }, onCommit: () => commit(amount, currency), text: text }));
62
+ }
63
+ /**
64
+ * The chosen contact's email and telephone, read from their record and saved there as they change: on the person, not
65
+ * the lead or deal, so every record with them as contact sees the change.
66
+ */
67
+ function ContactDetailsFields({ id, contact, name, access, text, }) {
68
+ const words = withText(text);
69
+ const [details, setDetails] = useState();
70
+ const [error, setError] = useState();
71
+ useEffect(() => {
72
+ let current = true;
73
+ setDetails(undefined);
74
+ setError(undefined);
75
+ access
76
+ .load(contact)
77
+ .then((loaded) => current && setDetails(loaded))
78
+ .catch(() => current && setError(words.contactDetailsUnavailable));
79
+ return () => {
80
+ current = false;
81
+ };
82
+ }, [access, contact, words.contactDetailsUnavailable]);
83
+ const save = async (changes) => {
84
+ setError(undefined);
85
+ try {
86
+ setDetails(await access.save(contact, changes));
87
+ }
88
+ catch (failure) {
89
+ setError(`${words.saveFailed} ${failure instanceof Error ? failure.message : ''}`.trim());
90
+ }
91
+ };
92
+ return (_jsxs("fieldset", { className: "grid gap-3 border-s-2 ps-3", "aria-describedby": error ? `${id}-error` : undefined, children: [_jsx("legend", { className: name ? 'text-sm font-medium' : 'sr-only', children: name ?? words.contactDetails }), _jsx(Field, { id: `${id}-email`, label: name ? `${name}: ${words.email}` : words.contactEmail, children: _jsx(CommitInput, { id: `${id}-email`, type: "email", autoComplete: "off", value: details?.email ?? '', disabled: !details, onCommit: (email) => void save({ email }) }) }), _jsx(Field, { id: `${id}-telephone`, label: name ? `${name}: ${words.telephone}` : words.contactTelephone, children: _jsx(CommitInput, { id: `${id}-telephone`, type: "tel", autoComplete: "off", value: details?.telephone ?? '', disabled: !details, onCommit: (telephone) => void save({ telephone }) }) }), error && (_jsx("p", { id: `${id}-error`, role: "alert", className: "text-destructive text-sm", children: error }))] }));
93
+ }
94
+ /** Statuses a lead can be set to: qualified comes from converting it. */
95
+ const SETTABLE_STATUSES = ['NEW', 'CONTACTED'];
96
+ /**
97
+ * An open lead's fields, each saved as it changes: title, status, company, contact, source, value and assignee. The
98
+ * company and contact can be added: "Add a new ..." opens a step for its details, and saving it saves the lead.
99
+ */
100
+ function LeadFields({ lead, names, companies, people, team, onChange, saving, contactDetails, text, }) {
101
+ const words = withText(text);
102
+ const id = useId();
103
+ const [step, setStep] = useState('fields');
104
+ const [error, setError] = useState();
105
+ const save = async (changes) => {
106
+ setError(undefined);
107
+ try {
108
+ await onChange(changes);
109
+ }
110
+ catch (failure) {
111
+ setError(`${words.saveFailed} ${failure instanceof Error ? failure.message : ''}`.trim());
112
+ }
113
+ };
114
+ if (step === 'company')
115
+ return (_jsx(NewCompanyStep, { framed: false, text: text, onBack: () => setStep('fields'), onUse: async (name) => {
116
+ // A new company replaces the lead's, so the link is cleared for it to be made.
117
+ await onChange({ contactCompany: null }, { companyName: name });
118
+ setStep('fields');
119
+ } }));
120
+ if (step === 'contact')
121
+ return (_jsx(NewContactStep, { framed: false, text: text, onBack: () => setStep('fields'), onUse: async (contact) => {
122
+ await onChange({}, { contact });
123
+ setStep('fields');
124
+ } }));
125
+ const link = (urn) => (urn ? { urn } : null);
126
+ return (_jsxs("div", { className: "grid gap-3", children: [_jsx(Field, { id: `${id}-title`, label: words.title, children: _jsx(CommitInput, { id: `${id}-title`, value: lead.title, onCommit: (title) => title && void save({ title }) }) }), _jsx(Field, { id: `${id}-status`, label: words.status, children: _jsxs(Select, { value: lead.status, onValueChange: (status) => void save({ status: status }), children: [_jsx(SelectTrigger, { id: `${id}-status`, className: "w-full", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: [...new Set([...SETTABLE_STATUSES, lead.status])].map((status) => (_jsx(SelectItem, { value: status, disabled: !SETTABLE_STATUSES.includes(status), children: LEAD_STATUS_LABELS[status] }, status))) })] }) }), _jsx(Field, { id: `${id}-company`, label: words.company, children: _jsx(ChoiceSelect, { id: `${id}-company`, value: lead.contactCompany?.urn ?? '', onChange: (urn) => void save({ contactCompany: link(urn) }), choices: companies, none: words.noCompany, add: { label: words.addCompany, onAdd: () => setStep('company') }, named: (urn) => companyNameOf(names, urn), text: text }) }), _jsx(Field, { id: `${id}-contact`, label: words.contact, children: _jsx(ChoiceSelect, { id: `${id}-contact`, value: lead.contactIdentity?.urn ?? '', onChange: (urn) => void save({ contactIdentity: link(urn) }), choices: people, none: words.noContact, add: { label: words.addContact, onAdd: () => setStep('contact') }, named: (urn) => personNameOf(names, urn), text: text }) }), lead.contactIdentity && contactDetails && (_jsx(ContactDetailsFields, { id: `${id}-contact-details`, contact: lead.contactIdentity.urn, access: contactDetails, text: text })), _jsx(Field, { id: `${id}-source`, label: words.source, children: _jsxs(Select, { value: lead.source, onValueChange: (source) => void save({ source: source }), children: [_jsx(SelectTrigger, { id: `${id}-source`, className: "w-full", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: LEAD_SOURCES.map((source) => (_jsx(SelectItem, { value: source, children: SOURCE_LABELS[source] }, source))) })] }) }), _jsx(Field, { id: `${id}-value`, label: words.value, children: _jsx(CommitMoney, { id: `${id}-value`, value: lead.targetValue, onCommit: (targetValue) => void save({ targetValue }), onInvalid: () => setError(words.invalidAmount), text: text }) }), _jsx(Field, { id: `${id}-assignee`, label: words.assignee, children: _jsx(ChoiceSelect, { id: `${id}-assignee`, value: lead.assignee?.urn ?? '', onChange: (urn) => void save({ assignee: link(urn) }), choices: team, none: words.unassigned, named: (urn) => personNameOf(names, urn), text: text }) }), _jsx("p", { "aria-live": "polite", className: "text-muted-foreground text-xs", children: saving ? words.saving : '' }), error && (_jsx("p", { role: "alert", className: "text-destructive text-sm", children: error }))] }));
127
+ }
128
+ /**
129
+ * A lead's details. While it's open, its fields can be changed (with `onChange`), it can be converted ("Convert to
130
+ * deal", where the new client company's name can be corrected) and marked unqualified with why. Once unqualified it
131
+ * can be reopened.
132
+ */
133
+ export function LeadDetail({ lead, names, companies = [], people = [], team = [], onChange, onConvert, onSetOutcome, converting, contactDetails, sample, text, }) {
134
+ const words = withText(text);
135
+ const id = useId();
136
+ const [companyName, setCompanyName] = useState('');
137
+ const [unqualifying, setUnqualifying] = useState(false);
138
+ const [reason, setReason] = useState('');
139
+ const outcome = leadOutcome(lead);
140
+ const open = outcome === 'IN_PROGRESS';
141
+ const editable = open && onChange !== undefined;
142
+ const submit = (event) => {
143
+ event.preventDefault();
144
+ onConvert?.(lead, lead.contactCompany ? {} : { companyName: companyName.trim() });
145
+ };
146
+ return (_jsx(CrmCard, { title: lead.title, sample: sample, text: text, children: _jsxs("div", { className: "grid gap-5", children: [editable && (_jsx(LeadFields, { lead: lead, names: names, companies: companies, people: people, team: team, onChange: onChange, saving: converting, contactDetails: contactDetails, text: text })), _jsx(DetailList, { items: [
147
+ ...(editable ? [] : [{ label: words.status, value: _jsx(LeadStatusBadge, { lead: lead }) }]),
148
+ // A lead has no close time of its own: it was last changed when it closed.
149
+ ...(!open ? [{ label: words.closed, value: formatDate(lead.updatedTimestamp) }] : []),
150
+ ...(lead.closedReason ? [{ label: words.unqualifiedReason, value: lead.closedReason }] : []),
151
+ ...(editable
152
+ ? []
153
+ : [
154
+ { label: words.contact, value: personNameOf(names, lead.contactIdentity?.urn) ?? '-' },
155
+ { label: words.company, value: leadCompany(lead, names) || '-' },
156
+ { label: words.source, value: SOURCE_LABELS[lead.source] },
157
+ { label: words.value, value: formatMaybeMoney(lead.targetValue) },
158
+ { label: words.assignee, value: personNameOf(names, lead.assignee?.urn) ?? '-' },
159
+ ]),
160
+ { label: words.created, value: formatDate(lead.createdTimestamp) },
161
+ ] }), open && onConvert && (_jsxs("form", { onSubmit: submit, className: "grid gap-3", "aria-labelledby": `${id}-title`, children: [_jsxs("div", { className: "grid gap-1", children: [_jsx("h3", { id: `${id}-title`, className: "text-sm font-semibold", children: words.convert }), _jsx("p", { className: "text-muted-foreground text-sm", children: words.convertSummary })] }), !lead.contactCompany && (_jsxs("div", { className: "grid gap-1.5", children: [_jsx(Label, { htmlFor: `${id}-company`, children: words.companyName }), _jsx(Input, { id: `${id}-company`, value: companyName, onChange: (event) => setCompanyName(event.target.value), "aria-describedby": `${id}-company-hint` }), _jsx("p", { id: `${id}-company-hint`, className: "text-muted-foreground text-xs", children: words.companyNameHint })] })), _jsx("div", { children: _jsx(Button, { type: "submit", size: "sm", disabled: converting ?? false, children: converting ? words.converting : words.convert }) })] })), open && onSetOutcome && !unqualifying && (_jsx("div", { children: _jsx(Button, { type: "button", size: "sm", variant: "outline", onClick: () => setUnqualifying(true), children: words.markUnqualified }) })), open && onSetOutcome && unqualifying && (_jsxs("form", { className: "grid gap-2", onSubmit: (event) => {
162
+ event.preventDefault();
163
+ setUnqualifying(false);
164
+ onSetOutcome(lead, 'CLOSED', reason);
165
+ }, children: [_jsx(Label, { htmlFor: `${id}-reason`, children: words.unqualifiedReason }), _jsx(Input, { id: `${id}-reason`, value: reason, onChange: (event) => setReason(event.target.value) }), _jsxs("div", { className: "flex gap-2", children: [_jsx(Button, { type: "submit", size: "sm", children: words.markUnqualified }), _jsx(Button, { type: "button", size: "sm", variant: "ghost", onClick: () => setUnqualifying(false), children: words.cancel })] })] })), outcome === 'CLOSED' && onSetOutcome && (_jsx("div", { children: _jsx(Button, { type: "button", size: "sm", variant: "outline", onClick: () => onSetOutcome(lead, 'IN_PROGRESS'), children: words.reopen }) }))] }) }));
166
+ }
167
+ const OUTCOME_LABELS = {
168
+ OPEN: 'outcomeOpen',
169
+ WON: 'outcomeWon',
170
+ LOST: 'outcomeLost',
171
+ };
172
+ /**
173
+ * Wins, loses or reopens a deal. Its outcome is on the deal, not its stage, as workflows are only progress. Open and
174
+ * won apply at once; lost asks why first.
175
+ */
176
+ export function OutcomeControl({ deal, onSetOutcome, disabled, text, }) {
177
+ const words = withText(text);
178
+ const id = useId();
179
+ const [losing, setLosing] = useState(false);
180
+ const [reason, setReason] = useState(deal.lostReason ?? '');
181
+ const outcome = dealOutcome(deal);
182
+ return (_jsxs("div", { className: "grid gap-2", children: [_jsxs(Select, { value: losing ? 'LOST' : outcome, disabled: disabled ?? false, onValueChange: (value) => {
183
+ if (value === 'LOST')
184
+ return setLosing(true);
185
+ setLosing(false);
186
+ onSetOutcome(deal, value);
187
+ }, children: [_jsx(SelectTrigger, { size: "sm", "aria-label": `${words.outcome}: ${deal.title}`, children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: ['OPEN', 'WON', 'LOST'].map((value) => (_jsx(SelectItem, { value: value, children: words[OUTCOME_LABELS[value]] }, value))) })] }), losing && (_jsxs("form", { className: "grid gap-2", onSubmit: (event) => {
188
+ event.preventDefault();
189
+ setLosing(false);
190
+ onSetOutcome(deal, 'LOST', reason);
191
+ }, children: [_jsx(Label, { htmlFor: `${id}-reason`, children: words.lostReason }), _jsx(Input, { id: `${id}-reason`, value: reason, onChange: (event) => setReason(event.target.value) }), _jsxs("div", { className: "flex gap-2", children: [_jsx(Button, { type: "submit", size: "sm", children: words.markLost }), _jsx(Button, { type: "button", size: "sm", variant: "ghost", onClick: () => setLosing(false), children: words.cancel })] })] }))] }));
192
+ }
193
+ /**
194
+ * A deal's fields, each saved as it changes: title, workflow and stage, companies and contacts (found by searching, each
195
+ * contact with their email and telephone), value, probability, expected close and assignee.
196
+ */
197
+ function DealFields({ deal, pipelines, names, companies, people, team, onChange, onMove, saving, contactDetails, text, }) {
198
+ const words = withText(text);
199
+ const id = useId();
200
+ const [error, setError] = useState();
201
+ const save = async (changes) => {
202
+ setError(undefined);
203
+ try {
204
+ await onChange(changes);
205
+ }
206
+ catch (failure) {
207
+ setError(`${words.saveFailed} ${failure instanceof Error ? failure.message : ''}`.trim());
208
+ }
209
+ };
210
+ return (_jsxs("div", { className: "grid gap-3", children: [_jsx(Field, { id: `${id}-title`, label: words.title, children: _jsx(CommitInput, { id: `${id}-title`, value: deal.title, onCommit: (title) => title && void save({ title }) }) }), _jsx(PipelineStageFields, { id: id, pipelines: pipelines, stage: deal.workflowStage?.urn ?? '', onStage: (stage) => (onMove ? onMove(deal, stage) : void save({ workflowStage: { urn: stage.urn } })), disabled: saving, text: text }), _jsx(Field, { id: `${id}-companies`, label: words.companies, children: _jsx(ChoiceCombobox, { id: `${id}-companies`, value: deal.contactCompanies.map((company) => company.urn), onChange: (urns) => void save({ contactCompanies: urns.map((urn) => ({ urn })) }), choices: companies, named: (urn) => companyNameOf(names, urn), placeholder: words.searchCompanies, text: text }) }), _jsx(Field, { id: `${id}-contacts`, label: words.contacts, children: _jsx(ChoiceCombobox, { id: `${id}-contacts`, value: deal.contactIdentities.map((contact) => contact.urn), onChange: (urns) => void save({ contactIdentities: urns.map((urn) => ({ urn })) }), choices: people, named: (urn) => personNameOf(names, urn), placeholder: words.searchContacts, text: text }) }), contactDetails &&
211
+ deal.contactIdentities.map((contact, index) => (_jsx(ContactDetailsFields, { id: `${id}-contact-${index}`, contact: contact.urn,
212
+ // Each contact's fields are named for them when there are several.
213
+ name: deal.contactIdentities.length > 1 ? (personNameOf(names, contact.urn) ?? words.unnamed) : undefined, access: contactDetails, text: text }, contact.urn))), _jsx(Field, { id: `${id}-value`, label: words.value, children: _jsx(CommitMoney, { id: `${id}-value`, value: deal.targetValue, onCommit: (targetValue) => void save({ targetValue }), onInvalid: () => setError(words.invalidAmount), text: text }) }), _jsx(Field, { id: `${id}-probability`, label: `${words.probability} (%)`, children: _jsx(CommitInput, { id: `${id}-probability`, inputMode: "decimal", value: deal.probability === null || deal.probability === undefined ? '' : String(deal.probability), onCommit: (typed) => {
214
+ const chance = typed ? Number(typed) : null;
215
+ if (chance !== null && !(chance >= 0 && chance <= 100))
216
+ return setError(words.invalidProbability);
217
+ void save({ probability: chance });
218
+ } }) }), _jsx(Field, { id: `${id}-close`, label: words.expectedClose, children: _jsx(Input, { id: `${id}-close`, type: "date", value: deal.targetCloseTimestamp?.slice(0, 10) ?? '', onChange: (event) => void save({ targetCloseTimestamp: event.target.value ? `${event.target.value}T00:00:00` : null }) }) }), _jsx(Field, { id: `${id}-assignee`, label: words.assignee, children: _jsx(ChoiceSelect, { id: `${id}-assignee`, value: deal.assignee?.urn ?? '', onChange: (urn) => void save({ assignee: urn ? { urn } : null }), choices: team, none: words.unassigned, named: (urn) => personNameOf(names, urn), text: text }) }), _jsx("p", { "aria-live": "polite", className: "text-muted-foreground text-xs", children: saving ? words.saving : '' }), error && (_jsx("p", { role: "alert", className: "text-destructive text-sm", children: error }))] }));
219
+ }
220
+ /**
221
+ * A deal's details: with `onChange`, its fields can be edited, saved as they change; its outcome is set with
222
+ * `onSetOutcome`. Without them, read only.
223
+ */
224
+ export function DealDetail({ deal, pipelines, names, companies = [], people = [], team = [], onChange, onMove, onSetOutcome, saving, contactDetails, sample, text, }) {
225
+ const words = withText(text);
226
+ const pipeline = pipelineOf(deal, pipelines) ?? pipelines[0];
227
+ const stage = pipeline && (stageOf(deal, pipeline) ?? orderedStages(pipeline)[0]);
228
+ const outcome = dealOutcome(deal);
229
+ const probability = dealProbability(deal);
230
+ const outcomeItem = {
231
+ label: words.outcome,
232
+ value: onSetOutcome ? (_jsx(OutcomeControl, { deal: deal, onSetOutcome: onSetOutcome, disabled: saving, text: text }, deal.urn)) : (_jsx(OutcomeBadge, { outcome: outcome, label: words[OUTCOME_LABELS[outcome]] })),
233
+ };
234
+ if (onChange)
235
+ return (_jsx(CrmCard, { title: deal.title, sample: sample, text: text, children: _jsxs("div", { className: "grid gap-5", children: [_jsx(DealFields, { deal: deal, pipelines: pipelines, names: names, companies: companies, people: people, team: team, onChange: onChange, onMove: onMove, saving: saving, contactDetails: contactDetails, text: text }), _jsx(DetailList, { items: [
236
+ outcomeItem,
237
+ ...(deal.closeTimestamp ? [{ label: words.closed, value: formatDate(deal.closeTimestamp) }] : []),
238
+ ...(deal.lostReason ? [{ label: words.lostReason, value: deal.lostReason }] : []),
239
+ { label: words.created, value: formatDate(deal.createdTimestamp) },
240
+ ] })] }) }));
241
+ return (_jsx(CrmCard, { title: deal.title, sample: sample, text: text, children: _jsx(DetailList, { items: [
242
+ {
243
+ label: words.stage,
244
+ value: onMove && pipeline ? (_jsx(StageSelect, { deal: deal, pipeline: pipeline, onMove: onMove, disabled: saving, text: text })) : ((stage?.name ?? '-')),
245
+ },
246
+ outcomeItem,
247
+ {
248
+ label: words.company,
249
+ value: deal.contactCompanies.map((company) => companyNameOf(names, company.urn) ?? words.unnamed).join(', ') ||
250
+ '-',
251
+ },
252
+ {
253
+ label: words.contact,
254
+ value: deal.contactIdentities.map((contact) => personNameOf(names, contact.urn) ?? words.unnamed).join(', ') ||
255
+ '-',
256
+ },
257
+ { label: words.value, value: formatMaybeMoney(deal.targetValue) },
258
+ { label: words.probability, value: probability === undefined ? '-' : `${probability}%` },
259
+ {
260
+ label: deal.closeTimestamp ? words.closed : words.expectedClose,
261
+ value: formatDate(deal.closeTimestamp ?? deal.targetCloseTimestamp),
262
+ },
263
+ ...(deal.lostReason ? [{ label: words.lostReason, value: deal.lostReason }] : []),
264
+ { label: words.assignee, value: personNameOf(names, deal.assignee?.urn) ?? '-' },
265
+ { label: words.created, value: formatDate(deal.createdTimestamp) },
266
+ ] }) }));
267
+ }
268
+ //# sourceMappingURL=Details.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Details.js","sourceRoot":"","sources":["../../src/react/Details.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAkC,MAAM,OAAO,CAAC;AAGnF,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC3F,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAYlG,OAAO,EACL,YAAY,EACZ,KAAK,EACL,OAAO,EACP,UAAU,EACV,cAAc,EACd,cAAc,EACd,mBAAmB,GAEpB,MAAM,YAAa,CAAC;AACrB,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAsB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAkB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,gBAAgB,EAAE,YAAY,EAAiB,MAAM,aAAa,CAAC;AACvG,OAAO,EAAE,WAAW,EAAE,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CAAC;AACJ,CAAC"}
@@ -0,0 +1,190 @@
1
+ import { type RefLike } from '@baack-software/baack-ts-tasks';
2
+ import { type ReactNode } from 'react';
3
+ import type { DealInput, InvoiceInput, LeadInput } from '../backend.ts';
4
+ import type { NewInvoiceOptions, NewLeadOptions } from '../crm-client.ts';
5
+ import type { Deal, Money, NewContact, Pipeline, PipelineStage, Taxability } from '../types.ts';
6
+ import { type CrmText } from './text.ts';
7
+ /**
8
+ * A record the forms can link to, named: one of the host's customers, or one of its people. `detail`, such as a
9
+ * person's email address, tells apart records with the same name.
10
+ */
11
+ export interface CrmChoice {
12
+ urn: string;
13
+ name: string;
14
+ detail?: string | undefined;
15
+ /** More to find it by when searching, such as a person's other emails and telephone numbers. */
16
+ keywords?: readonly string[] | undefined;
17
+ }
18
+ /** A company the forms can link a record to: the host's customers. */
19
+ export type CrmCompanyChoice = CrmChoice;
20
+ /** A person the forms can link a record to, as its contact or assignee: the host's people. */
21
+ export type CrmPersonChoice = CrmChoice;
22
+ interface FormProps {
23
+ /** The company whose CRM this is. */
24
+ owner: RefLike;
25
+ text?: Partial<CrmText> | undefined;
26
+ }
27
+ /** An invoice line as the new invoice form makes it: its unit price in major units, its price and tax as money. */
28
+ export interface InvoiceLineDraft {
29
+ description: string;
30
+ quantity: number;
31
+ unitPrice: number;
32
+ price: Money;
33
+ tax: Money;
34
+ itemCode?: string;
35
+ discountRate?: number;
36
+ discountPrice?: Money;
37
+ taxability?: Taxability;
38
+ taxName?: string;
39
+ }
40
+ /**
41
+ * An amount typed in major units (120.00, or 1,500.00 with separators) as minor units, or undefined when it isn't a
42
+ * number of at least zero.
43
+ */
44
+ export declare function minorOrUndefined(amount: string, currencyCode: string): number | undefined;
45
+ export declare function Field({ id, label, hint, children, }: {
46
+ id: string;
47
+ label: string;
48
+ hint?: string | undefined;
49
+ children: ReactNode;
50
+ }): import("react").JSX.Element;
51
+ /**
52
+ * A record to link: none, one of `choices`, or, with `add`, a new one made by the step `add` opens. A new one waiting
53
+ * to be made shows as chosen (`pending`, its name). A linked record missing from `choices` is still shown, named by
54
+ * `named` or by the end of its URN.
55
+ */
56
+ export declare function ChoiceSelect({ id, value, onChange, choices, none, add, pending, named, disabled, describedBy, text, }: {
57
+ id: string;
58
+ value: string;
59
+ onChange: (urn: string) => void;
60
+ choices: readonly CrmChoice[];
61
+ none: string;
62
+ add?: {
63
+ label: string;
64
+ onAdd: () => void;
65
+ } | undefined;
66
+ pending?: string | undefined;
67
+ named?: ((urn: string) => string | undefined) | undefined;
68
+ disabled?: boolean | undefined;
69
+ describedBy?: string | undefined;
70
+ text?: Partial<CrmText> | undefined;
71
+ }): import("react").JSX.Element;
72
+ /** The currencies offered for an amount, with the one it's already in when that's another. */
73
+ export declare const CURRENCIES: readonly string[];
74
+ /**
75
+ * An amount of money: a currency select joined to the amount, typed in major units (1,500.00). The amount's input
76
+ * has `id`, so a field's label names it; the currency select is named by `currencyLabel`.
77
+ */
78
+ export declare function MoneyInput({ id, amount, currencyCode, onAmount, onCurrency, onCommit, describedBy, text, }: {
79
+ id: string;
80
+ amount: string;
81
+ currencyCode: string;
82
+ onAmount: (amount: string) => void;
83
+ onCurrency: (currencyCode: string) => void;
84
+ /** Called when the amount loses focus or Enter is pressed, for fields that save as they change. */
85
+ onCommit?: (() => void) | undefined;
86
+ describedBy?: string | undefined;
87
+ text?: Partial<CrmText> | undefined;
88
+ }): import("react").JSX.Element;
89
+ /**
90
+ * Money typed into a `MoneyInput`, for saving: the money, null for no amount, or undefined when the amount isn't a
91
+ * number of at least zero.
92
+ */
93
+ export declare function moneyOf(amount: string, currencyCode: string): Money | null | undefined;
94
+ /**
95
+ * A new client company, as a step of a lead's form: its name, made when the lead is saved. `Use this` goes back to
96
+ * the lead with it chosen.
97
+ */
98
+ export declare function NewCompanyStep({ initial, onUse, onBack, framed, text, }: {
99
+ initial?: string | undefined;
100
+ /** False inside another card, such as an open lead's. */
101
+ framed?: boolean | undefined;
102
+ onUse: (name: string) => Promise<unknown> | void;
103
+ onBack: () => void;
104
+ text?: Partial<CrmText> | undefined;
105
+ }): import("react").JSX.Element;
106
+ /**
107
+ * A new person to be a lead's contact, as a step of the lead's form: their given and family name and email, made
108
+ * when the lead is saved. `Use this` goes back to the lead with them chosen.
109
+ */
110
+ export declare function NewContactStep({ initial, onUse, onBack, framed, text, }: {
111
+ initial?: NewContact | undefined;
112
+ /** False inside another card, such as an open lead's. */
113
+ framed?: boolean | undefined;
114
+ onUse: (contact: NewContact) => Promise<unknown> | void;
115
+ onBack: () => void;
116
+ text?: Partial<CrmText> | undefined;
117
+ }): import("react").JSX.Element;
118
+ /**
119
+ * A new person, such as one of a customer company's people: their given and family name and email. `onCreate` makes
120
+ * them (`CrmStore.createContact`); the form stays as it was if that fails, so it can be sent again.
121
+ */
122
+ export declare function NewContactForm({ onCreate, text, }: {
123
+ onCreate: (contact: NewContact) => Promise<unknown>;
124
+ text?: Partial<CrmText> | undefined;
125
+ }): import("react").JSX.Element;
126
+ /** A contact's name for showing while they're waiting to be made. */
127
+ export declare const draftName: (contact: NewContact) => string;
128
+ /**
129
+ * A new lead: its title, source, value, assignee, and its company and contact person (a lead holds its business by
130
+ * its company). Each is chosen from the host's, or added: "Add a new ..." opens a step for its details in the same
131
+ * form, and it's made when the lead is saved.
132
+ */
133
+ export declare function NewLeadForm({ owner, companies, people, team, currencyCode, onCreate, text, }: FormProps & {
134
+ companies?: readonly CrmCompanyChoice[] | undefined;
135
+ /** People to choose as the contact: the host's customers' people. */
136
+ people?: readonly CrmPersonChoice[] | undefined;
137
+ /** People to assign the lead to: the host's team. */
138
+ team?: readonly CrmPersonChoice[] | undefined;
139
+ currencyCode?: string;
140
+ onCreate: (input: LeadInput, options: NewLeadOptions) => Promise<unknown>;
141
+ }): import("react").JSX.Element;
142
+ /**
143
+ * Where a deal is: its workflow (any workflow can be a pipeline) and its stage in it. Choosing a workflow moves the
144
+ * deal to that workflow's first stage.
145
+ */
146
+ export declare function PipelineStageFields({ id, pipelines, stage, onStage, disabled, text, }: {
147
+ id: string;
148
+ pipelines: readonly Pipeline[];
149
+ /** The deal's stage URN, or "" for none. */
150
+ stage: string;
151
+ onStage: (stage: PipelineStage) => void;
152
+ disabled?: boolean | undefined;
153
+ text?: Partial<CrmText> | undefined;
154
+ }): import("react").JSX.Element;
155
+ /**
156
+ * A new deal that didn't start as a lead: its title, companies and contacts (found by searching), value, workflow and stage (the first
157
+ * workflow's first stage, to start with), expected close, probability and assignee.
158
+ */
159
+ export declare function NewDealForm({ owner, pipelines, companies, people, team, currencyCode, now, onCreate, text, }: FormProps & {
160
+ /** The workflows a deal can be in, the first chosen to start with. */
161
+ pipelines: readonly Pipeline[];
162
+ companies?: readonly CrmCompanyChoice[] | undefined;
163
+ /** People to choose as the contact: the host's customers' people. */
164
+ people?: readonly CrmPersonChoice[] | undefined;
165
+ /** People to assign the deal to: the host's team. */
166
+ team?: readonly CrmPersonChoice[] | undefined;
167
+ currencyCode?: string;
168
+ now?: Date;
169
+ onCreate: (input: DealInput) => Promise<unknown>;
170
+ }): import("react").JSX.Element;
171
+ /**
172
+ * A new invoice: who pays it (the remitter) and who's paid (the recipient), each a company, a person or both, found by
173
+ * searching; a company not in Baack yet can be added by name. The recipient starts as the one used last, else the
174
+ * owner. An invoice can be a sale (a customer pays the owner) or a cost (the owner pays a supplier). Its amount is
175
+ * lines, each opening into all its fields, or a total including tax, with a tax rate; then its dates, status, and
176
+ * the deal it's for, if any.
177
+ */
178
+ export declare function NewInvoiceForm({ owner, companies, people, deals, currencyCode: defaultCurrency, now, onCreate, text, }: FormProps & {
179
+ /** Companies either party can be: the host's own companies (the owner and its child companies) and customers. */
180
+ companies?: readonly CrmCompanyChoice[] | undefined;
181
+ /** People either party can be. */
182
+ people?: readonly CrmPersonChoice[] | undefined;
183
+ /** Deals the invoice can be raised for. */
184
+ deals?: readonly Deal[];
185
+ currencyCode?: string;
186
+ now?: Date;
187
+ onCreate: (input: InvoiceInput, lines: InvoiceLineDraft[], options: NewInvoiceOptions) => Promise<unknown>;
188
+ }): import("react").JSX.Element;
189
+ export {};
190
+ //# sourceMappingURL=Forms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Forms.d.ts","sourceRoot":"","sources":["../../src/react/Forms.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAEnE,OAAO,EAAmC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAK1E,OAAO,KAAK,EACV,IAAI,EAGJ,KAAK,EACL,UAAU,EACV,QAAQ,EACR,aAAa,EACb,UAAU,EACX,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAY,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAOnD;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,gGAAgG;IAChG,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;CAC1C;AAED,sEAAsE;AACtE,MAAM,MAAM,gBAAgB,GAAG,SAAS,CAAC;AAEzC,8FAA8F;AAC9F,MAAM,MAAM,eAAe,GAAG,SAAS,CAAC;AAExC,UAAU,SAAS;IACjB,qCAAqC;IACrC,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;CACrC;AAED,mHAAmH;AACnH,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,KAAK,CAAC;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