@olenbetong/synergi-react 3.0.0 → 3.1.1

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 (65) hide show
  1. package/es/components/ImageEditor/ImageEditor.css +5 -5
  2. package/es/components/ImageEditor/ImageEditor.js +1 -1
  3. package/es/filter/index.d.ts +8 -11
  4. package/es/filter/index.js +8 -10
  5. package/es/report/ReportLauncher.d.ts +1 -1
  6. package/es/report/ReportLauncher.js +1 -1
  7. package/es/report/ReportParameters.d.ts +1 -1
  8. package/package.json +6 -6
  9. package/src/components/ImageEditor/ImageEditor.css +5 -5
  10. package/src/components/ImageEditor/ImageEditor.tsx +1 -1
  11. package/src/filter/index.ts +34 -11
  12. package/src/report/ReportLauncher.tsx +1 -2
  13. package/src/report/ReportParameters.tsx +1 -1
  14. package/es/filter/ChipListInput.d.ts +0 -13
  15. package/es/filter/ChipListInput.js +0 -34
  16. package/es/filter/FilterBuilder.css +0 -152
  17. package/es/filter/FilterBuilder.d.ts +0 -115
  18. package/es/filter/FilterBuilder.js +0 -146
  19. package/es/filter/FilterBuilder.test.d.ts +0 -1
  20. package/es/filter/FilterBuilder.test.js +0 -120
  21. package/es/filter/FilterEditor.css +0 -231
  22. package/es/filter/FilterEditor.d.ts +0 -17
  23. package/es/filter/FilterEditor.js +0 -38
  24. package/es/filter/FilterEditor.test.d.ts +0 -1
  25. package/es/filter/FilterEditor.test.js +0 -183
  26. package/es/filter/FilterGroupEditor.d.ts +0 -22
  27. package/es/filter/FilterGroupEditor.js +0 -34
  28. package/es/filter/FilterNameDialog.css +0 -22
  29. package/es/filter/FilterNameDialog.d.ts +0 -18
  30. package/es/filter/FilterNameDialog.js +0 -32
  31. package/es/filter/FilterRow.d.ts +0 -14
  32. package/es/filter/FilterRow.js +0 -32
  33. package/es/filter/FilterShareDialog.css +0 -28
  34. package/es/filter/FilterShareDialog.d.ts +0 -23
  35. package/es/filter/FilterShareDialog.js +0 -63
  36. package/es/filter/FilterStringField.d.ts +0 -15
  37. package/es/filter/FilterStringField.js +0 -37
  38. package/es/filter/FilterValueEditor.d.ts +0 -16
  39. package/es/filter/FilterValueEditor.js +0 -85
  40. package/es/filter/SavedFilterTree.css +0 -107
  41. package/es/filter/SavedFilterTree.d.ts +0 -45
  42. package/es/filter/SavedFilterTree.js +0 -44
  43. package/es/filter/SavedFilterTree.test.d.ts +0 -1
  44. package/es/filter/SavedFilterTree.test.js +0 -75
  45. package/es/filter/types.d.ts +0 -34
  46. package/es/filter/types.js +0 -1
  47. package/src/filter/ChipListInput.tsx +0 -79
  48. package/src/filter/FilterBuilder.css +0 -152
  49. package/src/filter/FilterBuilder.test.tsx +0 -153
  50. package/src/filter/FilterBuilder.tsx +0 -435
  51. package/src/filter/FilterEditor.css +0 -231
  52. package/src/filter/FilterEditor.test.tsx +0 -259
  53. package/src/filter/FilterEditor.tsx +0 -74
  54. package/src/filter/FilterGroupEditor.tsx +0 -160
  55. package/src/filter/FilterNameDialog.css +0 -22
  56. package/src/filter/FilterNameDialog.tsx +0 -81
  57. package/src/filter/FilterRow.tsx +0 -117
  58. package/src/filter/FilterShareDialog.css +0 -28
  59. package/src/filter/FilterShareDialog.tsx +0 -201
  60. package/src/filter/FilterStringField.tsx +0 -77
  61. package/src/filter/FilterValueEditor.tsx +0 -220
  62. package/src/filter/SavedFilterTree.css +0 -107
  63. package/src/filter/SavedFilterTree.test.tsx +0 -94
  64. package/src/filter/SavedFilterTree.tsx +0 -222
  65. package/src/filter/types.ts +0 -38
