@caspeco/casper-ui-library 9.1.0 → 9.2.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,7 +1,21 @@
1
+ type TableToolbarSettingsProps = {
2
+ /**
3
+ * The current selected value in the Rows per page section.
4
+ * If provided, the rows-per-page selection becomes controlled and should be updated through `onPageSizeChange`.
5
+ * Note: This does not change the number of rendered rows automatically; handle that in your own table or pagination logic.
6
+ */
7
+ pageSize?: number;
8
+ /**
9
+ * Called when a new option is selected in the Rows per page section.
10
+ * Receives the selected number of rows to display per page.
11
+ */
12
+ onPageSizeChange?: (newPageSize: number) => void;
13
+ };
1
14
  /**
2
15
  * Settings menu for column visibility and breaking content. Use inside TableToolbar.
3
16
  *
4
17
  * @see Docs https://caspeco.github.io/casper-ui-library/components/table#column-visibility-and-how-to-store-it
5
18
  */
6
- export declare const TableToolbarSettings: import('react').MemoExoticComponent<() => import("react/jsx-runtime").JSX.Element>;
19
+ export declare const TableToolbarSettings: import('react').MemoExoticComponent<({ pageSize, onPageSizeChange }: TableToolbarSettingsProps) => import("react/jsx-runtime").JSX.Element>;
20
+ export {};
7
21
  //# sourceMappingURL=table-toolbar-settings.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"table-toolbar-settings.d.ts","sourceRoot":"","sources":["../../../lib/components/table/table-toolbar-settings.tsx"],"names":[],"mappings":"AA8EA;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,oFAAkC,CAAC"}
