@layerfi/components 0.1.16 → 0.1.17

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.
package/dist/index.d.ts CHANGED
@@ -130,18 +130,17 @@ declare module '@layerfi/components/api/layer/chart_of_accounts' {
130
130
 
131
131
  }
132
132
  declare module '@layerfi/components/api/layer/journal' {
133
- import { Account, NewAccount } from '@layerfi/components/types';
134
133
  import { JournalEntry } from '@layerfi/components/types/journal';
135
134
  export const getJournal: (baseUrl: string, accessToken: string | undefined, options?: {
136
135
  params?: Record<string, string | undefined> | undefined;
137
136
  } | undefined) => () => Promise<{
138
137
  data: JournalEntry[];
139
138
  }>;
140
- export const addEntry: (baseUrl: string, accessToken: string | undefined, options?: {
139
+ export const createJournalEntries: (baseUrl: string, accessToken: string | undefined, options?: {
141
140
  params?: Record<string, string | undefined> | undefined;
142
- body?: NewAccount | undefined;
141
+ body?: Record<string, unknown> | undefined;
143
142
  } | undefined) => Promise<{
144
- data: Account;
143
+ data: JournalEntry[];
145
144
  }>;
146
145
 
147
146
  }
@@ -321,11 +320,11 @@ declare module '@layerfi/components/api/layer' {
321
320
  } | undefined) => () => Promise<{
322
321
  data: import("@layerfi/components/types").JournalEntry[];
323
322
  }>;
324
- addEntry: (baseUrl: string, accessToken: string | undefined, options?: {
323
+ createJournalEntries: (baseUrl: string, accessToken: string | undefined, options?: {
325
324
  params?: Record<string, string | undefined> | undefined;
326
- body?: import("@layerfi/components/types").NewAccount | undefined;
325
+ body?: Record<string, unknown> | undefined;
327
326
  } | undefined) => Promise<{
328
- data: import("@layerfi/components/types").Account;
327
+ data: import("@layerfi/components/types").JournalEntry[];
329
328
  }>;
330
329
  getPlaidLinkToken: (baseUrl: string, accessToken: string | undefined, options?: {
331
330
  params?: {
@@ -609,6 +608,14 @@ declare module '@layerfi/components/components/Button/Button' {
609
608
  }
610
609
  export const Button: ({ className, children, variant, leftIcon, rightIcon, iconOnly, iconAsPrimary, justify, ...props }: ButtonProps) => React.JSX.Element;
611
610
 
611
+ }
612
+ declare module '@layerfi/components/components/Button/CloseButton' {
613
+ import React, { ButtonHTMLAttributes } from 'react';
614
+ export interface CloseButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
615
+ textOnly?: boolean;
616
+ }
617
+ export const CloseButton: ({ className, children, textOnly, ...props }: CloseButtonProps) => React.JSX.Element;
618
+
612
619
  }
613
620
  declare module '@layerfi/components/components/Button/IconButton' {
614
621
  import React, { ButtonHTMLAttributes, ReactNode } from 'react';
@@ -661,6 +668,7 @@ declare module '@layerfi/components/components/Button/index' {
661
668
  export { SubmitButton } from '@layerfi/components/components/Button/SubmitButton';
662
669
  export { TextButton } from '@layerfi/components/components/Button/TextButton';
663
670
  export { BackButton } from '@layerfi/components/components/Button/BackButton';
671
+ export { CloseButton } from '@layerfi/components/components/Button/CloseButton';
664
672
 
665
673
  }
666
674
  declare module '@layerfi/components/components/Card/Card' {
@@ -974,19 +982,6 @@ declare module '@layerfi/components/components/ExpandedBankTransactionRow/Expand
974
982
  declare module '@layerfi/components/components/ExpandedBankTransactionRow/index' {
975
983
  export { ExpandedBankTransactionRow } from '@layerfi/components/components/ExpandedBankTransactionRow/ExpandedBankTransactionRow';
976
984
 
977
- }
978
- declare module '@layerfi/components/components/Hello/Hello' {
979
- import React from 'react';
980
- type Props = {
981
- user?: string | undefined;
982
- };
983
- export const Hello: ({ user }: Props) => React.JSX.Element;
984
- export {};
985
-
986
- }
987
- declare module '@layerfi/components/components/Hello/index' {
988
- export { Hello } from '@layerfi/components/components/Hello/Hello';
989
-
990
985
  }
991
986
  declare module '@layerfi/components/components/HoverMenu/HoverMenu' {
992
987
  import React, { ReactNode } from 'react';
@@ -1007,6 +1002,21 @@ declare module '@layerfi/components/components/HoverMenu/HoverMenu' {
1007
1002
  declare module '@layerfi/components/components/HoverMenu/index' {
1008
1003
  export { HoverMenu, HoverMenuProps } from '@layerfi/components/components/HoverMenu/HoverMenu';
1009
1004
 
1005
+ }
1006
+ declare module '@layerfi/components/components/Input/DateInput' {
1007
+ import React from 'react';
1008
+ import 'react-datepicker/dist/react-datepicker.css';
1009
+ export const DateInput: ({ selected, onChange, ...props }: {
1010
+ selected?: string | undefined;
1011
+ onChange?: ((date: string) => void) | undefined;
1012
+ dateFormat?: string | undefined;
1013
+ timeIntervals?: number | undefined;
1014
+ timeCaption?: string | undefined;
1015
+ placeholderText?: string | undefined;
1016
+ showTimeSelect?: boolean | undefined;
1017
+ showTimeSelectOnly?: boolean | undefined;
1018
+ }) => React.JSX.Element;
1019
+
1010
1020
  }
1011
1021
  declare module '@layerfi/components/components/Input/FileInput' {
1012
1022
  import React from 'react';
@@ -1038,6 +1048,19 @@ declare module '@layerfi/components/components/Input/InputGroup' {
1038
1048
  }
1039
1049
  export const InputGroup: ({ label, name, className, inline, children, }: InputGroupProps) => React.JSX.Element;
1040
1050
 
1051
+ }
1052
+ declare module '@layerfi/components/components/Input/InputWithBadge' {
1053
+ import React, { HTMLProps } from 'react';
1054
+ import { BadgeVariant } from '@layerfi/components/components/Badge/index';
1055
+ export interface InputWithBadgeProps extends HTMLProps<HTMLInputElement> {
1056
+ isInvalid?: boolean;
1057
+ errorMessage?: string;
1058
+ leftText?: string;
1059
+ variant?: BadgeVariant;
1060
+ badge: React.ReactNode;
1061
+ }
1062
+ export const InputWithBadge: ({ className, isInvalid, errorMessage, leftText, badge, variant, ...props }: InputWithBadgeProps) => React.JSX.Element;
1063
+
1041
1064
  }
1042
1065
  declare module '@layerfi/components/components/Input/Select' {
1043
1066
  import React from 'react';
@@ -1062,35 +1085,65 @@ declare module '@layerfi/components/components/Input/index' {
1062
1085
  export { InputGroup } from '@layerfi/components/components/Input/InputGroup';
1063
1086
  export { FileInput } from '@layerfi/components/components/Input/FileInput';
1064
1087
  export { Select } from '@layerfi/components/components/Input/Select';
1088
+ export { InputWithBadge } from '@layerfi/components/components/Input/InputWithBadge';
1089
+ export { DateInput } from '@layerfi/components/components/Input/DateInput';
1065
1090
 
1066
1091
  }
1067
1092
  declare module '@layerfi/components/components/Journal/Journal' {
1068
1093
  import React from 'react';
1069
- import { useJournal } from '@layerfi/components/hooks/useJournal/index';
1070
1094
  export type View = 'mobile' | 'tablet' | 'desktop';
1095
+ export interface JournalConfig {
1096
+ form: {
1097
+ addEntryLinesLimit?: number;
1098
+ };
1099
+ }
1071
1100
  export interface JournalProps {
1072
1101
  asWidget?: boolean;
1102
+ config?: JournalConfig;
1073
1103
  }
1074
- export type JournalContextType = ReturnType<typeof useJournal>;
1075
- export const JournalContext: React.Context<{
1076
- data?: import("@layerfi/components/types").JournalEntry[] | undefined;
1077
- entryData?: import("@layerfi/components/types").JournalEntryLine | undefined;
1078
- isLoading?: boolean | undefined;
1079
- isLoadingEntry?: boolean | undefined;
1080
- isValidating?: boolean | undefined;
1081
- isValidatingEntry?: boolean | undefined;
1082
- error?: unknown;
1083
- errorEntry?: unknown;
1084
- refetch: () => void;
1085
- selectedEntryId?: string | undefined;
1086
- setSelectedEntryId: (id?: string | undefined) => void;
1087
- closeSelectedEntry: () => void;
1088
- }>;
1104
+ export const JOURNAL_CONFIG: JournalConfig;
1089
1105
  export const Journal: (props: JournalProps) => React.JSX.Element;
1090
1106
 
1091
1107
  }
1092
1108
  declare module '@layerfi/components/components/Journal/index' {
1093
- export { Journal, JournalContext, View } from '@layerfi/components/components/Journal/Journal';
1109
+ export { Journal, View } from '@layerfi/components/components/Journal/Journal';
1110
+
1111
+ }
1112
+ declare module '@layerfi/components/components/JournalEntryDetails/JournalEntryDetails' {
1113
+ import React from 'react';
1114
+ export const JournalEntryDetails: () => React.JSX.Element;
1115
+
1116
+ }
1117
+ declare module '@layerfi/components/components/JournalEntryDetails/index' {
1118
+ export { JournalEntryDetails } from '@layerfi/components/components/JournalEntryDetails/JournalEntryDetails';
1119
+
1120
+ }
1121
+ declare module '@layerfi/components/components/JournalForm/JournalForm' {
1122
+ import React from 'react';
1123
+ import { JournalConfig } from '@layerfi/components/components/Journal/Journal';
1124
+ export const JournalForm: ({ config }: {
1125
+ config: JournalConfig;
1126
+ }) => React.JSX.Element;
1127
+
1128
+ }
1129
+ declare module '@layerfi/components/components/JournalForm/JournalFormEntryLines' {
1130
+ import React from 'react';
1131
+ import { Direction, JournalEntryLineItem } from '@layerfi/components/types';
1132
+ import { LedgerAccountBalance } from '@layerfi/components/types/chart_of_accounts';
1133
+ import { BaseSelectOption } from '@layerfi/components/types/general';
1134
+ import { JournalConfig } from '@layerfi/components/components/Journal/Journal';
1135
+ export const JournalFormEntryLines: ({ entrylineItems, addEntryLine, removeEntryLine, changeFormData, sendingForm, config, }: {
1136
+ entrylineItems: JournalEntryLineItem[];
1137
+ addEntryLine: (direction: Direction) => void;
1138
+ removeEntryLine: (index: number) => void;
1139
+ changeFormData: (name: string, value: string | BaseSelectOption | number | undefined, lineItemIndex: number, accounts?: LedgerAccountBalance[] | undefined) => void;
1140
+ sendingForm: boolean;
1141
+ config: JournalConfig;
1142
+ }) => React.JSX.Element;
1143
+
1144
+ }
1145
+ declare module '@layerfi/components/components/JournalForm/index' {
1146
+ export { JournalForm } from '@layerfi/components/components/JournalForm/JournalForm';
1094
1147
 
1095
1148
  }
1096
1149
  declare module '@layerfi/components/components/JournalRow/JournalRow' {
@@ -1118,8 +1171,10 @@ declare module '@layerfi/components/components/JournalRow/index' {
1118
1171
  }
1119
1172
  declare module '@layerfi/components/components/JournalSidebar/JournalSidebar' {
1120
1173
  import React, { RefObject } from 'react';
1121
- export const JournalSidebar: ({ parentRef: _parentRef, }: {
1122
- parentRef?: RefObject<HTMLDivElement>;
1174
+ import { JournalConfig } from '@layerfi/components/components/Journal/Journal';
1175
+ export const JournalSidebar: ({ parentRef: _parentRef, config, }: {
1176
+ parentRef?: React.RefObject<HTMLDivElement> | undefined;
1177
+ config: JournalConfig;
1123
1178
  }) => React.JSX.Element;
1124
1179
 
1125
1180
  }
@@ -1130,10 +1185,12 @@ declare module '@layerfi/components/components/JournalSidebar/index' {
1130
1185
  declare module '@layerfi/components/components/JournalTable/JournalTable' {
1131
1186
  import React, { RefObject } from 'react';
1132
1187
  import { View } from '@layerfi/components/components/Journal/index';
1133
- export const JournalTable: ({ view, containerRef, pageSize, }: {
1188
+ import { JournalConfig } from '@layerfi/components/components/Journal/Journal';
1189
+ export const JournalTable: ({ view, containerRef, pageSize, config, }: {
1134
1190
  view: View;
1135
1191
  containerRef: RefObject<HTMLDivElement>;
1136
1192
  pageSize?: number | undefined;
1193
+ config: JournalConfig;
1137
1194
  }) => React.JSX.Element;
1138
1195
 
1139
1196
  }
@@ -1591,7 +1648,11 @@ declare module '@layerfi/components/components/SkeletonLoader/index' {
1591
1648
  }
1592
1649
  declare module '@layerfi/components/components/Textarea/Textarea' {
1593
1650
  import React, { HTMLProps } from 'react';
1594
- export const Textarea: ({ className, ...props }: HTMLProps<HTMLTextAreaElement>) => React.JSX.Element;
1651
+ export interface TextareaProps extends HTMLProps<HTMLTextAreaElement> {
1652
+ isInvalid?: boolean;
1653
+ errorMessage?: string;
1654
+ }
1655
+ export const Textarea: ({ className, isInvalid, errorMessage, ...props }: TextareaProps) => React.JSX.Element;
1595
1656
 
1596
1657
  }
1597
1658
  declare module '@layerfi/components/components/Textarea/index' {
@@ -1963,6 +2024,40 @@ declare module '@layerfi/components/contexts/ChartOfAccountsContext/ChartOfAccou
1963
2024
  declare module '@layerfi/components/contexts/ChartOfAccountsContext/index' {
1964
2025
  export { ChartOfAccountsContext } from '@layerfi/components/contexts/ChartOfAccountsContext/ChartOfAccountsContext';
1965
2026
 
2027
+ }
2028
+ declare module '@layerfi/components/contexts/JournalContext/JournalContext' {
2029
+ /// <reference types="react" />
2030
+ import { useJournal } from '@layerfi/components/hooks/useJournal/index';
2031
+ export type JournalContextType = ReturnType<typeof useJournal>;
2032
+ export const JournalContext: import("react").Context<{
2033
+ data?: import("@layerfi/components/types").JournalEntry[] | undefined;
2034
+ isLoading?: boolean | undefined;
2035
+ isLoadingEntry?: boolean | undefined;
2036
+ isValidating?: boolean | undefined;
2037
+ isValidatingEntry?: boolean | undefined;
2038
+ error?: unknown;
2039
+ errorEntry?: unknown;
2040
+ refetch: () => void;
2041
+ selectedEntryId?: string | undefined;
2042
+ setSelectedEntryId: (id?: string | undefined) => void;
2043
+ closeSelectedEntry: () => void;
2044
+ create: (newJournalEntry: import("@layerfi/components/types/journal").NewJournalEntry) => void;
2045
+ changeFormData: (name: string, value: string | number | import("@layerfi/components/types/general").BaseSelectOption | undefined, lineItemIndex?: number | undefined, accounts?: import("../../types/chart_of_accounts").LedgerAccountBalance[] | undefined) => void;
2046
+ submitForm: () => void;
2047
+ cancelForm: () => void;
2048
+ addEntry: () => void;
2049
+ sendingForm: boolean;
2050
+ form?: import("@layerfi/components/hooks/useJournal/useJournal").JournalFormTypes | undefined;
2051
+ apiError?: string | undefined;
2052
+ setForm: (form?: import("@layerfi/components/hooks/useJournal/useJournal").JournalFormTypes | undefined) => void;
2053
+ addEntryLine: (direction: import("@layerfi/components/types").Direction) => void;
2054
+ removeEntryLine: (index: number) => void;
2055
+ }>;
2056
+
2057
+ }
2058
+ declare module '@layerfi/components/contexts/JournalContext/index' {
2059
+ export { JournalContext } from '@layerfi/components/contexts/JournalContext/JournalContext';
2060
+
1966
2061
  }
1967
2062
  declare module '@layerfi/components/contexts/LayerContext/LayerContext' {
1968
2063
  /// <reference types="react" />
@@ -2066,13 +2161,9 @@ declare module '@layerfi/components/hooks/useChartOfAccounts/index' {
2066
2161
 
2067
2162
  }
2068
2163
  declare module '@layerfi/components/hooks/useChartOfAccounts/useChartOfAccounts' {
2069
- import { DateRange, NewAccount } from '@layerfi/components/types';
2164
+ import { FormError, DateRange, NewAccount } from '@layerfi/components/types';
2070
2165
  import { ChartWithBalances, LedgerAccountBalance } from '@layerfi/components/types/chart_of_accounts';
2071
2166
  import { BaseSelectOption } from '@layerfi/components/types/general';
2072
- interface FormError {
2073
- field: string;
2074
- message: string;
2075
- }
2076
2167
  export interface ChartOfAccountsForm {
2077
2168
  action: 'new' | 'edit';
2078
2169
  accountId?: string;
@@ -2137,10 +2228,12 @@ declare module '@layerfi/components/hooks/useJournal/index' {
2137
2228
 
2138
2229
  }
2139
2230
  declare module '@layerfi/components/hooks/useJournal/useJournal' {
2140
- import { JournalEntry, JournalEntryLine } from '@layerfi/components/types/journal';
2231
+ import { Direction, FormError, FormErrorWithId } from '@layerfi/components/types';
2232
+ import { LedgerAccountBalance } from '@layerfi/components/types/chart_of_accounts';
2233
+ import { BaseSelectOption } from '@layerfi/components/types/general';
2234
+ import { JournalEntry, NewJournalEntry } from '@layerfi/components/types/journal';
2141
2235
  type UseJournal = () => {
2142
2236
  data?: JournalEntry[];
2143
- entryData?: JournalEntryLine;
2144
2237
  isLoading?: boolean;
2145
2238
  isLoadingEntry?: boolean;
2146
2239
  isValidating?: boolean;
@@ -2151,7 +2244,26 @@ declare module '@layerfi/components/hooks/useJournal/useJournal' {
2151
2244
  selectedEntryId?: string;
2152
2245
  setSelectedEntryId: (id?: string) => void;
2153
2246
  closeSelectedEntry: () => void;
2247
+ create: (newJournalEntry: NewJournalEntry) => void;
2248
+ changeFormData: (name: string, value: string | BaseSelectOption | undefined | number, lineItemIndex?: number, accounts?: LedgerAccountBalance[] | undefined) => void;
2249
+ submitForm: () => void;
2250
+ cancelForm: () => void;
2251
+ addEntry: () => void;
2252
+ sendingForm: boolean;
2253
+ form?: JournalFormTypes;
2254
+ apiError?: string;
2255
+ setForm: (form?: JournalFormTypes) => void;
2256
+ addEntryLine: (direction: Direction) => void;
2257
+ removeEntryLine: (index: number) => void;
2154
2258
  };
2259
+ export interface JournalFormTypes {
2260
+ action: string;
2261
+ data: NewJournalEntry;
2262
+ errors?: {
2263
+ entry: FormError[];
2264
+ lineItems: FormErrorWithId[];
2265
+ } | undefined;
2266
+ }
2155
2267
  export const useJournal: UseJournal;
2156
2268
  export const flattenEntries: (entries: JournalEntry[]) => JournalEntry[];
2157
2269
  export {};
@@ -2414,6 +2526,13 @@ declare module '@layerfi/components/icons/ChevronRight' {
2414
2526
  const ChavronRight: ({ size, ...props }: IconSvgProps) => React.JSX.Element;
2415
2527
  export default ChavronRight;
2416
2528
 
2529
+ }
2530
+ declare module '@layerfi/components/icons/CloseIcon' {
2531
+ import * as React from 'react';
2532
+ import { IconSvgProps } from '@layerfi/components/icons/types';
2533
+ const CloseIcon: ({ size, ...props }: IconSvgProps) => React.JSX.Element;
2534
+ export default CloseIcon;
2535
+
2417
2536
  }
2418
2537
  declare module '@layerfi/components/icons/CreditCard' {
2419
2538
  import * as React from 'react';
@@ -2571,7 +2690,6 @@ declare module '@layerfi/components/icons/types' {
2571
2690
  declare module '@layerfi/components/index' {
2572
2691
  export { BalanceSheet } from '@layerfi/components/components/BalanceSheet/index';
2573
2692
  export { BankTransactions } from '@layerfi/components/components/BankTransactions/index';
2574
- export { Hello } from '@layerfi/components/components/Hello/index';
2575
2693
  export { LinkedAccounts } from '@layerfi/components/components/LinkedAccounts/index';
2576
2694
  export { ProfitAndLoss } from '@layerfi/components/components/ProfitAndLoss/index';
2577
2695
  export { ProfitAndLossView } from '@layerfi/components/components/ProfitAndLossView/index';
@@ -2907,6 +3025,26 @@ declare module '@layerfi/components/types/journal' {
2907
3025
  entry_at: string;
2908
3026
  createdAt: string;
2909
3027
  }
3028
+ export type NewJournalEntry = {
3029
+ entry_at: string;
3030
+ created_by: string;
3031
+ memo: string;
3032
+ line_items: JournalEntryLineItem[];
3033
+ };
3034
+ export type JournalEntryLineItem = {
3035
+ account_identifier: {
3036
+ type: string;
3037
+ stable_name: string;
3038
+ id: string;
3039
+ name: string;
3040
+ subType: {
3041
+ value: string;
3042
+ label: string;
3043
+ } | undefined;
3044
+ };
3045
+ amount: number;
3046
+ direction: Direction;
3047
+ };
2910
3048
 
2911
3049
  }
2912
3050
  declare module '@layerfi/components/types/layer_context' {
@@ -3169,7 +3307,14 @@ declare module '@layerfi/components/types' {
3169
3307
  export { ChartOfAccounts, Account, NewAccount, EditAccount, } from '@layerfi/components/types/chart_of_accounts';
3170
3308
  export { LedgerAccountLineItems as LedgerAccounts, LedgerAccountLineItem, LedgerAccountsAccount, LedgerAccountsEntry, } from '@layerfi/components/types/ledger_accounts';
3171
3309
  export { SortDirection } from '@layerfi/components/types/general';
3172
- export { JournalEntry, JournalEntryLine, } from '@layerfi/components/types/journal';
3310
+ export interface FormError {
3311
+ field: string;
3312
+ message: string;
3313
+ }
3314
+ export interface FormErrorWithId extends FormError {
3315
+ id: number;
3316
+ }
3317
+ export { JournalEntry, JournalEntryLine, JournalEntryLineItem, } from '@layerfi/components/types/journal';
3173
3318
  export type DateRange<T = Date> = {
3174
3319
  startDate: T;
3175
3320
  endDate: T;
@@ -3209,6 +3354,9 @@ declare module '@layerfi/components/utils/format' {
3209
3354
  * Convert Enum-like (upper snakecase) text into human friendly format.
3210
3355
  */
3211
3356
  export const humanizeEnum: (text: string) => string;
3357
+ export const convertNumberToCurrency: (amount: number | undefined) => string;
3358
+ export const convertCurrencyToNumber: (amount: string) => number;
3359
+ export const CURRENCY_INPUT_PATTERN = "[0-9]+(.[0-9]+)?";
3212
3360
 
3213
3361
  }
3214
3362
  declare module '@layerfi/components/utils/helpers' {