@olenbetong/appframe-ds 1.7.2 → 1.8.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.
- package/CHANGELOG.md +6 -0
- package/package.json +2 -2
- package/src/grid/Toolbar.tsx +75 -10
- package/src/grid/index.tsx +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @olenbetong/appframe-ds
|
|
2
2
|
|
|
3
|
+
## 1.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- eb09c99: Grid toolbar buttons for compact toolbars: `GridToolbarFilterButton` and `GridToolbarRefreshButton` take `iconOnly`, and `GridToolbarMoreOptionsButton` takes `showColumns` (the column panel as a menu item) and extra items as `children`. The more menu now closes when an item is chosen.
|
|
8
|
+
|
|
3
9
|
## 1.7.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olenbetong/appframe-ds",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "Components that bind Designsystemet components to Appframe data objects",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./es/index.d.ts",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "3.0.0",
|
|
65
65
|
"@base-ui/react": "1.9.0",
|
|
66
66
|
"@olenbetong/appframe-core": "^2.15.2",
|
|
67
|
-
"@olenbetong/appframe-data": "^1.8.
|
|
67
|
+
"@olenbetong/appframe-data": "^1.8.5",
|
|
68
68
|
"@olenbetong/appframe-react": "^2.2.8",
|
|
69
69
|
"clsx": "^2.1.1",
|
|
70
70
|
"dockview-react": "8.6.1",
|
package/src/grid/Toolbar.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Button, Dropdown } from "@digdir/designsystemet-react";
|
|
1
|
+
import { Badge, BadgePosition, Button, Dropdown } from "@digdir/designsystemet-react";
|
|
2
2
|
import {
|
|
3
3
|
type GridApi,
|
|
4
4
|
type GridExportMenuItemProps,
|
|
@@ -20,6 +20,8 @@ import {
|
|
|
20
20
|
import { type DataObject, exportOptionsFromDataObject } from "@olenbetong/appframe-data";
|
|
21
21
|
import { useDataObject, useLoading, usePermissions } from "@olenbetong/appframe-react";
|
|
22
22
|
|
|
23
|
+
import { useState } from "react";
|
|
24
|
+
|
|
23
25
|
import { openDataObjectReportWithProgress } from "../report-downloader/index.js";
|
|
24
26
|
import { useAfGridContext } from "./AfGridContext.js";
|
|
25
27
|
import { addRow } from "./editing.js";
|
|
@@ -45,16 +47,30 @@ export function GridToolbarAddIfAllowedButton({ disableInsert }: { disableInsert
|
|
|
45
47
|
) : null;
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
export
|
|
50
|
+
export type GridToolbarIconOnlyProps = {
|
|
51
|
+
/** Show the icon alone, with the label as its accessible name and tooltip. */
|
|
52
|
+
iconOnly?: boolean;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export function GridToolbarRefreshButton({ iconOnly }: GridToolbarIconOnlyProps = {}) {
|
|
49
56
|
let dataObject = useDataObject();
|
|
50
57
|
let isLoading = useLoading(dataObject);
|
|
58
|
+
let label = getLocalizedString("Refresh");
|
|
51
59
|
|
|
52
60
|
return (
|
|
53
|
-
<Button
|
|
61
|
+
<Button
|
|
62
|
+
variant="tertiary"
|
|
63
|
+
data-size="sm"
|
|
64
|
+
icon={iconOnly}
|
|
65
|
+
aria-label={iconOnly ? label : undefined}
|
|
66
|
+
title={iconOnly ? label : undefined}
|
|
67
|
+
loading={isLoading}
|
|
68
|
+
onClick={() => dataObject.refreshDataSource()}
|
|
69
|
+
>
|
|
54
70
|
{/* Designsystemet prepends the spinner rather than replacing the children, so
|
|
55
71
|
the icon is hidden while loading to keep the button from changing width */}
|
|
56
72
|
{!isLoading && <ArrowsCirclepathIcon aria-hidden />}
|
|
57
|
-
{
|
|
73
|
+
{!iconOnly && label}
|
|
58
74
|
</Button>
|
|
59
75
|
);
|
|
60
76
|
}
|
|
@@ -74,13 +90,26 @@ export function GridToolbarColumnsButton() {
|
|
|
74
90
|
* Opens the filter builder instead of the grid's own filter panel. The count
|
|
75
91
|
* reflects the conditions in the builder's filter, not the header filters.
|
|
76
92
|
*/
|
|
77
|
-
export function GridToolbarFilterButton() {
|
|
93
|
+
export function GridToolbarFilterButton({ iconOnly }: GridToolbarIconOnlyProps = {}) {
|
|
78
94
|
let { openFilterBuilder, filterCount } = useAfGridContext();
|
|
95
|
+
let label = getLocalizedString("Filter");
|
|
96
|
+
|
|
97
|
+
if (iconOnly) {
|
|
98
|
+
let name = filterCount > 0 ? `${label} (${filterCount})` : label;
|
|
99
|
+
return (
|
|
100
|
+
<BadgePosition placement="top-right" overlap="circle">
|
|
101
|
+
{filterCount > 0 && <Badge data-color="brand" data-size="sm" count={filterCount} aria-hidden="true" />}
|
|
102
|
+
<Button variant="tertiary" data-size="sm" icon aria-label={name} title={name} onClick={openFilterBuilder}>
|
|
103
|
+
<FilterIcon aria-hidden />
|
|
104
|
+
</Button>
|
|
105
|
+
</BadgePosition>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
79
108
|
|
|
80
109
|
return (
|
|
81
110
|
<Button variant="tertiary" data-size="sm" onClick={openFilterBuilder}>
|
|
82
111
|
<FilterIcon aria-hidden />
|
|
83
|
-
{
|
|
112
|
+
{label}
|
|
84
113
|
{filterCount > 0 ? ` (${filterCount})` : ""}
|
|
85
114
|
</Button>
|
|
86
115
|
);
|
|
@@ -160,16 +189,52 @@ export function AfGridToolbarExcelExportButton({ fileName, title }: { fileName?:
|
|
|
160
189
|
);
|
|
161
190
|
}
|
|
162
191
|
|
|
163
|
-
export
|
|
192
|
+
export type GridToolbarMoreOptionsButtonProps = React.PropsWithChildren<{
|
|
193
|
+
/** Offer the column panel in the menu, for toolbars without a Columns button. */
|
|
194
|
+
showColumns?: boolean;
|
|
195
|
+
}>;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* The toolbar's "more" menu: exports, density and layout reset. `children` are extra
|
|
199
|
+
* `Dropdown.Item`s placed first. The menu closes when an item is chosen.
|
|
200
|
+
*/
|
|
201
|
+
export function GridToolbarMoreOptionsButton({ showColumns, children }: GridToolbarMoreOptionsButtonProps = {}) {
|
|
164
202
|
let apiRef = useGridApiContext();
|
|
203
|
+
let { openColumnsPanel } = useAfGridContext();
|
|
204
|
+
let [open, setOpen] = useState(false);
|
|
165
205
|
|
|
166
206
|
return (
|
|
167
207
|
<Dropdown.TriggerContext>
|
|
168
|
-
<Dropdown.Trigger
|
|
208
|
+
<Dropdown.Trigger
|
|
209
|
+
variant="tertiary"
|
|
210
|
+
icon
|
|
211
|
+
data-size="sm"
|
|
212
|
+
aria-label={getLocalizedString("More options")}
|
|
213
|
+
title={getLocalizedString("More options")}
|
|
214
|
+
>
|
|
169
215
|
<MenuElipsisVerticalIcon aria-hidden />
|
|
170
216
|
</Dropdown.Trigger>
|
|
171
|
-
<Dropdown
|
|
172
|
-
|
|
217
|
+
<Dropdown
|
|
218
|
+
open={open}
|
|
219
|
+
onOpen={() => setOpen(true)}
|
|
220
|
+
onClose={() => setOpen(false)}
|
|
221
|
+
placement="bottom-end"
|
|
222
|
+
data-size="sm"
|
|
223
|
+
>
|
|
224
|
+
<Dropdown.List
|
|
225
|
+
onClick={(event) => {
|
|
226
|
+
if ((event.target as HTMLElement).closest("button, a")) setOpen(false);
|
|
227
|
+
}}
|
|
228
|
+
>
|
|
229
|
+
{children}
|
|
230
|
+
{showColumns && (
|
|
231
|
+
<Dropdown.Item>
|
|
232
|
+
<Dropdown.Button onClick={openColumnsPanel}>
|
|
233
|
+
<TableIcon aria-hidden />
|
|
234
|
+
{getLocalizedString("Columns")}
|
|
235
|
+
</Dropdown.Button>
|
|
236
|
+
</Dropdown.Item>
|
|
237
|
+
)}
|
|
173
238
|
<Dropdown.Item>
|
|
174
239
|
<Dropdown.Button onClick={() => apiRef.current.exportDataAsCsv()}>
|
|
175
240
|
<FileCsvIcon aria-hidden />
|
package/src/grid/index.tsx
CHANGED
|
@@ -41,7 +41,9 @@ import {
|
|
|
41
41
|
GridToolbarColumnsButton,
|
|
42
42
|
GridToolbarContainer,
|
|
43
43
|
GridToolbarFilterButton,
|
|
44
|
+
type GridToolbarIconOnlyProps,
|
|
44
45
|
GridToolbarMoreOptionsButton,
|
|
46
|
+
type GridToolbarMoreOptionsButtonProps,
|
|
45
47
|
GridToolbarRefreshButton,
|
|
46
48
|
GridToolbarResetLayoutButton,
|
|
47
49
|
} from "./Toolbar.js";
|
|
@@ -109,6 +111,8 @@ export type {
|
|
|
109
111
|
AfGridColumn,
|
|
110
112
|
AfGridExcelExportOptions,
|
|
111
113
|
AfGridNewItemRowPosition,
|
|
114
|
+
GridToolbarIconOnlyProps,
|
|
115
|
+
GridToolbarMoreOptionsButtonProps,
|
|
112
116
|
AfGridRowAction,
|
|
113
117
|
};
|
|
114
118
|
export type { AfGridGrouping, AfGridGroupingProps } from "./useAfRowGrouping.js";
|