@olenbetong/synergi-react 2.7.1 → 2.9.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/dist/styles/styles.css.map +1 -1
- package/es/{components → chrome}/AppMenu/AppMenu.css +648 -648
- package/es/{components → chrome}/AppMenu/index.d.ts +1 -1
- package/es/components/ImageEditor/ImageEditor.d.ts +12 -0
- package/es/components/ImageEditor/ImageEditor.js +27 -6
- package/es/components/ImageEditor/index.d.ts +2 -0
- package/es/components/ImageEditor/index.js +2 -0
- package/es/components/ImageEditor/plugins/zoomPlugin/ZoomControls.js +1 -1
- package/es/components/ImageEditor/useImageHistory.d.ts +6 -1
- package/es/components/ImageEditor/useImageHistory.js +21 -23
- package/es/components/PageBanner/index.d.ts +1 -1
- package/es/elements/ElementDamage/DamageFormButtons.d.ts +2 -3
- package/es/elements/ElementDamage/DamageFormButtons.js +1 -1
- package/es/elements/ElementDamage/TransportElementSelect.d.ts +1 -2
- package/es/elements/index.d.ts +5 -0
- package/es/elements/index.js +5 -0
- package/es/index.d.ts +2 -2
- package/es/index.js +2 -2
- package/package.json +4 -4
- package/src/{components → chrome}/AppMenu/AppMenu.css +648 -648
- package/src/{components → chrome}/AppMenu/AppMenu.tsx +285 -285
- package/src/{components → chrome}/AppMenu/AppMenuFavoriteButton.tsx +47 -47
- package/src/{components → chrome}/AppMenu/AppMenuHeader.tsx +79 -79
- package/src/{components → chrome}/AppMenu/AppMenuList.tsx +89 -89
- package/src/{components → chrome}/AppMenu/AppMenuRail.tsx +117 -117
- package/src/{components → chrome}/AppMenu/icons.tsx +76 -76
- package/src/{components → chrome}/AppMenu/index.ts +17 -17
- package/src/{components → chrome}/AppMenu/menuEntries.ts +128 -128
- package/src/{components → chrome}/AppMenu/types.ts +45 -45
- package/src/{components → chrome}/AppMenu/useFavorites.ts +40 -40
- package/src/{components → chrome}/AppMenu/useRovingTabIndex.ts +130 -130
- package/src/{components → chrome}/AppShell/index.tsx +287 -287
- package/src/colorScheme.ts +81 -81
- package/src/components/ImageEditor/ImageEditor.tsx +41 -6
- package/src/components/ImageEditor/index.ts +2 -0
- package/src/components/ImageEditor/plugins/zoomPlugin/ZoomControls.tsx +7 -8
- package/src/components/ImageEditor/useImageHistory.ts +27 -19
- package/src/components/LinkedCardList/index.scss +95 -93
- package/src/components/PageBanner/index.tsx +5 -4
- package/src/components/ProgressBar/index.scss +96 -94
- package/src/elements/ElementDamage/DamageFormButtons.tsx +2 -2
- package/src/elements/ElementDamage/TransportElementSelect.tsx +1 -1
- package/src/elements/index.ts +5 -0
- package/src/index.ts +70 -61
- /package/es/{components → chrome}/AppMenu/AppMenu.d.ts +0 -0
- /package/es/{components → chrome}/AppMenu/AppMenu.js +0 -0
- /package/es/{components → chrome}/AppMenu/AppMenuColorScheme.d.ts +0 -0
- /package/es/{components → chrome}/AppMenu/AppMenuColorScheme.js +0 -0
- /package/es/{components → chrome}/AppMenu/AppMenuFavoriteButton.d.ts +0 -0
- /package/es/{components → chrome}/AppMenu/AppMenuFavoriteButton.js +0 -0
- /package/es/{components → chrome}/AppMenu/AppMenuHeader.d.ts +0 -0
- /package/es/{components → chrome}/AppMenu/AppMenuHeader.js +0 -0
- /package/es/{components → chrome}/AppMenu/AppMenuList.d.ts +0 -0
- /package/es/{components → chrome}/AppMenu/AppMenuList.js +0 -0
- /package/es/{components → chrome}/AppMenu/AppMenuRail.d.ts +0 -0
- /package/es/{components → chrome}/AppMenu/AppMenuRail.js +0 -0
- /package/es/{components → chrome}/AppMenu/AppMenuToggle.d.ts +0 -0
- /package/es/{components → chrome}/AppMenu/AppMenuToggle.js +0 -0
- /package/es/{components → chrome}/AppMenu/AppMenuUserMenu.d.ts +0 -0
- /package/es/{components → chrome}/AppMenu/AppMenuUserMenu.js +0 -0
- /package/es/{components → chrome}/AppMenu/developerCategories.d.ts +0 -0
- /package/es/{components → chrome}/AppMenu/developerCategories.js +0 -0
- /package/es/{components → chrome}/AppMenu/icons.d.ts +0 -0
- /package/es/{components → chrome}/AppMenu/icons.js +0 -0
- /package/es/{components → chrome}/AppMenu/index.js +0 -0
- /package/es/{components → chrome}/AppMenu/menuEntries.d.ts +0 -0
- /package/es/{components → chrome}/AppMenu/menuEntries.js +0 -0
- /package/es/{components → chrome}/AppMenu/types.d.ts +0 -0
- /package/es/{components → chrome}/AppMenu/types.js +0 -0
- /package/es/{components → chrome}/AppMenu/useFavorites.d.ts +0 -0
- /package/es/{components → chrome}/AppMenu/useFavorites.js +0 -0
- /package/es/{components → chrome}/AppMenu/useRovingTabIndex.d.ts +0 -0
- /package/es/{components → chrome}/AppMenu/useRovingTabIndex.js +0 -0
- /package/es/{components → chrome}/AppMenu/useServiceWorkerUpdate.d.ts +0 -0
- /package/es/{components → chrome}/AppMenu/useServiceWorkerUpdate.js +0 -0
- /package/es/{components → chrome}/AppShell/index.d.ts +0 -0
- /package/es/{components → chrome}/AppShell/index.js +0 -0
- /package/src/{components → chrome}/AppMenu/AppMenuColorScheme.tsx +0 -0
- /package/src/{components → chrome}/AppMenu/AppMenuToggle.tsx +0 -0
- /package/src/{components → chrome}/AppMenu/AppMenuUserMenu.tsx +0 -0
- /package/src/{components → chrome}/AppMenu/developerCategories.ts +0 -0
- /package/src/{components → chrome}/AppMenu/useServiceWorkerUpdate.ts +0 -0
|
@@ -7,6 +7,6 @@ export { AppMenuRail, type AppMenuRailProps } from "./AppMenuRail.js";
|
|
|
7
7
|
export { AppMenuToggle, type AppMenuToggleProps } from "./AppMenuToggle.js";
|
|
8
8
|
export { AppMenuUserMenu, type AppMenuUser, type AppMenuUserMenuProps, defaultUserMenuItems, } from "./AppMenuUserMenu.js";
|
|
9
9
|
export { createDeveloperCategories, type DeveloperCategoryOptions } from "./developerCategories.js";
|
|
10
|
-
export type { AppMenuArticle } from "./menuEntries.js";
|
|
10
|
+
export type { AppMenuArticle, Selection as AppMenuSelection } from "./menuEntries.js";
|
|
11
11
|
export type { AppMenuCategory, AppMenuLink, AppMenuLinkGroup } from "./types.js";
|
|
12
12
|
export { useServiceWorkerUpdate } from "./useServiceWorkerUpdate.js";
|
|
@@ -3,6 +3,18 @@ import type { Plugin, ViewPlugin } from "./types.js";
|
|
|
3
3
|
export type ImageEditorRef = {
|
|
4
4
|
/** Returns the current edited blob, or null if no edits have been applied since the last source image. */
|
|
5
5
|
getCurrentBlob: () => Blob | null;
|
|
6
|
+
/**
|
|
7
|
+
* Runs a registered action plugin (e.g. `"rotate-cw"`) against the current image.
|
|
8
|
+
* Use this instead of calling `plugin.execute()` directly so external toolbars and
|
|
9
|
+
* keyboard shortcuts share the editor's image state and undo history.
|
|
10
|
+
* Resolves once the resulting image has been applied.
|
|
11
|
+
*/
|
|
12
|
+
executeAction: (pluginId: string) => Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Resolves once every queued action has been applied. Await this before `getCurrentBlob()`
|
|
15
|
+
* to be sure an action started moments earlier is included.
|
|
16
|
+
*/
|
|
17
|
+
whenIdle: () => Promise<void>;
|
|
6
18
|
};
|
|
7
19
|
interface Props {
|
|
8
20
|
imageUrl: string;
|
|
@@ -2,7 +2,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { Button, Spinner, Tooltip } from "@digdir/designsystemet-react";
|
|
3
3
|
import { ArrowCirclepathIcon, ArrowLeftIcon, ArrowRedoIcon, ArrowUndoIcon, CheckmarkIcon } from "@navikt/aksel-icons";
|
|
4
4
|
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
5
|
-
import { forwardRef, useImperativeHandle, useMemo, useState } from "react";
|
|
5
|
+
import { forwardRef, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
6
6
|
import "./ImageEditor.css";
|
|
7
7
|
import { ResponsiveButton } from "./ResponsiveButton.js";
|
|
8
8
|
import { useActiveTool } from "./useActiveTool.js";
|
|
@@ -21,15 +21,36 @@ export const ImageEditor = forwardRef(function ImageEditor({ imageUrl, onConfirm
|
|
|
21
21
|
let [busy, setBusy] = useState(false);
|
|
22
22
|
let disabled = busy || history.replaying;
|
|
23
23
|
let isSmall = useIsSmall();
|
|
24
|
+
// Keeps async/imperative callers working against the latest history state instead of
|
|
25
|
+
// the snapshot captured when their closure was created.
|
|
26
|
+
let historyRef = useRef(history);
|
|
27
|
+
historyRef.current = history;
|
|
28
|
+
// Serialises every action (toolbar clicks and imperative calls alike) so rapid
|
|
29
|
+
// invocations each build on the previous result instead of racing on a stale image.
|
|
30
|
+
let actionQueueRef = useRef(Promise.resolve());
|
|
24
31
|
useImperativeHandle(ref, () => ({
|
|
25
|
-
getCurrentBlob: () =>
|
|
32
|
+
getCurrentBlob: () => historyRef.current.getCurrentBlob(),
|
|
33
|
+
whenIdle: () => actionQueueRef.current,
|
|
34
|
+
executeAction: (pluginId) => {
|
|
35
|
+
let plugin = plugins.find((p) => p.type === "action" && p.id === pluginId);
|
|
36
|
+
if (!plugin) {
|
|
37
|
+
console.warn(`[ImageEditor] No action plugin registered with id "${pluginId}"`);
|
|
38
|
+
return Promise.resolve();
|
|
39
|
+
}
|
|
40
|
+
return enqueueAction(plugin);
|
|
41
|
+
},
|
|
26
42
|
}));
|
|
43
|
+
function enqueueAction(plugin) {
|
|
44
|
+
let next = actionQueueRef.current.then(() => executeAction(plugin));
|
|
45
|
+
actionQueueRef.current = next.catch(() => { });
|
|
46
|
+
return next;
|
|
47
|
+
}
|
|
27
48
|
async function executeAction(plugin) {
|
|
28
49
|
setBusy(true);
|
|
29
50
|
try {
|
|
30
|
-
let blob = await plugin.execute(
|
|
51
|
+
let blob = await plugin.execute(historyRef.current.getCurrentImageUrl());
|
|
31
52
|
let actions = [{ type: plugin.id, params: {} }];
|
|
32
|
-
|
|
53
|
+
historyRef.current.applyActions(blob, actions);
|
|
33
54
|
}
|
|
34
55
|
finally {
|
|
35
56
|
setBusy(false);
|
|
@@ -52,7 +73,7 @@ export const ImageEditor = forwardRef(function ImageEditor({ imageUrl, onConfirm
|
|
|
52
73
|
}
|
|
53
74
|
let CanvasWrapper = viewPlugin?.CanvasWrapper;
|
|
54
75
|
let TopBarControls = viewPlugin?.TopBarControls;
|
|
55
|
-
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: () =>
|
|
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))) })) })] }));
|
|
56
77
|
// Wrap with the active tool's provider so Overlay and Toolbar share context.
|
|
57
78
|
if (activePlugin) {
|
|
58
79
|
let ActiveProvider = activePlugin.Provider;
|
|
@@ -71,7 +92,7 @@ function ToolButton({ plugin, busy, onActivate, isSmall, }) {
|
|
|
71
92
|
if (isSmall) {
|
|
72
93
|
return (_jsx(Tooltip, { content: label, children: _jsx(Button, { icon: true, variant: "tertiary", "data-size": "sm", "aria-label": label, onClick: onActivate, disabled: busy, children: _jsx(Icon, {}) }) }));
|
|
73
94
|
}
|
|
74
|
-
return (_jsxs(Button, { variant: "
|
|
95
|
+
return (_jsxs(Button, { variant: "tertiary", "data-size": "sm", onClick: onActivate, disabled: busy, children: [_jsx(Icon, {}), label] }));
|
|
75
96
|
}
|
|
76
97
|
function ActionButton({ plugin, busy, onExecute, isSmall, }) {
|
|
77
98
|
let Icon = plugin.Icon;
|
|
@@ -2,5 +2,7 @@ export { defaultPlugins, defaultViewPlugin } from "./defaultPlugins.js";
|
|
|
2
2
|
export type { ImageEditorRef } from "./ImageEditor.js";
|
|
3
3
|
export { ImageEditor } from "./ImageEditor.js";
|
|
4
4
|
export { cropPlugin } from "./plugins/cropPlugin/index.js";
|
|
5
|
+
export { redactPlugin } from "./plugins/redactPlugin/index.js";
|
|
6
|
+
export { zoomPlugin } from "./plugins/zoomPlugin/index.js";
|
|
5
7
|
export { rotateCcwPlugin, rotateCwPlugin } from "./plugins/rotatePlugin.js";
|
|
6
8
|
export type { ActionPlugin, EditAction, Plugin, ToolPlugin, ViewPlugin } from "./types.js";
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { defaultPlugins, defaultViewPlugin } from "./defaultPlugins.js";
|
|
2
2
|
export { ImageEditor } from "./ImageEditor.js";
|
|
3
3
|
export { cropPlugin } from "./plugins/cropPlugin/index.js";
|
|
4
|
+
export { redactPlugin } from "./plugins/redactPlugin/index.js";
|
|
5
|
+
export { zoomPlugin } from "./plugins/zoomPlugin/index.js";
|
|
4
6
|
export { rotateCcwPlugin, rotateCwPlugin } from "./plugins/rotatePlugin.js";
|
|
@@ -5,5 +5,5 @@ import { ResponsiveButton } from "../../ResponsiveButton.js";
|
|
|
5
5
|
import { useZoom } from "./ZoomContext.js";
|
|
6
6
|
export function ZoomControls({ disabled, isSmall = false }) {
|
|
7
7
|
let { zoom, zoomIn, zoomOut, resetZoom, canZoomIn, canZoomOut, isZoomed } = useZoom();
|
|
8
|
-
return (_jsxs(_Fragment, { children: [_jsx(ResponsiveButton, { icon: _jsx(ZoomMinusIcon, { "aria-hidden": true }), label: getLocalizedString("Zoom out"), onClick: zoomOut, disabled: disabled || !canZoomOut, isSmall: isSmall }), _jsxs("span", { className: "image-editor__zoom-level", children: [Math.round(zoom * 100), "%"] }), _jsx(ResponsiveButton, { icon: _jsx(ZoomPlusIcon, { "aria-hidden": true }), label: getLocalizedString("Zoom in"), onClick: zoomIn, disabled: disabled || !canZoomIn, isSmall: isSmall }),
|
|
8
|
+
return (_jsxs(_Fragment, { children: [_jsx(ResponsiveButton, { icon: _jsx(ZoomMinusIcon, { "aria-hidden": true }), label: getLocalizedString("Zoom out"), onClick: zoomOut, disabled: disabled || !canZoomOut, isSmall: isSmall }), _jsxs("span", { className: "image-editor__zoom-level", children: [Math.round(zoom * 100), "%"] }), _jsx(ResponsiveButton, { icon: _jsx(ZoomPlusIcon, { "aria-hidden": true }), label: getLocalizedString("Zoom in"), onClick: zoomIn, disabled: disabled || !canZoomIn, isSmall: isSmall }), _jsx(ResponsiveButton, { disabled: !isZoomed, icon: _jsx(ShrinkIcon, { "aria-hidden": true }), label: getLocalizedString("Reset zoom"), onClick: resetZoom, isSmall: isSmall })] }));
|
|
9
9
|
}
|
|
@@ -2,11 +2,16 @@ import type { ActionRegistry, EditAction } from "./types.js";
|
|
|
2
2
|
export interface UseImageHistoryResult {
|
|
3
3
|
currentImageUrl: string;
|
|
4
4
|
currentBlob: Blob | null;
|
|
5
|
+
/** Synchronous read of the current image URL — valid immediately after `applyActions`. */
|
|
6
|
+
getCurrentImageUrl: () => string;
|
|
7
|
+
/** Synchronous read of the current blob — valid immediately after `applyActions`. */
|
|
8
|
+
getCurrentBlob: () => Blob | null;
|
|
5
9
|
canUndo: boolean;
|
|
6
10
|
canRedo: boolean;
|
|
7
11
|
/** True while an async replay (undo/redo) is in progress. */
|
|
8
12
|
replaying: boolean;
|
|
9
|
-
|
|
13
|
+
/** Applies a new blob to the current state and records it in history. Returns the new object URL. */
|
|
14
|
+
applyActions: (blob: Blob, actions: EditAction[]) => string;
|
|
10
15
|
undo: () => void;
|
|
11
16
|
redo: () => void;
|
|
12
17
|
reset: () => void;
|
|
@@ -12,20 +12,24 @@ export function useImageHistory(sourceUrl, registry) {
|
|
|
12
12
|
let [replaying, setReplaying] = useState(false);
|
|
13
13
|
let historyRef = useRef(history);
|
|
14
14
|
historyRef.current = history;
|
|
15
|
+
// Written synchronously by `replaceCurrent` so imperative callers can read the current
|
|
16
|
+
// image/blob before React has committed the corresponding render.
|
|
15
17
|
let currentRef = useRef(current);
|
|
16
|
-
currentRef.current = current;
|
|
17
18
|
let isReplaying = useRef(false);
|
|
18
19
|
let replayAbort = useRef(null);
|
|
20
|
+
function replaceCurrent(next) {
|
|
21
|
+
let prev = currentRef.current;
|
|
22
|
+
if (prev.generated && prev.url !== next.url)
|
|
23
|
+
URL.revokeObjectURL(prev.url);
|
|
24
|
+
currentRef.current = next;
|
|
25
|
+
setCurrent(next);
|
|
26
|
+
}
|
|
19
27
|
// When source changes (e.g. component remount with new image), reset fully.
|
|
20
28
|
useEffect(() => {
|
|
21
29
|
replayAbort.current?.abort();
|
|
22
30
|
isReplaying.current = false;
|
|
23
31
|
setReplaying(false);
|
|
24
|
-
|
|
25
|
-
if (prev.generated)
|
|
26
|
-
URL.revokeObjectURL(prev.url);
|
|
27
|
-
return { url: sourceUrl, blob: null, generated: false };
|
|
28
|
-
});
|
|
32
|
+
replaceCurrent({ url: sourceUrl, blob: null, generated: false });
|
|
29
33
|
setHistory({ past: [], future: [] });
|
|
30
34
|
}, [sourceUrl]);
|
|
31
35
|
useEffect(() => {
|
|
@@ -41,12 +45,9 @@ export function useImageHistory(sourceUrl, registry) {
|
|
|
41
45
|
isReplaying.current = false;
|
|
42
46
|
setReplaying(false);
|
|
43
47
|
let newUrl = URL.createObjectURL(blob);
|
|
44
|
-
|
|
45
|
-
if (prev.generated)
|
|
46
|
-
URL.revokeObjectURL(prev.url);
|
|
47
|
-
return { url: newUrl, blob, generated: true };
|
|
48
|
-
});
|
|
48
|
+
replaceCurrent({ url: newUrl, blob, generated: true });
|
|
49
49
|
setHistory((prev) => ({ past: [...prev.past, actions], future: [] }));
|
|
50
|
+
return newUrl;
|
|
50
51
|
}
|
|
51
52
|
async function doReplay(newPast, newFuture) {
|
|
52
53
|
replayAbort.current?.abort();
|
|
@@ -58,13 +59,12 @@ export function useImageHistory(sourceUrl, registry) {
|
|
|
58
59
|
let result = await replayAll(sourceUrl, newPast, registry, abort.signal);
|
|
59
60
|
if (abort.signal.aborted)
|
|
60
61
|
return;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
});
|
|
62
|
+
if (result) {
|
|
63
|
+
replaceCurrent({ url: result.url, blob: result.blob, generated: true });
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
replaceCurrent({ url: sourceUrl, blob: null, generated: false });
|
|
67
|
+
}
|
|
68
68
|
setHistory({ past: newPast, future: newFuture });
|
|
69
69
|
}
|
|
70
70
|
finally {
|
|
@@ -94,16 +94,14 @@ export function useImageHistory(sourceUrl, registry) {
|
|
|
94
94
|
replayAbort.current?.abort();
|
|
95
95
|
isReplaying.current = false;
|
|
96
96
|
setReplaying(false);
|
|
97
|
-
|
|
98
|
-
if (prev.generated)
|
|
99
|
-
URL.revokeObjectURL(prev.url);
|
|
100
|
-
return { url: sourceUrl, blob: null, generated: false };
|
|
101
|
-
});
|
|
97
|
+
replaceCurrent({ url: sourceUrl, blob: null, generated: false });
|
|
102
98
|
setHistory({ past: [], future: [] });
|
|
103
99
|
}
|
|
104
100
|
return {
|
|
105
101
|
currentImageUrl: current.url,
|
|
106
102
|
currentBlob: current.blob,
|
|
103
|
+
getCurrentImageUrl: () => currentRef.current.url,
|
|
104
|
+
getCurrentBlob: () => currentRef.current.blob,
|
|
107
105
|
canUndo: history.past.length > 0,
|
|
108
106
|
canRedo: history.future.length > 0,
|
|
109
107
|
replaying,
|
|
@@ -11,7 +11,7 @@ export type TabListProps = Pick<React.HTMLProps<HTMLDivElement>, "id" | "classNa
|
|
|
11
11
|
sticky?: boolean;
|
|
12
12
|
};
|
|
13
13
|
export declare function TabList({ as, className, children, sticky, ...other }: TabListProps): React.JSX.Element;
|
|
14
|
-
export type TabProps = Pick<React.HTMLProps<HTMLDivElement>, "id" | "className" | "children"> & {
|
|
14
|
+
export type TabProps = Pick<React.HTMLProps<HTMLDivElement>, "id" | "className" | "children"> & Pick<React.AnchorHTMLAttributes<HTMLAnchorElement>, "href" | "target" | "rel"> & {
|
|
15
15
|
active?: boolean;
|
|
16
16
|
as?: "a" | "li" | "div" | "span";
|
|
17
17
|
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
type DamageFormButtonsProps = {
|
|
1
|
+
export type DamageFormButtonsProps = {
|
|
2
2
|
isEdit: boolean;
|
|
3
3
|
loading: boolean;
|
|
4
4
|
uploadingFile: boolean;
|
|
5
5
|
handleDelete: () => void;
|
|
6
6
|
handleCancel: () => void;
|
|
7
7
|
};
|
|
8
|
-
export declare function
|
|
9
|
-
export {};
|
|
8
|
+
export declare function DamageFormButtons({ isEdit, loading, uploadingFile, handleDelete, handleCancel, }: DamageFormButtonsProps): import("react").JSX.Element;
|
|
@@ -2,6 +2,6 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import Add from "@mui/icons-material/Add";
|
|
3
3
|
import { Button } from "@mui/material";
|
|
4
4
|
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
5
|
-
export function
|
|
5
|
+
export function DamageFormButtons({ isEdit, loading, uploadingFile, handleDelete, handleCancel, }) {
|
|
6
6
|
return (_jsxs(_Fragment, { children: [isEdit && _jsx(Button, { onClick: handleDelete, children: getLocalizedString("Delete") }), _jsx(Button, { onClick: handleCancel, children: getLocalizedString("Cancel") }), _jsx(Button, { loading: loading || uploadingFile, loadingPosition: "start", startIcon: _jsx(Add, {}), type: "submit", variant: "contained", children: isEdit ? getLocalizedString("Save changes") : getLocalizedString("Register damage") })] }));
|
|
7
7
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { TransportElementsRecord } from "../data/dsTransportElements.js";
|
|
2
|
-
type TransportElementSelectProps = {
|
|
2
|
+
export type TransportElementSelectProps = {
|
|
3
3
|
elements: TransportElementsRecord[];
|
|
4
4
|
onSelect: (element: TransportElementsRecord) => void;
|
|
5
5
|
};
|
|
6
6
|
export declare function TransportElementSelect({ elements, onSelect }: TransportElementSelectProps): import("react").JSX.Element;
|
|
7
|
-
export {};
|
package/es/elements/index.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
export * from "./data/index.js";
|
|
2
|
+
export * from "./ElementDamage/DamageFormButtons.js";
|
|
2
3
|
export * from "./ElementDamage/DescriptionInput.js";
|
|
3
4
|
export * from "./ElementDamage/DuplicateDamage/index.js";
|
|
4
5
|
export * from "./ElementDamage/ElementNumberTextField.js";
|
|
5
6
|
export * from "./ElementDamage/HiddenDamageFields.js";
|
|
6
7
|
export * from "./ElementDamage/RegisterFix.js";
|
|
7
8
|
export * from "./ElementDamage/SubmitButtons.js";
|
|
9
|
+
export * from "./ElementDamage/TransportElementSelect.js";
|
|
8
10
|
export * from "./ElementLookup.js";
|
|
11
|
+
export * from "./ElementLookupDialog/BarcodeScanner/index.js";
|
|
12
|
+
export * from "./ElementLookupDialog/HIDScanner/index.js";
|
|
9
13
|
export * from "./ElementLookupDialog/index.js";
|
|
14
|
+
export * from "./ElementLookupDialog/Manual/ManualForm.js";
|
|
10
15
|
export * from "./ProjectSelect.js";
|
package/es/elements/index.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
export * from "./data/index.js";
|
|
2
|
+
export * from "./ElementDamage/DamageFormButtons.js";
|
|
2
3
|
export * from "./ElementDamage/DescriptionInput.js";
|
|
3
4
|
export * from "./ElementDamage/DuplicateDamage/index.js";
|
|
4
5
|
export * from "./ElementDamage/ElementNumberTextField.js";
|
|
5
6
|
export * from "./ElementDamage/HiddenDamageFields.js";
|
|
6
7
|
export * from "./ElementDamage/RegisterFix.js";
|
|
7
8
|
export * from "./ElementDamage/SubmitButtons.js";
|
|
9
|
+
export * from "./ElementDamage/TransportElementSelect.js";
|
|
8
10
|
export * from "./ElementLookup.js";
|
|
11
|
+
export * from "./ElementLookupDialog/BarcodeScanner/index.js";
|
|
12
|
+
export * from "./ElementLookupDialog/HIDScanner/index.js";
|
|
9
13
|
export * from "./ElementLookupDialog/index.js";
|
|
14
|
+
export * from "./ElementLookupDialog/Manual/ManualForm.js";
|
|
10
15
|
export * from "./ProjectSelect.js";
|
package/es/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { AppMenu, type AppMenuArticle, type AppMenuCategory, AppMenuColorScheme, type AppMenuLink, type AppMenuLinkGroup, type AppMenuProps, AppMenuToggle, type AppMenuToggleProps, type AppMenuUser, AppMenuUserMenu, type AppMenuUserMenuProps, createDeveloperCategories, defaultUserMenuItems, type DeveloperCategoryOptions, useServiceWorkerUpdate, } from "./
|
|
2
|
-
export { AppShell, type AppShellProps } from "./
|
|
1
|
+
export { AppMenu, type AppMenuArticle, type AppMenuCategory, AppMenuColorScheme, AppMenuFavoriteButton, type AppMenuFavoriteButtonProps, AppMenuHeader, type AppMenuHeaderProps, type AppMenuLink, type AppMenuLinkGroup, AppMenuList, type AppMenuListProps, type AppMenuProps, AppMenuRail, type AppMenuRailProps, type AppMenuSelection, AppMenuToggle, type AppMenuToggleProps, type AppMenuUser, AppMenuUserMenu, type AppMenuUserMenuProps, createDeveloperCategories, defaultUserMenuItems, type DeveloperCategoryOptions, useServiceWorkerUpdate, } from "./chrome/AppMenu/index.js";
|
|
2
|
+
export { AppShell, type AppShellProps } from "./chrome/AppShell/index.js";
|
|
3
3
|
export { Checkbox, type CheckboxProps } from "./components/Checkbox/index.js";
|
|
4
4
|
export { COLOR_SCHEME_CHANGE_EVENT, type ColorSchemePreference, getColorSchemePreference, setColorSchemePreference, useColorSchemePreference, } from "./colorScheme.js";
|
|
5
5
|
export { CardColumn, CardDetail, CardLabel, CardStep, CardStepList, ColorCard } from "./components/ColorCard/index.js";
|
package/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { AppMenu, AppMenuColorScheme, AppMenuToggle, AppMenuUserMenu, createDeveloperCategories, defaultUserMenuItems, useServiceWorkerUpdate, } from "./
|
|
2
|
-
export { AppShell } from "./
|
|
1
|
+
export { AppMenu, AppMenuColorScheme, AppMenuFavoriteButton, AppMenuHeader, AppMenuList, AppMenuRail, AppMenuToggle, AppMenuUserMenu, createDeveloperCategories, defaultUserMenuItems, useServiceWorkerUpdate, } from "./chrome/AppMenu/index.js";
|
|
2
|
+
export { AppShell } from "./chrome/AppShell/index.js";
|
|
3
3
|
export { Checkbox } from "./components/Checkbox/index.js";
|
|
4
4
|
export { COLOR_SCHEME_CHANGE_EVENT, getColorSchemePreference, setColorSchemePreference, useColorSchemePreference, } from "./colorScheme.js";
|
|
5
5
|
export { CardColumn, CardDetail, CardLabel, CardStep, CardStepList, ColorCard } from "./components/ColorCard/index.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olenbetong/synergi-react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"description": "Standalone React component for SynergiWeb and Partner Portal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"pdf-lib": "^1.17.1",
|
|
45
45
|
"pdfjs-dist": "5.7.284",
|
|
46
46
|
"react-pdf": "^10.4.1",
|
|
47
|
-
"@olenbetong/appframe-react": "2.0.0",
|
|
48
47
|
"@olenbetong/appframe-core": "2.11.10",
|
|
49
|
-
"@olenbetong/appframe-
|
|
50
|
-
"@olenbetong/appframe-
|
|
48
|
+
"@olenbetong/appframe-data": "1.5.0",
|
|
49
|
+
"@olenbetong/appframe-react": "2.0.0",
|
|
50
|
+
"@olenbetong/appframe-mui": "6.6.0"
|
|
51
51
|
},
|
|
52
52
|
"repository": {
|
|
53
53
|
"type": "git",
|