@layerfi/components 0.1.48 → 0.1.50

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.js CHANGED
@@ -850,12 +850,12 @@ var useBankTransactions = (params) => {
850
850
  }
851
851
  if (!prevData?.meta?.pagination?.cursor) {
852
852
  return [
853
- businessId && auth?.access_token && `bank-transactions${filters?.categorizationStatus ? `-scope-${filters?.categorizationStatus}` : ""}-${businessId}`,
853
+ businessId && auth?.access_token && `bank-transactions-${businessId}`,
854
854
  void 0
855
855
  ];
856
856
  }
857
857
  return [
858
- businessId && auth?.access_token && `bank-transactions${filters?.categorizationStatus ? `-scope-${filters?.categorizationStatus}` : ""}-${businessId}-${prevData.meta.pagination.cursor}`,
858
+ businessId && auth?.access_token && `bank-transactions-${businessId}-${prevData.meta.pagination.cursor}`,
859
859
  prevData.meta.pagination.cursor
860
860
  ];
861
861
  };
@@ -874,8 +874,7 @@ var useBankTransactions = (params) => {
874
874
  return Layer.getBankTransactions(apiUrl, auth?.access_token, {
875
875
  params: {
876
876
  businessId,
877
- cursor: nextCursor,
878
- categorized: filters?.categorizationStatus ? filters?.categorizationStatus === "categorized" /* categorized */ ? "true" : "false" : ""
877
+ cursor: nextCursor
879
878
  }
880
879
  }).call(false);
881
880
  }
@@ -1044,13 +1043,6 @@ var useBankTransactions = (params) => {
1044
1043
  mutate(updatedData, { revalidate: false });
1045
1044
  };
1046
1045
  const removeAfterCategorize = (bankTransaction) => {
1047
- const updatedData = rawResponseData?.map((page) => {
1048
- return {
1049
- ...page,
1050
- data: page.data?.filter((bt) => bt.id !== bankTransaction.id)
1051
- };
1052
- });
1053
- mutate(updatedData, { revalidate: false });
1054
1046
  };
1055
1047
  const refetch = () => {
1056
1048
  mutate();
@@ -8738,10 +8730,10 @@ var Quickbooks = () => {
8738
8730
  };
8739
8731
 
8740
8732
  // src/components/ProfitAndLoss/ProfitAndLoss.tsx
8741
- var import_react111 = __toESM(require("react"));
8733
+ var import_react118 = __toESM(require("react"));
8742
8734
 
8743
8735
  // src/hooks/useProfitAndLoss/useProfitAndLoss.tsx
8744
- var import_react98 = require("react");
8736
+ var import_react99 = require("react");
8745
8737
 
8746
8738
  // src/utils/profitAndLossUtils.ts
8747
8739
  var doesLineItemQualifies = (item) => {
@@ -8796,18 +8788,176 @@ var applyShare = (items, total) => {
8796
8788
  });
8797
8789
  };
8798
8790
 
8799
- // src/hooks/useProfitAndLoss/useProfitAndLossQuery.tsx
8791
+ // src/hooks/useProfitAndLoss/useProfitAndLossLTM.tsx
8800
8792
  var import_react97 = require("react");
8801
8793
  var import_date_fns16 = require("date-fns");
8802
8794
  var import_swr3 = __toESM(require("swr"));