@@ -2,10 +2,9 @@
2
2
  height: 100%;
3
3
  display: flex;
4
4
  flex-direction: column;
5
- /* The root carries data-color-scheme="dark": the editor chrome is always dark
6
- so the image stays the focus, and Designsystemet components inside pick up
7
- matching dark tokens. */
8
- background: var(--ds-color-neutral-background-default, #111);
5
+ /* Follow the page color scheme, but keep a neutral gray editor surface in light mode
6
+ so white scanned documents still stand out from the background. */
7
+ background: var(--ds-color-neutral-background-tinted, #f3f3f4);
9
8
  color: var(--ds-color-neutral-text-default, white);
10
9
  }
11
10
 
@@ -26,6 +25,7 @@
26
25
  justify-content: center;
27
26
  position: relative;
28
27
  overflow: hidden;
28
+ background: var(--ds-color-neutral-background-tinted, #f3f3f4);
29
29
  }
30
30
 
31
31
  .image-editor__replay-overlay {
@@ -157,7 +157,7 @@
157
157
  so they're never clipped at the edges. */
158
158
  padding: 16px;
159
159
  box-sizing: border-box;
160
- background: var(--ds-color-neutral-background-default, #111);
160
+ background: var(--ds-color-neutral-background-tinted, #f3f3f4);
161
161
  touch-action: none;
162
162
  }
163
163
 
@@ -73,7 +73,7 @@ export const ImageEditor = forwardRef(function ImageEditor({ imageUrl, onConfirm
73
73
  }
74
74
  let CanvasWrapper = viewPlugin?.CanvasWrapper;
75
75
  let TopBarControls = viewPlugin?.TopBarControls;
76
- let inner = (_jsxs("div", { className: "image-editor", "data-color-scheme": "dark", children: [_jsxs("div", { className: "image-editor__topbar", children: [_jsxs("div", { className: "image-editor__toolbar-group", children: [onCancel && (_jsxs(_Fragment, { children: [_jsx(ResponsiveButton, { icon: _jsx(ArrowLeftIcon, { "aria-hidden": true }), label: getLocalizedString("Back"), onClick: onCancel, isSmall: isSmall }), _jsx("span", { className: "image-editor__topbar-divider", "aria-hidden": true })] })), _jsx(ResponsiveButton, { icon: _jsx(ArrowUndoIcon, { "aria-hidden": true }), label: getLocalizedString("Undo"), onClick: history.undo, disabled: disabled || !history.canUndo || !!activePlugin, isSmall: isSmall }), _jsx(ResponsiveButton, { icon: _jsx(ArrowRedoIcon, { "aria-hidden": true }), label: getLocalizedString("Redo"), onClick: history.redo, disabled: disabled || !history.canRedo || !!activePlugin, isSmall: isSmall }), _jsx(ResponsiveButton, { icon: _jsx(ArrowCirclepathIcon, { "aria-hidden": true }), label: getLocalizedString("Reset"), onClick: history.reset, disabled: disabled || !history.canUndo || !!activePlugin, isSmall: isSmall })] }), TopBarControls && (_jsx("div", { className: "image-editor__toolbar-group", children: _jsx(TopBarControls, { disabled: disabled, isSmall: isSmall }) }))] }), _jsxs("div", { className: "image-editor__canvas", children: [CanvasWrapper ? (_jsx(CanvasWrapper, { panEnabled: !activePlugin, children: activePlugin ? (_jsx(ActiveOverlay, { plugin: activePlugin })) : (_jsx("img", { src: history.currentImageUrl, alt: getLocalizedString("Image to edit"), className: "image-editor__img" })) })) : activePlugin ? (_jsx(ActiveOverlay, { plugin: activePlugin })) : (_jsx("img", { src: history.currentImageUrl, alt: getLocalizedString("Image to edit"), className: "image-editor__img" })), !activePlugin && onConfirm && (_jsxs(Button, { className: "image-editor__done", variant: "primary", icon: isSmall, "aria-label": isSmall ? getLocalizedString("Done") : undefined, onClick: confirm, disabled: disabled, children: [_jsx(CheckmarkIcon, { "aria-hidden": true }), !isSmall && getLocalizedString("Done")] })), history.replaying && (_jsx("div", { className: "image-editor__replay-overlay", children: _jsx(Spinner, { "aria-label": getLocalizedString("Loading") }) }))] }), _jsx("div", { className: "image-editor__toolbar", children: activePlugin ? (_jsx(ActiveToolbar, { plugin: activePlugin })) : (_jsx("div", { className: "image-editor__toolbar-group", children: plugins.map((p) => p.type === "tool" ? (_jsx(ToolButton, { plugin: p, busy: disabled, onActivate: () => activateTool(p.id), isSmall: isSmall }, p.id)) : (_jsx(ActionButton, { plugin: p, busy: disabled, onExecute: () => enqueueAction(p), isSmall: isSmall }, p.id))) })) })] }));
76
+ let inner = (_jsxs("div", { className: "image-editor", children: [_jsxs("div", { className: "image-editor__topbar", children: [_jsxs("div", { className: "image-editor__toolbar-group", children: [onCancel && (_jsxs(_Fragment, { children: [_jsx(ResponsiveButton, { icon: _jsx(ArrowLeftIcon, { "aria-hidden": true }), label: getLocalizedString("Back"), onClick: onCancel, isSmall: isSmall }), _jsx("span", { className: "image-editor__topbar-divider", "aria-hidden": true })] })), _jsx(ResponsiveButton, { icon: _jsx(ArrowUndoIcon, { "aria-hidden": true }), label: getLocalizedString("Undo"), onClick: history.undo, disabled: disabled || !history.canUndo || !!activePlugin, isSmall: isSmall }), _jsx(ResponsiveButton, { icon: _jsx(ArrowRedoIcon, { "aria-hidden": true }), label: getLocalizedString("Redo"), onClick: history.redo, disabled: disabled || !history.canRedo || !!activePlugin, isSmall: isSmall }), _jsx(ResponsiveButton, { icon: _jsx(ArrowCirclepathIcon, { "aria-hidden": true }), label: getLocalizedString("Reset"), onClick: history.reset, disabled: disabled || !history.canUndo || !!activePlugin, isSmall: isSmall })] }), TopBarControls && (_jsx("div", { className: "image-editor__toolbar-group", children: _jsx(TopBarControls, { disabled: disabled, isSmall: isSmall }) }))] }), _jsxs("div", { className: "image-editor__canvas", children: [CanvasWrapper ? (_jsx(CanvasWrapper, { panEnabled: !activePlugin, children: activePlugin ? (_jsx(ActiveOverlay, { plugin: activePlugin })) : (_jsx("img", { src: history.currentImageUrl, alt: getLocalizedString("Image to edit"), className: "image-editor__img" })) })) : activePlugin ? (_jsx(ActiveOverlay, { plugin: activePlugin })) : (_jsx("img", { src: history.currentImageUrl, alt: getLocalizedString("Image to edit"), className: "image-editor__img" })), !activePlugin && onConfirm && (_jsxs(Button, { className: "image-editor__done", variant: "primary", icon: isSmall, "aria-label": isSmall ? getLocalizedString("Done") : undefined, onClick: confirm, disabled: disabled, children: [_jsx(CheckmarkIcon, { "aria-hidden": true }), !isSmall && getLocalizedString("Done")] })), history.replaying && (_jsx("div", { className: "image-editor__replay-overlay", children: _jsx(Spinner, { "aria-label": getLocalizedString("Loading") }) }))] }), _jsx("div", { className: "image-editor__toolbar", children: activePlugin ? (_jsx(ActiveToolbar, { plugin: activePlugin })) : (_jsx("div", { className: "image-editor__toolbar-group", children: plugins.map((p) => p.type === "tool" ? (_jsx(ToolButton, { plugin: p, busy: disabled, onActivate: () => activateTool(p.id), isSmall: isSmall }, p.id)) : (_jsx(ActionButton, { plugin: p, busy: disabled, onExecute: () => enqueueAction(p), isSmall: isSmall }, p.id))) })) })] }));
77
77
  // Wrap with the active tool's provider so Overlay and Toolbar share context.
78
78
  if (activePlugin) {
79
79
  let ActiveProvider = activePlugin.Provider;
@@ -1,11 +1,8 @@
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";
1
+ /**
2
+ * The filter builder now lives in `@olenbetong/appframe-ds`, which is where the
3
+ * Designsystemet components it is built from live. Re-exported here so existing
4
+ * imports from `@olenbetong/synergi-react` keep working.
5
+ *
6
+ * @deprecated Import from `@olenbetong/appframe-ds` instead.
7
+ */
8
+ 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, SavedFilterTree, type SavedFilterTreeProps, type SavedFilterValues, } from "@olenbetong/appframe-ds";
@@ -1,10 +1,8 @@
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";
1
+ /**
2
+ * The filter builder now lives in `@olenbetong/appframe-ds`, which is where the
3
+ * Designsystemet components it is built from live. Re-exported here so existing
4
+ * imports from `@olenbetong/synergi-react` keep working.
5
+ *
6
+ * @deprecated Import from `@olenbetong/appframe-ds` instead.
7
+ */
8
+ export { ChipListInput, FilterBuilder, FilterEditor, FilterGroupEditor, FilterNameDialog, FilterRow, FilterShareDialog, FilterStringField, FilterValueEditor, SavedFilterTree, } from "@olenbetong/appframe-ds";
@@ -1,6 +1,6 @@
1
1
  import "./ReportLauncher.css";
2
2
  import { type FieldMetadata } from "@olenbetong/appframe-core";
3
- import type { FilterEditorSize, GetFieldOptions } from "../filter/types.js";
3
+ import { type FilterEditorSize, type GetFieldOptions } from "@olenbetong/appframe-ds";
4
4
  export type ReportLauncherTab = "parameters" | "filter";
5
5
  export type ReportLauncherProps = {
6
6
  /** The report to run, e.g. `arpt_Personnel_Persons`. */
@@ -6,7 +6,7 @@ import { convertFilter, createEmptyFilter, getLocalizedString, restoreParameterV
6
6
  import { useFilterFields, useReport, useReportRender } from "@olenbetong/appframe-react";
7
7
  import clsx from "clsx";
8
8
  import { useEffect, useId, useMemo, useState } from "react";
9
- import { FilterBuilder } from "../filter/FilterBuilder.js";
9
+ import { FilterBuilder } from "@olenbetong/appframe-ds";
10
10
  import { ReportParameters } from "./ReportParameters.js";
11
11
  /** The label shown on the save button for each format. */
12
12
  const FORMAT_LABELS = {
@@ -1,6 +1,6 @@
1
1
  import "./ReportParameters.css";
2
2
  import { type ReportParameter, type ReportParameterValue, type ReportParameterValues } from "@olenbetong/appframe-core";
3
- import type { FilterEditorSize } from "../filter/types.js";
3
+ import type { FilterEditorSize } from "@olenbetong/appframe-ds";
4
4
  export type ReportParametersProps = {
5
5
  /** The report's parameters, from `useReport`. */
6
6
  parameters: ReportParameter[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olenbetong/synergi-react",
3
- "version": "3.0.0",
3
+ "version": "3.1.1",
4
4
  "description": "Standalone React component for SynergiWeb and Partner Portal",
5
5
  "type": "module",
6
6
  "exports": {
@@ -52,11 +52,11 @@
52
52
  "pdf-lib": "^1.17.1",
53
53
  "pdfjs-dist": "5.7.284",
54
54
  "react-pdf": "^10.4.1",
55
- "@olenbetong/appframe-core": "2.12.0",
56
- "@olenbetong/appframe-ds": "0.8.0",
57
- "@olenbetong/appframe-mui": "6.6.1",
58
- "@olenbetong/appframe-react": "2.1.0",
59
- "@olenbetong/appframe-data": "1.6.0"
55
+ "@olenbetong/appframe-core": "2.13.1",
56
+ "@olenbetong/appframe-ds": "0.9.1",
57
+ "@olenbetong/appframe-data": "1.6.2",
58
+ "@olenbetong/appframe-react": "2.1.2",
59
+ "@olenbetong/appframe-mui": "6.6.3"
60
60
  },
61
61
  "repository": {
62
62
  "type": "git",
@@ -2,10 +2,9 @@
2
2
  height: 100%;
3
3
  display: flex;
4
4
  flex-direction: column;
5
- /* The root carries data-color-scheme="dark": the editor chrome is always dark
6
- so the image stays the focus, and Designsystemet components inside pick up
7
- matching dark tokens. */
8
- background: var(--ds-color-neutral-background-default, #111);
5
+ /* Follow the page color scheme, but keep a neutral gray editor surface in light mode
6
+ so white scanned documents still stand out from the background. */
7
+ background: var(--ds-color-neutral-background-tinted, #f3f3f4);
9
8
  color: var(--ds-color-neutral-text-default, white);
10
9
  }
11
10
 
@@ -26,6 +25,7 @@
26
25
  justify-content: center;
27
26
  position: relative;
28
27
  overflow: hidden;
28
+ background: var(--ds-color-neutral-background-tinted, #f3f3f4);
29
29
  }
30
30
 
31
31
  .image-editor__replay-overlay {
@@ -157,7 +157,7 @@
157
157
  so they're never clipped at the edges. */
158
158
  padding: 16px;
159
159
  box-sizing: border-box;
160
- background: var(--ds-color-neutral-background-default, #111);
160
+ background: var(--ds-color-neutral-background-tinted, #f3f3f4);
161
161
  touch-action: none;
162
162
  }
163
163
 
@@ -113,7 +113,7 @@ export const ImageEditor = forwardRef<ImageEditorRef, Props>(function ImageEdito
113
113
  let TopBarControls = viewPlugin?.TopBarControls;
114
114
 
115
115
  let inner = (
116
- <div className="image-editor" data-color-scheme="dark">
116
+ <div className="image-editor">
117
117
  {/* Top toolbar — always visible; undo/redo/reset disabled while a tool is active */}
118
118
  <div className="image-editor__topbar">
119
119
  <div className="image-editor__toolbar-group">
@@ -1,11 +1,34 @@
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";
1
+ /**
2
+ * The filter builder now lives in `@olenbetong/appframe-ds`, which is where the
3
+ * Designsystemet components it is built from live. Re-exported here so existing
4
+ * imports from `@olenbetong/synergi-react` keep working.
5
+ *
6
+ * @deprecated Import from `@olenbetong/appframe-ds` instead.
7
+ */
8
+ export {
9
+ ChipListInput,
10
+ type ChipListInputProps,
11
+ FilterBuilder,
12
+ type FilterBuilderProps,
13
+ FilterEditor,
14
+ type FilterEditorProps,
15
+ type FilterEditorSize,
16
+ FilterGroupEditor,
17
+ type FilterGroupEditorProps,
18
+ FilterNameDialog,
19
+ type FilterNameDialogProps,
20
+ FilterRow,
21
+ type FilterRowProps,
22
+ FilterShareDialog,
23
+ type FilterShareDialogProps,
24
+ FilterStringField,
25
+ type FilterStringFieldProps,
26
+ FilterValueEditor,
27
+ type FilterValueEditorProps,
28
+ type FilterValueOption,
29
+ type GetFieldOptions,
30
+ type SavedFilterSelection,
31
+ SavedFilterTree,
32
+ type SavedFilterTreeProps,
33
+ type SavedFilterValues,
34
+ } from "@olenbetong/appframe-ds";
@@ -18,8 +18,7 @@ import { useFilterFields, useReport, useReportRender } from "@olenbetong/appfram
18
18
  import clsx from "clsx";
19
19
  import { useEffect, useId, useMemo, useState } from "react";
20
20
 
21
- import { FilterBuilder } from "../filter/FilterBuilder.js";
22
- import type { FilterEditorSize, GetFieldOptions } from "../filter/types.js";
21
+ import { FilterBuilder, type FilterEditorSize, type GetFieldOptions } from "@olenbetong/appframe-ds";
23
22
  import { ReportParameters } from "./ReportParameters.js";
24
23
 
25
24
  /** The label shown on the save button for each format. */
@@ -13,7 +13,7 @@ import { Combobox } from "@olenbetong/appframe-ds";
13
13
  import clsx from "clsx";
14
14
  import { useId } from "react";
15
15
 
16
- import type { FilterEditorSize } from "../filter/types.js";
16
+ import type { FilterEditorSize } from "@olenbetong/appframe-ds";
17
17
 
18
18
  export type ReportParametersProps = {
19
19
  /** The report's parameters, from `useReport`. */
@@ -1,13 +0,0 @@
1
- export type ChipListInputProps = {
2
- value: string[];
3
- onChange: (value: string[]) => void;
4
- readOnly?: boolean;
5
- "aria-label": string;
6
- "data-size"?: "sm" | "md" | "lg";
7
- type?: "text" | "number" | "date" | "datetime-local";
8
- };
9
- /**
10
- * Free text editor for the list operators. Values are added with Enter and
11
- * rendered as removable chips.
12
- */
13
- export declare function ChipListInput({ value, onChange, readOnly, type, "aria-label": ariaLabel, "data-size": size, }: ChipListInputProps): import("react").JSX.Element;
@@ -1,34 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { ChipRemovable, Textfield } from "@digdir/designsystemet-react";
3
- import { getLocalizedString } from "@olenbetong/appframe-core";
4
- import { useState } from "react";
5
- /**
6
- * Free text editor for the list operators. Values are added with Enter and
7
- * rendered as removable chips.
8
- */
9
- export function ChipListInput({ value, onChange, readOnly, type = "text", "aria-label": ariaLabel, "data-size": size, }) {
10
- let [draft, setDraft] = useState("");
11
- function commit() {
12
- let trimmed = draft.trim();
13
- if (!trimmed || value.includes(trimmed)) {
14
- setDraft("");
15
- return;
16
- }
17
- onChange([...value, trimmed]);
18
- setDraft("");
19
- }
20
- function handleKeyDown(event) {
21
- if (event.key === "Enter") {
22
- // The editor is often rendered inside a dialog; committing a value
23
- // must not submit or close it.
24
- event.preventDefault();
25
- commit();
26
- }
27
- else if (event.key === "Backspace" && draft === "" && value.length > 0) {
28
- onChange(value.slice(0, -1));
29
- }
30
- }
31
- return (_jsxs("div", { className: "ObFilterEditor-chipList", children: [value.map((item, index) => (_jsx(ChipRemovable
32
- // Values are deduplicated on add, so the value is a stable key.
33
- , { "data-size": size, disabled: readOnly, "aria-label": `${getLocalizedString("Remove")} ${item}`, onClick: () => onChange(value.filter((_, i) => i !== index)), children: item }, item))), !readOnly && (_jsx(Textfield, { className: "ObFilterEditor-chipListInput", "aria-label": ariaLabel, "data-size": size, type: type, value: draft, placeholder: getLocalizedString("Add value"), onChange: (event) => setDraft(event.target.value), onKeyDown: handleKeyDown, onBlur: commit }))] }));
34
- }
@@ -1,152 +0,0 @@
1
- /*
2
- * Colours use the contextual `--ds-color-*` aliases so the builder follows the
3
- * active colour scheme. Never add hex fallbacks.
4
- */
5
-
6
- .ObFilterBuilder-root {
7
- display: grid;
8
- gap: var(--ds-size-4);
9
- /*
10
- * The saved-filter list sits beside the editor. The buttons acting on the
11
- * selected filter share the bottom row with OK/Cancel rather than being
12
- * confined to the list's column, so they have room to stay on one line.
13
- * On narrow viewports everything stacks.
14
- */
15
- grid-template:
16
- "sidebar main" 1fr
17
- "error error" auto
18
- "footer footer" auto
19
- / minmax(14rem, 22rem) minmax(0, 1fr);
20
- block-size: 100%;
21
- min-block-size: 0;
22
- }
23
-
24
- .ObFilterBuilder-sidebar {
25
- grid-area: sidebar;
26
- overflow: auto;
27
- padding: var(--ds-size-2);
28
- border: var(--ds-border-width-default) solid var(--ds-color-border-subtle);
29
- border-radius: var(--ds-border-radius-md);
30
- }
31
-
32
- /*
33
- * The editor manages its own scrolling — the conditions scroll, the filter
34
- * string stays put — so this only has to hand it the available height. A caller
35
- * that replaces the editor through `renderMain` gets the same treatment.
36
- */
37
- .ObFilterBuilder-main {
38
- grid-area: main;
39
- display: flex;
40
- flex-direction: column;
41
- gap: var(--ds-size-3);
42
- min-inline-size: 0;
43
- min-block-size: 0;
44
- }
45
-
46
- .ObFilterBuilder-main > * {
47
- flex: 1 1 auto;
48
- min-inline-size: 0;
49
- min-block-size: 0;
50
- }
51
-
52
- .ObFilterBuilder-error {
53
- grid-area: error;
54
- margin: 0;
55
- color: var(--ds-color-danger-text-default);
56
- }
57
-
58
- .ObFilterBuilder-footer {
59
- grid-area: footer;
60
- display: flex;
61
- flex-wrap: wrap;
62
- align-items: center;
63
- justify-content: space-between;
64
- gap: var(--ds-size-4);
65
- }
66
-
67
- .ObFilterBuilder-toolbar,
68
- .ObFilterBuilder-actions {
69
- display: flex;
70
- flex-wrap: wrap;
71
- align-items: center;
72
- gap: var(--ds-size-2);
73
- }
74
-
75
- .ObFilterBuilder-actions {
76
- margin-inline-start: auto;
77
- }
78
-
79
- /*
80
- * Without the saved-filter list there are no buttons acting on one either, so
81
- * the editor takes the full width.
82
- */
83
- .ObFilterBuilder-root--noSavedFilters {
84
- grid-template:
85
- "main" 1fr
86
- "error" auto
87
- "footer" auto
88
- / minmax(0, 1fr);
89
- }
90
-
91
- /*
92
- * `Dialog` caps itself at `--dsc-dialog-max-width` (40rem), so setting a width
93
- * here would have no effect — the variable has to be raised instead. It needs
94
- * to be wide enough that a condition — field, operator, value and the group
95
- * buttons — fits on one line next to the saved-filter column.
96
- */
97
- .ObFilterBuilder-dialog {
98
- --dsc-dialog-max-width: 84rem;
99
- --dsc-dialog-max-height: 90dvh;
100
- }
101
-
102
- /*
103
- * A fixed height keeps the dialog from resizing as conditions are added and
104
- * removed, and gives the saved-filter column and the editor a height to fill.
105
- * The dialog itself must not scroll — the body does — or the heading would
106
- * scroll away and the OK/Cancel row would not stay at the bottom.
107
- */
108
- .ObFilterBuilder-dialog[open] {
109
- display: flex;
110
- flex-direction: column;
111
- block-size: 48rem;
112
- overflow: hidden;
113
- }
114
-
115
- /*
116
- * The heading and the close button share the header row.
117
- */
118
- .ObFilterBuilder-dialogHeader {
119
- display: flex;
120
- align-items: center;
121
- justify-content: space-between;
122
- gap: var(--ds-size-2);
123
- }
124
-
125
- .ObFilterBuilder-dialogBody {
126
- flex: 1 1 auto;
127
- min-block-size: 0;
128
- overflow: hidden;
129
- }
130
-
131
- @media (width < 48rem) {
132
- .ObFilterBuilder-root:not(.ObFilterBuilder-root--noSavedFilters) {
133
- grid-template:
134
- "sidebar" auto
135
- "main" 1fr
136
- "error" auto
137
- "footer" auto
138
- / minmax(0, 1fr);
139
- }
140
-
141
- /*
142
- * Stacked, the dialog body is the scroll container: the editor cannot give
143
- * both the list and the conditions a useful height in the space left over.
144
- */
145
- .ObFilterBuilder-dialogBody {
146
- overflow: auto;
147
- }
148
-
149
- .ObFilterBuilder-sidebar {
150
- max-block-size: 12rem;
151
- }
152
- }
@@ -1,115 +0,0 @@
1
- import "./FilterBuilder.css";
2
- import { type FilterTree, type SavedFilter } from "@olenbetong/appframe-core";
3
- import { type NamedFilterType } from "@olenbetong/appframe-react";
4
- import type { SaveFilterInput } from "@olenbetong/appframe-react";
5
- import type { DataObject } from "@olenbetong/appframe-data";
6
- import { type ReactNode } from "react";
7
- import type { FilterEditorSize, GetFieldOptions } from "./types.js";
8
- import type { FieldMetadata } from "@olenbetong/appframe-core";
9
- export type FilterBuilderProps = {
10
- /** The fields the user can filter on. Fields with `excludeFromFilter` are hidden. */
11
- fields: FieldMetadata[];
12
- /**
13
- * The view the filter applies to. Used both for conversion and, unless
14
- * `dbObjectId` is set, as the key saved filters are stored under.
15
- */
16
- viewName?: string;
17
- /** Overrides `viewName` as the key saved filters are stored under. */
18
- dbObjectId?: string;
19
- /** Loads the filters saved for a report instead of for a view. */
20
- reportId?: string;
21
- getFieldOptions?: GetFieldOptions;
22
- /**
23
- * `"dialog"` wraps the builder in a modal, `"inline"` renders it in place.
24
- * @default "dialog"
25
- */
26
- variant?: "dialog" | "inline";
27
- /** Whether the dialog is open. Ignored when `variant` is `"inline"`. */
28
- open?: boolean;
29
- /** Called when the dialog is dismissed, and after the filter is applied. */
30
- onClose?: () => void;
31
- /** The filter tree. Use together with `onChange` for a controlled component. */
32
- value?: FilterTree | null;
33
- /** The initial filter tree when uncontrolled. */
34
- defaultValue?: FilterTree | null;
35
- /** Called on every edit. */
36
- onChange?: (filter: FilterTree) => void;
37
- /**
38
- * Called when the user applies the filter. The tree is pruned, so incomplete
39
- * conditions are dropped and an empty filter is reported as `null`.
40
- */
41
- onApply?: (filter: FilterTree | null, filterString: string) => void;
42
- /**
43
- * Applies the filter to a data object when the user confirms. The filter is
44
- * written to a named slot, so it composes with other filter providers on the
45
- * same data object instead of overwriting them.
46
- */
47
- dataObject?: DataObject<any>;
48
- /**
49
- * Parameter the filter is applied to.
50
- * @default "filterObject"
51
- */
52
- filterType?: NamedFilterType;
53
- /**
54
- * Name of the slot the filter is applied to.
55
- * @default "filterBuilder"
56
- */
57
- slotName?: string;
58
- /**
59
- * Shows the filter string below the tree.
60
- * @default true
61
- */
62
- showFilterString?: boolean;
63
- /** Called whenever the filter string is reconverted. */
64
- onFilterStringChange?: (filterString: string) => void;
65
- /** Called when a saved filter is selected, and with `null` for "New Filter". */
66
- onSelect?: (filter: SavedFilter | null) => void;
67
- /**
68
- * Extra columns written along with the filter when it is saved. The report
69
- * launcher stores its header text, its hide-criteria flag and its parameter
70
- * values here.
71
- */
72
- saveValues?: SavedFilterValues;
73
- /**
74
- * Hides the OK/Cancel row, for callers that supply their own actions. The
75
- * saved-filter toolbar stays.
76
- */
77
- hideActions?: boolean;
78
- /**
79
- * Replaces the OK/Cancel buttons, so a caller's own actions share the row
80
- * with the buttons acting on the selected saved filter.
81
- */
82
- actions?: ReactNode;
83
- /**
84
- * Wraps the criteria editor, for callers that put it beside content of their
85
- * own — the report launcher puts it in a tab next to the report parameters.
86
- * Whatever is returned fills the column next to the saved-filter list.
87
- */
88
- renderMain?: (editor: ReactNode) => ReactNode;
89
- /** Hides the saved-filter list, leaving just the criteria editor. */
90
- hideSavedFilters?: boolean;
91
- className?: string;
92
- "data-size"?: FilterEditorSize;
93
- };
94
- /** The parts of a saved filter the builder writes on behalf of a caller. */
95
- export type SavedFilterValues = Pick<SaveFilterInput, "headerText" | "hideCriteria" | "parameters">;
96
- /**
97
- * The web port of the Windows filter builder: the saved-filter list, the
98
- * criteria editor and the save/share toolbar.
99
- *
100
- * Saved filters are stored as criteria strings, so selecting one round-trips
101
- * through the conversion endpoint to rebuild the tree, and saving converts the
102
- * tree back.
103
- *
104
- * @example
105
- * ```jsx
106
- * <FilterBuilder
107
- * open={open}
108
- * fields={dsPersons.getFields()}
109
- * viewName="aviw_Personnel_Persons"
110
- * dataObject={dsPersons}
111
- * onClose={() => setOpen(false)}
112
- * />
113
- * ```
114
- */
115
- export declare function FilterBuilder({ fields, viewName, dbObjectId, reportId, getFieldOptions, variant, open, onClose, value, defaultValue, onChange, onApply, dataObject, filterType, slotName, showFilterString, onFilterStringChange, onSelect, saveValues, hideActions, actions, renderMain, hideSavedFilters, className, "data-size": size, }: FilterBuilderProps): import("react").JSX.Element;