igniteui-webcomponents 6.1.0 → 6.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (320) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/components/accordion/accordion.js +3 -3
  3. package/components/accordion/accordion.js.map +1 -1
  4. package/components/avatar/avatar.d.ts +8 -9
  5. package/components/avatar/avatar.js +29 -32
  6. package/components/avatar/avatar.js.map +1 -1
  7. package/components/badge/badge.d.ts +3 -3
  8. package/components/badge/badge.js +15 -18
  9. package/components/badge/badge.js.map +1 -1
  10. package/components/banner/banner.d.ts +2 -3
  11. package/components/banner/banner.js +14 -13
  12. package/components/banner/banner.js.map +1 -1
  13. package/components/button/button-base.d.ts +4 -11
  14. package/components/button/button-base.js +14 -15
  15. package/components/button/button-base.js.map +1 -1
  16. package/components/button/button.d.ts +1 -0
  17. package/components/button/button.js +9 -12
  18. package/components/button/button.js.map +1 -1
  19. package/components/button/icon-button.d.ts +3 -2
  20. package/components/button/icon-button.js +10 -13
  21. package/components/button/icon-button.js.map +1 -1
  22. package/components/button-group/button-group.js +8 -11
  23. package/components/button-group/button-group.js.map +1 -1
  24. package/components/button-group/toggle-button.d.ts +1 -6
  25. package/components/button-group/toggle-button.js +9 -11
  26. package/components/button-group/toggle-button.js.map +1 -1
  27. package/components/calendar/calendar.js +7 -10
  28. package/components/calendar/calendar.js.map +1 -1
  29. package/components/calendar/days-view/days-view.js +6 -6
  30. package/components/calendar/days-view/days-view.js.map +1 -1
  31. package/components/calendar/months-view/months-view.js +8 -8
  32. package/components/calendar/months-view/months-view.js.map +1 -1
  33. package/components/calendar/years-view/years-view.js +8 -8
  34. package/components/calendar/years-view/years-view.js.map +1 -1
  35. package/components/card/card.actions.d.ts +1 -0
  36. package/components/card/card.actions.js +10 -13
  37. package/components/card/card.actions.js.map +1 -1
  38. package/components/card/card.content.d.ts +1 -0
  39. package/components/card/card.content.js +9 -15
  40. package/components/card/card.content.js.map +1 -1
  41. package/components/card/card.d.ts +1 -0
  42. package/components/card/card.header.d.ts +1 -0
  43. package/components/card/card.header.js +9 -15
  44. package/components/card/card.header.js.map +1 -1
  45. package/components/card/card.js +11 -14
  46. package/components/card/card.js.map +1 -1
  47. package/components/card/card.media.js +1 -1
  48. package/components/card/card.media.js.map +1 -1
  49. package/components/carousel/carousel-indicator-container.d.ts +1 -0
  50. package/components/carousel/carousel-indicator-container.js +9 -18
  51. package/components/carousel/carousel-indicator-container.js.map +1 -1
  52. package/components/carousel/carousel-indicator.d.ts +5 -7
  53. package/components/carousel/carousel-indicator.js +19 -19
  54. package/components/carousel/carousel-indicator.js.map +1 -1
  55. package/components/carousel/carousel-slide.d.ts +2 -3
  56. package/components/carousel/carousel-slide.js +17 -11
  57. package/components/carousel/carousel-slide.js.map +1 -1
  58. package/components/carousel/carousel.d.ts +0 -1
  59. package/components/carousel/carousel.js +22 -21
  60. package/components/carousel/carousel.js.map +1 -1
  61. package/components/checkbox/checkbox-base.js.map +1 -1
  62. package/components/checkbox/checkbox.d.ts +1 -1
  63. package/components/checkbox/checkbox.js +11 -15
  64. package/components/checkbox/checkbox.js.map +1 -1
  65. package/components/checkbox/switch.d.ts +1 -0
  66. package/components/checkbox/switch.js +10 -19
  67. package/components/checkbox/switch.js.map +1 -1
  68. package/components/checkbox/validators.js.map +1 -1
  69. package/components/chip/chip.js +7 -10
  70. package/components/chip/chip.js.map +1 -1
  71. package/components/combo/combo-header.d.ts +1 -0
  72. package/components/combo/combo-header.js +9 -15
  73. package/components/combo/combo-header.js.map +1 -1
  74. package/components/combo/combo-item.d.ts +4 -5
  75. package/components/combo/combo-item.js +22 -23
  76. package/components/combo/combo-item.js.map +1 -1
  77. package/components/combo/combo.d.ts +1 -1
  78. package/components/combo/combo.js +16 -16
  79. package/components/combo/combo.js.map +1 -1
  80. package/components/common/abort-handler.d.ts +39 -0
  81. package/components/common/abort-handler.js +19 -0
  82. package/components/common/abort-handler.js.map +1 -0
  83. package/components/common/controllers/drag.d.ts +3 -2
  84. package/components/common/controllers/drag.js +7 -6
  85. package/components/common/controllers/drag.js.map +1 -1
  86. package/components/common/controllers/focus-ring.d.ts +1 -0
  87. package/components/common/controllers/focus-ring.js +5 -4
  88. package/components/common/controllers/focus-ring.js.map +1 -1
  89. package/components/common/controllers/gestures.d.ts +6 -2
  90. package/components/common/controllers/gestures.js +15 -11
  91. package/components/common/controllers/gestures.js.map +1 -1
  92. package/components/common/controllers/internals.d.ts +33 -0
  93. package/components/common/controllers/internals.js +25 -0
  94. package/components/common/controllers/internals.js.map +1 -0
  95. package/components/common/controllers/key-bindings.d.ts +1 -0
  96. package/components/common/controllers/key-bindings.js +6 -4
  97. package/components/common/controllers/key-bindings.js.map +1 -1
  98. package/components/common/controllers/mutation-observer.d.ts +25 -15
  99. package/components/common/controllers/mutation-observer.js +23 -12
  100. package/components/common/controllers/mutation-observer.js.map +1 -1
  101. package/components/common/controllers/resize-observer.js.map +1 -1
  102. package/components/common/controllers/root-click.d.ts +58 -13
  103. package/components/common/controllers/root-click.js +47 -35
  104. package/components/common/controllers/root-click.js.map +1 -1
  105. package/components/common/decorators/shadow-options.d.ts +10 -0
  106. package/components/common/decorators/shadow-options.js +10 -0
  107. package/components/common/decorators/shadow-options.js.map +1 -0
  108. package/components/common/definitions/defineAllComponents.js +12 -12
  109. package/components/common/definitions/defineAllComponents.js.map +1 -1
  110. package/components/common/mixins/alert.d.ts +1 -2
  111. package/components/common/mixins/alert.js +13 -9
  112. package/components/common/mixins/alert.js.map +1 -1
  113. package/components/common/mixins/combo-box.d.ts +2 -1
  114. package/components/common/mixins/combo-box.js +0 -2
  115. package/components/common/mixins/combo-box.js.map +1 -1
  116. package/components/common/mixins/forms/associated.js +2 -2
  117. package/components/common/mixins/forms/associated.js.map +1 -1
  118. package/components/common/mixins/option.d.ts +1 -2
  119. package/components/common/mixins/option.js +13 -11
  120. package/components/common/mixins/option.js.map +1 -1
  121. package/components/common/part-map.js +1 -1
  122. package/components/common/part-map.js.map +1 -1
  123. package/components/common/util.d.ts +9 -0
  124. package/components/common/util.js +9 -1
  125. package/components/common/util.js.map +1 -1
  126. package/components/date-picker/date-picker.d.ts +2 -7
  127. package/components/date-picker/date-picker.js +18 -19
  128. package/components/date-picker/date-picker.js.map +1 -1
  129. package/components/date-picker/validators.js.map +1 -1
  130. package/components/date-range-picker/date-range-picker.d.ts +3 -8
  131. package/components/date-range-picker/date-range-picker.js +16 -17
  132. package/components/date-range-picker/date-range-picker.js.map +1 -1
  133. package/components/date-range-picker/predefined-ranges-area.d.ts +1 -0
  134. package/components/date-range-picker/predefined-ranges-area.js +10 -13
  135. package/components/date-range-picker/predefined-ranges-area.js.map +1 -1
  136. package/components/date-time-input/date-time-input.js.map +1 -1
  137. package/components/date-time-input/validators.js.map +1 -1
  138. package/components/dialog/dialog.d.ts +1 -0
  139. package/components/dialog/dialog.js +13 -13
  140. package/components/dialog/dialog.js.map +1 -1
  141. package/components/divider/divider.d.ts +5 -2
  142. package/components/divider/divider.js +17 -18
  143. package/components/divider/divider.js.map +1 -1
  144. package/components/dropdown/dropdown-group.d.ts +0 -1
  145. package/components/dropdown/dropdown-group.js +13 -12
  146. package/components/dropdown/dropdown-group.js.map +1 -1
  147. package/components/dropdown/dropdown-header.d.ts +1 -0
  148. package/components/dropdown/dropdown-header.js +9 -15
  149. package/components/dropdown/dropdown-header.js.map +1 -1
  150. package/components/dropdown/dropdown-item.d.ts +1 -0
  151. package/components/dropdown/dropdown-item.js +8 -14
  152. package/components/dropdown/dropdown-item.js.map +1 -1
  153. package/components/dropdown/dropdown.d.ts +2 -1
  154. package/components/dropdown/dropdown.js +7 -4
  155. package/components/dropdown/dropdown.js.map +1 -1
  156. package/components/dropdown/themes/item.js +7 -0
  157. package/components/dropdown/themes/item.js.map +1 -1
  158. package/components/dropdown/themes/shared/item/dropdown-item.bootstrap.css.d.ts +1 -0
  159. package/components/dropdown/themes/shared/item/dropdown-item.bootstrap.css.js +3 -0
  160. package/components/dropdown/themes/shared/item/dropdown-item.bootstrap.css.js.map +1 -0
  161. package/components/expansion-panel/expansion-panel.js +8 -11
  162. package/components/expansion-panel/expansion-panel.js.map +1 -1
  163. package/components/file-input/file-input.d.ts +1 -1
  164. package/components/file-input/file-input.js +18 -21
  165. package/components/file-input/file-input.js.map +1 -1
  166. package/components/file-input/themes/shared/file-input.material.css.js +1 -1
  167. package/components/file-input/themes/shared/file-input.material.css.js.map +1 -1
  168. package/components/file-input/validators.js.map +1 -1
  169. package/components/focus-trap/focus-trap.js +4 -4
  170. package/components/focus-trap/focus-trap.js.map +1 -1
  171. package/components/icon/icon.d.ts +2 -1
  172. package/components/icon/icon.js +18 -15
  173. package/components/icon/icon.js.map +1 -1
  174. package/components/input/input-base.d.ts +2 -8
  175. package/components/input/input-base.js +8 -11
  176. package/components/input/input-base.js.map +1 -1
  177. package/components/input/input.js.map +1 -1
  178. package/components/input/themes/shared/input.material.css.js +1 -1
  179. package/components/input/themes/shared/input.material.css.js.map +1 -1
  180. package/components/input/validators.js.map +1 -1
  181. package/components/list/list-header.d.ts +0 -1
  182. package/components/list/list-header.js +10 -17
  183. package/components/list/list-header.js.map +1 -1
  184. package/components/list/list-item.d.ts +0 -1
  185. package/components/list/list-item.js +13 -12
  186. package/components/list/list-item.js.map +1 -1
  187. package/components/list/list.d.ts +0 -1
  188. package/components/list/list.js +12 -17
  189. package/components/list/list.js.map +1 -1
  190. package/components/mask-input/mask-input.js.map +1 -1
  191. package/components/mask-input/validators.js.map +1 -1
  192. package/components/nav-drawer/nav-drawer-header-item.d.ts +1 -0
  193. package/components/nav-drawer/nav-drawer-header-item.js +9 -15
  194. package/components/nav-drawer/nav-drawer-header-item.js.map +1 -1
  195. package/components/nav-drawer/nav-drawer-item.d.ts +1 -0
  196. package/components/nav-drawer/nav-drawer-item.js +10 -13
  197. package/components/nav-drawer/nav-drawer-item.js.map +1 -1
  198. package/components/nav-drawer/nav-drawer.d.ts +1 -0
  199. package/components/nav-drawer/nav-drawer.js +10 -13
  200. package/components/nav-drawer/nav-drawer.js.map +1 -1
  201. package/components/navbar/navbar.d.ts +1 -0
  202. package/components/navbar/navbar.js +9 -15
  203. package/components/navbar/navbar.js.map +1 -1
  204. package/components/popover/popover.js +1 -1
  205. package/components/popover/popover.js.map +1 -1
  206. package/components/progress/base.d.ts +1 -2
  207. package/components/progress/base.js +28 -26
  208. package/components/progress/base.js.map +1 -1
  209. package/components/progress/circular-progress.d.ts +1 -0
  210. package/components/progress/circular-progress.js +10 -13
  211. package/components/progress/circular-progress.js.map +1 -1
  212. package/components/progress/linear-progress.d.ts +1 -0
  213. package/components/progress/linear-progress.js +9 -12
  214. package/components/progress/linear-progress.js.map +1 -1
  215. package/components/radio/radio.js +8 -11
  216. package/components/radio/radio.js.map +1 -1
  217. package/components/radio/utils.js.map +1 -1
  218. package/components/radio-group/radio-group.d.ts +1 -1
  219. package/components/radio-group/radio-group.js +15 -17
  220. package/components/radio-group/radio-group.js.map +1 -1
  221. package/components/rating/rating-symbol.js +1 -1
  222. package/components/rating/rating-symbol.js.map +1 -1
  223. package/components/rating/rating.js +7 -10
  224. package/components/rating/rating.js.map +1 -1
  225. package/components/resize-container/resize-container.js +7 -10
  226. package/components/resize-container/resize-container.js.map +1 -1
  227. package/components/resize-container/resize-controller.d.ts +3 -2
  228. package/components/resize-container/resize-controller.js +6 -4
  229. package/components/resize-container/resize-controller.js.map +1 -1
  230. package/components/ripple/ripple.js +3 -2
  231. package/components/ripple/ripple.js.map +1 -1
  232. package/components/select/select-group.d.ts +1 -1
  233. package/components/select/select-group.js +15 -14
  234. package/components/select/select-group.js.map +1 -1
  235. package/components/select/select-header.d.ts +1 -0
  236. package/components/select/select-header.js +9 -15
  237. package/components/select/select-header.js.map +1 -1
  238. package/components/select/select-item.d.ts +1 -0
  239. package/components/select/select-item.js +9 -9
  240. package/components/select/select-item.js.map +1 -1
  241. package/components/select/select.d.ts +1 -0
  242. package/components/select/select.js +11 -8
  243. package/components/select/select.js.map +1 -1
  244. package/components/select/validators.js.map +1 -1
  245. package/components/slider/slider-base.js +8 -8
  246. package/components/slider/slider-base.js.map +1 -1
  247. package/components/slider/slider-label.js +1 -1
  248. package/components/slider/slider-label.js.map +1 -1
  249. package/components/slider/slider.js.map +1 -1
  250. package/components/snackbar/snackbar.d.ts +1 -0
  251. package/components/snackbar/snackbar.js +9 -12
  252. package/components/snackbar/snackbar.js.map +1 -1
  253. package/components/stepper/step.d.ts +1 -0
  254. package/components/stepper/step.js +10 -13
  255. package/components/stepper/step.js.map +1 -1
  256. package/components/stepper/stepper.js +10 -13
  257. package/components/stepper/stepper.js.map +1 -1
  258. package/components/tabs/tab.d.ts +1 -0
  259. package/components/tabs/tab.js +12 -15
  260. package/components/tabs/tab.js.map +1 -1
  261. package/components/tabs/tabs.js +10 -13
  262. package/components/tabs/tabs.js.map +1 -1
  263. package/components/textarea/textarea.d.ts +2 -8
  264. package/components/textarea/textarea.js +11 -14
  265. package/components/textarea/textarea.js.map +1 -1
  266. package/components/textarea/themes/shared/textarea.material.css.js +1 -1
  267. package/components/textarea/themes/shared/textarea.material.css.js.map +1 -1
  268. package/components/textarea/validators.js.map +1 -1
  269. package/components/tile-manager/position.d.ts +1 -1
  270. package/components/tile-manager/position.js.map +1 -1
  271. package/components/tile-manager/themes/container.js.map +1 -1
  272. package/components/tile-manager/tile-manager.d.ts +0 -1
  273. package/components/tile-manager/tile-manager.js +5 -7
  274. package/components/tile-manager/tile-manager.js.map +1 -1
  275. package/components/tile-manager/tile.d.ts +1 -0
  276. package/components/tile-manager/tile.js +54 -57
  277. package/components/tile-manager/tile.js.map +1 -1
  278. package/components/toast/toast.d.ts +1 -0
  279. package/components/toast/toast.js +8 -17
  280. package/components/toast/toast.js.map +1 -1
  281. package/components/tooltip/controller.d.ts +2 -4
  282. package/components/tooltip/controller.js +11 -20
  283. package/components/tooltip/controller.js.map +1 -1
  284. package/components/tooltip/themes/themes.js +1 -1
  285. package/components/tooltip/themes/themes.js.map +1 -1
  286. package/components/tooltip/tooltip.js +17 -16
  287. package/components/tooltip/tooltip.js.map +1 -1
  288. package/components/tree/tree-item.d.ts +1 -0
  289. package/components/tree/tree-item.js +30 -33
  290. package/components/tree/tree-item.js.map +1 -1
  291. package/components/tree/tree.d.ts +1 -1
  292. package/components/tree/tree.js +6 -5
  293. package/components/tree/tree.js.map +1 -1
  294. package/components/tree/tree.navigation.d.ts +1 -1
  295. package/components/tree/tree.navigation.js.map +1 -1
  296. package/components/tree/tree.selection.d.ts +1 -1
  297. package/components/tree/tree.selection.js.map +1 -1
  298. package/components/validation-container/themes/themes.js.map +1 -1
  299. package/components/validation-container/validation-container.d.ts +2 -1
  300. package/components/validation-container/validation-container.js +13 -16
  301. package/components/validation-container/validation-container.js.map +1 -1
  302. package/custom-elements.json +1641 -1753
  303. package/igniteui-webcomponents.html-data.json +1 -1
  304. package/package.json +1 -1
  305. package/theming/config.d.ts +3 -3
  306. package/theming/config.js +14 -18
  307. package/theming/config.js.map +1 -1
  308. package/theming/theming-controller.d.ts +17 -13
  309. package/theming/theming-controller.js +29 -23
  310. package/theming/theming-controller.js.map +1 -1
  311. package/theming/theming-event.d.ts +1 -0
  312. package/theming/theming-event.js.map +1 -1
  313. package/theming/types.d.ts +3 -14
  314. package/theming/types.js.map +1 -1
  315. package/theming/utils.js +24 -23
  316. package/theming/utils.js.map +1 -1
  317. package/web-types.json +1 -1
  318. package/theming/theming-decorator.d.ts +0 -43
  319. package/theming/theming-decorator.js +0 -25
  320. package/theming/theming-decorator.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "igniteui-webcomponents",
