@olenbetong/synergi-react 4.3.1 → 5.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.
Files changed (81) hide show
  1. package/dist/styles/styles.css +1 -1
  2. package/dist/styles/styles.css.map +1 -1
  3. package/es/components/CodeEditor/CodeEditor.css +6 -6
  4. package/es/components/MergeProgressDialog/MergeProgressDialogDs.d.ts +7 -0
  5. package/es/components/MergeProgressDialog/MergeProgressDialogDs.js +20 -0
  6. package/es/components/MergeProgressDialog/index.d.ts +3 -8
  7. package/es/components/MergeProgressDialog/index.js +4 -133
  8. package/es/components/MergeProgressDialog/useMergeJob.d.ts +36 -0
  9. package/es/components/MergeProgressDialog/useMergeJob.js +141 -0
  10. package/es/components/ProgressBar/index.css +1 -1
  11. package/es/components/Toolbar/Toolbar.css +137 -137
  12. package/es/elements/ElementLookupDialog/BarcodeScanner/BarcodeScanner.css +81 -0
  13. package/es/elements/ElementLookupDialog/BarcodeScanner/DeadIcon.d.ts +2 -2
  14. package/es/elements/ElementLookupDialog/BarcodeScanner/DeadIcon.js +1 -2
  15. package/es/elements/ElementLookupDialog/BarcodeScanner/Error.js +3 -29
  16. package/es/elements/ElementLookupDialog/BarcodeScanner/index.d.ts +1 -0
  17. package/es/elements/ElementLookupDialog/BarcodeScanner/index.js +3 -28
  18. package/es/index.css +1 -1
  19. package/es/index.d.ts +2 -1
  20. package/es/index.js +2 -1
  21. package/es/mui/index.d.ts +1 -0
  22. package/es/mui/index.js +1 -0
  23. package/es/test/setup.d.ts +5 -0
  24. package/package.json +21 -14
  25. package/src/chrome/AppShell/index.tsx +29 -29
  26. package/src/chrome/openReport.ts +34 -34
  27. package/src/colorScheme.ts +125 -125
  28. package/src/components/CodeEditor/CodeEditor.css +6 -6
  29. package/src/components/CodeEditor/CodeEditor.tsx +173 -173
  30. package/src/components/CodeEditor/index.ts +1 -1
  31. package/src/components/DateNavigator/index.tsx +186 -186
  32. package/src/components/FilePond.tsx +312 -312
  33. package/src/components/ImageEditor/ImageEditor.tsx +348 -348
  34. package/src/components/ImageEditor/index.ts +9 -9
  35. package/src/components/ImageEditor/plugins/cropPlugin/CropOverlay.tsx +165 -165
  36. package/src/components/ImageEditor/plugins/cropPlugin/CropToolbar.tsx +48 -48
  37. package/src/components/ImageEditor/plugins/cropPlugin/useCropTool.ts +405 -405
  38. package/src/components/ImageEditor/plugins/redactPlugin/RedactToolbar.tsx +47 -47
  39. package/src/components/ImageEditor/plugins/zoomPlugin/ZoomContext.tsx +23 -23
  40. package/src/components/ImageEditor/plugins/zoomPlugin/ZoomControls.tsx +40 -40
  41. package/src/components/ImageEditor/useActiveTool.ts +21 -21
  42. package/src/components/ImageEditor/useEdgeDetection.ts +319 -319
  43. package/src/components/ImageEditor/useImageHistory.ts +197 -197
  44. package/src/components/ImageEditor/useOpenCV.ts +184 -184
  45. package/src/components/LinkedCardList/index.scss +95 -95
  46. package/src/components/MergeProgressDialog/MergeProgressDialogDs.tsx +91 -0
  47. package/src/components/MergeProgressDialog/index.tsx +5 -158
  48. package/src/components/MergeProgressDialog/useMergeJob.ts +169 -0
  49. package/src/components/PageBanner/index.tsx +80 -80
  50. package/src/components/PdfViewer/PdfViewer.tsx +158 -158
  51. package/src/components/ProgressBar/index.scss +23 -54
  52. package/src/components/SplitContainer/index.tsx +333 -333
  53. package/src/components/Toolbar/Toolbar.css +137 -137
  54. package/src/components/Toolbar/index.tsx +265 -265
  55. package/src/designsystemet-web-types.d.ts +24 -24
  56. package/src/elements/ElementDamage/DamageFormButtons.tsx +35 -35
  57. package/src/elements/ElementDamage/DescriptionInput.tsx +120 -120
  58. package/src/elements/ElementDamage/DuplicateDamage/DesktopView.tsx +82 -82
  59. package/src/elements/ElementDamage/DuplicateDamage/DublicateElementDamageDialog.tsx +67 -67
  60. package/src/elements/ElementDamage/DuplicateDamage/PhoneView.tsx +45 -45
  61. package/src/elements/ElementDamage/ElementNumberTextField.tsx +41 -41
  62. package/src/elements/ElementDamage/RegisterFix.tsx +100 -100
  63. package/src/elements/ElementDamage/SubmitButtons.tsx +40 -40
  64. package/src/elements/ElementDamage/TransportElementSelect.tsx +52 -52
  65. package/src/elements/ElementLookup.tsx +123 -123
  66. package/src/elements/ElementLookupDialog/BarcodeScanner/BarcodeScanner.css +81 -0
  67. package/src/elements/ElementLookupDialog/BarcodeScanner/DeadIcon.tsx +4 -4
  68. package/src/elements/ElementLookupDialog/BarcodeScanner/Error.tsx +7 -36
  69. package/src/elements/ElementLookupDialog/BarcodeScanner/index.tsx +20 -49
  70. package/src/elements/ElementLookupDialog/HIDScanner/index.tsx +67 -67
  71. package/src/elements/ElementLookupDialog/Manual/ManualForm.tsx +141 -141
  72. package/src/elements/ElementLookupDialog/index.tsx +226 -226
  73. package/src/elements/ElementLookupDialog/utils/Giai.ts +209 -209
  74. package/src/elements/ProjectSelect.tsx +130 -130
  75. package/src/elements/index.ts +15 -15
  76. package/src/filter/index.ts +34 -34
  77. package/src/i18n.ts +13 -13
  78. package/src/index.ts +5 -1
  79. package/src/mui/MuiThemeProvider.tsx +135 -135
  80. package/src/mui/index.ts +1 -0
  81. package/src/test/setup.ts +23 -8
