@cagatayfdn/flora-components 0.0.163 → 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.
@@ -1,7 +1,7 @@
1
1
  import { j as r } from "../../jsx-runtime-BcAkpsdy.js";
2
2
  import se, { useState as F, useEffect as O } from "react";
3
3
  import ne from "../NoResult/NoResult.js";
4
- import { c as m } from "../../index-BHf7G3IG.js";
4
+ import { c as C } from "../../index-BHf7G3IG.js";
5
5
  import { s as x } from "../../Table.module-rFa4-NE2.js";
6
6
  import { ThemeAppearance as z, AppearanceSpinner as D } from "../../enums/appearance.js";
7
7
  import G from "../Checkbox/Checkbox.js";
@@ -16,25 +16,25 @@ import { _ as W, k as pe } from "../../keys-B0bo5Q7o.js";
16
16
  import { _ as U, a as he, b as fe } from "../../_reduce-DsUCMz4O.js";
17
17
  import { _ as xe } from "../../Select-nhp2PiJK.js";
18
18
  function ue(l, t) {
19
- for (var n = 0, i = t.length, p = []; n < i; )
20
- l(t[n]) && (p[p.length] = t[n]), n += 1;
19
+ for (var o = 0, i = t.length, p = []; o < i; )
20
+ l(t[o]) && (p[p.length] = t[o]), o += 1;
21
21
  return p;
22
22
  }