3
- "version": "6.1.0",
3
+ "version": "6.1.1",
4
4
  "description": "Ignite UI for Web Components is a complete library of UI components, giving you the ability to build modern web applications using encapsulation and the concept of reusable components in a dependency-free approach.",
5
5
  "author": "Infragistics",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -1,9 +1,9 @@
1
1
  import type { Theme, ThemeVariant } from './types.js';
2
- export declare const getTheme: () => {
2
+ export declare function getTheme(): {
3
3
  theme: Theme;
4
4
  themeVariant: ThemeVariant;
5
5
  };
6
- export declare const setTheme: (value: Theme, variant: ThemeVariant) => void;
6
+ export declare function setTheme(value: Theme, variant: ThemeVariant): void;
7
7
  /**
8
8
  * Allows the global configuration of the active theme.
9
9
  *
@@ -14,4 +14,4 @@ export declare const setTheme: (value: Theme, variant: ThemeVariant) => void;
14
14
  * configureTheme('material', 'light');
15
15
  * ```
16
16
  */
17
- export declare const configureTheme: (t: Theme, v?: ThemeVariant) => void;
17
+ export declare function configureTheme(t: Theme, v?: ThemeVariant): void;
package/theming/config.js CHANGED
@@ -1,10 +1,10 @@
1
- import { isDefined } from '../components/common/util.js';
1
+ import { isServer } from 'lit';
2
2
  import { CHANGE_THEME_EVENT, } from './theming-event.js';
3
3
  import { getAllCssVariables } from './utils.js';
4
4
  let theme;
5
5
  let themeVariant;
6
6
  function dispatchThemingEvent(detail) {
7
- if (isDefined(globalThis.dispatchEvent)) {
7
+ if (!isServer) {
8
8
  globalThis.dispatchEvent(new CustomEvent(CHANGE_THEME_EVENT, { detail }));
9
9
  }
10
10
  }
@@ -14,28 +14,24 @@ function isOfTypeTheme(theme) {
14
14
  function isOfTypeThemeVariant(variant) {
15
15
  return ['light', 'dark'].includes(variant);
16
16
  }
17
- export const getTheme = () => {
17
+ export function getTheme() {
18
18
  if (!(theme && themeVariant)) {
19
- const [_theme, _variant] = Object.entries(getAllCssVariables()).filter(([v]) => v === 'igTheme' || v === 'igThemeVariant') || [];
20
- theme =
21
- _theme?.[1] && isOfTypeTheme(_theme[1])
22
- ? _theme[1]
23
- : 'bootstrap';
24
- themeVariant =
25
- _variant?.[1] && isOfTypeThemeVariant(_variant[1])
26
- ? _variant[1]
27
- : 'light';
19
+ const cssVars = getAllCssVariables();
20
+ const foundTheme = cssVars.igTheme;
21
+ const foundVariant = cssVars.igThemeVariant;
22
+ theme = isOfTypeTheme(foundTheme) ? foundTheme : 'bootstrap';
23
+ themeVariant = isOfTypeThemeVariant(foundVariant) ? foundVariant : 'light';
28
24
  }
29
25
  return { theme, themeVariant };
30
- };
31
- export const setTheme = (value, variant) => {
26
+ }
27
+ export function setTheme(value, variant) {
32
28
  theme = value;
33
29
  themeVariant = variant;
34
- };
35
- export const configureTheme = (t, v = 'light') => {
30
+ }
31
+ export function configureTheme(t, v = 'light') {
36
32
  if (isOfTypeTheme(t) && isOfTypeThemeVariant(v)) {
37
33
  setTheme(t, v);
34
+ dispatchThemingEvent({ theme, themeVariant });
38
35
  }
39
- dispatchThemingEvent({ theme, themeVariant });
40
- };
36
+ }
41
37
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/theming/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EACL,kBAAkB,GAEnB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,IAAI,KAAY,CAAC;AACjB,IAAI,YAA0B,CAAC;AAK/B,SAAS,oBAAoB,CAAC,MAA8B;IAC1D,IAAI,SAAS,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;QACxC,UAAU,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,kBAAkB,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IAC5E,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,KAAa;IAClC,OAAO,CAAC,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACvE,CAAC;AAED,SAAS,oBAAoB,CAAC,OAAe;IAC3C,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,CAAC,MAAM,QAAQ,GAGjB,GAAG,EAAE;IACP,IAAI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} from './theming-event.js';\nimport type { Theme, ThemeVariant } from './types.js';\nimport { getAllCssVariables } from './utils.js';\n\nlet theme: Theme;\nlet themeVariant: ThemeVariant;\n\n/**\n * Dispatch an \"igc-change-theme\" event to `window` with the given detail.\n */\nfunction dispatchThemingEvent(detail: ChangeThemeEventDetail) {\n if (isDefined(globalThis.dispatchEvent)) {\n globalThis.dispatchEvent(new CustomEvent(CHANGE_THEME_EVENT, { detail }));\n }\n}\n\nfunction isOfTypeTheme(theme: string): theme is Theme {\n return ['bootstrap', 'material', 'indigo', 'fluent'].includes(theme);\n}\n\nfunction isOfTypeThemeVariant(variant: string): variant is ThemeVariant {\n return ['light', 'dark'].includes(variant);\n}\n\nexport const getTheme: () => {\n theme: Theme;\n themeVariant: ThemeVariant;\n} = () => {\n if (!(theme && themeVariant)) {\n const [_theme, _variant] =\n Object.entries(getAllCssVariables()).filter(\n ([v]) => v === 'igTheme' || v === 'igThemeVariant'\n ) || [];\n\n theme =\n _theme?.[1] && isOfTypeTheme(_theme[1])\n ? (_theme[1] as Theme)\n : 'bootstrap';\n\n themeVariant =\n _variant?.[1] && isOfTypeThemeVariant(_variant[1])\n ? (_variant[1] as ThemeVariant)\n : 'light';\n }\n\n return { theme, themeVariant };\n};\n\nexport const setTheme = (value: Theme, variant: ThemeVariant) => {\n theme = value;\n themeVariant = variant;\n};\n\n/**\n * Allows the global configuration of the active theme.\n *\n * Usage:\n * ```ts\n * import { configureTheme } from 'igniteui-webcomponents';\n *\n * configureTheme('material', 'light');\n * ```\n */\nexport const configureTheme = (t: Theme, v: ThemeVariant = 'light') => {\n if (isOfTypeTheme(t) && isOfTypeThemeVariant(v)) {\n setTheme(t, v);\n }\n\n dispatchThemingEvent({ theme, themeVariant });\n};\n"]}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/theming/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAC/B,OAAO,EACL,kBAAkB,GAEnB,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AAC,CAAQ,EAAE,IAAkB,OAAO;IAChE,IAAI,aAAa,CAAC,CAAC,CAAC,IAAI,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC;QAChD,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACf,oBAAoB,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;IAChD,CAAC;AACH,CAAC","sourcesContent":["import { isServer } from 'lit';\nimport {\n CHANGE_THEME_EVENT,\n type ChangeThemeEventDetail,\n} from './theming-event.js';\nimport type { Theme, ThemeVariant } from './types.js';\nimport { getAllCssVariables } from './utils.js';\n\nlet theme: Theme;\nlet themeVariant: ThemeVariant;\n\n/**\n * Dispatch an \"igc-change-theme\" event to `window` with the given detail.\n */\nfunction dispatchThemingEvent(detail: ChangeThemeEventDetail): void {\n if (!isServer) {\n globalThis.dispatchEvent(new CustomEvent(CHANGE_THEME_EVENT, { detail }));\n }\n}\n\nfunction isOfTypeTheme(theme: string): theme is Theme {\n return ['bootstrap', 'material', 'indigo', 'fluent'].includes(theme);\n}\n\nfunction isOfTypeThemeVariant(variant: string): variant is ThemeVariant {\n return ['light', 'dark'].includes(variant);\n}\n\nexport function getTheme() {\n if (!(theme && themeVariant)) {\n const cssVars = getAllCssVariables();\n const foundTheme = cssVars.igTheme;\n const foundVariant = cssVars.igThemeVariant;\n\n theme = isOfTypeTheme(foundTheme) ? foundTheme : 'bootstrap';\n themeVariant = isOfTypeThemeVariant(foundVariant) ? foundVariant : 'light';\n }\n\n return { theme, themeVariant };\n}\n\nexport function setTheme(value: Theme, variant: ThemeVariant): void {\n theme = value;\n themeVariant = variant;\n}\n\n/**\n * Allows the global configuration of the active theme.\n *\n * Usage:\n * ```ts\n * import { configureTheme } from 'igniteui-webcomponents';\n *\n * configureTheme('material', 'light');\n * ```\n */\nexport function configureTheme(t: Theme, v: ThemeVariant = 'light'): void {\n if (isOfTypeTheme(t) && isOfTypeThemeVariant(v)) {\n setTheme(t, v);\n dispatchThemingEvent({ theme, themeVariant });\n }\n}\n"]}
@@ -1,18 +1,22 @@
1
1
  import { type ReactiveController, type ReactiveControllerHost, type ReactiveElement } from 'lit';
2
- import type { Theme, ThemeChangedCallback, ThemeController, ThemeVariant, Themes } from './types.js';
3
- declare class ThemingController implements ReactiveController, ThemeController {
4
- private themes;
5
- private host;
6
- theme: Theme;
7
- themeVariant: ThemeVariant;
8
- onThemeChanged?: ThemeChangedCallback;
9
- constructor(host: ReactiveControllerHost & ReactiveElement, themes: Themes);
2
+ import type { Theme, Themes, ThemingControllerConfig } from './types.js';
3
+ declare class ThemingController implements ReactiveController {
4
+ private readonly _host;
5
+ private readonly _themes;
6
+ private readonly _options?;
7
+ private _theme;
8
+ private _variant;
9
+ get theme(): Theme;
10
+ constructor(host: ReactiveControllerHost & ReactiveElement, themes: Themes, config?: ThemingControllerConfig);
11
+ /** @internal */
10
12
  hostConnected(): void;
13
+ /** @internal */
11
14
  hostDisconnected(): void;
15
+ /** @internal */
12
16
  handleEvent(): void;
13
- private getStyles;
14
- protected adoptStyles(): void;
15
- private themeChanged;
17
+ private _getStyles;
18
+ protected _adoptStyles(): void;
19
+ private _handleThemeChanged;
16
20
  }
17
- export declare function createThemeController(host: ReactiveControllerHost & ReactiveElement, themes: Themes): ThemingController;
18
- export {};
21
+ export declare function addThemingController(host: ReactiveControllerHost & ReactiveElement, themes: Themes, config?: ThemingControllerConfig): ThemingController;
22
+ export type { ThemingController };
@@ -1,26 +1,32 @@
1
1
  import { adoptStyles, css, } from 'lit';
2
2
  import { getTheme } from './config.js';
3
- import { CHANGED_THEME_EVENT, _themeChangedEmitter } from './theming-event.js';
3
+ import { _themeChangedEmitter, CHANGED_THEME_EVENT } from './theming-event.js';
4
4
  class ThemingController {
5
- constructor(host, themes) {
6
- this.themes = themes;
7
- this.host = host;
8
- this.host.addController(this);
5
+ get theme() {
6
+ return this._theme;
7
+ }
8
+ constructor(host, themes, config) {
9
+ this._theme = 'bootstrap';
10
+ this._variant = 'light';
11
+ this._host = host;
12
+ this._themes = themes;
13
+ this._options = config;
14
+ this._host.addController(this);
9
15
  }
10
16
  hostConnected() {
11
- this.themeChanged();
17
+ this._handleThemeChanged();
12
18
  _themeChangedEmitter.addEventListener(CHANGED_THEME_EVENT, this);
13
19
  }
14
20
  hostDisconnected() {
15
21
  _themeChangedEmitter.removeEventListener(CHANGED_THEME_EVENT, this);
16
22
  }
17
23
  handleEvent() {
18
- this.themeChanged();
24
+ this._handleThemeChanged();
19
25
  }
20
- getStyles() {
21
- const styleSheets = Object.entries(this.themes[this.themeVariant]);
26
+ _getStyles() {
27
+ const props = this._themes[this._variant];
22
28
  const styles = { shared: css ``, theme: css `` };
23
- for (const [name, sheet] of styleSheets) {
29
+ for (const [name, sheet] of Object.entries(props)) {
24
30
  if (name === 'shared') {
25
31
  styles.shared = sheet;
26
32
  }
@@ -30,21 +36,21 @@ class ThemingController {
30
36
  }
31
37
  return styles;
32
38
  }
33
- adoptStyles() {
34
- const { theme, themeVariant } = getTheme();
35
- this.theme = theme;
36
- this.themeVariant = themeVariant;
37
- const ctor = this.host.constructor;
38
- const { shared, theme: _theme } = this.getStyles();
39
- adoptStyles(this.host.shadowRoot, [...ctor.elementStyles, shared, _theme]);
39
+ _adoptStyles() {
40
+ const { theme: currentTheme, themeVariant } = getTheme();
41
+ this._theme = currentTheme;
42
+ this._variant = themeVariant;
43
+ const ctor = this._host.constructor;
44
+ const { shared, theme } = this._getStyles();
45
+ adoptStyles(this._host.shadowRoot, [...ctor.elementStyles, shared, theme]);
40
46
  }
41
- themeChanged() {
42
- this.adoptStyles();
43
- this.onThemeChanged?.call(this.host, this.theme);
44
- this.host.requestUpdate();
47
+ _handleThemeChanged() {
48
+ this._adoptStyles();
49
+ this._options?.themeChange?.call(this._host, this._theme);
50
+ this._host.requestUpdate();
45
51
  }
46
52
  }
47
- export function createThemeController(host, themes) {
48
- return new ThemingController(host, themes);
53
+ export function addThemingController(host, themes, config) {
54
+ return new ThemingController(host, themes, config);
49
55
  }
50
56
  //# sourceMappingURL=theming-controller.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"theming-controller.js","sourceRoot":"","sources":["../../src/theming/theming-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,WAAW,EACX,GAAG,GACJ,MAAM,KAAK,CAAC;AAEb,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAS/E,MAAM,iBAAiB;IAQrB,YAAY,IAA8C,EAAE,MAAc;QACxE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAEM,aAAa;QAClB,IAAI,CAAC,YAAY,EAAE,CAAC;QACpB,oBAAoB,CAAC,gBAAgB,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAC;IACnE,CAAC;IAEM,gBAAgB;QACrB,oBAAoB,CAAC,mBAAmB,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAC;IACtE,CAAC;IAEM,WAAW;QAChB,IAAI,CAAC,YAAY,EAAE,CAAC;IACtB,CAAC;IAEO,SAAS;QACf,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;QACnE,MAAM,MAAM,GAAG,EAAE,MAAM,EAAE,GAAG,CAAA,EAAE,EAAE,KAAK,EAAE,GAAG,CAAA,EAAE,EAAE,CAAC;QAE/C,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,WAAW,EAAE,CAAC;YACxC,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACtB,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC;YACxB,CAAC;YACD,IAAI,IAAI,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC;gBACxB,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;YACvB,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAES,WAAW;QACnB,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,QAAQ,EAAE,CAAC;QAC3C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QAEjC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,WAAgC,CAAC;QACxD,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAEnD,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,UAAW,EAAE,CAAC,GAAG,IAAI,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC9E,CAAC;IAEO,YAAY;QAClB,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QACjD,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;IAC5B,CAAC;CACF;AAED,MAAM,UAAU,qBAAqB,CACnC,IAA8C,EAC9C,MAAc;IAEd,OAAO,IAAI,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import {\n type LitElement,\n type ReactiveController,\n type ReactiveControllerHost,\n type ReactiveElement,\n adoptStyles,\n css,\n} from 'lit';\n\nimport { getTheme } from './config.js';\nimport { CHANGED_THEME_EVENT, _themeChangedEmitter } from './theming-event.js';\nimport type {\n Theme,\n ThemeChangedCallback,\n ThemeController,\n ThemeVariant,\n Themes,\n} from './types.js';\n\nclass ThemingController implements ReactiveController, ThemeController {\n private themes: Themes;\n private host: ReactiveControllerHost & ReactiveElement;\n\n public theme!: Theme;\n public themeVariant!: ThemeVariant;\n public onThemeChanged?: ThemeChangedCallback;\n\n constructor(host: ReactiveControllerHost & ReactiveElement, themes: Themes) {\n this.themes = themes;\n this.host = host;\n this.host.addController(this);\n }\n\n public hostConnected() {\n this.themeChanged();\n _themeChangedEmitter.addEventListener(CHANGED_THEME_EVENT, this);\n }\n\n public hostDisconnected() {\n _themeChangedEmitter.removeEventListener(CHANGED_THEME_EVENT, this);\n }\n\n public handleEvent() {\n this.themeChanged();\n }\n\n private getStyles() {\n const styleSheets = Object.entries(this.themes[this.themeVariant]);\n const styles = { shared: css``, theme: css`` };\n\n for (const [name, sheet] of styleSheets) {\n if (name === 'shared') {\n styles.shared = sheet;\n }\n if (name === this.theme) {\n styles.theme = sheet;\n }\n }\n\n return styles;\n }\n\n protected adoptStyles() {\n const { theme, themeVariant } = getTheme();\n this.theme = theme;\n this.themeVariant = themeVariant;\n\n const ctor = this.host.constructor as typeof LitElement;\n const { shared, theme: _theme } = this.getStyles();\n\n adoptStyles(this.host.shadowRoot!, [...ctor.elementStyles, shared, _theme]);\n }\n\n private themeChanged() {\n this.adoptStyles();\n this.onThemeChanged?.call(this.host, this.theme);\n this.host.requestUpdate();\n }\n}\n\nexport function createThemeController(\n host: ReactiveControllerHost & ReactiveElement,\n themes: Themes\n) {\n return new ThemingController(host, themes);\n}\n"]}
1
+ {"version":3,"file":"theming-controller.js","sourceRoot":"","sources":["../../src/theming/theming-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,GAAG,GAKJ,MAAM,KAAK,CAAC;AAEb,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAQ/E,MAAM,iBAAiB;IAQrB,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,YACE,IAA8C,EAC9C,MAAc,EACd,MAAgC;QAV1B,WAAM,GAAU,WAAW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,CAAC,QAAQ,GAAG,YAAY,CAAC;QAE7B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,WAAgC,CAAC;QACzD,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAE5C,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,UAAW,EAAE,CAAC,GAAG,IAAI,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IAC9E,CAAC;IAEO,mBAAmB;QACzB,IAAI,CAAC,YAAY,EAAE,CAAC;QACpB,IAAI,CAAC,QAAQ,EAAE,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1D,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;IAC7B,CAAC;CACF;AAED,MAAM,UAAU,oBAAoB,CAClC,IAA8C,EAC9C,MAAc,EACd,MAAgC;IAEhC,OAAO,IAAI,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AACrD,CAAC","sourcesContent":["import {\n adoptStyles,\n css,\n type LitElement,\n type ReactiveController,\n type ReactiveControllerHost,\n type ReactiveElement,\n} from 'lit';\n\nimport { getTheme } from './config.js';\nimport { _themeChangedEmitter, CHANGED_THEME_EVENT } from './theming-event.js';\nimport type {\n Theme,\n Themes,\n ThemeVariant,\n ThemingControllerConfig,\n} from './types.js';\n\nclass ThemingController implements ReactiveController {\n private readonly _host: ReactiveControllerHost & ReactiveElement;\n private readonly _themes: Themes;\n private readonly _options?: ThemingControllerConfig;\n\n private _theme: Theme = 'bootstrap';\n private _variant: ThemeVariant = 'light';\n\n public get theme(): Theme {\n return this._theme;\n }\n\n constructor(\n host: ReactiveControllerHost & ReactiveElement,\n themes: Themes,\n config?: ThemingControllerConfig\n ) {\n this._host = host;\n this._themes = themes;\n this._options = config;\n this._host.addController(this);\n }\n\n /** @internal */\n public hostConnected(): void {\n this._handleThemeChanged();\n _themeChangedEmitter.addEventListener(CHANGED_THEME_EVENT, this);\n }\n\n /** @internal */\n public hostDisconnected(): void {\n _themeChangedEmitter.removeEventListener(CHANGED_THEME_EVENT, this);\n }\n\n /** @internal */\n public handleEvent(): void {\n this._handleThemeChanged();\n }\n\n private _getStyles() {\n const props = this._themes[this._variant];\n const styles = { shared: css``, theme: css`` };\n\n for (const [name, sheet] of Object.entries(props)) {\n if (name === 'shared') {\n styles.shared = sheet;\n }\n if (name === this.theme) {\n styles.theme = sheet;\n }\n }\n\n return styles;\n }\n\n protected _adoptStyles(): void {\n const { theme: currentTheme, themeVariant } = getTheme();\n this._theme = currentTheme;\n this._variant = themeVariant;\n\n const ctor = this._host.constructor as typeof LitElement;\n const { shared, theme } = this._getStyles();\n\n adoptStyles(this._host.shadowRoot!, [...ctor.elementStyles, shared, theme]);\n }\n\n private _handleThemeChanged(): void {\n this._adoptStyles();\n this._options?.themeChange?.call(this._host, this._theme);\n this._host.requestUpdate();\n }\n}\n\nexport function addThemingController(\n host: ReactiveControllerHost & ReactiveElement,\n themes: Themes,\n config?: ThemingControllerConfig\n): ThemingController {\n return new ThemingController(host, themes, config);\n}\n\nexport type { ThemingController };\n"]}
@@ -1,6 +1,7 @@
1
1
  import type { Theme, ThemeVariant } from './types.js';
2
2
  declare class ThemeChangedEmitter extends EventTarget {
3
3
  constructor();
4
+ /** @internal */
4
5
  handleEvent(): void;
5
6
  }
6
7
  export declare const CHANGE_THEME_EVENT = "igc-change-theme";
@@ -1 +1 @@
1
- {"version":3,"file":"theming-event.js","sourceRoot":"","sources":["../../src/theming/theming-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAG/B,MAAM,mBAAoB,SAAQ,WAAW;IAC3C;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,UAAU,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;IAEM,WAAW;QAChB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,mBAAmB,CAAC,CAAC,CAAC;IAC3D,CAAC;CACF;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,kBAAkB,CAAC;AACrD,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;AACvD,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,mBAAmB,EAAE,CAAC","sourcesContent":["import { isServer } from 'lit';\nimport type { Theme, ThemeVariant } from './types.js';\n\nclass ThemeChangedEmitter extends EventTarget {\n constructor() {\n super();\n if (!isServer) {\n globalThis.addEventListener(CHANGE_THEME_EVENT, this);\n }\n }\n\n public handleEvent() {\n this.dispatchEvent(new CustomEvent(CHANGED_THEME_EVENT));\n }\n}\n\nexport const CHANGE_THEME_EVENT = 'igc-change-theme';\nexport const CHANGED_THEME_EVENT = 'igc-changed-theme';\nexport const _themeChangedEmitter = new ThemeChangedEmitter();\n\ndeclare global {\n interface WindowEventMap {\n [CHANGE_THEME_EVENT]: CustomEvent<ChangeThemeEventDetail>;\n }\n}\n\n/**\n * The possible details of the \"igc-change-theme\" event.\n */\nexport type ChangeThemeEventDetail = {\n theme: Theme;\n themeVariant: ThemeVariant;\n};\n"]}
1
+ {"version":3,"file":"theming-event.js","sourceRoot":"","sources":["../../src/theming/theming-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAG/B,MAAM,mBAAoB,SAAQ,WAAW;IAC3C;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,UAAU,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;IAGM,WAAW;QAChB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,mBAAmB,CAAC,CAAC,CAAC;IAC3D,CAAC;CACF;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,kBAAkB,CAAC;AACrD,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;AACvD,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,mBAAmB,EAAE,CAAC","sourcesContent":["import { isServer } from 'lit';\nimport type { Theme, ThemeVariant } from './types.js';\n\nclass ThemeChangedEmitter extends EventTarget {\n constructor() {\n super();\n if (!isServer) {\n globalThis.addEventListener(CHANGE_THEME_EVENT, this);\n }\n }\n\n /** @internal */\n public handleEvent(): void {\n this.dispatchEvent(new CustomEvent(CHANGED_THEME_EVENT));\n }\n}\n\nexport const CHANGE_THEME_EVENT = 'igc-change-theme';\nexport const CHANGED_THEME_EVENT = 'igc-changed-theme';\nexport const _themeChangedEmitter = new ThemeChangedEmitter();\n\ndeclare global {\n interface WindowEventMap {\n [CHANGE_THEME_EVENT]: CustomEvent<ChangeThemeEventDetail>;\n }\n}\n\n/**\n * The possible details of the \"igc-change-theme\" event.\n */\nexport type ChangeThemeEventDetail = {\n theme: Theme;\n themeVariant: ThemeVariant;\n};\n"]}
@@ -10,17 +10,6 @@ export type Themes = {
10
10
  };
11
11
  };
12
12
  export type ThemeChangedCallback = (theme: Theme) => unknown;
13
- /**
14
- * A controller responsible for adopting various component themes;
15
- * See also {@link updateWhenThemeChanges}.
16
- */
17
- export interface ThemeController {
18
- /**
19
- * The name of the currently adopted theme. See {@link Theme}.
20
- */
21
- theme: Theme;
22
- /**
23
- * Optional callback function to invoke when the theme is changed at runtime.
24
- */
25
- onThemeChanged?: ThemeChangedCallback;
26
- }
13
+ export type ThemingControllerConfig = {
14
+ themeChange?: ThemeChangedCallback;
15
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/theming/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { CSSResult } from 'lit';\n\nexport type Theme = 'material' | 'bootstrap' | 'indigo' | 'fluent';\nexport type ThemeVariant = 'light' | 'dark';\n\nexport type Themes = {\n light: {\n [K in Theme | 'shared']?: CSSResult;\n };\n dark: {\n [K in Theme | 'shared']?: CSSResult;\n };\n};\n\nexport type ThemeChangedCallback = (theme: Theme) => unknown;\n\n/**\n * A controller responsible for adopting various component themes;\n * See also {@link updateWhenThemeChanges}.\n */\nexport interface ThemeController {\n /**\n * The name of the currently adopted theme. See {@link Theme}.\n */\n theme: Theme;\n\n /**\n * Optional callback function to invoke when the theme is changed at runtime.\n */\n onThemeChanged?: ThemeChangedCallback;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/theming/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { CSSResult } from 'lit';\n\nexport type Theme = 'material' | 'bootstrap' | 'indigo' | 'fluent';\nexport type ThemeVariant = 'light' | 'dark';\n\nexport type Themes = {\n light: {\n [K in Theme | 'shared']?: CSSResult;\n };\n dark: {\n [K in Theme | 'shared']?: CSSResult;\n };\n};\n\nexport type ThemeChangedCallback = (theme: Theme) => unknown;\nexport type ThemingControllerConfig = {\n themeChange?: ThemeChangedCallback;\n};\n"]}
package/theming/utils.js CHANGED
@@ -1,42 +1,43 @@
1
1
  import { isServer } from 'lit';
2
- import { isDefined } from '../components/common/util.js';
3
2
  function isStyleRule(rule) {
4
- return !!rule && 'style' in rule;
3
+ return rule != null && 'style' in rule;
5
4
  }
6
5
  function cssKeyToJsKey(key) {
7
- return key.replace('--', '').replace(/-./g, (x) => x.toUpperCase()[1]);
6
+ return key.replace(/^--|-./g, (match) => {
7
+ return match.startsWith('--') ? '' : match.charAt(1).toUpperCase();
8
+ });
8
9
  }
9
10
  function getAllCssVariableNames() {
10
11
  const cssVars = new Set();
11
- if (isServer || !isDefined(globalThis.document)) {
12
- return cssVars;
13
- }
14
- const styleSheets = Array.from(globalThis.document.styleSheets).filter((sheet) => {
12
+ const styleSheets = Array.from(document.styleSheets);
13
+ for (const sheet of styleSheets) {
14
+ let rules;
15
15
  try {
16
- return sheet.cssRules;
16
+ rules = sheet.cssRules;
17
17
  }
18
18
  catch {
19
- return false;
19
+ continue;
20
20
  }
21
- });
22
- for (const sheet of styleSheets) {
23
- const rules = Array.from(sheet.cssRules).filter(isStyleRule);
24
- for (const rule of rules) {
25
- Array.from(rule.style).forEach((style) => {
26
- if (style.startsWith('--')) {
27
- cssVars.add(style);
21
+ if (!rules) {
22
+ continue;
23
+ }
24
+ for (const rule of Array.from(rules)) {
25
+ if (isStyleRule(rule)) {
26
+ const length = rule.style.length;
27
+ for (let i = 0; i < length; i++) {
28
+ const style = rule.style[i];
29
+ if (style.startsWith('--')) {
30
+ cssVars.add(style);
31
+ }
28
32
  }
29
- });
33
+ }
30
34
  }
31
35
  }
32
36
  return cssVars;
33
37
  }
34
38
  function getElementCssVariables(allCssVars, element, pseudo) {
35
39
  const cssVars = {};
36
- if (!isDefined(globalThis.getComputedStyle)) {
37
- return cssVars;
38
- }
39
- const styles = globalThis.getComputedStyle(element, pseudo);
40
+ const styles = getComputedStyle(element, pseudo);
40
41
  for (const key of allCssVars) {
41
42
  const value = styles.getPropertyValue(key);
42
43
  if (value) {
@@ -46,8 +47,8 @@ function getElementCssVariables(allCssVars, element, pseudo) {
46
47
  return cssVars;
47
48
  }
48
49
  export function getAllCssVariables() {
49
- return isServer || !isDefined(globalThis.document)
50
+ return isServer
50
51
  ? {}
51
- : getElementCssVariables(getAllCssVariableNames(), globalThis.document.documentElement);
52
+ : getElementCssVariables(getAllCssVariableNames(), document.documentElement);
52
53
  }
53
54
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/theming/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAE/B,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD,SAAS,WAAW,CAAC,IAAa;IAChC,OAAO,CAAC,CAAC,IAAI,IAAI,OAAO,IAAI,IAAI,CAAC;AACnC,CAAC;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e;IAEf,MAAM,OAAO,GAA2B,EAAE,CAAC;IAG3C,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAC5C,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,MAAM,GAAG,UAAU,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAE5D,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAE3C,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;QAC7C,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,kBAAkB;IAEhC,OAAO,QAAQ,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,QAAQ,CAAC;QAChD,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,sBAAsB,CACpB,sBAAsB,EAAE,EACxB,UAAU,CAAC,QAAQ,CAAC,eAAe,CACpC,CAAC;AACR,CAAC","sourcesContent":["import { isServer } from 'lit';\n\nimport { isDefined } from '../components/common/util.js';\n\nfunction isStyleRule(rule: CSSRule): rule is CSSStyleRule {\n return !!rule && 'style' in rule;\n}\n\nfunction cssKeyToJsKey(key: string): string {\n return key.replace('--', '').replace(/-./g, (x) => x.toUpperCase()[1]);\n}\n\nfunction getAllCssVariableNames(): Set<string> {\n const cssVars = new Set<string>();\n\n /* c8 ignore next 3 */\n if (isServer || !isDefined(globalThis.document)) {\n return cssVars;\n }\n\n // Filter out any external stylesheets which throw CORS errors\n const styleSheets = Array.from(globalThis.document.styleSheets).filter(\n (sheet) => {\n try {\n return sheet.cssRules;\n } catch {\n return false;\n }\n }\n );\n\n for (const sheet of styleSheets) {\n const rules = Array.from(sheet.cssRules).filter(isStyleRule);\n\n for (const rule of rules) {\n Array.from(rule.style).forEach((style) => {\n if (style.startsWith('--')) {\n cssVars.add(style);\n }\n });\n }\n }\n\n return cssVars;\n}\n\nfunction getElementCssVariables(\n allCssVars: Set<string>,\n element: HTMLElement,\n pseudo?: string\n): Record<string, string> {\n const cssVars: Record<string, string> = {};\n\n /* c8 ignore next 3 */\n if (!isDefined(globalThis.getComputedStyle)) {\n return cssVars;\n }\n\n const styles = globalThis.getComputedStyle(element, pseudo);\n\n for (const key of allCssVars) {\n const value = styles.getPropertyValue(key);\n\n if (value) {\n cssVars[cssKeyToJsKey(key)] = value.trim();\n }\n }\n\n return cssVars;\n}\n\nexport function getAllCssVariables(): Record<string, string> {\n /* c8 ignore next 2 */\n return isServer || !isDefined(globalThis.document)\n ? {}\n : getElementCssVariables(\n getAllCssVariableNames(),\n globalThis.document.documentElement\n );\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/theming/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAE/B,SAAS,WAAW,CAAC,IAAa;IAChC,OAAO,IAAI,IAAI,IAAI,IAAI,OAAO,IAAI,IAAI,CAAC;AACzC,CAAC;AAED,SAAS,aAAa,CAAC,GAAW;IAChC,OAAO,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;QACtC,OAAO,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IACrE,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,sBAAsB;IAC7B,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAErD,KAAK,MAAM,KAAK,IAAI,WAAW,EAAE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AAkB;IAEhC,OAAO,QAAQ;QACb,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,sBAAsB,CACpB,sBAAsB,EAAE,EACxB,QAAQ,CAAC,eAAe,CACzB,CAAC;AACR,CAAC","sourcesContent":["import { isServer } from 'lit';\n\nfunction isStyleRule(rule: CSSRule): rule is CSSStyleRule {\n return rule != null && 'style' in rule;\n}\n\nfunction cssKeyToJsKey(key: string): string {\n return key.replace(/^--|-./g, (match) => {\n return match.startsWith('--') ? '' : match.charAt(1).toUpperCase();\n });\n}\n\nfunction getAllCssVariableNames(): Set<string> {\n const cssVars = new Set<string>();\n const styleSheets = Array.from(document.styleSheets);\n\n for (const sheet of styleSheets) {\n let rules: CSSRuleList | undefined;\n\n // Potential CORS or access errors\n try {\n rules = sheet.cssRules;\n } catch {\n continue;\n }\n\n if (!rules) {\n continue;\n }\n\n for (const rule of Array.from(rules)) {\n if (isStyleRule(rule)) {\n const length = rule.style.length;\n\n for (let i = 0; i < length; i++) {\n const style = rule.style[i];\n\n if (style.startsWith('--')) {\n cssVars.add(style);\n }\n }\n }\n }\n }\n\n return cssVars;\n}\n\nfunction getElementCssVariables(\n allCssVars: Set<string>,\n element: HTMLElement,\n pseudo?: string\n): Record<string, string> {\n const cssVars: Record<string, string> = {};\n const styles = getComputedStyle(element, pseudo);\n\n for (const key of allCssVars) {\n const value = styles.getPropertyValue(key);\n\n if (value) {\n cssVars[cssKeyToJsKey(key)] = value.trim();\n }\n }\n\n return cssVars;\n}\n\nexport function getAllCssVariables(): Record<string, string> {\n /* c8 ignore next 2 */\n return isServer\n ? {}\n : getElementCssVariables(\n getAllCssVariableNames(),\n document.documentElement\n );\n}\n"]}