@owp/core 2.5.4 → 2.5.5
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/_virtual/index10.js +2 -2
- package/dist/_virtual/index11.js +2 -2
- package/dist/_virtual/index12.js +2 -2
- package/dist/_virtual/index13.js +2 -2
- package/dist/_virtual/index15.js +2 -2
- package/dist/_virtual/index16.js +4 -4
- package/dist/_virtual/index17.js +4 -4
- package/dist/_virtual/index18.js +4 -4
- package/dist/_virtual/index19.js +4 -4
- package/dist/_virtual/index5.js +2 -2
- package/dist/components/OwpPageSkeleton/OwpPageSkeleton.js +4 -4
- package/dist/components/OwpTable/OwpDataTable.js +293 -327
- package/dist/components/OwpTable/OwpDataTable.js.map +1 -1
- package/dist/components/OwpTable/OwpTable.js +102 -117
- package/dist/components/OwpTable/OwpTable.js.map +1 -1
- package/dist/components/OwpTable/internal/defaultTableStyle.js +50 -0
- package/dist/components/OwpTable/internal/defaultTableStyle.js.map +1 -0
- package/dist/components/OwpTreeGrid/OwpTreeGrid.js +47 -45
- package/dist/components/OwpTreeGrid/OwpTreeGrid.js.map +1 -1
- package/dist/components/OwpTreeGrid/internal/treeGridRuntime.js +179 -161
- package/dist/components/OwpTreeGrid/internal/treeGridRuntime.js.map +1 -1
- package/dist/contexts/OwpAppProvider.js.map +1 -1
- package/dist/features/themePreview/components/ThemePreviewCanvas.js +492 -0
- package/dist/features/themePreview/components/ThemePreviewCanvas.js.map +1 -0
- package/dist/features/themePreview/components/ThemePreviewCanvasSections.js +678 -0
- package/dist/features/themePreview/components/ThemePreviewCanvasSections.js.map +1 -0
- package/dist/features/themePreview/components/ThemePreviewColorField.js +301 -0
- package/dist/features/themePreview/components/ThemePreviewColorField.js.map +1 -0
- package/dist/features/themePreview/components/ThemePreviewControls.js +306 -0
- package/dist/features/themePreview/components/ThemePreviewControls.js.map +1 -0
- package/dist/features/themePreview/components/themePreviewCanvas.icons.js +17 -0
- package/dist/features/themePreview/components/themePreviewCanvas.icons.js.map +1 -0
- package/dist/features/themePreview/components/themePreviewCanvas.shared.js +296 -0
- package/dist/features/themePreview/components/themePreviewCanvas.shared.js.map +1 -0
- package/dist/features/themePreview/configs/grid.js +45 -0
- package/dist/features/themePreview/configs/grid.js.map +1 -0
- package/dist/features/themePreview/configs/presets.js +1106 -0
- package/dist/features/themePreview/configs/presets.js.map +1 -0
- package/dist/features/themePreview/configs/previewStorage.js +93 -0
- package/dist/features/themePreview/configs/previewStorage.js.map +1 -0
- package/dist/features/themePreview/configs/settings.js +148 -0
- package/dist/features/themePreview/configs/settings.js.map +1 -0
- package/dist/features/themePreview/configs/snackbar.js +39 -0
- package/dist/features/themePreview/configs/snackbar.js.map +1 -0
- package/dist/features/themePreview/configs/surface.js +10 -0
- package/dist/features/themePreview/configs/surface.js.map +1 -0
- package/dist/features/themePreview/configs/table.js +30 -0
- package/dist/features/themePreview/configs/table.js.map +1 -0
- package/dist/features/themePreview/defs/ThemePreviewGridDef.xml.js +43 -0
- package/dist/features/themePreview/defs/ThemePreviewGridDef.xml.js.map +1 -0
- package/dist/features/themePreview/defs/ThemePreviewReadonlyGridDef.xml.js +43 -0
- package/dist/features/themePreview/defs/ThemePreviewReadonlyGridDef.xml.js.map +1 -0
- package/dist/features/themePreview/dialogs/ThemePreviewDialog.js +429 -0
- package/dist/features/themePreview/dialogs/ThemePreviewDialog.js.map +1 -0
- package/dist/features/themePreview/hooks/useThemePreview.js +235 -0
- package/dist/features/themePreview/hooks/useThemePreview.js.map +1 -0
- package/dist/features/themePreview/utils/color.js +79 -0
- package/dist/features/themePreview/utils/color.js.map +1 -0
- package/dist/features/themePreview/utils/themePreviewDefinitions.js +526 -0
- package/dist/features/themePreview/utils/themePreviewDefinitions.js.map +1 -0
- package/dist/features/themePreview/utils/themePreviewExport.js +111 -0
- package/dist/features/themePreview/utils/themePreviewExport.js.map +1 -0
- package/dist/features/themePreview/utils/themePreviewSettings.js +211 -0
- package/dist/features/themePreview/utils/themePreviewSettings.js.map +1 -0
- package/dist/features/themePreview.js +75 -0
- package/dist/features/themePreview.js.map +1 -0
- package/dist/layout/components/logo/Logo.js +49 -45
- package/dist/layout/components/logo/Logo.js.map +1 -1
- package/dist/layout/components/toggles/NavigationSearchToggle.js +3 -3
- package/dist/layout/components/toggles/ThemePreviewToggle.js +51 -0
- package/dist/layout/components/toggles/ThemePreviewToggle.js.map +1 -0
- package/dist/layout/components/toolbar/ToolbarLayout.js +8 -6
- package/dist/layout/components/toolbar/ToolbarLayout.js.map +1 -1
- package/dist/node_modules/.pnpm/@mui_icons-material@7.3.9_@mui_material@7.3.9_@emotion_react@11.14.0_@types_react@19.2._dc2be6bc014bebdac88a574e3e02c144/node_modules/@mui/icons-material/esm/CheckCircleOutline.js +9 -0
- package/dist/node_modules/.pnpm/@mui_icons-material@7.3.9_@mui_material@7.3.9_@emotion_react@11.14.0_@types_react@19.2._dc2be6bc014bebdac88a574e3e02c144/node_modules/@mui/icons-material/esm/CheckCircleOutline.js.map +1 -0
- package/dist/node_modules/.pnpm/@mui_icons-material@7.3.9_@mui_material@7.3.9_@emotion_react@11.14.0_@types_react@19.2._dc2be6bc014bebdac88a574e3e02c144/node_modules/@mui/icons-material/esm/DownloadOutlined.js +9 -0
- package/dist/node_modules/.pnpm/@mui_icons-material@7.3.9_@mui_material@7.3.9_@emotion_react@11.14.0_@types_react@19.2._dc2be6bc014bebdac88a574e3e02c144/node_modules/@mui/icons-material/esm/DownloadOutlined.js.map +1 -0
- package/dist/node_modules/.pnpm/@mui_icons-material@7.3.9_@mui_material@7.3.9_@emotion_react@11.14.0_@types_react@19.2._dc2be6bc014bebdac88a574e3e02c144/node_modules/@mui/icons-material/esm/ErrorOutline.js +9 -0
- package/dist/node_modules/.pnpm/@mui_icons-material@7.3.9_@mui_material@7.3.9_@emotion_react@11.14.0_@types_react@19.2._dc2be6bc014bebdac88a574e3e02c144/node_modules/@mui/icons-material/esm/ErrorOutline.js.map +1 -0
- package/dist/node_modules/.pnpm/@mui_icons-material@7.3.9_@mui_material@7.3.9_@emotion_react@11.14.0_@types_react@19.2._dc2be6bc014bebdac88a574e3e02c144/node_modules/@mui/icons-material/esm/InfoOutlined.js +9 -0
- package/dist/node_modules/.pnpm/@mui_icons-material@7.3.9_@mui_material@7.3.9_@emotion_react@11.14.0_@types_react@19.2._dc2be6bc014bebdac88a574e3e02c144/node_modules/@mui/icons-material/esm/InfoOutlined.js.map +1 -0
- package/dist/node_modules/.pnpm/@mui_icons-material@7.3.9_@mui_material@7.3.9_@emotion_react@11.14.0_@types_react@19.2._dc2be6bc014bebdac88a574e3e02c144/node_modules/@mui/icons-material/esm/KeyboardArrowUpRounded.js +9 -0
- package/dist/node_modules/.pnpm/@mui_icons-material@7.3.9_@mui_material@7.3.9_@emotion_react@11.14.0_@types_react@19.2._dc2be6bc014bebdac88a574e3e02c144/node_modules/@mui/icons-material/esm/KeyboardArrowUpRounded.js.map +1 -0
- package/dist/node_modules/.pnpm/@mui_icons-material@7.3.9_@mui_material@7.3.9_@emotion_react@11.14.0_@types_react@19.2._dc2be6bc014bebdac88a574e3e02c144/node_modules/@mui/icons-material/esm/MenuRounded.js +9 -0
- package/dist/node_modules/.pnpm/@mui_icons-material@7.3.9_@mui_material@7.3.9_@emotion_react@11.14.0_@types_react@19.2._dc2be6bc014bebdac88a574e3e02c144/node_modules/@mui/icons-material/esm/MenuRounded.js.map +1 -0
- package/dist/node_modules/.pnpm/@mui_icons-material@7.3.9_@mui_material@7.3.9_@emotion_react@11.14.0_@types_react@19.2._dc2be6bc014bebdac88a574e3e02c144/node_modules/@mui/icons-material/esm/NotificationsNoneOutlined.js +9 -0
- package/dist/node_modules/.pnpm/@mui_icons-material@7.3.9_@mui_material@7.3.9_@emotion_react@11.14.0_@types_react@19.2._dc2be6bc014bebdac88a574e3e02c144/node_modules/@mui/icons-material/esm/NotificationsNoneOutlined.js.map +1 -0
- package/dist/node_modules/.pnpm/@mui_icons-material@7.3.9_@mui_material@7.3.9_@emotion_react@11.14.0_@types_react@19.2._dc2be6bc014bebdac88a574e3e02c144/node_modules/@mui/icons-material/esm/PaletteOutlined.js +25 -0
- package/dist/node_modules/.pnpm/@mui_icons-material@7.3.9_@mui_material@7.3.9_@emotion_react@11.14.0_@types_react@19.2._dc2be6bc014bebdac88a574e3e02c144/node_modules/@mui/icons-material/esm/PaletteOutlined.js.map +1 -0
- package/dist/node_modules/.pnpm/@mui_icons-material@7.3.9_@mui_material@7.3.9_@emotion_react@11.14.0_@types_react@19.2._dc2be6bc014bebdac88a574e3e02c144/node_modules/@mui/icons-material/esm/RestoreOutlined.js +9 -0
- package/dist/node_modules/.pnpm/@mui_icons-material@7.3.9_@mui_material@7.3.9_@emotion_react@11.14.0_@types_react@19.2._dc2be6bc014bebdac88a574e3e02c144/node_modules/@mui/icons-material/esm/RestoreOutlined.js.map +1 -0
- package/dist/node_modules/.pnpm/@mui_icons-material@7.3.9_@mui_material@7.3.9_@emotion_react@11.14.0_@types_react@19.2._dc2be6bc014bebdac88a574e3e02c144/node_modules/@mui/icons-material/esm/SaveOutlined.js +9 -0
- package/dist/node_modules/.pnpm/@mui_icons-material@7.3.9_@mui_material@7.3.9_@emotion_react@11.14.0_@types_react@19.2._dc2be6bc014bebdac88a574e3e02c144/node_modules/@mui/icons-material/esm/SaveOutlined.js.map +1 -0
- package/dist/node_modules/.pnpm/@mui_icons-material@7.3.9_@mui_material@7.3.9_@emotion_react@11.14.0_@types_react@19.2._dc2be6bc014bebdac88a574e3e02c144/node_modules/@mui/icons-material/esm/SpaceDashboardOutlined.js +9 -0
- package/dist/node_modules/.pnpm/@mui_icons-material@7.3.9_@mui_material@7.3.9_@emotion_react@11.14.0_@types_react@19.2._dc2be6bc014bebdac88a574e3e02c144/node_modules/@mui/icons-material/esm/SpaceDashboardOutlined.js.map +1 -0
- package/dist/node_modules/.pnpm/@mui_icons-material@7.3.9_@mui_material@7.3.9_@emotion_react@11.14.0_@types_react@19.2._dc2be6bc014bebdac88a574e3e02c144/node_modules/@mui/icons-material/esm/UploadFileOutlined.js +9 -0
- package/dist/node_modules/.pnpm/@mui_icons-material@7.3.9_@mui_material@7.3.9_@emotion_react@11.14.0_@types_react@19.2._dc2be6bc014bebdac88a574e3e02c144/node_modules/@mui/icons-material/esm/UploadFileOutlined.js.map +1 -0
- package/dist/node_modules/.pnpm/@mui_icons-material@7.3.9_@mui_material@7.3.9_@emotion_react@11.14.0_@types_react@19.2._dc2be6bc014bebdac88a574e3e02c144/node_modules/@mui/icons-material/esm/WarningAmberRounded.js +9 -0
- package/dist/node_modules/.pnpm/@mui_icons-material@7.3.9_@mui_material@7.3.9_@emotion_react@11.14.0_@types_react@19.2._dc2be6bc014bebdac88a574e3e02c144/node_modules/@mui/icons-material/esm/WarningAmberRounded.js.map +1 -0
- package/dist/node_modules/.pnpm/jsbarcode@3.12.1/node_modules/jsbarcode/bin/barcodes/CODE128/constants.js +1 -1
- package/dist/node_modules/.pnpm/jsbarcode@3.12.1/node_modules/jsbarcode/bin/barcodes/CODE128/index.js +1 -1
- package/dist/node_modules/.pnpm/jsbarcode@3.12.1/node_modules/jsbarcode/bin/barcodes/CODE39/index.js +1 -1
- package/dist/node_modules/.pnpm/jsbarcode@3.12.1/node_modules/jsbarcode/bin/barcodes/CODE93/index.js +1 -1
- package/dist/node_modules/.pnpm/jsbarcode@3.12.1/node_modules/jsbarcode/bin/barcodes/EAN_UPC/index.js +1 -1
- package/dist/node_modules/.pnpm/jsbarcode@3.12.1/node_modules/jsbarcode/bin/barcodes/GenericBarcode/index.js +1 -1
- package/dist/node_modules/.pnpm/jsbarcode@3.12.1/node_modules/jsbarcode/bin/barcodes/ITF/constants.js +1 -1
- package/dist/node_modules/.pnpm/jsbarcode@3.12.1/node_modules/jsbarcode/bin/barcodes/ITF/index.js +1 -1
- package/dist/node_modules/.pnpm/jsbarcode@3.12.1/node_modules/jsbarcode/bin/barcodes/MSI/index.js +1 -1
- package/dist/node_modules/.pnpm/jsbarcode@3.12.1/node_modules/jsbarcode/bin/barcodes/codabar/index.js +1 -1
- package/dist/node_modules/.pnpm/jsbarcode@3.12.1/node_modules/jsbarcode/bin/barcodes/pharmacode/index.js +1 -1
- package/dist/node_modules/.pnpm/jsbarcode@3.12.1/node_modules/jsbarcode/bin/renderers/index.js +1 -1
- package/dist/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/index.js +1 -1
- package/dist/node_modules/.pnpm/react-overlays@5.2.1_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/react-overlays/esm/Portal.js +1 -1
- package/dist/owp-app.css +1 -1
- package/dist/types/components/OwpTable/internal/defaultTableStyle.d.ts +49 -0
- package/dist/types/components/OwpTreeGrid/OwpTreeGrid.d.ts +2 -1
- package/dist/types/components/OwpTreeGrid/internal/treeGridRuntime.d.ts +6 -1
- package/dist/types/contexts/OwpAppProvider.d.ts +2 -0
- package/dist/types/features/themePreview/components/ThemePreviewCanvas.d.ts +8 -0
- package/dist/types/features/themePreview/components/ThemePreviewCanvasSections.d.ts +82 -0
- package/dist/types/features/themePreview/components/ThemePreviewColorField.d.ts +10 -0
- package/dist/types/features/themePreview/components/ThemePreviewControls.d.ts +18 -0
- package/dist/types/features/themePreview/components/index.d.ts +3 -0
- package/dist/types/features/themePreview/components/themePreviewCanvas.icons.d.ts +3 -0
- package/dist/types/features/themePreview/components/themePreviewCanvas.shared.d.ts +121 -0
- package/dist/types/features/themePreview/configs/grid.d.ts +41 -0
- package/dist/types/features/themePreview/configs/index.d.ts +7 -0
- package/dist/types/features/themePreview/configs/presets.d.ts +1153 -0
- package/dist/types/features/themePreview/configs/previewStorage.d.ts +34 -0
- package/dist/types/features/themePreview/configs/settings.d.ts +271 -0
- package/dist/types/features/themePreview/configs/snackbar.d.ts +43 -0
- package/dist/types/features/themePreview/configs/surface.d.ts +6 -0
- package/dist/types/features/themePreview/configs/table.d.ts +47 -0
- package/dist/types/features/themePreview/dialogs/ThemePreviewDialog.d.ts +3 -0
- package/dist/types/features/themePreview/dialogs/index.d.ts +1 -0
- package/dist/types/features/themePreview/hooks/index.d.ts +1 -0
- package/dist/types/features/themePreview/hooks/useThemePreview.d.ts +60 -0
- package/dist/types/features/themePreview/index.d.ts +6 -0
- package/dist/types/features/themePreview/types/index.d.ts +1 -0
- package/dist/types/features/themePreview/types/themePreview.d.ts +44 -0
- package/dist/types/features/themePreview/utils/color.d.ts +14 -0
- package/dist/types/features/themePreview/utils/index.d.ts +4 -0
- package/dist/types/features/themePreview/utils/themePreviewDefinitions.d.ts +10 -0
- package/dist/types/features/themePreview/utils/themePreviewExport.d.ts +1091 -0
- package/dist/types/features/themePreview/utils/themePreviewSettings.d.ts +54 -0
- package/dist/types/layout/components/toggles/ThemePreviewToggle.d.ts +5 -0
- package/features/themePreview.d.ts +3 -0
- package/features/themePreview.js +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
var E = Object.defineProperty;
|
|
2
|
+
var o = (e, t) => E(e, "name", { value: t, configurable: !0 });
|
|
3
|
+
import { toolbarCuratedPresetKeys as _ } from "../configs/presets.js";
|
|
4
|
+
import { defaultSnackbarTheme as d, defaultSnackbarProviderProps as k } from "../configs/snackbar.js";
|
|
5
|
+
import { merge as l } from "../../../node_modules/.pnpm/es-toolkit@1.39.10/node_modules/es-toolkit/dist/compat/object/merge.js";
|
|
6
|
+
import { isString as N } from "../../../node_modules/.pnpm/es-toolkit@1.39.10/node_modules/es-toolkit/dist/compat/predicate/isString.js";
|
|
7
|
+
import { isObject as h } from "../../../node_modules/.pnpm/es-toolkit@1.39.10/node_modules/es-toolkit/dist/compat/predicate/isObject.js";
|
|
8
|
+
const j = "__custom__", V = ["grid", "table", "snackbar"];
|
|
9
|
+
let v = null, S = null;
|
|
10
|
+
const b = "snackbarProviderProps.";
|
|
11
|
+
function u(e) {
|
|
12
|
+
return h(e) ? e : {};
|
|
13
|
+
}
|
|
14
|
+
o(u, "asObjectRecord");
|
|
15
|
+
function I(e, t = d) {
|
|
16
|
+
const a = "snackbar" in e && h(e.snackbar) ? e.snackbar : void 0;
|
|
17
|
+
return l({}, d, t, a);
|
|
18
|
+
}
|
|
19
|
+
o(I, "getThemePreviewSnackbarTheme");
|
|
20
|
+
function R(e, t = k) {
|
|
21
|
+
const a = "snackbarProviderProps" in e && h(e.snackbarProviderProps) ? e.snackbarProviderProps : void 0;
|
|
22
|
+
return l(
|
|
23
|
+
{},
|
|
24
|
+
k,
|
|
25
|
+
t,
|
|
26
|
+
a
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
o(R, "getThemePreviewSnackbarProviderProps");
|
|
30
|
+
function T(e, t = d) {
|
|
31
|
+
return l({}, e, {
|
|
32
|
+
snackbar: I(e, t),
|
|
33
|
+
snackbarProviderProps: R(e)
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
o(T, "createThemePreviewSettings");
|
|
37
|
+
function A(e) {
|
|
38
|
+
return V.includes(e);
|
|
39
|
+
}
|
|
40
|
+
o(A, "isThemePreviewCustomSection");
|
|
41
|
+
function p(e, t) {
|
|
42
|
+
switch (t) {
|
|
43
|
+
case "grid":
|
|
44
|
+
return u(e.theme.main.grid);
|
|
45
|
+
case "table":
|
|
46
|
+
return u(e.theme.main.table);
|
|
47
|
+
case "snackbar":
|
|
48
|
+
return u(e.snackbar);
|
|
49
|
+
default:
|
|
50
|
+
return u(e.theme[t].palette);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
o(p, "getThemePreviewSectionTarget");
|
|
54
|
+
function w(e) {
|
|
55
|
+
return T(e);
|
|
56
|
+
}
|
|
57
|
+
o(w, "cloneThemePreviewSettings");
|
|
58
|
+
function H(e, t, a = d) {
|
|
59
|
+
return l({}, T(e, a), {
|
|
60
|
+
theme: t
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
o(H, "getThemePreviewResetSettings");
|
|
64
|
+
function O(e, t, a) {
|
|
65
|
+
const [r, i] = a.startsWith(b) ? [u(e.snackbarProviderProps), a.slice(b.length)] : [p(e, t), a], n = i.split(".").reduce((c, s) => u(c)[s], r);
|
|
66
|
+
return typeof n == "number" ? String(n) : N(n) ? n : "";
|
|
67
|
+
}
|
|
68
|
+
o(O, "getThemePreviewPaletteValue");
|
|
69
|
+
function f(e, t) {
|
|
70
|
+
return e.theme[t].palette.mode === "dark" ? "dark" : "light";
|
|
71
|
+
}
|
|
72
|
+
o(f, "getThemePreviewSectionMode");
|
|
73
|
+
function F(e) {
|
|
74
|
+
return T(v ?? e);
|
|
75
|
+
}
|
|
76
|
+
o(F, "getThemePreviewDraftSettings");
|
|
77
|
+
function U(e) {
|
|
78
|
+
v = w(e);
|
|
79
|
+
}
|
|
80
|
+
o(U, "setThemePreviewDraftSettings");
|
|
81
|
+
function X(e, t) {
|
|
82
|
+
return l(
|
|
83
|
+
{
|
|
84
|
+
selectedPresetKeys: t,
|
|
85
|
+
selectedModes: {
|
|
86
|
+
main: f(e, "main"),
|
|
87
|
+
navbar: f(e, "navbar"),
|
|
88
|
+
toolbar: f(e, "toolbar")
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
S ?? {}
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
o(X, "getThemePreviewSelectionState");
|
|
95
|
+
function Y(e) {
|
|
96
|
+
S = l({}, e);
|
|
97
|
+
}
|
|
98
|
+
o(Y, "setThemePreviewSelectionState");
|
|
99
|
+
function $() {
|
|
100
|
+
v = null, S = null;
|
|
101
|
+
}
|
|
102
|
+
o($, "resetThemePreviewSessionState");
|
|
103
|
+
function x(e, t, a) {
|
|
104
|
+
const r = t.split("."), i = r.pop();
|
|
105
|
+
if (!i)
|
|
106
|
+
return;
|
|
107
|
+
let n = e;
|
|
108
|
+
r.forEach((s) => {
|
|
109
|
+
const P = n[s];
|
|
110
|
+
h(P) || (n[s] = {}), n = u(n[s]);
|
|
111
|
+
});
|
|
112
|
+
const c = n[i];
|
|
113
|
+
if (typeof c == "number") {
|
|
114
|
+
const s = Number(a.replace(/,/g, "."));
|
|
115
|
+
n[i] = Number.isNaN(s) ? c : s;
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
n[i] = a;
|
|
119
|
+
}
|
|
120
|
+
o(x, "applyThemePreviewPaletteValue");
|
|
121
|
+
function y(e, t, a) {
|
|
122
|
+
if (!a.length)
|
|
123
|
+
return e;
|
|
124
|
+
const r = w(e), i = p(r, t), n = u(r.snackbarProviderProps);
|
|
125
|
+
switch (a.forEach(({ path: c, value: s }) => {
|
|
126
|
+
const P = c.startsWith(
|
|
127
|
+
b
|
|
128
|
+
), m = P ? c.slice(b.length) : c;
|
|
129
|
+
x(
|
|
130
|
+
P ? n : i,
|
|
131
|
+
m,
|
|
132
|
+
s
|
|
133
|
+
);
|
|
134
|
+
}), r.snackbarProviderProps = n, t) {
|
|
135
|
+
case "grid":
|
|
136
|
+
return r.theme.main.grid = i, r;
|
|
137
|
+
case "table":
|
|
138
|
+
return r.theme.main.table = i, r;
|
|
139
|
+
case "snackbar":
|
|
140
|
+
return r.snackbar = i, r;
|
|
141
|
+
default:
|
|
142
|
+
return r.theme[t].palette = i, r;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
o(y, "setThemePreviewPaletteValues");
|
|
146
|
+
function q(e, t, a, r) {
|
|
147
|
+
return y(e, t, [{ path: a, value: r }]);
|
|
148
|
+
}
|
|
149
|
+
o(q, "setThemePreviewPaletteValue");
|
|
150
|
+
function z(e) {
|
|
151
|
+
const t = /^(light|dark)(\d+)$/, a = new Set(_);
|
|
152
|
+
return Object.entries(e).reduce((r, [i, n]) => (n != null && n.palette && r.push({
|
|
153
|
+
key: i,
|
|
154
|
+
label: i,
|
|
155
|
+
mode: n.palette.mode === "dark" ? "dark" : "light",
|
|
156
|
+
sections: a.has(i) ? ["toolbar"] : void 0,
|
|
157
|
+
originalIndex: r.length
|
|
158
|
+
}), r), []).sort((r, i) => {
|
|
159
|
+
const n = r.key.match(t), c = i.key.match(t), s = !!n;
|
|
160
|
+
if (s !== !!c)
|
|
161
|
+
return s ? 1 : -1;
|
|
162
|
+
if (n && c) {
|
|
163
|
+
const m = (n[1] === "light" ? 0 : 1) - (c[1] === "light" ? 0 : 1);
|
|
164
|
+
if (m !== 0)
|
|
165
|
+
return m;
|
|
166
|
+
const g = Number(n[2]) - Number(c[2]);
|
|
167
|
+
if (g !== 0)
|
|
168
|
+
return g;
|
|
169
|
+
}
|
|
170
|
+
return r.originalIndex - i.originalIndex;
|
|
171
|
+
}).map((r) => ({
|
|
172
|
+
key: r.key,
|
|
173
|
+
label: r.label,
|
|
174
|
+
mode: r.mode,
|
|
175
|
+
sections: r.sections
|
|
176
|
+
}));
|
|
177
|
+
}
|
|
178
|
+
o(z, "getThemePreviewPresetOptions");
|
|
179
|
+
function G(e, t, a) {
|
|
180
|
+
return e.filter(
|
|
181
|
+
(r) => r.mode === a && (!r.sections || r.sections.includes(t))
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
o(G, "getThemePreviewPresetOptionsByMode");
|
|
185
|
+
function J(e, t, a) {
|
|
186
|
+
return l({}, e, {
|
|
187
|
+
theme: {
|
|
188
|
+
[t]: a
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
o(J, "applyThemePreviewPreset");
|
|
193
|
+
export {
|
|
194
|
+
j as THEME_PREVIEW_CUSTOM_PRESET_KEY,
|
|
195
|
+
J as applyThemePreviewPreset,
|
|
196
|
+
w as cloneThemePreviewSettings,
|
|
197
|
+
F as getThemePreviewDraftSettings,
|
|
198
|
+
O as getThemePreviewPaletteValue,
|
|
199
|
+
z as getThemePreviewPresetOptions,
|
|
200
|
+
G as getThemePreviewPresetOptionsByMode,
|
|
201
|
+
H as getThemePreviewResetSettings,
|
|
202
|
+
f as getThemePreviewSectionMode,
|
|
203
|
+
X as getThemePreviewSelectionState,
|
|
204
|
+
A as isThemePreviewCustomSection,
|
|
205
|
+
$ as resetThemePreviewSessionState,
|
|
206
|
+
U as setThemePreviewDraftSettings,
|
|
207
|
+
q as setThemePreviewPaletteValue,
|
|
208
|
+
y as setThemePreviewPaletteValues,
|
|
209
|
+
Y as setThemePreviewSelectionState
|
|
210
|
+
};
|
|
211
|
+
//# sourceMappingURL=themePreviewSettings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"themePreviewSettings.js","sources":["../../../../src/features/themePreview/utils/themePreviewSettings.ts"],"sourcesContent":["import { toolbarCuratedPresetKeys } from '@/features/themePreview/configs/presets';\nimport {\n defaultSnackbarProviderProps,\n defaultSnackbarTheme,\n type SnackbarProviderTheme,\n type SnackbarTheme,\n} from '@/features/themePreview/configs/snackbar';\nimport type { OwpSettingsConfigType } from '@/types';\nimport { isObject, isString, merge } from 'es-toolkit/compat';\nimport type { PartialDeep } from 'type-fest';\nimport type {\n ThemePreviewMode,\n ThemePreviewPresetKeyBySection,\n ThemePreviewPresetOption,\n ThemePreviewPresetSectionKey,\n ThemePreviewPresetThemes,\n ThemePreviewSectionKey,\n ThemePreviewSettings,\n} from '../types';\n\nexport const THEME_PREVIEW_CUSTOM_PRESET_KEY = '__custom__';\nconst themePreviewCustomSectionKeys = ['grid', 'table', 'snackbar'] as const;\n\ntype ThemePreviewSelectionState = {\n selectedModes: Record<ThemePreviewPresetSectionKey, ThemePreviewMode>;\n selectedPresetKeys: ThemePreviewPresetKeyBySection;\n};\n\nlet persistedThemePreviewDraftSettings: ThemePreviewSettings | null = null;\nlet persistedThemePreviewSelectionState: ThemePreviewSelectionState | null = null;\nconst THEME_PREVIEW_SNACKBAR_PROVIDER_PROPS_PATH_PREFIX = 'snackbarProviderProps.';\ntype ThemePreviewPaletteValueUpdate = {\n path: string;\n value: string;\n};\n\nfunction asObjectRecord(value: unknown) {\n return isObject(value) ? (value as Record<string, unknown>) : {};\n}\n\nfunction getThemePreviewSnackbarTheme(\n settings: OwpSettingsConfigType | ThemePreviewSettings,\n snackbar = defaultSnackbarTheme,\n) {\n const nextSnackbar =\n 'snackbar' in settings && isObject(settings.snackbar) ? settings.snackbar : undefined;\n\n return merge({}, defaultSnackbarTheme, snackbar, nextSnackbar) as SnackbarTheme;\n}\n\nfunction getThemePreviewSnackbarProviderProps(\n settings: OwpSettingsConfigType | ThemePreviewSettings,\n snackbarProviderProps = defaultSnackbarProviderProps,\n) {\n const nextSnackbarProviderProps =\n 'snackbarProviderProps' in settings && isObject(settings.snackbarProviderProps)\n ? settings.snackbarProviderProps\n : undefined;\n\n return merge(\n {},\n defaultSnackbarProviderProps,\n snackbarProviderProps,\n nextSnackbarProviderProps,\n ) as SnackbarProviderTheme;\n}\n\nfunction createThemePreviewSettings(\n settings: OwpSettingsConfigType | ThemePreviewSettings,\n snackbar = defaultSnackbarTheme,\n) {\n return merge({}, settings, {\n snackbar: getThemePreviewSnackbarTheme(settings, snackbar),\n snackbarProviderProps: getThemePreviewSnackbarProviderProps(settings),\n }) as ThemePreviewSettings;\n}\n\nexport function isThemePreviewCustomSection(sectionKey: ThemePreviewSectionKey) {\n return (themePreviewCustomSectionKeys as readonly ThemePreviewSectionKey[]).includes(sectionKey);\n}\n\nfunction getThemePreviewSectionTarget(\n settings: ThemePreviewSettings,\n sectionKey: ThemePreviewSectionKey,\n) {\n switch (sectionKey) {\n case 'grid':\n return asObjectRecord(settings.theme.main.grid);\n case 'table':\n return asObjectRecord(settings.theme.main.table);\n case 'snackbar':\n return asObjectRecord(settings.snackbar);\n default:\n return asObjectRecord(settings.theme[sectionKey].palette);\n }\n}\n\nexport function cloneThemePreviewSettings(settings: ThemePreviewSettings) {\n return createThemePreviewSettings(settings);\n}\n\nexport function getThemePreviewResetSettings(\n settings: OwpSettingsConfigType,\n resetTheme: PartialDeep<OwpSettingsConfigType['theme']>,\n snackbar = defaultSnackbarTheme,\n) {\n return merge({}, createThemePreviewSettings(settings, snackbar), {\n theme: resetTheme,\n }) as ThemePreviewSettings;\n}\n\nexport function getThemePreviewPaletteValue(\n settings: ThemePreviewSettings,\n sectionKey: ThemePreviewSectionKey,\n path: string,\n) {\n const [pathSource, resolvedPath] = path.startsWith(THEME_PREVIEW_SNACKBAR_PROVIDER_PROPS_PATH_PREFIX)\n ? [asObjectRecord(settings.snackbarProviderProps), path.slice(THEME_PREVIEW_SNACKBAR_PROVIDER_PROPS_PATH_PREFIX.length)]\n : [getThemePreviewSectionTarget(settings, sectionKey), path];\n\n const value = resolvedPath.split('.').reduce<unknown>((acc, key) => {\n const currentValue = asObjectRecord(acc);\n\n return currentValue[key];\n }, pathSource);\n\n if (typeof value === 'number') {\n return String(value);\n }\n\n return isString(value) ? value : '';\n}\n\nexport function getThemePreviewSectionMode(\n settings: OwpSettingsConfigType,\n sectionKey: ThemePreviewPresetSectionKey,\n) {\n return settings.theme[sectionKey].palette.mode === 'dark' ? 'dark' : 'light';\n}\n\nexport function getThemePreviewDraftSettings(currentSettings: OwpSettingsConfigType) {\n return createThemePreviewSettings(persistedThemePreviewDraftSettings ?? currentSettings);\n}\n\nexport function setThemePreviewDraftSettings(settings: ThemePreviewSettings) {\n persistedThemePreviewDraftSettings = cloneThemePreviewSettings(settings);\n}\n\nexport function getThemePreviewSelectionState(\n settings: OwpSettingsConfigType,\n initialPresetKeys: ThemePreviewPresetKeyBySection,\n) {\n return merge(\n {\n selectedPresetKeys: initialPresetKeys,\n selectedModes: {\n main: getThemePreviewSectionMode(settings, 'main'),\n navbar: getThemePreviewSectionMode(settings, 'navbar'),\n toolbar: getThemePreviewSectionMode(settings, 'toolbar'),\n },\n },\n persistedThemePreviewSelectionState ?? {},\n ) as ThemePreviewSelectionState;\n}\n\nexport function setThemePreviewSelectionState(selectionState: ThemePreviewSelectionState) {\n persistedThemePreviewSelectionState = merge({}, selectionState) as ThemePreviewSelectionState;\n}\n\nexport function resetThemePreviewSessionState() {\n persistedThemePreviewDraftSettings = null;\n persistedThemePreviewSelectionState = null;\n}\n\nfunction applyThemePreviewPaletteValue(\n target: Record<string, unknown>,\n path: string,\n value: string,\n) {\n const pathKeys = path.split('.');\n const lastPathKey = pathKeys.pop();\n\n if (!lastPathKey) {\n return;\n }\n\n let currentTarget = target;\n\n pathKeys.forEach((key) => {\n const nextTarget = currentTarget[key];\n\n if (!isObject(nextTarget)) {\n currentTarget[key] = {};\n }\n\n currentTarget = asObjectRecord(currentTarget[key]);\n });\n\n const currentValue = currentTarget[lastPathKey];\n\n if (typeof currentValue === 'number') {\n const nextNumericValue = Number(value.replace(/,/g, '.'));\n currentTarget[lastPathKey] = Number.isNaN(nextNumericValue) ? currentValue : nextNumericValue;\n return;\n }\n\n currentTarget[lastPathKey] = value;\n}\n\nexport function setThemePreviewPaletteValues(\n settings: ThemePreviewSettings,\n sectionKey: ThemePreviewSectionKey,\n updates: ThemePreviewPaletteValueUpdate[],\n) {\n if (!updates.length) {\n return settings;\n }\n\n const nextSettings = cloneThemePreviewSettings(settings);\n const sectionTarget = getThemePreviewSectionTarget(nextSettings, sectionKey);\n const snackbarProviderPropsTarget = asObjectRecord(nextSettings.snackbarProviderProps);\n\n updates.forEach(({ path, value }) => {\n const isSnackbarProviderPropsPath = path.startsWith(\n THEME_PREVIEW_SNACKBAR_PROVIDER_PROPS_PATH_PREFIX,\n );\n const resolvedPath = isSnackbarProviderPropsPath\n ? path.slice(THEME_PREVIEW_SNACKBAR_PROVIDER_PROPS_PATH_PREFIX.length)\n : path;\n\n applyThemePreviewPaletteValue(\n isSnackbarProviderPropsPath ? snackbarProviderPropsTarget : sectionTarget,\n resolvedPath,\n value,\n );\n });\n\n nextSettings.snackbarProviderProps = snackbarProviderPropsTarget as SnackbarProviderTheme;\n\n switch (sectionKey) {\n case 'grid':\n nextSettings.theme.main.grid =\n sectionTarget as OwpSettingsConfigType['theme']['main']['grid'];\n return nextSettings;\n case 'table':\n nextSettings.theme.main.table =\n sectionTarget as OwpSettingsConfigType['theme']['main']['table'];\n return nextSettings;\n case 'snackbar':\n nextSettings.snackbar = sectionTarget as SnackbarTheme;\n return nextSettings;\n default:\n nextSettings.theme[sectionKey].palette = sectionTarget;\n return nextSettings;\n }\n}\n\nexport function setThemePreviewPaletteValue(\n settings: ThemePreviewSettings,\n sectionKey: ThemePreviewSectionKey,\n path: string,\n value: string,\n) {\n return setThemePreviewPaletteValues(settings, sectionKey, [{ path, value }]);\n}\n\nexport function getThemePreviewPresetOptions(presetThemes: ThemePreviewPresetThemes) {\n const numberedPresetPattern = /^(light|dark)(\\d+)$/;\n const toolbarCuratedPresetKeySet = new Set<string>(toolbarCuratedPresetKeys);\n\n return Object.entries(presetThemes)\n .reduce<Array<ThemePreviewPresetOption & { originalIndex: number }>>((acc, [key, theme]) => {\n if (!theme?.palette) {\n return acc;\n }\n\n acc.push({\n key,\n label: key,\n mode: theme.palette.mode === 'dark' ? 'dark' : 'light',\n sections: toolbarCuratedPresetKeySet.has(key) ? ['toolbar'] : undefined,\n originalIndex: acc.length,\n });\n\n return acc;\n }, [])\n .sort((leftOption, rightOption) => {\n const leftMatch = leftOption.key.match(numberedPresetPattern);\n const rightMatch = rightOption.key.match(numberedPresetPattern);\n const leftIsNumberedPreset = Boolean(leftMatch);\n const rightIsNumberedPreset = Boolean(rightMatch);\n\n if (leftIsNumberedPreset !== rightIsNumberedPreset) {\n return leftIsNumberedPreset ? 1 : -1;\n }\n\n if (leftMatch && rightMatch) {\n const familyOrder =\n (leftMatch[1] === 'light' ? 0 : 1) - (rightMatch[1] === 'light' ? 0 : 1);\n\n if (familyOrder !== 0) {\n return familyOrder;\n }\n\n const presetNumberOrder = Number(leftMatch[2]) - Number(rightMatch[2]);\n\n if (presetNumberOrder !== 0) {\n return presetNumberOrder;\n }\n }\n\n return leftOption.originalIndex - rightOption.originalIndex;\n })\n .map((presetOption) => ({\n key: presetOption.key,\n label: presetOption.label,\n mode: presetOption.mode,\n sections: presetOption.sections,\n }));\n}\n\nexport function getThemePreviewPresetOptionsByMode(\n presetOptions: ThemePreviewPresetOption[],\n sectionKey: ThemePreviewPresetSectionKey,\n mode: 'light' | 'dark',\n) {\n return presetOptions.filter(\n (presetOption) =>\n presetOption.mode === mode &&\n (!presetOption.sections || presetOption.sections.includes(sectionKey)),\n );\n}\n\nexport function applyThemePreviewPreset(\n settings: ThemePreviewSettings,\n sectionKey: ThemePreviewPresetSectionKey,\n presetTheme: ThemePreviewPresetThemes[string],\n) {\n return merge({}, settings, {\n theme: {\n [sectionKey]: presetTheme,\n },\n }) as ThemePreviewSettings;\n}\n"],"names":["THEME_PREVIEW_CUSTOM_PRESET_KEY","themePreviewCustomSectionKeys","persistedThemePreviewDraftSettings","persistedThemePreviewSelectionState","THEME_PREVIEW_SNACKBAR_PROVIDER_PROPS_PATH_PREFIX","asObjectRecord","value","isObject","__name","getThemePreviewSnackbarTheme","settings","snackbar","defaultSnackbarTheme","nextSnackbar","merge","getThemePreviewSnackbarProviderProps","snackbarProviderProps","defaultSnackbarProviderProps","nextSnackbarProviderProps","createThemePreviewSettings","isThemePreviewCustomSection","sectionKey","getThemePreviewSectionTarget","cloneThemePreviewSettings","getThemePreviewResetSettings","resetTheme","getThemePreviewPaletteValue","path","pathSource","resolvedPath","acc","key","isString","getThemePreviewSectionMode","getThemePreviewDraftSettings","currentSettings","setThemePreviewDraftSettings","getThemePreviewSelectionState","initialPresetKeys","setThemePreviewSelectionState","selectionState","resetThemePreviewSessionState","applyThemePreviewPaletteValue","target","pathKeys","lastPathKey","currentTarget","nextTarget","currentValue","nextNumericValue","setThemePreviewPaletteValues","updates","nextSettings","sectionTarget","snackbarProviderPropsTarget","isSnackbarProviderPropsPath","setThemePreviewPaletteValue","getThemePreviewPresetOptions","presetThemes","numberedPresetPattern","toolbarCuratedPresetKeySet","toolbarCuratedPresetKeys","theme","leftOption","rightOption","leftMatch","rightMatch","leftIsNumberedPreset","familyOrder","presetNumberOrder","presetOption","getThemePreviewPresetOptionsByMode","presetOptions","mode","applyThemePreviewPreset","presetTheme"],"mappings":";;;;;;;AAoBO,MAAMA,IAAkC,cACzCC,IAAgC,CAAC,QAAQ,SAAS,UAAU;AAOlE,IAAIC,IAAkE,MAClEC,IAAyE;AAC7E,MAAMC,IAAoD;AAM1D,SAASC,EAAeC,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IAAI,MAAMC,EAAW,CAAC,MAAM,UAAU,IAAI;AAExE,UAAIE,MAAgB;AAClB,eAAOA;AAGT,YAAMC,IAAoB,OAAOJ,EAAU,CAAC,CAAC,IAAI,OAAOC,EAAW,CAAC,CAAC;AAErE,UAAIG,MAAsB;AACxB,eAAOA;AAAA,IAEX;AAEA,WAAON,EAAW,gBAAgBC,EAAY;AAAA,EAChD,CAAC,EACA,IAAI,CAACM,OAAkB;AAAA,IACtB,KAAKA,EAAa;AAAA,IAClB,OAAOA,EAAa;AAAA,IACpB,MAAMA,EAAa;AAAA,IACnB,UAAUA,EAAa;AAAA,EAAA,EACvB;AACN;AArDgB9D,EAAAiD,GAAA;AAuDT,SAASc,EACdC,GACAnD,GACAoD,GACA;AACA,SAAOD,EAAc;AAAA,IACnB,CAACF,MACCA,EAAa,SAASG,MACrB,CAACH,EAAa,YAAYA,EAAa,SAAS,SAASjD,CAAU;AAAA,EAAA;AAE1E;AAVgBb,EAAA+D,GAAA;AAYT,SAASG,EACdhE,GACAW,GACAsD,GACA;AACA,SAAO7D,EAAM,CAAA,GAAIJ,GAAU;AAAA,IACzB,OAAO;AAAA,MACL,CAACW,CAAU,GAAGsD;AAAA,IAAA;AAAA,EAChB,CACD;AACH;AAVgBnE,EAAAkE,GAAA;"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { defaultGridTheme as r } from "./themePreview/configs/grid.js";
|
|
2
|
+
import { darkPaletteText as a, defaultNavbarDivider as i, defaultNavbarSecondaryPalette as m, defaultPrimaryPalette as l, defaultSecondaryPalette as P, defaultToolbarDivider as s, defaultToolbarSecondaryPalette as T, designSystemPresetKeys as v, legacyPresetCleanupCandidateKeys as p, lightPaletteText as h, themePreviewPresetContractKeys as n, themesConfig as f, toolbarCuratedPresetKeys as d } from "./themePreview/configs/presets.js";
|
|
3
|
+
import { clearThemePreviewAppliedSettings as S, clearThemePreviewTemporaryState as g, getResolvedThemePreviewSettingsConfig as u, getThemePreviewAppliedSettings as c, getThemePreviewTemporaryState as x, persistThemePreviewAppliedSettings as y, persistThemePreviewTemporaryState as C } from "./themePreview/configs/previewStorage.js";
|
|
4
|
+
import { defaultSettingsConfig as V } from "./themePreview/configs/settings.js";
|
|
5
|
+
import { defaultSnackbarProviderProps as D, defaultSnackbarTheme as k, snackbarVariantKeys as K } from "./themePreview/configs/snackbar.js";
|
|
6
|
+
import { defaultLayoutSurface as M } from "./themePreview/configs/surface.js";
|
|
7
|
+
import { defaultTableTheme as R } from "./themePreview/configs/table.js";
|
|
8
|
+
import { ThemePreviewCanvas as G } from "./themePreview/components/ThemePreviewCanvas.js";
|
|
9
|
+
import { ThemePreviewColorField as F } from "./themePreview/components/ThemePreviewColorField.js";
|
|
10
|
+
import { ThemePreviewControls as H } from "./themePreview/components/ThemePreviewControls.js";
|
|
11
|
+
import { ThemePreviewDialog as L } from "./themePreview/dialogs/ThemePreviewDialog.js";
|
|
12
|
+
import { useThemePreview as W } from "./themePreview/hooks/useThemePreview.js";
|
|
13
|
+
import { applyColorPickerValue as j, canDeriveThemePreviewColor as q, deriveThemePreviewPaletteGroupValues as z, getColorAlphaValue as J, toColorPickerValue as Q } from "./themePreview/utils/color.js";
|
|
14
|
+
import { createThemePreviewExportData as Z } from "./themePreview/utils/themePreviewExport.js";
|
|
15
|
+
import { themePreviewFieldGroupsBySection as ee, themePreviewSectionOptions as te } from "./themePreview/utils/themePreviewDefinitions.js";
|
|
16
|
+
import { THEME_PREVIEW_CUSTOM_PRESET_KEY as oe, applyThemePreviewPreset as ae, cloneThemePreviewSettings as ie, getThemePreviewDraftSettings as me, getThemePreviewPaletteValue as le, getThemePreviewPresetOptions as Pe, getThemePreviewPresetOptionsByMode as se, getThemePreviewResetSettings as Te, getThemePreviewSectionMode as ve, getThemePreviewSelectionState as pe, isThemePreviewCustomSection as he, resetThemePreviewSessionState as ne, setThemePreviewDraftSettings as fe, setThemePreviewPaletteValue as de, setThemePreviewPaletteValues as we, setThemePreviewSelectionState as Se } from "./themePreview/utils/themePreviewSettings.js";
|
|
17
|
+
export {
|
|
18
|
+
oe as THEME_PREVIEW_CUSTOM_PRESET_KEY,
|
|
19
|
+
G as ThemePreviewCanvas,
|
|
20
|
+
F as ThemePreviewColorField,
|
|
21
|
+
H as ThemePreviewControls,
|
|
22
|
+
L as ThemePreviewDialog,
|
|
23
|
+
j as applyColorPickerValue,
|
|
24
|
+
ae as applyThemePreviewPreset,
|
|
25
|
+
q as canDeriveThemePreviewColor,
|
|
26
|
+
S as clearThemePreviewAppliedSettings,
|
|
27
|
+
g as clearThemePreviewTemporaryState,
|
|
28
|
+
ie as cloneThemePreviewSettings,
|
|
29
|
+
Z as createThemePreviewExportData,
|
|
30
|
+
a as darkPaletteText,
|
|
31
|
+
r as defaultGridTheme,
|
|
32
|
+
M as defaultLayoutSurface,
|
|
33
|
+
i as defaultNavbarDivider,
|
|
34
|
+
m as defaultNavbarSecondaryPalette,
|
|
35
|
+
l as defaultPrimaryPalette,
|
|
36
|
+
P as defaultSecondaryPalette,
|
|
37
|
+
V as defaultSettingsConfig,
|
|
38
|
+
D as defaultSnackbarProviderProps,
|
|
39
|
+
k as defaultSnackbarTheme,
|
|
40
|
+
R as defaultTableTheme,
|
|
41
|
+
s as defaultToolbarDivider,
|
|
42
|
+
T as defaultToolbarSecondaryPalette,
|
|
43
|
+
z as deriveThemePreviewPaletteGroupValues,
|
|
44
|
+
v as designSystemPresetKeys,
|
|
45
|
+
J as getColorAlphaValue,
|
|
46
|
+
u as getResolvedThemePreviewSettingsConfig,
|
|
47
|
+
c as getThemePreviewAppliedSettings,
|
|
48
|
+
me as getThemePreviewDraftSettings,
|
|
49
|
+
le as getThemePreviewPaletteValue,
|
|
50
|
+
Pe as getThemePreviewPresetOptions,
|
|
51
|
+
se as getThemePreviewPresetOptionsByMode,
|
|
52
|
+
Te as getThemePreviewResetSettings,
|
|
53
|
+
ve as getThemePreviewSectionMode,
|
|
54
|
+
pe as getThemePreviewSelectionState,
|
|
55
|
+
x as getThemePreviewTemporaryState,
|
|
56
|
+
he as isThemePreviewCustomSection,
|
|
57
|
+
p as legacyPresetCleanupCandidateKeys,
|
|
58
|
+
h as lightPaletteText,
|
|
59
|
+
y as persistThemePreviewAppliedSettings,
|
|
60
|
+
C as persistThemePreviewTemporaryState,
|
|
61
|
+
ne as resetThemePreviewSessionState,
|
|
62
|
+
fe as setThemePreviewDraftSettings,
|
|
63
|
+
de as setThemePreviewPaletteValue,
|
|
64
|
+
we as setThemePreviewPaletteValues,
|
|
65
|
+
Se as setThemePreviewSelectionState,
|
|
66
|
+
K as snackbarVariantKeys,
|
|
67
|
+
ee as themePreviewFieldGroupsBySection,
|
|
68
|
+
n as themePreviewPresetContractKeys,
|
|
69
|
+
te as themePreviewSectionOptions,
|
|
70
|
+
f as themesConfig,
|
|
71
|
+
Q as toColorPickerValue,
|
|
72
|
+
d as toolbarCuratedPresetKeys,
|
|
73
|
+
W as useThemePreview
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=themePreview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"themePreview.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
import { jsx as e, jsxs as
|
|
4
|
-
import { useOwpAppContext as
|
|
5
|
-
import { useGetLogoSrc as
|
|
6
|
-
import { Skeleton as
|
|
7
|
-
import { styled as
|
|
8
|
-
import { useRef as I, useState as
|
|
9
|
-
const
|
|
1
|
+
var A = Object.defineProperty;
|
|
2
|
+
var m = (t, r) => A(t, "name", { value: r, configurable: !0 });
|
|
3
|
+
import { jsx as e, jsxs as O } from "../../../node_modules/.pnpm/@emotion_react@11.14.0_@types_react@19.2.14_react@19.2.4/node_modules/@emotion/react/jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js";
|
|
4
|
+
import { useOwpAppContext as k } from "../../../contexts/OwpAppProvider.js";
|
|
5
|
+
import { useGetLogoSrc as z } from "../../../hooks/useLogoSrc.js";
|
|
6
|
+
import { Skeleton as q } from "@mui/material";
|
|
7
|
+
import { styled as B } from "@mui/material/styles";
|
|
8
|
+
import { useRef as I, useState as w, useLayoutEffect as F } from "react";
|
|
9
|
+
const M = B("div")(({ theme: t }) => ({
|
|
10
|
+
height: "100%",
|
|
10
11
|
minWidth: 0,
|
|
11
12
|
maxWidth: "100%",
|
|
12
13
|
"& > .logo-icon": {
|
|
@@ -20,10 +21,13 @@ const B = q("div")(({ theme: t }) => ({
|
|
|
20
21
|
display: "flex",
|
|
21
22
|
alignItems: "center",
|
|
22
23
|
justifyContent: "flex-start",
|
|
24
|
+
width: "100%",
|
|
25
|
+
height: "100%",
|
|
23
26
|
minWidth: 0,
|
|
24
27
|
minHeight: 0,
|
|
25
28
|
maxWidth: "100%",
|
|
26
29
|
maxHeight: "100%",
|
|
30
|
+
flexShrink: 1,
|
|
27
31
|
overflow: "visible"
|
|
28
32
|
},
|
|
29
33
|
"& > .logo-slot > .logo-slot-frame": {
|
|
@@ -76,63 +80,63 @@ const B = q("div")(({ theme: t }) => ({
|
|
|
76
80
|
})
|
|
77
81
|
}
|
|
78
82
|
}));
|
|
79
|
-
function
|
|
80
|
-
const t =
|
|
83
|
+
function Q() {
|
|
84
|
+
const t = z(), { slots: r, slotProps: h } = k(), i = r == null ? void 0 : r.logo, a = h == null ? void 0 : h.logo, b = ["owp-logo-slot-content", a == null ? void 0 : a.className].filter(Boolean).join(" "), N = I(null), R = I(null), [L, g] = w(1), [H, f] = w({}), [l, c] = w(!i);
|
|
81
85
|
return F(() => {
|
|
82
|
-
if (!
|
|
83
|
-
|
|
86
|
+
if (!i) {
|
|
87
|
+
g(1), f({}), c(!0);
|
|
84
88
|
return;
|
|
85
89
|
}
|
|
86
|
-
const
|
|
87
|
-
if (!
|
|
90
|
+
const d = N.current, o = R.current, u = d == null ? void 0 : d.parentElement;
|
|
91
|
+
if (!d || !o || !u)
|
|
88
92
|
return;
|
|
89
|
-
let
|
|
90
|
-
|
|
91
|
-
const j = /* @__PURE__ */
|
|
92
|
-
const { width:
|
|
93
|
-
if (!
|
|
94
|
-
|
|
93
|
+
let p = 0;
|
|
94
|
+
c(!1);
|
|
95
|
+
const j = /* @__PURE__ */ m(() => {
|
|
96
|
+
const { width: n, height: E } = u.getBoundingClientRect(), C = o.getBoundingClientRect(), x = C.width || o.scrollWidth || o.offsetWidth, y = C.height || o.scrollHeight || o.offsetHeight;
|
|
97
|
+
if (!n || !E || !x || !y) {
|
|
98
|
+
g(1), f({}), c(!1);
|
|
95
99
|
return;
|
|
96
100
|
}
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
width:
|
|
100
|
-
height:
|
|
101
|
-
}),
|
|
102
|
-
}, "updateScale"),
|
|
103
|
-
cancelAnimationFrame(
|
|
101
|
+
const S = Math.min(n / x, E / y, 1);
|
|
102
|
+
g(S), f({
|
|
103
|
+
width: x * S,
|
|
104
|
+
height: y * S
|
|
105
|
+
}), c(!0);
|
|
106
|
+
}, "updateScale"), s = /* @__PURE__ */ m(() => {
|
|
107
|
+
cancelAnimationFrame(p), p = requestAnimationFrame(j);
|
|
104
108
|
}, "requestUpdate");
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
const W = Array.from(
|
|
109
|
-
return W.forEach((
|
|
110
|
-
|
|
109
|
+
s();
|
|
110
|
+
const v = new ResizeObserver(s);
|
|
111
|
+
v.observe(u), v.observe(o);
|
|
112
|
+
const W = Array.from(o.querySelectorAll("img"));
|
|
113
|
+
return W.forEach((n) => {
|
|
114
|
+
n.addEventListener("load", s), n.addEventListener("error", s);
|
|
111
115
|
}), () => {
|
|
112
|
-
cancelAnimationFrame(
|
|
113
|
-
|
|
116
|
+
cancelAnimationFrame(p), v.disconnect(), W.forEach((n) => {
|
|
117
|
+
n.removeEventListener("load", s), n.removeEventListener("error", s);
|
|
114
118
|
});
|
|
115
119
|
};
|
|
116
|
-
}, [
|
|
117
|
-
!
|
|
120
|
+
}, [i]), /* @__PURE__ */ e(M, { ref: N, className: "flex items-center space-x-8", children: i ? /* @__PURE__ */ O("div", { className: "logo-icon logo-slot", children: [
|
|
121
|
+
!l && /* @__PURE__ */ e(q, { animation: "wave", variant: "rounded", className: "logo-slot-skeleton" }),
|
|
118
122
|
/* @__PURE__ */ e(
|
|
119
123
|
"div",
|
|
120
124
|
{
|
|
121
125
|
className: "logo-slot-frame",
|
|
122
126
|
style: {
|
|
123
127
|
transform: "translateX(-8px)",
|
|
124
|
-
width: H.width,
|
|
125
|
-
height: H.height,
|
|
126
|
-
visibility:
|
|
128
|
+
width: l ? H.width : 0,
|
|
129
|
+
height: l ? H.height : 0,
|
|
130
|
+
visibility: l ? "visible" : "hidden"
|
|
127
131
|
},
|
|
128
|
-
children: /* @__PURE__ */ e("div", { className: "logo-slot-transform", style: { transform: `scale(${L})` }, children: /* @__PURE__ */ e("div", { className: "logo-slot-content", children: /* @__PURE__ */ e(
|
|
132
|
+
children: /* @__PURE__ */ e("div", { className: "logo-slot-transform", style: { transform: `scale(${L})` }, children: /* @__PURE__ */ e("div", { className: "logo-slot-content", children: /* @__PURE__ */ e(i, { ...a, className: b }) }) })
|
|
129
133
|
}
|
|
130
134
|
),
|
|
131
|
-
/* @__PURE__ */ e("div", { ref:
|
|
135
|
+
/* @__PURE__ */ e("div", { ref: R, className: "logo-slot-measure", "aria-hidden": !0, children: /* @__PURE__ */ e(i, { ...a, className: b }) })
|
|
132
136
|
] }) : /* @__PURE__ */ e("img", { className: "logo-icon", src: t, alt: "logo" }) });
|
|
133
137
|
}
|
|
134
|
-
|
|
138
|
+
m(Q, "Logo");
|
|
135
139
|
export {
|
|
136
|
-
|
|
140
|
+
Q as default
|
|
137
141
|
};
|
|
138
142
|
//# sourceMappingURL=Logo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Logo.js","sources":["../../../../src/layout/components/logo/Logo.tsx"],"sourcesContent":["import { useOwpAppContext as useAppContext } from '@/contexts/OwpAppProvider';\nimport { useGetLogoSrc } from '@/hooks/useLogoSrc';\nimport { Skeleton } from '@mui/material';\nimport { styled } from '@mui/material/styles';\nimport { useLayoutEffect, useRef, useState } from 'react';\n\nconst Root = styled('div')(({ theme }) => ({\n minWidth: 0,\n maxWidth: '100%',\n '& > .logo-icon': {\n transition: theme.transitions.create(['width', 'height'], {\n duration: theme.transitions.duration.shortest,\n easing: theme.transitions.easing.easeInOut,\n }),\n },\n '& > .logo-slot': {\n position: 'relative',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'flex-start',\n minWidth: 0,\n minHeight: 0,\n maxWidth: '100%',\n maxHeight: '100%',\n overflow: 'visible',\n },\n '& > .logo-slot > .logo-slot-frame': {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'flex-start',\n minWidth: 0,\n minHeight: 0,\n maxWidth: '100%',\n maxHeight: '100%',\n flexShrink: 1,\n overflow: 'hidden',\n },\n '& .logo-slot-transform': {\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'flex-start',\n transformOrigin: 'left center',\n },\n '& .logo-slot-content, & .logo-slot-measure': {\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'flex-start',\n width: 'fit-content',\n height: 'fit-content',\n },\n '& .logo-slot-measure': {\n position: 'absolute',\n top: 0,\n left: -99999,\n visibility: 'hidden',\n pointerEvents: 'none',\n whiteSpace: 'nowrap',\n },\n '& .logo-slot-skeleton': {\n position: 'absolute',\n top: '50%',\n left: '50%',\n width: 'min(100%, 160px)',\n minHeight: 70,\n height: 70,\n maxHeight: '100%',\n transform: 'translate(-50%, -50%)',\n borderRadius: theme.shape.borderRadius,\n },\n '& > .badge': {\n transition: theme.transitions.create('opacity', {\n duration: theme.transitions.duration.shortest,\n easing: theme.transitions.easing.easeInOut,\n }),\n },\n}));\n\n/**\n * The logo component.\n */\nfunction Logo() {\n const logoSrc = useGetLogoSrc();\n const { slots, slotProps } = useAppContext();\n const LogoSlot = slots?.logo;\n const logoSlotProps = slotProps?.logo;\n const logoSlotClassName = ['owp-logo-slot-content', logoSlotProps?.className]\n .filter(Boolean)\n .join(' ');\n const rootRef = useRef<HTMLDivElement | null>(null);\n const slotMeasureRef = useRef<HTMLDivElement | null>(null);\n const [slotScale, setSlotScale] = useState(1);\n const [slotSize, setSlotSize] = useState<{ width?: number; height?: number }>({});\n const [isSlotReady, setIsSlotReady] = useState(!LogoSlot);\n\n useLayoutEffect(() => {\n if (!LogoSlot) {\n setSlotScale(1);\n setSlotSize({});\n setIsSlotReady(true);\n return;\n }\n\n const rootElement = rootRef.current;\n const measureElement = slotMeasureRef.current;\n const boundaryElement = rootElement?.parentElement;\n\n if (!rootElement || !measureElement || !boundaryElement) {\n return;\n }\n\n let frameId = 0;\n setIsSlotReady(false);\n\n const updateScale = () => {\n const { width: boundaryWidth, height: boundaryHeight } =\n boundaryElement.getBoundingClientRect();\n const contentWidth = measureElement.scrollWidth || measureElement.offsetWidth;\n const contentHeight = measureElement.scrollHeight || measureElement.offsetHeight;\n\n if (!boundaryWidth || !boundaryHeight || !contentWidth || !contentHeight) {\n setSlotScale(1);\n setSlotSize({});\n setIsSlotReady(false);\n return;\n }\n\n const nextScale = Math.min(boundaryWidth / contentWidth, boundaryHeight / contentHeight, 1);\n\n setSlotScale(nextScale);\n setSlotSize({\n width: contentWidth * nextScale,\n height: contentHeight * nextScale,\n });\n setIsSlotReady(true);\n };\n\n const requestUpdate = () => {\n cancelAnimationFrame(frameId);\n frameId = requestAnimationFrame(updateScale);\n };\n\n requestUpdate();\n\n const resizeObserver = new ResizeObserver(requestUpdate);\n resizeObserver.observe(boundaryElement);\n resizeObserver.observe(measureElement);\n\n const imageElements = Array.from(measureElement.querySelectorAll('img'));\n imageElements.forEach((imageElement) => {\n imageElement.addEventListener('load', requestUpdate);\n imageElement.addEventListener('error', requestUpdate);\n });\n\n return () => {\n cancelAnimationFrame(frameId);\n resizeObserver.disconnect();\n imageElements.forEach((imageElement) => {\n imageElement.removeEventListener('load', requestUpdate);\n imageElement.removeEventListener('error', requestUpdate);\n });\n };\n }, [LogoSlot]);\n\n return (\n <Root ref={rootRef} className=\"flex items-center space-x-8\">\n {LogoSlot ? (\n <div className=\"logo-icon logo-slot\">\n {!isSlotReady && (\n <Skeleton animation=\"wave\" variant=\"rounded\" className=\"logo-slot-skeleton\" />\n )}\n <div\n className=\"logo-slot-frame\"\n style={{\n transform: 'translateX(-8px)',\n width: slotSize.width,\n height: slotSize.height,\n visibility: isSlotReady ? 'visible' : 'hidden',\n }}\n >\n <div className=\"logo-slot-transform\" style={{ transform: `scale(${slotScale})` }}>\n <div className=\"logo-slot-content\">\n <LogoSlot {...logoSlotProps} className={logoSlotClassName} />\n </div>\n </div>\n </div>\n <div ref={slotMeasureRef} className=\"logo-slot-measure\" aria-hidden>\n <LogoSlot {...logoSlotProps} className={logoSlotClassName} />\n </div>\n </div>\n ) : (\n <img className=\"logo-icon\" src={logoSrc} alt=\"logo\" />\n )}\n </Root>\n );\n}\n\nexport default Logo;\n"],"names":["Root","styled","theme","Logo","logoSrc","useGetLogoSrc","slots","slotProps","useAppContext","LogoSlot","logoSlotProps","logoSlotClassName","rootRef","useRef","slotMeasureRef","slotScale","setSlotScale","useState","slotSize","setSlotSize","isSlotReady","setIsSlotReady","useLayoutEffect","rootElement","measureElement","boundaryElement","frameId","updateScale","__name","boundaryWidth","boundaryHeight","contentWidth","contentHeight","nextScale","requestUpdate","resizeObserver","imageElements","imageElement","jsx","jsxs","Skeleton"],"mappings":";;;;;;;;AAMA,MAAMA,IAAOC,EAAO,KAAK,EAAE,CAAC,EAAE,OAAAC,SAAa;AAAA,EACzC,UAAU;AAAA,EACV,UAAU;AAAA,EACV,kBAAkB;AAAA,IAChB,YAAYA,EAAM,YAAY,OAAO,CAAC,SAAS,QAAQ,GAAG;AAAA,MACxD,UAAUA,EAAM,YAAY,SAAS;AAAA,MACrC,QAAQA,EAAM,YAAY,OAAO;AAAA,IAAA,CAClC;AAAA,EAAA;AAAA,E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AA,CAC7D,EAAA,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,IAEF,gBAAA2B,EAAC,OAAA,EAAI,KAAKxB,GAAgB,WAAU,qBAAoB,eAAW,IACjE,UAAA,gBAAAwB,EAAC7B,GAAA,EAAU,GAAGC,GAAe,WAAWC,GAAmB,EAAA,CAC7D;AAAA,EAAA,EAAA,CACF,sBAEC,OAAA,EAAI,WAAU,aAAY,KAAKP,GAAS,KAAI,OAAA,CAAO,EAAA,CAExD;AAEJ;AAlHSwB,EAAAzB,GAAA;"}
|
|
1
|
+
{"version":3,"file":"Logo.js","sources":["../../../../src/layout/components/logo/Logo.tsx"],"sourcesContent":["import { useOwpAppContext as useAppContext } from '@/contexts/OwpAppProvider';\nimport { useGetLogoSrc } from '@/hooks/useLogoSrc';\nimport { Skeleton } from '@mui/material';\nimport { styled } from '@mui/material/styles';\nimport { useLayoutEffect, useRef, useState } from 'react';\n\nconst Root = styled('div')(({ theme }) => ({\n height: '100%',\n minWidth: 0,\n maxWidth: '100%',\n '& > .logo-icon': {\n transition: theme.transitions.create(['width', 'height'], {\n duration: theme.transitions.duration.shortest,\n easing: theme.transitions.easing.easeInOut,\n }),\n },\n '& > .logo-slot': {\n position: 'relative',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'flex-start',\n width: '100%',\n height: '100%',\n minWidth: 0,\n minHeight: 0,\n maxWidth: '100%',\n maxHeight: '100%',\n flexShrink: 1,\n overflow: 'visible',\n },\n '& > .logo-slot > .logo-slot-frame': {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'flex-start',\n minWidth: 0,\n minHeight: 0,\n maxWidth: '100%',\n maxHeight: '100%',\n flexShrink: 1,\n overflow: 'hidden',\n },\n '& .logo-slot-transform': {\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'flex-start',\n transformOrigin: 'left center',\n },\n '& .logo-slot-content, & .logo-slot-measure': {\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'flex-start',\n width: 'fit-content',\n height: 'fit-content',\n },\n '& .logo-slot-measure': {\n position: 'absolute',\n top: 0,\n left: -99999,\n visibility: 'hidden',\n pointerEvents: 'none',\n whiteSpace: 'nowrap',\n },\n '& .logo-slot-skeleton': {\n position: 'absolute',\n top: '50%',\n left: '50%',\n width: 'min(100%, 160px)',\n minHeight: 70,\n height: 70,\n maxHeight: '100%',\n transform: 'translate(-50%, -50%)',\n borderRadius: theme.shape.borderRadius,\n },\n '& > .badge': {\n transition: theme.transitions.create('opacity', {\n duration: theme.transitions.duration.shortest,\n easing: theme.transitions.easing.easeInOut,\n }),\n },\n}));\n\n/**\n * The logo component.\n */\nfunction Logo() {\n const logoSrc = useGetLogoSrc();\n const { slots, slotProps } = useAppContext();\n const LogoSlot = slots?.logo;\n const logoSlotProps = slotProps?.logo;\n const logoSlotClassName = ['owp-logo-slot-content', logoSlotProps?.className]\n .filter(Boolean)\n .join(' ');\n const rootRef = useRef<HTMLDivElement | null>(null);\n const slotMeasureRef = useRef<HTMLDivElement | null>(null);\n const [slotScale, setSlotScale] = useState(1);\n const [slotSize, setSlotSize] = useState<{ width?: number; height?: number }>({});\n const [isSlotReady, setIsSlotReady] = useState(!LogoSlot);\n\n useLayoutEffect(() => {\n if (!LogoSlot) {\n setSlotScale(1);\n setSlotSize({});\n setIsSlotReady(true);\n return;\n }\n\n const rootElement = rootRef.current;\n const measureElement = slotMeasureRef.current;\n const boundaryElement = rootElement?.parentElement;\n\n if (!rootElement || !measureElement || !boundaryElement) {\n return;\n }\n\n let frameId = 0;\n setIsSlotReady(false);\n\n const updateScale = () => {\n const { width: boundaryWidth, height: boundaryHeight } =\n boundaryElement.getBoundingClientRect();\n const measureRect = measureElement.getBoundingClientRect();\n const contentWidth =\n measureRect.width || measureElement.scrollWidth || measureElement.offsetWidth;\n const contentHeight =\n measureRect.height || measureElement.scrollHeight || measureElement.offsetHeight;\n\n if (!boundaryWidth || !boundaryHeight || !contentWidth || !contentHeight) {\n setSlotScale(1);\n setSlotSize({});\n setIsSlotReady(false);\n return;\n }\n\n const nextScale = Math.min(boundaryWidth / contentWidth, boundaryHeight / contentHeight, 1);\n\n setSlotScale(nextScale);\n setSlotSize({\n width: contentWidth * nextScale,\n height: contentHeight * nextScale,\n });\n setIsSlotReady(true);\n };\n\n const requestUpdate = () => {\n cancelAnimationFrame(frameId);\n frameId = requestAnimationFrame(updateScale);\n };\n\n requestUpdate();\n\n const resizeObserver = new ResizeObserver(requestUpdate);\n resizeObserver.observe(boundaryElement);\n resizeObserver.observe(measureElement);\n\n const imageElements = Array.from(measureElement.querySelectorAll('img'));\n imageElements.forEach((imageElement) => {\n imageElement.addEventListener('load', requestUpdate);\n imageElement.addEventListener('error', requestUpdate);\n });\n\n return () => {\n cancelAnimationFrame(frameId);\n resizeObserver.disconnect();\n imageElements.forEach((imageElement) => {\n imageElement.removeEventListener('load', requestUpdate);\n imageElement.removeEventListener('error', requestUpdate);\n });\n };\n }, [LogoSlot]);\n\n return (\n <Root ref={rootRef} className=\"flex items-center space-x-8\">\n {LogoSlot ? (\n <div className=\"logo-icon logo-slot\">\n {!isSlotReady && (\n <Skeleton animation=\"wave\" variant=\"rounded\" className=\"logo-slot-skeleton\" />\n )}\n <div\n className=\"logo-slot-frame\"\n style={{\n transform: 'translateX(-8px)',\n width: isSlotReady ? slotSize.width : 0,\n height: isSlotReady ? slotSize.height : 0,\n visibility: isSlotReady ? 'visible' : 'hidden',\n }}\n >\n <div className=\"logo-slot-transform\" style={{ transform: `scale(${slotScale})` }}>\n <div className=\"logo-slot-content\">\n <LogoSlot {...logoSlotProps} className={logoSlotClassName} />\n </div>\n </div>\n </div>\n <div ref={slotMeasureRef} className=\"logo-slot-measure\" aria-hidden>\n <LogoSlot {...logoSlotProps} className={logoSlotClassName} />\n </div>\n </div>\n ) : (\n <img className=\"logo-icon\" src={logoSrc} alt=\"logo\" />\n )}\n </Root>\n );\n}\n\nexport default Logo;\n"],"names":["Root","styled","theme","Logo","logoSrc","useGetLogoSrc","slots","slotProps","useAppContext","LogoSlot","logoSlotProps","logoSlotClassName","rootRef","useRef","slotMeasureRef","slotScale","setSlotScale","useState","slotSize","setSlotSize","isSlotReady","setIsSlotReady","useLayoutEffect","rootElement","measureElement","boundaryElement","frameId","updateScale","__name","boundaryWidth","boundaryHeight","measureRect","contentWidth","contentHeight","nextScale","requestUpdate","resizeObserver","imageElements","imageElement","jsx","jsxs","Skeleton"],"mappings":";;;;;;;;AAMA,MAAMA,IAAOC,EAAO,KAAK,EAAE,CAAC,EAAE,OAAAC,SAAa;AAAA,EACzC,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,UAAU;AAAA,EACV,kBAAkB;AAAA,IAChB,YAAYA,EAAM,YAAY,OAAO,CAAC,SAAS,QAAQ,GAAG;AAAA,MACxD,UAAUA,EAAM,YAAY,SAAS;AAAA,MACrC,QAAQA,EAAM,YAAY,OAAO;AAAA,IAAA,CAClC;AAAA,EAAA;AAAA,EAEH,kBAAkB;AAAA,IAChB,UAAU;AAAA,IACV,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,gBAAgB;AAAA,IAChB,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,IACV,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,UAAU;AAAA,EAAA;AAAA,EAEZ,qCAAqC;AAAA,IACnC,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,gBAAgB;AAAA,IAChB,UAAU;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,IACV,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,UAAU;AAAA,EAAA;AAAA,EAEZ,0BAA0B;AAAA,IACxB,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,gBAAgB;AAAA,IAChB,iBAAiB;AAAA,EAAA;AAAA,EAEnB,8CAA8C;AAAA,IAC5C,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,gBAAgB;AAAA,IAChB,OAAO;AAAA,IACP,QAAQ;AAAA,EAAA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B,SAASH,CAAa;AAAA,MACzD,CAAC;AAAA,IACH;AAAA,EACF,GAAG,CAAC1B,CAAQ,CAAC,GAGX,gBAAA8B,EAACvC,GAAA,EAAK,KAAKY,GAAS,WAAU,+BAC3B,UAAAH,IACC,gBAAA+B,EAAC,OAAA,EAAI,WAAU,uBACZ,UAAA;AAAA,IAAA,CAACpB,uBACCqB,GAAA,EAAS,WAAU,QAAO,SAAQ,WAAU,WAAU,sBAAqB;AAAA,IAE9E,gBAAAF;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,WAAU;AAAA,QACV,OAAO;AAAA,UACL,WAAW;AAAA,UACX,OAAOnB,IAAcF,EAAS,QAAQ;AAAA,UACtC,QAAQE,IAAcF,EAAS,SAAS;AAAA,UACxC,YAAYE,IAAc,YAAY;AAAA,QAAA;AAAA,QAGxC,UAAA,gBAAAmB,EAAC,SAAI,WAAU,uBAAsB,OAAO,EAAE,WAAW,SAASxB,CAAS,IAAA,GACzE,4BAAC,OAAA,EAAI,WAAU,qBACb,UAAA,gBAAAwB,EAAC9B,GAAA,EAAU,GAAGC,GAAe,WAAWC,EAAA,CAAmB,EAAA,CAC7D,EAAA,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,IAEF,gBAAA4B,EAAC,OAAA,EAAI,KAAKzB,GAAgB,WAAU,qBAAoB,eAAW,IACjE,UAAA,gBAAAyB,EAAC9B,GAAA,EAAU,GAAGC,GAAe,WAAWC,GAAmB,EAAA,CAC7D;AAAA,EAAA,EAAA,CACF,sBAEC,OAAA,EAAI,WAAU,aAAY,KAAKP,GAAS,KAAI,OAAA,CAAO,EAAA,CAExD;AAEJ;AArHSwB,EAAAzB,GAAA;"}
|
|
@@ -18,11 +18,11 @@ import { styled as te } from "@mui/material/styles";
|
|
|
18
18
|
import z from "@mui/material/TextField";
|
|
19
19
|
import ne from "@mui/material/Tooltip";
|
|
20
20
|
import E from "@mui/material/Typography";
|
|
21
|
-
import D from "../../../_virtual/
|
|
22
|
-
import re from "../../../_virtual/
|
|
21
|
+
import D from "../../../_virtual/index16.js";
|
|
22
|
+
import re from "../../../_virtual/index17.js";
|
|
23
23
|
import { clsx as B } from "../../../node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.js";
|
|
24
24
|
import { useMemo as oe, useReducer as ie, useRef as T, useEffect as se } from "react";
|
|
25
|
-
import W from "../../../_virtual/
|
|
25
|
+
import W from "../../../_virtual/index18.js";
|
|
26
26
|
import { useNavigate as ae } from "react-router-dom";
|
|
27
27
|
import { toolbarToggleSx as le } from "./toggleStyles.js";
|
|
28
28
|
import { OwpSvgIcon as w } from "../../../components/OwpSvgIcon/OwpSvgIcon.js";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
var d = Object.defineProperty;
|
|
2
|
+
var l = (n, a) => d(n, "name", { value: a, configurable: !0 });
|
|
3
|
+
import { jsx as s } from "../../../node_modules/.pnpm/@emotion_react@11.14.0_@types_react@19.2.14_react@19.2.4/node_modules/@emotion/react/jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js";
|
|
4
|
+
import { useOwpAppContext as p } from "../../../contexts/OwpAppProvider.js";
|
|
5
|
+
import { preloadOnIdle as h } from "../../../utils/preloadOnIdle.js";
|
|
6
|
+
import w from "../../../node_modules/.pnpm/@mui_icons-material@7.3.9_@mui_material@7.3.9_@emotion_react@11.14.0_@types_react@19.2._dc2be6bc014bebdac88a574e3e02c144/node_modules/@mui/icons-material/esm/PaletteOutlined.js";
|
|
7
|
+
import P from "@mui/material/IconButton";
|
|
8
|
+
import g from "@mui/material/Tooltip";
|
|
9
|
+
import { clsx as T } from "../../../node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.js";
|
|
10
|
+
import { useDialogs as v } from "@toolpad/core/useDialogs";
|
|
11
|
+
import { useRef as D, useCallback as b, useEffect as x } from "react";
|
|
12
|
+
import { toolbarToggleSx as E } from "./toggleStyles.js";
|
|
13
|
+
function z(n) {
|
|
14
|
+
const { className: a = "" } = n, u = v(), { env: e } = p(), t = D(null), m = (e == null ? void 0 : e.isThemePreviewEnabled) === !0, o = e == null ? void 0 : e.themePreviewDialogLoader, i = b(() => o ? (t.current || (t.current = o().catch((r) => {
|
|
15
|
+
throw t.current = null, r;
|
|
16
|
+
})), t.current) : Promise.resolve(null), [o]);
|
|
17
|
+
if (x(() => {
|
|
18
|
+
if (!(!m || !o))
|
|
19
|
+
return h(() => i());
|
|
20
|
+
}, [m, i, o]), !m || !o)
|
|
21
|
+
return null;
|
|
22
|
+
const f = /* @__PURE__ */ l(async () => {
|
|
23
|
+
try {
|
|
24
|
+
const r = await i();
|
|
25
|
+
if (!r)
|
|
26
|
+
return;
|
|
27
|
+
await u.open(r.ThemePreviewDialog, {});
|
|
28
|
+
} catch (r) {
|
|
29
|
+
console.error(r);
|
|
30
|
+
}
|
|
31
|
+
}, "handleOpenThemePreviewDialog"), c = /* @__PURE__ */ l(() => {
|
|
32
|
+
i();
|
|
33
|
+
}, "handlePreloadThemePreviewDialog");
|
|
34
|
+
return /* @__PURE__ */ s(g, { title: "Theme Preview", placement: "bottom", children: /* @__PURE__ */ s(
|
|
35
|
+
P,
|
|
36
|
+
{
|
|
37
|
+
sx: E,
|
|
38
|
+
onClick: f,
|
|
39
|
+
onMouseEnter: c,
|
|
40
|
+
onFocus: c,
|
|
41
|
+
className: T(a),
|
|
42
|
+
"aria-label": "Theme Preview",
|
|
43
|
+
children: /* @__PURE__ */ s(w, { fontSize: "small" })
|
|
44
|
+
}
|
|
45
|
+
) });
|
|
46
|
+
}
|
|
47
|
+
l(z, "ThemePreviewToggle");
|
|
48
|
+
export {
|
|
49
|
+
z as default
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=ThemePreviewToggle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThemePreviewToggle.js","sources":["../../../../src/layout/components/toggles/ThemePreviewToggle.tsx"],"sourcesContent":["import { useOwpAppContext } from '@/contexts/OwpAppProvider';\nimport { preloadOnIdle } from '@/utils/preloadOnIdle';\nimport PaletteOutlinedIcon from '@mui/icons-material/PaletteOutlined';\nimport IconButton from '@mui/material/IconButton';\nimport Tooltip from '@mui/material/Tooltip';\nimport clsx from 'clsx';\nimport { type DialogComponent, useDialogs } from '@toolpad/core/useDialogs';\nimport { useCallback, useEffect, useRef } from 'react';\nimport { toolbarToggleSx } from './toggleStyles';\n\ntype ThemePreviewDialogModule = {\n ThemePreviewDialog: DialogComponent<unknown, unknown>;\n};\n\ntype ThemePreviewDialogLoader = () => Promise<ThemePreviewDialogModule>;\n\ntype ThemePreviewToggleProps = {\n className?: string;\n};\n\nfunction ThemePreviewToggle(props: ThemePreviewToggleProps) {\n const { className = '' } = props;\n const dialogs = useDialogs();\n const { env } = useOwpAppContext();\n const dialogModulePromiseRef = useRef<Promise<ThemePreviewDialogModule> | null>(null);\n const isThemePreviewEnabled = env?.isThemePreviewEnabled === true;\n const themePreviewDialogLoader = env?.themePreviewDialogLoader as\n | ThemePreviewDialogLoader\n | undefined;\n\n const loadThemePreviewDialog = useCallback(() => {\n if (!themePreviewDialogLoader) {\n return Promise.resolve(null);\n }\n\n if (!dialogModulePromiseRef.current) {\n dialogModulePromiseRef.current = themePreviewDialogLoader().catch((error) => {\n dialogModulePromiseRef.current = null;\n throw error;\n });\n }\n\n return dialogModulePromiseRef.current;\n }, [themePreviewDialogLoader]);\n\n useEffect(() => {\n if (!isThemePreviewEnabled || !themePreviewDialogLoader) {\n return;\n }\n\n return preloadOnIdle(() => loadThemePreviewDialog());\n }, [isThemePreviewEnabled, loadThemePreviewDialog, themePreviewDialogLoader]);\n\n if (!isThemePreviewEnabled || !themePreviewDialogLoader) {\n return null;\n }\n\n const handleOpenThemePreviewDialog = async () => {\n try {\n const dialogModule = await loadThemePreviewDialog();\n\n if (!dialogModule) {\n return;\n }\n\n await dialogs.open(dialogModule.ThemePreviewDialog, {});\n } catch (error) {\n console.error(error);\n }\n };\n\n const handlePreloadThemePreviewDialog = () => {\n void loadThemePreviewDialog();\n };\n\n return (\n <Tooltip title=\"Theme Preview\" placement=\"bottom\">\n <IconButton\n sx={toolbarToggleSx}\n onClick={handleOpenThemePreviewDialog}\n onMouseEnter={handlePreloadThemePreviewDialog}\n onFocus={handlePreloadThemePreviewDialog}\n className={clsx(className)}\n aria-label=\"Theme Preview\"\n >\n <PaletteOutlinedIcon fontSize=\"small\" />\n </IconButton>\n </Tooltip>\n );\n}\n\nexport default ThemePreviewToggle;\n"],"names":["ThemePreviewToggle","props","className","dialogs","useDialogs","env","useOwpAppContext","dialogModulePromiseRef","useRef","isThemePreviewEnabled","themePreviewDialogLoader","loadThemePreviewDialog","useCallback","error","useEffect","preloadOnIdle","handleOpenThemePreviewDialog","__name","dialogModule","handlePreloadThemePreviewDialog","jsx","Tooltip","IconButton","toolbarToggleSx","clsx","PaletteOutlinedIcon"],"mappings":";;;;;;;;;;;;AAoBA,SAASA,EAAmBC,GAAgC;AAC1D,QAAM,EAAE,WAAAC,IAAY,GAAA,IAAOD,GACrBE,IAAUC,EAAA,GACV,EAAE,KAAAC,EAAA,IAAQC,EAAA,GACVC,IAAyBC,EAAiD,IAAI,GAC9EC,KAAwBJ,KAAA,gBAAAA,EAAK,2BAA0B,IACvDK,IAA2BL,KAAA,gBAAAA,EAAK,0BAIhCM,IAAyBC,EAAY,MACpCF,KAIAH,EAAuB,YAC1BA,EAAuB,UAAUG,EAAA,EAA2B,MAAM,CAACG,MAAU;AAC3E,UAAAN,EAAuB,UAAU,MAC3BM;AAAA,EACR,CAAC,IAGIN,EAAuB,WAVrB,QAAQ,QAAQ,IAAI,GAW5B,CAACG,CAAwB,CAAC;AAU7B,MARAI,EAAU,MAAM;AACd,QAAI,GAACL,KAAyB,CAACC;AAI/B,aAAOK,EAAc,MAAMJ,GAAwB;AAAA,EACrD,GAAG,CAACF,GAAuBE,GAAwBD,CAAwB,CAAC,GAExE,CAACD,KAAyB,CAACC;AAC7B,WAAO;AAGT,QAAMM,IAA+B,gBAAAC,EAAA,YAA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