@layerfi/components 0.1.16 → 0.1.18

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' {
@@ -1007,6 +1015,21 @@ declare module '@layerfi/components/components/HoverMenu/HoverMenu' {
1007
1015
  declare module '@layerfi/components/components/HoverMenu/index' {
1008
1016
  export { HoverMenu, HoverMenuProps } from '@layerfi/components/components/HoverMenu/HoverMenu';
1009
1017
 
1018
+ }
1019
+ declare module '@layerfi/components/components/Input/DateInput' {
1020
+ import React from 'react';
1021
+ import 'react-datepicker/dist/react-datepicker.css';
1022
+ export const DateInput: ({ selected, onChange, ...props }: {
1023
+ selected?: string | undefined;
1024
+ onChange?: ((date: string) => void) | undefined;
1025
+ dateFormat?: string | undefined;
1026
+ timeIntervals?: number | undefined;
1027
+ timeCaption?: string | undefined;
1028
+ placeholderText?: string | undefined;
1029
+ showTimeSelect?: boolean | undefined;
1030
+ showTimeSelectOnly?: boolean | undefined;
1031
+ }) => React.JSX.Element;
1032
+
1010
1033
  }
1011
1034
  declare module '@layerfi/components/components/Input/FileInput' {
1012
1035
  import React from 'react';
@@ -1038,6 +1061,19 @@ declare module '@layerfi/components/components/Input/InputGroup' {
1038
1061
  }
1039
1062
  export const InputGroup: ({ label, name, className, inline, children, }: InputGroupProps) => React.JSX.Element;
1040
1063
 
1064
+ }
1065
+ declare module '@layerfi/components/components/Input/InputWithBadge' {
1066
+ import React, { HTMLProps } from 'react';
1067
+ import { BadgeVariant } from '@layerfi/components/components/Badge/index';
1068
+ export interface InputWithBadgeProps extends HTMLProps<HTMLInputElement> {
1069
+ isInvalid?: boolean;
1070
+ errorMessage?: string;
1071
+ leftText?: string;
1072
+ variant?: BadgeVariant;
1073
+ badge: React.ReactNode;
1074
+ }
1075
+ export const InputWithBadge: ({ className, isInvalid, errorMessage, leftText, badge, variant, ...props }: InputWithBadgeProps) => React.JSX.Element;
1076
+
1041
1077
  }
1042
1078
  declare module '@layerfi/components/components/Input/Select' {
1043
1079
  import React from 'react';
@@ -1062,35 +1098,65 @@ declare module '@layerfi/components/components/Input/index' {
1062
1098
  export { InputGroup } from '@layerfi/components/components/Input/InputGroup';
1063
1099
  export { FileInput } from '@layerfi/components/components/Input/FileInput';
1064
1100
  export { Select } from '@layerfi/components/components/Input/Select';
1101
+ export { InputWithBadge } from '@layerfi/components/components/Input/InputWithBadge';
1102
+ export { DateInput } from '@layerfi/components/components/Input/DateInput';
1065
1103
 
1066
1104
  }
1067
1105
  declare module '@layerfi/components/components/Journal/Journal' {
1068
1106
  import React from 'react';
1069
- import { useJournal } from '@layerfi/components/hooks/useJournal/index';
1070
1107
  export type View = 'mobile' | 'tablet' | 'desktop';
1108
+ export interface JournalConfig {
1109
+ form: {
1110
+ addEntryLinesLimit?: number;
1111
+ };
1112
+ }
1071
1113
  export interface JournalProps {
1072
1114
  asWidget?: boolean;
1115
+ config?: JournalConfig;
1073
1116
  }
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
- }>;
1117
+ export const JOURNAL_CONFIG: JournalConfig;
1089
1118
  export const Journal: (props: JournalProps) => React.JSX.Element;
1090
1119
 
1091
1120
  }
1092
1121
  declare module '@layerfi/components/components/Journal/index' {
1093
- export { Journal, JournalContext, View } from '@layerfi/components/components/Journal/Journal';
1122
+ export { Journal, View } from '@layerfi/components/components/Journal/Journal';
1123
+
1124
+ }
1125
+ declare module '@layerfi/components/components/JournalEntryDetails/JournalEntryDetails' {
1126
+ import React from 'react';
1127
+ export const JournalEntryDetails: () => React.JSX.Element;
1128
+
1129
+ }
1130
+ declare module '@layerfi/components/components/JournalEntryDetails/index' {
1131
+ export { JournalEntryDetails } from '@layerfi/components/components/JournalEntryDetails/JournalEntryDetails';
1132
+
1133
+ }
1134
+ declare module '@layerfi/components/components/JournalForm/JournalForm' {
1135
+ import React from 'react';
1136
+ import { JournalConfig } from '@layerfi/components/components/Journal/Journal';
1137
+ export const JournalForm: ({ config }: {
1138
+ config: JournalConfig;
1139
+ }) => React.JSX.Element;
1140
+
1141
+ }
1142
+ declare module '@layerfi/components/components/JournalForm/JournalFormEntryLines' {
1143
+ import React from 'react';
1144
+ import { Direction, JournalEntryLineItem } from '@layerfi/components/types';
1145
+ import { LedgerAccountBalance } from '@layerfi/components/types/chart_of_accounts';
1146
+ import { BaseSelectOption } from '@layerfi/components/types/general';
1147
+ import { JournalConfig } from '@layerfi/components/components/Journal/Journal';
1148
+ export const JournalFormEntryLines: ({ entrylineItems, addEntryLine, removeEntryLine, changeFormData, sendingForm, config, }: {
1149
+ entrylineItems: JournalEntryLineItem[];
1150
+ addEntryLine: (direction: Direction) => void;
1151
+ removeEntryLine: (index: number) => void;
1152
+ changeFormData: (name: string, value: string | BaseSelectOption | number | undefined, lineItemIndex: number, accounts?: LedgerAccountBalance[] | undefined) => void;
1153
+ sendingForm: boolean;
1154
+ config: JournalConfig;
1155
+ }) => React.JSX.Element;
1156
+
1157
+ }
1158
+ declare module '@layerfi/components/components/JournalForm/index' {
1159
+ export { JournalForm } from '@layerfi/components/components/JournalForm/JournalForm';
1094
1160
 
1095
1161
  }
1096
1162
  declare module '@layerfi/components/components/JournalRow/JournalRow' {
@@ -1118,8 +1184,10 @@ declare module '@layerfi/components/components/JournalRow/index' {
1118
1184
  }
1119
1185
  declare module '@layerfi/components/components/JournalSidebar/JournalSidebar' {
1120
1186
  import React, { RefObject } from 'react';
1121
- export const JournalSidebar: ({ parentRef: _parentRef, }: {
1122
- parentRef?: RefObject<HTMLDivElement>;
1187
+ import { JournalConfig } from '@layerfi/components/components/Journal/Journal';
1188
+ export const JournalSidebar: ({ parentRef: _parentRef, config, }: {
1189
+ parentRef?: React.RefObject<HTMLDivElement> | undefined;
1190
+ config: JournalConfig;
1123
1191
  }) => React.JSX.Element;
1124
1192
 
1125
1193
  }
@@ -1130,10 +1198,12 @@ declare module '@layerfi/components/components/JournalSidebar/index' {
1130
1198
  declare module '@layerfi/components/components/JournalTable/JournalTable' {
1131
1199
  import React, { RefObject } from 'react';
1132
1200
  import { View } from '@layerfi/components/components/Journal/index';
1133
- export const JournalTable: ({ view, containerRef, pageSize, }: {
1201
+ import { JournalConfig } from '@layerfi/components/components/Journal/Journal';
1202
+ export const JournalTable: ({ view, containerRef, pageSize, config, }: {
1134
1203
  view: View;
1135
1204
  containerRef: RefObject<HTMLDivElement>;
1136
1205
  pageSize?: number | undefined;
1206
+ config: JournalConfig;
1137
1207
  }) => React.JSX.Element;
1138
1208
 
1139
1209
  }
@@ -1591,7 +1661,11 @@ declare module '@layerfi/components/components/SkeletonLoader/index' {
1591
1661
  }
1592
1662
  declare module '@layerfi/components/components/Textarea/Textarea' {
1593
1663
  import React, { HTMLProps } from 'react';
1594
- export const Textarea: ({ className, ...props }: HTMLProps<HTMLTextAreaElement>) => React.JSX.Element;
1664
+ export interface TextareaProps extends HTMLProps<HTMLTextAreaElement> {
1665
+ isInvalid?: boolean;
1666
+ errorMessage?: string;
1667
+ }
1668
+ export const Textarea: ({ className, isInvalid, errorMessage, ...props }: TextareaProps) => React.JSX.Element;
1595
1669
 
1596
1670
  }
1597
1671
  declare module '@layerfi/components/components/Textarea/index' {
@@ -1963,6 +2037,40 @@ declare module '@layerfi/components/contexts/ChartOfAccountsContext/ChartOfAccou
1963
2037
  declare module '@layerfi/components/contexts/ChartOfAccountsContext/index' {
1964
2038
  export { ChartOfAccountsContext } from '@layerfi/components/contexts/ChartOfAccountsContext/ChartOfAccountsContext';
1965
2039
 
2040
+ }
2041
+ declare module '@layerfi/components/contexts/JournalContext/JournalContext' {
2042
+ /// <reference types="react" />
2043
+ import { useJournal } from '@layerfi/components/hooks/useJournal/index';
2044
+ export type JournalContextType = ReturnType<typeof useJournal>;
2045
+ export const JournalContext: import("react").Context<{
2046
+ data?: import("@layerfi/components/types").JournalEntry[] | undefined;
2047
+ isLoading?: boolean | undefined;
2048
+ isLoadingEntry?: boolean | undefined;
2049
+ isValidating?: boolean | undefined;
2050
+ isValidatingEntry?: boolean | undefined;
2051
+ error?: unknown;
2052
+ errorEntry?: unknown;
2053
+ refetch: () => void;
2054
+ selectedEntryId?: string | undefined;
2055
+ setSelectedEntryId: (id?: string | undefined) => void;
2056
+ closeSelectedEntry: () => void;
2057
+ create: (newJournalEntry: import("@layerfi/components/types/journal").NewJournalEntry) => void;
2058
+ 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;
2059
+ submitForm: () => void;
2060
+ cancelForm: () => void;
2061
+ addEntry: () => void;
2062
+ sendingForm: boolean;
2063
+ form?: import("@layerfi/components/hooks/useJournal/useJournal").JournalFormTypes | undefined;
2064
+ apiError?: string | undefined;
2065
+ setForm: (form?: import("@layerfi/components/hooks/useJournal/useJournal").JournalFormTypes | undefined) => void;
2066
+ addEntryLine: (direction: import("@layerfi/components/types").Direction) => void;
2067
+ removeEntryLine: (index: number) => void;
2068
+ }>;
2069
+
2070
+ }
2071
+ declare module '@layerfi/components/contexts/JournalContext/index' {
2072
+ export { JournalContext } from '@layerfi/components/contexts/JournalContext/JournalContext';
2073
+
1966
2074
  }
1967
2075
  declare module '@layerfi/components/contexts/LayerContext/LayerContext' {
1968
2076
  /// <reference types="react" />
@@ -2066,13 +2174,9 @@ declare module '@layerfi/components/hooks/useChartOfAccounts/index' {
2066
2174
 
2067
2175
  }
2068
2176
  declare module '@layerfi/components/hooks/useChartOfAccounts/useChartOfAccounts' {
2069
- import { DateRange, NewAccount } from '@layerfi/components/types';
2177
+ import { FormError, DateRange, NewAccount } from '@layerfi/components/types';
2070
2178
  import { ChartWithBalances, LedgerAccountBalance } from '@layerfi/components/types/chart_of_accounts';
2071
2179
  import { BaseSelectOption } from '@layerfi/components/types/general';
2072
- interface FormError {
2073
- field: string;
2074
- message: string;
2075
- }
2076
2180
  export interface ChartOfAccountsForm {
2077
2181
  action: 'new' | 'edit';
2078
2182
  accountId?: string;
@@ -2137,10 +2241,12 @@ declare module '@layerfi/components/hooks/useJournal/index' {
2137
2241
 
2138
2242
  }
2139
2243
  declare module '@layerfi/components/hooks/useJournal/useJournal' {
2140
- import { JournalEntry, JournalEntryLine } from '@layerfi/components/types/journal';
2244
+ import { Direction, FormError, FormErrorWithId } from '@layerfi/components/types';
2245
+ import { LedgerAccountBalance } from '@layerfi/components/types/chart_of_accounts';
2246
+ import { BaseSelectOption } from '@layerfi/components/types/general';
2247
+ import { JournalEntry, NewJournalEntry } from '@layerfi/components/types/journal';
2141
2248
  type UseJournal = () => {
2142
2249
  data?: JournalEntry[];
2143
- entryData?: JournalEntryLine;
2144
2250
  isLoading?: boolean;
2145
2251
  isLoadingEntry?: boolean;
2146
2252
  isValidating?: boolean;
@@ -2151,7 +2257,26 @@ declare module '@layerfi/components/hooks/useJournal/useJournal' {
2151
2257
  selectedEntryId?: string;
2152
2258
  setSelectedEntryId: (id?: string) => void;
2153
2259
  closeSelectedEntry: () => void;
2260
+ create: (newJournalEntry: NewJournalEntry) => void;
2261
+ changeFormData: (name: string, value: string | BaseSelectOption | undefined | number, lineItemIndex?: number, accounts?: LedgerAccountBalance[] | undefined) => void;
2262
+ submitForm: () => void;
2263
+ cancelForm: () => void;
2264
+ addEntry: () => void;
2265
+ sendingForm: boolean;
2266
+ form?: JournalFormTypes;
2267
+ apiError?: string;
2268
+ setForm: (form?: JournalFormTypes) => void;
2269
+ addEntryLine: (direction: Direction) => void;
2270
+ removeEntryLine: (index: number) => void;
2154
2271
  };
2272
+ export interface JournalFormTypes {
2273
+ action: string;
2274
+ data: NewJournalEntry;
2275
+ errors?: {
2276
+ entry: FormError[];
2277
+ lineItems: FormErrorWithId[];
2278
+ } | undefined;
2279
+ }
2155
2280
  export const useJournal: UseJournal;
2156
2281
  export const flattenEntries: (entries: JournalEntry[]) => JournalEntry[];
2157
2282
  export {};
@@ -2414,6 +2539,13 @@ declare module '@layerfi/components/icons/ChevronRight' {
2414
2539
  const ChavronRight: ({ size, ...props }: IconSvgProps) => React.JSX.Element;
2415
2540
  export default ChavronRight;
2416
2541
 
2542
+ }
2543
+ declare module '@layerfi/components/icons/CloseIcon' {
2544
+ import * as React from 'react';
2545
+ import { IconSvgProps } from '@layerfi/components/icons/types';
2546
+ const CloseIcon: ({ size, ...props }: IconSvgProps) => React.JSX.Element;
2547
+ export default CloseIcon;
2548
+
2417
2549
  }
2418
2550
  declare module '@layerfi/components/icons/CreditCard' {
2419
2551
  import * as React from 'react';
@@ -2907,6 +3039,26 @@ declare module '@layerfi/components/types/journal' {
2907
3039
  entry_at: string;
2908
3040
  createdAt: string;
2909
3041
  }
3042
+ export type NewJournalEntry = {
3043
+ entry_at: string;
3044
+ created_by: string;
3045
+ memo: string;
3046
+ line_items: JournalEntryLineItem[];
3047
+ };
3048
+ export type JournalEntryLineItem = {
3049
+ account_identifier: {
3050
+ type: string;
3051
+ stable_name: string;
3052
+ id: string;
3053
+ name: string;
3054
+ subType: {
3055
+ value: string;
3056
+ label: string;
3057
+ } | undefined;
3058
+ };
3059
+ amount: number;
3060
+ direction: Direction;
3061
+ };
2910
3062
 
2911
3063
  }
2912
3064
  declare module '@layerfi/components/types/layer_context' {
@@ -3169,7 +3321,14 @@ declare module '@layerfi/components/types' {
3169
3321
  export { ChartOfAccounts, Account, NewAccount, EditAccount, } from '@layerfi/components/types/chart_of_accounts';
3170
3322
  export { LedgerAccountLineItems as LedgerAccounts, LedgerAccountLineItem, LedgerAccountsAccount, LedgerAccountsEntry, } from '@layerfi/components/types/ledger_accounts';
3171
3323
  export { SortDirection } from '@layerfi/components/types/general';
3172
- export { JournalEntry, JournalEntryLine, } from '@layerfi/components/types/journal';
3324
+ export interface FormError {
3325
+ field: string;
3326
+ message: string;
3327
+ }
3328
+ export interface FormErrorWithId extends FormError {
3329
+ id: number;
3330
+ }
3331
+ export { JournalEntry, JournalEntryLine, JournalEntryLineItem, } from '@layerfi/components/types/journal';
3173
3332
  export type DateRange<T = Date> = {
3174
3333
  startDate: T;
3175
3334
  endDate: T;
@@ -3209,6 +3368,9 @@ declare module '@layerfi/components/utils/format' {
3209
3368
  * Convert Enum-like (upper snakecase) text into human friendly format.
3210
3369
  */
3211
3370
  export const humanizeEnum: (text: string) => string;
3371
+ export const convertNumberToCurrency: (amount: number | undefined) => string;
3372
+ export const convertCurrencyToNumber: (amount: string) => number;
3373
+ export const CURRENCY_INPUT_PATTERN = "[0-9]+(.[0-9]+)?";
3212
3374
 
3213
3375
  }
3214
3376
  declare module '@layerfi/components/utils/helpers' {