@blocklet/theme 3.0.9 → 3.0.10

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/cjs/index.js CHANGED
@@ -13,17 +13,15 @@ function isValidThemeMode(mode) {
13
13
  return mode === "light" || mode === "dark";
14
14
  }
15
15
  function getBlockletThemeOptions(mode = "light") {
16
- var _a;
17
- const { common = {}, light = {}, dark = {} } = ((_a = window.blocklet) == null ? void 0 : _a.theme) || {};
16
+ const { common = {}, light = {}, dark = {} } = window.blocklet?.theme || {};
18
17
  if (mode === "dark") {
19
18
  return merge(common, dark);
20
19
  }
21
20
  return merge(common, light);
22
21
  }
23
22
  function getDefaultThemePrefer(meta) {
24
- var _a, _b;
25
23
  const blockletInfo = Object.assign({}, window.blocklet, meta);
26
- const preferKey = ((_a = blockletInfo.theme) == null ? void 0 : _a.preferKey) ?? BLOCKLET_THEME_PREFER_KEY;
24
+ const preferKey = blockletInfo.theme?.preferKey ?? BLOCKLET_THEME_PREFER_KEY;
27
25
  const urlParams = new URLSearchParams(window.location.search);
28
26
  const urlPrefer = urlParams.get("theme");
29
27
  if (isValidThemeMode(urlPrefer)) {
@@ -33,7 +31,7 @@ function getDefaultThemePrefer(meta) {
33
31
  if (isValidThemeMode(sessionPrefer)) {
34
32
  return sessionPrefer;
35
33
  }
36
- const prefer = (_b = blockletInfo.theme) == null ? void 0 : _b.prefer;
34
+ const prefer = blockletInfo.theme?.prefer;
37
35
  if (prefer === "light" || prefer === "dark") {
38
36
  return prefer;
39
37
  }
@@ -47,18 +45,17 @@ function getDefaultThemePrefer(meta) {
47
45
  return "light";
48
46
  }
49
47
  const buildThemeStyles = (theme) => {
50
- var _a, _b, _c, _d, _e, _f, _g, _h;
51
48
  const { light = {}, dark = {} } = theme ?? {};
52
49
  return `
53
50
  <style id="blocklet-theme-style">
54
51
  :root {
55
- --blocklet-background-default-color: ${((_b = (_a = light.palette) == null ? void 0 : _a.background) == null ? void 0 : _b.default) ?? "#ffffff"};
56
- --blocklet-text-primary-color: ${((_d = (_c = light.palette) == null ? void 0 : _c.text) == null ? void 0 : _d.primary) ?? "#18181b"};
52
+ --blocklet-background-default-color: ${light.palette?.background?.default ?? "#ffffff"};
53
+ --blocklet-text-primary-color: ${light.palette?.text?.primary ?? "#18181b"};
57
54
  }
58
55
 
59
56
  [data-theme='dark'] {
60
- --blocklet-background-default-color: ${((_f = (_e = dark.palette) == null ? void 0 : _e.background) == null ? void 0 : _f.default) ?? "#121212"};
61
- --blocklet-text-primary-color: ${((_h = (_g = dark.palette) == null ? void 0 : _g.text) == null ? void 0 : _h.primary) ?? "#ffffff"};
57
+ --blocklet-background-default-color: ${dark.palette?.background?.default ?? "#121212"};
58
+ --blocklet-text-primary-color: ${dark.palette?.text?.primary ?? "#ffffff"};
62
59
  }
63
60
 
64
61
  html, body {
@@ -76,7 +73,7 @@ const buildThemeScript = (theme) => {
76
73
  ${isValidThemeMode.toString()}
77
74
  ${getDefaultThemePrefer.toString()}
78
75
 
79
- const prefer = getDefaultThemePrefer(${JSON.stringify({ theme: { prefer: (theme == null ? void 0 : theme.prefer) ?? "light", preferKey: BLOCKLET_THEME_PREFER_KEY } })});
76
+ const prefer = getDefaultThemePrefer(${JSON.stringify({ theme: { prefer: theme?.prefer ?? "light", preferKey: BLOCKLET_THEME_PREFER_KEY } })});
80
77
 
81
78
  if(prefer === 'dark') {
82
79
  document.documentElement.setAttribute('data-theme', 'dark');
package/dist/es/index.js CHANGED
@@ -11,17 +11,15 @@ function isValidThemeMode(mode) {
11
11
  return mode === "light" || mode === "dark";
12
12
  }
13
13
  function getBlockletThemeOptions(mode = "light") {
14
- var _a;
15
- const { common = {}, light = {}, dark = {} } = ((_a = window.blocklet) == null ? void 0 : _a.theme) || {};
14
+ const { common = {}, light = {}, dark = {} } = window.blocklet?.theme || {};
16
15
  if (mode === "dark") {
17
16
  return merge(common, dark);
18
17
  }
19
18
  return merge(common, light);
20
19
  }
21
20
  function getDefaultThemePrefer(meta) {
22
- var _a, _b;
23
21
  const blockletInfo = Object.assign({}, window.blocklet, meta);
24
- const preferKey = ((_a = blockletInfo.theme) == null ? void 0 : _a.preferKey) ?? BLOCKLET_THEME_PREFER_KEY;
22
+ const preferKey = blockletInfo.theme?.preferKey ?? BLOCKLET_THEME_PREFER_KEY;
25
23
  const urlParams = new URLSearchParams(window.location.search);
26
24
  const urlPrefer = urlParams.get("theme");
27
25
  if (isValidThemeMode(urlPrefer)) {
@@ -31,7 +29,7 @@ function getDefaultThemePrefer(meta) {
31
29
  if (isValidThemeMode(sessionPrefer)) {
32
30
  return sessionPrefer;
33
31
  }
34
- const prefer = (_b = blockletInfo.theme) == null ? void 0 : _b.prefer;
32
+ const prefer = blockletInfo.theme?.prefer;
35
33
  if (prefer === "light" || prefer === "dark") {
36
34
  return prefer;
37
35
  }
@@ -45,18 +43,17 @@ function getDefaultThemePrefer(meta) {
45
43
  return "light";
46
44
  }
47
45
  const buildThemeStyles = (theme) => {
48
- var _a, _b, _c, _d, _e, _f, _g, _h;
49
46
  const { light = {}, dark = {} } = theme ?? {};
50
47
  return `
51
48
  <style id="blocklet-theme-style">
52
49
  :root {
53
- --blocklet-background-default-color: ${((_b = (_a = light.palette) == null ? void 0 : _a.background) == null ? void 0 : _b.default) ?? "#ffffff"};
54
- --blocklet-text-primary-color: ${((_d = (_c = light.palette) == null ? void 0 : _c.text) == null ? void 0 : _d.primary) ?? "#18181b"};
50
+ --blocklet-background-default-color: ${light.palette?.background?.default ?? "#ffffff"};
51
+ --blocklet-text-primary-color: ${light.palette?.text?.primary ?? "#18181b"};
55
52
  }
56
53
 
57
54
  [data-theme='dark'] {
58
- --blocklet-background-default-color: ${((_f = (_e = dark.palette) == null ? void 0 : _e.background) == null ? void 0 : _f.default) ?? "#121212"};
59
- --blocklet-text-primary-color: ${((_h = (_g = dark.palette) == null ? void 0 : _g.text) == null ? void 0 : _h.primary) ?? "#ffffff"};
55
+ --blocklet-background-default-color: ${dark.palette?.background?.default ?? "#121212"};
56
+ --blocklet-text-primary-color: ${dark.palette?.text?.primary ?? "#ffffff"};
60
57
  }
61
58
 
62
59
  html, body {
@@ -74,7 +71,7 @@ const buildThemeScript = (theme) => {
74
71
  ${isValidThemeMode.toString()}
75
72
  ${getDefaultThemePrefer.toString()}
76
73
 
77
- const prefer = getDefaultThemePrefer(${JSON.stringify({ theme: { prefer: (theme == null ? void 0 : theme.prefer) ?? "light", preferKey: BLOCKLET_THEME_PREFER_KEY } })});
74
+ const prefer = getDefaultThemePrefer(${JSON.stringify({ theme: { prefer: theme?.prefer ?? "light", preferKey: BLOCKLET_THEME_PREFER_KEY } })});
78
75
 
79
76
  if(prefer === 'dark') {
80
77
  document.documentElement.setAttribute('data-theme', 'dark');
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.0.9",
6
+ "version": "3.0.10",
7
7
  "description": "A preset MUI-based theme configuration designed for use with Blocklet.",
8
8
  "main": "dist/cjs/index.js",
9
9
  "module": "dist/es/index.js",
@@ -45,5 +45,5 @@
45
45
  "ts-jest": "^29.4.0",
46
46
  "typescript": "~5.5.4"
47
47
  },
48
- "gitHead": "e2283285cb6e99f09146cde5e1af002e55091619"
48
+ "gitHead": "8e4b3b4f9cc52c8f1f1d270ab03a3c566073617a"
49
49
  }