@algorithm-shift/design-system 1.2.988 → 1.2.990

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
@@ -452,7 +452,12 @@ function useFileService(options) {
452
452
  withCredentials: true
453
453
  });
454
454
  setData(result);
455
- options?.onSuccess?.(result);
455
+ if (result.status === 200) {
456
+ options?.onSuccess?.(result.data);
457
+ } else {
458
+ const err = new Error(`Fetch failed with status ${result.status}`);
459
+ throw err;
460
+ }
456
461
  return result;
457
462
  } catch (err) {
458
463
  setError(err);
@@ -472,7 +477,12 @@ function useFileService(options) {
472
477
  withCredentials: true
473
478
  });
474
479
  setData(result);
475
- options?.onSuccess?.(result);
480
+ if (result.status === 200) {
481
+ options?.onSuccess?.(result.data);
482
+ } else {
483
+ const err = new Error(`Fetch failed with status ${result.status}`);
484
+ throw err;
485
+ }
476
486
  return result;
477
487
  } catch (err) {
478
488
  setError(err);
@@ -492,7 +502,12 @@ function useFileService(options) {
492
502
  withCredentials: true
493
503
  });
494
504
  setData(result);
495
- options?.onSuccess?.(result);
505
+ if (result.status === 200) {
506
+ options?.onSuccess?.(result.data);
507
+ } else {
508
+ const err = new Error(`Fetch failed with status ${result.status}`);
509
+ throw err;
510
+ }
496
511
  return result;
497
512
  } catch (err) {
498
513
  setError(err);
@@ -538,7 +553,10 @@ var ImageControl = ({
538
553
  axiosInstance: props.axiosInstance,
539
554
  apiUrl,
540
555
  onSuccess: async (result) => {
541
- if (!result?.data?.url && !props.onSuccess) return;
556
+ if (!result?.data?.url && !props.onSuccess) {
557
+ setLoader(false);
558
+ return;
559
+ }
542
560
  props.onSuccess?.({ url: result.data.url || "", fileName: result.data.originalname || "" });
543
561
  setLoader(false);
544
562
  }
@@ -2043,10 +2061,10 @@ function useLazyDropdown(config) {
2043
2061
  (0, import_react20.useEffect)(() => {
2044
2062
  if (config.initialData?.length) {
2045
2063
  allDataRef.current = config.initialData;
2046
- loadPage(1, "");
2047
2064
  }
2048
2065
  }, [config.initialData]);
2049
2066
  (0, import_react20.useEffect)(() => {
2067
+ if (config.fetchOnMount) loadPage(1, "");
2050
2068
  return () => {
2051
2069
  if (debounceTimer.current) clearTimeout(debounceTimer.current);
2052
2070
  };
@@ -4876,6 +4894,7 @@ function showSonnerToast({
4876
4894
  onAction
4877
4895
  }) {
4878
4896
  const options = {
4897
+ closeButton: true,
4879
4898
  description,
4880
4899
  duration,
4881
4900
  action: actionLabel ? {