@powerhousedao/design-system 1.8.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ import { GroupTransactionFormInputs } from '../../types';
2
+ import { Control } from 'react-hook-form';
3
+ export declare function EntryTimeLabel({ control, }: {
4
+ control: Control<GroupTransactionFormInputs>;
5
+ }): string | null;
@@ -0,0 +1,12 @@
1
+ import { useWatch as r } from "react-hook-form";
2
+ import { formatDateForDisplay as n } from "../../utils/date.js";
3
+ function m({
4
+ control: t
5
+ }) {
6
+ const e = r({ control: t, name: "entryTime" });
7
+ return e ? n(new Date(e), !0, !0) : null;
8
+ }
9
+ export {
10
+ m as EntryTimeLabel
11
+ };
12
+ //# sourceMappingURL=entry-time-label.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry-time-label.js","sources":["../../../../src/rwa/components/inputs/entry-time-label.tsx"],"sourcesContent":["import { GroupTransactionFormInputs } from \"@/rwa/types\";\nimport { formatDateForDisplay } from \"@/rwa/utils\";\nimport { Control, useWatch } from \"react-hook-form\";\n\nexport function EntryTimeLabel({\n control,\n}: {\n control: Control<GroupTransactionFormInputs>;\n}) {\n const value = useWatch({ control, name: \"entryTime\" });\n return value ? formatDateForDisplay(new Date(value), true, true) : null;\n}\n"],"names":["EntryTimeLabel","control","value","useWatch","formatDateForDisplay"],"mappings":";;AAIO,SAASA,EAAe;AAAA,EAC7B,SAAAC;AACF,GAEG;AACD,QAAMC,IAAQC,EAAS,EAAE,SAAAF,GAAS,MAAM,aAAa;AAC9C,SAAAC,IAAQE,EAAqB,IAAI,KAAKF,CAAK,GAAG,IAAM,EAAI,IAAI;AACrE;"}
@@ -1,10 +1,10 @@
1
1
  import { FormInputsByTableName, Operation, TableItemType, TableName } from '..';
2
- import { ReactElement } from 'react';
2
+ import { ReactElement, ReactNode } from 'react';
3
3
  import { Control, FormState, UseFormRegister, UseFormWatch } from 'react-hook-form';
4
4
  type Input = {
5
5
  label: string;
6
6
  Input: () => string | React.JSX.Element;
7
- inputLabel?: string | null;
7
+ inputLabel?: ReactNode | null;
8
8
  };