@@ -1,173 +1,173 @@
1
- import clsx from "clsx";
2
- import * as monaco from "monaco-editor";
3
- import { forwardRef, useEffect, useImperativeHandle, useRef } from "react";
4
-
5
- import { useResolvedColorScheme } from "../../colorScheme.js";
6
- import "./CodeEditor.css";
7
-
8
- /*
9
- * Monaco on the 2026 templates comes from the platform bundle through the import map. The
10
- * platform entry sets `MonacoEnvironment` (the editor and language workers, served next to it)
11
- * and links Monaco's stylesheet on first import, so this component only drives the editor.
12
- * Off the platform (the Vite dev server, a legacy template) Monaco is bundled from npm: its
13
- * stylesheets come with it, and without `MonacoEnvironment` the language services run on the
14
- * main thread with a console warning. That is fine for development; it is why this lives in its
15
- * own entry point and is not re-exported from the package root.
16
- */
17
-
18
- export type CodeEditorHandle = {
19
- /** The Monaco editor instance, once mounted. */
20
- editor: monaco.editor.IStandaloneCodeEditor | null;
21
- /** Replaces the selection (or inserts at the cursor) and focuses the editor. */
22
- insertText(text: string): void;
23
- focus(): void;
24
- };
25
-
26
- export type CodeEditorProps = {
27
- /** The text shown. The editor is controlled: `onChange` reports every edit. */
28
- value: string;
29
- onChange?: (value: string) => void;
30
- /** Monaco language ID, e.g. `html`, `css`, `javascript`, `json`, `sql`, `xml`. */
31
- language?: string;
32
- /**
33
- * Identifies the document. When it changes, the editor gets a fresh model, so undo history
34
- * does not leak from one record to the next. Without it, a new `value` is applied as an edit
35
- * that can be undone.
36
- */
37
- docKey?: string;
38
- readOnly?: boolean;
39
- /** Ctrl/Cmd+S inside the editor. */
40
- onSave?: () => void;
41
- /** Extra Monaco options, applied on mount and whenever the object changes. */
42
- options?: monaco.editor.IEditorOptions;
43
- className?: string;
44
- style?: React.CSSProperties;
45
- "aria-label"?: string;
46
- };
47
-
48
- /**
49
- * Monaco code editor that follows the site's colour scheme. The element fills its parent's size
50
- * through `className`/`style`; give it a height.
51
- */
52
- export const CodeEditor = forwardRef<CodeEditorHandle, CodeEditorProps>(function CodeEditor(
53
- {
54
- value,
55
- onChange,
56
- language = "plaintext",
57
- docKey,
58
- readOnly = false,
59
- onSave,
60
- options,
61
- className,
62
- style,
63
- "aria-label": ariaLabel,
64
- },
65
- ref,
66
- ) {
67
- let container = useRef<HTMLDivElement>(null);
68
- let editor = useRef<monaco.editor.IStandaloneCodeEditor | null>(null);
69
- // Latest callbacks without re-creating the editor.
70
- let callbacks = useRef({ onChange, onSave });
71
- callbacks.current = { onChange, onSave };
72
- // Set while the editor applies a `value` from props, so that edit is not reported back.
73
- let applyingValue = useRef(false);
74
- let shownDoc = useRef<string | undefined>(undefined);
75
- let colorScheme = useResolvedColorScheme();
76
-
77
- useEffect(() => {
78
- if (!container.current) return;
79
- let instance = monaco.editor.create(container.current, {
80
- value,
81
- language,
82
- theme: colorScheme === "dark" ? "vs-dark" : "vs",
83
- automaticLayout: true,
84
- minimap: { enabled: false },
85
- scrollBeyondLastLine: false,
86
- fixedOverflowWidgets: true,
87
- ariaLabel,
88
- readOnly,
89
- ...options,
90
- });
91
- editor.current = instance;
92
- shownDoc.current = docKey;
93
- let changeListener = instance.onDidChangeModelContent(() => {
94
- if (!applyingValue.current) {
95
- callbacks.current.onChange?.(instance.getValue());
96
- }
97
- });
98
- instance.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyS, () => callbacks.current.onSave?.());
99
-
100
- return () => {
101
- changeListener.dispose();
102
- instance.getModel()?.dispose();
103
- instance.dispose();
104
- editor.current = null;
105
- };
106
- // The editor is created once; every prop is synced by the effects below.
107
- // oxlint-disable-next-line react-hooks/exhaustive-deps
108
- }, []);
109
-
110
- useEffect(() => {
111
- let instance = editor.current;
112
- if (!instance) return;
113
-
114
- applyingValue.current = true;
115
- try {
116
- if (shownDoc.current !== docKey) {
117
- // New document: a new model, so undo history stays with the document it belongs to.
118
- let old = instance.getModel();
119
- instance.setModel(monaco.editor.createModel(value, language));
120
- old?.dispose();
121
- shownDoc.current = docKey;
122
- } else if (instance.getValue() !== value) {
123
- // Same document, changed from outside (cancel, reload): one undoable edit.
124
- let model = instance.getModel();
125
- if (model) {
126
- instance.executeEdits("external", [{ range: model.getFullModelRange(), text: value }]);
127
- }
128
- }
129
- } finally {
130
- applyingValue.current = false;
131
- }
132
- }, [docKey, value, language]);
133
-
134
- useEffect(() => {
135
- let model = editor.current?.getModel();
136
- if (model && model.getLanguageId() !== language) {
137
- monaco.editor.setModelLanguage(model, language);
138
- }
139
- }, [language]);
140
-
141
- useEffect(() => {
142
- editor.current?.updateOptions({ readOnly, ariaLabel, ...options });
143
- }, [readOnly, ariaLabel, options]);
144
-
145
- useEffect(() => {
146
- // The theme is global to every editor on the page.
147
- monaco.editor.setTheme(colorScheme === "dark" ? "vs-dark" : "vs");
148
- }, [colorScheme]);
149
-
150
- useImperativeHandle(ref, () => ({
151
- get editor() {
152
- return editor.current;
153
- },
154
- insertText(text: string) {
155
- let instance = editor.current;
156
- if (!instance) return;
157
- let range = instance.getSelection() ?? new monaco.Range(1, 1, 1, 1);
158
- instance.executeEdits("insert", [{ range, text, forceMoveMarkers: true }]);
159
- instance.focus();
160
- },
161
- focus() {
162
- editor.current?.focus();
163
- },
164
- }));
165
-
166
- /*
167
- * `monaco-component`: Monaco renders the context menu in a shadow root attached to this
168
- * container, a parent of `.monaco-editor`. Its colours are theme variables Monaco defines on
169
- * `.monaco-editor, .monaco-diff-editor, .monaco-component` only, so without the class the
170
- * menu inherits none of them and has no background.
171
- */
172
- return <div ref={container} className={clsx("ObCodeEditor-root", "monaco-component", className)} style={style} />;
173
- });
1
+ import clsx from "clsx";
2
+ import * as monaco from "monaco-editor";
3
+ import { forwardRef, useEffect, useImperativeHandle, useRef } from "react";
4
+
5
+ import { useResolvedColorScheme } from "../../colorScheme.js";
6
+ import "./CodeEditor.css";
7
+
8
+ /*
9
+ * Monaco on the 2026 templates comes from the platform bundle through the import map. The
10
+ * platform entry sets `MonacoEnvironment` (the editor and language workers, served next to it)
11
+ * and links Monaco's stylesheet on first import, so this component only drives the editor.
12
+ * Off the platform (the Vite dev server, a legacy template) Monaco is bundled from npm: its
13
+ * stylesheets come with it, and without `MonacoEnvironment` the language services run on the
14
+ * main thread with a console warning. That is fine for development; it is why this lives in its
15
+ * own entry point and is not re-exported from the package root.
16
+ */
17
+
18
+ export type CodeEditorHandle = {
19
+ /** The Monaco editor instance, once mounted. */
20
+ editor: monaco.editor.IStandaloneCodeEditor | null;
21
+ /** Replaces the selection (or inserts at the cursor) and focuses the editor. */
22
+ insertText(text: string): void;
23
+ focus(): void;
24
+ };
25
+
26
+ export type CodeEditorProps = {
27
+ /** The text shown. The editor is controlled: `onChange` reports every edit. */
28
+ value: string;
29
+ onChange?: (value: string) => void;
30
+ /** Monaco language ID, e.g. `html`, `css`, `javascript`, `json`, `sql`, `xml`. */
31
+ language?: string;
32
+ /**
33
+ * Identifies the document. When it changes, the editor gets a fresh model, so undo history
34
+ * does not leak from one record to the next. Without it, a new `value` is applied as an edit
35
+ * that can be undone.
36
+ */
37
+ docKey?: string;
38
+ readOnly?: boolean;
39
+ /** Ctrl/Cmd+S inside the editor. */
40
+ onSave?: () => void;
41
+ /** Extra Monaco options, applied on mount and whenever the object changes. */
42
+ options?: monaco.editor.IEditorOptions;
43
+ className?: string;
44
+ style?: React.CSSProperties;
45
+ "aria-label"?: string;
46
+ };
47
+
48
+ /**
49
+ * Monaco code editor that follows the site's colour scheme. The element fills its parent's size
50
+ * through `className`/`style`; give it a height.
51
+ */
52
+ export const CodeEditor = forwardRef<CodeEditorHandle, CodeEditorProps>(function CodeEditor(
53
+ {
54
+ value,
55
+ onChange,
56
+ language = "plaintext",
57
+ docKey,
58
+ readOnly = false,
59
+ onSave,
60
+ options,
61
+ className,
62
+ style,
63
+ "aria-label": ariaLabel,
64
+ },
65
+ ref,
66
+ ) {
67
+ let container = useRef<HTMLDivElement>(null);
68
+ let editor = useRef<monaco.editor.IStandaloneCodeEditor | null>(null);
69
+ // Latest callbacks without re-creating the editor.
70
+ let callbacks = useRef({ onChange, onSave });
71
+ callbacks.current = { onChange, onSave };
72
+ // Set while the editor applies a `value` from props, so that edit is not reported back.
73
+ let applyingValue = useRef(false);
74
+ let shownDoc = useRef<string | undefined>(undefined);
75
+ let colorScheme = useResolvedColorScheme();
76
+
77
+ useEffect(() => {
78
+ if (!container.current) return;
79
+ let instance = monaco.editor.create(container.current, {
80
+ value,
81
+ language,
82
+ theme: colorScheme === "dark" ? "vs-dark" : "vs",
83
+ automaticLayout: true,
84
+ minimap: { enabled: false },
85
+ scrollBeyondLastLine: false,
86
+ fixedOverflowWidgets: true,
87
+ ariaLabel,
88
+ readOnly,
89
+ ...options,
90
+ });
91
+ editor.current = instance;
92
+ shownDoc.current = docKey;
93
+ let changeListener = instance.onDidChangeModelContent(() => {
94
+ if (!applyingValue.current) {
95
+ callbacks.current.onChange?.(instance.getValue());
96
+ }
97
+ });
98
+ instance.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyS, () => callbacks.current.onSave?.());
99
+
100
+ return () => {
101
+ changeListener.dispose();
102
+ instance.getModel()?.dispose();
103
+ instance.dispose();
104
+ editor.current = null;
105
+ };
106
+ // The editor is created once; every prop is synced by the effects below.
107
+ // oxlint-disable-next-line react-hooks/exhaustive-deps
108
+ }, []);
109
+
110
+ useEffect(() => {
111
+ let instance = editor.current;
112
+ if (!instance) return;
113
+
114
+ applyingValue.current = true;
115
+ try {
116
+ if (shownDoc.current !== docKey) {
117
+ // New document: a new model, so undo history stays with the document it belongs to.
118
+ let old = instance.getModel();
119
+ instance.setModel(monaco.editor.createModel(value, language));
120
+ old?.dispose();
121
+ shownDoc.current = docKey;
122
+ } else if (instance.getValue() !== value) {
123
+ // Same document, changed from outside (cancel, reload): one undoable edit.
124
+ let model = instance.getModel();
125
+ if (model) {
126
+ instance.executeEdits("external", [{ range: model.getFullModelRange(), text: value }]);
127
+ }
128
+ }
129
+ } finally {
130
+ applyingValue.current = false;
131
+ }
132
+ }, [docKey, value, language]);
133
+
134
+ useEffect(() => {
135
+ let model = editor.current?.getModel();
136
+ if (model && model.getLanguageId() !== language) {
137
+ monaco.editor.setModelLanguage(model, language);
138
+ }
139
+ }, [language]);
140
+
141
+ useEffect(() => {
142
+ editor.current?.updateOptions({ readOnly, ariaLabel, ...options });
143
+ }, [readOnly, ariaLabel, options]);
144
+
145
+ useEffect(() => {
146
+ // The theme is global to every editor on the page.
147
+ monaco.editor.setTheme(colorScheme === "dark" ? "vs-dark" : "vs");
148
+ }, [colorScheme]);
149
+
150
+ useImperativeHandle(ref, () => ({
151
+ get editor() {
152
+ return editor.current;
153
+ },
154
+ insertText(text: string) {
155
+ let instance = editor.current;
156
+ if (!instance) return;
157
+ let range = instance.getSelection() ?? new monaco.Range(1, 1, 1, 1);
158
+ instance.executeEdits("insert", [{ range, text, forceMoveMarkers: true }]);
159
+ instance.focus();
160
+ },
161
+ focus() {
162
+ editor.current?.focus();
163
+ },
164
+ }));
165
+
166
+ /*
167
+ * `monaco-component`: Monaco renders the context menu in a shadow root attached to this
168
+ * container, a parent of `.monaco-editor`. Its colours are theme variables Monaco defines on
169
+ * `.monaco-editor, .monaco-diff-editor, .monaco-component` only, so without the class the
170
+ * menu inherits none of them and has no background.
171
+ */
172
+ return <div ref={container} className={clsx("ObCodeEditor-root", "monaco-component", className)} style={style} />;
173
+ });
@@ -1 +1 @@
1
- export { CodeEditor, type CodeEditorHandle, type CodeEditorProps } from "./CodeEditor.js";
1
+ export { CodeEditor, type CodeEditorHandle, type CodeEditorProps } from "./CodeEditor.js";