23
23
  var ge = /* @__PURE__ */ function() {
24
- function l(t, n) {
25
- this.xf = n, this.f = t;
24
+ function l(t, o) {
25
+ this.xf = o, this.f = t;
26
26
  }
27
- return l.prototype["@@transducer/init"] = U.init, l.prototype["@@transducer/result"] = U.result, l.prototype["@@transducer/step"] = function(t, n) {
28
- return this.f(n) ? this.xf["@@transducer/step"](t, n) : t;
27
+ return l.prototype["@@transducer/init"] = U.init, l.prototype["@@transducer/result"] = U.result, l.prototype["@@transducer/step"] = function(t, o) {
28
+ return this.f(o) ? this.xf["@@transducer/step"](t, o) : t;
29
29
  }, l;
30
- }(), be = /* @__PURE__ */ W(function(t, n) {
31
- return new ge(t, n);
30
+ }(), je = /* @__PURE__ */ W(function(t, o) {
31
+ return new ge(t, o);
32
32
  });
33
- const je = be;
33
+ const be = je;
34
34
  var k = /* @__PURE__ */ W(
35
- /* @__PURE__ */ he(["filter"], je, function(l, t) {
36
- return xe(t) ? fe(function(n, i) {
37
- return l(t[i]) && (n[i] = t[i]), n;
35
+ /* @__PURE__ */ he(["filter"], be, function(l, t) {
36
+ return xe(t) ? fe(function(o, i) {
37
+ return l(t[i]) && (o[i] = t[i]), o;
38
38
  }, {}, pe(t)) : (
39
39
  // else
40
40
  ue(l, t)
@@ -44,7 +44,7 @@ var k = /* @__PURE__ */ W(
44
44
  const Oe = (l) => {
45
45
  const {
46
46
  columns: t = [],
47
- dataSource: n = [],
47
+ dataSource: o = [],
48
48
  totalCount: i,
49
49
  currentPage: p,
50
50
  className: X,
@@ -55,8 +55,8 @@ const Oe = (l) => {
55
55
  rowSelectionChange: c,
56
56
  pagerVisible: _,
57
57
  pagerOnChange: E,
58
- columnRenderer: R,
59
- pageSizeOnChange: y,
58
+ columnRenderer: y,
59
+ pageSizeOnChange: R,
60
60
  pageSize: v,
61
61
  headerVisible: P = !0,
62
62
  headerLeftItem: q,
@@ -64,22 +64,22 @@ const Oe = (l) => {
64
64
  isLoading: M = !1,
65
65
  footerAction: Q = !0,
66
66
  pageSizeVisible: Y = !0,
67
- appearance: j = z.LIGHT,
67
+ appearance: w = z.LIGHT,
68
68
  fixedHeader: Z,
69
69
  showItemsText: L,
70
70
  customHeader: H,
71
71
  selectedItems: T = [],
72
72
  scrollClass: I,
73
73
  disabledItems: g = [],
74
- expandable: o
75
- } = l, [h, w] = F(T), [$, C] = F([]), ee = (e) => {
76
- c && (e.target.checked ? (w(
77
- n.filter((s) => !u(s, g))
74
+ expandable: n
75
+ } = l, [h, m] = F(T), [$, j] = F([]), ee = (e) => {
76
+ c && (e.target.checked ? (m(
77
+ o.filter((s) => !u(s, g))
78
78
  ), c(
79
- n.filter((s) => !u(s, g))
80
- )) : (w([]), c([])));
79
+ o.filter((s) => !u(s, g))
80
+ )) : (m([]), c([])));
81
81
  }, re = (e, s) => {
82
- c && (e.target.checked ? (w([...h, s]), c([...h, s])) : (w(
82
+ c && (e.target.checked ? (m([...h, s]), c([...h, s])) : (m(
83
83
  k((a) => a.pk !== s.pk, h)
84
84
  ), c(
85
85
  k((a) => a.pk !== s.pk, h)
@@ -87,7 +87,7 @@ const Oe = (l) => {
87
87
  }, ae = (e, s) => {
88
88
  var d;
89
89
  const a = u(e, $);
90
- C(a ? (f) => k((N) => N !== e, f) : (f) => [...f, e]), (d = o == null ? void 0 : o.onExpand) == null || d.call(o, !a, s);
90
+ (n == null ? void 0 : n.expandStrategy) === "single" ? j(a ? [] : [e]) : j(a ? (f) => k((N) => N !== e, f) : (f) => [...f, e]), (d = n == null ? void 0 : n.onExpand) == null || d.call(n, !a, s);
91
91
  }, te = (e, s) => e == null ? void 0 : e.map((a, d) => /* @__PURE__ */ r.jsx(
92
92
  "td",
93
93
  {
@@ -95,7 +95,7 @@ const Oe = (l) => {
95
95
  onClick: (f) => {
96
96
  a != null && a.onClick && (a == null || a.onClick(f, s, a, d));
97
97
  },
98
- className: m(a.className, a.tdClassName),
98
+ className: C(a.className, a.tdClassName),
99
99
  children: a.render ? a.render(s[a.dataIndex], s) : s[a.dataIndex]
100
100
  },
101
101
  `col-${d}`
@@ -103,13 +103,13 @@ const Oe = (l) => {
103
103
  return O(() => {
104
104
  c && c(T.filter((e) => !u(e, g)));
105
105
  }, [h, g]), O(() => {
106
- C([]);
106
+ j([]);
107
107
  }, [p]), /* @__PURE__ */ r.jsxs(
108
108
  "div",
109
109
  {
110
110
  "data-testid": "table-container",
111
- className: m(x.wrapper, B, {
112
- [x[`${j}`]]: j
111
+ className: C(x.wrapper, B, {
112
+ [x[`${w}`]]: w
113
113
  }),
114
114
  children: [
115
115
  P && /* @__PURE__ */ r.jsx(
@@ -119,7 +119,7 @@ const Oe = (l) => {
119
119
  showItemsText: L,
120
120
  actionOnChange: S,
121
121
  pageSize: v,
122
- pageSizeOnChange: y,
122
+ pageSizeOnChange: R,
123
123
  pagerOnChange: E,
124
124
  pagerVisible: _,
125
125
  totalCount: i,
@@ -131,7 +131,7 @@ const Oe = (l) => {
131
131
  oe,
132
132
  {
133
133
  wrapperClass: x.tableLoading,
134
- appearance: j === z.LIGHT ? D.LIGHT : D.DARK
134
+ appearance: w === z.LIGHT ? D.LIGHT : D.DARK
135
135
  }
136
136
  ),
137
137
  H && H,
@@ -139,18 +139,18 @@ const Oe = (l) => {
139
139
  "table",
140
140
  {
141
141
  "data-testid": "table-content",
142
- className: m(x.table, X, {
142
+ className: C(x.table, X, {
143
143
  [x.fixed]: Z
144
144
  }),
145
145
  children: [
146
146
  /* @__PURE__ */ r.jsx("thead", { "data-testid": "table-head", children: /* @__PURE__ */ r.jsxs("tr", { "data-testid": "table-row", children: [
147
- o && /* @__PURE__ */ r.jsx("th", { className: "w-[48px]" }),
147
+ n && /* @__PURE__ */ r.jsx("th", { className: "w-[48px]" }),
148
148
  b && /* @__PURE__ */ r.jsx("th", { className: "w-[26px]", children: /* @__PURE__ */ r.jsx(
149
149
  G,
150
150
  {
151
151
  name: "selectAll",
152
- isDisabled: n.length === 0,
153
- checked: n.length > 0 && n.length === h.length,
152
+ isDisabled: o.length === 0,
153
+ checked: o.length > 0 && o.length === h.length,
154
154
  onChange: ee
155
155
  }
156
156
  ) }),
@@ -186,7 +186,7 @@ const Oe = (l) => {
186
186
  );
187
187
  })
188
188
  ] }) }),
189
- /* @__PURE__ */ r.jsx("tbody", { "data-testid": "table-body", children: n.length > 0 ? n.map((e, s) => {
189
+ /* @__PURE__ */ r.jsx("tbody", { "data-testid": "table-body", children: o.length > 0 ? o.map((e, s) => {
190
190
  const a = u(s, $);
191
191
  return /* @__PURE__ */ r.jsxs(se.Fragment, { children: [
192
192
  /* @__PURE__ */ r.jsxs(
@@ -194,20 +194,20 @@ const Oe = (l) => {
194
194
  {
195
195
  "data-testid": "table-row",
196
196
  onClick: () => {
197
- o && o.rowExpandable && o.rowExpandable(e) && ae(s, e);
197
+ n && n.rowExpandable && n.rowExpandable(e) && ae(s, e);
198
198
  },
199
- className: m({
200
- "cursor-pointer": o && o.rowExpandable ? o.rowExpandable(e) : o
199
+ className: C({
200
+ "cursor-pointer": n && n.rowExpandable ? n.rowExpandable(e) : n
201
201
  }),
202
202
  children: [
203
- o && /* @__PURE__ */ r.jsx("td", { children: /* @__PURE__ */ r.jsx(
203
+ n && /* @__PURE__ */ r.jsx("td", { children: /* @__PURE__ */ r.jsx(
204
204
  "span",
205
205
  {
206
206
  className: "inline-block transition-transform duration-200",
207
207
  style: {
208
208
  transform: a ? "rotate(90deg)" : "rotate(0deg)"
209
209
  },
210
- children: o.rowExpandable && o.rowExpandable(e) ? /* @__PURE__ */ r.jsx(ie, { name: ce.ChevronRight }) : null
210
+ children: n.rowExpandable && n.rowExpandable(e) ? /* @__PURE__ */ r.jsx(ie, { name: ce.ChevronRight }) : null
211
211
  }
212
212
  ) }),
213
213
  b && /* @__PURE__ */ r.jsx("td", { children: /* @__PURE__ */ r.jsx(
@@ -219,24 +219,24 @@ const Oe = (l) => {
219
219
  isDisabled: u(e, g)
220
220
  }
221
221
  ) }),
222
- R ? R(t, e) : te(t, e)
222
+ y ? y(t, e) : te(t, e)
223
223
  ]
224
224
  },
225
225
  `table-row-${s}`
226
226
  ),
227
- o && a && /* @__PURE__ */ r.jsx("tr", { children: /* @__PURE__ */ r.jsx(
227
+ n && a && /* @__PURE__ */ r.jsx("tr", { children: /* @__PURE__ */ r.jsx(
228
228
  "td",
229
229
  {
230
- colSpan: t.length + (b ? 1 : 0) + (o ? 1 : 0),
230
+ colSpan: t.length + (b ? 1 : 0) + (n ? 1 : 0),
231
231
  className: "p-0 border-0",
232
- children: o.expandedRowRender(e)
232
+ children: n.expandedRowRender(e)
233
233
  }
234
234
  ) })
235
235
  ] }, `row-${s}`);
236
236
  }) : /* @__PURE__ */ r.jsx("tr", { children: /* @__PURE__ */ r.jsx(
237
237
  "td",
238
238
  {
239
- colSpan: t.length + (b ? 1 : 0) + (o ? 1 : 0),
239
+ colSpan: t.length + (b ? 1 : 0) + (n ? 1 : 0),
240
240
  children: /* @__PURE__ */ r.jsx(ne, {})
241
241
  }
242
242
  ) }) })
@@ -251,7 +251,7 @@ const Oe = (l) => {
251
251
  showItemsText: L,
252
252
  actionOnChange: S,
253
253
  pageSize: v,
254
- pageSizeOnChange: y,
254
+ pageSizeOnChange: R,
255
255
  pagerOnChange: E,
256
256
  pagerVisible: _,
257
257
  pageSizeVisible: Y,
@@ -259,7 +259,7 @@ const Oe = (l) => {
259
259
  customItem: J,
260
260
  headerLeftItem: q,
261
261
  currentPage: p,
262
- appearance: j
262
+ appearance: w
263
263
  }
264
264
  )
265
265
  ]
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;
@@ -525,6 +555,7 @@ declare type ExpandableType = {
525
555
  expandedRowRender: (record: any) => ReactNode;
526
556
  rowExpandable?: (record: any) => boolean;
527
557
  onExpand?: (expanded: boolean, record: any) => void;
558
+ expandStrategy?: 'single' | 'multiple';
528
559
  };
529
560
 
530
561
  export declare type FetcherReturnType = {
@@ -533,8 +564,69 @@ export declare type FetcherReturnType = {
533
564
  startInterval: (...params: any) => void;
534
565
  };
535
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
+
536
596
  export declare type FetcherType = (...params: any) => void;
537
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
+
538
630
  export declare interface FetchLogsParams {
539
631
  applications: string[];
540
632
  scroll_mode?: 'older' | 'newer';
@@ -543,6 +635,47 @@ export declare interface FetchLogsParams {
543
635
  withoutPermission?: boolean;
544
636
  }
545
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
+
546
679
  export declare const FileUpload: React_2.ForwardRefExoticComponent<{
547
680
  type?: "number" | "email" | "search" | "text" | "url" | "tel" | "password" | "hidden" | undefined;
548
681
  id?: string | undefined;
@@ -851,11 +984,42 @@ export declare type InputProps = {
851
984
  textFillColor?: string;
852
985
  } & Omit<FormElementProps, 'value'> & Omit<EventProps<HTMLInputElement>, 'onMouseUp' | 'onMouseDown' | 'onMouseEnter' | 'onMouseLeave'>;
853
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
+
854
1012
  export declare enum isActiveColor {
855
1013
  inActive = "#4482ff",
856
1014
  active = "#3f4b5c"
857
1015
  }
858
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
+
859
1023
  export declare interface KeyValueParams {
860
1024
  [key: string]: string | string[] | number | number[] | undefined | Record<string, unknown>;
861
1025
  }