@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.
- package/dist/styles/styles.css +1 -1
- package/dist/styles/styles.css.map +1 -1
- package/es/components/CodeEditor/CodeEditor.css +6 -6
- package/es/components/MergeProgressDialog/MergeProgressDialogDs.d.ts +7 -0
- package/es/components/MergeProgressDialog/MergeProgressDialogDs.js +20 -0
- package/es/components/MergeProgressDialog/index.d.ts +3 -8
- package/es/components/MergeProgressDialog/index.js +4 -133
- package/es/components/MergeProgressDialog/useMergeJob.d.ts +36 -0
- package/es/components/MergeProgressDialog/useMergeJob.js +141 -0
- package/es/components/ProgressBar/index.css +1 -1
- package/es/components/Toolbar/Toolbar.css +137 -137
- package/es/elements/ElementLookupDialog/BarcodeScanner/BarcodeScanner.css +81 -0
- package/es/elements/ElementLookupDialog/BarcodeScanner/DeadIcon.d.ts +2 -2
- package/es/elements/ElementLookupDialog/BarcodeScanner/DeadIcon.js +1 -2
- package/es/elements/ElementLookupDialog/BarcodeScanner/Error.js +3 -29
- package/es/elements/ElementLookupDialog/BarcodeScanner/index.d.ts +1 -0
- package/es/elements/ElementLookupDialog/BarcodeScanner/index.js +3 -28
- package/es/index.css +1 -1
- package/es/index.d.ts +2 -1
- package/es/index.js +2 -1
- package/es/mui/index.d.ts +1 -0
- package/es/mui/index.js +1 -0
- package/es/test/setup.d.ts +5 -0
- package/package.json +21 -14
- package/src/chrome/AppShell/index.tsx +29 -29
- package/src/chrome/openReport.ts +34 -34
- package/src/colorScheme.ts +125 -125
- package/src/components/CodeEditor/CodeEditor.css +6 -6
- package/src/components/CodeEditor/CodeEditor.tsx +173 -173
- package/src/components/CodeEditor/index.ts +1 -1
- package/src/components/DateNavigator/index.tsx +186 -186
- package/src/components/FilePond.tsx +312 -312
- package/src/components/ImageEditor/ImageEditor.tsx +348 -348
- package/src/components/ImageEditor/index.ts +9 -9
- package/src/components/ImageEditor/plugins/cropPlugin/CropOverlay.tsx +165 -165
- package/src/components/ImageEditor/plugins/cropPlugin/CropToolbar.tsx +48 -48
- package/src/components/ImageEditor/plugins/cropPlugin/useCropTool.ts +405 -405
- package/src/components/ImageEditor/plugins/redactPlugin/RedactToolbar.tsx +47 -47
- package/src/components/ImageEditor/plugins/zoomPlugin/ZoomContext.tsx +23 -23
- package/src/components/ImageEditor/plugins/zoomPlugin/ZoomControls.tsx +40 -40
- package/src/components/ImageEditor/useActiveTool.ts +21 -21
- package/src/components/ImageEditor/useEdgeDetection.ts +319 -319
- package/src/components/ImageEditor/useImageHistory.ts +197 -197
- package/src/components/ImageEditor/useOpenCV.ts +184 -184
- package/src/components/LinkedCardList/index.scss +95 -95
- package/src/components/MergeProgressDialog/MergeProgressDialogDs.tsx +91 -0
- package/src/components/MergeProgressDialog/index.tsx +5 -158
- package/src/components/MergeProgressDialog/useMergeJob.ts +169 -0
- package/src/components/PageBanner/index.tsx +80 -80
- package/src/components/PdfViewer/PdfViewer.tsx +158 -158
- package/src/components/ProgressBar/index.scss +23 -54
- package/src/components/SplitContainer/index.tsx +333 -333
- package/src/components/Toolbar/Toolbar.css +137 -137
- package/src/components/Toolbar/index.tsx +265 -265
- package/src/designsystemet-web-types.d.ts +24 -24
- package/src/elements/ElementDamage/DamageFormButtons.tsx +35 -35
- package/src/elements/ElementDamage/DescriptionInput.tsx +120 -120
- package/src/elements/ElementDamage/DuplicateDamage/DesktopView.tsx +82 -82
- package/src/elements/ElementDamage/DuplicateDamage/DublicateElementDamageDialog.tsx +67 -67
- package/src/elements/ElementDamage/DuplicateDamage/PhoneView.tsx +45 -45
- package/src/elements/ElementDamage/ElementNumberTextField.tsx +41 -41
- package/src/elements/ElementDamage/RegisterFix.tsx +100 -100
- package/src/elements/ElementDamage/SubmitButtons.tsx +40 -40
- package/src/elements/ElementDamage/TransportElementSelect.tsx +52 -52
- package/src/elements/ElementLookup.tsx +123 -123
- package/src/elements/ElementLookupDialog/BarcodeScanner/BarcodeScanner.css +81 -0
- package/src/elements/ElementLookupDialog/BarcodeScanner/DeadIcon.tsx +4 -4
- package/src/elements/ElementLookupDialog/BarcodeScanner/Error.tsx +7 -36
- package/src/elements/ElementLookupDialog/BarcodeScanner/index.tsx +20 -49
- package/src/elements/ElementLookupDialog/HIDScanner/index.tsx +67 -67
- package/src/elements/ElementLookupDialog/Manual/ManualForm.tsx +141 -141
- package/src/elements/ElementLookupDialog/index.tsx +226 -226
- package/src/elements/ElementLookupDialog/utils/Giai.ts +209 -209
- package/src/elements/ProjectSelect.tsx +130 -130
- package/src/elements/index.ts +15 -15
- package/src/filter/index.ts +34 -34
- package/src/i18n.ts +13 -13
- package/src/index.ts +5 -1
- package/src/mui/MuiThemeProvider.tsx +135 -135
- package/src/mui/index.ts +1 -0
- package/src/test/setup.ts +23 -8
package/src/elements/index.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export * from "./data/index.js";
|
|
2
|
-
export * from "./ElementDamage/DamageFormButtons.js";
|
|
3
|
-
export * from "./ElementDamage/DescriptionInput.js";
|
|
4
|
-
export * from "./ElementDamage/DuplicateDamage/index.js";
|
|
5
|
-
export * from "./ElementDamage/ElementNumberTextField.js";
|
|
6
|
-
export * from "./ElementDamage/HiddenDamageFields.js";
|
|
7
|
-
export * from "./ElementDamage/RegisterFix.js";
|
|
8
|
-
export * from "./ElementDamage/SubmitButtons.js";
|
|
9
|
-
export * from "./ElementDamage/TransportElementSelect.js";
|
|
10
|
-
export * from "./ElementLookup.js";
|
|
11
|
-
export * from "./ElementLookupDialog/BarcodeScanner/index.js";
|
|
12
|
-
export * from "./ElementLookupDialog/HIDScanner/index.js";
|
|
13
|
-
export * from "./ElementLookupDialog/index.js";
|
|
14
|
-
export * from "./ElementLookupDialog/Manual/ManualForm.js";
|
|
15
|
-
export * from "./ProjectSelect.js";
|
|
1
|
+
export * from "./data/index.js";
|
|
2
|
+
export * from "./ElementDamage/DamageFormButtons.js";
|
|
3
|
+
export * from "./ElementDamage/DescriptionInput.js";
|
|
4
|
+
export * from "./ElementDamage/DuplicateDamage/index.js";
|
|
5
|
+
export * from "./ElementDamage/ElementNumberTextField.js";
|
|
6
|
+
export * from "./ElementDamage/HiddenDamageFields.js";
|
|
7
|
+
export * from "./ElementDamage/RegisterFix.js";
|
|
8
|
+
export * from "./ElementDamage/SubmitButtons.js";
|
|
9
|
+
export * from "./ElementDamage/TransportElementSelect.js";
|
|
10
|
+
export * from "./ElementLookup.js";
|
|
11
|
+
export * from "./ElementLookupDialog/BarcodeScanner/index.js";
|
|
12
|
+
export * from "./ElementLookupDialog/HIDScanner/index.js";
|
|
13
|
+
export * from "./ElementLookupDialog/index.js";
|
|
14
|
+
export * from "./ElementLookupDialog/Manual/ManualForm.js";
|
|
15
|
+
export * from "./ProjectSelect.js";
|
package/src/filter/index.ts
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
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";
|
|
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";
|
package/src/i18n.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The package's strings live in their own globalization project, `synergi-react`, so one
|
|
3
|
-
* translation covers every app and the package can word a term its own way. The templates
|
|
4
|
-
* render the dictionary as af.i18n["synergi-react"]; on a page that does not (a legacy
|
|
5
|
-
* template) the localizer falls back to the article's strings, exactly as before. See
|
|
6
|
-
* `createLocalizer` in @olenbetong/appframe-core.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { createLocalizer } from "@olenbetong/appframe-core";
|
|
10
|
-
|
|
11
|
-
export const PROJECT = "synergi-react";
|
|
12
|
-
|
|
13
|
-
export const { getLocalizedString, localize } = createLocalizer(PROJECT);
|
|
1
|
+
/*
|
|
2
|
+
* The package's strings live in their own globalization project, `synergi-react`, so one
|
|
3
|
+
* translation covers every app and the package can word a term its own way. The templates
|
|
4
|
+
* render the dictionary as af.i18n["synergi-react"]; on a page that does not (a legacy
|
|
5
|
+
* template) the localizer falls back to the article's strings, exactly as before. See
|
|
6
|
+
* `createLocalizer` in @olenbetong/appframe-core.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { createLocalizer } from "@olenbetong/appframe-core";
|
|
10
|
+
|
|
11
|
+
export const PROJECT = "synergi-react";
|
|
12
|
+
|
|
13
|
+
export const { getLocalizedString, localize } = createLocalizer(PROJECT);
|
package/src/index.ts
CHANGED
|
@@ -43,7 +43,11 @@ export {
|
|
|
43
43
|
type SavedFilterTreeProps,
|
|
44
44
|
} from "./filter/index.js";
|
|
45
45
|
export { Card, LinkedList, LinkedListItem } from "./components/LinkedCardList/index.js";
|
|
46
|
-
export {
|
|
46
|
+
export {
|
|
47
|
+
MergeProgressDialogDs,
|
|
48
|
+
type MergeProgressDialogDsProps,
|
|
49
|
+
} from "./components/MergeProgressDialog/MergeProgressDialogDs.js";
|
|
50
|
+
export { type MergeJobOptions, type MergePhase, useMergeJob } from "./components/MergeProgressDialog/useMergeJob.js";
|
|
47
51
|
export { type OpenReportOptions, openReport } from "./chrome/openReport.js";
|
|
48
52
|
export {
|
|
49
53
|
BannerImage as PageBannerImage,
|
|
@@ -1,135 +1,135 @@
|
|
|
1
|
-
import { StyledEngineProvider, ThemeProvider } from "@mui/material";
|
|
2
|
-
import { createTheme as muiCreateTheme } from "@mui/material/styles";
|
|
3
|
-
import { type ReactNode, useEffect, useState } from "react";
|
|
4
|
-
|
|
5
|
-
import { useResolvedColorScheme as useColorScheme } from "../colorScheme.js";
|
|
6
|
-
|
|
7
|
-
function buildMuiTheme(mode: "light" | "dark") {
|
|
8
|
-
const s = getComputedStyle(document.body);
|
|
9
|
-
const get = (v: string) => s.getPropertyValue(v).trim();
|
|
10
|
-
const isDark = mode === "dark";
|
|
11
|
-
|
|
12
|
-
return muiCreateTheme({
|
|
13
|
-
palette: {
|
|
14
|
-
mode,
|
|
15
|
-
primary: {
|
|
16
|
-
main: get("--ds-color-brand-base-default") || "#116069",
|
|
17
|
-
dark: get("--ds-color-brand-base-hover") || "#0d4b52",
|
|
18
|
-
contrastText: get("--ds-color-brand-base-contrast-default") || "#ffffff",
|
|
19
|
-
},
|
|
20
|
-
secondary: {
|
|
21
|
-
main: get("--ds-color-brand-light-base-default") || "#1a95a2",
|
|
22
|
-
},
|
|
23
|
-
background: {
|
|
24
|
-
default: get("--ds-color-neutral-background-default") || (isDark ? "#17181a" : "#ffffff"),
|
|
25
|
-
paper: get("--ds-color-neutral-background-default") || (isDark ? "#17181a" : "#ffffff"),
|
|
26
|
-
},
|
|
27
|
-
text: {
|
|
28
|
-
primary: get("--ds-color-neutral-text-default") || (isDark ? "#e5e6e7" : "#292c30"),
|
|
29
|
-
secondary: get("--ds-color-neutral-text-subtle") || (isDark ? "#b3b5b7" : "#5b5f64"),
|
|
30
|
-
},
|
|
31
|
-
divider: get("--ds-color-neutral-border-subtle") || (isDark ? "#4e5052" : "#bbbcbd"),
|
|
32
|
-
},
|
|
33
|
-
typography: {
|
|
34
|
-
fontFamily: [
|
|
35
|
-
"-apple-system",
|
|
36
|
-
"BlinkMacSystemFont",
|
|
37
|
-
'"Segoe UI"',
|
|
38
|
-
"Roboto",
|
|
39
|
-
'"Helvetica Neue"',
|
|
40
|
-
"Arial",
|
|
41
|
-
"sans-serif",
|
|
42
|
-
'"Apple Color Emoji"',
|
|
43
|
-
'"Segoe UI Emoji"',
|
|
44
|
-
'"Segoe UI Symbol"',
|
|
45
|
-
].join(","),
|
|
46
|
-
},
|
|
47
|
-
components: {
|
|
48
|
-
MuiTypography: {
|
|
49
|
-
styleOverrides: {
|
|
50
|
-
h1: { fontSize: "2.488rem" },
|
|
51
|
-
h2: { fontSize: "2.074rem" },
|
|
52
|
-
h3: { fontSize: "1.728rem" },
|
|
53
|
-
h4: { fontSize: "1.44rem" },
|
|
54
|
-
h5: { fontSize: "1.2rem" },
|
|
55
|
-
h6: { fontSize: "1rem" },
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
MuiAppBar: {
|
|
59
|
-
styleOverrides: {
|
|
60
|
-
root: {
|
|
61
|
-
"& .MuiTypography-h1": {
|
|
62
|
-
fontSize: "1.25rem",
|
|
63
|
-
fontWeight: "500",
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
MuiButton: {
|
|
69
|
-
styleOverrides: {
|
|
70
|
-
root: { borderRadius: 2 },
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
MuiDialogTitle: {
|
|
74
|
-
styleOverrides: {
|
|
75
|
-
root: {
|
|
76
|
-
fontSize: "1.2rem",
|
|
77
|
-
fontWeight: 500,
|
|
78
|
-
paddingLeft: 16,
|
|
79
|
-
paddingRight: 16,
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
MuiFormLabel: {
|
|
84
|
-
styleOverrides: {
|
|
85
|
-
root: { color: get("--ds-color-neutral-text-subtle") || "rgba(0, 0, 0, 0.72)" },
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
MuiTextField: { defaultProps: { variant: "filled" } },
|
|
89
|
-
MuiSelect: { defaultProps: { variant: "filled" } },
|
|
90
|
-
MuiFormControl: { defaultProps: { variant: "filled" } },
|
|
91
|
-
},
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export type MuiThemeProviderProps = {
|
|
96
|
-
children: ReactNode;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Bridges Designsystemet's colour tokens into a MUI theme, so MUI components
|
|
101
|
-
* (most notably the data grid) follow Designsystemet instead of MUI defaults.
|
|
102
|
-
*
|
|
103
|
-
* This lives in a separate entry point (`@olenbetong/synergi-react/mui`) so apps
|
|
104
|
-
* that have migrated to Designsystemet don't pull ~160 kB of MUI and Emotion
|
|
105
|
-
* into their bundle just by using `AppShell`. Wrap `AppShell` with it in apps
|
|
106
|
-
* that still render MUI components:
|
|
107
|
-
*
|
|
108
|
-
* @example
|
|
109
|
-
* ```tsx
|
|
110
|
-
* import { AppShell } from "@olenbetong/synergi-react";
|
|
111
|
-
* import { MuiThemeProvider } from "@olenbetong/synergi-react/mui";
|
|
112
|
-
*
|
|
113
|
-
* <MuiThemeProvider>
|
|
114
|
-
* <AppShell>{children}</AppShell>
|
|
115
|
-
* </MuiThemeProvider>
|
|
116
|
-
* ```
|
|
117
|
-
*/
|
|
118
|
-
export function MuiThemeProvider({ children }: MuiThemeProviderProps) {
|
|
119
|
-
const colorScheme = useColorScheme();
|
|
120
|
-
|
|
121
|
-
// Rebuilt whenever the color scheme changes so MUI components (notably the
|
|
122
|
-
// data grid) follow Designsystemet instead of staying stuck in light mode.
|
|
123
|
-
// Also re-read after mount, since the stylesheets are imported from JS and
|
|
124
|
-
// the CSS variables aren't necessarily resolved during the first render.
|
|
125
|
-
const [theme, setTheme] = useState(() => buildMuiTheme(colorScheme));
|
|
126
|
-
useEffect(() => {
|
|
127
|
-
setTheme(buildMuiTheme(colorScheme));
|
|
128
|
-
}, [colorScheme]);
|
|
129
|
-
|
|
130
|
-
return (
|
|
131
|
-
<StyledEngineProvider injectFirst>
|
|
132
|
-
<ThemeProvider theme={theme}>{children}</ThemeProvider>
|
|
133
|
-
</StyledEngineProvider>
|
|
134
|
-
);
|
|
135
|
-
}
|
|
1
|
+
import { StyledEngineProvider, ThemeProvider } from "@mui/material";
|
|
2
|
+
import { createTheme as muiCreateTheme } from "@mui/material/styles";
|
|
3
|
+
import { type ReactNode, useEffect, useState } from "react";
|
|
4
|
+
|
|
5
|
+
import { useResolvedColorScheme as useColorScheme } from "../colorScheme.js";
|
|
6
|
+
|
|
7
|
+
function buildMuiTheme(mode: "light" | "dark") {
|
|
8
|
+
const s = getComputedStyle(document.body);
|
|
9
|
+
const get = (v: string) => s.getPropertyValue(v).trim();
|
|
10
|
+
const isDark = mode === "dark";
|
|
11
|
+
|
|
12
|
+
return muiCreateTheme({
|
|
13
|
+
palette: {
|
|
14
|
+
mode,
|
|
15
|
+
primary: {
|
|
16
|
+
main: get("--ds-color-brand-base-default") || "#116069",
|
|
17
|
+
dark: get("--ds-color-brand-base-hover") || "#0d4b52",
|
|
18
|
+
contrastText: get("--ds-color-brand-base-contrast-default") || "#ffffff",
|
|
19
|
+
},
|
|
20
|
+
secondary: {
|
|
21
|
+
main: get("--ds-color-brand-light-base-default") || "#1a95a2",
|
|
22
|
+
},
|
|
23
|
+
background: {
|
|
24
|
+
default: get("--ds-color-neutral-background-default") || (isDark ? "#17181a" : "#ffffff"),
|
|
25
|
+
paper: get("--ds-color-neutral-background-default") || (isDark ? "#17181a" : "#ffffff"),
|
|
26
|
+
},
|
|
27
|
+
text: {
|
|
28
|
+
primary: get("--ds-color-neutral-text-default") || (isDark ? "#e5e6e7" : "#292c30"),
|
|
29
|
+
secondary: get("--ds-color-neutral-text-subtle") || (isDark ? "#b3b5b7" : "#5b5f64"),
|
|
30
|
+
},
|
|
31
|
+
divider: get("--ds-color-neutral-border-subtle") || (isDark ? "#4e5052" : "#bbbcbd"),
|
|
32
|
+
},
|
|
33
|
+
typography: {
|
|
34
|
+
fontFamily: [
|
|
35
|
+
"-apple-system",
|
|
36
|
+
"BlinkMacSystemFont",
|
|
37
|
+
'"Segoe UI"',
|
|
38
|
+
"Roboto",
|
|
39
|
+
'"Helvetica Neue"',
|
|
40
|
+
"Arial",
|
|
41
|
+
"sans-serif",
|
|
42
|
+
'"Apple Color Emoji"',
|
|
43
|
+
'"Segoe UI Emoji"',
|
|
44
|
+
'"Segoe UI Symbol"',
|
|
45
|
+
].join(","),
|
|
46
|
+
},
|
|
47
|
+
components: {
|
|
48
|
+
MuiTypography: {
|
|
49
|
+
styleOverrides: {
|
|
50
|
+
h1: { fontSize: "2.488rem" },
|
|
51
|
+
h2: { fontSize: "2.074rem" },
|
|
52
|
+
h3: { fontSize: "1.728rem" },
|
|
53
|
+
h4: { fontSize: "1.44rem" },
|
|
54
|
+
h5: { fontSize: "1.2rem" },
|
|
55
|
+
h6: { fontSize: "1rem" },
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
MuiAppBar: {
|
|
59
|
+
styleOverrides: {
|
|
60
|
+
root: {
|
|
61
|
+
"& .MuiTypography-h1": {
|
|
62
|
+
fontSize: "1.25rem",
|
|
63
|
+
fontWeight: "500",
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
MuiButton: {
|
|
69
|
+
styleOverrides: {
|
|
70
|
+
root: { borderRadius: 2 },
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
MuiDialogTitle: {
|
|
74
|
+
styleOverrides: {
|
|
75
|
+
root: {
|
|
76
|
+
fontSize: "1.2rem",
|
|
77
|
+
fontWeight: 500,
|
|
78
|
+
paddingLeft: 16,
|
|
79
|
+
paddingRight: 16,
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
MuiFormLabel: {
|
|
84
|
+
styleOverrides: {
|
|
85
|
+
root: { color: get("--ds-color-neutral-text-subtle") || "rgba(0, 0, 0, 0.72)" },
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
MuiTextField: { defaultProps: { variant: "filled" } },
|
|
89
|
+
MuiSelect: { defaultProps: { variant: "filled" } },
|
|
90
|
+
MuiFormControl: { defaultProps: { variant: "filled" } },
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export type MuiThemeProviderProps = {
|
|
96
|
+
children: ReactNode;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Bridges Designsystemet's colour tokens into a MUI theme, so MUI components
|
|
101
|
+
* (most notably the data grid) follow Designsystemet instead of MUI defaults.
|
|
102
|
+
*
|
|
103
|
+
* This lives in a separate entry point (`@olenbetong/synergi-react/mui`) so apps
|
|
104
|
+
* that have migrated to Designsystemet don't pull ~160 kB of MUI and Emotion
|
|
105
|
+
* into their bundle just by using `AppShell`. Wrap `AppShell` with it in apps
|
|
106
|
+
* that still render MUI components:
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```tsx
|
|
110
|
+
* import { AppShell } from "@olenbetong/synergi-react";
|
|
111
|
+
* import { MuiThemeProvider } from "@olenbetong/synergi-react/mui";
|
|
112
|
+
*
|
|
113
|
+
* <MuiThemeProvider>
|
|
114
|
+
* <AppShell>{children}</AppShell>
|
|
115
|
+
* </MuiThemeProvider>
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export function MuiThemeProvider({ children }: MuiThemeProviderProps) {
|
|
119
|
+
const colorScheme = useColorScheme();
|
|
120
|
+
|
|
121
|
+
// Rebuilt whenever the color scheme changes so MUI components (notably the
|
|
122
|
+
// data grid) follow Designsystemet instead of staying stuck in light mode.
|
|
123
|
+
// Also re-read after mount, since the stylesheets are imported from JS and
|
|
124
|
+
// the CSS variables aren't necessarily resolved during the first render.
|
|
125
|
+
const [theme, setTheme] = useState(() => buildMuiTheme(colorScheme));
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
setTheme(buildMuiTheme(colorScheme));
|
|
128
|
+
}, [colorScheme]);
|
|
129
|
+
|
|
130
|
+
return (
|
|
131
|
+
<StyledEngineProvider injectFirst>
|
|
132
|
+
<ThemeProvider theme={theme}>{children}</ThemeProvider>
|
|
133
|
+
</StyledEngineProvider>
|
|
134
|
+
);
|
|
135
|
+
}
|
package/src/mui/index.ts
CHANGED
package/src/test/setup.ts
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
|
-
import "@testing-library/jest-dom/vitest";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
afterEach
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import "@testing-library/jest-dom/vitest";
|
|
2
|
+
|
|
3
|
+
import type { TestingLibraryMatchers } from "@testing-library/jest-dom/matchers";
|
|
4
|
+
|
|
5
|
+
import { cleanup } from "@testing-library/react";
|
|
6
|
+
import { afterEach } from "vitest";
|
|
7
|
+
|
|
8
|
+
afterEach(() => {
|
|
9
|
+
cleanup();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
* jest-dom 7.0.1 types its matchers onto the one-parameter `Assertion<T>` of Vitest 4, which
|
|
14
|
+
* Vitest 5 replaced with `Assertion<R, T>`; custom matchers now go on `Matchers<R, T>`. Until
|
|
15
|
+
* jest-dom ships Vitest 5 types, register them there. Remove this when its `vitest` entry
|
|
16
|
+
* types `Matchers` itself.
|
|
17
|
+
*/
|
|
18
|
+
declare module "vitest" {
|
|
19
|
+
interface Matchers<R extends void | Promise<void> = void | Promise<void>, T = unknown> extends TestingLibraryMatchers<
|
|
20
|
+
T,
|
|
21
|
+
R
|
|
22
|
+
> {}
|
|
23
|
+
}
|