@expcat/tigercat-react 1.2.39 → 1.2.41

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.
Files changed (43) hide show
  1. package/dist/{chunk-JDJFSO2D.mjs → chunk-2VE2CP7E.mjs} +102 -8
  2. package/dist/{chunk-LJDILPI6.js → chunk-36I5APFX.js} +2 -2
  3. package/dist/{chunk-C3NKZZQQ.js → chunk-AE2QE2C6.js} +2 -2
  4. package/dist/{chunk-ZDEOTMXP.mjs → chunk-C44WSDEY.mjs} +2 -1
  5. package/dist/{chunk-3LCISRAV.js → chunk-JIFSUUGA.js} +2 -1
  6. package/dist/{chunk-AKZY7QYA.js → chunk-JLQBG5XU.js} +23 -17
  7. package/dist/{chunk-FZX7USS4.js → chunk-LHBE3N3U.js} +124 -30
  8. package/dist/{chunk-XU4TF2YA.js → chunk-LYYL2JMP.js} +2 -2
  9. package/dist/{chunk-LJARWKJT.mjs → chunk-MV54EEKO.mjs} +1 -1
  10. package/dist/{chunk-AT2GRD6F.js → chunk-OBY4FYRZ.js} +2 -2
  11. package/dist/{chunk-TAYQDWXN.mjs → chunk-TANTMMR7.mjs} +1 -1
  12. package/dist/{chunk-WVTUGFWO.mjs → chunk-TYZNV54N.mjs} +23 -17
  13. package/dist/{chunk-TSZKBVTA.mjs → chunk-WYGO6XC7.mjs} +35 -4
  14. package/dist/{chunk-M36PT6BS.js → chunk-XUETAIF3.js} +76 -45
  15. package/dist/{chunk-PCPAMUAE.mjs → chunk-ZDS5WL22.mjs} +1 -1
  16. package/dist/{chunk-73OAHAPC.mjs → chunk-ZL44XLSB.mjs} +1 -1
  17. package/dist/components/DataTableWithToolbar.d.mts +2 -2
  18. package/dist/components/DataTableWithToolbar.d.ts +2 -2
  19. package/dist/components/DataTableWithToolbar.js +6 -3
  20. package/dist/components/DataTableWithToolbar.mjs +5 -2
  21. package/dist/components/Dropdown.js +2 -2
  22. package/dist/components/Dropdown.mjs +1 -1
  23. package/dist/components/DropdownItem.js +3 -3
  24. package/dist/components/DropdownItem.mjs +2 -2
  25. package/dist/components/DropdownMenu.js +2 -2
  26. package/dist/components/DropdownMenu.mjs +1 -1
  27. package/dist/components/Popconfirm.js +3 -3
  28. package/dist/components/Popconfirm.mjs +2 -2
  29. package/dist/components/Popover.js +3 -3
  30. package/dist/components/Popover.mjs +2 -2
  31. package/dist/components/Table.d.mts +2 -2
  32. package/dist/components/Table.d.ts +2 -2
  33. package/dist/components/Table.js +2 -2
  34. package/dist/components/Table.mjs +1 -1
  35. package/dist/components/Tooltip.js +3 -3
  36. package/dist/components/Tooltip.mjs +2 -2
  37. package/dist/index.d.mts +1 -1
  38. package/dist/index.d.ts +1 -1
  39. package/dist/index.js +11 -11
  40. package/dist/index.mjs +10 -10
  41. package/dist/{types-mtq1tZJd.d.mts → types-CHmCMNEM.d.mts} +1 -0
  42. package/dist/{types-mtq1tZJd.d.ts → types-CHmCMNEM.d.ts} +1 -0
  43. package/package.json +2 -2
@@ -1,15 +1,21 @@
1
1
  import {
2
2
  Table
3
- } from "./chunk-TSZKBVTA.mjs";
3
+ } from "./chunk-WYGO6XC7.mjs";
4
4
  import {
5
5
  Select
6
6
  } from "./chunk-T4OVGM4X.mjs";
7
+ import {
8
+ Popover
9
+ } from "./chunk-TANTMMR7.mjs";
7
10
  import {
8
11
  useTigerConfig
9
12
  } from "./chunk-QAIBQHIO.mjs";
10
13
  import {
11
14
  Input
12
15
  } from "./chunk-WNLUUD5N.mjs";
16
+ import {
17
+ Checkbox
18
+ } from "./chunk-MSHCPJIJ.mjs";
13
19
  import {
14
20
  Button
15
21
  } from "./chunk-USWK2S3Y.mjs";
