@caspeco/casper-ui-library 7.9.3 → 7.10.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.
@@ -10,6 +10,10 @@ export type TableToolbarProps = {
10
10
  * Use this to filter your data. Optional.
11
11
  */
12
12
  onSearch?: (e: ChangeEvent<HTMLInputElement>) => void;
13
+ /**
14
+ * DefaultValue for the search input, e.g. if you have a persisted filter state you want to hydrate after refresh or routing.
15
+ */
16
+ defaultValue?: string;
13
17
  /**
14
18
  * Use this to add a new item. Optional.
15
19
  */
@@ -19,7 +23,7 @@ export type TableToolbarProps = {
19
23
  */
20
24
  actionMenu?: React.ReactElement<ComponentProps<typeof MenuList>, typeof MenuList>;
21
25
  };
22
- declare const TableToolbarInner: ({ tableName, onSearch, onAddNewItem, actionMenu, ...props }: TableToolbarProps & ThemeStyleProps) => import("react/jsx-runtime").JSX.Element;
26
+ declare const TableToolbarInner: ({ tableName, onSearch, defaultValue, onAddNewItem, actionMenu, ...props }: TableToolbarProps & ThemeStyleProps) => import("react/jsx-runtime").JSX.Element;
23
27
  export declare const TableToolbar: typeof TableToolbarInner;
24
28
  export {};
25
29
  //# sourceMappingURL=table-toolbar.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"table-toolbar.d.ts","sourceRoot":"","sources":["../../../lib/components/table/table-toolbar.tsx"],"names":[],"mappings":"AAIA,OAAO,EAA2D,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGtG,OAAO,EAMN,KAAK,eAAe,EACpB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAA8B,KAAK,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AAI1F,MAAM,MAAM,iBAAiB,GAAG;IAC/B;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IACtD;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B;;OAEG;IACH,UAAU,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,cAAc,CAAC,OAAO,QAAQ,CAAC,EAAE,OAAO,QAAQ,CAAC,CAAC;CAClF,CAAC;AAEF,QAAA,MAAM,iBAAiB,GAAI,6DAMxB,iBAAiB,GAAG,eAAe,4CA4KrC,CAAC;AAEF,eAAO,MAAM,YAAY,EAA8B,OAAO,iBAAiB,CAAC"}
1
+ {"version":3,"file":"table-toolbar.d.ts","sourceRoot":"","sources":["../../../lib/components/table/table-toolbar.tsx"],"names":[],"mappings":"AAIA,OAAO,EAA2D,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGtG,OAAO,EAMN,KAAK,eAAe,EACpB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAA8B,KAAK,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AAI1F,MAAM,MAAM,iBAAiB,GAAG;IAC/B;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IACtD;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B;;OAEG;IACH,UAAU,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,cAAc,CAAC,OAAO,QAAQ,CAAC,EAAE,OAAO,QAAQ,CAAC,CAAC;CAClF,CAAC;AAEF,QAAA,MAAM,iBAAiB,GAAI,2EAOxB,iBAAiB,GAAG,eAAe,4CA6KrC,CAAC;AAEF,eAAO,MAAM,YAAY,EAA8B,OAAO,iBAAiB,CAAC"}
@@ -1,83 +1,85 @@
1
- import { jsx as e, jsxs as o, Fragment as v } from "react/jsx-runtime";
2
- import { useMediaQuery as A, Flex as a, Portal as H, Box as M } from "@chakra-ui/react";
3
- import { memo as O, useCallback as l, useMemo as x } from "react";
4
- import { useTableContext as D } from "./table-context.js";
5
- import { translations as G } from "./translations.js";
6
- import { Input as E } from "../input/input.js";
7
- import { Icon as y } from "../icon/icon.js";
1
+ import { jsx as e, jsxs as o, Fragment as A } from "react/jsx-runtime";
2
+ import { useMediaQuery as H, Flex as a, Portal as O, Box as x } from "@chakra-ui/react";
3
+ import { memo as D, useCallback as l, useMemo as y } from "react";
4
+ import { useTableContext as G } from "./table-context.js";
5
+ import { translations as E } from "./translations.js";
6
+ import { Input as P } from "../input/input.js";
7
+ import { Icon as I } from "../icon/icon.js";
8
8
  import { Icons as c } from "../icon/types.js";
9
- import { Menu as I } from "../menu/menu.js";
10
- import { MenuButton as P } from "../menu/menu-button.js";
11
- import { MenuList as Q } from "../menu/menu-list.js";
12
- import { Text as w } from "../text/text.js";
13
- import { MenuItem as B } from "../menu/menu-item.js";
14
- import { Checkbox as W } from "../checkbox/checkbox.js";
15
- import { MenuDivider as X } from "../menu/menu-divider.js";
16
- import { Switch as Y } from "../switch/switch.js";
17
- import { IconButton as q } from "../icon-button/icon-button.js";
18
- import { MenuIconButton as J } from "../menu/menu-icon-button.js";
19
- import { ThemeIconSizeVariable as K, ThemeSpaceVariable as i, ThemeColorVariable as F, ThemeFontVariable as R, ThemeFontSizeVariable as U } from "../../theme/theme-types.js";
20
- const Z = ({
9
+ import { Menu as w } from "../menu/menu.js";
10
+ import { MenuButton as Q } from "../menu/menu-button.js";
11
+ import { MenuList as W } from "../menu/menu-list.js";
12
+ import { Text as B } from "../text/text.js";
13
+ import { MenuItem as F } from "../menu/menu-item.js";
14
+ import { Checkbox as X } from "../checkbox/checkbox.js";
15
+ import { MenuDivider as Y } from "../menu/menu-divider.js";
16
+ import { Switch as q } from "../switch/switch.js";
17
+ import { IconButton as J } from "../icon-button/icon-button.js";
18
+ import { MenuIconButton as K } from "../menu/menu-icon-button.js";
19
+ import { ThemeIconSizeVariable as R, ThemeSpaceVariable as i, ThemeColorVariable as L, ThemeFontVariable as U, ThemeFontSizeVariable as Z } from "../../theme/theme-types.js";
20
+ const _ = ({
21
21
  tableName: g,
22
22
  onSearch: f,
23
- onAddNewItem: C,
23
+ defaultValue: C,
24
+ onAddNewItem: k,
24
25
  actionMenu: p,
25
- ...L
26
+ ...j
26
27
  }) => {
27
- const t = D(), [V] = A("(min-width: 48em)"), r = G[t.localeString], k = l(() => t.table.getAllColumns().length === Object.keys(t.breakingContentState).length && !Object.values(t.breakingContentState).includes(!1), [t.breakingContentState, t.table]), S = l(
28
+ const t = G(), [z] = H("(min-width: 48em)"), r = E[t.localeString], S = l(() => t.table.getAllColumns().length === Object.keys(t.breakingContentState).length && !Object.values(t.breakingContentState).includes(!1), [t.breakingContentState, t.table]), T = l(
28
29
  (n) => {
29
30
  const b = {};
30
- t.table.getAllColumns().forEach((T) => {
31
- b[T.id] = n.target.checked;
31
+ t.table.getAllColumns().forEach((M) => {
32
+ b[M.id] = n.target.checked;
32
33
  }), t.setBreakingContentState(b), t.onBreakingContentChange?.(b);
33
34
  },
34
35
  [t]
35
36
  ), s = l(
36
37
  () => /* @__PURE__ */ e(
37
- E,
38
+ P,
38
39
  {
39
- leftElement: /* @__PURE__ */ e(y, { icon: c.Search }),
40
+ leftElement: /* @__PURE__ */ e(I, { icon: c.Search }),
40
41
  onChange: (n) => f?.(n),
42
+ defaultValue: C,
41
43
  size: "md",
42
44
  type: "search",
43
45
  w: { base: "100%", md: "170px" },
44
46
  "data-testid": "filterInput"
45
47
  }
46
48
  ),
47
- [f]
49
+ [f, C]
48
50
  ), m = l(
49
- () => /* @__PURE__ */ e(a, { children: /* @__PURE__ */ o(I, { closeOnSelect: !1, isLazy: !0, children: [
50
- /* @__PURE__ */ e(P, { "aria-label": r.presets, variant: "ghost", p: "unset", w: "40px", h: "40px", children: /* @__PURE__ */ e(y, { icon: c.Sliders, size: K.Medium }) }),
51
- /* @__PURE__ */ e(H, { children: /* @__PURE__ */ o(Q, { children: [
51
+ () => /* @__PURE__ */ e(a, { children: /* @__PURE__ */ o(w, { closeOnSelect: !1, isLazy: !0, children: [
52
+ /* @__PURE__ */ e(Q, { "aria-label": r.presets, variant: "ghost", p: "unset", w: "40px", h: "40px", children: /* @__PURE__ */ e(I, { icon: c.Sliders, size: R.Medium }) }),
53
+ /* @__PURE__ */ e(O, { children: /* @__PURE__ */ o(W, { children: [
52
54
  /* @__PURE__ */ e(
53
- w,
55
+ B,
54
56
  {
55
- color: F.OnSurfaceSubdued,
57
+ color: L.OnSurfaceSubdued,
56
58
  py: i.Small,
57
59
  px: i.Medium,
58
60
  children: r.showColumns
59
61
  }
60
62
  ),
61
- /* @__PURE__ */ e(M, { maxHeight: "320px", overflowY: "auto", children: t.table.getAllLeafColumns().filter((n) => n.getCanHide()).map((n) => /* @__PURE__ */ o(B, { itemType: "checkbox", leftIcon: c.GripMore, children: [
62
- /* @__PURE__ */ e(v, { children: n.columnDef.header }),
63
+ /* @__PURE__ */ e(x, { maxHeight: "320px", overflowY: "auto", children: t.table.getAllLeafColumns().filter((n) => n.getCanHide()).map((n) => /* @__PURE__ */ o(F, { itemType: "checkbox", leftIcon: c.GripMore, children: [
64
+ /* @__PURE__ */ e(A, { children: n.columnDef.header }),
63
65
  /* @__PURE__ */ e(
64
- W,
66
+ X,
65
67
  {
66
68
  isChecked: n.getIsVisible(),
67
69
  onChange: n.getToggleVisibilityHandler()
68
70
  }
69
71
  )
70
72
  ] }, n.id)) }),
71
- /* @__PURE__ */ e(X, {}),
72
- /* @__PURE__ */ o(B, { itemType: "switch", children: [
73
+ /* @__PURE__ */ e(Y, {}),
74
+ /* @__PURE__ */ o(F, { itemType: "switch", children: [
73
75
  r.breakingContent,
74
- /* @__PURE__ */ e(Y, { onChange: S, isChecked: k() })
76
+ /* @__PURE__ */ e(q, { onChange: T, isChecked: S() })
75
77
  ] })
76
78
  ] }) })
77
79
  ] }) }),
78
80
  [
79
- k,
80
81
  S,
82
+ T,
81
83
  t.table,
82
84
  r.breakingContent,
83
85
  r.presets,
@@ -85,18 +87,18 @@ const Z = ({
85
87
  ]
86
88
  ), d = l(
87
89
  () => /* @__PURE__ */ e(
88
- q,
90
+ J,
89
91
  {
90
92
  "aria-label": r.new,
91
93
  icon: c.Increase,
92
- onClick: C,
94
+ onClick: k,
93
95
  variant: "secondary"
94
96
  }
95
97
  ),
96
- [C, r.new]
97
- ), u = l(() => p ? /* @__PURE__ */ o(I, { children: [
98
+ [k, r.new]
99
+ ), h = l(() => p ? /* @__PURE__ */ o(w, { children: [
98
100
  /* @__PURE__ */ e(
99
- J,
101
+ K,
100
102
  {
101
103
  icon: c.MoreVertical,
102
104
  variant: "ghost",
@@ -105,45 +107,45 @@ const Z = ({
105
107
  }
106
108
  ),
107
109
  p
108
- ] }) : null, [p, r.toolbarActions]), h = l(
110
+ ] }) : null, [p, r.toolbarActions]), u = l(
109
111
  () => /* @__PURE__ */ e(
110
- w,
112
+ B,
111
113
  {
112
- fontSize: U.X2Large,
113
- color: F.OnBackgroundHeader,
114
+ fontSize: Z.X2Large,
115
+ color: L.OnBackgroundHeader,
114
116
  fontWeight: "bold",
115
- fontFamily: R.Header,
117
+ fontFamily: U.Header,
116
118
  children: g
117
119
  }
118
120
  ),
119
121
  [g]
120
- ), j = x(
122
+ ), V = y(
121
123
  () => /* @__PURE__ */ e(a, { direction: "column", gap: i.Medium, mb: i.Medium, children: /* @__PURE__ */ o(a, { justifyContent: "space-between", alignItems: "center", children: [
122
- h(),
124
+ u(),
123
125
  /* @__PURE__ */ o(a, { gap: i.Medium, children: [
124
126
  s(),
125
127
  m(),
126
- u(),
128
+ h(),
127
129
  d()
128
130
  ] })
129
131
  ] }) }),
130
- [d, s, m, h, u]
131
- ), z = x(
132
+ [d, s, m, u, h]
133
+ ), v = y(
132
134
  () => /* @__PURE__ */ o(a, { direction: "column", gap: i.Medium, mb: i.Medium, children: [
133
135
  /* @__PURE__ */ o(a, { justifyContent: "space-between", children: [
134
- h(),
136
+ u(),
135
137
  d()
136
138
  ] }),
137
139
  /* @__PURE__ */ o(a, { justifyContent: "space-between", gap: i.Medium, children: [
138
140
  s(),
139
- u(),
141
+ h(),
140
142
  m()
141
143
  ] })
142
144
  ] }),
143
- [d, s, m, h, u]
145
+ [d, s, m, u, h]
144
146
  );
145
- return /* @__PURE__ */ e(M, { id: "tableToolbar", ...L, children: V ? j : z });
146
- }, ge = O(Z);
147
+ return /* @__PURE__ */ e(x, { id: "tableToolbar", ...j, children: z ? V : v });
148
+ }, fe = D(_);
147
149
  export {
148
- ge as TableToolbar
150
+ fe as TableToolbar
149
151
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caspeco/casper-ui-library",
3
- "version": "7.9.3",
3
+ "version": "7.10.0",
4
4
  "prettier": "@caspeco/prettier-config",
5
5
  "type": "module",
6
6
  "sideEffects": false,