@olenbetong/synergi-react 2.9.0 → 3.0.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/es/chrome/AppShell/index.d.ts +8 -0
- package/es/chrome/AppShell/index.js +10 -130
- package/es/components/ImageEditor/ImageEditor.css +10 -0
- package/es/components/ImageEditor/index.d.ts +1 -0
- package/es/components/ImageEditor/index.js +1 -0
- package/es/components/ImageEditor/plugins/cropPlugin/CropOverlay.js +27 -5
- package/es/components/ImageEditor/plugins/cropPlugin/CropToolbar.js +4 -3
- package/es/components/ImageEditor/plugins/cropPlugin/useCropTool.d.ts +20 -3
- package/es/components/ImageEditor/plugins/cropPlugin/useCropTool.js +216 -33
- package/es/components/ImageEditor/plugins/zoomPlugin/ZoomContext.d.ts +5 -0
- package/es/components/ImageEditor/plugins/zoomPlugin/ZoomContext.js +7 -0
- package/es/components/ImageEditor/useEdgeDetection.d.ts +0 -2
- package/es/components/ImageEditor/useEdgeDetection.js +11 -30
- package/es/components/ImageEditor/useOpenCV.d.ts +26 -1
- package/es/components/ImageEditor/useOpenCV.js +108 -42
- package/es/components/SplitContainer/index.js +2 -4
- package/es/filter/ChipListInput.d.ts +13 -0
- package/es/filter/ChipListInput.js +34 -0
- package/es/filter/FilterBuilder.css +152 -0
- package/es/filter/FilterBuilder.d.ts +115 -0
- package/es/filter/FilterBuilder.js +146 -0
- package/es/filter/FilterBuilder.test.d.ts +1 -0
- package/es/filter/FilterBuilder.test.js +120 -0
- package/es/filter/FilterEditor.css +231 -0
- package/es/filter/FilterEditor.d.ts +17 -0
- package/es/filter/FilterEditor.js +38 -0
- package/es/filter/FilterEditor.test.d.ts +1 -0
- package/es/filter/FilterEditor.test.js +183 -0
- package/es/filter/FilterGroupEditor.d.ts +22 -0
- package/es/filter/FilterGroupEditor.js +34 -0
- package/es/filter/FilterNameDialog.css +22 -0
- package/es/filter/FilterNameDialog.d.ts +18 -0
- package/es/filter/FilterNameDialog.js +32 -0
- package/es/filter/FilterRow.d.ts +14 -0
- package/es/filter/FilterRow.js +32 -0
- package/es/filter/FilterShareDialog.css +28 -0
- package/es/filter/FilterShareDialog.d.ts +23 -0
- package/es/filter/FilterShareDialog.js +63 -0
- package/es/filter/FilterStringField.d.ts +15 -0
- package/es/filter/FilterStringField.js +37 -0
- package/es/filter/FilterValueEditor.d.ts +16 -0
- package/es/filter/FilterValueEditor.js +85 -0
- package/es/filter/SavedFilterTree.css +107 -0
- package/es/filter/SavedFilterTree.d.ts +45 -0
- package/es/filter/SavedFilterTree.js +44 -0
- package/es/filter/SavedFilterTree.test.d.ts +1 -0
- package/es/filter/SavedFilterTree.test.js +75 -0
- package/es/filter/index.d.ts +11 -0
- package/es/filter/index.js +10 -0
- package/es/filter/types.d.ts +34 -0
- package/es/filter/types.js +1 -0
- package/es/index.d.ts +2 -1
- package/es/index.js +6 -1
- package/es/mui/MuiThemeProvider.d.ts +24 -0
- package/es/mui/MuiThemeProvider.js +152 -0
- package/es/mui/index.d.ts +1 -0
- package/es/mui/index.js +1 -0
- package/es/report/ReportLauncher.css +147 -0
- package/es/report/ReportLauncher.d.ts +55 -0
- package/es/report/ReportLauncher.js +142 -0
- package/es/report/ReportLauncher.test.d.ts +1 -0
- package/es/report/ReportLauncher.test.js +231 -0
- package/es/report/ReportParameters.css +29 -0
- package/es/report/ReportParameters.d.ts +46 -0
- package/es/report/ReportParameters.js +65 -0
- package/es/report/ReportParameters.test.d.ts +1 -0
- package/es/report/ReportParameters.test.js +84 -0
- package/es/report/index.d.ts +2 -0
- package/es/report/index.js +2 -0
- package/es/test/setup.d.ts +1 -0
- package/es/test/setup.js +6 -0
- package/package.json +22 -7
- package/src/chrome/AppShell/index.tsx +34 -171
- package/src/components/ImageEditor/ImageEditor.css +10 -0
- package/src/components/ImageEditor/index.ts +1 -0
- package/src/components/ImageEditor/plugins/cropPlugin/CropOverlay.tsx +66 -20
- package/src/components/ImageEditor/plugins/cropPlugin/CropToolbar.tsx +19 -3
- package/src/components/ImageEditor/plugins/cropPlugin/useCropTool.ts +266 -39
- package/src/components/ImageEditor/plugins/zoomPlugin/ZoomContext.tsx +8 -0
- package/src/components/ImageEditor/useEdgeDetection.ts +11 -51
- package/src/components/ImageEditor/useOpenCV.ts +112 -62
- package/src/components/SplitContainer/index.tsx +3 -4
- package/src/filter/ChipListInput.tsx +79 -0
- package/src/filter/FilterBuilder.css +152 -0
- package/src/filter/FilterBuilder.test.tsx +153 -0
- package/src/filter/FilterBuilder.tsx +435 -0
- package/src/filter/FilterEditor.css +231 -0
- package/src/filter/FilterEditor.test.tsx +259 -0
- package/src/filter/FilterEditor.tsx +74 -0
- package/src/filter/FilterGroupEditor.tsx +160 -0
- package/src/filter/FilterNameDialog.css +22 -0
- package/src/filter/FilterNameDialog.tsx +81 -0
- package/src/filter/FilterRow.tsx +117 -0
- package/src/filter/FilterShareDialog.css +28 -0
- package/src/filter/FilterShareDialog.tsx +201 -0
- package/src/filter/FilterStringField.tsx +77 -0
- package/src/filter/FilterValueEditor.tsx +220 -0
- package/src/filter/SavedFilterTree.css +107 -0
- package/src/filter/SavedFilterTree.test.tsx +94 -0
- package/src/filter/SavedFilterTree.tsx +222 -0
- package/src/filter/index.ts +11 -0
- package/src/filter/types.ts +38 -0
- package/src/index.ts +39 -1
- package/src/mui/MuiThemeProvider.tsx +174 -0
- package/src/mui/index.ts +1 -0
- package/src/report/ReportLauncher.css +147 -0
- package/src/report/ReportLauncher.test.tsx +281 -0
- package/src/report/ReportLauncher.tsx +421 -0
- package/src/report/ReportParameters.css +29 -0
- package/src/report/ReportParameters.test.tsx +133 -0
- package/src/report/ReportParameters.tsx +198 -0
- package/src/report/index.ts +2 -0
- package/src/test/setup.ts +8 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Colours use the contextual `--ds-color-*` aliases so the dialog follows the
|
|
3
|
+
* active colour scheme. Never add hex fallbacks.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
.ObFilterShareDialog-root {
|
|
7
|
+
inline-size: min(40rem, 100%);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.ObFilterShareDialog-candidate {
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
gap: var(--ds-size-2);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.ObFilterShareDialog-candidateLogin {
|
|
17
|
+
margin-inline-start: auto;
|
|
18
|
+
color: var(--ds-color-text-subtle);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.ObFilterShareDialog-table {
|
|
22
|
+
inline-size: 100%;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.ObFilterShareDialog-error {
|
|
26
|
+
margin: 0 0 var(--ds-size-2);
|
|
27
|
+
color: var(--ds-color-danger-text-default);
|
|
28
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import "./FilterShareDialog.css";
|
|
2
|
+
export type FilterShareDialogProps = {
|
|
3
|
+
open: boolean;
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
/** `FilterID` of the filter to manage sharing for. */
|
|
6
|
+
filterId: number | null;
|
|
7
|
+
/** Shown in the dialog heading. */
|
|
8
|
+
filterName?: string;
|
|
9
|
+
"data-size"?: "sm" | "md" | "lg";
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Manages who a saved filter is shared with.
|
|
13
|
+
*
|
|
14
|
+
* Only a manager of the filter can load or change the grants — for anyone else
|
|
15
|
+
* `sstp_WebSiteCMS_FilterBuilder_GetPermissions` returns nothing, so the list
|
|
16
|
+
* simply stays empty.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```jsx
|
|
20
|
+
* <FilterShareDialog open={sharing} filterId={selected} filterName={name} onClose={() => setSharing(false)} />
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function FilterShareDialog({ open, onClose, filterId, filterName, "data-size": size, }: FilterShareDialogProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, Dialog, Heading, Select, Table } from "@digdir/designsystemet-react";
|
|
3
|
+
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
4
|
+
import { useDebounce, useFilterPermissions } from "@olenbetong/appframe-react";
|
|
5
|
+
import { Combobox } from "@olenbetong/appframe-ds";
|
|
6
|
+
import { PersonGroupIcon, PersonIcon, TrashIcon } from "@navikt/aksel-icons";
|
|
7
|
+
import { useEffect, useState } from "react";
|
|
8
|
+
import "./FilterShareDialog.css";
|
|
9
|
+
/**
|
|
10
|
+
* Manages who a saved filter is shared with.
|
|
11
|
+
*
|
|
12
|
+
* Only a manager of the filter can load or change the grants — for anyone else
|
|
13
|
+
* `sstp_WebSiteCMS_FilterBuilder_GetPermissions` returns nothing, so the list
|
|
14
|
+
* simply stays empty.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```jsx
|
|
18
|
+
* <FilterShareDialog open={sharing} filterId={selected} filterName={name} onClose={() => setSharing(false)} />
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export function FilterShareDialog({ open, onClose, filterId, filterName, "data-size": size = "sm", }) {
|
|
22
|
+
let { permissions, loading, error, setPermission, removePermission, search } = useFilterPermissions(open ? filterId : null);
|
|
23
|
+
let [candidates, setCandidates] = useState([]);
|
|
24
|
+
let [searchText, setSearchText] = useState("");
|
|
25
|
+
let query = useDebounce(searchText, 300);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (!open || query.length < 2) {
|
|
28
|
+
setCandidates([]);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
let isCancelled = false;
|
|
32
|
+
search(query)
|
|
33
|
+
.then((results) => {
|
|
34
|
+
if (isCancelled)
|
|
35
|
+
return;
|
|
36
|
+
// Anyone who already has a grant is not a candidate for a new one.
|
|
37
|
+
let granted = new Set(permissions.map((permission) => permission.groupRef));
|
|
38
|
+
setCandidates(results.filter((result) => !granted.has(result.primKey)));
|
|
39
|
+
})
|
|
40
|
+
.catch(() => {
|
|
41
|
+
if (!isCancelled)
|
|
42
|
+
setCandidates([]);
|
|
43
|
+
});
|
|
44
|
+
return () => {
|
|
45
|
+
isCancelled = true;
|
|
46
|
+
};
|
|
47
|
+
}, [open, query, search, permissions]);
|
|
48
|
+
function handleAdd(candidate) {
|
|
49
|
+
if (!candidate)
|
|
50
|
+
return;
|
|
51
|
+
setSearchText("");
|
|
52
|
+
void setPermission(candidate.primKey, "Reader");
|
|
53
|
+
}
|
|
54
|
+
return (_jsxs(Dialog, { open: open, closedby: "any", "data-size": size, onClose: onClose, className: "ObFilterShareDialog-root", children: [_jsx(Dialog.Block, { children: _jsx(Heading, { level: 2, "data-size": "xs", children: filterName ? getLocalizedString("Sharing - {0}").replace("{0}", filterName) : getLocalizedString("Sharing") }) }), _jsx(Dialog.Block, { children: _jsx(Combobox, { options: candidates, value: null, inputValue: searchText, loading: loading, "data-size": size, label: getLocalizedString("Add user or group"), placeholder: getLocalizedString("Search..."), getOptionLabel: (option) => option.name, getOptionKey: (option) => option.primKey,
|
|
55
|
+
// The procedure searches both name and login, so filtering again on
|
|
56
|
+
// the label would drop everything matched by login.
|
|
57
|
+
filterOptions: (options) => [...options], noOptionsText: query.length < 2 ? getLocalizedString("Type to search") : getLocalizedString("No matches"), renderOption: (option) => (_jsxs("span", { className: "ObFilterShareDialog-candidate", children: [option.type === "User" ? _jsx(PersonIcon, { "aria-hidden": true }) : _jsx(PersonGroupIcon, { "aria-hidden": true }), _jsx("span", { children: option.name }), _jsx("span", { className: "ObFilterShareDialog-candidateLogin", children: option.login })] })),
|
|
58
|
+
// The picker never keeps a selection; picking an option adds a grant.
|
|
59
|
+
onInputChange: (_event, value) => setSearchText(value), onChange: (_event, value) => handleAdd(value) }) }), _jsxs(Dialog.Block, { children: [error && _jsx("p", { className: "ObFilterShareDialog-error", children: String(error.message ?? error) }), _jsxs(Table, { "data-size": size, className: "ObFilterShareDialog-table", children: [_jsx(Table.Head, { children: _jsxs(Table.Row, { children: [_jsx(Table.HeaderCell, { children: getLocalizedString("Name") }), _jsx(Table.HeaderCell, { children: getLocalizedString("Login") }), _jsx(Table.HeaderCell, { children: getLocalizedString("Access") }), _jsx(Table.HeaderCell, {})] }) }), _jsxs(Table.Body, { children: [permissions.length === 0 && (_jsx(Table.Row, { children: _jsx(Table.Cell, { colSpan: 4, children: loading ? getLocalizedString("Loading...") : getLocalizedString("Not shared with anyone") }) })), permissions.map((permission) => (_jsx(PermissionRow, { permission: permission, size: size, onChangeAccess: (accessLevel) => void setPermission(permission.groupRef, accessLevel), onRemove: () => void removePermission(permission.groupRef) }, permission.primKey)))] })] })] }), _jsx(Dialog.Block, { children: _jsx(Button, { type: "button", variant: "secondary", "data-size": size, onClick: onClose, children: getLocalizedString("Close") }) })] }));
|
|
60
|
+
}
|
|
61
|
+
function PermissionRow({ permission, size, onChangeAccess, onRemove }) {
|
|
62
|
+
return (_jsxs(Table.Row, { children: [_jsx(Table.Cell, { children: _jsxs("span", { className: "ObFilterShareDialog-candidate", children: [permission.type === "User" ? _jsx(PersonIcon, { "aria-hidden": true }) : _jsx(PersonGroupIcon, { "aria-hidden": true }), permission.name] }) }), _jsx(Table.Cell, { children: permission.login }), _jsx(Table.Cell, { children: _jsxs(Select, { "data-size": size, value: permission.accessLevel, "aria-label": getLocalizedString("Access for {0}").replace("{0}", permission.name), onChange: (event) => onChangeAccess(event.currentTarget.value), children: [_jsx(Select.Option, { value: "Reader", children: getLocalizedString("Reader") }), _jsx(Select.Option, { value: "Manager", children: getLocalizedString("Manager") })] }) }), _jsx(Table.Cell, { children: _jsx(Button, { type: "button", variant: "tertiary", "data-color": "danger", "data-size": size, icon: true, "aria-label": getLocalizedString("Remove access for {0}").replace("{0}", permission.name), onClick: onRemove, children: _jsx(TrashIcon, { "aria-hidden": true }) }) })] }));
|
|
63
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type FilterTree } from "@olenbetong/appframe-core";
|
|
2
|
+
import type { FilterEditorSize } from "./types.js";
|
|
3
|
+
export type FilterStringFieldProps = {
|
|
4
|
+
filter: FilterTree;
|
|
5
|
+
onChange: (filter: FilterTree) => void;
|
|
6
|
+
viewName?: string;
|
|
7
|
+
readOnly?: boolean;
|
|
8
|
+
"data-size"?: FilterEditorSize;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Two-way filter string editor. The tree is the source of truth: it is
|
|
12
|
+
* converted to a string whenever it changes. Editing the string and leaving the
|
|
13
|
+
* field parses it back into a tree.
|
|
14
|
+
*/
|
|
15
|
+
export declare function FilterStringField({ filter, onChange, viewName, readOnly, "data-size": size, }: FilterStringFieldProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Textfield, ValidationMessage } from "@digdir/designsystemet-react";
|
|
3
|
+
import { getLocalizedString, toFilterTree } from "@olenbetong/appframe-core";
|
|
4
|
+
import { useFilterConversion } from "@olenbetong/appframe-react";
|
|
5
|
+
import { useEffect, useState } from "react";
|
|
6
|
+
/**
|
|
7
|
+
* Two-way filter string editor. The tree is the source of truth: it is
|
|
8
|
+
* converted to a string whenever it changes. Editing the string and leaving the
|
|
9
|
+
* field parses it back into a tree.
|
|
10
|
+
*/
|
|
11
|
+
export function FilterStringField({ filter, onChange, viewName, readOnly, "data-size": size = "sm", }) {
|
|
12
|
+
let { filterString, isConverting, error, warning, parseFilterString } = useFilterConversion(filter, { viewName });
|
|
13
|
+
let [draft, setDraft] = useState(null);
|
|
14
|
+
let [parseError, setParseError] = useState(null);
|
|
15
|
+
// The tree changed underneath us, so any half-typed string is stale.
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
setDraft(null);
|
|
18
|
+
setParseError(null);
|
|
19
|
+
}, [filter]);
|
|
20
|
+
async function commit() {
|
|
21
|
+
if (draft === null || draft === filterString) {
|
|
22
|
+
setDraft(null);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
let parsed = await parseFilterString(draft);
|
|
26
|
+
if (parsed) {
|
|
27
|
+
setDraft(null);
|
|
28
|
+
setParseError(null);
|
|
29
|
+
onChange(toFilterTree(parsed));
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
setParseError(getLocalizedString("The filter could not be parsed"));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
let message = parseError ?? error?.message ?? warning;
|
|
36
|
+
return (_jsxs("div", { className: "ObFilterEditor-filterString", children: [_jsx(Textfield, { multiline: true, rows: 3, "data-size": size, readOnly: readOnly, label: _jsxs("span", { className: "ObFilterEditor-filterStringLabel", children: [getLocalizedString("Filter string"), isConverting && _jsx("span", { className: "ObFilterEditor-hint", children: getLocalizedString("Converting…") })] }), value: draft ?? filterString, onChange: (event) => setDraft(event.target.value), onBlur: commit }), message && _jsx(ValidationMessage, { "data-color": parseError ? "danger" : "warning", children: message })] }));
|
|
37
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type FieldMetadata, type FilterExpression } from "@olenbetong/appframe-core";
|
|
2
|
+
import type { FilterEditorSize, FilterValueOption } from "./types.js";
|
|
3
|
+
export type FilterValueEditorProps = {
|
|
4
|
+
expression: FilterExpression;
|
|
5
|
+
field?: FieldMetadata;
|
|
6
|
+
options?: FilterValueOption[];
|
|
7
|
+
onChange: (expression: FilterExpression) => void;
|
|
8
|
+
readOnly?: boolean;
|
|
9
|
+
"data-size"?: FilterEditorSize;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* The value part of a filter row. Which editor is rendered depends on the
|
|
13
|
+
* operator's arity, the field's type, and whether the value is a dynamic
|
|
14
|
+
* ("special") value such as `Today` or `CurrentUser`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function FilterValueEditor({ expression, field, options, onChange, readOnly, "data-size": size, }: FilterValueEditorProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Select, Textfield } from "@digdir/designsystemet-react";
|
|
3
|
+
import { PencilIcon } from "@navikt/aksel-icons";
|
|
4
|
+
import { getDynamicValueLabel, getDynamicValuesForField, getLocalizedString, getOperatorArity, getValueType, normalizeOperator, } from "@olenbetong/appframe-core";
|
|
5
|
+
import { Combobox } from "@olenbetong/appframe-ds";
|
|
6
|
+
import { ChipListInput } from "./ChipListInput.js";
|
|
7
|
+
/** The `input` type used for a field's scalar editor. */
|
|
8
|
+
function getInputType(field) {
|
|
9
|
+
switch (field?.type) {
|
|
10
|
+
case "number":
|
|
11
|
+
return "number";
|
|
12
|
+
case "date":
|
|
13
|
+
return "date";
|
|
14
|
+
case "datetime":
|
|
15
|
+
return "datetime-local";
|
|
16
|
+
default:
|
|
17
|
+
return "text";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function toStringValue(value) {
|
|
21
|
+
if (value === null || value === undefined)
|
|
22
|
+
return "";
|
|
23
|
+
if (value instanceof Date)
|
|
24
|
+
return value.toISOString();
|
|
25
|
+
return String(value);
|
|
26
|
+
}
|
|
27
|
+
function toArrayValue(value, length) {
|
|
28
|
+
let array = Array.isArray(value) ? value.map(toStringValue) : [];
|
|
29
|
+
if (length === undefined)
|
|
30
|
+
return array;
|
|
31
|
+
// Pair editors always render two inputs, even before both are filled in.
|
|
32
|
+
return Array.from({ length }, (_, index) => array[index] ?? "");
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The value part of a filter row. Which editor is rendered depends on the
|
|
36
|
+
* operator's arity, the field's type, and whether the value is a dynamic
|
|
37
|
+
* ("special") value such as `Today` or `CurrentUser`.
|
|
38
|
+
*/
|
|
39
|
+
export function FilterValueEditor({ expression, field, options, onChange, readOnly, "data-size": size = "sm", }) {
|
|
40
|
+
let operator = normalizeOperator(expression.operator);
|
|
41
|
+
let arity = getOperatorArity(operator);
|
|
42
|
+
let isDynamic = expression.valueType === "special";
|
|
43
|
+
let dynamicValues = field ? getDynamicValuesForField(field) : [];
|
|
44
|
+
let inputType = getInputType(field);
|
|
45
|
+
function setValue(value) {
|
|
46
|
+
onChange({ ...expression, value });
|
|
47
|
+
}
|
|
48
|
+
function setDynamic(enabled) {
|
|
49
|
+
if (enabled) {
|
|
50
|
+
onChange({ ...expression, value: dynamicValues[0] ?? null, valueType: "special" });
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
onChange({
|
|
54
|
+
...expression,
|
|
55
|
+
value: arity === "pair" ? ["", ""] : arity === "list" ? [] : "",
|
|
56
|
+
valueType: field ? getValueType(field, operator) : "string",
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (arity === "none")
|
|
61
|
+
return null;
|
|
62
|
+
let editor;
|
|
63
|
+
if (isDynamic) {
|
|
64
|
+
editor = (_jsx(Select, { className: "ObFilterEditor-value", "aria-label": getLocalizedString("Value"), "data-size": size, disabled: readOnly, value: toStringValue(expression.value), onChange: (event) => setValue(event.target.value), children: dynamicValues.map((dynamicValue) => (_jsx(Select.Option, { value: dynamicValue, children: getDynamicValueLabel(dynamicValue) }, dynamicValue))) }));
|
|
65
|
+
}
|
|
66
|
+
else if (arity === "list") {
|
|
67
|
+
editor = options ? (_jsx(Combobox, { className: "ObFilterEditor-value", multiple: true, "data-size": size, readOnly: readOnly, placeholder: getLocalizedString("Select values"), "aria-label": getLocalizedString("Value"), options: options, getOptionLabel: (option) => option.label ?? option.value, isOptionEqualToValue: (a, b) => a.value === b.value, value: toArrayValue(expression.value).map((item) => options.find((option) => option.value === item) ?? { value: item }), onChange: (_event, selected) => setValue(selected.map((option) => option.value)) })) : (_jsx(ChipListInput, { "aria-label": getLocalizedString("Value"), "data-size": size, readOnly: readOnly, type: inputType, value: toArrayValue(expression.value), onChange: setValue }));
|
|
68
|
+
}
|
|
69
|
+
else if (arity === "pair") {
|
|
70
|
+
let [from, to] = toArrayValue(expression.value, 2);
|
|
71
|
+
editor = (_jsxs("div", { className: "ObFilterEditor-pair", children: [_jsx(Textfield, { className: "ObFilterEditor-value", "aria-label": getLocalizedString("From"), "data-size": size, readOnly: readOnly, type: inputType, value: from, onChange: (event) => setValue([event.target.value, to]) }), _jsx("span", { className: "ObFilterEditor-pairSeparator", children: getLocalizedString("and") }), _jsx(Textfield, { className: "ObFilterEditor-value", "aria-label": getLocalizedString("To"), "data-size": size, readOnly: readOnly, type: inputType, value: to, onChange: (event) => setValue([from, event.target.value]) })] }));
|
|
72
|
+
}
|
|
73
|
+
else if (options) {
|
|
74
|
+
let current = toStringValue(expression.value);
|
|
75
|
+
editor = (_jsx(Combobox, { className: "ObFilterEditor-value", "data-size": size, readOnly: readOnly, placeholder: getLocalizedString("Select value"), "aria-label": getLocalizedString("Value"), options: options, getOptionLabel: (option) => option.label ?? option.value, isOptionEqualToValue: (a, b) => a.value === b.value, value: current ? (options.find((option) => option.value === current) ?? { value: current }) : null, onChange: (_event, selected) => setValue(selected?.value ?? "") }));
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
editor = (_jsx(Textfield, { className: "ObFilterEditor-value", "aria-label": getLocalizedString("Value"), "data-size": size, readOnly: readOnly, type: inputType, value: toStringValue(expression.value), onChange: (event) => setValue(event.target.value) }));
|
|
79
|
+
}
|
|
80
|
+
// Dynamic values are resolved server side, so they can only replace the whole
|
|
81
|
+
// value. Pairs would need one toggle per side, which the Windows editor does
|
|
82
|
+
// not offer either.
|
|
83
|
+
let canToggleDynamic = !readOnly && dynamicValues.length > 0 && arity === "single";
|
|
84
|
+
return (_jsxs("div", { className: "ObFilterEditor-valueCell", children: [editor, canToggleDynamic && (_jsx("button", { type: "button", className: "ObFilterEditor-iconButton", "aria-pressed": isDynamic, title: getLocalizedString("Use a relative value"), "aria-label": getLocalizedString("Use a relative value"), onClick: () => setDynamic(!isDynamic), children: _jsx(PencilIcon, { "aria-hidden": true }) }))] }));
|
|
85
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Colours use the contextual `--ds-color-*` aliases so the tree follows the
|
|
3
|
+
* active colour scheme. Never add hex fallbacks — they only encode the light
|
|
4
|
+
* theme and silently mask misspelled tokens.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
.ObSavedFilterTree-root,
|
|
8
|
+
.ObSavedFilterTree-children {
|
|
9
|
+
list-style: none;
|
|
10
|
+
margin: 0;
|
|
11
|
+
padding: 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.ObSavedFilterTree-children {
|
|
15
|
+
/*
|
|
16
|
+
* A branch is chevron + icon, a child only an icon, so matching the branch
|
|
17
|
+
* indent would put a child's icon under its parent's icon and make the two
|
|
18
|
+
* levels look like one. Indent past the branch icon instead, so a child's
|
|
19
|
+
* icon starts where its parent's label does.
|
|
20
|
+
*/
|
|
21
|
+
margin-inline-start: calc(var(--ds-size-6) + var(--ds-size-1) + var(--ds-size-6));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.ObSavedFilterTree-item {
|
|
25
|
+
display: flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
gap: var(--ds-size-1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.ObSavedFilterTree-node {
|
|
31
|
+
display: flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
gap: var(--ds-size-1);
|
|
34
|
+
flex: 1;
|
|
35
|
+
min-inline-size: 0;
|
|
36
|
+
padding: var(--ds-size-1) var(--ds-size-2);
|
|
37
|
+
border: none;
|
|
38
|
+
border-radius: var(--ds-border-radius-sm);
|
|
39
|
+
background: none;
|
|
40
|
+
color: var(--ds-color-text-default);
|
|
41
|
+
font: inherit;
|
|
42
|
+
text-align: start;
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.ObSavedFilterTree-node:hover {
|
|
47
|
+
background: var(--ds-color-surface-hover);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.ObSavedFilterTree-node:focus-visible {
|
|
51
|
+
outline: var(--ds-border-width-focus) solid var(--ds-color-focus-outer);
|
|
52
|
+
outline-offset: var(--ds-border-width-focus);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.ObSavedFilterTree-selected {
|
|
56
|
+
background: var(--ds-color-surface-active);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.ObSavedFilterTree-dirty .ObSavedFilterTree-label {
|
|
60
|
+
font-weight: var(--ds-font-weight-semibold);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.ObSavedFilterTree-chevron,
|
|
64
|
+
.ObSavedFilterTree-icon {
|
|
65
|
+
display: inline-flex;
|
|
66
|
+
flex: none;
|
|
67
|
+
align-items: center;
|
|
68
|
+
justify-content: center;
|
|
69
|
+
inline-size: var(--ds-size-6);
|
|
70
|
+
block-size: var(--ds-size-6);
|
|
71
|
+
color: var(--ds-color-text-subtle);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.ObSavedFilterTree-chevron > *,
|
|
75
|
+
.ObSavedFilterTree-icon > * {
|
|
76
|
+
inline-size: 100%;
|
|
77
|
+
block-size: 100%;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.ObSavedFilterTree-label {
|
|
81
|
+
overflow: hidden;
|
|
82
|
+
text-overflow: ellipsis;
|
|
83
|
+
white-space: nowrap;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.ObSavedFilterTree-empty {
|
|
87
|
+
/* Lines up with the child labels, past their icon. */
|
|
88
|
+
padding: var(--ds-size-1) var(--ds-size-2) var(--ds-size-1)
|
|
89
|
+
calc(var(--ds-size-2) + var(--ds-size-6) + var(--ds-size-1));
|
|
90
|
+
color: var(--ds-color-text-subtle);
|
|
91
|
+
font-style: italic;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/*
|
|
95
|
+
* The menu button only appears on hover/focus on pointer devices; on touch it is
|
|
96
|
+
* always visible because there is no hover to reveal it.
|
|
97
|
+
*/
|
|
98
|
+
@media (hover: hover) {
|
|
99
|
+
.ObSavedFilterTree-menuButton {
|
|
100
|
+
visibility: hidden;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.ObSavedFilterTree-item:hover .ObSavedFilterTree-menuButton,
|
|
104
|
+
.ObSavedFilterTree-item:focus-within .ObSavedFilterTree-menuButton {
|
|
105
|
+
visibility: visible;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type SavedFilter } from "@olenbetong/appframe-core";
|
|
2
|
+
import "./SavedFilterTree.css";
|
|
3
|
+
/** `null` is the "new filter" node, i.e. no saved filter selected. */
|
|
4
|
+
export type SavedFilterSelection = number | null;
|
|
5
|
+
export type SavedFilterTreeProps = {
|
|
6
|
+
mine: SavedFilter[];
|
|
7
|
+
shared: SavedFilter[];
|
|
8
|
+
/** `FilterID` of the selected filter, or `null` for "new filter". */
|
|
9
|
+
value: SavedFilterSelection;
|
|
10
|
+
onChange: (filterId: SavedFilterSelection) => void;
|
|
11
|
+
/**
|
|
12
|
+
* Marks the selected filter as having unsaved changes; it is then rendered
|
|
13
|
+
* in bold, like the Windows client does.
|
|
14
|
+
*/
|
|
15
|
+
dirty?: boolean;
|
|
16
|
+
onRename?: (filter: SavedFilter) => void;
|
|
17
|
+
onDelete?: (filter: SavedFilter) => void;
|
|
18
|
+
/** Shows an "info" item in the context menu when supplied. */
|
|
19
|
+
onShowInfo?: (filter: SavedFilter) => void;
|
|
20
|
+
loading?: boolean;
|
|
21
|
+
className?: string;
|
|
22
|
+
"data-size"?: "sm" | "md" | "lg";
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* The saved-filter list of the filter builder: a "new filter" entry followed by
|
|
26
|
+
* the user's own filters and the filters shared with them.
|
|
27
|
+
*
|
|
28
|
+
* Which actions a filter offers depends on the access the database resolved for
|
|
29
|
+
* it — renaming and deleting are restricted to filters the user created, even
|
|
30
|
+
* when they manage a filter someone else made.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```jsx
|
|
34
|
+
* let { mine, shared, rename, remove } = useSavedFilters({ dbObjectId: "aviw_Personnel_Persons" });
|
|
35
|
+
*
|
|
36
|
+
* <SavedFilterTree
|
|
37
|
+
* mine={mine}
|
|
38
|
+
* shared={shared}
|
|
39
|
+
* value={selected}
|
|
40
|
+
* onChange={setSelected}
|
|
41
|
+
* onRename={(filter) => rename(filter.filterId, prompt("Name", filter.name))}
|
|
42
|
+
* />
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function SavedFilterTree({ mine, shared, value, onChange, dirty, onRename, onDelete, onShowInfo, loading, className, "data-size": size, }: SavedFilterTreeProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Dropdown } from "@digdir/designsystemet-react";
|
|
3
|
+
import { canDeleteSavedFilter, canRenameSavedFilter, getLocalizedString, } from "@olenbetong/appframe-core";
|
|
4
|
+
import { ChevronDownIcon, ChevronRightIcon, FilesIcon, FileTextIcon, MenuElipsisVerticalIcon, PadlockLockedIcon, PencilIcon, StarIcon, TrashIcon, } from "@navikt/aksel-icons";
|
|
5
|
+
import clsx from "clsx";
|
|
6
|
+
import { useState } from "react";
|
|
7
|
+
import "./SavedFilterTree.css";
|
|
8
|
+
/**
|
|
9
|
+
* The saved-filter list of the filter builder: a "new filter" entry followed by
|
|
10
|
+
* the user's own filters and the filters shared with them.
|
|
11
|
+
*
|
|
12
|
+
* Which actions a filter offers depends on the access the database resolved for
|
|
13
|
+
* it — renaming and deleting are restricted to filters the user created, even
|
|
14
|
+
* when they manage a filter someone else made.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```jsx
|
|
18
|
+
* let { mine, shared, rename, remove } = useSavedFilters({ dbObjectId: "aviw_Personnel_Persons" });
|
|
19
|
+
*
|
|
20
|
+
* <SavedFilterTree
|
|
21
|
+
* mine={mine}
|
|
22
|
+
* shared={shared}
|
|
23
|
+
* value={selected}
|
|
24
|
+
* onChange={setSelected}
|
|
25
|
+
* onRename={(filter) => rename(filter.filterId, prompt("Name", filter.name))}
|
|
26
|
+
* />
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export function SavedFilterTree({ mine, shared, value, onChange, dirty, onRename, onDelete, onShowInfo, loading, className, "data-size": size = "sm", }) {
|
|
30
|
+
let [expanded, setExpanded] = useState({ mine: true, shared: true });
|
|
31
|
+
function renderBranch(key, label, icon, filters) {
|
|
32
|
+
let isExpanded = expanded[key];
|
|
33
|
+
return (_jsxs("li", { className: "ObSavedFilterTree-branch", children: [_jsxs("button", { type: "button", className: "ObSavedFilterTree-node", "aria-expanded": isExpanded, onClick: () => setExpanded((state) => ({ ...state, [key]: !state[key] })), children: [_jsx("span", { className: "ObSavedFilterTree-chevron", "aria-hidden": true, children: isExpanded ? _jsx(ChevronDownIcon, {}) : _jsx(ChevronRightIcon, {}) }), _jsx("span", { className: "ObSavedFilterTree-icon", "aria-hidden": true, children: icon }), _jsx("span", { className: "ObSavedFilterTree-label", children: label })] }), isExpanded && (_jsxs("ul", { className: "ObSavedFilterTree-children", children: [filters.length === 0 && !loading && (_jsx("li", { className: "ObSavedFilterTree-empty", children: getLocalizedString("No filters") })), filters.map((filter) => (_jsx(SavedFilterNode, { filter: filter, selected: filter.filterId === value, dirty: dirty && filter.filterId === value, onSelect: () => onChange(filter.filterId), onRename: onRename, onDelete: onDelete, onShowInfo: onShowInfo }, filter.filterId)))] }))] }));
|
|
34
|
+
}
|
|
35
|
+
return (_jsxs("ul", { className: clsx("ObSavedFilterTree-root", className), "data-size": size, children: [_jsx("li", { children: _jsxs("button", { type: "button", className: clsx("ObSavedFilterTree-node", value === null && "ObSavedFilterTree-selected"), "aria-current": value === null, onClick: () => onChange(null), children: [_jsx("span", { className: "ObSavedFilterTree-chevron", "aria-hidden": true }), _jsx("span", { className: "ObSavedFilterTree-icon", "aria-hidden": true, children: _jsx(FileTextIcon, {}) }), _jsx("span", { className: "ObSavedFilterTree-label", children: getLocalizedString("New Filter") })] }) }), renderBranch("mine", getLocalizedString("My Filters"), _jsx(StarIcon, {}), mine), renderBranch("shared", getLocalizedString("Shared With Me"), _jsx(FilesIcon, {}), shared)] }));
|
|
36
|
+
}
|
|
37
|
+
function SavedFilterNode({ filter, selected, dirty, onSelect, onRename, onDelete, onShowInfo }) {
|
|
38
|
+
let canRename = Boolean(onRename) && canRenameSavedFilter(filter);
|
|
39
|
+
let canDelete = Boolean(onDelete) && canDeleteSavedFilter(filter);
|
|
40
|
+
let hasMenu = canRename || canDelete || Boolean(onShowInfo);
|
|
41
|
+
// A shared filter the user may not change; the Windows client shows a lock.
|
|
42
|
+
let isReadOnly = !filter.createdByUser && filter.accessLevel === "Reader";
|
|
43
|
+
return (_jsxs("li", { className: "ObSavedFilterTree-item", children: [_jsxs("button", { type: "button", className: clsx("ObSavedFilterTree-node", selected && "ObSavedFilterTree-selected", dirty && "ObSavedFilterTree-dirty"), "aria-current": selected, onClick: onSelect, children: [_jsx("span", { className: "ObSavedFilterTree-icon", "aria-hidden": true, children: isReadOnly ? _jsx(PadlockLockedIcon, {}) : _jsx(FileTextIcon, {}) }), _jsx("span", { className: "ObSavedFilterTree-label", children: filter.name })] }), hasMenu && (_jsxs(Dropdown.TriggerContext, { children: [_jsx(Dropdown.Trigger, { variant: "tertiary", icon: true, className: "ObSavedFilterTree-menuButton", "aria-label": getLocalizedString("Options for {0}").replace("{0}", filter.name), children: _jsx(MenuElipsisVerticalIcon, { "aria-hidden": true }) }), _jsx(Dropdown, { children: _jsxs(Dropdown.List, { children: [canRename && (_jsx(Dropdown.Item, { children: _jsxs(Dropdown.Button, { onClick: () => onRename?.(filter), children: [_jsx(PencilIcon, { "aria-hidden": true }), getLocalizedString("Rename")] }) })), onShowInfo && (_jsx(Dropdown.Item, { children: _jsx(Dropdown.Button, { onClick: () => onShowInfo(filter), children: getLocalizedString("Information") }) })), canDelete && (_jsx(Dropdown.Item, { children: _jsxs(Dropdown.Button, { "data-color": "danger", onClick: () => onDelete?.(filter), children: [_jsx(TrashIcon, { "aria-hidden": true }), getLocalizedString("Delete")] }) }))] }) })] }))] }));
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
4
|
+
import { describe, expect, it, vi } from "vitest";
|
|
5
|
+
import { SavedFilterTree } from "./SavedFilterTree.js";
|
|
6
|
+
function savedFilter(overrides) {
|
|
7
|
+
return {
|
|
8
|
+
primKey: `pk-${overrides.filterId}`,
|
|
9
|
+
criteria: "",
|
|
10
|
+
dbObjectId: "aviw_Test_View",
|
|
11
|
+
accessLevel: "Manager",
|
|
12
|
+
createdByUser: true,
|
|
13
|
+
createdBy: "bvh",
|
|
14
|
+
domain: "OB",
|
|
15
|
+
crossDomain: false,
|
|
16
|
+
isPersonallyShared: false,
|
|
17
|
+
hideCriteria: false,
|
|
18
|
+
headerText: null,
|
|
19
|
+
comment: null,
|
|
20
|
+
parameters: null,
|
|
21
|
+
reportTitle: null,
|
|
22
|
+
created: null,
|
|
23
|
+
updated: null,
|
|
24
|
+
...overrides,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const MINE = [savedFilter({ filterId: 1, name: "Agder" })];
|
|
28
|
+
const SHARED = [
|
|
29
|
+
savedFilter({ filterId: 2, name: "Alle ledere", createdByUser: false, createdBy: "ola", accessLevel: "Reader" }),
|
|
30
|
+
];
|
|
31
|
+
function renderTree(props = {}) {
|
|
32
|
+
let onChange = vi.fn();
|
|
33
|
+
render(_jsx(SavedFilterTree, { mine: MINE, shared: SHARED, value: null, onChange: onChange, ...props }));
|
|
34
|
+
return { onChange };
|
|
35
|
+
}
|
|
36
|
+
describe("SavedFilterTree", () => {
|
|
37
|
+
it("renders the three fixed nodes and their filters", () => {
|
|
38
|
+
renderTree();
|
|
39
|
+
expect(screen.getByRole("button", { name: "New Filter" })).toBeTruthy();
|
|
40
|
+
expect(screen.getByRole("button", { name: /My Filters/ })).toBeTruthy();
|
|
41
|
+
expect(screen.getByRole("button", { name: /Shared With Me/ })).toBeTruthy();
|
|
42
|
+
expect(screen.getByRole("button", { name: "Agder" })).toBeTruthy();
|
|
43
|
+
expect(screen.getByRole("button", { name: "Alle ledere" })).toBeTruthy();
|
|
44
|
+
});
|
|
45
|
+
it("reports the selected filter id", async () => {
|
|
46
|
+
let { onChange } = renderTree();
|
|
47
|
+
await userEvent.click(screen.getByRole("button", { name: "Agder" }));
|
|
48
|
+
expect(onChange).toHaveBeenCalledWith(1);
|
|
49
|
+
});
|
|
50
|
+
it("reports null when the new filter node is selected", async () => {
|
|
51
|
+
let { onChange } = renderTree({ value: 1 });
|
|
52
|
+
await userEvent.click(screen.getByRole("button", { name: "New Filter" }));
|
|
53
|
+
expect(onChange).toHaveBeenCalledWith(null);
|
|
54
|
+
});
|
|
55
|
+
it("collapses a branch", async () => {
|
|
56
|
+
renderTree();
|
|
57
|
+
await userEvent.click(screen.getByRole("button", { name: /My Filters/ }));
|
|
58
|
+
expect(screen.queryByRole("button", { name: "Agder" })).toBeNull();
|
|
59
|
+
});
|
|
60
|
+
it("offers rename and delete for the user's own filters", async () => {
|
|
61
|
+
let onRename = vi.fn();
|
|
62
|
+
renderTree({ onRename, onDelete: vi.fn() });
|
|
63
|
+
await userEvent.click(screen.getByRole("button", { name: "Options for Agder" }));
|
|
64
|
+
await userEvent.click(screen.getByRole("button", { name: "Rename" }));
|
|
65
|
+
expect(onRename).toHaveBeenCalledWith(MINE[0]);
|
|
66
|
+
});
|
|
67
|
+
it("does not offer rename or delete for filters created by someone else", () => {
|
|
68
|
+
renderTree({ onRename: vi.fn(), onDelete: vi.fn() });
|
|
69
|
+
expect(screen.queryByRole("button", { name: "Options for Alle ledere" })).toBeNull();
|
|
70
|
+
});
|
|
71
|
+
it("still offers info for filters created by someone else", () => {
|
|
72
|
+
renderTree({ onShowInfo: vi.fn() });
|
|
73
|
+
expect(screen.getByRole("button", { name: "Options for Alle ledere" })).toBeTruthy();
|
|
74
|
+
});
|
|
75
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { ChipListInput, type ChipListInputProps } from "./ChipListInput.js";
|
|
2
|
+
export { FilterBuilder, type FilterBuilderProps, type SavedFilterValues } from "./FilterBuilder.js";
|
|
3
|
+
export { FilterEditor } from "./FilterEditor.js";
|
|
4
|
+
export { FilterGroupEditor, type FilterGroupEditorProps } from "./FilterGroupEditor.js";
|
|
5
|
+
export { FilterNameDialog, type FilterNameDialogProps } from "./FilterNameDialog.js";
|
|
6
|
+
export { FilterRow, type FilterRowProps } from "./FilterRow.js";
|
|
7
|
+
export { FilterShareDialog, type FilterShareDialogProps } from "./FilterShareDialog.js";
|
|
8
|
+
export { FilterStringField, type FilterStringFieldProps } from "./FilterStringField.js";
|
|
9
|
+
export { FilterValueEditor, type FilterValueEditorProps } from "./FilterValueEditor.js";
|
|
10
|
+
export { SavedFilterTree, type SavedFilterSelection, type SavedFilterTreeProps } from "./SavedFilterTree.js";
|
|
11
|
+
export type { FilterEditorProps, FilterEditorSize, FilterValueOption, GetFieldOptions } from "./types.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { ChipListInput } from "./ChipListInput.js";
|
|
2
|
+
export { FilterBuilder } from "./FilterBuilder.js";
|
|
3
|
+
export { FilterEditor } from "./FilterEditor.js";
|
|
4
|
+
export { FilterGroupEditor } from "./FilterGroupEditor.js";
|
|
5
|
+
export { FilterNameDialog } from "./FilterNameDialog.js";
|
|
6
|
+
export { FilterRow } from "./FilterRow.js";
|
|
7
|
+
export { FilterShareDialog } from "./FilterShareDialog.js";
|
|
8
|
+
export { FilterStringField } from "./FilterStringField.js";
|
|
9
|
+
export { FilterValueEditor } from "./FilterValueEditor.js";
|
|
10
|
+
export { SavedFilterTree } from "./SavedFilterTree.js";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { FieldMetadata, FilterTree } from "@olenbetong/appframe-core";
|
|
2
|
+
/** A selectable value for a field that has a fixed list of values. */
|
|
3
|
+
export type FilterValueOption = {
|
|
4
|
+
value: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Resolves the list of values offered in the value editor for a field. Return
|
|
9
|
+
* `undefined` to fall back to a free text editor.
|
|
10
|
+
*
|
|
11
|
+
* Lookup fields carry a `valueListRecordSource` in their metadata, but loading
|
|
12
|
+
* that record source needs a data object, which is out of scope for this
|
|
13
|
+
* component. Supply the options from the outside instead.
|
|
14
|
+
*/
|
|
15
|
+
export type GetFieldOptions = (field: FieldMetadata) => FilterValueOption[] | undefined;
|
|
16
|
+
export type FilterEditorSize = "sm" | "md" | "lg";
|
|
17
|
+
export type FilterEditorProps = {
|
|
18
|
+
/** The fields the user can filter on. Fields with `excludeFromFilter` are hidden. */
|
|
19
|
+
fields: FieldMetadata[];
|
|
20
|
+
/** The filter tree. Use together with `onChange` for a controlled component. */
|
|
21
|
+
value?: FilterTree | null;
|
|
22
|
+
/** The initial filter tree when uncontrolled. */
|
|
23
|
+
defaultValue?: FilterTree | null;
|
|
24
|
+
onChange?: (filter: FilterTree) => void;
|
|
25
|
+
/** Renders the tree without any editing affordances. */
|
|
26
|
+
readOnly?: boolean;
|
|
27
|
+
/** Shows the filter string below the tree, editable unless `readOnly`. */
|
|
28
|
+
showFilterString?: boolean;
|
|
29
|
+
/** View the filter applies to. Passed to the conversion endpoint. */
|
|
30
|
+
viewName?: string;
|
|
31
|
+
getFieldOptions?: GetFieldOptions;
|
|
32
|
+
className?: string;
|
|
33
|
+
"data-size"?: FilterEditorSize;
|
|
34
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/es/index.d.ts
CHANGED
|
@@ -6,10 +6,11 @@ export { CardColumn, CardDetail, CardLabel, CardStep, CardStepList, ColorCard }
|
|
|
6
6
|
export { DateNavigator } from "./components/DateNavigator/index.js";
|
|
7
7
|
export * from "./components/FilePond.js";
|
|
8
8
|
export * from "./components/ImageEditor/index.js";
|
|
9
|
+
export { ChipListInput, type ChipListInputProps, FilterBuilder, type FilterBuilderProps, FilterEditor, type FilterEditorProps, type FilterEditorSize, FilterGroupEditor, type FilterGroupEditorProps, FilterNameDialog, type FilterNameDialogProps, FilterRow, type FilterRowProps, FilterShareDialog, type FilterShareDialogProps, FilterStringField, type FilterStringFieldProps, FilterValueEditor, type FilterValueEditorProps, type FilterValueOption, type GetFieldOptions, type SavedFilterSelection, type SavedFilterValues, SavedFilterTree, type SavedFilterTreeProps, } from "./filter/index.js";
|
|
9
10
|
export { Card, LinkedList, LinkedListItem } from "./components/LinkedCardList/index.js";
|
|
10
11
|
export { MergeProgressDialog, type MergeProgressDialogProps } from "./components/MergeProgressDialog/index.js";
|
|
12
|
+
export { ReportLauncher, type ReportLauncherProps, type ReportLauncherTab, ReportParameterField, ReportParameters, type ReportParametersProps, } from "./report/index.js";
|
|
11
13
|
export { BannerImage as PageBannerImage, type BannerImageProps, PageBanner, type PageBannerProps, Tab as PageBannerTab, TabList as PageBannerTabList, type TabListProps as PageBannerTabListProps, type TabProps as PageBannerTabProps, Title as PageBannerTitle, type TitleProps as PageBannerTitleProps, } from "./components/PageBanner/index.js";
|
|
12
|
-
export * from "./components/PdfViewer/index.js";
|
|
13
14
|
export { Portal } from "./components/Portal/index.js";
|
|
14
15
|
export { ToolbarBreadcrumbs, ToolbarPortal, type BreadcrumbItem, type ToolbarBreadcrumbsProps, type ToolbarPortalProps, type ToolbarPortalSlot, } from "./components/Toolbar/index.js";
|
|
15
16
|
export { ProgressBar } from "./components/ProgressBar/index.js";
|