@algorithm-shift/design-system 1.2.987 → 1.2.989

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -36,6 +36,7 @@ interface ImageProps extends ElementProps {
36
36
  enableUpload?: boolean;
37
37
  onSuccess?: (data: { url: string; fileName: string }) => void;
38
38
  axiosInstance?: typeof axios;
39
+ apiUrl?: string;
39
40
  }
40
41
 
41
42
  type InputProperties = {
@@ -304,7 +305,7 @@ declare const _default$2: typeof Repeater;
304
305
 
305
306
  declare const ButtonWrapper: ({ className, style, textContent, loadingText, loading, ...props }: ButtonProps) => react_jsx_runtime.JSX.Element;
306
307
 
307
- declare const ImageControl: ({ className, style, imageUrl, altText, ...props }: ImageProps) => react_jsx_runtime.JSX.Element;
308
+ declare const ImageControl: ({ className, style, imageUrl, altText, apiUrl, ...props }: ImageProps) => react_jsx_runtime.JSX.Element;
308
309
 
309
310
  declare const Shape: ({ children, className, style }: ElementProps) => react_jsx_runtime.JSX.Element;
310
311
 
package/dist/index.d.ts CHANGED
@@ -36,6 +36,7 @@ interface ImageProps extends ElementProps {
36
36
  enableUpload?: boolean;
37
37
  onSuccess?: (data: { url: string; fileName: string }) => void;
38
38
  axiosInstance?: typeof axios;
39
+ apiUrl?: string;
39
40
  }
40
41
 
41
42
  type InputProperties = {
@@ -304,7 +305,7 @@ declare const _default$2: typeof Repeater;
304
305
 
305
306
  declare const ButtonWrapper: ({ className, style, textContent, loadingText, loading, ...props }: ButtonProps) => react_jsx_runtime.JSX.Element;
306
307
 
307
- declare const ImageControl: ({ className, style, imageUrl, altText, ...props }: ImageProps) => react_jsx_runtime.JSX.Element;
308
+ declare const ImageControl: ({ className, style, imageUrl, altText, apiUrl, ...props }: ImageProps) => react_jsx_runtime.JSX.Element;
308
309
 
309
310
  declare const Shape: ({ children, className, style }: ElementProps) => react_jsx_runtime.JSX.Element;
310
311
 
package/dist/index.js CHANGED
@@ -447,12 +447,17 @@ function useFileService(options) {
447
447
  formData.append(key, value);
448
448
  });
449
449
  const axiosClient = options.axiosInstance ?? import_axios.default;
450
- const apiUrl = "/fileservice/upload";
450
+ const apiUrl = options.apiUrl ?? "/fileservice/upload";
451
451
  const result = await axiosClient.post(`${apiUrl}`, formData, {
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);
@@ -519,6 +534,7 @@ var ImageControl = ({
519
534
  style,
520
535
  imageUrl,
521
536
  altText = "Preview",
537
+ apiUrl,
522
538
  ...props
523
539
  }) => {
524
540
  const defaultImgClass = cn(
@@ -535,8 +551,12 @@ var ImageControl = ({
535
551
  };
536
552
  const { uploadFile } = useFileService({
537
553
  axiosInstance: props.axiosInstance,
554
+ apiUrl,
538
555
  onSuccess: async (result) => {
539
- if (!result?.data?.url && !props.onSuccess) return;
556
+ if (!result?.data?.url && !props.onSuccess) {
557
+ setLoader(false);
558
+ return;
559
+ }
540
560
  props.onSuccess?.({ url: result.data.url || "", fileName: result.data.originalname || "" });
541
561
  setLoader(false);
542
562
  }
@@ -4874,6 +4894,7 @@ function showSonnerToast({
4874
4894
  onAction
4875
4895
  }) {
4876
4896
  const options = {
4897
+ closeButton: true,
4877
4898
  description,
4878
4899
  duration,
4879
4900
  action: actionLabel ? {