9
9
  type Props = {
10
10
  tableName: TableName;
@@ -1,66 +1,67 @@
1
- import { jsx as s, jsxs as F, Fragment as v } from "react/jsx-runtime";
2
- import { useCallback as B, useMemo as $ } from "react";
3
- import { CashBalanceChange as z } from "../components/table/transactions/cash-balance-change.js";
1
+ import { jsxs as F, Fragment as g, jsx as s } from "react/jsx-runtime";
2
+ import { useCallback as D, useMemo as k } from "react";
3
+ import { CashBalanceChange as B } from "../components/table/transactions/cash-balance-change.js";
4
+ import { EntryTimeLabel as $ } from "../components/inputs/entry-time-label.js";
5
+ import { FeeTransactionsTable as z } from "../components/table/transactions/fee-transactions-table.js";
4
6
  import { UnitPrice as Y } from "../components/table/transactions/unit-price.js";
5
7
  import { TransactionReference as W } from "../components/table/transactions/transaction-reference.js";
6
- import { FeeTransactionsTable as j } from "../components/table/transactions/fee-transactions-table.js";
7
- import { useEditorContext as G } from "../context/editor-context.js";
8
- import { useModal as H } from "../components/modal/modal-manager.js";
9
- import { tableNames as g } from "../constants/names.js";
10
- import { feesTransactions as Q, assetGroupTransactions as Z, allGroupTransactionTypes as X, groupTransactionTypeLabels as J } from "../constants/transactions.js";
11
- import { makeFixedIncomeOptionLabel as K } from "../utils/form.js";
12
- import { RWATableSelect as f } from "../components/inputs/select.js";
13
- import { formatDateForDisplay as R } from "../utils/date.js";
14
- import { RWANumberInput as V } from "../components/inputs/number-input.js";
8
+ import { useEditorContext as j } from "../context/editor-context.js";
9
+ import { useModal as G } from "../components/modal/modal-manager.js";
10
+ import { tableNames as f } from "../constants/names.js";
11
+ import { feesTransactions as H, assetGroupTransactions as Q, allGroupTransactionTypes as Z, groupTransactionTypeLabels as X } from "../constants/transactions.js";
12
+ import { makeFixedIncomeOptionLabel as J } from "../utils/form.js";
15
13
  import { RWATableTextInput as u } from "../components/inputs/text-input.js";
14
+ import { formatDateForDisplay as K } from "../utils/date.js";
15
+ import { RWATableSelect as y } from "../components/inputs/select.js";
16
+ import { RWANumberInput as R } from "../components/inputs/number-input.js";
16
17
  import { handleTableDatum as T } from "../utils/table.js";
17
- function ve(_) {
18
+ function ge(V) {
18
19
  const {
19
20
  tableName: A,
20
21
  operation: i,
21
22
  formState: p,
22
23
  tableItem: E,
23
- register: I,
24
+ register: b,
24
25
  watch: q,
25
- control: y
26
- } = _, {
27
- fixedIncomeTypes: w,
28
- spvs: C,
26
+ control: h
27
+ } = V, {
28
+ fixedIncomeTypes: C,
29
+ spvs: w,
29
30
  serviceProviderFeeTypes: S,
30
31
  accounts: P,
31
32
  fixedIncomes: M
32
- } = G(), { showModal: x } = H(), b = B(
33
- (a) => () => {
34
- x("createItem", { tableName: a });
33
+ } = j(), { showModal: x } = G(), I = D(
34
+ (r) => () => {
35
+ x("createItem", { tableName: r });
35
36
  },
36
37
  [x]
37
38
  );
38
- return $(() => {
39
+ return k(() => {
39
40
  switch (A) {
40
- case g.ASSET: {
41
- const a = E, c = I, r = p, { errors: t } = r, o = y, d = i !== "create" && a ? [
41
+ case f.ASSET: {
42
+ const r = E, c = b, e = p, { errors: t } = e, o = h, d = i !== "create" && r ? [
42
43
  {
43
44
  label: "Notional",
44
- Input: () => /* @__PURE__ */ s(v, { children: T(a.notional) })
45
+ Input: () => /* @__PURE__ */ s(g, { children: T(r.notional) })
45
46
  },
46
47
  {
47
48
  label: "Purchase Date",
48
- Input: () => /* @__PURE__ */ s(v, { children: T(a.purchaseDate) })
49
+ Input: () => /* @__PURE__ */ s(g, { children: T(r.purchaseDate) })
49
50
  },
50
51
  {
51
52
  label: "Purchase Price",
52
- Input: () => /* @__PURE__ */ s(v, { children: T(a.purchasePrice, 6) })
53
+ Input: () => /* @__PURE__ */ s(g, { children: T(r.purchasePrice, 6) })
53
54
  },
54
55
  {
55
56
  label: "Purchase Proceeds",
56
- Input: () => /* @__PURE__ */ s(v, { children: T(a.purchaseProceeds) })
57
+ Input: () => /* @__PURE__ */ s(g, { children: T(r.purchaseProceeds) })
57
58
  }
58
59
  ] : [];
59
60
  return { inputs: [
60
61
  {
61
62
  label: "Asset Name",
62
63
  Input: () => {
63
- var e;
64
+ var a;
64
65
  return /* @__PURE__ */ s(
65
66
  u,
66
67
  {
@@ -69,7 +70,7 @@ function ve(_) {
69
70
  required: "Asset name is required"
70
71
  }),
71
72
  "aria-invalid": t.name ? "true" : "false",
72
- errorMessage: (e = t.name) == null ? void 0 : e.message,
73
+ errorMessage: (a = t.name) == null ? void 0 : a.message,
73
74
  inputClassName: "text-left",
74
75
  placeholder: "E.g. My Asset"
75
76
  }
@@ -79,8 +80,8 @@ function ve(_) {
79
80
  {
80
81
  label: "CUSIP",
81
82
  Input: () => {
82
- var e;
83
- return i === "view" ? (a == null ? void 0 : a.CUSIP) ?? "Not available" : /* @__PURE__ */ s(
83
+ var a;
84
+ return i === "view" ? (r == null ? void 0 : r.CUSIP) ?? "Not available" : /* @__PURE__ */ s(
84
85
  u,
85
86
  {
86
87
  ...c("CUSIP", {
@@ -98,7 +99,7 @@ function ve(_) {
98
99
  }
99
100
  }),
100
101
  "aria-invalid": t.CUSIP ? "true" : "false",
101
- errorMessage: (e = t.CUSIP) == null ? void 0 : e.message,
102
+ errorMessage: (a = t.CUSIP) == null ? void 0 : a.message,
102
103
  placeholder: "E.g. A2345B789"
103
104
  }
104
105
  );
@@ -107,8 +108,8 @@ function ve(_) {
107
108
  {
108
109
  label: "ISIN",
109
110
  Input: () => {
110
- var e;
111
- return i === "view" ? (a == null ? void 0 : a.ISIN) ?? "Not available" : /* @__PURE__ */ s(
111
+ var a;
112
+ return i === "view" ? (r == null ? void 0 : r.ISIN) ?? "Not available" : /* @__PURE__ */ s(
112
113
  u,
113
114
  {
114
115
  ...c("ISIN", {
@@ -126,7 +127,7 @@ function ve(_) {
126
127
  }
127
128
  }),
128
129
  "aria-invalid": t.ISIN ? "true" : "false",
129
- errorMessage: (e = t.ISIN) == null ? void 0 : e.message,
130
+ errorMessage: (a = t.ISIN) == null ? void 0 : a.message,
130
131
  placeholder: "E.g. 123456789ABC"
131
132
  }
132
133
  );
@@ -145,25 +146,25 @@ function ve(_) {
145
146
  })
146
147
  }
147
148
  ),
148
- inputLabel: a != null && a.maturity ? R(a.maturity, !0) : null
149
+ inputLabel: r != null && r.maturity ? K(r.maturity, !0) : null
149
150
  },
150
151
  {
151
152
  label: "Asset Type",
152
153
  Input: () => {
153
- var e;
154
+ var a;
154
155
  return /* @__PURE__ */ s(
155
- f,
156
+ y,
156
157
  {
157
158
  addItemButtonProps: {
158
- onClick: b("ASSET"),
159
+ onClick: I("ASSET"),
159
160
  label: "Create Fixed Income Type"
160
161
  },
161
162
  "aria-invalid": t.fixedIncomeTypeId ? "true" : "false",
162
163
  control: o,
163
164
  disabled: i === "view",
164
- errorMessage: (e = t.fixedIncomeTypeId) == null ? void 0 : e.message,
165
+ errorMessage: (a = t.fixedIncomeTypeId) == null ? void 0 : a.message,
165
166
  name: "fixedIncomeTypeId",
166
- options: w.map((l) => ({
167
+ options: C.map((l) => ({
167
168
  ...l,
168
169
  value: l.id,
169
170
  label: l.name
@@ -176,20 +177,20 @@ function ve(_) {
176
177
  {
177
178
  label: "SPV",
178
179
  Input: () => {
179
- var e;
180
+ var a;
180
181
  return /* @__PURE__ */ s(
181
- f,
182
+ y,
182
183
  {
183
184
  addItemButtonProps: {
184
- onClick: b("SPV"),
185
+ onClick: I("SPV"),
185
186
  label: "Create SPV"
186
187
  },
187
188
  "aria-invalid": t.spvId ? "true" : "false",
188
189
  control: o,
189
190
  disabled: i === "view",
190
- errorMessage: (e = t.spvId) == null ? void 0 : e.message,
191
+ errorMessage: (a = t.spvId) == null ? void 0 : a.message,
191
192
  name: "spvId",
192
- options: C.map((l) => ({
193
+ options: w.map((l) => ({
193
194
  ...l,
194
195
  value: l.id,
195
196
  label: l.name
@@ -202,35 +203,35 @@ function ve(_) {
202
203
  ...d
203
204
  ] };
204
205
  }
205
- case g.TRANSACTION: {
206
- const a = I, c = q, { errors: r } = p, t = y, o = c("type"), d = c("entryTime") ?? (/* @__PURE__ */ new Date()).toISOString(), h = !!o && Q.includes(o), e = !!o && Z.includes(o), l = !h, O = X.map((n) => ({
207
- label: J[n],
206
+ case f.TRANSACTION: {
207
+ const r = b, c = q, { errors: e } = p, t = h, o = c("type"), d = !!o && H.includes(o), v = !!o && Q.includes(o), a = !d, l = Z.map((n) => ({
208
+ label: X[n],
208
209
  value: n
209
- })), D = M.map((n) => ({
210
- label: K(n),
210
+ })), _ = M.map((n) => ({
211
+ label: J(n),
211
212
  value: n.id
212
213
  })), N = S.map(
213
214
  (n) => {
214
215
  var m;
215
216
  return {
216
- label: `${n.name} — ${n.feeType} — ${(m = P.find((k) => k.id === n.accountId)) == null ? void 0 : m.reference}`,
217
+ label: `${n.name} — ${n.feeType} — ${(m = P.find((U) => U.id === n.accountId)) == null ? void 0 : m.reference}`,
217
218
  value: n.id
218
219
  };
219
220
  }
220
- ), U = [
221
+ ), O = [
221
222
  {
222
223
  label: "Transaction Type",
223
224
  Input: () => {
224
225
  var n;
225
226
  return /* @__PURE__ */ s(
226
- f,
227
+ y,
227
228
  {
228
- "aria-invalid": r.type ? "true" : "false",
229
+ "aria-invalid": e.type ? "true" : "false",
229
230
  control: t,
230
231
  disabled: i === "view",
231
- errorMessage: (n = r.type) == null ? void 0 : n.message,
232
+ errorMessage: (n = e.type) == null ? void 0 : n.message,
232
233
  name: "type",
233
- options: O,
234
+ options: l,
234
235
  rules: {
235
236
  required: "Transaction type is required"
236
237
  }
@@ -246,21 +247,21 @@ function ve(_) {
246
247
  className: "h-8 w-full rounded-md bg-gray-100 px-3 disabled:bg-transparent disabled:p-0",
247
248
  step: 1,
248
249
  type: "datetime-local",
249
- ...a("entryTime", {
250
+ ...r("entryTime", {
250
251
  disabled: i === "view",
251
252
  required: "Entry time is required"
252
253
  })
253
254
  }
254
255
  ),
255
- inputLabel: d ? R(new Date(d)) : null
256
+ inputLabel: /* @__PURE__ */ s($, { control: t })
256
257
  },
257
- h ? {
258
+ d ? {
258
259
  label: "Service Provider",
259
260
  Input: () => /* @__PURE__ */ s(
260
- f,
261
+ y,
261
262
  {
262
263
  addItemButtonProps: {
263
- onClick: b("SERVICE_PROVIDER_FEE_TYPE"),
264
+ onClick: I("SERVICE_PROVIDER_FEE_TYPE"),
264
265
  label: "Add Service Provider"
265
266
  },
266
267
  control: t,
@@ -270,23 +271,23 @@ function ve(_) {
270
271
  }
271
272
  )
272
273
  } : null,
273
- e ? {
274
+ v ? {
274
275
  label: "Asset name",
275
276
  Input: () => {
276
277
  var n;
277
278
  return /* @__PURE__ */ s(
278
- f,
279
+ y,
279
280
  {
280
281
  addItemButtonProps: {
281
- onClick: b("ASSET"),
282
+ onClick: I("ASSET"),
282
283
  label: "Create Asset"
283
284
  },
284
- "aria-invalid": r.type ? "true" : "false",
285
+ "aria-invalid": e.type ? "true" : "false",
285
286
  control: t,
286
287
  disabled: i === "view",
287
- errorMessage: (n = r.type) == null ? void 0 : n.message,
288
+ errorMessage: (n = e.type) == null ? void 0 : n.message,
288
289
  name: "fixedIncomeId",
289
- options: D,
290
+ options: _,
290
291
  rules: {
291
292
  required: "Asset name is required"
292
293
  }
@@ -294,17 +295,17 @@ function ve(_) {
294
295
  );
295
296
  }
296
297
  } : void 0,
297
- e ? {
298
+ v ? {
298
299
  label: "Quantity",
299
300
  Input: () => {
300
301
  var n;
301
302
  return /* @__PURE__ */ s(
302
- V,
303
+ R,
303
304
  {
304
- "aria-invalid": r.fixedIncomeAmount ? "true" : "false",
305
+ "aria-invalid": e.fixedIncomeAmount ? "true" : "false",
305
306
  control: t,
306
307
  disabled: i === "view",
307
- errorMessage: (n = r.fixedIncomeAmount) == null ? void 0 : n.message,
308
+ errorMessage: (n = e.fixedIncomeAmount) == null ? void 0 : n.message,
308
309
  name: "fixedIncomeAmount",
309
310
  placeholder: "E.g. 1,000.00",
310
311
  rules: {
@@ -318,18 +319,18 @@ function ve(_) {
318
319
  }
319
320
  } : void 0,
320
321
  {
321
- label: e ? "Asset Proceeds" : "Cash Amount",
322
+ label: v ? "Asset Proceeds" : "Cash Amount",
322
323
  Input: () => {
323
324
  var n;
324
- return /* @__PURE__ */ F(v, { children: [
325
+ return /* @__PURE__ */ F(g, { children: [
325
326
  /* @__PURE__ */ s(
326
- V,
327
+ R,
327
328
  {
328
- "aria-invalid": r.cashAmount ? "true" : "false",
329
+ "aria-invalid": e.cashAmount ? "true" : "false",
329
330
  control: t,
330
331
  currency: "USD",
331
332
  disabled: i === "view",
332
- errorMessage: (n = r.cashAmount) == null ? void 0 : n.message,
333
+ errorMessage: (n = e.cashAmount) == null ? void 0 : n.message,
333
334
  name: "cashAmount",
334
335
  placeholder: "E.g. $1,000.00",
335
336
  rules: {
@@ -340,7 +341,7 @@ function ve(_) {
340
341
  }
341
342
  }
342
343
  ),
343
- e ? /* @__PURE__ */ s(
344
+ v ? /* @__PURE__ */ s(
344
345
  Y,
345
346
  {
346
347
  control: t,
@@ -357,38 +358,38 @@ function ve(_) {
357
358
  return /* @__PURE__ */ s(
358
359
  W,
359
360
  {
360
- ...a("txRef", {
361
+ ...r("txRef", {
361
362
  disabled: i === "view"
362
363
  }),
363
- "aria-invalid": r.txRef ? "true" : "false",
364
+ "aria-invalid": e.txRef ? "true" : "false",
364
365
  control: t,
365
- errorMessage: (n = r.txRef) == null ? void 0 : n.message,
366
+ errorMessage: (n = e.txRef) == null ? void 0 : n.message,
366
367
  placeholder: "E.g. 0x123..."
367
368
  }
368
369
  );
369
370
  }
370
371
  }
371
- ].filter(Boolean), L = /* @__PURE__ */ F(v, { children: [
372
+ ].filter(Boolean), L = /* @__PURE__ */ F(g, { children: [
372
373
  /* @__PURE__ */ s(
373
- j,
374
+ z,
374
375
  {
375
- canHaveTransactionFees: l,
376
+ canHaveTransactionFees: a,
376
377
  control: t,
377
- errors: r,
378
+ errors: e,
378
379
  isViewOnly: i === "view",
379
380
  serviceProviderFeeTypeOptions: N,
380
381
  serviceProviderFeeTypes: S,
381
- showCreateServiceProviderFeeTypeModal: b(
382
+ showCreateServiceProviderFeeTypeModal: I(
382
383
  "SERVICE_PROVIDER_FEE_TYPE"
383
384
  )
384
385
  }
385
386
  ),
386
- /* @__PURE__ */ s(z, { control: t })
387
+ /* @__PURE__ */ s(B, { control: t })
387
388
  ] });
388
- return { inputs: U, additionalInputs: L };
389
+ return { inputs: O, additionalInputs: L };
389
390
  }
390
- case g.ACCOUNT: {
391
- const a = I, c = p, { errors: r } = c;
391
+ case f.ACCOUNT: {
392
+ const r = b, c = p, { errors: e } = c;
392
393
  return { inputs: [
393
394
  {
394
395
  label: "Account Label",
@@ -397,12 +398,12 @@ function ve(_) {
397
398
  return /* @__PURE__ */ s(
398
399
  u,
399
400
  {
400
- ...a("label", {
401
+ ...r("label", {
401
402
  disabled: i === "view",
402
403
  required: "Account label is required"
403
404
  }),
404
- "aria-invalid": ((o = r.label) == null ? void 0 : o.type) === "required" ? "true" : "false",
405
- errorMessage: (d = r.label) == null ? void 0 : d.message,
405
+ "aria-invalid": ((o = e.label) == null ? void 0 : o.type) === "required" ? "true" : "false",
406
+ errorMessage: (d = e.label) == null ? void 0 : d.message,
406
407
  placeholder: "E.g. My Label"
407
408
  }
408
409
  );
@@ -415,12 +416,12 @@ function ve(_) {
415
416
  return /* @__PURE__ */ s(
416
417
  u,
417
418
  {
418
- ...a("reference", {
419
+ ...r("reference", {
419
420
  disabled: i === "view",
420
421
  required: "Account reference is required"
421
422
  }),
422
- "aria-invalid": ((o = r.reference) == null ? void 0 : o.type) === "required" ? "true" : "false",
423
- errorMessage: (d = r.reference) == null ? void 0 : d.message,
423
+ "aria-invalid": ((o = e.reference) == null ? void 0 : o.type) === "required" ? "true" : "false",
424
+ errorMessage: (d = e.reference) == null ? void 0 : d.message,
424
425
  placeholder: "E.g. bank account number or ETH address"
425
426
  }
426
427
  );
@@ -428,8 +429,8 @@ function ve(_) {
428
429
  }
429
430
  ] };
430
431
  }
431
- case g.SPV: {
432
- const a = I, c = p, { errors: r } = c;
432
+ case f.SPV: {
433
+ const r = b, c = p, { errors: e } = c;
433
434
  return { inputs: [
434
435
  {
435
436
  label: "SPV name",
@@ -438,12 +439,12 @@ function ve(_) {
438
439
  return /* @__PURE__ */ s(
439
440
  u,
440
441
  {
441
- ...a("name", {
442
+ ...r("name", {
442
443
  disabled: i === "view",
443
444
  required: "SPV name is required"
444
445
  }),
445
- "aria-invalid": ((o = r.name) == null ? void 0 : o.type) === "required" ? "true" : "false",
446
- errorMessage: (d = r.name) == null ? void 0 : d.message,
446
+ "aria-invalid": ((o = e.name) == null ? void 0 : o.type) === "required" ? "true" : "false",
447
+ errorMessage: (d = e.name) == null ? void 0 : d.message,
447
448
  placeholder: "E.g. My SPV name"
448
449
  }
449
450
  );
@@ -451,8 +452,8 @@ function ve(_) {
451
452
  }
452
453
  ] };
453
454
  }
454
- case g.FIXED_INCOME_TYPE: {
455
- const a = I, c = p, { errors: r } = c;
455
+ case f.FIXED_INCOME_TYPE: {
456
+ const r = b, c = p, { errors: e } = c;
456
457
  return { inputs: [
457
458
  {
458
459
  label: "Fixed Income Type Name",
@@ -461,12 +462,12 @@ function ve(_) {
461
462
  return /* @__PURE__ */ s(
462
463
  u,
463
464
  {
464
- ...a("name", {
465
+ ...r("name", {
465
466
  disabled: i === "view",
466
467
  required: "Fixed Income Type name is required"
467
468
  }),
468
- "aria-invalid": ((o = r.name) == null ? void 0 : o.type) === "required" ? "true" : "false",
469
- errorMessage: (d = r.name) == null ? void 0 : d.message,
469
+ "aria-invalid": ((o = e.name) == null ? void 0 : o.type) === "required" ? "true" : "false",
470
+ errorMessage: (d = e.name) == null ? void 0 : d.message,
470
471
  placeholder: "E.g. My Fixed Income Type name"
471
472
  }
472
473
  );
@@ -474,8 +475,8 @@ function ve(_) {
474
475
  }
475
476
  ] };
476
477
  }
477
- case g.SERVICE_PROVIDER_FEE_TYPE: {
478
- const a = I, c = p, { errors: r } = c, t = y, o = (e) => `${e.label} (${e.reference})`, d = (e) => e.map((l) => ({
478
+ case f.SERVICE_PROVIDER_FEE_TYPE: {
479
+ const r = b, c = p, { errors: e } = c, t = h, o = (a) => `${a.label} (${a.reference})`, d = (a) => a.map((l) => ({
479
480
  ...l,
480
481
  value: l.id,
481
482
  label: o(l)
@@ -484,16 +485,16 @@ function ve(_) {
484
485
  {
485
486
  label: "Service Provider Name",
486
487
  Input: () => {
487
- var e, l;
488
+ var a, l;
488
489
  return /* @__PURE__ */ s(
489
490
  u,
490
491
  {
491
- ...a("name", {
492
+ ...r("name", {
492
493
  disabled: i === "view",
493
494
  required: "Service provider name is required"
494
495
  }),
495
- "aria-invalid": ((e = r.name) == null ? void 0 : e.type) === "required" ? "true" : "false",
496
- errorMessage: (l = r.name) == null ? void 0 : l.message,
496
+ "aria-invalid": ((a = e.name) == null ? void 0 : a.type) === "required" ? "true" : "false",
497
+ errorMessage: (l = e.name) == null ? void 0 : l.message,
497
498
  placeholder: "E.g. My Service Provider"
498
499
  }
499
500
  );
@@ -502,16 +503,16 @@ function ve(_) {
502
503
  {
503
504
  label: "Fee Type",
504
505
  Input: () => {
505
- var e, l;
506
+ var a, l;
506
507
  return /* @__PURE__ */ s(
507
508
  u,
508
509
  {
509
- ...a("feeType", {
510
+ ...r("feeType", {
510
511
  disabled: i === "view",
511
512
  required: "Fee type is required"
512
513
  }),
513
- "aria-invalid": ((e = r.name) == null ? void 0 : e.type) === "required" ? "true" : "false",
514
- errorMessage: (l = r.name) == null ? void 0 : l.message,
514
+ "aria-invalid": ((a = e.name) == null ? void 0 : a.type) === "required" ? "true" : "false",
515
+ errorMessage: (l = e.name) == null ? void 0 : l.message,
515
516
  placeholder: "E.g. My Fee Type"
516
517
  }
517
518
  );
@@ -520,18 +521,18 @@ function ve(_) {
520
521
  {
521
522
  label: "Account",
522
523
  Input: () => {
523
- var e;
524
+ var a;
524
525
  return /* @__PURE__ */ s(
525
- f,
526
+ y,
526
527
  {
527
528
  addItemButtonProps: {
528
- onClick: b("ACCOUNT"),
529
+ onClick: I("ACCOUNT"),
529
530
  label: "Create Account"
530
531
  },
531
- "aria-invalid": r.accountId ? "true" : "false",
532
+ "aria-invalid": e.accountId ? "true" : "false",
532
533
  control: t,
533
534
  disabled: i === "view",
534
- errorMessage: (e = r.accountId) == null ? void 0 : e.message,
535
+ errorMessage: (a = e.accountId) == null ? void 0 : a.message,
535
536
  name: "accountId",
536
537
  options: d(P),
537
538
  rules: { required: "Account is required" }
@@ -544,21 +545,21 @@ function ve(_) {
544
545
  }
545
546
  }, [
546
547
  p,
547
- y,
548
- I,
548
+ h,
549
+ b,
549
550
  E,
550
551
  q,
551
552
  P,
552
- w,
553
+ C,
553
554
  M,
554
555
  i,
555
556
  S,
556
- b,
557
- C,
557
+ I,
558
+ w,
558
559
  A
559
560
  ]);
560
561
  }
561
562
  export {
562
- ve as useFormInputs
563
+ ge as useFormInputs
563
564
  };
564
565
  //# sourceMappingURL=useFormInputs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useFormInputs.js","sources":["../../../src/rwa/hooks/useFormInputs.tsx"],"sourcesContent":["import {\n Account,\n allGroupTransactionTypes,\n assetGroupTransactions,\n feesTransactions,\n FeeTransactionsTable,\n formatDateForDisplay,\n FormInputsByTableName,\n groupTransactionTypeLabels,\n handleTableDatum,\n makeFixedIncomeOptionLabel,\n Operation,\n RWANumberInput,\n RWATableSelect,\n RWATableTextInput,\n TableItemType,\n TableName,\n tableNames,\n TransactionReference,\n UnitPrice,\n useEditorContext,\n useModal,\n} from \"@/rwa\";\nimport { ReactElement, useCallback, useMemo } from \"react\";\nimport {\n Control,\n FormState,\n UseFormRegister,\n UseFormWatch,\n} from \"react-hook-form\";\nimport { CashBalanceChange } from \"../components/table/transactions/cash-balance-change\";\n\ntype Input = {\n label: string;\n Input: () => string | React.JSX.Element;\n inputLabel?: string | null;\n};\n\ntype Props = {\n tableName: TableName;\n tableItem: TableItemType<TableName> | undefined | null;\n operation: Operation;\n formState: FormState<FormInputsByTableName[TableName]>;\n register: UseFormRegister<FormInputsByTableName[TableName]>;\n watch: UseFormWatch<FormInputsByTableName[TableName]>;\n control: Control<FormInputsByTableName[TableName]>;\n};\nexport function useFormInputs(props: Props): {\n inputs: Input[];\n additionalInputs?: ReactElement;\n} {\n const {\n tableName,\n operation,\n formState: _formState,\n tableItem: _tableItem,\n register: _register,\n watch: _watch,\n control: _control,\n } = props;\n const {\n fixedIncomeTypes,\n spvs,\n serviceProviderFeeTypes,\n accounts,\n fixedIncomes,\n } = useEditorContext();\n const { showModal } = useModal();\n const showCreateItemModal = useCallback(\n (tableName: TableName) => () => {\n showModal(\"createItem\", { tableName });\n },\n [showModal],\n );\n\n return useMemo(() => {\n switch (tableName) {\n case tableNames.ASSET: {\n const tableItem = _tableItem as TableItemType<\"ASSET\"> | null;\n type Payload = FormInputsByTableName[\"ASSET\"];\n const register = _register as UseFormRegister<Payload>;\n const formState = _formState as FormState<Payload>;\n const { errors } = formState;\n\n const control = _control as Control<Payload>;\n const derivedInputsToDisplay =\n operation !== \"create\" && !!tableItem\n ? [\n {\n label: \"Notional\",\n Input: () => <>{handleTableDatum(tableItem.notional)}</>,\n },\n {\n label: \"Purchase Date\",\n Input: () => <>{handleTableDatum(tableItem.purchaseDate)}</>,\n },\n {\n label: \"Purchase Price\",\n Input: () => (\n <>{handleTableDatum(tableItem.purchasePrice, 6)}</>\n ),\n },\n {\n label: \"Purchase Proceeds\",\n Input: () => (\n <>{handleTableDatum(tableItem.purchaseProceeds)}</>\n ),\n },\n ]\n : [];\n\n const inputs = [\n {\n label: \"Asset Name\",\n Input: () => (\n <RWATableTextInput\n {...register(\"name\", {\n disabled: operation === \"view\",\n required: \"Asset name is required\",\n })}\n aria-invalid={errors.name ? \"true\" : \"false\"}\n errorMessage={errors.name?.message}\n inputClassName=\"text-left\"\n placeholder=\"E.g. My Asset\"\n />\n ),\n },\n {\n label: \"CUSIP\",\n Input: () =>\n operation === \"view\" ? (\n (tableItem?.CUSIP ?? \"Not available\")\n ) : (\n <RWATableTextInput\n {...register(\"CUSIP\", {\n maxLength: {\n value: 9,\n message: \"CUSIP cannot be longer than 9 characters\",\n },\n minLength: {\n value: 9,\n message: \"CUSIP cannot be shorter than 9 characters\",\n },\n pattern: {\n value: /^[a-zA-Z0-9]*$/,\n message: \"CUSIP must be alphanumeric\",\n },\n })}\n aria-invalid={errors.CUSIP ? \"true\" : \"false\"}\n errorMessage={errors.CUSIP?.message}\n placeholder=\"E.g. A2345B789\"\n />\n ),\n },\n {\n label: \"ISIN\",\n Input: () =>\n operation === \"view\" ? (\n (tableItem?.ISIN ?? \"Not available\")\n ) : (\n <RWATableTextInput\n {...register(\"ISIN\", {\n maxLength: {\n value: 12,\n message: \"ISIN cannot be longer than 12 characters\",\n },\n minLength: {\n value: 12,\n message: \"ISIN cannot be shorter than 12 characters\",\n },\n pattern: {\n value: /^[a-zA-Z0-9]*$/,\n message: \"ISIN must be alphanumeric\",\n },\n })}\n aria-invalid={errors.ISIN ? \"true\" : \"false\"}\n errorMessage={errors.ISIN?.message}\n placeholder=\"E.g. 123456789ABC\"\n />\n ),\n },\n {\n label: \"Maturity\",\n Input: () => (\n <input\n className=\"h-8 w-full rounded-md bg-gray-100 px-3 disabled:bg-transparent disabled:p-0\"\n step={1}\n type=\"date\"\n {...register(\"maturity\", {\n disabled: operation === \"view\",\n })}\n />\n ),\n inputLabel: tableItem?.maturity\n ? formatDateForDisplay(tableItem.maturity, true)\n : null,\n },\n {\n label: \"Asset Type\",\n Input: () => (\n <RWATableSelect\n addItemButtonProps={{\n onClick: showCreateItemModal(\"ASSET\"),\n label: \"Create Fixed Income Type\",\n }}\n aria-invalid={errors.fixedIncomeTypeId ? \"true\" : \"false\"}\n control={control}\n disabled={operation === \"view\"}\n errorMessage={errors.fixedIncomeTypeId?.message}\n name=\"fixedIncomeTypeId\"\n options={fixedIncomeTypes.map((t) => ({\n ...t,\n value: t.id,\n label: t.name,\n }))}\n rules={{ required: \"Asset type is required\" }}\n />\n ),\n },\n {\n label: \"SPV\",\n Input: () => (\n <RWATableSelect\n addItemButtonProps={{\n onClick: showCreateItemModal(\"SPV\"),\n label: \"Create SPV\",\n }}\n aria-invalid={errors.spvId ? \"true\" : \"false\"}\n control={control}\n disabled={operation === \"view\"}\n errorMessage={errors.spvId?.message}\n name=\"spvId\"\n options={spvs.map((t) => ({\n ...t,\n value: t.id,\n label: t.name,\n }))}\n rules={{ required: \"SPV is required\" }}\n />\n ),\n },\n ...derivedInputsToDisplay,\n ];\n\n return { inputs };\n }\n case tableNames.TRANSACTION: {\n type Payload = FormInputsByTableName[\"TRANSACTION\"];\n const register = _register as UseFormRegister<Payload>;\n const watch = _watch as UseFormWatch<Payload>;\n const { errors } = _formState as FormState<Payload>;\n const control = _control as Control<Payload>;\n const type = watch(\"type\");\n const entryTimeInputValue =\n watch(\"entryTime\") ?? new Date().toISOString();\n const isFeesTransaction = !!type && feesTransactions.includes(type);\n const isAssetTransaction =\n !!type && assetGroupTransactions.includes(type);\n const canHaveTransactionFees = !isFeesTransaction;\n const transactionTypeOptions = allGroupTransactionTypes.map((type) => ({\n label: groupTransactionTypeLabels[type],\n value: type,\n }));\n const fixedIncomeOptions = fixedIncomes.map((fixedIncome) => ({\n label: makeFixedIncomeOptionLabel(fixedIncome),\n value: fixedIncome.id,\n }));\n const serviceProviderFeeTypeOptions = serviceProviderFeeTypes.map(\n (spft) => ({\n label: `${spft.name} — ${spft.feeType} — ${accounts.find((account) => account.id === spft.accountId)?.reference}`,\n value: spft.id,\n }),\n );\n\n const inputs = [\n {\n label: \"Transaction Type\",\n Input: () => (\n <RWATableSelect\n aria-invalid={errors.type ? \"true\" : \"false\"}\n control={control}\n disabled={operation === \"view\"}\n errorMessage={errors.type?.message}\n name=\"type\"\n options={transactionTypeOptions}\n rules={{\n required: \"Transaction type is required\",\n }}\n />\n ),\n },\n {\n label: \"Entry Time\",\n Input: () => (\n <input\n className=\"h-8 w-full rounded-md bg-gray-100 px-3 disabled:bg-transparent disabled:p-0\"\n step={1}\n type=\"datetime-local\"\n {...register(\"entryTime\", {\n disabled: operation === \"view\",\n required: \"Entry time is required\",\n })}\n />\n ),\n inputLabel: entryTimeInputValue\n ? formatDateForDisplay(new Date(entryTimeInputValue))\n : null,\n },\n isFeesTransaction\n ? {\n label: \"Service Provider\",\n Input: () => (\n <RWATableSelect\n addItemButtonProps={{\n onClick: showCreateItemModal(\"SERVICE_PROVIDER_FEE_TYPE\"),\n label: \"Add Service Provider\",\n }}\n control={control}\n disabled={operation === \"view\"}\n name=\"serviceProviderFeeTypeId\"\n options={serviceProviderFeeTypeOptions}\n />\n ),\n }\n : null,\n isAssetTransaction\n ? {\n label: \"Asset name\",\n Input: () => (\n <RWATableSelect\n addItemButtonProps={{\n onClick: showCreateItemModal(\"ASSET\"),\n label: \"Create Asset\",\n }}\n aria-invalid={errors.type ? \"true\" : \"false\"}\n control={control}\n disabled={operation === \"view\"}\n errorMessage={errors.type?.message}\n name=\"fixedIncomeId\"\n options={fixedIncomeOptions}\n rules={{\n required: \"Asset name is required\",\n }}\n />\n ),\n }\n : undefined,\n isAssetTransaction\n ? {\n label: \"Quantity\",\n Input: () => (\n <RWANumberInput\n aria-invalid={errors.fixedIncomeAmount ? \"true\" : \"false\"}\n control={control}\n disabled={operation === \"view\"}\n errorMessage={errors.fixedIncomeAmount?.message}\n name=\"fixedIncomeAmount\"\n placeholder=\"E.g. 1,000.00\"\n rules={{\n required: \"Quantity is required\",\n validate: {\n positive: (value) =>\n (!!value && Number(value) > 0) ||\n \"Asset proceeds must be greater than zero\",\n },\n }}\n />\n ),\n }\n : undefined,\n {\n label: isAssetTransaction ? \"Asset Proceeds\" : \"Cash Amount\",\n Input: () => (\n <>\n <RWANumberInput\n aria-invalid={errors.cashAmount ? \"true\" : \"false\"}\n control={control}\n currency=\"USD\"\n disabled={operation === \"view\"}\n errorMessage={errors.cashAmount?.message}\n name=\"cashAmount\"\n placeholder=\"E.g. $1,000.00\"\n rules={{\n required: \"Asset proceeds is required\",\n validate: {\n positive: (value) =>\n (!!value && Number(value) > 0) ||\n \"Asset proceeds must be greater than zero\",\n },\n }}\n />\n {isAssetTransaction ? (\n <UnitPrice\n control={control}\n isViewOnly={operation === \"view\"}\n />\n ) : null}\n </>\n ),\n },\n {\n label: \"Transaction reference\",\n Input: () => (\n <TransactionReference\n {...register(\"txRef\", {\n disabled: operation === \"view\",\n })}\n aria-invalid={errors.txRef ? \"true\" : \"false\"}\n control={control}\n errorMessage={errors.txRef?.message}\n placeholder=\"E.g. 0x123...\"\n />\n ),\n },\n ].filter(Boolean);\n\n const additionalInputs = (\n <>\n <FeeTransactionsTable\n canHaveTransactionFees={canHaveTransactionFees}\n control={control}\n errors={errors}\n isViewOnly={operation === \"view\"}\n serviceProviderFeeTypeOptions={serviceProviderFeeTypeOptions}\n serviceProviderFeeTypes={serviceProviderFeeTypes}\n showCreateServiceProviderFeeTypeModal={showCreateItemModal(\n \"SERVICE_PROVIDER_FEE_TYPE\",\n )}\n />\n <CashBalanceChange control={control} />\n </>\n );\n\n return { inputs, additionalInputs };\n }\n case tableNames.ACCOUNT: {\n type Payload = FormInputsByTableName[\"ACCOUNT\"];\n const register = _register as UseFormRegister<Payload>;\n const formState = _formState as FormState<Payload>;\n const { errors } = formState;\n const inputs = [\n {\n label: \"Account Label\",\n Input: () => (\n <RWATableTextInput\n {...register(\"label\", {\n disabled: operation === \"view\",\n required: \"Account label is required\",\n })}\n aria-invalid={\n errors.label?.type === \"required\" ? \"true\" : \"false\"\n }\n errorMessage={errors.label?.message}\n placeholder=\"E.g. My Label\"\n />\n ),\n },\n {\n label: \"Account Reference\",\n Input: () => (\n <RWATableTextInput\n {...register(\"reference\", {\n disabled: operation === \"view\",\n required: \"Account reference is required\",\n })}\n aria-invalid={\n errors.reference?.type === \"required\" ? \"true\" : \"false\"\n }\n errorMessage={errors.reference?.message}\n placeholder=\"E.g. bank account number or ETH address\"\n />\n ),\n },\n ];\n return { inputs };\n }\n case tableNames.SPV: {\n type Payload = FormInputsByTableName[\"SPV\"];\n const register = _register as UseFormRegister<Payload>;\n const formState = _formState as FormState<Payload>;\n const { errors } = formState;\n\n const inputs = [\n {\n label: \"SPV name\",\n Input: () => (\n <RWATableTextInput\n {...register(\"name\", {\n disabled: operation === \"view\",\n required: \"SPV name is required\",\n })}\n aria-invalid={\n errors.name?.type === \"required\" ? \"true\" : \"false\"\n }\n errorMessage={errors.name?.message}\n placeholder=\"E.g. My SPV name\"\n />\n ),\n },\n ];\n\n return { inputs };\n }\n case tableNames.FIXED_INCOME_TYPE: {\n type Payload = FormInputsByTableName[\"FIXED_INCOME_TYPE\"];\n const register = _register as UseFormRegister<Payload>;\n const formState = _formState as FormState<Payload>;\n const { errors } = formState;\n\n const inputs = [\n {\n label: \"Fixed Income Type Name\",\n Input: () => (\n <RWATableTextInput\n {...register(\"name\", {\n disabled: operation === \"view\",\n required: \"Fixed Income Type name is required\",\n })}\n aria-invalid={\n errors.name?.type === \"required\" ? \"true\" : \"false\"\n }\n errorMessage={errors.name?.message}\n placeholder=\"E.g. My Fixed Income Type name\"\n />\n ),\n },\n ];\n\n return { inputs };\n }\n case tableNames.SERVICE_PROVIDER_FEE_TYPE: {\n type Payload = FormInputsByTableName[\"SERVICE_PROVIDER_FEE_TYPE\"];\n const register = _register as UseFormRegister<Payload>;\n const formState = _formState as FormState<Payload>;\n const { errors } = formState;\n const control = _control as Control<Payload>;\n\n const makeAccountLabel = (account: Account) => {\n return `${account.label} (${account.reference})`;\n };\n\n const makeAccountOptions = (accounts: Account[]) => {\n return accounts.map((account) => ({\n ...account,\n value: account.id,\n label: makeAccountLabel(account),\n }));\n };\n\n const inputs = [\n {\n label: \"Service Provider Name\",\n Input: () => (\n <RWATableTextInput\n {...register(\"name\", {\n disabled: operation === \"view\",\n required: \"Service provider name is required\",\n })}\n aria-invalid={\n errors.name?.type === \"required\" ? \"true\" : \"false\"\n }\n errorMessage={errors.name?.message}\n placeholder=\"E.g. My Service Provider\"\n />\n ),\n },\n {\n label: \"Fee Type\",\n Input: () => (\n <RWATableTextInput\n {...register(\"feeType\", {\n disabled: operation === \"view\",\n required: \"Fee type is required\",\n })}\n aria-invalid={\n errors.name?.type === \"required\" ? \"true\" : \"false\"\n }\n errorMessage={errors.name?.message}\n placeholder=\"E.g. My Fee Type\"\n />\n ),\n },\n {\n label: \"Account\",\n Input: () => (\n <RWATableSelect\n addItemButtonProps={{\n onClick: showCreateItemModal(\"ACCOUNT\"),\n label: \"Create Account\",\n }}\n aria-invalid={errors.accountId ? \"true\" : \"false\"}\n control={control}\n disabled={operation === \"view\"}\n errorMessage={errors.accountId?.message}\n name=\"accountId\"\n options={makeAccountOptions(accounts)}\n rules={{ required: \"Account is required\" }}\n />\n ),\n },\n ];\n\n return { inputs };\n }\n }\n }, [\n _formState,\n _control,\n _register,\n _tableItem,\n _watch,\n accounts,\n fixedIncomeTypes,\n fixedIncomes,\n operation,\n serviceProviderFeeTypes,\n showCreateItemModal,\n spvs,\n tableName,\n ]);\n}\n"],"names":["useFormInputs","props","tableName","operation","_formState","_tableItem","_register","_watch","_control","fixedIncomeTypes","spvs","serviceProviderFeeTypes","accounts","fixedIncomes","useEditorContext","showModal","useModal","showCreateItemModal","useCallback","useMemo","tableNames","tableItem","register","formState","errors","control","derivedInputsToDisplay","jsx","Fragment","handleTableDatum","RWATableTextInput","_a","formatDateForDisplay","RWATableSelect","t","watch","type","entryTimeInputValue","isFeesTransaction","feesTransactions","isAssetTransaction","assetGroupTransactions","canHaveTransactionFees","transactionTypeOptions","allGroupTransactionTypes","groupTransactionTypeLabels","fixedIncomeOptions","fixedIncome","makeFixedIncomeOptionLabel","serviceProviderFeeTypeOptions","spft","account","inputs","RWANumberInput","value","jsxs","UnitPrice","TransactionReference","additionalInputs","FeeTransactionsTable","CashBalanceChange","_b","makeAccountLabel","makeAccountOptions"],"mappings":";;;;;;;;;;;;;;;;AA+CO,SAASA,GAAcC,GAG5B;AACM,QAAA;AAAA,IACJ,WAAAC;AAAA,IACA,WAAAC;AAAA,IACA,WAAWC;AAAA,IAC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":["../../../src/rwa/hooks/useFormInputs.tsx"],"sourcesContent":["import {\n Account,\n allGroupTransactionTypes,\n assetGroupTransactions,\n feesTransactions,\n FeeTransactionsTable,\n formatDateForDisplay,\n FormInputsByTableName,\n groupTransactionTypeLabels,\n handleTableDatum,\n makeFixedIncomeOptionLabel,\n Operation,\n RWANumberInput,\n RWATableSelect,\n RWATableTextInput,\n TableItemType,\n TableName,\n tableNames,\n TransactionReference,\n UnitPrice,\n useEditorContext,\n useModal,\n} from \"@/rwa\";\nimport { ReactElement, ReactNode, useCallback, useMemo } from \"react\";\nimport {\n Control,\n FormState,\n UseFormRegister,\n UseFormWatch,\n} from \"react-hook-form\";\nimport { CashBalanceChange } from \"../components/table/transactions/cash-balance-change\";\nimport { EntryTimeLabel } from \"../components/inputs/entry-time-label\";\n\ntype Input = {\n label: string;\n Input: () => string | React.JSX.Element;\n inputLabel?: ReactNode | null;\n};\n\ntype Props = {\n tableName: TableName;\n tableItem: TableItemType<TableName> | undefined | null;\n operation: Operation;\n formState: FormState<FormInputsByTableName[TableName]>;\n register: UseFormRegister<FormInputsByTableName[TableName]>;\n watch: UseFormWatch<FormInputsByTableName[TableName]>;\n control: Control<FormInputsByTableName[TableName]>;\n};\nexport function useFormInputs(props: Props): {\n inputs: Input[];\n additionalInputs?: ReactElement;\n} {\n const {\n tableName,\n operation,\n formState: _formState,\n tableItem: _tableItem,\n register: _register,\n watch: _watch,\n control: _control,\n } = props;\n const {\n fixedIncomeTypes,\n spvs,\n serviceProviderFeeTypes,\n accounts,\n fixedIncomes,\n } = useEditorContext();\n const { showModal } = useModal();\n const showCreateItemModal = useCallback(\n (tableName: TableName) => () => {\n showModal(\"createItem\", { tableName });\n },\n [showModal],\n );\n return useMemo(() => {\n switch (tableName) {\n case tableNames.ASSET: {\n const tableItem = _tableItem as TableItemType<\"ASSET\"> | null;\n type Payload = FormInputsByTableName[\"ASSET\"];\n const register = _register as UseFormRegister<Payload>;\n const formState = _formState as FormState<Payload>;\n const { errors } = formState;\n\n const control = _control as Control<Payload>;\n const derivedInputsToDisplay =\n operation !== \"create\" && !!tableItem\n ? [\n {\n label: \"Notional\",\n Input: () => <>{handleTableDatum(tableItem.notional)}</>,\n },\n {\n label: \"Purchase Date\",\n Input: () => <>{handleTableDatum(tableItem.purchaseDate)}</>,\n },\n {\n label: \"Purchase Price\",\n Input: () => (\n <>{handleTableDatum(tableItem.purchasePrice, 6)}</>\n ),\n },\n {\n label: \"Purchase Proceeds\",\n Input: () => (\n <>{handleTableDatum(tableItem.purchaseProceeds)}</>\n ),\n },\n ]\n : [];\n\n const inputs = [\n {\n label: \"Asset Name\",\n Input: () => (\n <RWATableTextInput\n {...register(\"name\", {\n disabled: operation === \"view\",\n required: \"Asset name is required\",\n })}\n aria-invalid={errors.name ? \"true\" : \"false\"}\n errorMessage={errors.name?.message}\n inputClassName=\"text-left\"\n placeholder=\"E.g. My Asset\"\n />\n ),\n },\n {\n label: \"CUSIP\",\n Input: () =>\n operation === \"view\" ? (\n (tableItem?.CUSIP ?? \"Not available\")\n ) : (\n <RWATableTextInput\n {...register(\"CUSIP\", {\n maxLength: {\n value: 9,\n message: \"CUSIP cannot be longer than 9 characters\",\n },\n minLength: {\n value: 9,\n message: \"CUSIP cannot be shorter than 9 characters\",\n },\n pattern: {\n value: /^[a-zA-Z0-9]*$/,\n message: \"CUSIP must be alphanumeric\",\n },\n })}\n aria-invalid={errors.CUSIP ? \"true\" : \"false\"}\n errorMessage={errors.CUSIP?.message}\n placeholder=\"E.g. A2345B789\"\n />\n ),\n },\n {\n label: \"ISIN\",\n Input: () =>\n operation === \"view\" ? (\n (tableItem?.ISIN ?? \"Not available\")\n ) : (\n <RWATableTextInput\n {...register(\"ISIN\", {\n maxLength: {\n value: 12,\n message: \"ISIN cannot be longer than 12 characters\",\n },\n minLength: {\n value: 12,\n message: \"ISIN cannot be shorter than 12 characters\",\n },\n pattern: {\n value: /^[a-zA-Z0-9]*$/,\n message: \"ISIN must be alphanumeric\",\n },\n })}\n aria-invalid={errors.ISIN ? \"true\" : \"false\"}\n errorMessage={errors.ISIN?.message}\n placeholder=\"E.g. 123456789ABC\"\n />\n ),\n },\n {\n label: \"Maturity\",\n Input: () => (\n <input\n className=\"h-8 w-full rounded-md bg-gray-100 px-3 disabled:bg-transparent disabled:p-0\"\n step={1}\n type=\"date\"\n {...register(\"maturity\", {\n disabled: operation === \"view\",\n })}\n />\n ),\n inputLabel: tableItem?.maturity\n ? formatDateForDisplay(tableItem.maturity, true)\n : null,\n },\n {\n label: \"Asset Type\",\n Input: () => (\n <RWATableSelect\n addItemButtonProps={{\n onClick: showCreateItemModal(\"ASSET\"),\n label: \"Create Fixed Income Type\",\n }}\n aria-invalid={errors.fixedIncomeTypeId ? \"true\" : \"false\"}\n control={control}\n disabled={operation === \"view\"}\n errorMessage={errors.fixedIncomeTypeId?.message}\n name=\"fixedIncomeTypeId\"\n options={fixedIncomeTypes.map((t) => ({\n ...t,\n value: t.id,\n label: t.name,\n }))}\n rules={{ required: \"Asset type is required\" }}\n />\n ),\n },\n {\n label: \"SPV\",\n Input: () => (\n <RWATableSelect\n addItemButtonProps={{\n onClick: showCreateItemModal(\"SPV\"),\n label: \"Create SPV\",\n }}\n aria-invalid={errors.spvId ? \"true\" : \"false\"}\n control={control}\n disabled={operation === \"view\"}\n errorMessage={errors.spvId?.message}\n name=\"spvId\"\n options={spvs.map((t) => ({\n ...t,\n value: t.id,\n label: t.name,\n }))}\n rules={{ required: \"SPV is required\" }}\n />\n ),\n },\n ...derivedInputsToDisplay,\n ];\n\n return { inputs };\n }\n case tableNames.TRANSACTION: {\n type Payload = FormInputsByTableName[\"TRANSACTION\"];\n const register = _register as UseFormRegister<Payload>;\n const watch = _watch as UseFormWatch<Payload>;\n const { errors } = _formState as FormState<Payload>;\n const control = _control as Control<Payload>;\n const type = watch(\"type\");\n const isFeesTransaction = !!type && feesTransactions.includes(type);\n const isAssetTransaction =\n !!type && assetGroupTransactions.includes(type);\n const canHaveTransactionFees = !isFeesTransaction;\n const transactionTypeOptions = allGroupTransactionTypes.map((type) => ({\n label: groupTransactionTypeLabels[type],\n value: type,\n }));\n const fixedIncomeOptions = fixedIncomes.map((fixedIncome) => ({\n label: makeFixedIncomeOptionLabel(fixedIncome),\n value: fixedIncome.id,\n }));\n const serviceProviderFeeTypeOptions = serviceProviderFeeTypes.map(\n (spft) => ({\n label: `${spft.name} — ${spft.feeType} — ${accounts.find((account) => account.id === spft.accountId)?.reference}`,\n value: spft.id,\n }),\n );\n\n const inputs = [\n {\n label: \"Transaction Type\",\n Input: () => (\n <RWATableSelect\n aria-invalid={errors.type ? \"true\" : \"false\"}\n control={control}\n disabled={operation === \"view\"}\n errorMessage={errors.type?.message}\n name=\"type\"\n options={transactionTypeOptions}\n rules={{\n required: \"Transaction type is required\",\n }}\n />\n ),\n },\n {\n label: \"Entry Time\",\n Input: () => (\n <input\n className=\"h-8 w-full rounded-md bg-gray-100 px-3 disabled:bg-transparent disabled:p-0\"\n step={1}\n type=\"datetime-local\"\n {...register(\"entryTime\", {\n disabled: operation === \"view\",\n required: \"Entry time is required\",\n })}\n />\n ),\n inputLabel: <EntryTimeLabel control={control} />,\n },\n isFeesTransaction\n ? {\n label: \"Service Provider\",\n Input: () => (\n <RWATableSelect\n addItemButtonProps={{\n onClick: showCreateItemModal(\"SERVICE_PROVIDER_FEE_TYPE\"),\n label: \"Add Service Provider\",\n }}\n control={control}\n disabled={operation === \"view\"}\n name=\"serviceProviderFeeTypeId\"\n options={serviceProviderFeeTypeOptions}\n />\n ),\n }\n : null,\n isAssetTransaction\n ? {\n label: \"Asset name\",\n Input: () => (\n <RWATableSelect\n addItemButtonProps={{\n onClick: showCreateItemModal(\"ASSET\"),\n label: \"Create Asset\",\n }}\n aria-invalid={errors.type ? \"true\" : \"false\"}\n control={control}\n disabled={operation === \"view\"}\n errorMessage={errors.type?.message}\n name=\"fixedIncomeId\"\n options={fixedIncomeOptions}\n rules={{\n required: \"Asset name is required\",\n }}\n />\n ),\n }\n : undefined,\n isAssetTransaction\n ? {\n label: \"Quantity\",\n Input: () => (\n <RWANumberInput\n aria-invalid={errors.fixedIncomeAmount ? \"true\" : \"false\"}\n control={control}\n disabled={operation === \"view\"}\n errorMessage={errors.fixedIncomeAmount?.message}\n name=\"fixedIncomeAmount\"\n placeholder=\"E.g. 1,000.00\"\n rules={{\n required: \"Quantity is required\",\n validate: {\n positive: (value) =>\n (!!value && Number(value) > 0) ||\n \"Asset proceeds must be greater than zero\",\n },\n }}\n />\n ),\n }\n : undefined,\n {\n label: isAssetTransaction ? \"Asset Proceeds\" : \"Cash Amount\",\n Input: () => (\n <>\n <RWANumberInput\n aria-invalid={errors.cashAmount ? \"true\" : \"false\"}\n control={control}\n currency=\"USD\"\n disabled={operation === \"view\"}\n errorMessage={errors.cashAmount?.message}\n name=\"cashAmount\"\n placeholder=\"E.g. $1,000.00\"\n rules={{\n required: \"Asset proceeds is required\",\n validate: {\n positive: (value) =>\n (!!value && Number(value) > 0) ||\n \"Asset proceeds must be greater than zero\",\n },\n }}\n />\n {isAssetTransaction ? (\n <UnitPrice\n control={control}\n isViewOnly={operation === \"view\"}\n />\n ) : null}\n </>\n ),\n },\n {\n label: \"Transaction reference\",\n Input: () => (\n <TransactionReference\n {...register(\"txRef\", {\n disabled: operation === \"view\",\n })}\n aria-invalid={errors.txRef ? \"true\" : \"false\"}\n control={control}\n errorMessage={errors.txRef?.message}\n placeholder=\"E.g. 0x123...\"\n />\n ),\n },\n ].filter(Boolean);\n\n const additionalInputs = (\n <>\n <FeeTransactionsTable\n canHaveTransactionFees={canHaveTransactionFees}\n control={control}\n errors={errors}\n isViewOnly={operation === \"view\"}\n serviceProviderFeeTypeOptions={serviceProviderFeeTypeOptions}\n serviceProviderFeeTypes={serviceProviderFeeTypes}\n showCreateServiceProviderFeeTypeModal={showCreateItemModal(\n \"SERVICE_PROVIDER_FEE_TYPE\",\n )}\n />\n <CashBalanceChange control={control} />\n </>\n );\n\n return { inputs, additionalInputs };\n }\n case tableNames.ACCOUNT: {\n type Payload = FormInputsByTableName[\"ACCOUNT\"];\n const register = _register as UseFormRegister<Payload>;\n const formState = _formState as FormState<Payload>;\n const { errors } = formState;\n const inputs = [\n {\n label: \"Account Label\",\n Input: () => (\n <RWATableTextInput\n {...register(\"label\", {\n disabled: operation === \"view\",\n required: \"Account label is required\",\n })}\n aria-invalid={\n errors.label?.type === \"required\" ? \"true\" : \"false\"\n }\n errorMessage={errors.label?.message}\n placeholder=\"E.g. My Label\"\n />\n ),\n },\n {\n label: \"Account Reference\",\n Input: () => (\n <RWATableTextInput\n {...register(\"reference\", {\n disabled: operation === \"view\",\n required: \"Account reference is required\",\n })}\n aria-invalid={\n errors.reference?.type === \"required\" ? \"true\" : \"false\"\n }\n errorMessage={errors.reference?.message}\n placeholder=\"E.g. bank account number or ETH address\"\n />\n ),\n },\n ];\n return { inputs };\n }\n case tableNames.SPV: {\n type Payload = FormInputsByTableName[\"SPV\"];\n const register = _register as UseFormRegister<Payload>;\n const formState = _formState as FormState<Payload>;\n const { errors } = formState;\n\n const inputs = [\n {\n label: \"SPV name\",\n Input: () => (\n <RWATableTextInput\n {...register(\"name\", {\n disabled: operation === \"view\",\n required: \"SPV name is required\",\n })}\n aria-invalid={\n errors.name?.type === \"required\" ? \"true\" : \"false\"\n }\n errorMessage={errors.name?.message}\n placeholder=\"E.g. My SPV name\"\n />\n ),\n },\n ];\n\n return { inputs };\n }\n case tableNames.FIXED_INCOME_TYPE: {\n type Payload = FormInputsByTableName[\"FIXED_INCOME_TYPE\"];\n const register = _register as UseFormRegister<Payload>;\n const formState = _formState as FormState<Payload>;\n const { errors } = formState;\n\n const inputs = [\n {\n label: \"Fixed Income Type Name\",\n Input: () => (\n <RWATableTextInput\n {...register(\"name\", {\n disabled: operation === \"view\",\n required: \"Fixed Income Type name is required\",\n })}\n aria-invalid={\n errors.name?.type === \"required\" ? \"true\" : \"false\"\n }\n errorMessage={errors.name?.message}\n placeholder=\"E.g. My Fixed Income Type name\"\n />\n ),\n },\n ];\n\n return { inputs };\n }\n case tableNames.SERVICE_PROVIDER_FEE_TYPE: {\n type Payload = FormInputsByTableName[\"SERVICE_PROVIDER_FEE_TYPE\"];\n const register = _register as UseFormRegister<Payload>;\n const formState = _formState as FormState<Payload>;\n const { errors } = formState;\n const control = _control as Control<Payload>;\n\n const makeAccountLabel = (account: Account) => {\n return `${account.label} (${account.reference})`;\n };\n\n const makeAccountOptions = (accounts: Account[]) => {\n return accounts.map((account) => ({\n ...account,\n value: account.id,\n label: makeAccountLabel(account),\n }));\n };\n\n const inputs = [\n {\n label: \"Service Provider Name\",\n Input: () => (\n <RWATableTextInput\n {...register(\"name\", {\n disabled: operation === \"view\",\n required: \"Service provider name is required\",\n })}\n aria-invalid={\n errors.name?.type === \"required\" ? \"true\" : \"false\"\n }\n errorMessage={errors.name?.message}\n placeholder=\"E.g. My Service Provider\"\n />\n ),\n },\n {\n label: \"Fee Type\",\n Input: () => (\n <RWATableTextInput\n {...register(\"feeType\", {\n disabled: operation === \"view\",\n required: \"Fee type is required\",\n })}\n aria-invalid={\n errors.name?.type === \"required\" ? \"true\" : \"false\"\n }\n errorMessage={errors.name?.message}\n placeholder=\"E.g. My Fee Type\"\n />\n ),\n },\n {\n label: \"Account\",\n Input: () => (\n <RWATableSelect\n addItemButtonProps={{\n onClick: showCreateItemModal(\"ACCOUNT\"),\n label: \"Create Account\",\n }}\n aria-invalid={errors.accountId ? \"true\" : \"false\"}\n control={control}\n disabled={operation === \"view\"}\n errorMessage={errors.accountId?.message}\n name=\"accountId\"\n options={makeAccountOptions(accounts)}\n rules={{ required: \"Account is required\" }}\n />\n ),\n },\n ];\n\n return { inputs };\n }\n }\n }, [\n _formState,\n _control,\n _register,\n _tableItem,\n _watch,\n accounts,\n fixedIncomeTypes,\n fixedIncomes,\n operation,\n serviceProviderFeeTypes,\n showCreateItemModal,\n spvs,\n tableName,\n ]);\n}\n"],"names":["useFormInputs","props","tableName","operation","_formState","_tableItem","_register","_watch","_control","fixedIncomeTypes","spvs","serviceProviderFeeTypes","accounts","fixedIncomes","useEditorContext","showModal","useModal","showCreateItemModal","useCallback","useMemo","tableNames","tableItem","register","formState","errors","control","derivedInputsToDisplay","jsx","Fragment","handleTableDatum","RWATableTextInput","_a","formatDateForDisplay","RWATableSelect","t","watch","type","isFeesTransaction","feesTransactions","isAssetTransaction","assetGroupTransactions","canHaveTransactionFees","transactionTypeOptions","allGroupTransactionTypes","groupTransactionTypeLabels","fixedIncomeOptions","fixedIncome","makeFixedIncomeOptionLabel","serviceProviderFeeTypeOptions","spft","account","inputs","EntryTimeLabel","RWANumberInput","value","jsxs","UnitPrice","TransactionReference","additionalInputs","FeeTransactionsTable","CashBalanceChange","_b","makeAccountLabel","makeAccountOptions"],"mappings":";;;;;;;;;;;;;;;;;AAgDO,SAASA,GAAcC,GAG5B;AACM,QAAA;AAAA,IACJ,WAAAC;AAAA,IACA,WAAAC;AAAA,IACA,WAAWC;AAAA,IACX,WAAWC;AAAA,IACX,UAAUC;AAAA,IACV,OAAOC;AAAA,IACP,SAASC;AAAA,EAAA,IACPP,GACE;AAAA,IACJ,kBAAAQ;AAAA,IACA,MAAAC;AAAA,IACA,yBAAAC;AAAA,IACA,UAAAC;AAAA,IACA,cAAAC;AAAA,MACEC,EAAiB,GACf,EAAE,WAAAC,EAAU,IAAIC,EAAS,GACzBC,IAAsBC;AAAA,IAC1B,CAAChB,MAAyB,MAAM;AAC9B,MAAAa,EAAU,cAAc,EAAE,WAAAb,EAAAA,CAAW;AAAA,IACvC;AAAA,IACA,CAACa,CAAS;AAAA,EACZ;AACA,SAAOI,EAAQ,MAAM;AACnB,YAAQjB,GAAW;AAAA,MACjB,KAAKkB,EAAW,OAAO;AACrB,cAAMC,IAAYhB,GAEZiB,IAAWhB,GACXiB,IAAYnB,GACZ,EAAE,QAAAoB,MAAWD,GAEbE,IAAUjB,GACVkB,IACJvB,MAAc,YAAckB,IACxB;AAAA,UACE;AAAA,YACE,OAAO;AAAA,YACP,OAAO,MAAM,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A,gBAAcO,EAAO,YAAY,SAAS;AAAA,kBAC1C,SAAAC;AAAA,kBACA,UAAUtB,MAAc;AAAA,kBACxB,eAAc4B,IAAAP,EAAO,cAAP,gBAAAO,EAAkB;AAAA,kBAChC,MAAK;AAAA,kBACL,SAASgC,EAAmBnD,CAAQ;AAAA,kBACpC,OAAO,EAAE,UAAU,sBAAsB;AAAA,gBAAA;AAAA,cAAA;AAAA;AAAA,UAC3C;AAAA,QAGN,EAEgB;AAAA,MAAA;AAAA,IAClB;AAAA,EACF,GACC;AAAA,IACDR;AAAA,IACAI;AAAA,IACAF;AAAA,IACAD;AAAA,IACAE;AAAA,IACAK;AAAA,IACAH;AAAA,IACAI;AAAA,IACAV;AAAA,IACAQ;AAAA,IACAM;AAAA,IACAP;AAAA,IACAR;AAAA,EAAA,CACD;AACH;"}
@@ -8,7 +8,7 @@ export declare function useTableForm(props: FormHookProps): {
8
8
  inputs: {
9
9
  label: string;
10
10
  Input: () => string | React.JSX.Element;
11
- inputLabel?: string | null;
11
+ inputLabel?: import('react').ReactNode | null;
12
12
  }[];
13
13
  additionalInputs?: import('react').ReactElement;
14
14
  };
@@ -1,4 +1,4 @@
1
- export declare function formatDateForDisplay(date: Date | string, displayTime?: boolean): string;
1
+ export declare function formatDateForDisplay(date: Date | string, displayTime?: boolean, isUTC?: boolean): string;
2
2
  export declare function isISODate(str: string): boolean;
3
3
  export declare function getTimeZone(): string;
4
4
  export declare function isoDateStringToDateInput(isoDateString: string, withTime?: boolean): string;
@@ -1,9 +1,9 @@
1
- import { formatInTimeZone as o } from "date-fns-tz/formatInTimeZone";
2
- function d(t, e = !0) {
3
- const n = e ? "yyyy/MM/dd, HH:mm:ss zzz" : "yyyy/MM/dd";
4
- return o(t, r(), n);
1
+ import { formatInTimeZone as i } from "date-fns-tz/formatInTimeZone";
2
+ function s(t, e = !0, n = !1) {
3
+ const o = e ? "yyyy/MM/dd, HH:mm:ss zzz" : "yyyy/MM/dd", a = n ? "UTC" : r();
4
+ return i(t, a, o);
5
5
  }
6
- function m(t) {
6
+ function d(t) {
7
7
  if (!/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/.test(t)) return !1;
8
8
  const e = new Date(t);
9
9
  return e instanceof Date && !isNaN(e.getTime()) && e.toISOString() === t;
@@ -12,13 +12,13 @@ function r() {
12
12
  return Intl.DateTimeFormat().resolvedOptions().timeZone;
13
13
  }
14
14
  function y(t, e = !1) {
15
- const n = e ? "yyyy-MM-dd'T'HH:mm:ss.SSS" : "yyyy-MM-dd", i = r();
16
- return o(t, i, n);
15
+ const n = e ? "yyyy-MM-dd'T'HH:mm:ss" : "yyyy-MM-dd", o = r();
16
+ return i(t, o, n);
17
17
  }
18
18
  export {
19
- d as formatDateForDisplay,
19
+ s as formatDateForDisplay,
20
20
  r as getTimeZone,
21
- m as isISODate,
21
+ d as isISODate,
22
22
  y as isoDateStringToDateInput
23
23
  };
24
24
  //# sourceMappingURL=date.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"date.js","sources":["../../../src/rwa/utils/date.ts"],"sourcesContent":["import { formatInTimeZone } from \"date-fns-tz/formatInTimeZone\";\n\nexport function formatDateForDisplay(date: Date | string, displayTime = true) {\n const formatString = displayTime ? \"yyyy/MM/dd, HH:mm:ss zzz\" : \"yyyy/MM/dd\";\n return formatInTimeZone(date, getTimeZone(), formatString);\n}\n\nexport function isISODate(str: string) {\n if (!/\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}.\\d{3}Z/.test(str)) return false;\n const d = new Date(str);\n return d instanceof Date && !isNaN(d.getTime()) && d.toISOString() === str;\n}\n\nexport function getTimeZone() {\n return Intl.DateTimeFormat().resolvedOptions().timeZone;\n}\n\nexport function isoDateStringToDateInput(\n isoDateString: string,\n withTime = false,\n) {\n const format = withTime ? \"yyyy-MM-dd'T'HH:mm:ss.SSS\" : \"yyyy-MM-dd\";\n const timeZone = getTimeZone();\n return formatInTimeZone(isoDateString, timeZone, format);\n}\n"],"names":["formatDateForDisplay","date","displayTime","formatString","formatInTimeZone","getTimeZone","isISODate","str","d","isoDateStringToDateInput","isoDateString","withTime","format","timeZone"],"mappings":";AAEgB,SAAAA,EAAqBC,GAAqBC,IAAc,IAAM;AACtE,QAAAC,IAAeD,IAAc,6BAA6B;AAChE,SAAOE,EAAiBH,GAAMI,EAAY,GAAGF,CAAY;AAC3D;AAEO,SAASG,EAAUC,GAAa;AACrC,MAAI,CAAC,6CAA6C,KAAKA,CAAG,EAAU,QAAA;AAC9D,QAAAC,IAAI,IAAI,KAAKD,CAAG;AACf,SAAAC,aAAa,QAAQ,CAAC,MAAMA,EAAE,SAAS,KAAKA,EAAE,YAAA,MAAkBD;AACzE;AAEO,SAASF,IAAc;AAC5B,SAAO,KAAK,iBAAiB,gBAAkB,EAAA;AACjD;AAEgB,SAAAI,EACdC,GACAC,IAAW,IACX;AACM,QAAAC,IAASD,IAAW,8BAA8B,cAClDE,IAAWR,EAAY;AACtB,SAAAD,EAAiBM,GAAeG,GAAUD,CAAM;AACzD;"}
1
+ {"version":3,"file":"date.js","sources":["../../../src/rwa/utils/date.ts"],"sourcesContent":["import { formatInTimeZone } from \"date-fns-tz/formatInTimeZone\";\n\nexport function formatDateForDisplay(\n date: Date | string,\n displayTime = true,\n isUTC = false,\n) {\n const formatString = displayTime ? \"yyyy/MM/dd, HH:mm:ss zzz\" : \"yyyy/MM/dd\";\n const timeZone = isUTC ? \"UTC\" : getTimeZone();\n return formatInTimeZone(date, timeZone, formatString);\n}\n\nexport function isISODate(str: string) {\n if (!/\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}.\\d{3}Z/.test(str)) return false;\n const d = new Date(str);\n return d instanceof Date && !isNaN(d.getTime()) && d.toISOString() === str;\n}\n\nexport function getTimeZone() {\n return Intl.DateTimeFormat().resolvedOptions().timeZone;\n}\n\nexport function isoDateStringToDateInput(\n isoDateString: string,\n withTime = false,\n) {\n const format = withTime ? \"yyyy-MM-dd'T'HH:mm:ss\" : \"yyyy-MM-dd\";\n const timeZone = getTimeZone();\n return formatInTimeZone(isoDateString, timeZone, format);\n}\n"],"names":["formatDateForDisplay","date","displayTime","isUTC","formatString","timeZone","getTimeZone","formatInTimeZone","isISODate","str","d","isoDateStringToDateInput","isoDateString","withTime","format"],"mappings":";AAEO,SAASA,EACdC,GACAC,IAAc,IACdC,IAAQ,IACR;AACM,QAAAC,IAAeF,IAAc,6BAA6B,cAC1DG,IAAWF,IAAQ,QAAQG,EAAY;AACtC,SAAAC,EAAiBN,GAAMI,GAAUD,CAAY;AACtD;AAEO,SAASI,EAAUC,GAAa;AACrC,MAAI,CAAC,6CAA6C,KAAKA,CAAG,EAAU,QAAA;AAC9D,QAAAC,IAAI,IAAI,KAAKD,CAAG;AACf,SAAAC,aAAa,QAAQ,CAAC,MAAMA,EAAE,SAAS,KAAKA,EAAE,YAAA,MAAkBD;AACzE;AAEO,SAASH,IAAc;AAC5B,SAAO,KAAK,iBAAiB,gBAAkB,EAAA;AACjD;AAEgB,SAAAK,EACdC,GACAC,IAAW,IACX;AACM,QAAAC,IAASD,IAAW,0BAA0B,cAC9CR,IAAWC,EAAY;AACtB,SAAAC,EAAiBK,GAAeP,GAAUS,CAAM;AACzD;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/design-system",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "description": "",
5
5
  "files": [
6
6
  "/dist"