@sprucelabs/spruce-heartwood-utils 29.14.3 → 29.15.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.
@@ -6,6 +6,7 @@ export declare class ThemeManagerImpl implements ThemeManager {
6
6
  private currentTheme;
7
7
  private themeCount;
8
8
  private themeChangeHandler?;
9
+ private stylesheetNode?;
9
10
  protected constructor(theme: SkillTheme);
10
11
  static getInstance(): ThemeManagerImpl;
11
12
  static reset(): void;
@@ -14,6 +15,7 @@ export declare class ThemeManagerImpl implements ThemeManager {
14
15
  getThemeSetCount(): number;
15
16
  resetThemeCount(): void;
16
17
  setTheme(theme: SkillTheme, shouldAnimate?: boolean): Promise<void>;
18
+ private dropInExternalStylesheet;
17
19
  private applyBorderRadius;
18
20
  private deleteProp;
19
21
  private setProps;
@@ -53,6 +53,7 @@ export class ThemeManagerImpl {
53
53
  return;
54
54
  }
55
55
  (_b = this.themeChangeHandler) === null || _b === void 0 ? void 0 : _b.call(this, theme);
56
+ this.dropInExternalStylesheet(theme);
56
57
  this.themeCount++;
57
58
  this.currentTheme = theme;
58
59
  const _f = theme.props, { calendarEvents, borderRadius, cardStyles, controlBar } = _f, rest = __rest(_f, ["calendarEvents", "borderRadius", "cardStyles", "controlBar"]);
@@ -85,6 +86,19 @@ export class ThemeManagerImpl {
85
86
  .querySelector('meta[name="theme-color"]')) === null || _d === void 0 ? void 0 : _d.setAttribute('content', (_e = theme.props.color1Inverse) !== null && _e !== void 0 ? _e : 'white');
86
87
  });
87
88
  }
89
+ dropInExternalStylesheet(theme) {
90
+ if (this.stylesheetNode) {
91
+ document.head.removeChild(this.stylesheetNode);
92
+ delete this.stylesheetNode;
93
+ }
94
+ if (theme.props.stylesheetUrl) {
95
+ const link = document.createElement('link');
96
+ link.rel = 'stylesheet';
97
+ link.type = 'text/css';
98
+ link.href = theme.props.stylesheetUrl;
99
+ this.stylesheetNode = document.head.appendChild(link);
100
+ }
101
+ }
88
102
  applyBorderRadius(borderRadius) {
89
103
  if (!borderRadius || borderRadius === 'rounded') {
90
104
  this.deleteProp('borderRadiusSmall');
@@ -6,6 +6,7 @@ export declare class ThemeManagerImpl implements ThemeManager {
6
6
  private currentTheme;
7
7
  private themeCount;
8
8
  private themeChangeHandler?;
9
+ private stylesheetNode?;
9
10
  protected constructor(theme: SkillTheme);
10
11
  static getInstance(): ThemeManagerImpl;
11
12
  static reset(): void;
@@ -14,6 +15,7 @@ export declare class ThemeManagerImpl implements ThemeManager {
14
15
  getThemeSetCount(): number;
15
16
  resetThemeCount(): void;
16
17
  setTheme(theme: SkillTheme, shouldAnimate?: boolean): Promise<void>;
18
+ private dropInExternalStylesheet;
17
19
  private applyBorderRadius;
18
20
  private deleteProp;
19
21
  private setProps;
@@ -33,6 +33,7 @@ class ThemeManagerImpl {
33
33
  return;
34
34
  }
35
35
  this.themeChangeHandler?.(theme);
36
+ this.dropInExternalStylesheet(theme);
36
37
  this.themeCount++;
37
38
  this.currentTheme = theme;
38
39
  const { calendarEvents, borderRadius, cardStyles, controlBar, ...rest } = theme.props;
@@ -65,6 +66,19 @@ class ThemeManagerImpl {
65
66
  .querySelector('meta[name="theme-color"]')
66
67
  ?.setAttribute('content', theme.props.color1Inverse ?? 'white');
67
68
  }
69
+ dropInExternalStylesheet(theme) {
70
+ if (this.stylesheetNode) {
71
+ document.head.removeChild(this.stylesheetNode);
72
+ delete this.stylesheetNode;
73
+ }
74
+ if (theme.props.stylesheetUrl) {
75
+ const link = document.createElement('link');
76
+ link.rel = 'stylesheet';
77
+ link.type = 'text/css';
78
+ link.href = theme.props.stylesheetUrl;
79
+ this.stylesheetNode = document.head.appendChild(link);
80
+ }
81
+ }
68
82
  applyBorderRadius(borderRadius) {
69
83
  if (!borderRadius || borderRadius === 'rounded') {
70
84
  this.deleteProp('borderRadiusSmall');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sprucelabs/spruce-heartwood-utils",
3
3
  "description": "Heartwood Utilities",
4
- "version": "29.14.3",
4
+ "version": "29.15.0",
5
5
  "skill": {
6
6
  "namespace": "heartwood"
7
7
  },