1
+ {"version":3,"file":"table-toolbar-settings.d.ts","sourceRoot":"","sources":["../../../lib/components/table/table-toolbar-settings.tsx"],"names":[],"mappings":"AAaA,KAAK,yBAAyB,GAAG;IAChC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;CACjD,CAAC;AAiGF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,uEApGkC,yBAAyB,6CAoGzB,CAAC"}
@@ -1,59 +1,86 @@
1
- import { jsx as n, jsxs as r, Fragment as b } from "react/jsx-runtime";
2
- import { Flex as C, Portal as g, Box as p } from "@chakra-ui/react";
3
- import { memo as d, useCallback as a } from "react";
4
- import { useTableContext as u } from "./table-context.js";
5
- import { translations as f } from "./translations.js";
6
- import { Menu as k } from "../menu/menu.js";
7
- import { MenuButton as S } from "../menu/menu-button.js";
8
- import { SlidersIcon as x } from "../icon/icons/sliders-icon.js";
9
- import { MenuList as T } from "../menu/menu-list.js";
10
- import { Text as I } from "../text/text.js";
11
- import { MenuItem as s } from "../menu/menu-item.js";
12
- import { GripMoreIcon as B } from "../icon/icons/grip-more-icon.js";
13
- import { Checkbox as M } from "../checkbox/checkbox.js";
14
- import { MenuDivider as v } from "../menu/menu-divider.js";
15
- import { Switch as w } from "../switch/switch.js";
16
- import { ThemeIconSizeVariable as y, ThemeSpaceVariable as m, ThemeColorVariable as V } from "../../theme/theme-types.js";
17
- const j = () => {
18
- const e = u(), l = f[e.localeString], c = a(() => e.table.getAllColumns().length === Object.keys(e.breakingContentState).length && !Object.values(e.breakingContentState).includes(!1), [e.breakingContentState, e.table]), h = a(
19
- ({ checked: t }) => {
20
- const o = {};
21
- e.table.getAllColumns().forEach((i) => {
22
- o[i.id] = t;
23
- }), e.setBreakingContentState(o), e.onBreakingContentChange?.(o);
1
+ import { jsx as t, jsxs as o, Fragment as u } from "react/jsx-runtime";
2
+ import { Flex as S, Portal as k, Box as T } from "@chakra-ui/react";
3
+ import { memo as x, useCallback as h } from "react";
4
+ import { useTableContext as I } from "./table-context.js";
5
+ import { DEFAULT_PAGE_SIZE_OPTIONS as v } from "./table.constants.js";
6
+ import { translations as B } from "./translations.js";
7
+ import { Menu as M } from "../menu/menu.js";
8
+ import { MenuButton as w } from "../menu/menu-button.js";
9
+ import { SlidersIcon as y } from "../icon/icons/sliders-icon.js";
10
+ import { MenuList as O } from "../menu/menu-list.js";
11
+ import { Text as d } from "../text/text.js";
12
+ import { MenuItem as i } from "../menu/menu-item.js";
13
+ import { GripMoreIcon as V } from "../icon/icons/grip-more-icon.js";
14
+ import { Checkbox as A } from "../checkbox/checkbox.js";
15
+ import { MenuDivider as b } from "../menu/menu-divider.js";
16
+ import { RadioGroup as F } from "../radio/radio-group.js";
17
+ import { Radio as G } from "../radio/radio.js";
18
+ import { Switch as P } from "../switch/switch.js";
19
+ import { ThemeIconSizeVariable as j, ThemeSpaceVariable as a, ThemeColorVariable as g } from "../../theme/theme-types.js";
20
+ const D = ({ pageSize: m, onPageSizeChange: s }) => {
21
+ const r = I(), l = B[r.localeString], p = !!s && Number.isInteger(m), C = h(() => r.table.getAllColumns().length === Object.keys(r.breakingContentState).length && !Object.values(r.breakingContentState).includes(!1), [r.breakingContentState, r.table]), f = h(
22
+ ({ checked: e }) => {
23
+ const n = {};
24
+ r.table.getAllColumns().forEach((c) => {
25
+ n[c.id] = e;
26
+ }), r.setBreakingContentState(n), r.onBreakingContentChange?.(n);
24
27
  },
25
- [e]
28
+ [r]
26
29
  );
27
- return /* @__PURE__ */ n(C, { children: /* @__PURE__ */ r(k, { closeOnSelect: !1, isLazy: !0, children: [
28
- /* @__PURE__ */ n(S, { "aria-label": l.presets, variant: "ghost", p: "unset", w: "40px", h: "40px", children: /* @__PURE__ */ n(x, { size: y.Medium }) }),
29
- /* @__PURE__ */ n(g, { children: /* @__PURE__ */ r(T, { children: [
30
- /* @__PURE__ */ n(
31
- I,
30
+ return /* @__PURE__ */ t(S, { children: /* @__PURE__ */ o(M, { closeOnSelect: !1, isLazy: !0, children: [
31
+ /* @__PURE__ */ t(w, { "aria-label": l.presets, variant: "ghost", p: "unset", w: "40px", h: "40px", children: /* @__PURE__ */ t(y, { size: j.Medium }) }),
32
+ /* @__PURE__ */ t(k, { children: /* @__PURE__ */ o(O, { children: [
33
+ /* @__PURE__ */ t(
34
+ d,
32
35
  {
33
- color: V.OnSurfaceSubdued,
34
- py: m.Small,
35
- px: m.Medium,
36
+ color: g.OnSurfaceSubdued,
37
+ py: a.Small,
38
+ px: a.Medium,
36
39
  children: l.showColumns
37
40
  }
38
41
  ),
39
- /* @__PURE__ */ n(p, { maxHeight: "320px", overflowY: "auto", children: e.table.getAllLeafColumns().filter((t) => t.getCanHide()).map((t) => /* @__PURE__ */ r(s, { itemType: "checkbox", leftIcon: B, value: t.id, children: [
40
- /* @__PURE__ */ n(b, { children: t.columnDef.header }),
41
- /* @__PURE__ */ n(
42
- M,
42
+ /* @__PURE__ */ t(T, { maxHeight: "320px", overflowY: "auto", children: r.table.getAllLeafColumns().filter((e) => e.getCanHide()).map((e) => /* @__PURE__ */ o(i, { itemType: "checkbox", leftIcon: V, value: e.id, children: [
43
+ /* @__PURE__ */ t(u, { children: e.columnDef.header }),
44
+ /* @__PURE__ */ t(
45
+ A,
43
46
  {
44
- isChecked: t.getIsVisible(),
45
- onCheckedChange: ({ checked: o }) => t.toggleVisibility(!!o)
47
+ isChecked: e.getIsVisible(),
48
+ onCheckedChange: ({ checked: n }) => e.toggleVisibility(!!n)
46
49
  }
47
50
  )
48
- ] }, t.id)) }),
49
- /* @__PURE__ */ n(v, {}),
50
- /* @__PURE__ */ r(s, { itemType: "switch", value: "breakingContent", children: [
51
+ ] }, e.id)) }),
52
+ /* @__PURE__ */ t(b, {}),
53
+ p && /* @__PURE__ */ o(u, { children: [
54
+ /* @__PURE__ */ t(
55
+ d,
56
+ {
57
+ color: g.OnSurfaceSubdued,
58
+ py: a.Small,
59
+ px: a.Medium,
60
+ children: l.rowsPerPage
61
+ }
62
+ ),
63
+ /* @__PURE__ */ t(
64
+ F,
65
+ {
66
+ gap: "unset",
67
+ value: String(m),
68
+ onValueChange: (e) => s?.(Number(e.value)),
69
+ children: v.map((e) => /* @__PURE__ */ o(i, { itemType: "radio", value: String(e), children: [
70
+ l.numberOfRows.replace("{count}", String(e)),
71
+ /* @__PURE__ */ t(G, { value: String(e) })
72
+ ] }, e))
73
+ }
74
+ ),
75
+ /* @__PURE__ */ t(b, {})
76
+ ] }),
77
+ /* @__PURE__ */ o(i, { itemType: "switch", value: "breakingContent", children: [
51
78
  l.breakingContent,
52
- /* @__PURE__ */ n(w, { onCheckedChange: h, isChecked: c() })
79
+ /* @__PURE__ */ t(P, { onCheckedChange: f, isChecked: C() })
53
80
  ] })
54
81
  ] }) })
55
82
  ] }) });
56
- }, R = d(j);
83
+ }, re = x(D);
57
84
  export {
58
- R as TableToolbarSettings
85
+ re as TableToolbarSettings
59
86
  };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=table-toolbar-settings.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table-toolbar-settings.spec.d.ts","sourceRoot":"","sources":["../../../lib/components/table/table-toolbar-settings.spec.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export declare const DEFAULT_PAGE_SIZE_OPTIONS: readonly [10, 25, 50, 100];
2
+ //# sourceMappingURL=table.constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table.constants.d.ts","sourceRoot":"","sources":["../../../lib/components/table/table.constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yBAAyB,4BAA6B,CAAC"}
@@ -0,0 +1,4 @@
1
+ const E = [10, 25, 50, 100];
2
+ export {
3
+ E as DEFAULT_PAGE_SIZE_OPTIONS
4
+ };
@@ -23,6 +23,8 @@ export declare const translations: {
23
23
  filterReset: string;
24
24
  selected: string;
25
25
  selectedSingular: string;
26
+ rowsPerPage: string;
27
+ numberOfRows: string;
26
28
  action: string;
27
29
  deleteSelectedRows: string;
28
30
  };
@@ -49,6 +51,8 @@ export declare const translations: {
49
51
  filterReset: string;
50
52
  selected: string;
51
53
  selectedSingular: string;
54
+ rowsPerPage: string;
55
+ numberOfRows: string;
52
56
  action: string;
53
57
  deleteSelectedRows: string;
54
58
  };
@@ -75,6 +79,8 @@ export declare const translations: {
75
79
  filterReset: string;
76
80
  selected: string;
77
81
  selectedSingular: string;
82
+ rowsPerPage: string;
83
+ numberOfRows: string;
78
84
  action: string;
79
85
  deleteSelectedRows: string;
80
86
  };
@@ -101,6 +107,8 @@ export declare const translations: {
101
107
  filterReset: string;
102
108
  selected: string;
103
109
  selectedSingular: string;
110
+ rowsPerPage: string;
111
+ numberOfRows: string;
104
112
  action: string;
105
113
  deleteSelectedRows: string;
106
114
  };
@@ -127,6 +135,8 @@ export declare const translations: {
127
135
  filterReset: string;
128
136
  selected: string;
129
137
  selectedSingular: string;
138
+ rowsPerPage: string;
139
+ numberOfRows: string;
130
140
  action: string;
131
141
  deleteSelectedRows: string;
132
142
  };
@@ -153,6 +163,8 @@ export declare const translations: {
153
163
  filterReset: string;
154
164
  selected: string;
155
165
  selectedSingular: string;
166
+ rowsPerPage: string;
167
+ numberOfRows: string;
156
168
  action: string;
157
169
  deleteSelectedRows: string;
158
170
  };
@@ -179,6 +191,8 @@ export declare const translations: {
179
191
  filterReset: string;
180
192
  selected: string;
181
193
  selectedSingular: string;
194
+ rowsPerPage: string;
195
+ numberOfRows: string;
182
196
  action: string;
183
197
  deleteSelectedRows: string;
184
198
  };
@@ -1 +1 @@
1
- {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../lib/components/table/translations.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;AA6B1F,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqIxB,CAAC"}
1
+ {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../lib/components/table/translations.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;AA+B1F,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+IxB,CAAC"}
@@ -21,6 +21,8 @@ const e = {
21
21
  filterReset: "Clear filter",
22
22
  selected: "{count} selected",
23
23
  selectedSingular: "{count} selected",
24
+ rowsPerPage: "Rows per page",
25
+ numberOfRows: "{count} rows",
24
26
  action: "Action",
25
27
  deleteSelectedRows: "Delete selected rows"
26
28
  }, n = {
@@ -47,6 +49,8 @@ const e = {
47
49
  filterReset: "Rensa filter",
48
50
  selected: "{count} valda",
49
51
  selectedSingular: "{count} vald",
52
+ rowsPerPage: "Rader per sida",
53
+ numberOfRows: "{count} rader",
50
54
  action: "Åtgärd",
51
55
  deleteSelectedRows: "Ta bort valda rader"
52
56
  },
@@ -75,6 +79,8 @@ const e = {
75
79
  filterReset: "Fjern filter",
76
80
  selected: "{count} valgte",
77
81
  selectedSingular: "{count} valgt",
82
+ rowsPerPage: "Rader per side",
83
+ numberOfRows: "{count} rader",
78
84
  action: "Handling",
79
85
  deleteSelectedRows: "Fjern valgte rader"
80
86
  },
@@ -101,6 +107,8 @@ const e = {
101
107
  filterReset: "Fjern filter",
102
108
  selected: "{count} valgte",
103
109
  selectedSingular: "{count} valgt",
110
+ rowsPerPage: "Rækker per side",
111
+ numberOfRows: "{count} rækker",
104
112
  action: "Handling",
105
113
  deleteSelectedRows: "Fjern valgte rækker"
106
114
  },
@@ -127,6 +135,8 @@ const e = {
127
135
  filterReset: "Effacer le filtre",
128
136
  selected: "{count} sélectionnées",
129
137
  selectedSingular: "{count} sélectionnée",
138
+ rowsPerPage: "Lignes par page",
139
+ numberOfRows: "{count} lignes",
130
140
  action: "Action",
131
141
  deleteSelectedRows: "Supprimer les lignes sélectionnées"
132
142
  },
@@ -153,6 +163,8 @@ const e = {
153
163
  filterReset: "Filter wissen",
154
164
  selected: "{count} geselecteerd",
155
165
  selectedSingular: "{count} geselecteerd",
166
+ rowsPerPage: "Rijen per pagina",
167
+ numberOfRows: "{count} rijen",
156
168
  action: "Actie",
157
169
  deleteSelectedRows: "Verwijder geselecteerde rijen"
158
170
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caspeco/casper-ui-library",
3
- "version": "9.1.0",
3
+ "version": "9.2.0",
4
4
  "prettier": "@caspeco/prettier-config",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "devDependencies": {
40
40
  "@arethetypeswrong/cli": "^0.18.2",
41
- "@caspeco/eslint-config-react": "^5.1.0",
41
+ "@caspeco/eslint-config-react": "^5.2.1",
42
42
  "@caspeco/prettier-config": "^1.0.7",
43
43
  "@chakra-ui/cli": "^3.35.0",
44
44
  "@eslint/js": "^9.39.2",
@@ -51,11 +51,11 @@
51
51
  "eslint": "^9.39.2",
52
52
  "eslint-plugin-react-hooks": "^7.1.1",
53
53
  "eslint-plugin-react-refresh": "^0.5.2",
54
- "globals": "^17.5.0",
54
+ "globals": "^17.6.0",
55
55
  "rimraf": "^6.1.3",
56
- "tsc-alias": "^1.8.16",
56
+ "tsc-alias": "^1.8.17",
57
57
  "typescript": "~6.0.3",
58
- "typescript-eslint": "^8.59.0",
58
+ "typescript-eslint": "^8.59.1",
59
59
  "vite": "^7.3.1",
60
60
  "vite-plugin-dts": "^4.5.4",
61
61
  "vite-tsconfig-paths": "^6.1.1",