@layerfi/components 0.1.114-alpha.5 → 0.1.114

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.
@@ -202,7 +202,7 @@ class ErrorHandlerClass {
202
202
  }
203
203
  const errorHandler = new ErrorHandlerClass();
204
204
  const reportError = (payload) => errorHandler.onError(payload);
205
- const version = "0.1.114-alpha.5";
205
+ const version = "0.1.114";
206
206
  const pkg = {
207
207
  version
208
208
  };
@@ -8974,7 +8974,7 @@ function buildCustomDropdownIndicator() {
8974
8974
  Select$1.components.DropdownIndicator,
8975
8975
  __spreadProps(__spreadValues({}, restProps), {
8976
8976
  className: COMBO_BOX_CLASS_NAMES.DROPDOWN_INDICATOR,
8977
- children: !isDisabled && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { size: 16 })
8977
+ children: !isDisabled ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { size: 16 }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {})
8978
8978
  })
8979
8979
  );
8980
8980
  };
@@ -10423,7 +10423,7 @@ const BankTransactionsCategorizeAllModal = ({
10423
10423
  const { selectedIds } = useSelectedIds();
10424
10424
  const { clearSelection } = useBulkSelectionActions();
10425
10425
  const [selectedCategory, setSelectedCategory] = react.useState(null);
10426
- const { trigger } = useBulkCategorize();
10426
+ const { trigger, isMutating } = useBulkCategorize();
10427
10427
  const handleCategorizeModalClose = react.useCallback((isOpen2) => {
10428
10428
  onOpenChange(isOpen2);
10429
10429
  if (!isOpen2) {
@@ -10459,7 +10459,7 @@ const BankTransactionsCategorizeAllModal = ({
10459
10459
  title: mode === "Categorize" ? "Categorize all selected transactions?" : "Recategorize all selected transactions?",
10460
10460
  content: /* @__PURE__ */ jsxRuntime.jsxs(VStack, { gap: "xs", children: [
10461
10461
  /* @__PURE__ */ jsxRuntime.jsxs(VStack, { gap: "3xs", children: [
10462
- /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: categorySelectId, children: "Select category" }),
10462
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { size: "sm", htmlFor: categorySelectId, children: "Select category" }),
10463
10463
  useCategorySelectDrawer ? /* @__PURE__ */ jsxRuntime.jsx(
10464
10464
  CategorySelectDrawerWithTrigger,
10465
10465
  {
@@ -10474,7 +10474,8 @@ const BankTransactionsCategorizeAllModal = ({
10474
10474
  inputId: categorySelectId,
10475
10475
  selectedValue: selectedCategory,
10476
10476
  onSelectedValueChange: setSelectedCategory,
10477
- includeSuggestedMatches: false
10477
+ includeSuggestedMatches: false,
10478
+ isDisabled: isMutating
10478
10479
  }
10479
10480
  )
10480
10481
  ] }),
@@ -13344,6 +13345,37 @@ const MonthPicker = ({
13344
13345
  ) }) })
13345
13346
  ] });
13346
13347
  };
13348
+ const NewToggleOption = ({
13349
+ label,
13350
+ value
13351
+ }) => {
13352
+ return /* @__PURE__ */ jsxRuntime.jsxs(reactAriaComponents.ToggleButton, { id: value, className: "Layer__NewToggleOption", children: [
13353
+ /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.SelectionIndicator, { className: "Layer__NewToggleOption-SelectionIndicator" }),
13354
+ /* @__PURE__ */ jsxRuntime.jsx(Span, { className: "Layer__NewToggle-Option-Content", children: /* @__PURE__ */ jsxRuntime.jsx(Span, { noWrap: true, children: label }) })
13355
+ ] });
13356
+ };
13357
+ const NewToggle = ({
13358
+ options: options2,
13359
+ selectedKey,
13360
+ onSelectionChange
13361
+ }) => {
13362
+ const selectedKeys = selectedKey !== void 0 ? /* @__PURE__ */ new Set([selectedKey]) : /* @__PURE__ */ new Set();
13363
+ return /* @__PURE__ */ jsxRuntime.jsx(
13364
+ reactAriaComponents.ToggleButtonGroup,
13365
+ {
13366
+ className: "Layer__NewToggle",
13367
+ selectionMode: "single",
13368
+ selectedKeys,
13369
+ onSelectionChange: (keys2) => {
13370
+ const selectedKeysArray = Array.from(keys2);
13371
+ if (selectedKeysArray.length > 0 && onSelectionChange) {
13372
+ onSelectionChange(selectedKeysArray[0]);
13373
+ }
13374
+ },
13375
+ children: options2.map((option) => /* @__PURE__ */ jsxRuntime.jsx(NewToggleOption, __spreadValues({}, option), option.value))
13376
+ }
13377
+ );
13378
+ };
13347
13379
  const SmallLoader = ({ size = 28 }) => {
13348
13380
  return /* @__PURE__ */ jsxRuntime.jsx(
13349
13381
  "span",
@@ -13388,169 +13420,6 @@ const SyncingComponent = ({
13388
13420
  }
13389
13421
  );
13390
13422
  };
13391
- var ToggleSize = /* @__PURE__ */ ((ToggleSize2) => {
13392
- ToggleSize2["medium"] = "medium";
13393
- ToggleSize2["small"] = "small";
13394
- ToggleSize2["xsmall"] = "xsmall";
13395
- return ToggleSize2;
13396
- })(ToggleSize || {});
13397
- const Toggle = ({
13398
- name,
13399
- options: options2,
13400
- selected,
13401
- onChange,
13402
- size = "medium"
13403
- /* medium */
13404
- }) => {
13405
- const [currentWidth, setCurrentWidth] = react.useState(0);
13406
- const [thumbPos, setThumbPos] = react.useState({ left: 0, width: 0 });
13407
- const [initialized, setInitialized] = react.useState(false);
13408
- const activeOption = react.useMemo(() => {
13409
- return selected ? selected : options2.length > 0 ? options2[0].value : void 0;
13410
- }, [selected, options2]);
13411
- const toggleRef = useElementSize((_a, _b, c) => {
13412
- if (c.width && (c == null ? void 0 : c.width) !== currentWidth) {
13413
- setCurrentWidth(c.width);
13414
- }
13415
- });
13416
- const baseClassName2 = classNames(
13417
- "Layer__toggle",
13418
- `Layer__toggle--${size}`,
13419
- initialized ? "Layer__toggle--initialized" : ""
13420
- );
13421
- const handleChange = (e) => {
13422
- var _a;
13423
- updateThumbPosition(Number((_a = e.target.getAttribute("data-idx")) != null ? _a : 0));
13424
- onChange(e);
13425
- };
13426
- const updateThumbPosition = (active) => {
13427
- if (!(toggleRef == null ? void 0 : toggleRef.current)) {
13428
- return;
13429
- }
13430
- const optionsNodes = [...toggleRef.current.children].map((x) => {
13431
- if (x.className.includes("Layer__tooltip-trigger") && x.children && x.children.length > 0) {
13432
- return x.children[0];
13433
- }
13434
- return x;
13435
- }).filter((c) => c.className.includes("Layer__toggle-option"));
13436
- let shift = 0;
13437
- let width = thumbPos.width;
13438
- optionsNodes.forEach((c, i) => {
13439
- if (i < active) {
13440
- shift = shift + c.offsetWidth;
13441
- } else if (i === active) {
13442
- width = c.offsetWidth;
13443
- }
13444
- });
13445
- shift = shift + (size === "medium" ? 2 : 1.5);
13446
- setThumbPos({ left: shift, width });
13447
- };
13448
- react.useEffect(() => {
13449
- const selectedIndex = getSelectedIndex();
13450
- updateThumbPosition(selectedIndex);
13451
- setTimeout(() => {
13452
- setInitialized(true);
13453
- }, 400);
13454
- }, []);
13455
- react.useEffect(() => {
13456
- const selectedIndex = getSelectedIndex();
13457
- updateThumbPosition(selectedIndex);
13458
- }, [currentWidth]);
13459
- const getSelectedIndex = () => {
13460
- const selectedIndex = options2.findIndex(
13461
- (option) => option.value === activeOption
13462
- );
13463
- if (selectedIndex === -1) {
13464
- return 0;
13465
- }
13466
- return selectedIndex;
13467
- };
13468
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: baseClassName2, ref: toggleRef, children: [
13469
- options2.map((option, index2) => {
13470
- var _a;
13471
- return /* @__PURE__ */ react.createElement(
13472
- ToggleOption,
13473
- __spreadProps(__spreadValues({}, option), {
13474
- size,
13475
- key: option.value,
13476
- name,
13477
- checked: activeOption === option.value,
13478
- onChange: handleChange,
13479
- disabled: (_a = option.disabled) != null ? _a : false,
13480
- disabledMessage: option.disabledMessage,
13481
- index: index2
13482
- })
13483
- );
13484
- }),
13485
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "Layer__toggle__thumb", style: __spreadValues({}, thumbPos) })
13486
- ] });
13487
- };
13488
- const ToggleOption = ({
13489
- checked,
13490
- label,
13491
- name,
13492
- onChange,
13493
- value,
13494
- size: _size,
13495
- leftIcon,
13496
- disabled,
13497
- disabledMessage = "Disabled",
13498
- style,
13499
- index: index2
13500
- }) => {
13501
- const optionClassName = classNames("Layer__toggle-option", {
13502
- "Layer__toggle-option--active": checked
13503
- });
13504
- if (disabled) {
13505
- return /* @__PURE__ */ jsxRuntime.jsxs(DeprecatedTooltip, { children: [
13506
- /* @__PURE__ */ jsxRuntime.jsx(DeprecatedTooltipTrigger, { children: /* @__PURE__ */ jsxRuntime.jsxs(
13507
- "label",
13508
- {
13509
- className: optionClassName,
13510
- "data-checked": checked,
13511
- style,
13512
- children: [
13513
- /* @__PURE__ */ jsxRuntime.jsx(
13514
- "input",
13515
- {
13516
- type: "radio",
13517
- checked,
13518
- name,
13519
- onChange,
13520
- value,
13521
- disabled,
13522
- "data-idx": index2
13523
- }
13524
- ),
13525
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "Layer__toggle-option-content", children: [
13526
- leftIcon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "Layer__toggle-option__icon", children: leftIcon }),
13527
- /* @__PURE__ */ jsxRuntime.jsx(Span, { noWrap: true, children: label })
13528
- ] })
13529
- ]
13530
- }
13531
- ) }),
13532
- /* @__PURE__ */ jsxRuntime.jsx(DeprecatedTooltipContent, { className: "Layer__tooltip", children: disabledMessage })
13533
- ] });
13534
- }
13535
- return /* @__PURE__ */ jsxRuntime.jsxs("label", { className: optionClassName, "data-checked": checked, style, children: [
13536
- /* @__PURE__ */ jsxRuntime.jsx(
13537
- "input",
13538
- {
13539
- type: "radio",
13540
- checked,
13541
- name,
13542
- onChange,
13543
- value,
13544
- disabled,
13545
- "data-idx": index2
13546
- }
13547
- ),
13548
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "Layer__toggle-option-content", children: [
13549
- leftIcon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "Layer__toggle-option__icon", children: leftIcon }),
13550
- /* @__PURE__ */ jsxRuntime.jsx(Span, { noWrap: true, children: label })
13551
- ] })
13552
- ] });
13553
- };
13554
13423
  var HeadingSize = /* @__PURE__ */ ((HeadingSize2) => {
13555
13424
  HeadingSize2["primary"] = "primary";
13556
13425
  HeadingSize2["secondary"] = "secondary";
@@ -13737,9 +13606,9 @@ const BankTransactionsHeader = ({
13737
13606
  stringOverrides == null ? void 0 : stringOverrides.header,
13738
13607
  withDatePicker
13739
13608
  ]);
13740
- const onCategorizationDisplayChange = (event) => {
13609
+ const onCategorizationDisplayChange = (value) => {
13741
13610
  setFilters({
13742
- categorizationStatus: event.target.value === "categorized" ? DisplayState.categorized : event.target.value === "all" ? DisplayState.all : DisplayState.review
13611
+ categorizationStatus: value === "categorized" ? DisplayState.categorized : value === "all" ? DisplayState.all : DisplayState.review
13743
13612
  });
13744
13613
  };
13745
13614
  const headerMenuActions = react.useMemo(() => {
@@ -13775,16 +13644,14 @@ const BankTransactionsHeader = ({
13775
13644
  ) : /* @__PURE__ */ jsxRuntime.jsxs(HStack, { slot: "toggle", justify: "center", gap: "xs", children: [
13776
13645
  collapseHeader && headerTopRow,
13777
13646
  !categorizedOnly && categorizeView && showStatusToggle && /* @__PURE__ */ jsxRuntime.jsx(
13778
- Toggle,
13647
+ NewToggle,
13779
13648
  {
13780
- name: "bank-transaction-display",
13781
- size: mobileComponent === "mobileList" ? ToggleSize.small : ToggleSize.medium,
13782
13649
  options: [
13783
13650
  { label: "To Review", value: DisplayState.review },
13784
13651
  { label: "Categorized", value: DisplayState.categorized }
13785
13652
  ],
13786
- selected: display,
13787
- onChange: onCategorizationDisplayChange
13653
+ selectedKey: display,
13654
+ onSelectionChange: onCategorizationDisplayChange
13788
13655
  }
13789
13656
  )
13790
13657
  ] }),
@@ -16098,6 +15965,169 @@ const MatchForm = ({
16098
15965
  matchFormError && /* @__PURE__ */ jsxRuntime.jsx(ErrorText, { children: matchFormError })
16099
15966
  ] });
16100
15967
  };
15968
+ var ToggleSize = /* @__PURE__ */ ((ToggleSize2) => {
15969
+ ToggleSize2["medium"] = "medium";
15970
+ ToggleSize2["small"] = "small";
15971
+ ToggleSize2["xsmall"] = "xsmall";
15972
+ return ToggleSize2;
15973
+ })(ToggleSize || {});
15974
+ const Toggle = ({
15975
+ name,
15976
+ options: options2,
15977
+ selected,
15978
+ onChange,
15979
+ size = "medium"
15980
+ /* medium */
15981
+ }) => {
15982
+ const [currentWidth, setCurrentWidth] = react.useState(0);
15983
+ const [thumbPos, setThumbPos] = react.useState({ left: 0, width: 0 });
15984
+ const [initialized, setInitialized] = react.useState(false);
15985
+ const activeOption = react.useMemo(() => {
15986
+ return selected ? selected : options2.length > 0 ? options2[0].value : void 0;
15987
+ }, [selected, options2]);
15988
+ const toggleRef = useElementSize((_a, _b, c) => {
15989
+ if (c.width && (c == null ? void 0 : c.width) !== currentWidth) {
15990
+ setCurrentWidth(c.width);
15991
+ }
15992
+ });
15993
+ const baseClassName2 = classNames(
15994
+ "Layer__toggle",
15995
+ `Layer__toggle--${size}`,
15996
+ initialized ? "Layer__toggle--initialized" : ""
15997
+ );
15998
+ const handleChange = (e) => {
15999
+ var _a;
16000
+ updateThumbPosition(Number((_a = e.target.getAttribute("data-idx")) != null ? _a : 0));
16001
+ onChange(e);
16002
+ };
16003
+ const updateThumbPosition = (active) => {
16004
+ if (!(toggleRef == null ? void 0 : toggleRef.current)) {
16005
+ return;
16006
+ }
16007
+ const optionsNodes = [...toggleRef.current.children].map((x) => {
16008
+ if (x.className.includes("Layer__tooltip-trigger") && x.children && x.children.length > 0) {
16009
+ return x.children[0];
16010
+ }
16011
+ return x;
16012
+ }).filter((c) => c.className.includes("Layer__toggle-option"));
16013
+ let shift = 0;
16014
+ let width = thumbPos.width;
16015
+ optionsNodes.forEach((c, i) => {
16016
+ if (i < active) {
16017
+ shift = shift + c.offsetWidth;
16018
+ } else if (i === active) {
16019
+ width = c.offsetWidth;
16020
+ }
16021
+ });
16022
+ shift = shift + (size === "medium" ? 2 : 1.5);
16023
+ setThumbPos({ left: shift, width });
16024
+ };
16025
+ react.useEffect(() => {
16026
+ const selectedIndex = getSelectedIndex();
16027
+ updateThumbPosition(selectedIndex);
16028
+ setTimeout(() => {
16029
+ setInitialized(true);
16030
+ }, 400);
16031
+ }, []);
16032
+ react.useEffect(() => {
16033
+ const selectedIndex = getSelectedIndex();
16034
+ updateThumbPosition(selectedIndex);
16035
+ }, [currentWidth]);
16036
+ const getSelectedIndex = () => {
16037
+ const selectedIndex = options2.findIndex(
16038
+ (option) => option.value === activeOption
16039
+ );
16040
+ if (selectedIndex === -1) {
16041
+ return 0;
16042
+ }
16043
+ return selectedIndex;
16044
+ };
16045
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: baseClassName2, ref: toggleRef, children: [
16046
+ options2.map((option, index2) => {
16047
+ var _a;
16048
+ return /* @__PURE__ */ react.createElement(
16049
+ ToggleOption,
16050
+ __spreadProps(__spreadValues({}, option), {
16051
+ size,
16052
+ key: option.value,
16053
+ name,
16054
+ checked: activeOption === option.value,
16055
+ onChange: handleChange,
16056
+ disabled: (_a = option.disabled) != null ? _a : false,
16057
+ disabledMessage: option.disabledMessage,
16058
+ index: index2
16059
+ })
16060
+ );
16061
+ }),
16062
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "Layer__toggle__thumb", style: __spreadValues({}, thumbPos) })
16063
+ ] });
16064
+ };
16065
+ const ToggleOption = ({
16066
+ checked,
16067
+ label,
16068
+ name,
16069
+ onChange,
16070
+ value,
16071
+ size: _size,
16072
+ leftIcon,
16073
+ disabled,
16074
+ disabledMessage = "Disabled",
16075
+ style,
16076
+ index: index2
16077
+ }) => {
16078
+ const optionClassName = classNames("Layer__toggle-option", {
16079
+ "Layer__toggle-option--active": checked
16080
+ });
16081
+ if (disabled) {
16082
+ return /* @__PURE__ */ jsxRuntime.jsxs(DeprecatedTooltip, { children: [
16083
+ /* @__PURE__ */ jsxRuntime.jsx(DeprecatedTooltipTrigger, { children: /* @__PURE__ */ jsxRuntime.jsxs(
16084
+ "label",
16085
+ {
16086
+ className: optionClassName,
16087
+ "data-checked": checked,
16088
+ style,
16089
+ children: [
16090
+ /* @__PURE__ */ jsxRuntime.jsx(
16091
+ "input",
16092
+ {
16093
+ type: "radio",
16094
+ checked,
16095
+ name,
16096
+ onChange,
16097
+ value,
16098
+ disabled,
16099
+ "data-idx": index2
16100
+ }
16101
+ ),
16102
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "Layer__toggle-option-content", children: [
16103
+ leftIcon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "Layer__toggle-option__icon", children: leftIcon }),
16104
+ /* @__PURE__ */ jsxRuntime.jsx(Span, { noWrap: true, children: label })
16105
+ ] })
16106
+ ]
16107
+ }
16108
+ ) }),
16109
+ /* @__PURE__ */ jsxRuntime.jsx(DeprecatedTooltipContent, { className: "Layer__tooltip", children: disabledMessage })
16110
+ ] });
16111
+ }
16112
+ return /* @__PURE__ */ jsxRuntime.jsxs("label", { className: optionClassName, "data-checked": checked, style, children: [
16113
+ /* @__PURE__ */ jsxRuntime.jsx(
16114
+ "input",
16115
+ {
16116
+ type: "radio",
16117
+ checked,
16118
+ name,
16119
+ onChange,
16120
+ value,
16121
+ disabled,
16122
+ "data-idx": index2
16123
+ }
16124
+ ),
16125
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "Layer__toggle-option-content", children: [
16126
+ leftIcon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "Layer__toggle-option__icon", children: leftIcon }),
16127
+ /* @__PURE__ */ jsxRuntime.jsx(Span, { noWrap: true, children: label })
16128
+ ] })
16129
+ ] });
16130
+ };
16101
16131
  const GET_BANK_TRANSACTION_METADATA_TAG_KEY = "#bank-transaction-metadata";
