@layerfi/components 0.1.6 → 0.1.7

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
@@ -691,12 +691,30 @@ declare module '@layerfi/components/components/ProfitAndLoss/ProfitAndLoss' {
691
691
  Chart: () => React.JSX.Element;
692
692
  Context: React.Context<{
693
693
  data: import("@layerfi/components/types").ProfitAndLoss | undefined;
694
+ filteredData: import("@layerfi/components/types/line_item").LineBaseItem[];
695
+ filteredTotal?: number | undefined;
694
696
  isLoading: boolean;
695
697
  isValidating: boolean;
696
698
  error: unknown;
697
699
  dateRange: import("@layerfi/components/types").DateRange;
698
700
  changeDateRange: (dateRange: Partial<import("@layerfi/components/types").DateRange>) => void;
699
701
  refetch: () => void;
702
+ sidebarScope: import("@layerfi/components/hooks/useProfitAndLoss/useProfitAndLoss").SidebarScope;
703
+ setSidebarScope: (view: import("@layerfi/components/hooks/useProfitAndLoss/useProfitAndLoss").SidebarScope) => void;
704
+ filters: {
705
+ expenses: {
706
+ sortBy?: string | undefined;
707
+ sortDirection?: import("@layerfi/components/types").SortDirection | undefined;
708
+ types?: string[] | undefined;
709
+ } | undefined;
710
+ revenue: {
711
+ sortBy?: string | undefined;
712
+ sortDirection?: import("@layerfi/components/types").SortDirection | undefined;
713
+ types?: string[] | undefined;
714
+ } | undefined;
715
+ };
716
+ sortBy: (scope: import("@layerfi/components/hooks/useProfitAndLoss/useProfitAndLoss").Scope, field: string, direction?: import("../../types").SortDirection | undefined) => void;
717
+ setFilterTypes: (scope: import("@layerfi/components/hooks/useProfitAndLoss/useProfitAndLoss").Scope, types: string[]) => void;
700
718
  }>;
701
719
  DatePicker: () => React.JSX.Element;
702
720
  Summaries: ({ vertical, revenueLabel, }: {
@@ -742,6 +760,15 @@ declare module '@layerfi/components/components/ProfitAndLossDatePicker/ProfitAnd
742
760
  declare module '@layerfi/components/components/ProfitAndLossDatePicker/index' {
743
761
  export { ProfitAndLossDatePicker } from '@layerfi/components/components/ProfitAndLossDatePicker/ProfitAndLossDatePicker';
744
762
 
763
+ }
764
+ declare module '@layerfi/components/components/ProfitAndLossDetailedCharts/ProfitAndLossDetailedCharts' {
765
+ import React from 'react';
766
+ export const ProfitAndLossDetailedCharts: () => React.JSX.Element;
767
+
768
+ }
769
+ declare module '@layerfi/components/components/ProfitAndLossDetailedCharts/index' {
770
+ export { ProfitAndLossDetailedCharts } from '@layerfi/components/components/ProfitAndLossDetailedCharts/ProfitAndLossDetailedCharts';
771
+
745
772
  }
746
773
  declare module '@layerfi/components/components/ProfitAndLossRow/ProfitAndLossRow' {
747
774
  import React from 'react';
@@ -800,6 +827,7 @@ declare module '@layerfi/components/components/ProfitAndLossView/ProfitAndLossVi
800
827
  export interface ProfitAndLossViewProps {
801
828
  hideTable?: boolean;
802
829
  hideChart?: boolean;
830
+ showDetailedCharts?: boolean;
803
831
  }
804
832
  export const ProfitAndLossView: (props: ProfitAndLossViewProps) => React.JSX.Element;
805
833
 
@@ -1249,7 +1277,10 @@ declare module '@layerfi/components/hooks/useProfitAndLoss/index' {
1249
1277
 
1250
1278
  }
1251
1279
  declare module '@layerfi/components/hooks/useProfitAndLoss/useProfitAndLoss' {
1252
- import { ProfitAndLoss, DateRange, ReportingBasis } from '@layerfi/components/types';
1280
+ import { ProfitAndLoss, DateRange, ReportingBasis, SortDirection } from '@layerfi/components/types';
1281
+ import { LineBaseItem } from '@layerfi/components/types/line_item';
1282
+ export type Scope = 'expenses' | 'revenue';
1283
+ export type SidebarScope = Scope | undefined;
1253
1284
  type Props = {
1254
1285
  startDate?: Date;
1255
1286
  endDate?: Date;
@@ -1259,14 +1290,27 @@ declare module '@layerfi/components/hooks/useProfitAndLoss/useProfitAndLoss' {
1259
1290
  };
1260
1291
  reportingBasis?: ReportingBasis;
1261
1292
  };
1293
+ type ProfitAndLossFilter = {
1294
+ sortBy?: string;
1295
+ sortDirection?: SortDirection;
1296
+ types?: string[];
1297
+ };
1298
+ type ProfitAndLossFilters = Record<Scope, ProfitAndLossFilter | undefined>;
1262
1299
  type UseProfitAndLoss = (props?: Props) => {
1263
1300
  data: ProfitAndLoss | undefined;
1301
+ filteredData: LineBaseItem[];
1302
+ filteredTotal?: number;
1264
1303
  isLoading: boolean;
1265
1304
  isValidating: boolean;
1266
1305
  error: unknown;
1267
1306
  dateRange: DateRange;
1268
1307
  changeDateRange: (dateRange: Partial<DateRange>) => void;
1269
1308
  refetch: () => void;
1309
+ sidebarScope: SidebarScope;
1310
+ setSidebarScope: (view: SidebarScope) => void;
1311
+ filters: ProfitAndLossFilters;
1312
+ sortBy: (scope: Scope, field: string, direction?: SortDirection) => void;
1313
+ setFilterTypes: (scope: Scope, types: string[]) => void;
1270
1314
  };
1271
1315
  export const useProfitAndLoss: UseProfitAndLoss;
1272
1316
  export {};
@@ -1383,6 +1427,13 @@ declare module '@layerfi/components/icons/ScissorsFullOpen' {
1383
1427
  const ScissorsFullOpen: ({ size, ...props }: IconSvgProps) => React.JSX.Element;
1384
1428
  export default ScissorsFullOpen;
1385
1429
 
1430
+ }
1431
+ declare module '@layerfi/components/icons/SortArrows' {
1432
+ import * as React from 'react';
1433
+ import { IconSvgProps } from '@layerfi/components/icons/types';
1434
+ const SortArrows: ({ size, ...props }: IconSvgProps) => React.JSX.Element;
1435
+ export default SortArrows;
1436
+
1386
1437
  }
1387
1438
  declare module '@layerfi/components/icons/Trash' {
1388
1439
  import * as React from 'react';
@@ -1397,6 +1448,13 @@ declare module '@layerfi/components/icons/UploadCloud' {
1397
1448
  const UploadCloud: ({ size, ...props }: IconSvgProps) => React.JSX.Element;
1398
1449
  export default UploadCloud;
1399
1450
 
1451
+ }
1452
+ declare module '@layerfi/components/icons/X' {
1453
+ import * as React from 'react';
1454
+ import { IconSvgProps } from '@layerfi/components/icons/types';
1455
+ const X: ({ size, ...props }: IconSvgProps) => React.JSX.Element;
1456
+ export default X;
1457
+
1400
1458
  }
1401
1459
  declare module '@layerfi/components/icons/types' {
1402
1460
  import { SVGProps } from 'react';
@@ -1658,6 +1716,10 @@ declare module '@layerfi/components/types/chart_of_accounts' {
1658
1716
  description: string;
1659
1717
  };
1660
1718
 
1719
+ }
1720
+ declare module '@layerfi/components/types/general' {
1721
+ export type SortDirection = 'asc' | 'desc';
1722
+
1661
1723
  }
1662
1724
  declare module '@layerfi/components/types/layer_context' {
1663
1725
  import { Category } from '@layerfi/components/types';
@@ -1738,6 +1800,15 @@ declare module '@layerfi/components/types/line_item' {
1738
1800
  display_name: string;
1739
1801
  value: number | undefined;
1740
1802
  line_items?: LineItem[] | null;
1803
+ is_contra?: boolean;
1804
+ }
1805
+ export interface LineBaseItem {
1806
+ name?: string;
1807
+ display_name: string;
1808
+ value: number;
1809
+ type: string;
1810
+ share?: number;
1811
+ hidden?: boolean;
1741
1812
  }
1742
1813
 
1743
1814
  }
@@ -1779,6 +1850,7 @@ declare module '@layerfi/components/types' {
1779
1850
  export { Direction, BankTransaction } from '@layerfi/components/types/bank_transactions';
1780
1851
  export { CategorizationStatus, Category, CategorizationType, AutoCategorization, SuggestedCategorization, SingleCategoryUpdate, SplitCategoryUpdate, CategoryUpdate, } from '@layerfi/components/types/categories';
1781
1852
  export { AccountAlternate, ChartOfAccounts, Account, NewAccount, } from '@layerfi/components/types/chart_of_accounts';
1853
+ export { SortDirection } from '@layerfi/components/types/general';
1782
1854
  export type DateRange<T = Date> = {
1783
1855
  startDate: T;
1784
1856
  endDate: T;
@@ -1805,6 +1877,15 @@ declare module '@layerfi/components/utils/format' {
1805
1877
  * Capitalize first letter of the given text.
1806
1878
  */
1807
1879
  export const capitalizeFirstLetter: (text: string) => string;
1880
+ /**
1881
+ * Convert number into percentage.
1882
+ *
1883
+ * @example
1884
+ * 0.112 -> 11%
1885
+ * 0.09843 -> 9.8%
1886
+ * 0.00123 -> 0.12%
1887
+ */
1888
+ export const formatPercent: (value?: number, options?: Intl.NumberFormatOptions) => string | undefined;
1808
1889
 
1809
1890
  }
1810
1891
  declare module '@layerfi/components/utils/helpers' {
@@ -1812,6 +1893,16 @@ declare module '@layerfi/components/utils/helpers' {
1812
1893
  export const debounce: <F extends (...args: Parameters<F>) => ReturnType<F>>(fnc: F, timeout?: number) => (...args: Parameters<F>) => void;
1813
1894
  export const sleep: (time: number) => Promise<unknown>;
1814
1895
 
1896
+ }
1897
+ declare module '@layerfi/components/utils/profitAndLossUtils' {
1898
+ import { SidebarScope } from '@layerfi/components/hooks/useProfitAndLoss/useProfitAndLoss';
1899
+ import { LineBaseItem } from '@layerfi/components/types/line_item';
1900
+ import { ProfitAndLoss } from '@layerfi/components/types/profit_and_loss';
1901
+ export const collectExpensesItems: (data: ProfitAndLoss) => LineBaseItem[];
1902
+ export const collectRevenueItems: (data: ProfitAndLoss) => LineBaseItem[];
1903
+ export const humanizeTitle: (sidebarView: SidebarScope) => "Expenses" | "Revenue" | "Profit & Loss";
1904
+ export const applyShare: (items: LineBaseItem[], total: number) => LineBaseItem[];
1905
+
1815
1906
  }
1816
1907
  declare module '@layerfi/components' {
1817
1908
  import main = require('@layerfi/components/index');