@cagatayfdn/flora-components 0.0.164 → 0.0.165

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
@@ -208,6 +208,9 @@ export declare type BreadcrumbProps = {
208
208
  state?: any;
209
209
  };
210
210
 
211
+ /** Build the final request URL from `baseURL`, `url` and serialized `params`. */
212
+ export declare function buildFullURL(config: FetchRequestConfig): string;
213
+
211
214
  export declare const Button: ({ children, size, isLoading, isDisabled, isBlock, noBorder, noBackground, round, isSolid, isPill, type, focus, className, prefixIcon, appearance, onClick, }: ButtonProps) => JSX.Element;
212
215
 
213
216
  export declare type ButtonProps = {
@@ -319,6 +322,12 @@ export declare type ColumnsType = {
319
322
  render?: (property: any, row: any) => void;
320
323
  };
321
324
 
325
+ /**
326
+ * Join a base URL and a relative URL with a single slash. An absolute
327
+ * `relativeURL` (with its own scheme/host) is returned untouched.
328
+ */
329
+ export declare function combineURLs(baseURL?: string, relativeURL?: string): string;
330
+
322
331
  export declare function Config({ config, scrollProps }: ConfigProps): JSX_2.Element;
323
332
 
324
333
  declare function Config({ config, scrollProps }: ConfigProps): JSX_2.Element;
@@ -379,6 +388,20 @@ export declare type CountdownProps = {
379
388
 
380
389
  export declare const createConnectedService: (projects: Record<string, any>[], isFlex?: boolean) => JSX_2.Element[] | undefined;
381
390
 
391
+ /**
392
+ * Create an axios-like HTTP client backed by the Fetch API.
393
+ *
394
+ * @example
395
+ * const instance = createFetchClient({ baseURL: import.meta.env.VITE_APP_API_URL });
396
+ * instance.interceptors.request.use((config) => {
397
+ * const token = localStorage.getItem("token");
398
+ * if (token) config.headers = { ...config.headers, Authorization: `Token ${token}` };
399
+ * return config;
400
+ * });
401
+ * const { data } = await instance.get("/users");
402
+ */
403
+ export declare function createFetchClient(defaultConfig?: FetchRequestConfig): FetchInstance;
404
+
382
405
  export declare type CustomItemProps = {
383
406
  item: OptionProps;
384
407
  };
@@ -440,6 +463,13 @@ export declare interface DateRange {
440
463
 
441
464
  export { dayjs }
442
465
 
466
+ /**
467
+ * Serialize `params` into a query string. Arrays repeat the key with a `[]`
468
+ * suffix, `Date`s become ISO strings, plain objects are JSON-encoded, and
469
+ * `null`/`undefined` values are skipped — matching axios' default behaviour.
470
+ */
471
+ export declare function defaultParamsSerializer(params: any): string;
472
+
443
473
  declare type Dispatch_2 = React_2.Dispatch<Actiontype>;
444
474
 
445
475
  export declare const Divider: ({ appearance, className, margin, }: DividerProps) => JSX.Element;
@@ -534,8 +564,69 @@ export declare type FetcherReturnType = {
534
564
  startInterval: (...params: any) => void;
535
565
  };
536
566
 
567
+ /**
568
+ * Error thrown for failed requests. Mirrors `AxiosError`: it carries the
569
+ * originating `config`, the `response` (when the server responded) and a
570
+ * machine-readable `code`. Network failures, timeouts and cancellations have
571
+ * no `response`.
572
+ */
573
+ export declare class FetchError<T = any> extends Error {
574
+ config: FetchRequestConfig;
575
+ code?: string;
576
+ request?: any;
577
+ response?: FetchResponse<T>;
578
+ isFetchError: boolean;
579
+ constructor(message: string, config: FetchRequestConfig, code?: string, request?: any, response?: FetchResponse<T>);
580
+ toJSON(): {
581
+ name: string;
582
+ message: string;
583
+ code: string | undefined;
584
+ status: number | undefined;
585
+ };
586
+ }
587
+
588
+ export declare const FetchErrorCode: {
589
+ readonly BAD_REQUEST: "ERR_BAD_REQUEST";
590
+ readonly BAD_RESPONSE: "ERR_BAD_RESPONSE";
591
+ readonly NETWORK: "ERR_NETWORK";
592
+ readonly TIMEOUT: "ERR_TIMEOUT";
593
+ readonly CANCELED: "ERR_CANCELED";
594
+ };
595
+
537
596
  export declare type FetcherType = (...params: any) => void;
538
597
 
598
+ export declare type FetchHeaders = Record<string, string>;
599
+
600
+ /**
601
+ * A configured client. Callable like axios (`instance(config)` /
602
+ * `instance(url, config)`) and exposes `request`, the HTTP verb helpers,
603
+ * `interceptors`, `defaults`, and `create`.
604
+ */
605
+ export declare interface FetchInstance {
606
+ <T = any>(config: FetchRequestConfig): Promise<FetchResponse<T>>;
607
+ <T = any>(url: string, config?: FetchRequestConfig): Promise<FetchResponse<T>>;
608
+ request<T = any>(config: FetchRequestConfig): Promise<FetchResponse<T>>;
609
+ get<T = any>(url: string, config?: FetchRequestConfig): Promise<FetchResponse<T>>;
610
+ delete<T = any>(url: string, config?: FetchRequestConfig): Promise<FetchResponse<T>>;
611
+ head<T = any>(url: string, config?: FetchRequestConfig): Promise<FetchResponse<T>>;
612
+ options<T = any>(url: string, config?: FetchRequestConfig): Promise<FetchResponse<T>>;
613
+ post<T = any, D = any>(url: string, data?: D, config?: FetchRequestConfig): Promise<FetchResponse<T>>;
614
+ put<T = any, D = any>(url: string, data?: D, config?: FetchRequestConfig): Promise<FetchResponse<T>>;
615
+ patch<T = any, D = any>(url: string, data?: D, config?: FetchRequestConfig): Promise<FetchResponse<T>>;
616
+ interceptors: {
617
+ request: FetchInterceptorManager<FetchRequestConfig>;
618
+ response: FetchInterceptorManager<FetchResponse>;
619
+ };
620
+ defaults: FetchRequestConfig;
621
+ create(config?: FetchRequestConfig): FetchInstance;
622
+ }
623
+
624
+ export declare interface FetchInterceptorManager<V> {
625
+ use(onFulfilled?: (value: V) => V | Promise<V>, onRejected?: InterceptorRejected): number;
626
+ eject(id: number): void;
627
+ clear(): void;
628
+ }
629
+
539
630
  export declare interface FetchLogsParams {
540
631
  applications: string[];
541
632
  scroll_mode?: 'older' | 'newer';
@@ -544,6 +635,47 @@ export declare interface FetchLogsParams {
544
635
  withoutPermission?: boolean;
545
636
  }
546
637
 
638
+ export declare type FetchMethod = "get" | "GET" | "post" | "POST" | "put" | "PUT" | "patch" | "PATCH" | "delete" | "DELETE" | "head" | "HEAD" | "options" | "OPTIONS";
639
+
640
+ /**
641
+ * Request configuration. Mirrors the shape of an axios request config so that
642
+ * migrating existing axios code requires minimal changes. Unknown keys are
643
+ * allowed (e.g. custom flags like `_retry`) via the index signature.
644
+ */
645
+ export declare interface FetchRequestConfig<D = any> {
646
+ url?: string;
647
+ method?: FetchMethod;
648
+ baseURL?: string;
649
+ headers?: FetchHeaders;
650
+ params?: any;
651
+ data?: D;
652
+ signal?: AbortSignal;
653
+ /** Abort the request after this many milliseconds. */
654
+ timeout?: number;
655
+ /** When true, sends credentials (cookies) cross-origin (`credentials: "include"`). */
656
+ withCredentials?: boolean;
657
+ /** Fine-grained override of the fetch `credentials` mode. Takes precedence over `withCredentials`. */
658
+ credentials?: RequestCredentials;
659
+ /** How to parse the response body. Defaults to `"json"`. */
660
+ responseType?: FetchResponseType;
661
+ /** Custom query-string serializer. Defaults to an axios-compatible serializer. */
662
+ paramsSerializer?: (params: any) => string;
663
+ /** Resolves the promise only for matching statuses. `null` accepts every status. */
664
+ validateStatus?: ((status: number) => boolean) | null;
665
+ [key: string]: any;
666
+ }
667
+
668
+ export declare interface FetchResponse<T = any, D = any> {
669
+ data: T;
670
+ status: number;
671
+ statusText: string;
672
+ headers: FetchHeaders;
673
+ config: FetchRequestConfig<D>;
674
+ request?: any;
675
+ }
676
+
677
+ export declare type FetchResponseType = "json" | "text" | "blob" | "arrayBuffer" | "formData";
678
+
547
679
  export declare const FileUpload: React_2.ForwardRefExoticComponent<{
548
680
  type?: "number" | "email" | "search" | "text" | "url" | "tel" | "password" | "hidden" | undefined;
549
681
  id?: string | undefined;
@@ -852,11 +984,42 @@ export declare type InputProps = {
852
984
  textFillColor?: string;
853
985
  } & Omit<FormElementProps, 'value'> & Omit<EventProps<HTMLInputElement>, 'onMouseUp' | 'onMouseDown' | 'onMouseEnter' | 'onMouseLeave'>;
854
986
 
987
+ declare interface InterceptorHandler<V> {
988
+ fulfilled?: (value: V) => V | Promise<V>;
989
+ rejected?: InterceptorRejected;
990
+ }
991
+
992
+ /**
993
+ * Holds a list of interceptor handlers. Ejecting nulls a slot instead of
994
+ * splicing so previously returned ids stay valid (same approach as axios).
995
+ */
996
+ export declare class InterceptorManager<V> {
997
+ private handlers;
998
+ /**
999
+ * Register a handler pair. Returns an id usable with {@link eject}.
1000
+ */
1001
+ use(onFulfilled?: (value: V) => V | Promise<V>, onRejected?: InterceptorRejected): number;
1002
+ /** Remove the handler registered under `id`. */
1003
+ eject(id: number): void;
1004
+ /** Remove every registered handler. */
1005
+ clear(): void;
1006
+ /** Iterate over the non-ejected handlers in registration order. */
1007
+ forEach(fn: (handler: InterceptorHandler<V>) => void): void;
1008
+ }
1009
+
1010
+ export declare type InterceptorRejected = (error: any) => any;
1011
+
855
1012
  export declare enum isActiveColor {
856
1013
  inActive = "#4482ff",
857
1014
  active = "#3f4b5c"
858
1015
  }
859
1016
 
1017
+ /** True when `value` is the error produced by an aborted/cancelled request. */
1018
+ export declare function isCancel(value: any): boolean;
1019
+
1020
+ /** Type guard: true when `value` is a `FetchError`. */
1021
+ export declare function isFetchError(value: any): value is FetchError;
1022
+
860
1023
  export declare interface KeyValueParams {
861
1024
  [key: string]: string | string[] | number | number[] | undefined | Record<string, unknown>;
862
1025
  }
package/dist/index.d.ts CHANGED
@@ -208,6 +208,9 @@ export declare type BreadcrumbProps = {
208
208
  state?: any;
209
209
  };
210
210
 
211
+ /** Build the final request URL from `baseURL`, `url` and serialized `params`. */
212
+ export declare function buildFullURL(config: FetchRequestConfig): string;
213
+
211
214
  export declare const Button: ({ children, size, isLoading, isDisabled, isBlock, noBorder, noBackground, round, isSolid, isPill, type, focus, className, prefixIcon, appearance, onClick, }: ButtonProps) => JSX.Element;
212
215
 
213
216
  export declare type ButtonProps = {
@@ -319,6 +322,12 @@ export declare type ColumnsType = {
319
322
  render?: (property: any, row: any) => void;
320
323
  };
321
324
 
325
+ /**
326
+ * Join a base URL and a relative URL with a single slash. An absolute
327
+ * `relativeURL` (with its own scheme/host) is returned untouched.
328
+ */
329
+ export declare function combineURLs(baseURL?: string, relativeURL?: string): string;
330
+
322
331
  export declare function Config({ config, scrollProps }: ConfigProps): JSX_2.Element;
323
332
 
324
333
  declare function Config({ config, scrollProps }: ConfigProps): JSX_2.Element;
@@ -379,6 +388,20 @@ export declare type CountdownProps = {
379
388
 
380
389
  export declare const createConnectedService: (projects: Record<string, any>[], isFlex?: boolean) => JSX_2.Element[] | undefined;
381
390
 
391
+ /**
392
+ * Create an axios-like HTTP client backed by the Fetch API.
393
+ *
394
+ * @example
395
+ * const instance = createFetchClient({ baseURL: import.meta.env.VITE_APP_API_URL });
396
+ * instance.interceptors.request.use((config) => {
397
+ * const token = localStorage.getItem("token");
398
+ * if (token) config.headers = { ...config.headers, Authorization: `Token ${token}` };
399
+ * return config;
400
+ * });
401
+ * const { data } = await instance.get("/users");
402
+ */
403
+ export declare function createFetchClient(defaultConfig?: FetchRequestConfig): FetchInstance;
404
+
382
405
  export declare type CustomItemProps = {
383
406
  item: OptionProps;
384
407
  };
@@ -440,6 +463,13 @@ export declare interface DateRange {
440
463
 
441
464
  export { dayjs }
442
465
 
466
+ /**
467
+ * Serialize `params` into a query string. Arrays repeat the key with a `[]`
468
+ * suffix, `Date`s become ISO strings, plain objects are JSON-encoded, and
469
+ * `null`/`undefined` values are skipped — matching axios' default behaviour.
470
+ */
471
+ export declare function defaultParamsSerializer(params: any): string;
472
+
443
473
  declare type Dispatch_2 = React_2.Dispatch<Actiontype>;
444
474
 
445
475
  export declare const Divider: ({ appearance, className, margin, }: DividerProps) => JSX.Element;
@@ -534,8 +564,69 @@ export declare type FetcherReturnType = {
534
564
  startInterval: (...params: any) => void;
535
565
  };
536
566
 
567
+ /**
568
+ * Error thrown for failed requests. Mirrors `AxiosError`: it carries the
569
+ * originating `config`, the `response` (when the server responded) and a
570
+ * machine-readable `code`. Network failures, timeouts and cancellations have
571
+ * no `response`.
572
+ */
573
+ export declare class FetchError<T = any> extends Error {
574
+ config: FetchRequestConfig;
575
+ code?: string;
576
+ request?: any;
577
+ response?: FetchResponse<T>;
578
+ isFetchError: boolean;
579
+ constructor(message: string, config: FetchRequestConfig, code?: string, request?: any, response?: FetchResponse<T>);
580
+ toJSON(): {
581
+ name: string;
582
+ message: string;
583
+ code: string | undefined;
584
+ status: number | undefined;
585
+ };
586
+ }
587
+
588
+ export declare const FetchErrorCode: {
589
+ readonly BAD_REQUEST: "ERR_BAD_REQUEST";
590
+ readonly BAD_RESPONSE: "ERR_BAD_RESPONSE";
591
+ readonly NETWORK: "ERR_NETWORK";
592
+ readonly TIMEOUT: "ERR_TIMEOUT";
593
+ readonly CANCELED: "ERR_CANCELED";
594
+ };
595
+
537
596
  export declare type FetcherType = (...params: any) => void;
538
597
 
598
+ export declare type FetchHeaders = Record<string, string>;
599
+
600
+ /**
601
+ * A configured client. Callable like axios (`instance(config)` /
602
+ * `instance(url, config)`) and exposes `request`, the HTTP verb helpers,
603
+ * `interceptors`, `defaults`, and `create`.
604
+ */
605
+ export declare interface FetchInstance {
606
+ <T = any>(config: FetchRequestConfig): Promise<FetchResponse<T>>;
607
+ <T = any>(url: string, config?: FetchRequestConfig): Promise<FetchResponse<T>>;
608
+ request<T = any>(config: FetchRequestConfig): Promise<FetchResponse<T>>;
609
+ get<T = any>(url: string, config?: FetchRequestConfig): Promise<FetchResponse<T>>;
610
+ delete<T = any>(url: string, config?: FetchRequestConfig): Promise<FetchResponse<T>>;
611
+ head<T = any>(url: string, config?: FetchRequestConfig): Promise<FetchResponse<T>>;
612
+ options<T = any>(url: string, config?: FetchRequestConfig): Promise<FetchResponse<T>>;
613
+ post<T = any, D = any>(url: string, data?: D, config?: FetchRequestConfig): Promise<FetchResponse<T>>;
614
+ put<T = any, D = any>(url: string, data?: D, config?: FetchRequestConfig): Promise<FetchResponse<T>>;
615
+ patch<T = any, D = any>(url: string, data?: D, config?: FetchRequestConfig): Promise<FetchResponse<T>>;
616
+ interceptors: {
617
+ request: FetchInterceptorManager<FetchRequestConfig>;
618
+ response: FetchInterceptorManager<FetchResponse>;
619
+ };
620
+ defaults: FetchRequestConfig;
621
+ create(config?: FetchRequestConfig): FetchInstance;
622
+ }
623
+
624
+ export declare interface FetchInterceptorManager<V> {
625
+ use(onFulfilled?: (value: V) => V | Promise<V>, onRejected?: InterceptorRejected): number;
626
+ eject(id: number): void;
627
+ clear(): void;
628
+ }
629
+
539
630
  export declare interface FetchLogsParams {
540
631
  applications: string[];
541
632
  scroll_mode?: 'older' | 'newer';
@@ -544,6 +635,47 @@ export declare interface FetchLogsParams {
544
635
  withoutPermission?: boolean;
545
636
  }
546
637
 
638
+ export declare type FetchMethod = "get" | "GET" | "post" | "POST" | "put" | "PUT" | "patch" | "PATCH" | "delete" | "DELETE" | "head" | "HEAD" | "options" | "OPTIONS";
639
+
640
+ /**
641
+ * Request configuration. Mirrors the shape of an axios request config so that
642
+ * migrating existing axios code requires minimal changes. Unknown keys are
643
+ * allowed (e.g. custom flags like `_retry`) via the index signature.
644
+ */
645
+ export declare interface FetchRequestConfig<D = any> {
646
+ url?: string;
647
+ method?: FetchMethod;
648
+ baseURL?: string;
649
+ headers?: FetchHeaders;
650
+ params?: any;
651
+ data?: D;
652
+ signal?: AbortSignal;
653
+ /** Abort the request after this many milliseconds. */
654
+ timeout?: number;
655
+ /** When true, sends credentials (cookies) cross-origin (`credentials: "include"`). */
656
+ withCredentials?: boolean;
657
+ /** Fine-grained override of the fetch `credentials` mode. Takes precedence over `withCredentials`. */
658
+ credentials?: RequestCredentials;
659
+ /** How to parse the response body. Defaults to `"json"`. */
660
+ responseType?: FetchResponseType;
661
+ /** Custom query-string serializer. Defaults to an axios-compatible serializer. */
662
+ paramsSerializer?: (params: any) => string;
663
+ /** Resolves the promise only for matching statuses. `null` accepts every status. */
664
+ validateStatus?: ((status: number) => boolean) | null;
665
+ [key: string]: any;
666
+ }
667
+
668
+ export declare interface FetchResponse<T = any, D = any> {
669
+ data: T;
670
+ status: number;
671
+ statusText: string;
672
+ headers: FetchHeaders;
673
+ config: FetchRequestConfig<D>;
674
+ request?: any;
675
+ }
676
+
677
+ export declare type FetchResponseType = "json" | "text" | "blob" | "arrayBuffer" | "formData";
678
+
547
679
  export declare const FileUpload: React_2.ForwardRefExoticComponent<{
548
680
  type?: "number" | "email" | "search" | "text" | "url" | "tel" | "password" | "hidden" | undefined;
549
681
  id?: string | undefined;
@@ -852,11 +984,42 @@ export declare type InputProps = {
852
984
  textFillColor?: string;
853
985
  } & Omit<FormElementProps, 'value'> & Omit<EventProps<HTMLInputElement>, 'onMouseUp' | 'onMouseDown' | 'onMouseEnter' | 'onMouseLeave'>;
854
986
 
987
+ declare interface InterceptorHandler<V> {
988
+ fulfilled?: (value: V) => V | Promise<V>;
989
+ rejected?: InterceptorRejected;
990
+ }
991
+
992
+ /**
993
+ * Holds a list of interceptor handlers. Ejecting nulls a slot instead of
994
+ * splicing so previously returned ids stay valid (same approach as axios).
995
+ */
996
+ export declare class InterceptorManager<V> {
997
+ private handlers;
998
+ /**
999
+ * Register a handler pair. Returns an id usable with {@link eject}.
1000
+ */
1001
+ use(onFulfilled?: (value: V) => V | Promise<V>, onRejected?: InterceptorRejected): number;
1002
+ /** Remove the handler registered under `id`. */
1003
+ eject(id: number): void;
1004
+ /** Remove every registered handler. */
1005
+ clear(): void;
1006
+ /** Iterate over the non-ejected handlers in registration order. */
1007
+ forEach(fn: (handler: InterceptorHandler<V>) => void): void;
1008
+ }
1009
+
1010
+ export declare type InterceptorRejected = (error: any) => any;
1011
+
855
1012
  export declare enum isActiveColor {
856
1013
  inActive = "#4482ff",
857
1014
  active = "#3f4b5c"
858
1015
  }
859
1016
 
1017
+ /** True when `value` is the error produced by an aborted/cancelled request. */
1018
+ export declare function isCancel(value: any): boolean;
1019
+
1020
+ /** Type guard: true when `value` is a `FetchError`. */
1021
+ export declare function isFetchError(value: any): value is FetchError;
1022
+
860
1023
  export declare interface KeyValueParams {
861
1024
  [key: string]: string | string[] | number | number[] | undefined | Record<string, unknown>;
862
1025
  }