@vuu-ui/vuu-table-extras 0.13.34 → 0.13.35
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.
- package/cjs/cell-renderers/button-cell/IconButtonCell.css.js +6 -0
- package/cjs/cell-renderers/button-cell/IconButtonCell.css.js.map +1 -0
- package/cjs/cell-renderers/button-cell/IconButtonCell.js +40 -0
- package/cjs/cell-renderers/button-cell/IconButtonCell.js.map +1 -0
- package/cjs/index.js +2 -0
- package/cjs/index.js.map +1 -1
- package/cjs/table-provider/TableProvider.js +15 -2
- package/cjs/table-provider/TableProvider.js.map +1 -1
- package/esm/cell-renderers/button-cell/IconButtonCell.css.js +4 -0
- package/esm/cell-renderers/button-cell/IconButtonCell.css.js.map +1 -0
- package/esm/cell-renderers/button-cell/IconButtonCell.js +38 -0
- package/esm/cell-renderers/button-cell/IconButtonCell.js.map +1 -0
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/table-provider/TableProvider.js +15 -3
- package/esm/table-provider/TableProvider.js.map +1 -1
- package/package.json +11 -11
- package/types/cell-renderers/button-cell/IconButtonCell.d.ts +6 -0
- package/types/cell-renderers/index.d.ts +1 -0
- package/types/table-provider/TableProvider.d.ts +8 -7
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var iconButtonCellCss = "\n.vuuTableCell:has(.vuuIconButtonCell){\n padding: 0;\n position: relative;\n}\n\n.vuuIconButtonCell {\n align-items: center;\n display: inline-flex;\n justify-content: center;\n padding: 0;\n font-weight: 500;\n position: relative;\n height: 100%;\n --saltButton-height: 100%;\n --saltButton-minWidth: 100%;\n --saltButton-padding: 0;\n --saltButton-width: 100%;\n}\n";
|
|
4
|
+
|
|
5
|
+
module.exports = iconButtonCellCss;
|
|
6
|
+
//# sourceMappingURL=IconButtonCell.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IconButtonCell.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var styles = require('@salt-ds/styles');
|
|
6
|
+
var window = require('@salt-ds/window');
|
|
7
|
+
var IconButtonCell$1 = require('./IconButtonCell.css.js');
|
|
8
|
+
var TableProvider = require('../../table-provider/TableProvider.js');
|
|
9
|
+
var core = require('@salt-ds/core');
|
|
10
|
+
|
|
11
|
+
const classBase = "vuuIconButtonCell";
|
|
12
|
+
const IconButtonCell = ({ column, row }) => {
|
|
13
|
+
const targetWindow = window.useWindow();
|
|
14
|
+
styles.useComponentCssInjection({
|
|
15
|
+
testId: "vuu-dropdown-cell",
|
|
16
|
+
css: IconButtonCell$1,
|
|
17
|
+
window: targetWindow
|
|
18
|
+
});
|
|
19
|
+
const actionHandler = TableProvider.useRowAction(column.name);
|
|
20
|
+
const handleClick = react.useCallback(
|
|
21
|
+
(evt) => {
|
|
22
|
+
evt.stopPropagation();
|
|
23
|
+
actionHandler(column.name, row);
|
|
24
|
+
},
|
|
25
|
+
[actionHandler, column, row]
|
|
26
|
+
);
|
|
27
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
28
|
+
core.Button,
|
|
29
|
+
{
|
|
30
|
+
appearance: "transparent",
|
|
31
|
+
className: classBase,
|
|
32
|
+
"data-embedded": true,
|
|
33
|
+
"data-icon": true,
|
|
34
|
+
onClick: handleClick
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
exports.IconButtonCell = IconButtonCell;
|
|
40
|
+
//# sourceMappingURL=IconButtonCell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IconButtonCell.js","sources":["../../../../../packages/vuu-table-extras/src/cell-renderers/button-cell/IconButtonCell.tsx"],"sourcesContent":["import { TableCellRendererProps } from \"@vuu-ui/vuu-table-types\";\nimport { MouseEventHandler, useCallback } from \"react\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\n\nimport iconButtonCellCss from \"./IconButtonCell.css\";\nimport { useRowAction } from \"../../table-provider/TableProvider\";\nimport { Button } from \"@salt-ds/core\";\n\nconst classBase = \"vuuIconButtonCell\";\n\n/**\n * To assign an icon to the cell, give the columndescriptor\n * a className. In css, assign an icon variable to --vuu-svg-icon.\n */\nexport const IconButtonCell = ({ column, row }: TableCellRendererProps) => {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"vuu-dropdown-cell\",\n css: iconButtonCellCss,\n window: targetWindow,\n });\n\n const actionHandler = useRowAction(column.name);\n const handleClick = useCallback<MouseEventHandler<HTMLButtonElement>>(\n (evt) => {\n evt.stopPropagation();\n actionHandler(column.name, row);\n },\n [actionHandler, column, row],\n );\n\n return (\n <Button\n appearance=\"transparent\"\n className={classBase}\n data-embedded\n data-icon\n onClick={handleClick}\n />\n );\n};\n"],"names":["useWindow","useComponentCssInjection","iconButtonCellCss","useRowAction","useCallback","jsx","Button"],"mappings":";;;;;;;;;;AASA,MAAM,SAAY,GAAA,mBAAA;AAMX,MAAM,cAAiB,GAAA,CAAC,EAAE,MAAA,EAAQ,KAAkC,KAAA;AACzE,EAAA,MAAM,eAAeA,gBAAU,EAAA;AAC/B,EAAyBC,+BAAA,CAAA;AAAA,IACvB,MAAQ,EAAA,mBAAA;AAAA,IACR,GAAK,EAAAC,gBAAA;AAAA,IACL,MAAQ,EAAA;AAAA,GACT,CAAA;AAED,EAAM,MAAA,aAAA,GAAgBC,0BAAa,CAAA,MAAA,CAAO,IAAI,CAAA;AAC9C,EAAA,MAAM,WAAc,GAAAC,iBAAA;AAAA,IAClB,CAAC,GAAQ,KAAA;AACP,MAAA,GAAA,CAAI,eAAgB,EAAA;AACpB,MAAc,aAAA,CAAA,MAAA,CAAO,MAAM,GAAG,CAAA;AAAA,KAChC;AAAA,IACA,CAAC,aAAe,EAAA,MAAA,EAAQ,GAAG;AAAA,GAC7B;AAEA,EACE,uBAAAC,cAAA;AAAA,IAACC,WAAA;AAAA,IAAA;AAAA,MACC,UAAW,EAAA,aAAA;AAAA,MACX,SAAW,EAAA,SAAA;AAAA,MACX,eAAa,EAAA,IAAA;AAAA,MACb,WAAS,EAAA,IAAA;AAAA,MACT,OAAS,EAAA;AAAA;AAAA,GACX;AAEJ;;;;"}
|
package/cjs/index.js
CHANGED
|
@@ -8,6 +8,7 @@ var DropdownCell = require('./cell-renderers/dropdown-cell/DropdownCell.js');
|
|
|
8
8
|
var LookupCell = require('./cell-renderers/lookup-cell/LookupCell.js');
|
|
9
9
|
var PctProgressCell = require('./cell-renderers/pct-progress-cell/PctProgressCell.js');
|
|
10
10
|
require('./cell-renderers/progress-cell/ProgressCell.js');
|
|
11
|
+
var IconButtonCell = require('./cell-renderers/button-cell/IconButtonCell.js');
|
|
11
12
|
var ColumnList = require('./column-list/ColumnList.js');
|
|
12
13
|
var ColumnMenu = require('./column-menu/ColumnMenu.js');
|
|
13
14
|
var useColumnActions = require('./column-menu/useColumnActions.js');
|
|
@@ -39,6 +40,7 @@ exports.BackgroundCellConfigurationEditor = BackgroundCellConfigurationEditor.Ba
|
|
|
39
40
|
exports.DropdownCell = DropdownCell.DropdownCell;
|
|
40
41
|
exports.LookupCell = LookupCell.LookupCell;
|
|
41
42
|
exports.PctProgressCell = PctProgressCell.PctProgressCell;
|
|
43
|
+
exports.IconButtonCell = IconButtonCell.IconButtonCell;
|
|
42
44
|
exports.ColumnList = ColumnList.ColumnList;
|
|
43
45
|
exports.classBase = ColumnList.classBase;
|
|
44
46
|
exports.classBaseListItem = ColumnList.classBaseListItem;
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -17,14 +17,16 @@ const TableContext = react.createContext({
|
|
|
17
17
|
const TableProvider = ({
|
|
18
18
|
children,
|
|
19
19
|
dataSource,
|
|
20
|
-
menuActionHandler
|
|
20
|
+
menuActionHandler,
|
|
21
|
+
rowActionHandlers
|
|
21
22
|
}) => {
|
|
22
23
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
23
24
|
TableContext.Provider,
|
|
24
25
|
{
|
|
25
26
|
value: {
|
|
26
27
|
dataSource,
|
|
27
|
-
menuActionHandler
|
|
28
|
+
menuActionHandler,
|
|
29
|
+
rowActionHandlers
|
|
28
30
|
},
|
|
29
31
|
children
|
|
30
32
|
}
|
|
@@ -41,8 +43,19 @@ function useTableContext(throwIfNoDataSource = false) {
|
|
|
41
43
|
};
|
|
42
44
|
}
|
|
43
45
|
}
|
|
46
|
+
const useRowAction = (actionId) => {
|
|
47
|
+
const { rowActionHandlers } = react.useContext(TableContext);
|
|
48
|
+
if (rowActionHandlers?.[actionId]) {
|
|
49
|
+
return rowActionHandlers[actionId];
|
|
50
|
+
} else {
|
|
51
|
+
throw Error(
|
|
52
|
+
`[TableProvider] useRowAction, no action configured #${actionId}`
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
44
56
|
|
|
45
57
|
exports.TableContext = TableContext;
|
|
46
58
|
exports.TableProvider = TableProvider;
|
|
59
|
+
exports.useRowAction = useRowAction;
|
|
47
60
|
exports.useTableContext = useTableContext;
|
|
48
61
|
//# sourceMappingURL=TableProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableProvider.js","sources":["../../../../packages/vuu-table-extras/src/table-provider/TableProvider.tsx"],"sourcesContent":["import { MenuActionHandler } from \"@vuu-ui/vuu-context-menu\";\nimport { DataSource } from \"@vuu-ui/vuu-data-types\";\nimport {
|
|
1
|
+
{"version":3,"file":"TableProvider.js","sources":["../../../../packages/vuu-table-extras/src/table-provider/TableProvider.tsx"],"sourcesContent":["import type { MenuActionHandler } from \"@vuu-ui/vuu-context-menu\";\nimport type { DataSource } from \"@vuu-ui/vuu-data-types\";\nimport type { TableProps } from \"@vuu-ui/vuu-table\";\nimport type { ColumnDescriptor } from \"@vuu-ui/vuu-table-types\";\nimport { createContext, ReactNode, useContext } from \"react\";\nimport type { ColumnMenuActionType } from \"../column-menu/column-menu-utils\";\n\nexport interface TableContextProps\n extends Pick<TableProps, \"dataSource\" | \"rowActionHandlers\"> {\n menuActionHandler: MenuActionHandler<ColumnMenuActionType, ColumnDescriptor>;\n}\n\nconst NullMenuActionHandler = (menuItemId: string) => {\n console.log(\n `[TableContext] no menu action handler installed (menuItemHandler invoked with ${menuItemId})`,\n );\n return false;\n};\nconst NullDataSource = {} as DataSource;\n\nexport const TableContext = createContext<TableContextProps>({\n dataSource: NullDataSource,\n menuActionHandler: NullMenuActionHandler,\n});\n\nexport const TableProvider = ({\n children,\n dataSource,\n menuActionHandler,\n rowActionHandlers,\n}: TableContextProps & {\n children: ReactNode;\n}) => {\n return (\n <TableContext.Provider\n value={{\n dataSource,\n menuActionHandler,\n rowActionHandlers,\n }}\n >\n {children}\n </TableContext.Provider>\n );\n};\n\nexport function useTableContext(throwIfNoDataSource = false) {\n const { dataSource, menuActionHandler } = useContext(TableContext);\n if (\n dataSource === NullDataSource &&\n menuActionHandler == NullMenuActionHandler &&\n throwIfNoDataSource\n ) {\n throw Error(`[TableProvider] no DataSourceProvider has been declared`);\n } else {\n return {\n dataSource,\n menuActionHandler,\n };\n }\n}\n\nexport const useRowAction = (actionId: string) => {\n const { rowActionHandlers } = useContext(TableContext);\n if (rowActionHandlers?.[actionId]) {\n return rowActionHandlers[actionId];\n } else {\n throw Error(\n `[TableProvider] useRowAction, no action configured #${actionId}`,\n );\n }\n};\n"],"names":["createContext","jsx","useContext"],"mappings":";;;;;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;;;;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var iconButtonCellCss = "\n.vuuTableCell:has(.vuuIconButtonCell){\n padding: 0;\n position: relative;\n}\n\n.vuuIconButtonCell {\n align-items: center;\n display: inline-flex;\n justify-content: center;\n padding: 0;\n font-weight: 500;\n position: relative;\n height: 100%;\n --saltButton-height: 100%;\n --saltButton-minWidth: 100%;\n --saltButton-padding: 0;\n --saltButton-width: 100%;\n}\n";
|
|
2
|
+
|
|
3
|
+
export { iconButtonCellCss as default };
|
|
4
|
+
//# sourceMappingURL=IconButtonCell.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IconButtonCell.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { useComponentCssInjection } from '@salt-ds/styles';
|
|
4
|
+
import { useWindow } from '@salt-ds/window';
|
|
5
|
+
import iconButtonCellCss from './IconButtonCell.css.js';
|
|
6
|
+
import { useRowAction } from '../../table-provider/TableProvider.js';
|
|
7
|
+
import { Button } from '@salt-ds/core';
|
|
8
|
+
|
|
9
|
+
const classBase = "vuuIconButtonCell";
|
|
10
|
+
const IconButtonCell = ({ column, row }) => {
|
|
11
|
+
const targetWindow = useWindow();
|
|
12
|
+
useComponentCssInjection({
|
|
13
|
+
testId: "vuu-dropdown-cell",
|
|
14
|
+
css: iconButtonCellCss,
|
|
15
|
+
window: targetWindow
|
|
16
|
+
});
|
|
17
|
+
const actionHandler = useRowAction(column.name);
|
|
18
|
+
const handleClick = useCallback(
|
|
19
|
+
(evt) => {
|
|
20
|
+
evt.stopPropagation();
|
|
21
|
+
actionHandler(column.name, row);
|
|
22
|
+
},
|
|
23
|
+
[actionHandler, column, row]
|
|
24
|
+
);
|
|
25
|
+
return /* @__PURE__ */ jsx(
|
|
26
|
+
Button,
|
|
27
|
+
{
|
|
28
|
+
appearance: "transparent",
|
|
29
|
+
className: classBase,
|
|
30
|
+
"data-embedded": true,
|
|
31
|
+
"data-icon": true,
|
|
32
|
+
onClick: handleClick
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export { IconButtonCell };
|
|
38
|
+
//# sourceMappingURL=IconButtonCell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IconButtonCell.js","sources":["../../../../../packages/vuu-table-extras/src/cell-renderers/button-cell/IconButtonCell.tsx"],"sourcesContent":["import { TableCellRendererProps } from \"@vuu-ui/vuu-table-types\";\nimport { MouseEventHandler, useCallback } from \"react\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\n\nimport iconButtonCellCss from \"./IconButtonCell.css\";\nimport { useRowAction } from \"../../table-provider/TableProvider\";\nimport { Button } from \"@salt-ds/core\";\n\nconst classBase = \"vuuIconButtonCell\";\n\n/**\n * To assign an icon to the cell, give the columndescriptor\n * a className. In css, assign an icon variable to --vuu-svg-icon.\n */\nexport const IconButtonCell = ({ column, row }: TableCellRendererProps) => {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"vuu-dropdown-cell\",\n css: iconButtonCellCss,\n window: targetWindow,\n });\n\n const actionHandler = useRowAction(column.name);\n const handleClick = useCallback<MouseEventHandler<HTMLButtonElement>>(\n (evt) => {\n evt.stopPropagation();\n actionHandler(column.name, row);\n },\n [actionHandler, column, row],\n );\n\n return (\n <Button\n appearance=\"transparent\"\n className={classBase}\n data-embedded\n data-icon\n onClick={handleClick}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;;;AASA,MAAM,SAAY,GAAA,mBAAA;AAMX,MAAM,cAAiB,GAAA,CAAC,EAAE,MAAA,EAAQ,KAAkC,KAAA;AACzE,EAAA,MAAM,eAAe,SAAU,EAAA;AAC/B,EAAyB,wBAAA,CAAA;AAAA,IACvB,MAAQ,EAAA,mBAAA;AAAA,IACR,GAAK,EAAA,iBAAA;AAAA,IACL,MAAQ,EAAA;AAAA,GACT,CAAA;AAED,EAAM,MAAA,aAAA,GAAgB,YAAa,CAAA,MAAA,CAAO,IAAI,CAAA;AAC9C,EAAA,MAAM,WAAc,GAAA,WAAA;AAAA,IAClB,CAAC,GAAQ,KAAA;AACP,MAAA,GAAA,CAAI,eAAgB,EAAA;AACpB,MAAc,aAAA,CAAA,MAAA,CAAO,MAAM,GAAG,CAAA;AAAA,KAChC;AAAA,IACA,CAAC,aAAe,EAAA,MAAA,EAAQ,GAAG;AAAA,GAC7B;AAEA,EACE,uBAAA,GAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,UAAW,EAAA,aAAA;AAAA,MACX,SAAW,EAAA,SAAA;AAAA,MACX,eAAa,EAAA,IAAA;AAAA,MACb,WAAS,EAAA,IAAA;AAAA,MACT,OAAS,EAAA;AAAA;AAAA,GACX;AAEJ;;;;"}
|
package/esm/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export { DropdownCell } from './cell-renderers/dropdown-cell/DropdownCell.js';
|
|
|
6
6
|
export { LookupCell } from './cell-renderers/lookup-cell/LookupCell.js';
|
|
7
7
|
export { PctProgressCell } from './cell-renderers/pct-progress-cell/PctProgressCell.js';
|
|
8
8
|
import './cell-renderers/progress-cell/ProgressCell.js';
|
|
9
|
+
export { IconButtonCell } from './cell-renderers/button-cell/IconButtonCell.js';
|
|
9
10
|
export { ColumnList, classBase, classBaseListItem } from './column-list/ColumnList.js';
|
|
10
11
|
export { ColumnMenu } from './column-menu/ColumnMenu.js';
|
|
11
12
|
export { useColumnActions } from './column-menu/useColumnActions.js';
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -15,14 +15,16 @@ const TableContext = createContext({
|
|
|
15
15
|
const TableProvider = ({
|
|
16
16
|
children,
|
|
17
17
|
dataSource,
|
|
18
|
-
menuActionHandler
|
|
18
|
+
menuActionHandler,
|
|
19
|
+
rowActionHandlers
|
|
19
20
|
}) => {
|
|
20
21
|
return /* @__PURE__ */ jsx(
|
|
21
22
|
TableContext.Provider,
|
|
22
23
|
{
|
|
23
24
|
value: {
|
|
24
25
|
dataSource,
|
|
25
|
-
menuActionHandler
|
|
26
|
+
menuActionHandler,
|
|
27
|
+
rowActionHandlers
|
|
26
28
|
},
|
|
27
29
|
children
|
|
28
30
|
}
|
|
@@ -39,6 +41,16 @@ function useTableContext(throwIfNoDataSource = false) {
|
|
|
39
41
|
};
|
|
40
42
|
}
|
|
41
43
|
}
|
|
44
|
+
const useRowAction = (actionId) => {
|
|
45
|
+
const { rowActionHandlers } = useContext(TableContext);
|
|
46
|
+
if (rowActionHandlers?.[actionId]) {
|
|
47
|
+
return rowActionHandlers[actionId];
|
|
48
|
+
} else {
|
|
49
|
+
throw Error(
|
|
50
|
+
`[TableProvider] useRowAction, no action configured #${actionId}`
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
42
54
|
|
|
43
|
-
export { TableContext, TableProvider, useTableContext };
|
|
55
|
+
export { TableContext, TableProvider, useRowAction, useTableContext };
|
|
44
56
|
//# sourceMappingURL=TableProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableProvider.js","sources":["../../../../packages/vuu-table-extras/src/table-provider/TableProvider.tsx"],"sourcesContent":["import { MenuActionHandler } from \"@vuu-ui/vuu-context-menu\";\nimport { DataSource } from \"@vuu-ui/vuu-data-types\";\nimport {
|
|
1
|
+
{"version":3,"file":"TableProvider.js","sources":["../../../../packages/vuu-table-extras/src/table-provider/TableProvider.tsx"],"sourcesContent":["import type { MenuActionHandler } from \"@vuu-ui/vuu-context-menu\";\nimport type { DataSource } from \"@vuu-ui/vuu-data-types\";\nimport type { TableProps } from \"@vuu-ui/vuu-table\";\nimport type { ColumnDescriptor } from \"@vuu-ui/vuu-table-types\";\nimport { createContext, ReactNode, useContext } from \"react\";\nimport type { ColumnMenuActionType } from \"../column-menu/column-menu-utils\";\n\nexport interface TableContextProps\n extends Pick<TableProps, \"dataSource\" | \"rowActionHandlers\"> {\n menuActionHandler: MenuActionHandler<ColumnMenuActionType, ColumnDescriptor>;\n}\n\nconst NullMenuActionHandler = (menuItemId: string) => {\n console.log(\n `[TableContext] no menu action handler installed (menuItemHandler invoked with ${menuItemId})`,\n );\n return false;\n};\nconst NullDataSource = {} as DataSource;\n\nexport const TableContext = createContext<TableContextProps>({\n dataSource: NullDataSource,\n menuActionHandler: NullMenuActionHandler,\n});\n\nexport const TableProvider = ({\n children,\n dataSource,\n menuActionHandler,\n rowActionHandlers,\n}: TableContextProps & {\n children: ReactNode;\n}) => {\n return (\n <TableContext.Provider\n value={{\n dataSource,\n menuActionHandler,\n rowActionHandlers,\n }}\n >\n {children}\n </TableContext.Provider>\n );\n};\n\nexport function useTableContext(throwIfNoDataSource = false) {\n const { dataSource, menuActionHandler } = useContext(TableContext);\n if (\n dataSource === NullDataSource &&\n menuActionHandler == NullMenuActionHandler &&\n throwIfNoDataSource\n ) {\n throw Error(`[TableProvider] no DataSourceProvider has been declared`);\n } else {\n return {\n dataSource,\n menuActionHandler,\n };\n }\n}\n\nexport const useRowAction = (actionId: string) => {\n const { rowActionHandlers } = useContext(TableContext);\n if (rowActionHandlers?.[actionId]) {\n return rowActionHandlers[actionId];\n } else {\n throw Error(\n `[TableProvider] useRowAction, no action configured #${actionId}`,\n );\n }\n};\n"],"names":[],"mappings":";;;AAYA,MAAM,qBAAA,GAAwB,CAAC,UAAuB,KAAA;AACpD,EAAQ,OAAA,CAAA,GAAA;AAAA,IACN,iFAAiF,UAAU,CAAA,CAAA;AAAA,GAC7F;AACA,EAAO,OAAA,KAAA;AACT,CAAA;AACA,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ependencies": {
|
|
6
|
-
"@vuu-ui/vuu-filter-types": "0.13.
|
|
7
|
-
"@vuu-ui/vuu-protocol-types": "0.13.
|
|
6
|
+
"@vuu-ui/vuu-filter-types": "0.13.35",
|
|
7
|
+
"@vuu-ui/vuu-protocol-types": "0.13.35"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@vuu-ui/vuu-codemirror": "0.13.
|
|
11
|
-
"@vuu-ui/vuu-data-react": "0.13.
|
|
12
|
-
"@vuu-ui/vuu-data-types": "0.13.
|
|
13
|
-
"@vuu-ui/vuu-table-types": "0.13.
|
|
14
|
-
"@vuu-ui/vuu-popups": "0.13.
|
|
15
|
-
"@vuu-ui/vuu-table": "0.13.
|
|
16
|
-
"@vuu-ui/vuu-utils": "0.13.
|
|
17
|
-
"@vuu-ui/vuu-ui-controls": "0.13.
|
|
10
|
+
"@vuu-ui/vuu-codemirror": "0.13.35",
|
|
11
|
+
"@vuu-ui/vuu-data-react": "0.13.35",
|
|
12
|
+
"@vuu-ui/vuu-data-types": "0.13.35",
|
|
13
|
+
"@vuu-ui/vuu-table-types": "0.13.35",
|
|
14
|
+
"@vuu-ui/vuu-popups": "0.13.35",
|
|
15
|
+
"@vuu-ui/vuu-table": "0.13.35",
|
|
16
|
+
"@vuu-ui/vuu-utils": "0.13.35",
|
|
17
|
+
"@vuu-ui/vuu-ui-controls": "0.13.35",
|
|
18
18
|
"@lezer/lr": "1.4.2",
|
|
19
19
|
"@salt-ds/core": "1.43.0",
|
|
20
20
|
"@salt-ds/styles": "0.2.1",
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { TableCellRendererProps } from "@vuu-ui/vuu-table-types";
|
|
2
|
+
/**
|
|
3
|
+
* To assign an icon to the cell, give the columndescriptor
|
|
4
|
+
* a className. In css, assign an icon variable to --vuu-svg-icon.
|
|
5
|
+
*/
|
|
6
|
+
export declare const IconButtonCell: ({ column, row }: TableCellRendererProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { MenuActionHandler } from "@vuu-ui/vuu-context-menu";
|
|
2
|
-
import { DataSource } from "@vuu-ui/vuu-data-types";
|
|
1
|
+
import type { MenuActionHandler } from "@vuu-ui/vuu-context-menu";
|
|
2
|
+
import type { DataSource } from "@vuu-ui/vuu-data-types";
|
|
3
|
+
import type { TableProps } from "@vuu-ui/vuu-table";
|
|
4
|
+
import type { ColumnDescriptor } from "@vuu-ui/vuu-table-types";
|
|
3
5
|
import { ReactNode } from "react";
|
|
4
|
-
import { ColumnMenuActionType } from "../column-menu/column-menu-utils";
|
|
5
|
-
|
|
6
|
-
export interface TableContextProps {
|
|
7
|
-
dataSource: DataSource;
|
|
6
|
+
import type { ColumnMenuActionType } from "../column-menu/column-menu-utils";
|
|
7
|
+
export interface TableContextProps extends Pick<TableProps, "dataSource" | "rowActionHandlers"> {
|
|
8
8
|
menuActionHandler: MenuActionHandler<ColumnMenuActionType, ColumnDescriptor>;
|
|
9
9
|
}
|
|
10
10
|
export declare const TableContext: import("react").Context<TableContextProps>;
|
|
11
|
-
export declare const TableProvider: ({ children, dataSource, menuActionHandler, }: TableContextProps & {
|
|
11
|
+
export declare const TableProvider: ({ children, dataSource, menuActionHandler, rowActionHandlers, }: TableContextProps & {
|
|
12
12
|
children: ReactNode;
|
|
13
13
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
14
14
|
export declare function useTableContext(throwIfNoDataSource?: boolean): {
|
|
15
15
|
dataSource: DataSource;
|
|
16
16
|
menuActionHandler: MenuActionHandler<ColumnMenuActionType, ColumnDescriptor>;
|
|
17
17
|
};
|
|
18
|
+
export declare const useRowAction: (actionId: string) => import("@vuu-ui/vuu-table-types").RowActionHandler;
|