@caspeco/casper-ui-library 4.1.1 → 5.0.0

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 +1 @@
1
- {"version":3,"file":"paginator.composition.d.ts","sourceRoot":"","sources":["../../../lib/components/paginator/paginator.composition.tsx"],"names":[],"mappings":"AASA,eAAO,MAAM,cAAc,+CAyB1B,CAAC"}
1
+ {"version":3,"file":"paginator.composition.d.ts","sourceRoot":"","sources":["../../../lib/components/paginator/paginator.composition.tsx"],"names":[],"mappings":"AASA,eAAO,MAAM,cAAc,+CAgB1B,CAAC"}
@@ -1,23 +1,16 @@
1
- import { Locales } from './translations.js';
2
- export type PaginatorProps = {
3
- /** String to determine translations for the paginator */
4
- localeString: Locales;
5
- /** Array of options to pick a page size out of. Default is [10, 25, 50, 100] */
6
- pageSizeOptions?: number[];
7
- /** Number to display current page size */
8
- pageSize: number;
9
- /** Number to display current page index */
10
- pageIndex: number;
11
- /** Number to display current number of pages */
12
- pageCount: number;
13
- /** Boolean to disable button to go to the previous page */
14
- canPreviousPage: boolean;
15
- /** Boolean to disable button to go to the next page */
16
- canNextPage: boolean;
17
- /** Function to update the page size of the table */
18
- setPageSize: (pageSize: number) => void;
19
- /** Function to update the page index of the table */
20
- setPageIndex: (pageIndex: number) => void;
1
+ import { ThemeStyleProps } from '../../theme/index.js';
2
+ import { Locale } from './translations.js';
3
+ export type PaginatorProps = ThemeStyleProps & {
4
+ /** Which locale to use for translations */
5
+ locale: Locale;
6
+ /** The size of each page */
7
+ pageSize?: number;
8
+ /** The total number of items */
9
+ itemCount: number;
10
+ /** The current page index (turns component controlled) */
11
+ pageIndex?: number;
12
+ /** Invoked when the page index changes */
13
+ onPageChange?: (newPageIndex: number) => void;
21
14
  };
22
- export declare function Paginator({ localeString, pageSizeOptions, pageSize, pageIndex, pageCount, canPreviousPage, canNextPage, setPageSize, setPageIndex, }: PaginatorProps): import("react/jsx-runtime").JSX.Element;
15
+ export declare function Paginator({ locale, pageSize, itemCount, pageIndex: _pageIndex, onPageChange, ...rest }: PaginatorProps): import("react/jsx-runtime").JSX.Element;
23
16
  //# sourceMappingURL=paginator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"paginator.d.ts","sourceRoot":"","sources":["../../../lib/components/paginator/paginator.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,OAAO,EAAgB,MAAM,gBAAgB,CAAC;AAE5D,MAAM,MAAM,cAAc,GAAG;IAC5B,yDAAyD;IACzD,YAAY,EAAE,OAAO,CAAC;IACtB,gFAAgF;IAChF,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,2CAA2C;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,eAAe,EAAE,OAAO,CAAC;IACzB,uDAAuD;IACvD,WAAW,EAAE,OAAO,CAAC;IACrB,oDAAoD;IACpD,WAAW,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,qDAAqD;IACrD,YAAY,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1C,CAAC;AAEF,wBAAgB,SAAS,CAAC,EACzB,YAAY,EACZ,eAAmC,EACnC,QAAQ,EACR,SAAS,EACT,SAAS,EACT,eAAe,EACf,WAAW,EACX,WAAW,EACX,YAAY,GACZ,EAAE,cAAc,2CAiDhB"}
1
+ {"version":3,"file":"paginator.d.ts","sourceRoot":"","sources":["../../../lib/components/paginator/paginator.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,gBAAgB,CAAC;AAE3D,MAAM,MAAM,cAAc,GAAG,eAAe,GAAG;IAC9C,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC;IAEf,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,gCAAgC;IAChC,SAAS,EAAE,MAAM,CAAC;IAElB,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,0CAA0C;IAC1C,YAAY,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9C,CAAC;AAEF,wBAAgB,SAAS,CAAC,EACzB,MAAM,EACN,QAAa,EACb,SAAS,EACT,SAAS,EAAE,UAAU,EACrB,YAAY,EACZ,GAAG,IAAI,EACP,EAAE,cAAc,2CA6ChB"}
@@ -1,58 +1,47 @@
1
- import { jsxs as e, jsx as o } from "react/jsx-runtime";
2
- import { useStyleConfig as b, Box as i } from "@chakra-ui/react";
1
+ import { jsxs as i, jsx as e } from "react/jsx-runtime";
2
+ import { useControllableState as C, useStyleConfig as b, Box as s } from "@chakra-ui/react";
3
3
  import { translations as k } from "./translations.js";
4
- import { Select as p } from "../select/select.js";
5
- import { IconButton as l } from "../icon-button/icon-button.js";
6
- import { Icons as s } from "../icon/types.js";
7
- function _({
8
- localeString: c,
9
- pageSizeOptions: m = [10, 25, 50, 100],
10
- pageSize: u,
11
- pageIndex: t,
12
- pageCount: h,
13
- canPreviousPage: d,
14
- canNextPage: f,
15
- setPageSize: g,
16
- setPageIndex: a
4
+ import { IconButton as c } from "../icon-button/icon-button.js";
5
+ import { Icons as l } from "../icon/types.js";
6
+ function N({
7
+ locale: g,
8
+ pageSize: n = 10,
9
+ itemCount: o,
10
+ pageIndex: m,
11
+ onPageChange: d,
12
+ ...P
17
13
  }) {
18
- const v = b("Paginator"), n = k[c], C = () => {
19
- a(t - 1);
20
- }, P = () => {
21
- a(t + 1);
14
+ const [a, r] = C({
15
+ value: m,
16
+ defaultValue: 0,
17
+ onChange: d
18
+ }), x = b("Paginator"), t = k[g], u = a > 0, f = n > 0 && a < Math.ceil(o / n) - 1, h = a * n + 1, p = Math.max(Math.min(n * (a + 1), o), 1), I = () => {
19
+ r(a - 1);
20
+ }, v = () => {
21
+ r(a + 1);
22
22
  };
23
- return /* @__PURE__ */ e(i, { __css: v, children: [
24
- /* @__PURE__ */ o(i, { children: n.pageSize }),
25
- /* @__PURE__ */ o(i, { children: /* @__PURE__ */ o(
26
- p,
27
- {
28
- value: u,
29
- onChange: (r) => {
30
- g(Number(r.target.value));
31
- },
32
- children: m.map((r) => /* @__PURE__ */ o("option", { value: r, children: r }, r))
33
- }
34
- ) }),
35
- /* @__PURE__ */ o(i, { children: n.currentPage(t, h) }),
36
- /* @__PURE__ */ e(i, { children: [
37
- /* @__PURE__ */ o(
38
- l,
23
+ return /* @__PURE__ */ i(s, { __css: x, ...P, children: [
24
+ /* @__PURE__ */ e(s, { children: t.currentPage(h, p, o) }),
25
+ /* @__PURE__ */ i(s, { children: [
26
+ /* @__PURE__ */ e(
27
+ c,
39
28
  {
40
- icon: s.Back,
29
+ icon: l.Back,
41
30
  size: "md",
42
31
  variant: "ghost",
43
- "aria-label": n.previousPage,
44
- onClick: C,
45
- isDisabled: !d
32
+ "aria-label": t.previousPage,
33
+ onClick: I,
34
+ isDisabled: !u
46
35
  }
47
36
  ),
48
- /* @__PURE__ */ o(
49
- l,
37
+ /* @__PURE__ */ e(
38
+ c,
50
39
  {
51
- icon: s.Forward,
40
+ icon: l.Forward,
52
41
  size: "md",
53
42
  variant: "ghost",
54
- "aria-label": n.nextPage,
55
- onClick: P,
43
+ "aria-label": t.nextPage,
44
+ onClick: v,
56
45
  isDisabled: !f
57
46
  }
58
47
  )
@@ -60,5 +49,5 @@ function _({
60
49
  ] });
61
50
  }
62
51
  export {
63
- _ as Paginator
52
+ N as Paginator
64
53
  };
@@ -1,34 +1,9 @@
1
- export type Locales = "en-US" | "nb-NO" | "da-DK" | "sv-SE" | "en-GB";
2
- export declare const translations: {
3
- "sv-SE": {
4
- pageSize: string;
5
- currentPage: (pageIndex: number, pageCount: number) => string;
6
- previousPage: string;
7
- nextPage: string;
8
- };
9
- "en-US": {
10
- pageSize: string;
11
- currentPage: (pageIndex: number, pageCount: number) => string;
12
- previousPage: string;
13
- nextPage: string;
14
- };
15
- "en-GB": {
16
- pageSize: string;
17
- currentPage: (pageIndex: number, pageCount: number) => string;
18
- previousPage: string;
19
- nextPage: string;
20
- };
21
- "nb-NO": {
22
- pageSize: string;
23
- currentPage: (pageIndex: number, pageCount: number) => string;
24
- previousPage: string;
25
- nextPage: string;
26
- };
27
- "da-DK": {
28
- pageSize: string;
29
- currentPage: (pageIndex: number, pageCount: number) => string;
30
- previousPage: string;
31
- nextPage: string;
32
- };
33
- };
1
+ export type Locale = "en-US" | "nb-NO" | "da-DK" | "sv-SE" | "en-GB";
2
+ interface TranslationObject {
3
+ currentPage: (start: number, end: number, itemCount: number) => string;
4
+ previousPage: string;
5
+ nextPage: string;
6
+ }
7
+ export declare const translations: Record<Locale, TranslationObject>;
8
+ export {};
34
9
  //# sourceMappingURL=translations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../lib/components/paginator/translations.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;AAStE,eAAO,MAAM,YAAY;;;iCAGE,MAAM,aAAa,MAAM;;;;;;iCAR1B,MAAM,aAAa,MAAM;;;;;;iCAAzB,MAAM,aAAa,MAAM;;;;;;iCAgBxB,MAAM,aAAa,MAAM;;;;;;iCAMzB,MAAM,aAAa,MAAM;;;;CAInD,CAAC"}
1
+ {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../lib/components/paginator/translations.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;AAErE,UAAU,iBAAiB;IAC1B,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;IACvE,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CACjB;AAQD,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAkB1D,CAAC"}
@@ -1,26 +1,22 @@
1
- const i = {
2
- pageSize: "Rows per page",
3
- currentPage: (e, a) => `Page ${e + 1} of ${a}`,
1
+ const s = {
2
+ currentPage: (e, a, r) => `${e}-${a} of ${r}`,
4
3
  previousPage: "Previous page",
5
4
  nextPage: "Next page"
6
5
  }, g = {
7
6
  "sv-SE": {
8
- pageSize: "Antal per sida",
9
- currentPage: (e, a) => `Sida ${e + 1} av ${a}`,
7
+ currentPage: (e, a, r) => `${e}-${a} av ${r}`,
10
8
  previousPage: "Föregående sida",
11
9
  nextPage: "Nästa sida"
12
10
  },
13
- "en-US": i,
14
- "en-GB": i,
11
+ "en-US": s,
12
+ "en-GB": s,
15
13
  "nb-NO": {
16
- pageSize: "Antall per side",
17
- currentPage: (e, a) => `Side ${e + 1} av ${a}`,
14
+ currentPage: (e, a, r) => `${e}-${a} av ${r}`,
18
15
  previousPage: "Forrige side",
19
16
  nextPage: "Neste side"
20
17
  },
21
18
  "da-DK": {
22
- pageSize: "Antal per side",
23
- currentPage: (e, a) => `Side ${e + 1} af ${a}`,
19
+ currentPage: (e, a, r) => `${e}-${a} af ${r}`,
24
20
  previousPage: "Forrige side",
25
21
  nextPage: "Næste side"
26
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"table-context.d.ts","sourceRoot":"","sources":["../../../lib/components/table/table-context.tsx"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,MAAM,EACX,KAAK,SAAS,EACd,KAAK,aAAa,EAKlB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,KAAK,EAGV,KAAK,eAAe,EACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAiB,KAAK,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AC,EAAE,aAAa,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IACvG,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAClD,QAAQ,EAAE,aAAa,CAAC;IACxB,OAAO,EAAE,YAAY,CAAC;IACtB,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,CAAC;IAC/D,WAAW,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC,CAAC;IACjE,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,eAAe,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1D,YAAY,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAC7C,gBAAgB,EAAE,eAAe,CAAC;CAClC;AAED,eAAO,MAAM,YAAY,4DAAyD,CAAC;AAEnF,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,YAAY,CAAC,CAAC,CAAC,EAAE,iRAgBtD,sBAAsB,CAAC,CAAC,CAAC,4CAmG3B,CAAC"}
@@ -1,45 +1,49 @@
1
1
  import { jsx as z } from "react/jsx-runtime";
2
+ import { useControllableState as u } from "@chakra-ui/react";
2
3
  import { useReactTable as A } from "../../node_modules/@tanstack/react-table/build/lib/index.js";
3
4
  import { useState as i, useEffect as B, useCallback as w, createContext as D } from "react";
4
- import { useControllableState as S } from "./use-controllable-state.js";
5
5
  import { getFilteredRowModel as G, getSortedRowModel as H, getExpandedRowModel as J, getCoreRowModel as K } from "../../node_modules/@tanstack/table-core/build/lib/index.js";
6
6
  const L = D(null), Y = ({
7
7
  data: s,
8
8
  columns: C,
9
- children: R,
10
- expandedState: m,
11
- localeString: u,
12
- initialExpandedState: r = {},
13
- initialBreakingContentState: d = {},
9
+ children: S,
10
+ expandedState: R,
11
+ localeString: m,
12
+ initialExpandedState: a = {},
13
+ initialBreakingContentState: r = {},
14
14
  initialColumnVisibilityState: p = {},
15
15
  columnVisibilityState: x,
16
16
  onColumnVisibilityChange: M,
17
- onExpandedChange: c,
18
- onBreakingContentChange: y,
19
- onFilterColumn: h,
20
- id: E,
21
- customRowIndication: l
17
+ onExpandedChange: d,
18
+ onBreakingContentChange: h,
19
+ onFilterColumn: y,
20
+ id: v,
21
+ customRowIndication: n
22
22
  }) => {
23
- const [t, b] = S(m, c, r), [n, v] = S(
24
- x,
25
- M,
26
- p
27
- ), [a, T] = i([]), [k, F] = i(
28
- d || {}
23
+ const [t, c] = u({
24
+ value: R,
25
+ onChange: d,
26
+ defaultValue: a
27
+ }), [l, E] = u({
28
+ value: x,
29
+ onChange: M,
30
+ defaultValue: p
31
+ }), [b, V] = i([]), [T, k] = i(
32
+ r || {}
29
33
  ), [f, g] = i({});
30
34
  B(() => {
31
- l && g(l);
32
- }, [l]);
33
- const P = w(
35
+ n && g(n);
36
+ }, [n]);
37
+ const F = w(
34
38
  (e) => {
35
39
  let o;
36
- typeof e == "function" ? o = e(n) : o = e, v(o);
40
+ typeof e == "function" ? o = e(l) : o = e, E(o);
37
41
  },
38
- [n]
39
- ), V = w(
42
+ [l]
43
+ ), P = w(
40
44
  (e) => {
41
45
  let o;
42
- typeof e == "function" ? o = e(t) : o = e, b(o);
46
+ typeof e == "function" ? o = e(t) : o = e, c(o);
43
47
  },
44
48
  [t]
45
49
  ), j = A({
@@ -49,39 +53,39 @@ const L = D(null), Y = ({
49
53
  getExpandedRowModel: J(),
50
54
  getSortedRowModel: H(),
51
55
  getFilteredRowModel: G(),
52
- onColumnVisibilityChange: P,
53
- onExpandedChange: V,
56
+ onColumnVisibilityChange: F,
57
+ onExpandedChange: P,
54
58
  getSubRows: (e) => e.subRows,
55
59
  enableSubRowSelection: !0,
56
60
  enableMultiRowSelection: !1,
57
61
  enableRowSelection: !0,
58
62
  state: {
59
- sorting: a,
60
- columnVisibility: n,
63
+ sorting: b,
64
+ columnVisibility: l,
61
65
  expanded: t,
62
66
  rowSelection: f
63
67
  }
64
68
  }), q = {
65
69
  data: s,
66
70
  table: j,
67
- initialExpandedState: r,
68
- initialBreakingContentState: d,
69
- localeString: u,
70
- onExpandedChange: c,
71
+ initialExpandedState: a,
72
+ initialBreakingContentState: r,
73
+ localeString: m,
74
+ onExpandedChange: d,
71
75
  expanded: t,
72
- sorting: a,
73
- setSorting: T,
74
- setExpanded: b,
75
- breakingContentState: k,
76
- setBreakingContentState: F,
77
- onBreakingContentChange: y,
78
- onFilterColumn: h,
79
- id: E,
76
+ sorting: b,
77
+ setSorting: V,
78
+ setExpanded: c,
79
+ breakingContentState: T,
80
+ setBreakingContentState: k,
81
+ onBreakingContentChange: h,
82
+ onFilterColumn: y,
83
+ id: v,
80
84
  setRowSelection: g,
81
85
  rowSelection: f,
82
- columnVisibility: n
86
+ columnVisibility: l
83
87
  };
84
- return /* @__PURE__ */ z(L.Provider, { value: q, children: R });
88
+ return /* @__PURE__ */ z(L.Provider, { value: q, children: S });
85
89
  };
86
90
  export {
87
91
  L as TableContext,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caspeco/casper-ui-library",
3
- "version": "4.1.1",
3
+ "version": "5.0.0",
4
4
  "prettier": "@caspeco/prettier-config",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -1,28 +0,0 @@
1
- /**
2
- * A custom React hook for managing state that can be either controlled by a parent component or managed internally.
3
- *
4
- * @param value - The controlled value provided by the parent component. If `undefined`, the hook operates in uncontrolled mode and manages the state internally.
5
- * @param changeHandler - Optional callback invoked when the state changes. Useful for notifying the parent component of state changes in controlled mode.
6
- * @param initialValue - The initial state value when operating in uncontrolled mode.
7
- *
8
- * @returns A tuple containing:
9
- * - The current state value (`T`).
10
- * - A function to update the state (`setValue`).
11
- * In controlled mode, calling `setValue` invokes `changeHandler` without updating internal state.
12
- * In uncontrolled mode, `setValue` updates the internal state.
13
- *
14
- * @example
15
- * // Uncontrolled component usage:
16
- * const [value, setValue] = useControllableState(undefined, props.onChange, 'default');
17
- * setValue('new value');
18
- * // props.onChange('new value') is called
19
- * console.log(value) // 'new value'
20
- *
21
- * // Controlled component usage:
22
- * const [value, setValue] = useControllableState(props.value, props.onChange, 'default');
23
- * setValue('new value');
24
- * // props.onChange('new value') is called
25
- * console.log(value) // 'default'
26
- */
27
- export declare function useControllableState<T>(value: T extends Function ? never : T | undefined, changeHandler: ((newValue: T) => void) | undefined, initialValue: T): [T, React.Dispatch<React.SetStateAction<T>>];
28
- //# sourceMappingURL=use-controllable-state.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-controllable-state.d.ts","sourceRoot":"","sources":["../../../lib/components/table/use-controllable-state.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAErC,KAAK,EAAE,CAAC,SAAS,QAAQ,GAAG,KAAK,GAAG,CAAC,GAAG,SAAS,EACjD,aAAa,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,KAAK,IAAI,CAAC,GAAG,SAAS,EAClD,YAAY,EAAE,CAAC,GACb,CAAC,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAgB9C"}
@@ -1,12 +0,0 @@
1
- import { useState as s } from "react";
2
- function a(o, e, n) {
3
- const [r, l] = s(n);
4
- return [o !== void 0 ? o : r, (t) => {
5
- if (typeof t == "function")
6
- throw new Error("Function as argument is not supported.");
7
- l(t), e?.(t);
8
- }];
9
- }
10
- export {
11
- a as useControllableState
12
- };