16102
16132
  function buildKey$I({
16103
16133
  access_token: accessToken,
@@ -16131,6 +16161,24 @@ function useBankTransactionMetadata({ bankTransactionId }) {
16131
16161
  );
16132
16162
  }
16133
16163
  const UPDATE_BANK_TRANSACTION_METADATA_TAG_KEY = "#update-bank-transaction-metadata";
16164
+ class UpdateBankTransactionMetadataSWRResponse {
16165
+ constructor(swrResponse) {
16166
+ __publicField(this, "swrResponse");
16167
+ this.swrResponse = swrResponse;
16168
+ }
16169
+ get data() {
16170
+ return this.swrResponse.data;
16171
+ }
16172
+ get trigger() {
16173
+ return this.swrResponse.trigger;
16174
+ }
16175
+ get isMutating() {
16176
+ return this.swrResponse.isMutating;
16177
+ }
16178
+ get isError() {
16179
+ return this.swrResponse.error !== void 0;
16180
+ }
16181
+ }
16134
16182
  function buildKey$H({
16135
16183
  access_token: accessToken,
16136
16184
  apiUrl,
@@ -16151,7 +16199,7 @@ function useUpdateBankTransactionMetadata({ bankTransactionId, onSuccess }) {
16151
16199
  const { data: auth } = useAuth();
16152
16200
  const { businessId } = useLayerContext();
16153
16201
  const { mutate } = useSWR.useSWRConfig();
16154
- const mutationResponse = useSWRMutation(
16202
+ const rawMutationResponse = useSWRMutation(
16155
16203
  () => buildKey$H({
16156
16204
  access_token: auth == null ? void 0 : auth.access_token,
16157
16205
  apiUrl: auth == null ? void 0 : auth.apiUrl,
@@ -16177,6 +16225,7 @@ function useUpdateBankTransactionMetadata({ bankTransactionId, onSuccess }) {
16177
16225
  throwOnError: false
16178
16226
  }
16179
16227
  );
16228
+ const mutationResponse = new UpdateBankTransactionMetadataSWRResponse(rawMutationResponse);
16180
16229
  const { trigger: originalTrigger } = mutationResponse;
16181
16230
  const stableProxiedTrigger = react.useCallback(
16182
16231
  (...triggerParameters) => __async(null, null, function* () {
@@ -16202,21 +16251,37 @@ function useUpdateBankTransactionMetadata({ bankTransactionId, onSuccess }) {
16202
16251
  });
16203
16252
  }
16204
16253
  const useBankTransactionMemo = ({ bankTransactionId }) => {
16205
- const { trigger: updateBankTransactionMetadata2 } = useUpdateBankTransactionMetadata({ bankTransactionId });
16206
- const { data: bankTransactionMetadata } = useBankTransactionMetadata({ bankTransactionId });
16254
+ const {
16255
+ trigger: updateBankTransactionMetadata2,
16256
+ isMutating: isUpdatingMemo,
16257
+ isError: isErrorUpdatingMemo,
16258
+ data: updateResult
16259
+ } = useUpdateBankTransactionMetadata({ bankTransactionId });
16260
+ const { data: bankTransactionMetadata, mutate: mutateBankTransactionMetadata } = useBankTransactionMetadata({ bankTransactionId });
16207
16261
  const form = reactForm.useForm({
16208
16262
  defaultValues: {
16209
16263
  memo: bankTransactionMetadata == null ? void 0 : bankTransactionMetadata.memo
16210
16264
  },
16211
16265
  onSubmit: (_0) => __async(null, [_0], function* ({ value }) {
16212
- var _a;
16266
+ var _a, _b;
16213
16267
  if (value.memo !== void 0 && form.state.isDirty) {
16214
- yield updateBankTransactionMetadata2({ memo: (_a = value.memo) != null ? _a : "" });
16215
- form.reset(value);
16268
+ const result = yield mutateBankTransactionMetadata(
16269
+ updateBankTransactionMetadata2({ memo: (_a = value.memo) != null ? _a : "" }),
16270
+ { optimisticData: { memo: (_b = value.memo) != null ? _b : "" }, revalidate: false }
16271
+ );
16272
+ if (result !== void 0) {
16273
+ form.reset(value);
16274
+ }
16216
16275
  }
16217
16276
  })
16218
16277
  });
16219
- return form;
16278
+ const isSaved = !isUpdatingMemo && !isErrorUpdatingMemo && updateResult !== void 0 && !form.state.isDirty;
16279
+ return react.useMemo(() => ({
16280
+ form,
16281
+ isUpdatingMemo,
16282
+ isErrorUpdatingMemo,
16283
+ isSaved
16284
+ }), [form, isErrorUpdatingMemo, isUpdatingMemo, isSaved]);
16220
16285
  };
16221
16286
  const Textarea = (_Pb) => {
16222
16287
  var _Qb = _Pb, {
@@ -16239,24 +16304,26 @@ const Textarea = (_Pb) => {
16239
16304
  ] });
16240
16305
  };
16241
16306
  const BankTransactionMemo = ({ bankTransactionId }) => {
16242
- const form = useBankTransactionMemo({ bankTransactionId });
16307
+ const { form, isUpdatingMemo, isErrorUpdatingMemo, isSaved } = useBankTransactionMemo({ bankTransactionId });
16243
16308
  return /* @__PURE__ */ jsxRuntime.jsx("form", { onBlur: () => void form.handleSubmit(), children: /* @__PURE__ */ jsxRuntime.jsx(form.Field, { name: "memo", children: (field) => {
16244
16309
  var _a;
16245
- return /* @__PURE__ */ jsxRuntime.jsx(
16246
- InputGroup,
16247
- {
16248
- name: "memo",
16249
- children: /* @__PURE__ */ jsxRuntime.jsx(
16250
- Textarea,
16251
- {
16252
- name: "memo",
16253
- placeholder: "Add description",
16254
- value: (_a = field.state.value) != null ? _a : void 0,
16255
- onChange: (e) => field.handleChange(e.target.value)
16256
- }
16257
- )
16258
- }
16259
- );
16310
+ return /* @__PURE__ */ jsxRuntime.jsxs(VStack, { gap: "3xs", children: [
16311
+ /* @__PURE__ */ jsxRuntime.jsxs(HStack, { justify: "space-between", align: "baseline", children: [
16312
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: "memo", size: "sm", weight: "bold", children: "Description" }),
16313
+ isUpdatingMemo && /* @__PURE__ */ jsxRuntime.jsx(Span, { size: "sm", weight: "bold", variant: "subtle", children: "Saving..." }),
16314
+ !isUpdatingMemo && isSaved && /* @__PURE__ */ jsxRuntime.jsx(Span, { size: "sm", status: "success", children: "Saved" }),
16315
+ !isUpdatingMemo && !isSaved && isErrorUpdatingMemo && /* @__PURE__ */ jsxRuntime.jsx(Span, { size: "sm", weight: "bold", status: "error", children: "Error saving" })
16316
+ ] }),
16317
+ /* @__PURE__ */ jsxRuntime.jsx(
16318
+ Textarea,
16319
+ {
16320
+ name: "memo",
16321
+ placeholder: "Add description",
16322
+ value: (_a = field.state.value) != null ? _a : void 0,
16323
+ onChange: (e) => field.handleChange(e.target.value)
16324
+ }
16325
+ )
16326
+ ] });
16260
16327
  } }) });
16261
16328
  };
16262
16329
  const range$1 = (start, end) => {
@@ -17396,10 +17463,7 @@ function BankTransactionFormFields({
17396
17463
  isReadOnly
17397
17464
  }
17398
17465
  ),
17399
- showDescriptions && /* @__PURE__ */ jsxRuntime.jsxs(VStack, { gap: "sm", children: [
17400
- /* @__PURE__ */ jsxRuntime.jsx(Span, { size: "sm", weight: "bold", children: "Description" }),
17401
- /* @__PURE__ */ jsxRuntime.jsx(BankTransactionMemo, { bankTransactionId: bankTransaction.id })
17402
- ] })
17466
+ showDescriptions && /* @__PURE__ */ jsxRuntime.jsx(VStack, { gap: "sm", children: /* @__PURE__ */ jsxRuntime.jsx(BankTransactionMemo, { bankTransactionId: bankTransaction.id }) })
17403
17467
  ] });
17404
17468
  }
17405
17469
  const ExpandedBankTransactionRow = react.forwardRef(
@@ -17628,8 +17692,7 @@ const ExpandedBankTransactionRow = react.forwardRef(
17628
17692
  onSelectedValueChange: (value) => {
17629
17693
  changeCategoryForSplitAtIndex(index2, value);
17630
17694
  },
17631
- isLoading: bankTransaction.processing,
17632
- isDisabled: !categorizationEnabled,
17695
+ isDisabled: !categorizationEnabled || bankTransaction.processing,
17633
17696
  includeSuggestedMatches: false
17634
17697
  }
17635
17698
  ),
@@ -17808,6 +17871,7 @@ const BankTransactionRow = ({
17808
17871
  const { setTransactionCategory } = useBankTransactionsCategoryActions();
17809
17872
  const { selectedCategory } = useGetBankTransactionCategory(bankTransaction.id);
17810
17873
  const { saveBankTransactionRow } = useSaveBankTransactionRow();
17874
+ const displayAsCategorized = bankTransaction.recently_categorized && shouldHideAfterCategorize() ? false : categorized;
17811
17875
  react.useEffect(() => {
17812
17876
  if (bankTransaction.error) {
17813
17877
  setShowRetry(true);
@@ -17950,12 +18014,12 @@ const BankTransactionRow = ({
17950
18014
  className: "Layer__bank-transaction__submit-btn",
17951
18015
  processing: bankTransaction.processing,
17952
18016
  active: open,
17953
- action: categorized ? SubmitAction.SAVE : SubmitAction.UPDATE,
18017
+ action: displayAsCategorized ? SubmitAction.SAVE : SubmitAction.UPDATE,
17954
18018
  disabled: selectedCategory === null,
17955
- children: categorized ? (stringOverrides == null ? void 0 : stringOverrides.updateButtonText) || "Update" : (stringOverrides == null ? void 0 : stringOverrides.approveButtonText) || "Confirm"
18019
+ children: displayAsCategorized ? (stringOverrides == null ? void 0 : stringOverrides.updateButtonText) || "Update" : (stringOverrides == null ? void 0 : stringOverrides.approveButtonText) || "Confirm"
17956
18020
  }
17957
18021
  ),
17958
- !categorizationEnabled && !categorized && /* @__PURE__ */ jsxRuntime.jsx(VStack, { pis: "lg", fluid: true, children: /* @__PURE__ */ jsxRuntime.jsx(BankTransactionsProcessingInfo, {}) }),
18022
+ !categorizationEnabled && !displayAsCategorized && /* @__PURE__ */ jsxRuntime.jsx(VStack, { pis: "lg", fluid: true, children: /* @__PURE__ */ jsxRuntime.jsx(BankTransactionsProcessingInfo, {}) }),
17959
18023
  /* @__PURE__ */ jsxRuntime.jsx(
17960
18024
  IconButton,
17961
18025
  {
@@ -17977,7 +18041,7 @@ const BankTransactionRow = ({
17977
18041
  variant: "fade",
17978
18042
  isOpen: categorizationEnabled && !categorized,
17979
18043
  className: "Layer__BankTransactionRow__CategoryComboBoxMotionContent",
17980
- slotProps: { AnimatePresence: { mode: "wait" } },
18044
+ slotProps: { AnimatePresence: { mode: "wait", initial: false } },
17981
18045
  children: /* @__PURE__ */ jsxRuntime.jsx(
17982
18046
  BankTransactionCategoryComboBox,
17983
18047
  {
@@ -17987,20 +18051,20 @@ const BankTransactionRow = ({
17987
18051
  setTransactionCategory(bankTransaction.id, selectedCategory2);
17988
18052
  setShowRetry(false);
17989
18053
  },
17990
- isLoading: bankTransaction.processing
18054
+ isDisabled: bankTransaction.processing
17991
18055
  }
17992
18056
  )
17993
18057
  },
17994
18058
  "category-combobox"
17995
18059
  ),
17996
- categorized && /* @__PURE__ */ jsxRuntime.jsx(
18060
+ displayAsCategorized && /* @__PURE__ */ jsxRuntime.jsx(
17997
18061
  BankTransactionsCategorizedSelectedValue,
17998
18062
  {
17999
18063
  bankTransaction,
18000
18064
  className: "Layer__bank-transaction-row__category"
18001
18065
  }
18002
18066
  ),
18003
- categorizationEnabled && !categorized && showRetry && /* @__PURE__ */ jsxRuntime.jsx(
18067
+ !displayAsCategorized && categorizationEnabled && showRetry && /* @__PURE__ */ jsxRuntime.jsx(
18004
18068
  RetryButton,
18005
18069
  {
18006
18070
  onClick: () => {
@@ -18014,7 +18078,7 @@ const BankTransactionRow = ({
18014
18078
  children: "Retry"
18015
18079
  }
18016
18080
  ),
18017
- !categorized && categorizationEnabled && !showRetry && /* @__PURE__ */ jsxRuntime.jsx(
18081
+ !displayAsCategorized && categorizationEnabled && !showRetry && /* @__PURE__ */ jsxRuntime.jsx(
18018
18082
  SubmitButton,
18019
18083
  {
18020
18084
  onClick: () => {
@@ -18026,11 +18090,11 @@ const BankTransactionRow = ({
18026
18090
  processing: bankTransaction.processing,
18027
18091
  active: open,
18028
18092
  disabled: selectedCategory === null,
18029
- action: categorized ? SubmitAction.SAVE : SubmitAction.UPDATE,
18030
- children: categorized ? (stringOverrides == null ? void 0 : stringOverrides.updateButtonText) || "Update" : (stringOverrides == null ? void 0 : stringOverrides.approveButtonText) || "Confirm"
18093
+ action: displayAsCategorized ? SubmitAction.SAVE : SubmitAction.UPDATE,
18094
+ children: displayAsCategorized ? (stringOverrides == null ? void 0 : stringOverrides.updateButtonText) || "Update" : (stringOverrides == null ? void 0 : stringOverrides.approveButtonText) || "Confirm"
18031
18095
  }
18032
18096
  ),
18033
- !categorizationEnabled && !categorized && /* @__PURE__ */ jsxRuntime.jsx(VStack, { pis: "xs", fluid: true, children: /* @__PURE__ */ jsxRuntime.jsx(BankTransactionsProcessingInfo, {}) }),
18097
+ !categorizationEnabled && !displayAsCategorized && /* @__PURE__ */ jsxRuntime.jsx(VStack, { pis: "xs", fluid: true, children: /* @__PURE__ */ jsxRuntime.jsx(BankTransactionsProcessingInfo, {}) }),
18034
18098
  /* @__PURE__ */ jsxRuntime.jsx(
18035
18099
  IconButton,
18036
18100
  {
@@ -18054,7 +18118,7 @@ const BankTransactionRow = ({
18054
18118
  {
18055
18119
  ref: expandedRowRef,
18056
18120
  bankTransaction,
18057
- categorized,
18121
+ categorized: displayAsCategorized,
18058
18122
  isOpen: open,
18059
18123
  close: () => setOpen(false),
18060
18124
  containerWidth,
@@ -18160,6 +18224,7 @@ const BankTransactionsListItem = ({
18160
18224
  const bookkeepingStatus = useEffectiveBookkeepingStatus();
18161
18225
  const categorizationEnabled = isCategorizationEnabledForStatus(bookkeepingStatus);
18162
18226
  const categorized = isCategorized(bankTransaction);
18227
+ const displayAsCategorized = bankTransaction.recently_categorized && shouldHideAfterCategorize() ? false : categorized;
18163
18228
  const { isVisible } = useDelayedVisibility({ delay: index2 * 80 });
18164
18229
  const { select, deselect } = useBulkSelectionActions();
18165
18230
  const isSelected = useIdIsSelected();
@@ -18256,7 +18321,7 @@ const BankTransactionsListItem = ({
18256
18321
  }
18257
18322
  )
18258
18323
  ] }),
18259
- !categorizationEnabled && !categorized && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "Layer__bank-transaction-list-item__processing-info", children: /* @__PURE__ */ jsxRuntime.jsx(BankTransactionsProcessingInfo, {}) }),
18324
+ !categorizationEnabled && !displayAsCategorized && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "Layer__bank-transaction-list-item__processing-info", children: /* @__PURE__ */ jsxRuntime.jsx(BankTransactionsProcessingInfo, {}) }),
18260
18325
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "Layer__bank-transaction-list-item__expanded-row", onClick: preventRowExpansion, children: /* @__PURE__ */ jsxRuntime.jsx(AnimatedPresenceDiv, { variant: "expand", isOpen: openExpandedRow, children: /* @__PURE__ */ jsxRuntime.jsx(
18261
18326
  ExpandedBankTransactionRow,
18262
18327
  {
@@ -18264,9 +18329,9 @@ const BankTransactionsListItem = ({
18264
18329
  bankTransaction,
18265
18330
  isOpen: openExpandedRow,
18266
18331
  close: () => setOpenExpandedRow(false),
18267
- categorized,
18332
+ categorized: displayAsCategorized,
18268
18333
  asListItem: true,
18269
- submitBtnText: categorized ? (stringOverrides == null ? void 0 : stringOverrides.updateButtonText) || "Update" : (stringOverrides == null ? void 0 : stringOverrides.approveButtonText) || "Approve",
18334
+ submitBtnText: displayAsCategorized ? (stringOverrides == null ? void 0 : stringOverrides.updateButtonText) || "Update" : (stringOverrides == null ? void 0 : stringOverrides.approveButtonText) || "Approve",
18270
18335
  containerWidth,
18271
18336
  showDescriptions,
18272
18337
  showReceiptUploads,
@@ -18274,7 +18339,7 @@ const BankTransactionsListItem = ({
18274
18339
  variant: "list"
18275
18340
  }
18276
18341
  ) }, `expanded-${bankTransaction.id}`) }),
18277
- !openExpandedRow && categorizationEnabled && !categorized && /* @__PURE__ */ jsxRuntime.jsx("div", { onClick: preventRowExpansion, children: /* @__PURE__ */ jsxRuntime.jsxs(HStack, { pi: "md", gap: "md", pb: "md", children: [
18342
+ !openExpandedRow && categorizationEnabled && !displayAsCategorized && /* @__PURE__ */ jsxRuntime.jsx("div", { onClick: preventRowExpansion, children: /* @__PURE__ */ jsxRuntime.jsxs(HStack, { pi: "md", gap: "md", pb: "md", children: [
18278
18343
  /* @__PURE__ */ jsxRuntime.jsx(
18279
18344
  BankTransactionCategoryComboBox,
18280
18345
  {
@@ -18284,7 +18349,7 @@ const BankTransactionsListItem = ({
18284
18349
  setTransactionCategory(bankTransaction.id, selectedCategory2);
18285
18350
  setShowRetry(false);
18286
18351
  },
18287
- isLoading: bankTransaction.processing
18352
+ isDisabled: bankTransaction.processing
18288
18353
  }
18289
18354
  ),
18290
18355
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -18294,14 +18359,14 @@ const BankTransactionsListItem = ({
18294
18359
  onClick: handleSave,
18295
18360
  className: showRetry ? "Layer__bank-transaction__retry-btn" : "Layer__bank-transaction__submit-btn",
18296
18361
  processing: bankTransaction.processing,
18297
- action: !categorized ? SubmitAction.SAVE : SubmitAction.UPDATE,
18362
+ action: !displayAsCategorized ? SubmitAction.SAVE : SubmitAction.UPDATE,
18298
18363
  withRetry: true,
18299
18364
  error: showRetry ? "Approval failed. Check connection and retry in few seconds." : void 0,
18300
- children: showRetry ? "Retry" : !categorized ? (stringOverrides == null ? void 0 : stringOverrides.approveButtonText) || "Approve" : (stringOverrides == null ? void 0 : stringOverrides.updateButtonText) || "Update"
18365
+ children: showRetry ? "Retry" : !displayAsCategorized ? (stringOverrides == null ? void 0 : stringOverrides.approveButtonText) || "Approve" : (stringOverrides == null ? void 0 : stringOverrides.updateButtonText) || "Update"
18301
18366
  }
18302
18367
  )
18303
18368
  ] }) }),
18304
- !openExpandedRow && categorized && /* @__PURE__ */ jsxRuntime.jsx(
18369
+ !openExpandedRow && displayAsCategorized && /* @__PURE__ */ jsxRuntime.jsx(
18305
18370
  BankTransactionsListItemCategory,
18306
18371
  {
18307
18372
  bankTransaction
@@ -19282,37 +19347,6 @@ const BankTransactionsMobileForms = ({
19282
19347
  };
19283
19348
  return /* @__PURE__ */ jsxRuntime.jsx(ReceiptsProvider, { bankTransaction, isActive: isOpen, children: getContent() });
19284
19349
  };
19285
- const NewToggleOption = ({
19286
- label,
19287
- value
19288
- }) => {
19289
- return /* @__PURE__ */ jsxRuntime.jsxs(reactAriaComponents.ToggleButton, { id: value, className: "Layer__NewToggleOption", children: [
19290
- /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.SelectionIndicator, { className: "Layer__NewToggleOption-SelectionIndicator" }),
19291
- /* @__PURE__ */ jsxRuntime.jsx(Span, { className: "Layer__NewToggle-Option-Content", children: /* @__PURE__ */ jsxRuntime.jsx(Span, { noWrap: true, children: label }) })
19292
- ] });
19293
- };
19294
- const NewToggle = ({
19295
- options: options2,
19296
- selectedKey,
19297
- onSelectionChange
19298
- }) => {
19299
- const selectedKeys = selectedKey !== void 0 ? /* @__PURE__ */ new Set([selectedKey]) : /* @__PURE__ */ new Set();
19300
- return /* @__PURE__ */ jsxRuntime.jsx(
19301
- reactAriaComponents.ToggleButtonGroup,
19302
- {
19303
- className: "Layer__NewToggle",
19304
- selectionMode: "single",
19305
- selectedKeys,
19306
- onSelectionChange: (keys2) => {
19307
- const selectedKeysArray = Array.from(keys2);
19308
- if (selectedKeysArray.length > 0 && onSelectionChange) {
19309
- onSelectionChange(selectedKeysArray[0]);
19310
- }
19311
- },
19312
- children: options2.map((option) => /* @__PURE__ */ jsxRuntime.jsx(NewToggleOption, __spreadValues({}, option), option.value))
19313
- }
19314
- );
19315
- };
19316
19350
  const PURPOSE_TOGGLE_OPTIONS = [
19317
19351
  {
19318
19352
  value: "business",
@@ -19426,6 +19460,7 @@ const BankTransactionsMobileListItem = ({
19426
19460
  const { shouldHideAfterCategorize } = useBankTransactionsContext();
19427
19461
  const categorized = isCategorized(bankTransaction);
19428
19462
  const itemRef = react.useRef(null);
19463
+ const displayAsCategorized = bankTransaction.recently_categorized && shouldHideAfterCategorize() ? false : categorized;
19429
19464
  const [open, setOpen] = react.useState(isFirstItem);
19430
19465
  const openNext = () => {
19431
19466
  if (editable && itemRef.current && itemRef.current.nextSibling) {
@@ -19512,11 +19547,11 @@ const BankTransactionsMobileListItem = ({
19512
19547
  const isTransactionSelected = isSelected(bankTransaction.id);
19513
19548
  const { renderInAppLink } = useInAppLinkContext();
19514
19549
  const inAppLink = react.useMemo(() => {
19515
- if (!categorized) {
19550
+ if (!displayAsCategorized) {
19516
19551
  return null;
19517
19552
  }
19518
19553
  return getInAppLink(bankTransaction, renderInAppLink);
19519
- }, [categorized, bankTransaction, renderInAppLink]);
19554
+ }, [displayAsCategorized, bankTransaction, renderInAppLink]);
19520
19555
  const { isVisible } = useDelayedVisibility({ delay: index2 * 20, initialVisibility: Boolean(initialLoad) });
19521
19556
  const className = "Layer__bank-transaction-mobile-list-item";
19522
19557
  const openClassName = open ? `${className}--expanded` : "";
@@ -19583,7 +19618,7 @@ const BankTransactionsMobileListItem = ({
19583
19618
  ]
19584
19619
  }
19585
19620
  ),
19586
- !open && (!categorizationEnabled && !categorized ? /* @__PURE__ */ jsxRuntime.jsx(BankTransactionsProcessingInfo, { showAsBadge: true }) : /* @__PURE__ */ jsxRuntime.jsx(
19621
+ !open && (!categorizationEnabled && !displayAsCategorized ? /* @__PURE__ */ jsxRuntime.jsx(BankTransactionsProcessingInfo, { showAsBadge: true }) : /* @__PURE__ */ jsxRuntime.jsx(
19587
19622
  BankTransactionsListItemCategory,
19588
19623
  {
19589
19624
  bankTransaction,