8795
+ var buildDates = ({ currentDate }) => {
8796
+ return {
8797
+ startYear: (0, import_date_fns16.startOfMonth)(currentDate).getFullYear() - 1,
8798
+ startMonth: (0, import_date_fns16.startOfMonth)(currentDate).getMonth() + 1,
8799
+ endYear: (0, import_date_fns16.startOfMonth)(currentDate).getFullYear(),
8800
+ endMonth: (0, import_date_fns16.startOfMonth)(currentDate).getMonth() + 1
8801
+ };
8802
+ };
8803
+ var buildMonthsArray = (startDate, endDate) => {
8804
+ if (startDate >= endDate) {
8805
+ return [];
8806
+ }
8807
+ var dates = [];
8808
+ for (var d = startDate; d <= endDate; d.setMonth(d.getMonth() + 1)) {
8809
+ dates.push(new Date(d));
8810
+ }
8811
+ return dates;
8812
+ };
8813
+ var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
8814
+ currentDate: (0, import_date_fns16.startOfMonth)(Date.now())
8815
+ }) => {
8816
+ const {
8817
+ businessId,
8818
+ auth,
8819
+ apiUrl,
8820
+ syncTimestamps,
8821
+ read,
8822
+ readTimestamps,
8823
+ hasBeenTouched
8824
+ } = useLayerContext();
8825
+ const [date, setDate] = (0, import_react97.useState)(currentDate);
8826
+ const [loaded, setLoaded] = (0, import_react97.useState)("initial");
8827
+ const [data, setData] = (0, import_react97.useState)([]);
8828
+ const { startYear, startMonth, endYear, endMonth } = (0, import_react97.useMemo)(() => {
8829
+ return buildDates({ currentDate: date });
8830
+ }, [date, businessId, tagFilter, reportingBasis]);
8831
+ const queryKey = businessId && Boolean(startYear) && Boolean(startMonth) && Boolean(endYear) && Boolean(endMonth) && auth?.access_token && `profit-and-loss-summaries-${businessId}-${startYear.toString()}-${startMonth.toString()}-${tagFilter?.key}-${tagFilter?.values?.join(
8832
+ ","
8833
+ )}-${reportingBasis}`;
8834
+ const {
8835
+ data: rawData,
8836
+ isLoading,
8837
+ isValidating,
8838
+ error,
8839
+ mutate
8840
+ } = (0, import_swr3.default)(
8841
+ queryKey,
8842
+ Layer.getProfitAndLossSummaries(apiUrl, auth?.access_token, {
8843
+ params: {
8844
+ businessId,
8845
+ startYear: startYear.toString(),
8846
+ startMonth: startMonth.toString(),
8847
+ endYear: endYear.toString(),
8848
+ endMonth: endMonth.toString(),
8849
+ tagKey: tagFilter?.key,
8850
+ tagValues: tagFilter?.values?.join(","),
8851
+ reportingBasis
8852
+ }
8853
+ })
8854
+ );
8855
+ (0, import_react97.useEffect)(() => {
8856
+ const newData = data.slice();
8857
+ const newPeriod = buildMonthsArray((0, import_date_fns16.sub)(date, { years: 1 }), date);
8858
+ if (newData && newPeriod) {
8859
+ newPeriod.forEach((x) => {
8860
+ if (!newData?.find(
8861
+ (n) => x.getMonth() + 1 === n.month && x.getFullYear() === n.year
8862
+ )) {
8863
+ newData.push({
8864
+ year: x.getFullYear(),
8865
+ month: x.getMonth() + 1,
8866
+ income: 0,
8867
+ costOfGoodsSold: 0,
8868
+ grossProfit: 0,
8869
+ operatingExpenses: 0,
8870
+ profitBeforeTaxes: 0,
8871
+ taxes: 0,
8872
+ netProfit: 0,
8873
+ fullyCategorized: false,
8874
+ totalExpenses: 0,
8875
+ uncategorizedInflows: 0,
8876
+ uncategorizedOutflows: 0,
8877
+ uncategorized_transactions: 0,
8878
+ isLoading: true
8879
+ });
8880
+ }
8881
+ });
8882
+ }
8883
+ if (newData) {
8884
+ setData(
8885
+ newData.sort(
8886
+ (a, b) => Number(new Date(a.year, a.month, 1)) - Number(new Date(b.year, b.month, 1))
8887
+ )
8888
+ );
8889
+ }
8890
+ }, [startYear, startMonth]);
8891
+ (0, import_react97.useEffect)(() => {
8892
+ const newData = rawData?.data?.months?.slice();
8893
+ if (data && newData) {
8894
+ data.forEach((x) => {
8895
+ if (!newData?.find((n) => x.month === n.month && x.year === n.year)) {
8896
+ newData.push({ ...x });
8897
+ }
8898
+ });
8899
+ }
8900
+ if (newData) {
8901
+ setData(
8902
+ newData.sort(
8903
+ (a, b) => Number(new Date(a.year, a.month, 1)) - Number(new Date(b.year, b.month, 1))
8904
+ )
8905
+ );
8906
+ }
8907
+ }, [rawData]);
8908
+ (0, import_react97.useEffect)(() => {
8909
+ if (isLoading && loaded === "initial") {
8910
+ setLoaded("loading");
8911
+ return;
8912
+ }
8913
+ if (!isLoading && rawData) {
8914
+ setLoaded("complete");
8915
+ }
8916
+ }, [data, isLoading]);
8917
+ const pullData = (date2) => setDate(date2);
8918
+ (0, import_react97.useEffect)(() => {
8919
+ if (queryKey && (isLoading || isValidating)) {
8920
+ read("PROFIT_AND_LOSS" /* PROFIT_AND_LOSS */, queryKey);
8921
+ }
8922
+ }, [isLoading, isValidating]);
8923
+ (0, import_react97.useEffect)(() => {
8924
+ if (queryKey && hasBeenTouched(queryKey)) {
8925
+ mutate();
8926
+ }
8927
+ }, [
8928
+ syncTimestamps,
8929
+ startYear,
8930
+ startMonth,
8931
+ endYear,
8932
+ endMonth,
8933
+ tagFilter,
8934
+ reportingBasis
8935
+ ]);
8936
+ const refetch = () => {
8937
+ mutate();
8938
+ };
8939
+ return {
8940
+ data,
8941
+ isLoading,
8942
+ loaded,
8943
+ error,
8944
+ pullData,
8945
+ refetch
8946
+ };
8947
+ };
8948
+
8949
+ // src/hooks/useProfitAndLoss/useProfitAndLossQuery.tsx
8950
+ var import_react98 = require("react");
8951
+ var import_date_fns17 = require("date-fns");
8952
+ var import_swr4 = __toESM(require("swr"));
8803
8953
  var useProfitAndLossQuery = ({
8804
8954
  startDate,
8805
8955
  endDate,
8806
8956
  tagFilter,
8807
8957
  reportingBasis
8808
8958
  } = {
8809
- startDate: (0, import_date_fns16.startOfMonth)(/* @__PURE__ */ new Date()),
8810
- endDate: (0, import_date_fns16.endOfMonth)(/* @__PURE__ */ new Date())
8959
+ startDate: (0, import_date_fns17.startOfMonth)(/* @__PURE__ */ new Date()),
8960
+ endDate: (0, import_date_fns17.endOfMonth)(/* @__PURE__ */ new Date())
8811
8961
  }) => {
8812
8962
  const { auth, businessId, apiUrl, syncTimestamps, read, hasBeenTouched } = useLayerContext();
8813
8963
  const queryKey = businessId && startDate && endDate && auth?.access_token && `profit-and-loss-${businessId}-${startDate.valueOf()}-${endDate.valueOf()}-${tagFilter?.key}-${tagFilter?.values?.join(
@@ -8819,13 +8969,13 @@ var useProfitAndLossQuery = ({
8819
8969
  isValidating,
8820
8970
  error: rawError,
8821
8971
  mutate
8822
- } = (0, import_swr3.default)(
8972
+ } = (0, import_swr4.default)(
8823
8973
  queryKey,
8824
8974
  Layer.getProfitAndLoss(apiUrl, auth?.access_token, {
8825
8975
  params: {
8826
8976
  businessId,
8827
- startDate: (0, import_date_fns16.formatISO)(startDate.valueOf()),
8828
- endDate: (0, import_date_fns16.formatISO)(endDate.valueOf()),
8977
+ startDate: (0, import_date_fns17.formatISO)(startDate.valueOf()),
8978
+ endDate: (0, import_date_fns17.formatISO)(endDate.valueOf()),
8829
8979
  tagKey: tagFilter?.key,
8830
8980
  tagValues: tagFilter?.values?.join(","),
8831
8981
  reportingBasis
@@ -8835,12 +8985,12 @@ var useProfitAndLossQuery = ({
8835
8985
  const refetch = () => {
8836
8986
  mutate();
8837
8987
  };
8838
- (0, import_react97.useEffect)(() => {
8988
+ (0, import_react98.useEffect)(() => {
8839
8989
  if (queryKey && (isLoading || isValidating)) {
8840
8990
  read("PROFIT_AND_LOSS" /* PROFIT_AND_LOSS */, queryKey);
8841
8991
  }
8842
8992
  }, [isLoading, isValidating]);
8843
- (0, import_react97.useEffect)(() => {
8993
+ (0, import_react98.useEffect)(() => {
8844
8994
  if (queryKey && hasBeenTouched(queryKey)) {
8845
8995
  refetch();
8846
8996
  }
@@ -8857,33 +9007,36 @@ var useProfitAndLossQuery = ({
8857
9007
  };
8858
9008
 
8859
9009
  // src/hooks/useProfitAndLoss/useProfitAndLoss.tsx
8860
- var import_date_fns17 = require("date-fns");
9010
+ var import_date_fns18 = require("date-fns");
8861
9011
  var useProfitAndLoss = ({
8862
9012
  startDate: initialStartDate,
8863
9013
  endDate: initialEndDate,
8864
9014
  tagFilter,
8865
9015
  reportingBasis
8866
9016
  } = {
8867
- startDate: (0, import_date_fns17.startOfMonth)(/* @__PURE__ */ new Date()),
8868
- endDate: (0, import_date_fns17.endOfMonth)(/* @__PURE__ */ new Date())
9017
+ startDate: (0, import_date_fns18.startOfMonth)(/* @__PURE__ */ new Date()),
9018
+ endDate: (0, import_date_fns18.endOfMonth)(/* @__PURE__ */ new Date())
8869
9019
  }) => {
8870
- const [startDate, setStartDate] = (0, import_react98.useState)(
8871
- initialStartDate || (0, import_date_fns17.startOfMonth)(Date.now())
9020
+ const [startDate, setStartDate] = (0, import_react99.useState)(
9021
+ initialStartDate || (0, import_date_fns18.startOfMonth)(Date.now())
8872
9022
  );
8873
- const [endDate, setEndDate] = (0, import_react98.useState)(
8874
- initialEndDate || (0, import_date_fns17.endOfMonth)(Date.now())
9023
+ const [endDate, setEndDate] = (0, import_react99.useState)(
9024
+ initialEndDate || (0, import_date_fns18.endOfMonth)(Date.now())
8875
9025
  );
8876
- const [filters, setFilters] = (0, import_react98.useState)({
9026
+ const [filters, setFilters] = (0, import_react99.useState)({
8877
9027
  expenses: void 0,
8878
9028
  revenue: void 0
8879
9029
  });
8880
- const [sidebarScope, setSidebarScope] = (0, import_react98.useState)(void 0);
9030
+ const [sidebarScope, setSidebarScope] = (0, import_react99.useState)(void 0);
8881
9031
  const { data, isLoading, isValidating, error, refetch } = useProfitAndLossQuery({
8882
9032
  startDate,
8883
9033
  endDate,
8884
9034
  tagFilter,
8885
9035
  reportingBasis
8886
9036
  });
9037
+ const { data: summaryData } = useProfitAndLossLTM({
9038
+ currentDate: startDate ? startDate : (0, import_date_fns18.startOfMonth)(/* @__PURE__ */ new Date())
9039
+ });
8887
9040
  const changeDateRange = ({
8888
9041
  startDate: newStartDate,
8889
9042
  endDate: newEndDate
@@ -8910,7 +9063,7 @@ var useProfitAndLoss = ({
8910
9063
  }
8911
9064
  });
8912
9065
  };
8913
- const { filteredDataRevenue, filteredTotalRevenue } = (0, import_react98.useMemo)(() => {
9066
+ const { filteredDataRevenue, filteredTotalRevenue } = (0, import_react99.useMemo)(() => {
8914
9067
  if (!data) {
8915
9068
  return { filteredDataRevenue: [], filteredTotalRevenue: void 0 };
8916
9069
  }
@@ -8924,6 +9077,19 @@ var useProfitAndLoss = ({
8924
9077
  }
8925
9078
  return x;
8926
9079
  });
9080
+ const month = startDate.getMonth() + 1;
9081
+ const year = startDate.getFullYear();
9082
+ const found = summaryData.find((x) => x.month === month && x.year === year);
9083
+ if (found && (found.uncategorizedInflows ?? 0) > 0) {
9084
+ filtered.push({
9085
+ name: "uncategorized",
9086
+ display_name: "Uncategorized",
9087
+ value: found.uncategorizedInflows,
9088
+ type: "Uncategorized",
9089
+ share: 0,
9090
+ hidden: false
9091
+ });
9092
+ }
8927
9093
  const sorted = filtered.sort((a, b) => {
8928
9094
  switch (filters["revenue"]?.sortBy) {
8929
9095
  case "category":
@@ -8946,8 +9112,8 @@ var useProfitAndLoss = ({
8946
9112
  const total = sorted.filter((x) => !x.hidden).reduce((x, { value }) => x + value, 0);
8947
9113
  const withShare = applyShare(sorted, total);
8948
9114
  return { filteredDataRevenue: withShare, filteredTotalRevenue: total };
8949
- }, [data, startDate, filters, sidebarScope]);
8950
- const { filteredDataExpenses, filteredTotalExpenses } = (0, import_react98.useMemo)(() => {
9115
+ }, [data, startDate, filters, sidebarScope, summaryData]);
9116
+ const { filteredDataExpenses, filteredTotalExpenses } = (0, import_react99.useMemo)(() => {
8951
9117
  if (!data) {
8952
9118
  return { filteredDataExpenses: [], filteredTotalExpenses: void 0 };
8953
9119
  }
@@ -8961,6 +9127,19 @@ var useProfitAndLoss = ({
8961
9127
  }
8962
9128
  return x;
8963
9129
  });
9130
+ const month = startDate.getMonth() + 1;
9131
+ const year = startDate.getFullYear();
9132
+ const found = summaryData.find((x) => x.month === month && x.year === year);
9133
+ if (found && (found.uncategorizedOutflows ?? 0) > 0) {
9134
+ filtered.push({
9135
+ name: "uncategorized",
9136
+ display_name: "Uncategorized",
9137
+ value: found.uncategorizedOutflows,
9138
+ type: "Uncategorized",
9139
+ share: 0,
9140
+ hidden: false
9141
+ });
9142
+ }
8964
9143
  const sorted = filtered.sort((a, b) => {
8965
9144
  switch (filters["expenses"]?.sortBy) {
8966
9145
  case "category":
@@ -8983,7 +9162,7 @@ var useProfitAndLoss = ({
8983
9162
  const total = sorted.filter((x) => !x.hidden).reduce((x, { value }) => x + value, 0);
8984
9163
  const withShare = applyShare(sorted, total);
8985
9164
  return { filteredDataExpenses: withShare, filteredTotalExpenses: total };
8986
- }, [data, startDate, filters, sidebarScope]);
9165
+ }, [data, startDate, filters, sidebarScope, summaryData]);
8987
9166
  return {
8988
9167
  data,
8989
9168
  filteredDataRevenue,
@@ -9007,238 +9186,80 @@ var useProfitAndLoss = ({
9007
9186
  // src/components/ProfitAndLossChart/ProfitAndLossChart.tsx
9008
9187
  var import_react101 = __toESM(require("react"));
9009
9188
 
9010
- // src/hooks/useProfitAndLoss/useProfitAndLossLTM.tsx
9011
- var import_react99 = require("react");
9012
- var import_date_fns18 = require("date-fns");
9013
- var import_swr4 = __toESM(require("swr"));
9014
- var buildDates = ({ currentDate }) => {
9015
- return {
9016
- startYear: (0, import_date_fns18.startOfMonth)(currentDate).getFullYear() - 1,
9017
- startMonth: (0, import_date_fns18.startOfMonth)(currentDate).getMonth() + 1,
9018
- endYear: (0, import_date_fns18.startOfMonth)(currentDate).getFullYear(),
9019
- endMonth: (0, import_date_fns18.startOfMonth)(currentDate).getMonth() + 1
9189
+ // src/components/ProfitAndLossChart/Indicator.tsx
9190
+ var import_react100 = __toESM(require("react"));
9191
+ var emptyViewBox = { x: 0, y: 0, width: 0, height: 0 };
9192
+ var Indicator = ({
9193
+ className,
9194
+ animateFrom,
9195
+ setAnimateFrom,
9196
+ customCursorSize,
9197
+ setCustomCursorSize,
9198
+ viewBox = {}
9199
+ }) => {
9200
+ if (!className?.match(/selected/)) {
9201
+ return null;
9202
+ }
9203
+ const [opacityIndicator, setOpacityIndicator] = (0, import_react100.useState)(0);
9204
+ const { x: animateTo = 0, width = 0 } = "x" in viewBox ? viewBox : emptyViewBox;
9205
+ const margin = width > 12 ? 12 : 6;
9206
+ const boxWidth = width + margin;
9207
+ const xOffset = boxWidth / 2;
9208
+ const borderRadius = 6;
9209
+ const rectWidth = `${boxWidth}px`;
9210
+ const rectHeight = "calc(100% - 38px)";
9211
+ (0, import_react100.useEffect)(() => {
9212
+ if (Math.abs(animateTo - animateFrom) < 30) {
9213
+ setOpacityIndicator(0);
9214
+ }
9215
+ setAnimateFrom(animateTo);
9216
+ setTimeout(() => {
9217
+ setOpacityIndicator(1);
9218
+ }, 200);
9219
+ }, [animateTo]);
9220
+ const rectRef = (ref) => {
9221
+ if (ref) {
9222
+ const refRectWidth = ref.getBoundingClientRect().width;
9223
+ const refRectHeight = ref.getBoundingClientRect().height;
9224
+ if (customCursorSize.width !== refRectWidth || customCursorSize.height !== refRectHeight) {
9225
+ setCustomCursorSize(refRectWidth, refRectHeight, actualX - xOffset);
9226
+ }
9227
+ }
9020
9228
  };
9229
+ const actualX = animateFrom === -1 ? animateTo : animateFrom;
9230
+ return /* @__PURE__ */ import_react100.default.createElement(
9231
+ "rect",
9232
+ {
9233
+ ref: rectRef,
9234
+ className: "Layer__profit-and-loss-chart__selection-indicator",
9235
+ rx: borderRadius,
9236
+ ry: borderRadius,
9237
+ style: {
9238
+ width: rectWidth,
9239
+ // @ts-expect-error -- y is fine but x apparently isn't!
9240
+ x: actualX - xOffset / 2 + margin / 4,
9241
+ y: 22,
9242
+ height: rectHeight,
9243
+ opacity: opacityIndicator
9244
+ }
9245
+ }
9246
+ );
9021
9247
  };
9022
- var buildMonthsArray = (startDate, endDate) => {
9023
- if (startDate >= endDate) {
9024
- return [];
9025
- }
9026
- var dates = [];
9027
- for (var d = startDate; d <= endDate; d.setMonth(d.getMonth() + 1)) {
9028
- dates.push(new Date(d));
9029
- }
9030
- return dates;
9031
- };
9032
- var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
9033
- currentDate: (0, import_date_fns18.startOfMonth)(Date.now())
9034
- }) => {
9035
- const {
9036
- businessId,
9037
- auth,
9038
- apiUrl,
9039
- syncTimestamps,
9040
- read,
9041
- readTimestamps,
9042
- hasBeenTouched
9043
- } = useLayerContext();
9044
- const [date, setDate] = (0, import_react99.useState)(currentDate);
9045
- const [loaded, setLoaded] = (0, import_react99.useState)("initial");
9046
- const [data, setData] = (0, import_react99.useState)([]);
9047
- const { startYear, startMonth, endYear, endMonth } = (0, import_react99.useMemo)(() => {
9048
- return buildDates({ currentDate: date });
9049
- }, [date, businessId, tagFilter, reportingBasis]);
9050
- const queryKey = businessId && Boolean(startYear) && Boolean(startMonth) && Boolean(endYear) && Boolean(endMonth) && auth?.access_token && `profit-and-loss-summaries-${businessId}-${startYear.toString()}-${startMonth.toString()}-${tagFilter?.key}-${tagFilter?.values?.join(
9051
- ","
9052
- )}-${reportingBasis}`;
9053
- const {
9054
- data: rawData,
9055
- isLoading,
9056
- isValidating,
9057
- error,
9058
- mutate
9059
- } = (0, import_swr4.default)(
9060
- queryKey,
9061
- Layer.getProfitAndLossSummaries(apiUrl, auth?.access_token, {
9062
- params: {
9063
- businessId,
9064
- startYear: startYear.toString(),
9065
- startMonth: startMonth.toString(),
9066
- endYear: endYear.toString(),
9067
- endMonth: endMonth.toString(),
9068
- tagKey: tagFilter?.key,
9069
- tagValues: tagFilter?.values?.join(","),
9070
- reportingBasis
9071
- }
9072
- })
9073
- );
9074
- (0, import_react99.useEffect)(() => {
9075
- const newData = data.slice();
9076
- const newPeriod = buildMonthsArray((0, import_date_fns18.sub)(date, { years: 1 }), date);
9077
- if (newData && newPeriod) {
9078
- newPeriod.forEach((x) => {
9079
- if (!newData?.find(
9080
- (n) => x.getMonth() + 1 === n.month && x.getFullYear() === n.year
9081
- )) {
9082
- newData.push({
9083
- year: x.getFullYear(),
9084
- month: x.getMonth() + 1,
9085
- income: 0,
9086
- costOfGoodsSold: 0,
9087
- grossProfit: 0,
9088
- operatingExpenses: 0,
9089
- profitBeforeTaxes: 0,
9090
- taxes: 0,
9091
- netProfit: 0,
9092
- fullyCategorized: false,
9093
- totalExpenses: 0,
9094
- uncategorizedInflows: 0,
9095
- uncategorizedOutflows: 0,
9096
- uncategorized_transactions: 0,
9097
- isLoading: true
9098
- });
9099
- }
9100
- });
9101
- }
9102
- if (newData) {
9103
- setData(
9104
- newData.sort(
9105
- (a, b) => Number(new Date(a.year, a.month, 1)) - Number(new Date(b.year, b.month, 1))
9106
- )
9107
- );
9108
- }
9109
- }, [startYear, startMonth]);
9110
- (0, import_react99.useEffect)(() => {
9111
- const newData = rawData?.data?.months?.slice();
9112
- if (data && newData) {
9113
- data.forEach((x) => {
9114
- if (!newData?.find((n) => x.month === n.month && x.year === n.year)) {
9115
- newData.push({ ...x });
9116
- }
9117
- });
9118
- }
9119
- if (newData) {
9120
- setData(
9121
- newData.sort(
9122
- (a, b) => Number(new Date(a.year, a.month, 1)) - Number(new Date(b.year, b.month, 1))
9123
- )
9124
- );
9125
- }
9126
- }, [rawData]);
9127
- (0, import_react99.useEffect)(() => {
9128
- if (isLoading && loaded === "initial") {
9129
- setLoaded("loading");
9130
- return;
9131
- }
9132
- if (!isLoading && rawData) {
9133
- setLoaded("complete");
9134
- }
9135
- }, [data, isLoading]);
9136
- const pullData = (date2) => setDate(date2);
9137
- (0, import_react99.useEffect)(() => {
9138
- if (queryKey && (isLoading || isValidating)) {
9139
- read("PROFIT_AND_LOSS" /* PROFIT_AND_LOSS */, queryKey);
9140
- }
9141
- }, [isLoading, isValidating]);
9142
- (0, import_react99.useEffect)(() => {
9143
- if (queryKey && hasBeenTouched(queryKey)) {
9144
- mutate();
9145
- }
9146
- }, [
9147
- syncTimestamps,
9148
- startYear,
9149
- startMonth,
9150
- endYear,
9151
- endMonth,
9152
- tagFilter,
9153
- reportingBasis
9154
- ]);
9155
- const refetch = () => {
9156
- mutate();
9157
- };
9158
- return {
9159
- data,
9160
- isLoading,
9161
- loaded,
9162
- error,
9163
- pullData,
9164
- refetch
9165
- };
9166
- };
9167
-
9168
- // src/components/ProfitAndLossChart/Indicator.tsx
9169
- var import_react100 = __toESM(require("react"));
9170
- var emptyViewBox = { x: 0, y: 0, width: 0, height: 0 };
9171
- var Indicator = ({
9172
- className,
9173
- animateFrom,
9174
- setAnimateFrom,
9175
- customCursorSize,
9176
- setCustomCursorSize,
9177
- viewBox = {}
9178
- }) => {
9179
- if (!className?.match(/selected/)) {
9180
- return null;
9181
- }
9182
- const [opacityIndicator, setOpacityIndicator] = (0, import_react100.useState)(0);
9183
- const { x: animateTo = 0, width = 0 } = "x" in viewBox ? viewBox : emptyViewBox;
9184
- const margin = width > 12 ? 12 : 6;
9185
- const boxWidth = width + margin;
9186
- const xOffset = boxWidth / 2;
9187
- const borderRadius = 6;
9188
- const rectWidth = `${boxWidth}px`;
9189
- const rectHeight = "calc(100% - 38px)";
9190
- (0, import_react100.useEffect)(() => {
9191
- if (Math.abs(animateTo - animateFrom) < 30) {
9192
- setOpacityIndicator(0);
9193
- }
9194
- setAnimateFrom(animateTo);
9195
- setTimeout(() => {
9196
- setOpacityIndicator(1);
9197
- }, 200);
9198
- }, [animateTo]);
9199
- const rectRef = (ref) => {
9200
- if (ref) {
9201
- const refRectWidth = ref.getBoundingClientRect().width;
9202
- const refRectHeight = ref.getBoundingClientRect().height;
9203
- if (customCursorSize.width !== refRectWidth || customCursorSize.height !== refRectHeight) {
9204
- setCustomCursorSize(refRectWidth, refRectHeight, actualX - xOffset);
9205
- }
9206
- }
9207
- };
9208
- const actualX = animateFrom === -1 ? animateTo : animateFrom;
9209
- return /* @__PURE__ */ import_react100.default.createElement(
9210
- "rect",
9211
- {
9212
- ref: rectRef,
9213
- className: "Layer__profit-and-loss-chart__selection-indicator",
9214
- rx: borderRadius,
9215
- ry: borderRadius,
9216
- style: {
9217
- width: rectWidth,
9218
- // @ts-expect-error -- y is fine but x apparently isn't!
9219
- x: actualX - xOffset / 2 + margin / 4,
9220
- y: 22,
9221
- height: rectHeight,
9222
- opacity: opacityIndicator
9223
- }
9224
- }
9225
- );
9226
- };
9227
-
9228
- // src/components/ProfitAndLossChart/ProfitAndLossChart.tsx
9229
- var import_classnames42 = __toESM(require("classnames"));
9230
- var import_date_fns19 = require("date-fns");
9231
- var import_recharts = require("recharts");
9232
- var getChartWindow = ({
9233
- chartWindow,
9234
- currentYear,
9235
- currentMonth
9236
- }) => {
9237
- const today = (0, import_date_fns19.startOfMonth)(Date.now());
9238
- const yearAgo = (0, import_date_fns19.sub)(today, { months: 11 });
9239
- const current = (0, import_date_fns19.startOfMonth)(new Date(currentYear, currentMonth - 1, 1));
9240
- if ((0, import_date_fns19.differenceInMonths)((0, import_date_fns19.startOfMonth)(chartWindow.start), current) < 0 && (0, import_date_fns19.differenceInMonths)((0, import_date_fns19.startOfMonth)(chartWindow.end), current) > 1) {
9241
- return chartWindow;
9248
+
9249
+ // src/components/ProfitAndLossChart/ProfitAndLossChart.tsx
9250
+ var import_classnames42 = __toESM(require("classnames"));
9251
+ var import_date_fns19 = require("date-fns");
9252
+ var import_recharts = require("recharts");
9253
+ var getChartWindow = ({
9254
+ chartWindow,
9255
+ currentYear,
9256
+ currentMonth
9257
+ }) => {
9258
+ const today = (0, import_date_fns19.startOfMonth)(Date.now());
9259
+ const yearAgo = (0, import_date_fns19.sub)(today, { months: 11 });
9260
+ const current = (0, import_date_fns19.startOfMonth)(new Date(currentYear, currentMonth - 1, 1));
9261
+ if ((0, import_date_fns19.differenceInMonths)((0, import_date_fns19.startOfMonth)(chartWindow.start), current) < 0 && (0, import_date_fns19.differenceInMonths)((0, import_date_fns19.startOfMonth)(chartWindow.end), current) > 1) {
9262
+ return chartWindow;
9242
9263
  }
9243
9264
  if ((0, import_date_fns19.differenceInMonths)((0, import_date_fns19.startOfMonth)(chartWindow.start), current) === 0) {
9244
9265
  return {
@@ -10142,6 +10163,12 @@ var mapTypesToColors = (data, colorList = DEFAULT_CHART_COLOR_TYPE) => {
10142
10163
  let colorIndex = 0;
10143
10164
  return data.map((obj) => {
10144
10165
  const type = obj.type;
10166
+ if (type === "Uncategorized") {
10167
+ return {
10168
+ color: "#EEEEF0",
10169
+ opacity: 1
10170
+ };
10171
+ }
10145
10172
  if (!typeToColor[type]) {
10146
10173
  typeToColor[type] = colorList[colorIndex % colorList.length];
10147
10174
  colorIndex++;
@@ -10156,6 +10183,57 @@ var mapTypesToColors = (data, colorList = DEFAULT_CHART_COLOR_TYPE) => {
10156
10183
  };
10157
10184
  });
10158
10185
  };
10186
+ var ValueIcon = ({
10187
+ item,
10188
+ typeColorMapping,
10189
+ idx
10190
+ }) => {
10191
+ if (item.type === "Uncategorized") {
10192
+ return /* @__PURE__ */ import_react103.default.createElement(
10193
+ "svg",
10194
+ {
10195
+ viewBox: "0 0 12 12",
10196
+ fill: "none",
10197
+ xmlns: "http://www.w3.org/2000/svg",
10198
+ width: "12",
10199
+ height: "12"
10200
+ },
10201
+ /* @__PURE__ */ import_react103.default.createElement("defs", null, /* @__PURE__ */ import_react103.default.createElement(
10202
+ "pattern",
10203
+ {
10204
+ id: "layer-pie-dots-pattern-legend",
10205
+ x: "0",
10206
+ y: "0",
10207
+ width: "3",
10208
+ height: "3",
10209
+ patternUnits: "userSpaceOnUse"
10210
+ },
10211
+ /* @__PURE__ */ import_react103.default.createElement("rect", { width: "1", height: "1", opacity: 0.76 })
10212
+ )),
10213
+ /* @__PURE__ */ import_react103.default.createElement("rect", { width: "12", height: "12", id: "layer-pie-dots-pattern-bg", rx: "2" }),
10214
+ /* @__PURE__ */ import_react103.default.createElement(
10215
+ "rect",
10216
+ {
10217
+ x: "1",
10218
+ y: "1",
10219
+ width: "10",
10220
+ height: "10",
10221
+ fill: "url(#layer-pie-dots-pattern-legend)"
10222
+ }
10223
+ )
10224
+ );
10225
+ }
10226
+ return /* @__PURE__ */ import_react103.default.createElement(
10227
+ "div",
10228
+ {
10229
+ className: "share-icon",
10230
+ style: {
10231
+ background: typeColorMapping[idx].color,
10232
+ opacity: typeColorMapping[idx].opacity
10233
+ }
10234
+ }
10235
+ );
10236
+ };
10159
10237
  var DetailedTable = ({
10160
10238
  filteredData,
10161
10239
  sidebarScope,
@@ -10217,13 +10295,11 @@ var DetailedTable = ({
10217
10295
  /* @__PURE__ */ import_react103.default.createElement("td", { className: "type-col" }, item.type),
10218
10296
  /* @__PURE__ */ import_react103.default.createElement("td", { className: "value-col" }, "$", centsToDollars(item.value)),
10219
10297
  /* @__PURE__ */ import_react103.default.createElement("td", { className: "share-col" }, /* @__PURE__ */ import_react103.default.createElement("span", { className: "share-cell-content" }, formatPercent(item.share), "%", /* @__PURE__ */ import_react103.default.createElement(
10220
- "div",
10298
+ ValueIcon,
10221
10299
  {
10222
- className: "share-icon",
10223
- style: {
10224
- background: typeColorMapping[idx].color,
10225
- opacity: typeColorMapping[idx].opacity
10226
- }
10300
+ item,
10301
+ typeColorMapping,
10302
+ idx
10227
10303
  }
10228
10304
  )))
10229
10305
  );
@@ -10231,6 +10307,7 @@ var DetailedTable = ({
10231
10307
  };
10232
10308
 
10233
10309
  // src/components/ProfitAndLossDetailedCharts/DetailedChart.tsx
10310
+ var import_classnames44 = __toESM(require("classnames"));
10234
10311
  var import_recharts2 = require("recharts");
10235
10312
  var DetailedChart = ({
10236
10313
  filteredData,
@@ -10264,7 +10341,32 @@ var DetailedChart = ({
10264
10341
  }, [filteredData, isLoading]);
10265
10342
  const noValue = chartData.length === 0 || !chartData.find((x) => x.value !== 0);
10266
10343
  const typeColorMapping = mapTypesToColors(chartData, chartColorsList);
10267
- return /* @__PURE__ */ import_react104.default.createElement("div", { className: "chart-field" }, /* @__PURE__ */ import_react104.default.createElement("div", { className: "header--tablet" }, showDatePicker && /* @__PURE__ */ import_react104.default.createElement(ProfitAndLossDatePicker, null)), /* @__PURE__ */ import_react104.default.createElement("div", { className: "chart-container" }, /* @__PURE__ */ import_react104.default.createElement(import_recharts2.ResponsiveContainer, null, /* @__PURE__ */ import_react104.default.createElement(import_recharts2.PieChart, null, !isLoading && !noValue ? /* @__PURE__ */ import_react104.default.createElement(
10344
+ return /* @__PURE__ */ import_react104.default.createElement("div", { className: "chart-field" }, /* @__PURE__ */ import_react104.default.createElement("div", { className: "header--tablet" }, showDatePicker && /* @__PURE__ */ import_react104.default.createElement(ProfitAndLossDatePicker, null)), /* @__PURE__ */ import_react104.default.createElement("div", { className: "chart-container" }, /* @__PURE__ */ import_react104.default.createElement(import_recharts2.ResponsiveContainer, null, /* @__PURE__ */ import_react104.default.createElement(import_recharts2.PieChart, null, /* @__PURE__ */ import_react104.default.createElement("defs", null, /* @__PURE__ */ import_react104.default.createElement(
10345
+ "pattern",
10346
+ {
10347
+ id: "layer-pie-stripe-pattern",
10348
+ x: "0",
10349
+ y: "0",
10350
+ width: "4",
10351
+ height: "4",
10352
+ patternTransform: "rotate(45)",
10353
+ patternUnits: "userSpaceOnUse"
10354
+ },
10355
+ /* @__PURE__ */ import_react104.default.createElement("rect", { width: "4", height: "4", opacity: 0.16 }),
10356
+ /* @__PURE__ */ import_react104.default.createElement("line", { x1: "0", y: "0", x2: "0", y2: "4", strokeWidth: "2" })
10357
+ ), /* @__PURE__ */ import_react104.default.createElement(
10358
+ "pattern",
10359
+ {
10360
+ id: "layer-pie-dots-pattern",
10361
+ x: "0",
10362
+ y: "0",
10363
+ width: "3",
10364
+ height: "3",
10365
+ patternUnits: "userSpaceOnUse"
10366
+ },
10367
+ /* @__PURE__ */ import_react104.default.createElement("rect", { width: "3", height: "3", opacity: 0.46, className: "bg" }),
10368
+ /* @__PURE__ */ import_react104.default.createElement("rect", { width: "1", height: "1", opacity: 0.56 })
10369
+ )), !isLoading && !noValue ? /* @__PURE__ */ import_react104.default.createElement(
10268
10370
  import_recharts2.Pie,
10269
10371
  {
10270
10372
  data: chartData,
@@ -10290,8 +10392,14 @@ var DetailedChart = ({
10290
10392
  import_recharts2.Cell,
10291
10393
  {
10292
10394
  key: `cell-${index}`,
10293
- className: `Layer__profit-and-loss-detailed-charts__pie ${hoveredItem && active ? "active" : "inactive"}`,
10294
- style: { fill },
10395
+ className: (0, import_classnames44.default)(
10396
+ "Layer__profit-and-loss-detailed-charts__pie",
10397
+ hoveredItem && active ? "active" : "inactive",
10398
+ entry.type === "Uncategorized" && "Layer__profit-and-loss-detailed-charts__pie--border"
10399
+ ),
10400
+ style: {
10401
+ fill: entry.type === "Uncategorized" && fill ? "url(#layer-pie-dots-pattern)" : fill
10402
+ },
10295
10403
  opacity: typeColorMapping[index].opacity,
10296
10404
  onMouseEnter: () => setHoveredItem(entry.name),
10297
10405
  onMouseLeave: () => setHoveredItem(void 0)
@@ -10647,7 +10755,7 @@ var MiniChart = ({ data }) => {
10647
10755
  };
10648
10756
 
10649
10757
  // src/components/ProfitAndLossSummaries/ProfitAndLossSummaries.tsx
10650
- var import_classnames44 = __toESM(require("classnames"));
10758
+ var import_classnames45 = __toESM(require("classnames"));
10651
10759
  var CHART_PLACEHOLDER = [
10652
10760
  {
10653
10761
  name: "placeholder",
@@ -10706,7 +10814,7 @@ var ProfitAndLossSummaries = ({
10706
10814
  /* @__PURE__ */ import_react108.default.createElement(
10707
10815
  "div",
10708
10816
  {
10709
- className: (0, import_classnames44.default)(
10817
+ className: (0, import_classnames45.default)(
10710
10818
  "Layer__profit-and-loss-summaries__summary",
10711
10819
  actionable && "Layer__actionable",
10712
10820
  "Layer__profit-and-loss-summaries__summary--income",
@@ -10728,7 +10836,7 @@ var ProfitAndLossSummaries = ({
10728
10836
  /* @__PURE__ */ import_react108.default.createElement(
10729
10837
  "div",
10730
10838
  {
10731
- className: (0, import_classnames44.default)(
10839
+ className: (0, import_classnames45.default)(
10732
10840
  "Layer__profit-and-loss-summaries__summary",
10733
10841
  actionable && "Layer__actionable",
10734
10842
  "Layer__profit-and-loss-summaries__summary--expenses",
@@ -10752,7 +10860,7 @@ var ProfitAndLossSummaries = ({
10752
10860
  /* @__PURE__ */ import_react108.default.createElement(
10753
10861
  "div",
10754
10862
  {
10755
- className: (0, import_classnames44.default)(
10863
+ className: (0, import_classnames45.default)(
10756
10864
  "Layer__profit-and-loss-summaries__summary net-profit Layer__profit-and-loss-summaries__summary--net-profit",
10757
10865
  actionable && "Layer__actionable"
10758
10866
  )
@@ -10768,15 +10876,91 @@ var ProfitAndLossSummaries = ({
10768
10876
  );
10769
10877
  };
10770
10878
 
10771
- // src/components/ProfitAndLossTable/ProfitAndLossTable.tsx
10772
- var import_react110 = __toESM(require("react"));
10879
+ // src/components/ProfitAndLossTable/ProfitAndLossTableWithProvider.tsx
10880
+ var import_react117 = __toESM(require("react"));
10773
10881
 
10774
- // src/components/ProfitAndLossRow/ProfitAndLossRow.tsx
10882
+ // src/contexts/TableContext/TableContext.tsx
10775
10883
  var import_react109 = __toESM(require("react"));
10884
+ var defaultValue = {
10885
+ expandedRows: [],
10886
+ setExpandedRows: () => {
10887
+ },
10888
+ expandAllRows: () => {
10889
+ },
10890
+ expandedAllRows: false,
10891
+ setExpandedAllRows: () => {
10892
+ }
10893
+ };
10894
+ var TableContext = (0, import_react109.createContext)(defaultValue);
10895
+ var TableProvider = ({ children }) => {
10896
+ const [expandedRows, setExpandedRowsState] = (0, import_react109.useState)([]);
10897
+ const [expandedAllRows, setExpandedAllRows] = (0, import_react109.useState)(false);
10898
+ const toggleRow = (rowKey) => {
10899
+ setExpandedRowsState((prevRows) => {
10900
+ const rows = [...prevRows];
10901
+ if (rows.includes(rowKey)) {
10902
+ rows.splice(rows.indexOf(rowKey), 1);
10903
+ } else {
10904
+ rows.push(rowKey);
10905
+ }
10906
+ return rows;
10907
+ });
10908
+ };
10909
+ const expandAllRows = (rowKeys) => {
10910
+ setExpandedRowsState(rowKeys);
10911
+ };
10912
+ const contextValue = {
10913
+ expandedRows,
10914
+ setExpandedRows: toggleRow,
10915
+ expandAllRows,
10916
+ expandedAllRows,
10917
+ setExpandedAllRows
10918
+ };
10919
+ return /* @__PURE__ */ import_react109.default.createElement(TableContext.Provider, { value: contextValue }, children);
10920
+ };
10921
+
10922
+ // src/components/ProfitAndLossTable/ProfitAndLossTableComponent.tsx
10923
+ var import_react116 = __toESM(require("react"));
10924
+
10925
+ // src/hooks/useTableExpandRow/useTableExpandRow.tsx
10926
+ var import_react110 = require("react");
10927
+ var useTableExpandRow = () => {
10928
+ const {
10929
+ expandedAllRows,
10930
+ setExpandedAllRows,
10931
+ expandAllRows,
10932
+ expandedRows,
10933
+ setExpandedRows
10934
+ } = (0, import_react110.useContext)(TableContext);
10935
+ const toggleAllRows = () => {
10936
+ if (expandedAllRows) {
10937
+ setIsOpen([]);
10938
+ return setExpandedAllRows(false);
10939
+ } else {
10940
+ return setExpandedAllRows(true);
10941
+ }
10942
+ };
10943
+ const setIsOpen = (rowKey, withoutAllRowsUpdate) => {
10944
+ if (!withoutAllRowsUpdate && expandedAllRows) {
10945
+ setExpandedAllRows(false);
10946
+ }
10947
+ if (Array.isArray(rowKey)) {
10948
+ return expandAllRows(rowKey);
10949
+ }
10950
+ return setExpandedRows(rowKey);
10951
+ };
10952
+ const isOpen = (rowKey) => expandedRows.includes(rowKey);
10953
+ return {
10954
+ isOpen,
10955
+ setIsOpen,
10956
+ expandedAllRows,
10957
+ toggleAllRows
10958
+ };
10959
+ };
10776
10960
 
10777
10961
  // src/icons/PieChart.tsx
10778
- var React122 = __toESM(require("react"));
10779
- var PieChart3 = ({ size = 12, ...props }) => /* @__PURE__ */ React122.createElement(
10962
+ var React123 = __toESM(require("react"));
10963
+ var PieChart3 = ({ size = 12, ...props }) => /* @__PURE__ */ React123.createElement(
10780
10964
  "svg",
10781
10965
  {
10782
10966
  xmlns: "http://www.w3.org/2000/svg",
@@ -10786,7 +10970,7 @@ var PieChart3 = ({ size = 12, ...props }) => /* @__PURE__ */ React122.createElem
10786
10970
  width: size,
10787
10971
  height: size
10788
10972
  },
10789
- /* @__PURE__ */ React122.createElement("g", null, /* @__PURE__ */ React122.createElement(
10973
+ /* @__PURE__ */ React123.createElement("g", null, /* @__PURE__ */ React123.createElement(
10790
10974
  "path",
10791
10975
  {
10792
10976
  d: "M10.2213 7.78271C9.92969 8.47226 9.47363 9.07989 8.89297 9.55247C8.3123 10.0251 7.62471 10.3482 6.89031 10.4936C6.1559 10.6391 5.39705 10.6024 4.68009 10.3869C3.96313 10.1713 3.30989 9.78337 2.77749 9.25701C2.24509 8.73065 1.84973 8.08189 1.62598 7.36744C1.40223 6.65298 1.3569 5.8946 1.49396 5.15858C1.63102 4.42257 1.94629 3.73133 2.41221 3.14531C2.87813 2.55928 3.48051 2.09631 4.16669 1.79688",
@@ -10794,7 +10978,7 @@ var PieChart3 = ({ size = 12, ...props }) => /* @__PURE__ */ React122.createElem
10794
10978
  strokeLinecap: "round",
10795
10979
  strokeLinejoin: "round"
10796
10980
  }
10797
- ), /* @__PURE__ */ React122.createElement(
10981
+ ), /* @__PURE__ */ React123.createElement(
10798
10982
  "path",
10799
10983
  {
10800
10984
  d: "M10.5833 6.00033C10.5833 5.39843 10.4648 4.80244 10.2344 4.24636C10.0041 3.69028 9.66651 3.18502 9.24091 2.75942C8.8153 2.33382 8.31004 1.99621 7.75397 1.76588C7.19789 1.53554 6.60189 1.41699 6 1.41699V6.00033H10.5833Z",
@@ -10806,96 +10990,139 @@ var PieChart3 = ({ size = 12, ...props }) => /* @__PURE__ */ React122.createElem
10806
10990
  );
10807
10991
  var PieChart_default = PieChart3;
10808
10992
 
10809
- // src/components/ProfitAndLossRow/ProfitAndLossRow.tsx
10810
- var ProfitAndLossRow = ({
10811
- variant,
10812
- lineItem,
10813
- depth = 0,
10814
- maxDepth = 8,
10815
- direction = "DEBIT" /* DEBIT */,
10816
- lockExpanded = false,
10817
- scope,
10818
- setSidebarScope,
10819
- defaultExpanded = false
10993
+ // src/components/TableBody/TableBody.tsx
10994
+ var import_react111 = __toESM(require("react"));
10995
+ var TableBody = ({ children }) => {
10996
+ return /* @__PURE__ */ import_react111.default.createElement("tbody", { className: "Layer__table-body" }, children);
10997
+ };
10998
+
10999
+ // src/components/TableCell/TableCell.tsx
11000
+ var import_react112 = __toESM(require("react"));
11001
+ var import_classnames46 = __toESM(require("classnames"));
11002
+ var TableCell = ({
11003
+ children,
11004
+ isHeaderCell,
11005
+ isCurrency,
11006
+ primary,
11007
+ withExpandIcon = false,
11008
+ fullWidth
10820
11009
  }) => {
10821
- if (!lineItem) {
10822
- return null;
10823
- }
10824
- const { value, display_name, line_items } = lineItem;
10825
- const [expanded, setExpanded] = (0, import_react109.useState)(lockExpanded || defaultExpanded);
10826
- const amount = value ?? 0;
11010
+ const amount = typeof children === "number" ? children : 0;
11011
+ const isPositive = amount >= 0;
10827
11012
  const amountString = centsToDollars(Math.abs(amount));
10828
- const labelClasses = [
10829
- "Layer__profit-and-loss-row",
10830
- "Layer__profit-and-loss-row__label"
10831
- ];
10832
- const valueClasses = [
10833
- "Layer__profit-and-loss-row",
10834
- "Layer__profit-and-loss-row__value"
10835
- ];
10836
- const positive = amount === 0 || direction === "CREDIT" /* CREDIT */ && amount > 0 || direction === "DEBIT" /* DEBIT */ && amount < 0;
10837
- valueClasses.push(
10838
- positive ? "Layer__profit-and-loss-row__value--amount-positive" : "Layer__profit-and-loss-row__value--amount-negative"
10839
- );
10840
- labelClasses.push(`Layer__profit-and-loss-row__label--depth-${depth}`);
10841
- valueClasses.push(`Layer__profit-and-loss-row__value--depth-${depth}`);
10842
- variant && labelClasses.push(`Layer__profit-and-loss-row__label--variant-${variant}`);
10843
- variant && valueClasses.push(`Layer__profit-and-loss-row__value--variant-${variant}`);
10844
- const toggleExpanded = () => setExpanded(!expanded);
10845
- const canGoDeeper = depth < maxDepth;
10846
- const hasChildren = (line_items?.length ?? 0) > 0;
10847
- const displayChildren = hasChildren && canGoDeeper;
10848
- labelClasses.push(
10849
- `Layer__profit-and-loss-row__label--display-children-${displayChildren}`
10850
- );
10851
- valueClasses.push(
10852
- `Layer__profit-and-loss-row__value--display-children-${displayChildren}`
10853
- );
10854
- displayChildren && expanded && labelClasses.push("Layer__profit-and-loss-row__label--expanded");
10855
- displayChildren && expanded && valueClasses.push("Layer__profit-and-loss-row__value--expanded");
10856
- return /* @__PURE__ */ import_react109.default.createElement(import_react109.default.Fragment, null, /* @__PURE__ */ import_react109.default.createElement(
10857
- "div",
11013
+ const cellClassNames = (0, import_classnames46.default)(
11014
+ "Layer__table-cell",
11015
+ (primary || isHeaderCell) && "Layer__table-cell--primary",
11016
+ isCurrency && "Layer__table-cell-amount",
11017
+ isCurrency && isPositive && "Layer__table-cell-amount--positive",
11018
+ isCurrency && !isPositive && "Layer__table-cell-amount--negative"
11019
+ );
11020
+ if (isHeaderCell) {
11021
+ return /* @__PURE__ */ import_react112.default.createElement("th", { className: cellClassNames }, /* @__PURE__ */ import_react112.default.createElement("span", { className: "Layer__table-cell-content" }, children));
11022
+ }
11023
+ return /* @__PURE__ */ import_react112.default.createElement(
11024
+ "td",
10858
11025
  {
10859
- className: labelClasses.join(" "),
10860
- onClick: () => !lockExpanded && toggleExpanded(),
10861
- style: {
10862
- paddingLeft: depth === 0 && !hasChildren ? 28 : 16 * (depth + 1) + 2
10863
- }
11026
+ className: cellClassNames,
11027
+ style: fullWidth ? { width: "100%" } : void 0
10864
11028
  },
10865
- /* @__PURE__ */ import_react109.default.createElement("span", { className: "Layer__profit-and-loss-row__label__title" }, !lockExpanded && variant !== "summation" ? /* @__PURE__ */ import_react109.default.createElement(
11029
+ /* @__PURE__ */ import_react112.default.createElement("span", { className: "Layer__table-cell-content" }, withExpandIcon && /* @__PURE__ */ import_react112.default.createElement(
10866
11030
  ChevronDownFill_default,
10867
11031
  {
10868
- size: 16,
10869
- className: "Layer__profit-and-loss-row__label__chevron"
11032
+ className: "Layer__table-row--expand-icon",
11033
+ size: 16
10870
11034
  }
10871
- ) : null, /* @__PURE__ */ import_react109.default.createElement(Text, null, display_name)),
10872
- setSidebarScope && /* @__PURE__ */ import_react109.default.createElement(
10873
- "span",
10874
- {
10875
- className: "Layer__profit-and-loss-row__detailed-chart-btn",
10876
- onClick: (e) => {
10877
- e.stopPropagation();
10878
- setSidebarScope && setSidebarScope(scope ?? "expenses");
11035
+ ), isCurrency ? amountString : children, " ")
11036
+ );
11037
+ };
11038
+
11039
+ // src/components/TableHead/TableHead.tsx
11040
+ var import_react113 = __toESM(require("react"));
11041
+ var TableHead = ({ children }) => {
11042
+ return /* @__PURE__ */ import_react113.default.createElement("thead", { className: "Layer__table-header" }, children);
11043
+ };
11044
+
11045
+ // src/components/TableRow/TableRow.tsx
11046
+ var import_react114 = __toESM(require("react"));
11047
+ var import_classnames47 = __toESM(require("classnames"));
11048
+ var TableRow = ({
11049
+ rowKey,
11050
+ children,
11051
+ depth = 0,
11052
+ expandable = false,
11053
+ isExpanded = false,
11054
+ handleExpand,
11055
+ variant = expandable ? "expandable" : "default",
11056
+ withDivider,
11057
+ withDividerPosition = "top",
11058
+ isHeadRow = false
11059
+ }) => {
11060
+ const toggleExpanded = () => {
11061
+ if (variant === "summation" || !expandable)
11062
+ return;
11063
+ handleExpand && handleExpand();
11064
+ };
11065
+ const rowClassNames = (0, import_classnames47.default)([
11066
+ "Layer__table-row",
11067
+ !isHeadRow && `Layer__table-row--depth-${depth}`,
11068
+ !isHeadRow && `Layer__table-row--variant-${variant}`,
11069
+ !isHeadRow && expandable && (isExpanded ? "Layer__table-row--expanded" : "Layer__table-row--collapsed")
11070
+ ]);
11071
+ return /* @__PURE__ */ import_react114.default.createElement(import_react114.default.Fragment, null, withDivider && withDividerPosition === "top" && /* @__PURE__ */ import_react114.default.createElement("tr", { className: "Layer__table-empty-row" }, /* @__PURE__ */ import_react114.default.createElement("td", { colSpan: Array.isArray(children) ? children.length : 1 })), /* @__PURE__ */ import_react114.default.createElement("tr", { "data-key": rowKey, className: rowClassNames, onClick: toggleExpanded }, children), withDivider && withDividerPosition === "bottom" && /* @__PURE__ */ import_react114.default.createElement("tr", { className: "Layer__table-empty-row" }, /* @__PURE__ */ import_react114.default.createElement("td", { colSpan: Array.isArray(children) ? children.length : 1 })));
11072
+ };
11073
+
11074
+ // src/components/Table/Table.tsx
11075
+ var import_react115 = __toESM(require("react"));
11076
+ var import_classnames48 = __toESM(require("classnames"));
11077
+ var Table = ({
11078
+ componentName,
11079
+ children,
11080
+ borderCollapse = "separate",
11081
+ bottomSpacing = true
11082
+ }) => {
11083
+ const tableRef = (0, import_react115.useRef)(null);
11084
+ const prevChildrenRef = (0, import_react115.useRef)([]);
11085
+ (0, import_react115.useEffect)(() => {
11086
+ if (tableRef.current) {
11087
+ const tbody = tableRef.current.querySelector("tbody");
11088
+ const rows = tbody ? Array.from(tbody.querySelectorAll("tr")) : [];
11089
+ const prevChildrenArray = prevChildrenRef.current;
11090
+ const currentChildren = rows.map(
11091
+ (child) => child.getAttribute("data-key") && {
11092
+ key: child.getAttribute("data-key"),
11093
+ child
10879
11094
  }
10880
- },
10881
- /* @__PURE__ */ import_react109.default.createElement(PieChart_default, null)
10882
- )
10883
- ), /* @__PURE__ */ import_react109.default.createElement("div", { className: valueClasses.join(" ") }, /* @__PURE__ */ import_react109.default.createElement(Text, null, amountString)), canGoDeeper && hasChildren && /* @__PURE__ */ import_react109.default.createElement(
10884
- "div",
10885
- {
10886
- className: `Layer__profit-and-loss-row__children ${expanded && "Layer__profit-and-loss-row__children--expanded"}`
10887
- },
10888
- /* @__PURE__ */ import_react109.default.createElement("div", { className: "Layer__profit-and-loss-row__children--content" }, (line_items || []).map((line_item) => /* @__PURE__ */ import_react109.default.createElement(
10889
- ProfitAndLossRow,
10890
- {
10891
- key: line_item.display_name,
10892
- lineItem: line_item,
10893
- depth: depth + 1,
10894
- maxDepth,
10895
- direction
10896
- }
10897
- )))
10898
- ));
11095
+ );
11096
+ const newChildrenKeys = [];
11097
+ const newChildrenArray = currentChildren.filter((el) => {
11098
+ if (el && el.key) {
11099
+ newChildrenKeys.push(el.key);
11100
+ }
11101
+ return el && el.key && !prevChildrenArray.includes(el.key);
11102
+ });
11103
+ newChildrenArray.forEach((row, index) => {
11104
+ const rowKey = row && row.key;
11105
+ if (rowKey && !row.child.classList.contains("Layer__table-empty-row")) {
11106
+ row.child.classList.add("Layer__table-row--anim-starting-state");
11107
+ setTimeout(() => {
11108
+ row.child.classList.add("Layer__table-row--anim-complete-state");
11109
+ row.child.classList.remove("Layer__table-row--anim-starting-state");
11110
+ }, 15 * index);
11111
+ }
11112
+ });
11113
+ prevChildrenRef.current = newChildrenKeys;
11114
+ }
11115
+ }, [children]);
11116
+ const tableWrapperClassNames = (0, import_classnames48.default)(
11117
+ "Layer__table-wrapper",
11118
+ bottomSpacing && "Layer__table-wrapper--bottom-spacing"
11119
+ );
11120
+ const tableClassNames = (0, import_classnames48.default)(
11121
+ "Layer__table",
11122
+ componentName && `Layer__${componentName}__table`,
11123
+ borderCollapse && `Layer__table__${borderCollapse}-rows`
11124
+ );
11125
+ return /* @__PURE__ */ import_react115.default.createElement("div", { className: tableWrapperClassNames }, /* @__PURE__ */ import_react115.default.createElement("table", { className: tableClassNames, ref: tableRef }, children));
10899
11126
  };
10900
11127
 
10901
11128
  // src/components/ProfitAndLossTable/empty_profit_and_loss_report.ts
@@ -10946,10 +11173,9 @@ var empty_profit_and_loss_report_default = {
10946
11173
  fully_categorized: false
10947
11174
  };
10948
11175
 
10949
- // src/components/ProfitAndLossTable/ProfitAndLossTable.tsx
10950
- var import_classnames45 = __toESM(require("classnames"));
10951
- var ProfitAndLossTable = ({
10952
- lockExpanded,
11176
+ // src/components/ProfitAndLossTable/ProfitAndLossTableComponent.tsx
11177
+ var import_classnames49 = __toESM(require("classnames"));
11178
+ var ProfitAndLossTableComponent = ({
10953
11179
  asContainer,
10954
11180
  stringOverrides
10955
11181
  }) => {
@@ -10957,135 +11183,134 @@ var ProfitAndLossTable = ({
10957
11183
  data: actualData,
10958
11184
  isLoading,
10959
11185
  setSidebarScope
10960
- } = (0, import_react110.useContext)(ProfitAndLoss.Context);
11186
+ } = (0, import_react116.useContext)(ProfitAndLoss.Context);
11187
+ const { isOpen, setIsOpen } = useTableExpandRow();
11188
+ (0, import_react116.useEffect)(() => {
11189
+ setIsOpen(["income", "cost_of_goods_sold", "expenses"]);
11190
+ }, []);
10961
11191
  const currentData = Array.isArray(actualData) ? actualData[actualData.length - 1] : actualData;
10962
11192
  const data = !currentData || isLoading ? empty_profit_and_loss_report_default : currentData;
10963
11193
  if (isLoading || actualData === void 0) {
10964
- return /* @__PURE__ */ import_react110.default.createElement(
11194
+ return /* @__PURE__ */ import_react116.default.createElement(
10965
11195
  "div",
10966
11196
  {
10967
- className: (0, import_classnames45.default)(
11197
+ className: (0, import_classnames49.default)(
10968
11198
  "Layer__profit-and-loss-table__loader-container",
10969
11199
  asContainer && "Layer__component-container"
10970
11200
  )
10971
11201
  },
10972
- /* @__PURE__ */ import_react110.default.createElement(Loader2, null)
11202
+ /* @__PURE__ */ import_react116.default.createElement(Loader2, null)
10973
11203
  );
10974
11204
  }
10975
- return /* @__PURE__ */ import_react110.default.createElement(import_react110.default.Fragment, null, /* @__PURE__ */ import_react110.default.createElement(
10976
- "div",
10977
- {
10978
- className: (0, import_classnames45.default)(
10979
- "Layer__profit-and-loss-table Layer__profit-and-loss-table--main",
10980
- asContainer && "Layer__component-container"
10981
- )
10982
- },
10983
- /* @__PURE__ */ import_react110.default.createElement(
10984
- ProfitAndLossRow,
10985
- {
10986
- lineItem: data.income,
10987
- direction: "CREDIT" /* CREDIT */,
10988
- lockExpanded,
10989
- scope: "revenue",
10990
- setSidebarScope,
10991
- defaultExpanded: true
10992
- }
10993
- ),
10994
- /* @__PURE__ */ import_react110.default.createElement(
10995
- ProfitAndLossRow,
10996
- {
10997
- lineItem: data.cost_of_goods_sold,
10998
- direction: "DEBIT" /* DEBIT */,
10999
- lockExpanded,
11000
- scope: "expenses",
11001
- setSidebarScope,
11002
- defaultExpanded: true
11003
- }
11004
- ),
11005
- /* @__PURE__ */ import_react110.default.createElement(
11006
- ProfitAndLossRow,
11007
- {
11008
- lineItem: {
11009
- value: data.gross_profit,
11010
- display_name: stringOverrides?.grossProfitLabel || "Gross Profit"
11011
- },
11012
- variant: "summation",
11013
- direction: "CREDIT" /* CREDIT */,
11014
- lockExpanded,
11015
- scope: "revenue",
11016
- setSidebarScope,
11017
- defaultExpanded: true
11018
- }
11019
- ),
11020
- /* @__PURE__ */ import_react110.default.createElement(
11021
- ProfitAndLossRow,
11022
- {
11023
- lineItem: data.expenses,
11024
- direction: "DEBIT" /* DEBIT */,
11025
- lockExpanded,
11026
- scope: "expenses",
11027
- setSidebarScope,
11028
- defaultExpanded: true
11029
- }
11030
- ),
11031
- /* @__PURE__ */ import_react110.default.createElement(
11032
- ProfitAndLossRow,
11033
- {
11034
- lineItem: {
11035
- value: data.profit_before_taxes,
11036
- display_name: stringOverrides?.profitBeforeTaxesLabel || "Profit Before Taxes"
11037
- },
11038
- variant: "summation",
11039
- direction: "CREDIT" /* CREDIT */,
11040
- lockExpanded,
11041
- scope: "revenue",
11042
- setSidebarScope,
11043
- defaultExpanded: true
11044
- }
11045
- ),
11046
- /* @__PURE__ */ import_react110.default.createElement(
11047
- ProfitAndLossRow,
11048
- {
11049
- lineItem: data.taxes,
11050
- direction: "DEBIT" /* DEBIT */,
11051
- lockExpanded,
11052
- scope: "expenses",
11053
- setSidebarScope,
11054
- defaultExpanded: true
11055
- }
11056
- ),
11057
- /* @__PURE__ */ import_react110.default.createElement(
11058
- ProfitAndLossRow,
11205
+ const renderLineItem = (lineItem, depth, rowKey, rowIndex, scope, setSidebarScope2, variant) => {
11206
+ const expandable = !!lineItem.line_items && lineItem.line_items.length > 0;
11207
+ const expanded = expandable ? isOpen(rowKey) : true;
11208
+ return /* @__PURE__ */ import_react116.default.createElement(import_react116.default.Fragment, { key: rowKey + "-" + rowIndex }, /* @__PURE__ */ import_react116.default.createElement(
11209
+ TableRow,
11059
11210
  {
11060
- lineItem: {
11061
- value: data.net_profit,
11062
- display_name: stringOverrides?.netProfitLabel || "Net Profit"
11211
+ rowKey: rowKey + "-" + rowIndex,
11212
+ expandable,
11213
+ isExpanded: expanded,
11214
+ depth,
11215
+ variant: variant ? variant : expandable ? "expandable" : "default",
11216
+ handleExpand: () => setIsOpen(rowKey)
11217
+ },
11218
+ /* @__PURE__ */ import_react116.default.createElement(
11219
+ TableCell,
11220
+ {
11221
+ primary: true,
11222
+ withExpandIcon: expandable,
11223
+ fullWidth: !!setSidebarScope2
11063
11224
  },
11064
- variant: "summation",
11065
- direction: "CREDIT" /* CREDIT */,
11066
- lockExpanded
11067
- }
11068
- )
11069
- ), data.other_outflows || data.personal_expenses ? /* @__PURE__ */ import_react110.default.createElement("div", { className: "Layer__profit-and-loss-table Layer__profit-and-loss-table__outflows" }, /* @__PURE__ */ import_react110.default.createElement(
11070
- ProfitAndLossRow,
11225
+ lineItem.display_name,
11226
+ " ",
11227
+ setSidebarScope2 && /* @__PURE__ */ import_react116.default.createElement(
11228
+ "span",
11229
+ {
11230
+ className: "Layer__profit-and-loss-row__detailed-chart-btn",
11231
+ onClick: (e) => {
11232
+ e.stopPropagation();
11233
+ setSidebarScope2 && setSidebarScope2(scope ?? "expenses");
11234
+ }
11235
+ },
11236
+ /* @__PURE__ */ import_react116.default.createElement(PieChart_default, null)
11237
+ )
11238
+ ),
11239
+ /* @__PURE__ */ import_react116.default.createElement(TableCell, { isCurrency: true, primary: true }, lineItem.value)
11240
+ ), expanded && lineItem.line_items ? lineItem.line_items.map(
11241
+ (child, i) => renderLineItem(
11242
+ child,
11243
+ depth + 1,
11244
+ child.display_name + "-" + rowIndex,
11245
+ i
11246
+ )
11247
+ ) : null);
11248
+ };
11249
+ return /* @__PURE__ */ import_react116.default.createElement(Table, { borderCollapse: "collapse", bottomSpacing: false }, /* @__PURE__ */ import_react116.default.createElement(TableBody, null, renderLineItem(
11250
+ data.income,
11251
+ 0,
11252
+ "income",
11253
+ 0,
11254
+ "revenue",
11255
+ setSidebarScope
11256
+ ), renderLineItem(
11257
+ data.cost_of_goods_sold,
11258
+ 0,
11259
+ "cost_of_goods_sold",
11260
+ 1,
11261
+ "expenses",
11262
+ setSidebarScope
11263
+ ), renderLineItem(
11071
11264
  {
11072
- lineItem: data.other_outflows,
11073
- direction: "DEBIT" /* DEBIT */,
11074
- lockExpanded
11075
- }
11076
- ), /* @__PURE__ */ import_react110.default.createElement(
11077
- ProfitAndLossRow,
11265
+ value: data.gross_profit,
11266
+ display_name: stringOverrides?.grossProfitLabel || "Gross Profit"
11267
+ },
11268
+ 0,
11269
+ "gross_profit",
11270
+ 2,
11271
+ "revenue",
11272
+ setSidebarScope,
11273
+ "summation"
11274
+ ), renderLineItem(
11275
+ data.expenses,
11276
+ 0,
11277
+ "expenses",
11278
+ 3,
11279
+ "expenses",
11280
+ setSidebarScope
11281
+ ), renderLineItem(
11078
11282
  {
11079
- lineItem: data.personal_expenses,
11080
- direction: "DEBIT" /* DEBIT */,
11081
- lockExpanded
11082
- }
11083
- )) : null);
11283
+ value: data.profit_before_taxes,
11284
+ display_name: stringOverrides?.profitBeforeTaxesLabel || "Profit Before Taxes"
11285
+ },
11286
+ 0,
11287
+ "profit_before_taxes",
11288
+ 4,
11289
+ "revenue",
11290
+ setSidebarScope,
11291
+ "summation"
11292
+ ), renderLineItem(data.taxes, 0, "taxes", 5, "expenses", setSidebarScope), renderLineItem(
11293
+ {
11294
+ value: data.net_profit,
11295
+ display_name: stringOverrides?.netProfitLabel || "Net Profit"
11296
+ },
11297
+ 0,
11298
+ "net_profit",
11299
+ 5,
11300
+ void 0,
11301
+ void 0,
11302
+ "summation"
11303
+ ), data.other_outflows || data.personal_expenses ? /* @__PURE__ */ import_react116.default.createElement(import_react116.default.Fragment, null, renderLineItem(data.other_outflows, 0, "other_outflows", 6), renderLineItem(data.personal_expenses, 0, "personal_expenses", 7)) : null));
11304
+ };
11305
+
11306
+ // src/components/ProfitAndLossTable/ProfitAndLossTableWithProvider.tsx
11307
+ var ProfitAndLossTableWithProvider = (props) => {
11308
+ return /* @__PURE__ */ import_react117.default.createElement(TableProvider, null, /* @__PURE__ */ import_react117.default.createElement(ProfitAndLossTableComponent, { ...props }));
11084
11309
  };
11085
11310
 
11086
11311
  // src/components/ProfitAndLoss/ProfitAndLoss.tsx
11087
11312
  var import_date_fns22 = require("date-fns");
11088
- var PNLContext = (0, import_react111.createContext)({
11313
+ var PNLContext = (0, import_react118.createContext)({
11089
11314
  data: void 0,
11090
11315
  filteredDataRevenue: [],
11091
11316
  filteredTotalRevenue: void 0,
@@ -11121,21 +11346,21 @@ var ProfitAndLoss = ({
11121
11346
  asContainer = true
11122
11347
  }) => {
11123
11348
  const contextData = useProfitAndLoss({ tagFilter, reportingBasis });
11124
- return /* @__PURE__ */ import_react111.default.createElement(PNLContext.Provider, { value: contextData }, asContainer ? /* @__PURE__ */ import_react111.default.createElement(Container, { name: "profit-and-loss" }, children) : children);
11349
+ return /* @__PURE__ */ import_react118.default.createElement(PNLContext.Provider, { value: contextData }, asContainer ? /* @__PURE__ */ import_react118.default.createElement(Container, { name: "profit-and-loss" }, children) : children);
11125
11350
  };
11126
11351
  ProfitAndLoss.Chart = ProfitAndLossChart;
11127
11352
  ProfitAndLoss.Context = PNLContext;
11128
11353
  ProfitAndLoss.DatePicker = ProfitAndLossDatePicker;
11129
11354
  ProfitAndLoss.Summaries = ProfitAndLossSummaries;
11130
- ProfitAndLoss.Table = ProfitAndLossTable;
11355
+ ProfitAndLoss.Table = ProfitAndLossTableWithProvider;
11131
11356
  ProfitAndLoss.DetailedCharts = ProfitAndLossDetailedCharts;
11132
11357
 
11133
11358
  // src/components/BalanceSheet/BalanceSheet.tsx
11134
11359
  var import_react127 = __toESM(require("react"));
11135
11360
 
11136
11361
  // src/contexts/BalanceSheetContext/BalanceSheetContext.tsx
11137
- var import_react112 = require("react");
11138
- var BalanceSheetContext = (0, import_react112.createContext)({
11362
+ var import_react119 = require("react");
11363
+ var BalanceSheetContext = (0, import_react119.createContext)({
11139
11364
  data: void 0,
11140
11365
  isLoading: false,
11141
11366
  error: void 0,
@@ -11143,48 +11368,8 @@ var BalanceSheetContext = (0, import_react112.createContext)({
11143
11368
  }
11144
11369
  });
11145
11370
 
11146
- // src/contexts/TableContext/TableContext.tsx
11147
- var import_react113 = __toESM(require("react"));
11148
- var defaultValue = {
11149
- expandedRows: [],
11150
- setExpandedRows: () => {
11151
- },
11152
- expandAllRows: () => {
11153
- },
11154
- expandedAllRows: false,
11155
- setExpandedAllRows: () => {
11156
- }
11157
- };
11158
- var TableContext = (0, import_react113.createContext)(defaultValue);
11159
- var TableProvider = ({ children }) => {
11160
- const [expandedRows, setExpandedRowsState] = (0, import_react113.useState)([]);
11161
- const [expandedAllRows, setExpandedAllRows] = (0, import_react113.useState)(false);
11162
- const toggleRow = (rowKey) => {
11163
- setExpandedRowsState((prevRows) => {
11164
- const rows = [...prevRows];
11165
- if (rows.includes(rowKey)) {
11166
- rows.splice(rows.indexOf(rowKey), 1);
11167
- } else {
11168
- rows.push(rowKey);
11169
- }
11170
- return rows;
11171
- });
11172
- };
11173
- const expandAllRows = (rowKeys) => {
11174
- setExpandedRowsState(rowKeys);
11175
- };
11176
- const contextValue = {
11177
- expandedRows,
11178
- setExpandedRows: toggleRow,
11179
- expandAllRows,
11180
- expandedAllRows,
11181
- setExpandedAllRows
11182
- };
11183
- return /* @__PURE__ */ import_react113.default.createElement(TableContext.Provider, { value: contextValue }, children);
11184
- };
11185
-
11186
11371
  // src/hooks/useBalanceSheet/useBalanceSheet.tsx
11187
- var import_react114 = require("react");
11372
+ var import_react120 = require("react");
11188
11373
  var import_date_fns23 = require("date-fns");
11189
11374
  var import_swr5 = __toESM(require("swr"));
11190
11375
  var useBalanceSheet = (date = /* @__PURE__ */ new Date()) => {
@@ -11203,12 +11388,12 @@ var useBalanceSheet = (date = /* @__PURE__ */ new Date()) => {
11203
11388
  const refetch = () => {
11204
11389
  mutate();
11205
11390
  };
11206
- (0, import_react114.useEffect)(() => {
11391
+ (0, import_react120.useEffect)(() => {
11207
11392
  if (queryKey && (isLoading || isValidating)) {
11208
11393
  read("BALANCE_SHEET" /* BALANCE_SHEET */, queryKey);
11209
11394
  }
11210
11395
  }, [isLoading, isValidating]);
11211
- (0, import_react114.useEffect)(() => {
11396
+ (0, import_react120.useEffect)(() => {
11212
11397
  if (queryKey && hasBeenTouched(queryKey)) {
11213
11398
  refetch();
11214
11399
  }
@@ -11217,12 +11402,12 @@ var useBalanceSheet = (date = /* @__PURE__ */ new Date()) => {
11217
11402
  };
11218
11403
 
11219
11404
  // src/components/BalanceSheetDatePicker/BalanceSheetDatePicker.tsx
11220
- var import_react115 = __toESM(require("react"));
11405
+ var import_react121 = __toESM(require("react"));
11221
11406
  var BalanceSheetDatePicker = ({
11222
11407
  effectiveDate,
11223
11408
  setEffectiveDate
11224
11409
  }) => {
11225
- return /* @__PURE__ */ import_react115.default.createElement(import_react115.default.Fragment, null, /* @__PURE__ */ import_react115.default.createElement(
11410
+ return /* @__PURE__ */ import_react121.default.createElement(import_react121.default.Fragment, null, /* @__PURE__ */ import_react121.default.createElement(
11226
11411
  DatePicker,
11227
11412
  {
11228
11413
  selected: effectiveDate,
@@ -11233,181 +11418,14 @@ var BalanceSheetDatePicker = ({
11233
11418
  };
11234
11419
 
11235
11420
  // src/components/BalanceSheetExpandAllButton/BalanceSheetExpandAllButton.tsx
11236
- var import_react117 = __toESM(require("react"));
11237
-
11238
- // src/hooks/useTableExpandRow/useTableExpandRow.tsx
11239
- var import_react116 = require("react");
11240
- var useTableExpandRow = () => {
11241
- const {
11242
- expandedAllRows,
11243
- setExpandedAllRows,
11244
- expandAllRows,
11245
- expandedRows,
11246
- setExpandedRows
11247
- } = (0, import_react116.useContext)(TableContext);
11248
- const toggleAllRows = () => {
11249
- if (expandedAllRows) {
11250
- setIsOpen([]);
11251
- return setExpandedAllRows(false);
11252
- } else {
11253
- return setExpandedAllRows(true);
11254
- }
11255
- };
11256
- const setIsOpen = (rowKey, withoutAllRowsUpdate) => {
11257
- if (!withoutAllRowsUpdate && expandedAllRows) {
11258
- setExpandedAllRows(false);
11259
- }
11260
- if (Array.isArray(rowKey)) {
11261
- return expandAllRows(rowKey);
11262
- }
11263
- return setExpandedRows(rowKey);
11264
- };
11265
- const isOpen = (rowKey) => expandedRows.includes(rowKey);
11266
- return {
11267
- isOpen,
11268
- setIsOpen,
11269
- expandedAllRows,
11270
- toggleAllRows
11271
- };
11272
- };
11273
-
11274
- // src/components/BalanceSheetExpandAllButton/BalanceSheetExpandAllButton.tsx
11421
+ var import_react122 = __toESM(require("react"));
11275
11422
  var BalanceSheetExpandAllButton = () => {
11276
11423
  const { expandedAllRows, toggleAllRows } = useTableExpandRow();
11277
- return /* @__PURE__ */ import_react117.default.createElement(Button, { onClick: () => toggleAllRows(), variant: "secondary" /* secondary */ }, !expandedAllRows ? "Expand all rows" : "Collapse all rows");
11424
+ return /* @__PURE__ */ import_react122.default.createElement(Button, { onClick: () => toggleAllRows(), variant: "secondary" /* secondary */ }, !expandedAllRows ? "Expand all rows" : "Collapse all rows");
11278
11425
  };
11279
11426
 
11280
11427
  // src/components/BalanceSheetTable/BalanceSheetTable.tsx
11281
11428
  var import_react123 = __toESM(require("react"));
11282
-
11283
- // src/components/TableBody/TableBody.tsx
11284
- var import_react118 = __toESM(require("react"));
11285
- var TableBody = ({ children }) => {
11286
- return /* @__PURE__ */ import_react118.default.createElement("tbody", { className: "Layer__table-body" }, children);
11287
- };
11288
-
11289
- // src/components/TableCell/TableCell.tsx
11290
- var import_react119 = __toESM(require("react"));
11291
- var import_classnames46 = __toESM(require("classnames"));
11292
- var TableCell = ({
11293
- children,
11294
- isHeaderCell,
11295
- isCurrency,
11296
- primary,
11297
- withExpandIcon = false
11298
- }) => {
11299
- const amount = typeof children === "number" ? children : 0;
11300
- const isPositive = amount >= 0;
11301
- const amountString = centsToDollars(Math.abs(amount));
11302
- const cellClassNames = (0, import_classnames46.default)(
11303
- "Layer__table-cell",
11304
- (primary || isHeaderCell) && "Layer__table-cell--primary",
11305
- isCurrency && "Layer__table-cell-amount",
11306
- isCurrency && isPositive && "Layer__table-cell-amount--positive",
11307
- isCurrency && !isPositive && "Layer__table-cell-amount--negative"
11308
- );
11309
- if (isHeaderCell) {
11310
- return /* @__PURE__ */ import_react119.default.createElement("th", { className: cellClassNames }, /* @__PURE__ */ import_react119.default.createElement("span", { className: "Layer__table-cell-content" }, children));
11311
- }
11312
- return /* @__PURE__ */ import_react119.default.createElement("td", { className: cellClassNames }, /* @__PURE__ */ import_react119.default.createElement("span", { className: "Layer__table-cell-content" }, withExpandIcon && /* @__PURE__ */ import_react119.default.createElement(
11313
- ChevronDownFill_default,
11314
- {
11315
- className: "Layer__table-row--expand-icon",
11316
- size: 16
11317
- }
11318
- ), isCurrency ? amountString : children, " "));
11319
- };
11320
-
11321
- // src/components/TableHead/TableHead.tsx
11322
- var import_react120 = __toESM(require("react"));
11323
- var TableHead = ({ children }) => {
11324
- return /* @__PURE__ */ import_react120.default.createElement("thead", { className: "Layer__table-header" }, children);
11325
- };
11326
-
11327
- // src/components/TableRow/TableRow.tsx
11328
- var import_react121 = __toESM(require("react"));
11329
- var import_classnames47 = __toESM(require("classnames"));
11330
- var TableRow = ({
11331
- rowKey,
11332
- children,
11333
- depth = 0,
11334
- expandable = false,
11335
- isExpanded = false,
11336
- handleExpand,
11337
- variant = expandable ? "expandable" : "default",
11338
- withDivider,
11339
- withDividerPosition = "top",
11340
- isHeadRow = false
11341
- }) => {
11342
- const toggleExpanded = () => {
11343
- if (variant === "summation" || !expandable)
11344
- return;
11345
- handleExpand && handleExpand();
11346
- };
11347
- const rowClassNames = (0, import_classnames47.default)([
11348
- "Layer__table-row",
11349
- !isHeadRow && `Layer__table-row--depth-${depth}`,
11350
- !isHeadRow && `Layer__table-row--variant-${variant}`,
11351
- !isHeadRow && expandable && (isExpanded ? "Layer__table-row--expanded" : "Layer__table-row--collapsed")
11352
- ]);
11353
- return /* @__PURE__ */ import_react121.default.createElement(import_react121.default.Fragment, null, withDivider && withDividerPosition === "top" && /* @__PURE__ */ import_react121.default.createElement("tr", { className: "Layer__table-empty-row" }, /* @__PURE__ */ import_react121.default.createElement("td", { colSpan: Array.isArray(children) ? children.length : 1 })), /* @__PURE__ */ import_react121.default.createElement("tr", { "data-key": rowKey, className: rowClassNames, onClick: toggleExpanded }, children), withDivider && withDividerPosition === "bottom" && /* @__PURE__ */ import_react121.default.createElement("tr", { className: "Layer__table-empty-row" }, /* @__PURE__ */ import_react121.default.createElement("td", { colSpan: Array.isArray(children) ? children.length : 1 })));
11354
- };
11355
-
11356
- // src/components/Table/Table.tsx
11357
- var import_react122 = __toESM(require("react"));
11358
- var import_classnames48 = __toESM(require("classnames"));
11359
- var Table = ({
11360
- componentName,
11361
- children,
11362
- borderCollapse = "separate",
11363
- bottomSpacing = true
11364
- }) => {
11365
- const tableRef = (0, import_react122.useRef)(null);
11366
- const prevChildrenRef = (0, import_react122.useRef)([]);
11367
- (0, import_react122.useEffect)(() => {
11368
- if (tableRef.current) {
11369
- const tbody = tableRef.current.querySelector("tbody");
11370
- const rows = tbody ? Array.from(tbody.querySelectorAll("tr")) : [];
11371
- const prevChildrenArray = prevChildrenRef.current;
11372
- const currentChildren = rows.map(
11373
- (child) => child.getAttribute("data-key") && {
11374
- key: child.getAttribute("data-key"),
11375
- child
11376
- }
11377
- );
11378
- const newChildrenKeys = [];
11379
- const newChildrenArray = currentChildren.filter((el) => {
11380
- if (el && el.key) {
11381
- newChildrenKeys.push(el.key);
11382
- }
11383
- return el && el.key && !prevChildrenArray.includes(el.key);
11384
- });
11385
- newChildrenArray.forEach((row, index) => {
11386
- const rowKey = row && row.key;
11387
- if (rowKey && !row.child.classList.contains("Layer__table-empty-row")) {
11388
- row.child.classList.add("Layer__table-row--anim-starting-state");
11389
- setTimeout(() => {
11390
- row.child.classList.add("Layer__table-row--anim-complete-state");
11391
- row.child.classList.remove("Layer__table-row--anim-starting-state");
11392
- }, 15 * index);
11393
- }
11394
- });
11395
- prevChildrenRef.current = newChildrenKeys;
11396
- }
11397
- }, [children]);
11398
- const tableWrapperClassNames = (0, import_classnames48.default)(
11399
- "Layer__table-wrapper",
11400
- bottomSpacing && "Layer__table-wrapper--bottom-spacing"
11401
- );
11402
- const tableClassNames = (0, import_classnames48.default)(
11403
- "Layer__table",
11404
- componentName && `Layer__${componentName}__table`,
11405
- borderCollapse && `Layer__table__${borderCollapse}-rows`
11406
- );
11407
- return /* @__PURE__ */ import_react122.default.createElement("div", { className: tableWrapperClassNames }, /* @__PURE__ */ import_react122.default.createElement("table", { className: tableClassNames, ref: tableRef }, children));
11408
- };
11409
-
11410
- // src/components/BalanceSheetTable/BalanceSheetTable.tsx
11411
11429
  var BalanceSheetTable = ({
11412
11430
  data,
11413
11431
  config,
@@ -11486,7 +11504,7 @@ var ViewHeader = ({ title, controls }) => {
11486
11504
 
11487
11505
  // src/components/Panel/Panel.tsx
11488
11506
  var import_react125 = __toESM(require("react"));
11489
- var import_classnames49 = __toESM(require("classnames"));
11507
+ var import_classnames50 = __toESM(require("classnames"));
11490
11508
  var Panel = ({
11491
11509
  children,
11492
11510
  className,
@@ -11502,14 +11520,14 @@ var Panel = ({
11502
11520
  setSidebarHeight(parentRef?.current?.offsetHeight - 1);
11503
11521
  }
11504
11522
  }, [parentRef?.current?.offsetHeight, sidebarIsOpen]);
11505
- const sidebarClass = (0, import_classnames49.default)(
11523
+ const sidebarClass = (0, import_classnames50.default)(
11506
11524
  "Layer__panel__sidebar",
11507
11525
  defaultSidebarHeight && "Layer__panel__sidebar--default"
11508
11526
  );
11509
11527
  return /* @__PURE__ */ import_react125.default.createElement(
11510
11528
  "div",
11511
11529
  {
11512
- className: (0, import_classnames49.default)(
11530
+ className: (0, import_classnames50.default)(
11513
11531
  "Layer__panel",
11514
11532
  className,
11515
11533
  sidebarIsOpen && "Layer__panel--open"
@@ -11530,7 +11548,7 @@ var Panel = ({
11530
11548
  };
11531
11549
 
11532
11550
  // src/components/View/View.tsx
11533
- var import_classnames50 = __toESM(require("classnames"));
11551
+ var import_classnames51 = __toESM(require("classnames"));
11534
11552
  var View = ({
11535
11553
  title,
11536
11554
  children,
@@ -11542,7 +11560,7 @@ var View = ({
11542
11560
  }) => {
11543
11561
  const { theme } = useLayerContext();
11544
11562
  const styles = parseStylesFromThemeConfig(theme);
11545
- const viewClassNames = (0, import_classnames50.default)(
11563
+ const viewClassNames = (0, import_classnames51.default)(
11546
11564
  "Layer__view",
11547
11565
  type === "panel" && "Layer__view--panel",
11548
11566
  viewClassName
@@ -12532,7 +12550,7 @@ var Edit2 = ({ size = 18, ...props }) => /* @__PURE__ */ React142.createElement(
12532
12550
  var Edit2_default = Edit2;
12533
12551
 
12534
12552
  // src/components/ChartOfAccountsRow/ChartOfAccountsRow.tsx
12535
- var import_classnames51 = __toESM(require("classnames"));
12553
+ var import_classnames52 = __toESM(require("classnames"));
12536
12554
  var INDENTATION = 24;
12537
12555
  var EXPANDED_STYLE2 = {
12538
12556
  height: 52,
@@ -12587,7 +12605,7 @@ var ChartOfAccountsRow = ({
12587
12605
  setIsOpen(expandAll === "collapsed" ? false : true);
12588
12606
  }
12589
12607
  }, [expandAll]);
12590
- const baseClass = (0, import_classnames51.default)(
12608
+ const baseClass = (0, import_classnames52.default)(
12591
12609
  "Layer__table-row",
12592
12610
  isOpen ? "Layer__table-row--expanded" : "Layer__table-row--collapsed",
12593
12611
  !expanded && "Layer__table-row--hidden",
@@ -12595,11 +12613,11 @@ var ChartOfAccountsRow = ({
12595
12613
  form?.accountId === account.id && "Layer__table-row--active",
12596
12614
  !showComponent && "Layer__table-row--anim-starting-state"
12597
12615
  );
12598
- const desktopRowClass = (0, import_classnames51.default)(
12616
+ const desktopRowClass = (0, import_classnames52.default)(
12599
12617
  baseClass,
12600
12618
  "Layer__chart-of-accounts__row---desktop"
12601
12619
  );
12602
- const mobileRowClass = (0, import_classnames51.default)(
12620
+ const mobileRowClass = (0, import_classnames52.default)(
12603
12621
  baseClass,
12604
12622
  "Layer__chart-of-accounts__row---mobile"
12605
12623
  );
@@ -13039,9 +13057,9 @@ var import_react146 = __toESM(require("react"));
13039
13057
 
13040
13058
  // src/components/Card/Card.tsx
13041
13059
  var import_react142 = __toESM(require("react"));
13042
- var import_classnames52 = __toESM(require("classnames"));
13060
+ var import_classnames53 = __toESM(require("classnames"));
13043
13061
  var Card = ({ children, className }) => {
13044
- return /* @__PURE__ */ import_react142.default.createElement("div", { className: (0, import_classnames52.default)("Layer__card", className) }, children);
13062
+ return /* @__PURE__ */ import_react142.default.createElement("div", { className: (0, import_classnames53.default)("Layer__card", className) }, children);
13045
13063
  };
13046
13064
 
13047
13065
  // src/components/DateTime/DateTime.tsx
@@ -13083,14 +13101,14 @@ var DateTime = ({
13083
13101
 
13084
13102
  // src/components/DetailsList/DetailsList.tsx
13085
13103
  var import_react144 = __toESM(require("react"));
13086
- var import_classnames53 = __toESM(require("classnames"));
13104
+ var import_classnames54 = __toESM(require("classnames"));
13087
13105
  var DetailsList = ({
13088
13106
  title,
13089
13107
  children,
13090
13108
  className,
13091
13109
  actions
13092
13110
  }) => {
13093
- return /* @__PURE__ */ import_react144.default.createElement("div", { className: (0, import_classnames53.default)("Layer__details-list", className) }, title && /* @__PURE__ */ import_react144.default.createElement(Header, null, /* @__PURE__ */ import_react144.default.createElement(Heading, { size: "secondary" /* secondary */ }, title), actions && /* @__PURE__ */ import_react144.default.createElement("div", { className: "Layer__details-list__actions" }, actions)), /* @__PURE__ */ import_react144.default.createElement("ul", { className: "Layer__details-list__list" }, children));
13111
+ return /* @__PURE__ */ import_react144.default.createElement("div", { className: (0, import_classnames54.default)("Layer__details-list", className) }, title && /* @__PURE__ */ import_react144.default.createElement(Header, null, /* @__PURE__ */ import_react144.default.createElement(Heading, { size: "secondary" /* secondary */ }, title), actions && /* @__PURE__ */ import_react144.default.createElement("div", { className: "Layer__details-list__actions" }, actions)), /* @__PURE__ */ import_react144.default.createElement("ul", { className: "Layer__details-list__list" }, children));
13094
13112
  };
13095
13113
 
13096
13114
  // src/components/DetailsList/DetailsListItem.tsx
@@ -13223,7 +13241,7 @@ var LedgerAccountEntryDetails = ({ stringOverrides }) => {
13223
13241
 
13224
13242
  // src/components/LedgerAccount/LedgerAccountRow.tsx
13225
13243
  var import_react147 = __toESM(require("react"));
13226
- var import_classnames54 = __toESM(require("classnames"));
13244
+ var import_classnames55 = __toESM(require("classnames"));
13227
13245
  var import_date_fns31 = require("date-fns");
13228
13246
  var LedgerAccountRow = ({
13229
13247
  row,
@@ -13247,7 +13265,7 @@ var LedgerAccountRow = ({
13247
13265
  return /* @__PURE__ */ import_react147.default.createElement(
13248
13266
  "tr",
13249
13267
  {
13250
- className: (0, import_classnames54.default)(
13268
+ className: (0, import_classnames55.default)(
13251
13269
  "Layer__table-row",
13252
13270
  row.entry_id === selectedEntryId && "Layer__table-row--active",
13253
13271
  initialLoad && "initial-load",
@@ -13280,7 +13298,7 @@ var LedgerAccountRow = ({
13280
13298
  return /* @__PURE__ */ import_react147.default.createElement(
13281
13299
  "tr",
13282
13300
  {
13283
- className: (0, import_classnames54.default)(
13301
+ className: (0, import_classnames55.default)(
13284
13302
  "Layer__table-row",
13285
13303
  row.entry_id === selectedEntryId && "Layer__table-row--active",
13286
13304
  initialLoad && "initial-load",
@@ -13309,7 +13327,7 @@ var LedgerAccountRow = ({
13309
13327
  return /* @__PURE__ */ import_react147.default.createElement(
13310
13328
  "tr",
13311
13329
  {
13312
- className: (0, import_classnames54.default)(
13330
+ className: (0, import_classnames55.default)(
13313
13331
  "Layer__table-row",
13314
13332
  row.entry_id === selectedEntryId && "Layer__table-row--active",
13315
13333
  initialLoad && "initial-load",
@@ -13335,7 +13353,7 @@ var LedgerAccountRow = ({
13335
13353
  };
13336
13354
 
13337
13355
  // src/components/LedgerAccount/LedgerAccountIndex.tsx
13338
- var import_classnames55 = __toESM(require("classnames"));
13356
+ var import_classnames56 = __toESM(require("classnames"));
13339
13357
  var LedgerAccount = ({
13340
13358
  containerRef,
13341
13359
  pageSize = 15,
@@ -13364,7 +13382,7 @@ var LedgerAccount = ({
13364
13382
  return () => clearTimeout(timeoutLoad);
13365
13383
  }
13366
13384
  }, [isLoading]);
13367
- const baseClassName = (0, import_classnames55.default)(
13385
+ const baseClassName = (0, import_classnames56.default)(
13368
13386
  "Layer__ledger-account__index",
13369
13387
  accountId && "open"
13370
13388
  );
@@ -13834,7 +13852,7 @@ var import_react157 = __toESM(require("react"));
13834
13852
 
13835
13853
  // src/components/JournalRow/JournalRow.tsx
13836
13854
  var import_react152 = __toESM(require("react"));
13837
- var import_classnames56 = __toESM(require("classnames"));
13855
+ var import_classnames57 = __toESM(require("classnames"));
13838
13856
  var import_date_fns32 = require("date-fns");
13839
13857
  var INDENTATION2 = 24;
13840
13858
  var EXPANDED_STYLE3 = {
@@ -13881,7 +13899,7 @@ var JournalRow = ({
13881
13899
  transitionDelay: `${lineItemsLength - 15 * index}ms`
13882
13900
  };
13883
13901
  const [showComponent, setShowComponent] = (0, import_react152.useState)(false);
13884
- const baseClass = (0, import_classnames56.default)(
13902
+ const baseClass = (0, import_classnames57.default)(
13885
13903
  "Layer__journal-table-row",
13886
13904
  rowId(row) === selectedEntryId && "Layer__table-row--active",
13887
13905
  initialLoad && "initial-load",
@@ -13889,7 +13907,7 @@ var JournalRow = ({
13889
13907
  showComponent ? "show" : "Layer__table-row--anim-starting-state",
13890
13908
  isOpen && "Layer__journal__table-row--expanded"
13891
13909
  );
13892
- const journalEntryLineClass = (0, import_classnames56.default)(
13910
+ const journalEntryLineClass = (0, import_classnames57.default)(
13893
13911
  "Layer__journal-entry-table-row",
13894
13912
  selectedEntries && "Layer__table-row--active",
13895
13913
  initialLoad && "initial-load",
@@ -14727,7 +14745,7 @@ var SmileIcon_default = SmileIcon;
14727
14745
 
14728
14746
  // src/components/TasksListItem/TasksListItem.tsx
14729
14747
  var import_react162 = __toESM(require("react"));
14730
- var import_classnames57 = __toESM(require("classnames"));
14748
+ var import_classnames58 = __toESM(require("classnames"));
14731
14749
  var TasksListItem = ({
14732
14750
  task,
14733
14751
  goToNextPageIfAllComplete,
@@ -14736,16 +14754,16 @@ var TasksListItem = ({
14736
14754
  const [isOpen, setIsOpen] = (0, import_react162.useState)(defaultOpen);
14737
14755
  const [userResponse, setUserResponse] = (0, import_react162.useState)(task.user_response || "");
14738
14756
  const { submitResponseToTask: submitResponseToTask2 } = (0, import_react162.useContext)(TasksContext);
14739
- const taskBodyClassName = (0, import_classnames57.default)(
14757
+ const taskBodyClassName = (0, import_classnames58.default)(
14740
14758
  "Layer__tasks-list-item__body",
14741
14759
  isOpen && "Layer__tasks-list-item__body--expanded",
14742
14760
  isComplete(task.status) && "Layer__tasks-list-item--completed"
14743
14761
  );
14744
- const taskHeadClassName = (0, import_classnames57.default)(
14762
+ const taskHeadClassName = (0, import_classnames58.default)(
14745
14763
  "Layer__tasks-list-item__head-info",
14746
14764
  isComplete(task.status) ? "Layer__tasks-list-item--completed" : "Layer__tasks-list-item--pending"
14747
14765
  );
14748
- const taskItemClassName = (0, import_classnames57.default)(
14766
+ const taskItemClassName = (0, import_classnames58.default)(
14749
14767
  "Layer__tasks-list-item",
14750
14768
  isOpen && "Layer__tasks-list-item__expanded"
14751
14769
  );
@@ -14844,7 +14862,7 @@ var TasksList = ({ pageSize = 10 }) => {
14844
14862
 
14845
14863
  // src/components/TasksPending/TasksPending.tsx
14846
14864
  var import_react164 = __toESM(require("react"));
14847
- var import_classnames58 = __toESM(require("classnames"));
14865
+ var import_classnames59 = __toESM(require("classnames"));
14848
14866
  var import_date_fns33 = require("date-fns");
14849
14867
  var import_recharts4 = require("recharts");
14850
14868
  var TasksPending = () => {
@@ -14860,7 +14878,7 @@ var TasksPending = () => {
14860
14878
  value: data?.filter((task) => !isComplete(task.status)).length
14861
14879
  }
14862
14880
  ];
14863
- const taskStatusClassName = (0, import_classnames58.default)(
14881
+ const taskStatusClassName = (0, import_classnames59.default)(
14864
14882
  completedTasks && completedTasks > 0 ? "Layer__tasks-pending-bar__status--done" : "Layer__tasks-pending-bar__status--pending"
14865
14883
  );
14866
14884
  return /* @__PURE__ */ import_react164.default.createElement("div", { className: "Layer__tasks-pending" }, /* @__PURE__ */ import_react164.default.createElement(Text, { size: "lg" /* lg */ }, (0, import_date_fns33.format)(Date.now(), "MMMM")), /* @__PURE__ */ import_react164.default.createElement("div", { className: "Layer__tasks-pending-bar" }, /* @__PURE__ */ import_react164.default.createElement(Text, { size: "sm" /* sm */ }, /* @__PURE__ */ import_react164.default.createElement("span", { className: taskStatusClassName }, completedTasks), "/", data?.length, " done"), /* @__PURE__ */ import_react164.default.createElement(import_recharts4.PieChart, { width: 24, height: 24, className: "mini-chart" }, /* @__PURE__ */ import_react164.default.createElement(
@@ -14894,7 +14912,7 @@ var TasksPending = () => {
14894
14912
  };
14895
14913
 
14896
14914
  // src/components/Tasks/Tasks.tsx
14897
- var import_classnames59 = __toESM(require("classnames"));
14915
+ var import_classnames60 = __toESM(require("classnames"));
14898
14916
  var UseTasksContext = (0, import_react165.createContext)({
14899
14917
  data: void 0,
14900
14918
  isLoading: void 0,
@@ -14966,7 +14984,7 @@ var TasksComponent = ({
14966
14984
  ), /* @__PURE__ */ import_react165.default.createElement(
14967
14985
  "div",
14968
14986
  {
14969
- className: (0, import_classnames59.default)(
14987
+ className: (0, import_classnames60.default)(
14970
14988
  "Layer__tasks__content",
14971
14989
  !open && "Layer__tasks__content--collapsed"
14972
14990
  )
@@ -15066,7 +15084,7 @@ var BookkeepingUpsellBar = ({
15066
15084
 
15067
15085
  // src/views/BookkeepingOverview/BookkeepingOverview.tsx
15068
15086
  var import_react168 = __toESM(require("react"));
15069
- var import_classnames60 = __toESM(require("classnames"));
15087
+ var import_classnames61 = __toESM(require("classnames"));
15070
15088
  var BookkeepingOverview = ({
15071
15089
  title,
15072
15090
  // deprecated
@@ -15126,7 +15144,7 @@ var BookkeepingOverview = ({
15126
15144
  ), /* @__PURE__ */ import_react168.default.createElement(
15127
15145
  Container,
15128
15146
  {
15129
- name: (0, import_classnames60.default)(
15147
+ name: (0, import_classnames61.default)(
15130
15148
  "bookkeeping-overview-profit-and-loss-chart",
15131
15149
  pnlToggle !== "revenue" && "bookkeeping-overview-profit-and-loss-chart--hidden"
15132
15150
  )
@@ -15142,7 +15160,7 @@ var BookkeepingOverview = ({
15142
15160
  ), /* @__PURE__ */ import_react168.default.createElement(
15143
15161
  Container,
15144
15162
  {
15145
- name: (0, import_classnames60.default)(
15163
+ name: (0, import_classnames61.default)(
15146
15164
  "bookkeeping-overview-profit-and-loss-chart",
15147
15165
  pnlToggle !== "expenses" && "bookkeeping-overview-profit-and-loss-chart--hidden"
15148
15166
  )
@@ -15173,13 +15191,13 @@ var BadgeLoader = ({ children }) => {
15173
15191
 
15174
15192
  // src/components/NotificationCard/NotificationCard.tsx
15175
15193
  var import_react170 = __toESM(require("react"));
15176
- var import_classnames61 = __toESM(require("classnames"));
15194
+ var import_classnames62 = __toESM(require("classnames"));
15177
15195
  var NotificationCard = ({
15178
15196
  onClick,
15179
15197
  children,
15180
15198
  className
15181
15199
  }) => {
15182
- return /* @__PURE__ */ import_react170.default.createElement("div", { className: (0, import_classnames61.default)("Layer__notification-card", className) }, /* @__PURE__ */ import_react170.default.createElement("div", { className: "Layer__notification-card__main" }, children), /* @__PURE__ */ import_react170.default.createElement(
15200
+ return /* @__PURE__ */ import_react170.default.createElement("div", { className: (0, import_classnames62.default)("Layer__notification-card", className) }, /* @__PURE__ */ import_react170.default.createElement("div", { className: "Layer__notification-card__main" }, children), /* @__PURE__ */ import_react170.default.createElement(
15183
15201
  IconButton,
15184
15202
  {
15185
15203
  icon: /* @__PURE__ */ import_react170.default.createElement(ChevronRight_default, null),
@@ -15258,7 +15276,7 @@ var TransactionToReviewCard = ({
15258
15276
  };
15259
15277
 
15260
15278
  // src/views/AccountingOverview/AccountingOverview.tsx
15261
- var import_classnames62 = __toESM(require("classnames"));
15279
+ var import_classnames63 = __toESM(require("classnames"));
15262
15280
  var AccountingOverview = ({
15263
15281
  title = "Accounting overview",
15264
15282
  enableOnboarding = false,
@@ -15313,7 +15331,7 @@ var AccountingOverview = ({
15313
15331
  ), /* @__PURE__ */ import_react172.default.createElement(
15314
15332
  Container,
15315
15333
  {
15316
- name: (0, import_classnames62.default)(
15334
+ name: (0, import_classnames63.default)(
15317
15335
  "accounting-overview-profit-and-loss-chart",
15318
15336
  pnlToggle !== "revenue" && "accounting-overview-profit-and-loss-chart--hidden"
15319
15337
  )
@@ -15330,7 +15348,7 @@ var AccountingOverview = ({
15330
15348
  ), /* @__PURE__ */ import_react172.default.createElement(
15331
15349
  Container,
15332
15350
  {
15333
- name: (0, import_classnames62.default)(
15351
+ name: (0, import_classnames63.default)(
15334
15352
  "accounting-overview-profit-and-loss-chart",
15335
15353
  pnlToggle !== "expenses" && "accounting-overview-profit-and-loss-chart--hidden"
15336
15354
  )