@@ -33,6 +39,9 @@ var DataTableWithToolbar = ({
33
39
  onSearch,
34
40
  onFiltersChange,
35
41
  onBulkAction,
42
+ hiddenColumnKeys,
43
+ defaultHiddenColumnKeys,
44
+ onHiddenColumnsChange,
36
45
  pagination = false,
37
46
  onPageChange,
38
47
  onPageSizeChange,
@@ -45,6 +54,9 @@ var DataTableWithToolbar = ({
45
54
  pagination && typeof pagination === "object" ? pagination.pageSize ?? pagination.defaultPageSize ?? 10 : void 0
46
55
  );
47
56
  const [internalSearch, setInternalSearch] = useState(toolbar?.defaultSearchValue ?? "");
57
+ const [internalHiddenKeys, setInternalHiddenKeys] = useState(
58
+ defaultHiddenColumnKeys ?? hiddenColumnKeys ?? []
59
+ );
48
60
  const [internalFilters, setInternalFilters] = useState(
49
61
  () => {
50
62
  const initial = {};
@@ -60,7 +72,9 @@ var DataTableWithToolbar = ({
60
72
  () => locale ? getImmediateTigerLocale(locale) : void 0,
61
73
  [locale]
62
74
  );
63
- const [resolvedTableLocale, setResolvedTableLocale] = useState(immediateTableLocale);
75
+ const [resolvedTableLocale, setResolvedTableLocale] = useState(
76
+ immediateTableLocale
77
+ );
64
78
  useEffect(() => {
65
79
  let active = true;
66
80
  setResolvedTableLocale(immediateTableLocale);
@@ -79,15 +93,17 @@ var DataTableWithToolbar = ({
79
93
  () => mergeTigerLocale(config.locale, resolvedTableLocale),
80
94
  [config.locale, resolvedTableLocale]
81
95
  );
82
- const tableLabels = useMemo(
83
- () => getTableLabels(tableLocale, labels),
84
- [labels, tableLocale]
85
- );
96
+ const tableLabels = useMemo(() => getTableLabels(tableLocale, labels), [labels, tableLocale]);
86
97
  useEffect(() => {
87
98
  if (toolbar?.searchValue !== void 0) {
88
99
  setInternalSearch(toolbar.searchValue ?? "");
89
100
  }
90
101
  }, [toolbar?.searchValue]);
102
+ useEffect(() => {
103
+ if (hiddenColumnKeys !== void 0) {
104
+ setInternalHiddenKeys(hiddenColumnKeys);
105
+ }
106
+ }, [hiddenColumnKeys]);
91
107
  useEffect(() => {
92
108
  if (pagination && typeof pagination === "object") {
93
109
  previousPageSizeRef.current = pagination.pageSize ?? pagination.defaultPageSize ?? 10;
@@ -119,6 +135,18 @@ var DataTableWithToolbar = ({
119
135
  );
120
136
  const hasFilters = Boolean(toolbar?.filters && toolbar.filters.length > 0);
121
137
  const hasBulkActions = Boolean(toolbar?.bulkActions && toolbar.bulkActions.length > 0);
138
+ const hasColumnSettings = Boolean(toolbar?.showColumnSettings);
139
+ const resolvedHiddenKeys = hiddenColumnKeys ?? internalHiddenKeys;
140
+ const handleHiddenColumnsChange = (nextHiddenKeys) => {
141
+ if (hiddenColumnKeys === void 0) {
142
+ setInternalHiddenKeys(nextHiddenKeys);
143
+ }
144
+ onHiddenColumnsChange?.(nextHiddenKeys);
145
+ };
146
+ const handleToggleColumnVisibility = (columnKey, visible) => {
147
+ const nextHiddenKeys = visible ? resolvedHiddenKeys.filter((key) => key !== columnKey) : [...resolvedHiddenKeys, columnKey];
148
+ handleHiddenColumnsChange(nextHiddenKeys);
149
+ };
122
150
  const { bordered = false, ...remainingTableProps } = tableProps;
123
151
  const selectedKeys = toolbar?.selectedKeys ?? tableProps.rowSelection?.selectedRowKeys ?? [];
124
152
  const selectedCount = toolbar?.selectedCount ?? selectedKeys.length;
@@ -169,8 +197,72 @@ var DataTableWithToolbar = ({
169
197
  }
170
198
  previousPageSizeRef.current = pageSize;
171
199
  };
200
+ const renderColumnSettings = () => {
201
+ const lockedKeys = new Set(toolbar?.columnSettings?.lockedColumnKeys ?? []);
202
+ const panelTitle = toolbar?.columnSettings?.title ?? tableLabels.columnSettingsText;
203
+ return /* @__PURE__ */ jsx(
204
+ Popover,
205
+ {
206
+ trigger: "click",
207
+ placement: "bottom-end",
208
+ titleContent: panelTitle,
209
+ contentContent: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2 min-w-[160px]", children: tableProps.columns.map((column) => {
210
+ const locked = lockedKeys.has(column.key) || column.hideable === false;
211
+ return /* @__PURE__ */ jsx(
212
+ Checkbox,
213
+ {
214
+ size: "sm",
215
+ checked: !resolvedHiddenKeys.includes(column.key),
216
+ disabled: locked,
217
+ onChange: (checked) => handleToggleColumnVisibility(column.key, checked),
218
+ children: column.title
219
+ },
220
+ column.key
221
+ );
222
+ }) }),
223
+ children: /* @__PURE__ */ jsx(
224
+ Button,
225
+ {
226
+ size: "sm",
227
+ variant: "outline",
228
+ className: "shrink-0 px-2",
229
+ "aria-label": tableLabels.columnSettingsAriaLabel,
230
+ children: /* @__PURE__ */ jsxs(
231
+ "svg",
232
+ {
233
+ className: "w-3.5 h-3.5",
234
+ fill: "none",
235
+ stroke: "currentColor",
236
+ strokeWidth: "2",
237
+ viewBox: "0 0 24 24",
238
+ "aria-hidden": "true",
239
+ children: [
240
+ /* @__PURE__ */ jsx(
241
+ "path",
242
+ {
243
+ strokeLinecap: "round",
244
+ strokeLinejoin: "round",
245
+ d: "M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"
246
+ }
247
+ ),
248
+ /* @__PURE__ */ jsx(
249
+ "path",
250
+ {
251
+ strokeLinecap: "round",
252
+ strokeLinejoin: "round",
253
+ d: "M15 12a3 3 0 11-6 0 3 3 0 016 0z"
254
+ }
255
+ )
256
+ ]
257
+ }
258
+ )
259
+ }
260
+ )
261
+ }
262
+ );
263
+ };
172
264
  const renderToolbar = () => {
173
- if (!hasSearch && !hasFilters && !hasBulkActions) return null;
265
+ if (!hasSearch && !hasFilters && !hasBulkActions && !hasColumnSettings) return null;
174
266
  return /* @__PURE__ */ jsxs(
175
267
  "div",
176
268
  {
@@ -279,7 +371,8 @@ var DataTableWithToolbar = ({
279
371
  },
280
372
  action.key
281
373
  ))
282
- ] }) : null
374
+ ] }) : null,
375
+ hasColumnSettings ? /* @__PURE__ */ jsx("div", { className: classNames("shrink-0", !hasBulkActions && "ml-auto"), children: renderColumnSettings() }) : null
283
376
  ]
284
377
  }
285
378
  );
@@ -293,6 +386,7 @@ var DataTableWithToolbar = ({
293
386
  locale,
294
387
  labels,
295
388
  bordered,
389
+ hiddenColumnKeys: resolvedHiddenKeys,
296
390
  pagination,
297
391
  className: classNames(tableClassName, bordered && "border-none rounded-none shadow-none"),
298
392
  onPageChange: handleTablePageChange
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunk3LCISRAVjs = require('./chunk-3LCISRAV.js');
3
+ var _chunkJIFSUUGAjs = require('./chunk-JIFSUUGA.js');
4
4
 
5
5
 
6
6
  var _chunkSTTQ5LXXjs = require('./chunk-STTQ5LXX.js');
@@ -84,7 +84,7 @@ var Popconfirm = ({
84
84
  floatingRef,
85
85
  actualPlacement,
86
86
  floatingStyles: baseFloatingStyles
87
- } = _chunk3LCISRAVjs.usePopup.call(void 0, {
87
+ } = _chunkJIFSUUGAjs.usePopup.call(void 0, {
88
88
  open,
89
89
  defaultOpen,
90
90
  disabled,
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkAKZY7QYAjs = require('./chunk-AKZY7QYA.js');
3
+ var _chunkJLQBG5XUjs = require('./chunk-JLQBG5XU.js');
4
4
 
5
5
  // src/components/DropdownItem.tsx
6
6
  var _react = require('react');
@@ -17,7 +17,7 @@ var DropdownItem = ({
17
17
  children,
18
18
  ...buttonProps
19
19
  }) => {
20
- const context = _react.useContext.call(void 0, _chunkAKZY7QYAjs.DropdownContext);
20
+ const context = _react.useContext.call(void 0, _chunkJLQBG5XUjs.DropdownContext);
21
21
  const handleClick = (event) => {
22
22
  if (disabled) {
23
23
  event.preventDefault();
@@ -8,6 +8,7 @@ import {
8
8
  import { useCallback, useMemo, useRef, useState } from "react";
9
9
  import {
10
10
  getTransformOrigin,
11
+ FLOATING_OVERLAY_Z_INDEX,
11
12
  buildTriggerHandlerMap,
12
13
  restoreFocus
13
14
  } from "@expcat/tigercat-core";
@@ -86,7 +87,7 @@ function usePopup(options) {
86
87
  left: x,
87
88
  top: y,
88
89
  transformOrigin: getTransformOrigin(actualPlacement),
89
- zIndex: 1e3
90
+ zIndex: FLOATING_OVERLAY_Z_INDEX
90
91
  }),
91
92
  [x, y, actualPlacement]
92
93
  );
@@ -10,6 +10,7 @@ var _react = require('react');
10
10
 
11
11
 
12
12
 
13
+
13
14
  var _tigercatcore = require('@expcat/tigercat-core');
14
15
  function usePopup(options) {
15
16
  const {
@@ -86,7 +87,7 @@ function usePopup(options) {
86
87
  left: x,
87
88
  top: y,
88
89
  transformOrigin: _tigercatcore.getTransformOrigin.call(void 0, actualPlacement),
89
- zIndex: 1e3
90
+ zIndex: _tigercatcore.FLOATING_OVERLAY_Z_INDEX
90
91
  }),
91
92
  [x, y, actualPlacement]
92
93
  );
@@ -2,6 +2,7 @@
2
2
 
3
3
 
4
4
 
5
+
5
6
  var _chunkSTTQ5LXXjs = require('./chunk-STTQ5LXX.js');
6
7
 
7
8
  // src/components/Dropdown.tsx
@@ -28,6 +29,7 @@ var _react = require('react'); var _react2 = _interopRequireDefault(_react);
28
29
 
29
30
 
30
31
 
32
+
31
33
  var _tigercatcore = require('@expcat/tigercat-core');
32
34
  var _jsxruntime = require('react/jsx-runtime');
33
35
  var DropdownContext = _react.createContext.call(void 0, null);
@@ -50,6 +52,7 @@ var Dropdown = ({
50
52
  defaultOpen = false,
51
53
  closeOnClick = true,
52
54
  showArrow = true,
55
+ portal = true,
53
56
  className,
54
57
  style,
55
58
  onOpenChange,
@@ -125,7 +128,7 @@ var Dropdown = ({
125
128
  }, []);
126
129
  _chunkSTTQ5LXXjs.useClickOutside.call(void 0, {
127
130
  enabled: trigger === "click" && visible,
128
- refs: [containerRef],
131
+ refs: [containerRef, floatingRef],
129
132
  onOutsideClick: () => setVisible(false)
130
133
  });
131
134
  _chunkSTTQ5LXXjs.useEscapeKey.call(void 0, {
@@ -151,12 +154,13 @@ var Dropdown = ({
151
154
  [className]
152
155
  );
153
156
  const triggerClasses = _react.useMemo.call(void 0, () => _tigercatcore.getDropdownTriggerClasses.call(void 0, disabled), [disabled]);
154
- const menuWrapperClasses = _tigercatcore.classNames.call(void 0, "absolute z-50", _tigercatcore.DROPDOWN_ENTER_CLASS);
157
+ const menuWrapperClasses = _tigercatcore.classNames.call(void 0, "absolute", _tigercatcore.DROPDOWN_ENTER_CLASS);
155
158
  const menuWrapperStyles = _react.useMemo.call(void 0,
156
159
  () => ({
157
160
  position: "absolute",
158
161
  left: x,
159
162
  top: y,
163
+ zIndex: _tigercatcore.FLOATING_OVERLAY_Z_INDEX,
160
164
  transformOrigin: _tigercatcore.getTransformOrigin.call(void 0, placement)
161
165
  }),
162
166
  [x, y, placement]
@@ -195,6 +199,22 @@ var Dropdown = ({
195
199
  children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: _tigercatcore.DROPDOWN_CHEVRON_PATH })
196
200
  }
197
201
  ) : null;
202
+ const menuWrapperNode = /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
203
+ "div",
204
+ {
205
+ ref: floatingRef,
206
+ className: menuWrapperClasses,
207
+ style: menuWrapperStyles,
208
+ hidden: !visible,
209
+ "data-tiger-dropdown-menu": "",
210
+ onMouseEnter: handleMouseEnter,
211
+ onMouseLeave: handleMouseLeave,
212
+ onKeyDown: handleMenuKeyDown,
213
+ children: menuElement && _react2.default.isValidElement(menuElement) ? _react2.default.cloneElement(menuElement, {
214
+ id: menuId
215
+ }) : menuElement
216
+ }
217
+ );
198
218
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DropdownContext.Provider, { value: contextValue, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ref: containerRef, className: containerClasses, style, ...divProps, children: [
199
219
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
200
220
  "div",
@@ -213,21 +233,7 @@ var Dropdown = ({
213
233
  ]
214
234
  }
215
235
  ),
216
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
217
- "div",
218
- {
219
- ref: floatingRef,
220
- className: menuWrapperClasses,
221
- style: menuWrapperStyles,
222
- hidden: !visible,
223
- onMouseEnter: handleMouseEnter,
224
- onMouseLeave: handleMouseLeave,
225
- onKeyDown: handleMenuKeyDown,
226
- children: menuElement && _react2.default.isValidElement(menuElement) ? _react2.default.cloneElement(menuElement, {
227
- id: menuId
228
- }) : menuElement
229
- }
230
- )
236
+ portal ? _chunkSTTQ5LXXjs.renderBodyPortal.call(void 0, menuWrapperNode) : menuWrapperNode
231
237
  ] }) });
232
238
  };
233
239
 
@@ -1,17 +1,23 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkM36PT6BSjs = require('./chunk-M36PT6BS.js');
3
+ var _chunkXUETAIF3js = require('./chunk-XUETAIF3.js');
4
4
 
5
5
 
6
6
  var _chunk6Z4LLPZAjs = require('./chunk-6Z4LLPZA.js');
7
7
 
8
8
 
9
+ var _chunkLYYL2JMPjs = require('./chunk-LYYL2JMP.js');
10
+
11
+
9
12
  var _chunkTDODFBBOjs = require('./chunk-TDODFBBO.js');
10
13
 
11
14
 
12
15
  var _chunkZYJTHGQWjs = require('./chunk-ZYJTHGQW.js');
13
16
 
14
17
 
18
+ var _chunkF7H4ALKNjs = require('./chunk-F7H4ALKN.js');
19
+
20
+
15
21
  var _chunk56ZV3VVYjs = require('./chunk-56ZV3VVY.js');
16
22
 
17
23
  // src/components/DataTableWithToolbar.tsx
@@ -33,6 +39,9 @@ var DataTableWithToolbar = ({
33
39
  onSearch,
34
40
  onFiltersChange,
35
41
  onBulkAction,
42
+ hiddenColumnKeys,
43
+ defaultHiddenColumnKeys,
44
+ onHiddenColumnsChange,
36
45
  pagination = false,
37
46
  onPageChange,
38
47
  onPageSizeChange,
@@ -45,6 +54,9 @@ var DataTableWithToolbar = ({
45
54
  pagination && typeof pagination === "object" ? _nullishCoalesce(_nullishCoalesce(pagination.pageSize, () => ( pagination.defaultPageSize)), () => ( 10)) : void 0
46
55
  );
47
56
  const [internalSearch, setInternalSearch] = _react.useState.call(void 0, _nullishCoalesce(_optionalChain([toolbar, 'optionalAccess', _ => _.defaultSearchValue]), () => ( "")));
57
+ const [internalHiddenKeys, setInternalHiddenKeys] = _react.useState.call(void 0,
58
+ _nullishCoalesce(_nullishCoalesce(defaultHiddenColumnKeys, () => ( hiddenColumnKeys)), () => ( []))
59
+ );
48
60
  const [internalFilters, setInternalFilters] = _react.useState.call(void 0,
49
61
  () => {
50
62
  const initial = {};
@@ -60,7 +72,9 @@ var DataTableWithToolbar = ({
60
72
  () => locale ? _tigercatcore.getImmediateTigerLocale.call(void 0, locale) : void 0,
61
73
  [locale]
62
74
  );
63
- const [resolvedTableLocale, setResolvedTableLocale] = _react.useState.call(void 0, immediateTableLocale);
75
+ const [resolvedTableLocale, setResolvedTableLocale] = _react.useState.call(void 0,
76
+ immediateTableLocale
77
+ );
64
78
  _react.useEffect.call(void 0, () => {
65
79
  let active = true;
66
80
  setResolvedTableLocale(immediateTableLocale);
@@ -79,15 +93,17 @@ var DataTableWithToolbar = ({
79
93
  () => _tigercatcore.mergeTigerLocale.call(void 0, config.locale, resolvedTableLocale),
80
94
  [config.locale, resolvedTableLocale]
81
95
  );
82
- const tableLabels = _react.useMemo.call(void 0,
83
- () => _tigercatcore.getTableLabels.call(void 0, tableLocale, labels),
84
- [labels, tableLocale]
85
- );
96
+ const tableLabels = _react.useMemo.call(void 0, () => _tigercatcore.getTableLabels.call(void 0, tableLocale, labels), [labels, tableLocale]);
86
97
  _react.useEffect.call(void 0, () => {
87
98
  if (_optionalChain([toolbar, 'optionalAccess', _5 => _5.searchValue]) !== void 0) {
88
99
  setInternalSearch(_nullishCoalesce(toolbar.searchValue, () => ( "")));
89
100
  }
90
101
  }, [_optionalChain([toolbar, 'optionalAccess', _6 => _6.searchValue])]);
102
+ _react.useEffect.call(void 0, () => {
103
+ if (hiddenColumnKeys !== void 0) {
104
+ setInternalHiddenKeys(hiddenColumnKeys);
105
+ }
106
+ }, [hiddenColumnKeys]);
91
107
  _react.useEffect.call(void 0, () => {
92
108
  if (pagination && typeof pagination === "object") {
93
109
  previousPageSizeRef.current = _nullishCoalesce(_nullishCoalesce(pagination.pageSize, () => ( pagination.defaultPageSize)), () => ( 10));
@@ -119,10 +135,22 @@ var DataTableWithToolbar = ({
119
135
  );
120
136
  const hasFilters = Boolean(_optionalChain([toolbar, 'optionalAccess', _14 => _14.filters]) && toolbar.filters.length > 0);
121
137
  const hasBulkActions = Boolean(_optionalChain([toolbar, 'optionalAccess', _15 => _15.bulkActions]) && toolbar.bulkActions.length > 0);
138
+ const hasColumnSettings = Boolean(_optionalChain([toolbar, 'optionalAccess', _16 => _16.showColumnSettings]));
139
+ const resolvedHiddenKeys = _nullishCoalesce(hiddenColumnKeys, () => ( internalHiddenKeys));
140
+ const handleHiddenColumnsChange = (nextHiddenKeys) => {
141
+ if (hiddenColumnKeys === void 0) {
142
+ setInternalHiddenKeys(nextHiddenKeys);
143
+ }
144
+ _optionalChain([onHiddenColumnsChange, 'optionalCall', _17 => _17(nextHiddenKeys)]);
145
+ };
146
+ const handleToggleColumnVisibility = (columnKey, visible) => {
147
+ const nextHiddenKeys = visible ? resolvedHiddenKeys.filter((key) => key !== columnKey) : [...resolvedHiddenKeys, columnKey];
148
+ handleHiddenColumnsChange(nextHiddenKeys);
149
+ };
122
150
  const { bordered = false, ...remainingTableProps } = tableProps;
123
- const selectedKeys = _nullishCoalesce(_nullishCoalesce(_optionalChain([toolbar, 'optionalAccess', _16 => _16.selectedKeys]), () => ( _optionalChain([tableProps, 'access', _17 => _17.rowSelection, 'optionalAccess', _18 => _18.selectedRowKeys]))), () => ( []));
124
- const selectedCount = _nullishCoalesce(_optionalChain([toolbar, 'optionalAccess', _19 => _19.selectedCount]), () => ( selectedKeys.length));
125
- const bulkLabel = _nullishCoalesce(_optionalChain([toolbar, 'optionalAccess', _20 => _20.bulkActionsLabel]), () => ( tableLabels.selectedText));
151
+ const selectedKeys = _nullishCoalesce(_nullishCoalesce(_optionalChain([toolbar, 'optionalAccess', _18 => _18.selectedKeys]), () => ( _optionalChain([tableProps, 'access', _19 => _19.rowSelection, 'optionalAccess', _20 => _20.selectedRowKeys]))), () => ( []));
152
+ const selectedCount = _nullishCoalesce(_optionalChain([toolbar, 'optionalAccess', _21 => _21.selectedCount]), () => ( selectedKeys.length));
153
+ const bulkLabel = _nullishCoalesce(_optionalChain([toolbar, 'optionalAccess', _22 => _22.bulkActionsLabel]), () => ( tableLabels.selectedText));
126
154
  const wrapperClasses = _react.useMemo.call(void 0,
127
155
  () => _tigercatcore.classNames.call(void 0,
128
156
  "tiger-data-table-with-toolbar flex flex-col",
@@ -132,15 +160,15 @@ var DataTableWithToolbar = ({
132
160
  [className, bordered]
133
161
  );
134
162
  const handleSearchChange = (value) => {
135
- if (_optionalChain([toolbar, 'optionalAccess', _21 => _21.searchValue]) === void 0) {
163
+ if (_optionalChain([toolbar, 'optionalAccess', _23 => _23.searchValue]) === void 0) {
136
164
  setInternalSearch(value);
137
165
  }
138
- _optionalChain([onSearchChange, 'optionalCall', _22 => _22(value)]);
139
- _optionalChain([toolbar, 'optionalAccess', _23 => _23.onSearchChange, 'optionalCall', _24 => _24(value)]);
166
+ _optionalChain([onSearchChange, 'optionalCall', _24 => _24(value)]);
167
+ _optionalChain([toolbar, 'optionalAccess', _25 => _25.onSearchChange, 'optionalCall', _26 => _26(value)]);
140
168
  };
141
169
  const handleSearchSubmit = () => {
142
- _optionalChain([onSearch, 'optionalCall', _25 => _25(_nullishCoalesce(searchValue, () => ( "")))]);
143
- _optionalChain([toolbar, 'optionalAccess', _26 => _26.onSearch, 'optionalCall', _27 => _27(_nullishCoalesce(searchValue, () => ( "")))]);
170
+ _optionalChain([onSearch, 'optionalCall', _27 => _27(_nullishCoalesce(searchValue, () => ( "")))]);
171
+ _optionalChain([toolbar, 'optionalAccess', _28 => _28.onSearch, 'optionalCall', _29 => _29(_nullishCoalesce(searchValue, () => ( "")))]);
144
172
  };
145
173
  const handleFilterSelect = (filter, value) => {
146
174
  const nextFilters = {
@@ -153,24 +181,88 @@ var DataTableWithToolbar = ({
153
181
  [filter.key]: value
154
182
  }));
155
183
  }
156
- _optionalChain([onFiltersChange, 'optionalCall', _28 => _28(nextFilters)]);
157
- _optionalChain([toolbar, 'optionalAccess', _29 => _29.onFiltersChange, 'optionalCall', _30 => _30(nextFilters)]);
184
+ _optionalChain([onFiltersChange, 'optionalCall', _30 => _30(nextFilters)]);
185
+ _optionalChain([toolbar, 'optionalAccess', _31 => _31.onFiltersChange, 'optionalCall', _32 => _32(nextFilters)]);
158
186
  };
159
187
  const handleBulkAction = (action) => {
160
188
  const keys = _nullishCoalesce(selectedKeys, () => ( []));
161
- _optionalChain([action, 'access', _31 => _31.onClick, 'optionalCall', _32 => _32(keys)]);
162
- _optionalChain([onBulkAction, 'optionalCall', _33 => _33(action, keys)]);
163
- _optionalChain([toolbar, 'optionalAccess', _34 => _34.onBulkAction, 'optionalCall', _35 => _35(action, keys)]);
189
+ _optionalChain([action, 'access', _33 => _33.onClick, 'optionalCall', _34 => _34(keys)]);
190
+ _optionalChain([onBulkAction, 'optionalCall', _35 => _35(action, keys)]);
191
+ _optionalChain([toolbar, 'optionalAccess', _36 => _36.onBulkAction, 'optionalCall', _37 => _37(action, keys)]);
164
192
  };
165
193
  const handleTablePageChange = ({ current, pageSize }) => {
166
- _optionalChain([onPageChange, 'optionalCall', _36 => _36(current, pageSize)]);
194
+ _optionalChain([onPageChange, 'optionalCall', _38 => _38(current, pageSize)]);
167
195
  if (previousPageSizeRef.current !== void 0 && previousPageSizeRef.current !== pageSize) {
168
- _optionalChain([onPageSizeChange, 'optionalCall', _37 => _37(current, pageSize)]);
196
+ _optionalChain([onPageSizeChange, 'optionalCall', _39 => _39(current, pageSize)]);
169
197
  }
170
198
  previousPageSizeRef.current = pageSize;
171
199
  };
200
+ const renderColumnSettings = () => {
201
+ const lockedKeys = new Set(_nullishCoalesce(_optionalChain([toolbar, 'optionalAccess', _40 => _40.columnSettings, 'optionalAccess', _41 => _41.lockedColumnKeys]), () => ( [])));
202
+ const panelTitle = _nullishCoalesce(_optionalChain([toolbar, 'optionalAccess', _42 => _42.columnSettings, 'optionalAccess', _43 => _43.title]), () => ( tableLabels.columnSettingsText));
203
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
204
+ _chunkLYYL2JMPjs.Popover,
205
+ {
206
+ trigger: "click",
207
+ placement: "bottom-end",
208
+ titleContent: panelTitle,
209
+ contentContent: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex flex-col gap-2 min-w-[160px]", children: tableProps.columns.map((column) => {
210
+ const locked = lockedKeys.has(column.key) || column.hideable === false;
211
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
212
+ _chunkF7H4ALKNjs.Checkbox,
213
+ {
214
+ size: "sm",
215
+ checked: !resolvedHiddenKeys.includes(column.key),
216
+ disabled: locked,
217
+ onChange: (checked) => handleToggleColumnVisibility(column.key, checked),
218
+ children: column.title
219
+ },
220
+ column.key
221
+ );
222
+ }) }),
223
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
224
+ _chunk56ZV3VVYjs.Button,
225
+ {
226
+ size: "sm",
227
+ variant: "outline",
228
+ className: "shrink-0 px-2",
229
+ "aria-label": tableLabels.columnSettingsAriaLabel,
230
+ children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
231
+ "svg",
232
+ {
233
+ className: "w-3.5 h-3.5",
234
+ fill: "none",
235
+ stroke: "currentColor",
236
+ strokeWidth: "2",
237
+ viewBox: "0 0 24 24",
238
+ "aria-hidden": "true",
239
+ children: [
240
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
241
+ "path",
242
+ {
243
+ strokeLinecap: "round",
244
+ strokeLinejoin: "round",
245
+ d: "M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"
246
+ }
247
+ ),
248
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
249
+ "path",
250
+ {
251
+ strokeLinecap: "round",
252
+ strokeLinejoin: "round",
253
+ d: "M15 12a3 3 0 11-6 0 3 3 0 016 0z"
254
+ }
255
+ )
256
+ ]
257
+ }
258
+ )
259
+ }
260
+ )
261
+ }
262
+ );
263
+ };
172
264
  const renderToolbar = () => {
173
- if (!hasSearch && !hasFilters && !hasBulkActions) return null;
265
+ if (!hasSearch && !hasFilters && !hasBulkActions && !hasColumnSettings) return null;
174
266
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
175
267
  "div",
176
268
  {
@@ -189,7 +281,7 @@ var DataTableWithToolbar = ({
189
281
  type: "search",
190
282
  size: "sm",
191
283
  value: searchValue,
192
- placeholder: _nullishCoalesce(_optionalChain([toolbar, 'optionalAccess', _38 => _38.searchPlaceholder]), () => ( tableLabels.searchPlaceholder)),
284
+ placeholder: _nullishCoalesce(_optionalChain([toolbar, 'optionalAccess', _44 => _44.searchPlaceholder]), () => ( tableLabels.searchPlaceholder)),
193
285
  prefix: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
194
286
  "svg",
195
287
  {
@@ -217,19 +309,19 @@ var DataTableWithToolbar = ({
217
309
  }
218
310
  }
219
311
  ),
220
- _nullishCoalesce(_optionalChain([toolbar, 'optionalAccess', _39 => _39.showSearchButton]), () => ( true)) ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
312
+ _nullishCoalesce(_optionalChain([toolbar, 'optionalAccess', _45 => _45.showSearchButton]), () => ( true)) ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
221
313
  _chunk56ZV3VVYjs.Button,
222
314
  {
223
315
  size: "sm",
224
316
  variant: "primary",
225
317
  className: "whitespace-nowrap shrink-0 rounded-[var(--tiger-radius-md,0.5rem)] px-3",
226
318
  onClick: handleSearchSubmit,
227
- disabled: !onSearch && !_optionalChain([toolbar, 'optionalAccess', _40 => _40.onSearch]),
228
- children: _nullishCoalesce(_optionalChain([toolbar, 'optionalAccess', _41 => _41.searchButtonText]), () => ( tableLabels.searchButtonText))
319
+ disabled: !onSearch && !_optionalChain([toolbar, 'optionalAccess', _46 => _46.onSearch]),
320
+ children: _nullishCoalesce(_optionalChain([toolbar, 'optionalAccess', _47 => _47.searchButtonText]), () => ( tableLabels.searchButtonText))
229
321
  }
230
322
  ) : null
231
323
  ] }) : null,
232
- hasFilters ? _optionalChain([toolbar, 'optionalAccess', _42 => _42.filters, 'optionalAccess', _43 => _43.map, 'call', _44 => _44((filter) => {
324
+ hasFilters ? _optionalChain([toolbar, 'optionalAccess', _48 => _48.filters, 'optionalAccess', _49 => _49.map, 'call', _50 => _50((filter) => {
233
325
  const currentValue = resolvedFilters[filter.key];
234
326
  const clearable = filter.clearable !== false;
235
327
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
@@ -268,7 +360,7 @@ var DataTableWithToolbar = ({
268
360
  tableLabels.selectedItemsText
269
361
  ] })
270
362
  ] }) : null,
271
- _optionalChain([toolbar, 'optionalAccess', _45 => _45.bulkActions, 'optionalAccess', _46 => _46.map, 'call', _47 => _47((action) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
363
+ _optionalChain([toolbar, 'optionalAccess', _51 => _51.bulkActions, 'optionalAccess', _52 => _52.map, 'call', _53 => _53((action) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
272
364
  _chunk56ZV3VVYjs.Button,
273
365
  {
274
366
  size: "sm",
@@ -279,7 +371,8 @@ var DataTableWithToolbar = ({
279
371
  },
280
372
  action.key
281
373
  ))])
282
- ] }) : null
374
+ ] }) : null,
375
+ hasColumnSettings ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: _tigercatcore.classNames.call(void 0, "shrink-0", !hasBulkActions && "ml-auto"), children: renderColumnSettings() }) : null
283
376
  ]
284
377
  }
285
378
  );
@@ -287,12 +380,13 @@ var DataTableWithToolbar = ({
287
380
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: wrapperClasses, "data-tiger-data-table-with-toolbar": true, children: [
288
381
  renderToolbar(),
289
382
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
290
- _chunkM36PT6BSjs.Table,
383
+ _chunkXUETAIF3js.Table,
291
384
  {
292
385
  ...remainingTableProps,
293
386
  locale,
294
387
  labels,
295
388
  bordered,
389
+ hiddenColumnKeys: resolvedHiddenKeys,
296
390
  pagination,
297
391
  className: _tigercatcore.classNames.call(void 0, tableClassName, bordered && "border-none rounded-none shadow-none"),
298
392
  onPageChange: handleTablePageChange
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunk3LCISRAVjs = require('./chunk-3LCISRAV.js');
3
+ var _chunkJIFSUUGAjs = require('./chunk-JIFSUUGA.js');
4
4
 
5
5
 
6
6
  var _chunkSTTQ5LXXjs = require('./chunk-STTQ5LXX.js');
@@ -41,7 +41,7 @@ var Popover = ({
41
41
  const popoverId = popoverIdRef.current;
42
42
  const titleId = `${popoverId}-title`;
43
43
  const contentId = `${popoverId}-content`;
44
- const { currentVisible, containerRef, triggerRef, floatingRef, floatingStyles, triggerHandlers } = _chunk3LCISRAVjs.usePopup.call(void 0, { open, defaultOpen, disabled, trigger, placement, offset, onOpenChange });
44
+ const { currentVisible, containerRef, triggerRef, floatingRef, floatingStyles, triggerHandlers } = _chunkJIFSUUGAjs.usePopup.call(void 0, { open, defaultOpen, disabled, trigger, placement, offset, onOpenChange });
45
45
  const containerClasses = _react.useMemo.call(void 0,
46
46
  () => _tigercatcore.classNames.call(void 0, _tigercatcore.getPopoverContainerClasses.call(void 0, ), className),
47
47
  [className]
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  usePopup
3
- } from "./chunk-ZDEOTMXP.mjs";
3
+ } from "./chunk-C44WSDEY.mjs";
4
4
  import {
5
5
  renderBodyPortal
6
6
  } from "./chunk-SEWNVIHH.mjs";