igniteui-webcomponents 3.3.0-beta.0 → 3.4.0-beta.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.
Files changed (265) hide show
  1. package/CHANGELOG.md +45 -20
  2. package/README.md +7 -2
  3. package/components/accordion/accordion.d.ts +36 -0
  4. package/components/accordion/accordion.js +129 -0
  5. package/components/accordion/accordion.js.map +1 -0
  6. package/components/accordion/themes/accordion.base.css.d.ts +1 -0
  7. package/components/accordion/themes/accordion.base.css.js +3 -0
  8. package/components/accordion/themes/accordion.base.css.js.map +1 -0
  9. package/components/button/button-base.js +7 -2
  10. package/components/button/button-base.js.map +1 -1
  11. package/components/button/icon-button.d.ts +0 -1
  12. package/components/button/icon-button.js +3 -1
  13. package/components/button/icon-button.js.map +1 -1
  14. package/components/button/themes/button/light/button.base.css.js +1 -1
  15. package/components/button/themes/button/light/button.base.css.js.map +1 -1
  16. package/components/button/themes/button/light/button.material.css.js +1 -1
  17. package/components/button/themes/button/light/button.material.css.js.map +1 -1
  18. package/components/calendar/calendar.d.ts +0 -4
  19. package/components/calendar/calendar.js +6 -4
  20. package/components/calendar/calendar.js.map +1 -1
  21. package/components/calendar/common/calendar-base.js +3 -1
  22. package/components/calendar/common/calendar-base.js.map +1 -1
  23. package/components/calendar/common/calendar.model.js.map +1 -1
  24. package/components/calendar/days-view/days-view.d.ts +3 -0
  25. package/components/calendar/days-view/days-view.js +19 -7
  26. package/components/calendar/days-view/days-view.js.map +1 -1
  27. package/components/calendar/months-view/months-view.d.ts +1 -0
  28. package/components/calendar/months-view/months-view.js +2 -2
  29. package/components/calendar/months-view/months-view.js.map +1 -1
  30. package/components/calendar/years-view/years-view.d.ts +1 -0
  31. package/components/calendar/years-view/years-view.js +2 -2
  32. package/components/calendar/years-view/years-view.js.map +1 -1
  33. package/components/card/card.js +6 -0
  34. package/components/card/card.js.map +1 -1
  35. package/components/checkbox/checkbox-base.js +7 -2
  36. package/components/checkbox/checkbox-base.js.map +1 -1
  37. package/components/checkbox/checkbox.d.ts +1 -0
  38. package/components/checkbox/checkbox.js +6 -5
  39. package/components/checkbox/checkbox.js.map +1 -1
  40. package/components/checkbox/switch.d.ts +1 -0
  41. package/components/checkbox/switch.js +6 -5
  42. package/components/checkbox/switch.js.map +1 -1
  43. package/components/chip/chip.d.ts +1 -1
  44. package/components/chip/chip.js +12 -1
  45. package/components/chip/chip.js.map +1 -1
  46. package/components/common/decorators/blazorAdditionalDependencies.d.ts +5 -0
  47. package/components/common/decorators/blazorAdditionalDependencies.js +6 -0
  48. package/components/common/decorators/blazorAdditionalDependencies.js.map +1 -0
  49. package/components/common/decorators/blazorDeepImport.d.ts +4 -0
  50. package/components/common/decorators/blazorDeepImport.js +2 -0
  51. package/components/common/decorators/blazorDeepImport.js.map +1 -0
  52. package/components/common/decorators/index.d.ts +1 -0
  53. package/components/common/decorators/index.js +1 -0
  54. package/components/common/decorators/index.js.map +1 -1
  55. package/components/common/definitions/defineAllComponents.js +2 -0
  56. package/components/common/definitions/defineAllComponents.js.map +1 -1
  57. package/components/common/i18n/calendar.resources.js.map +1 -1
  58. package/components/common/types.d.ts +1 -0
  59. package/components/common/types.js +2 -0
  60. package/components/common/types.js.map +1 -0
  61. package/components/common/util.d.ts +2 -1
  62. package/components/common/util.js +5 -2
  63. package/components/common/util.js.map +1 -1
  64. package/components/date-time-input/date-time-input.d.ts +2 -0
  65. package/components/date-time-input/date-time-input.js +12 -2
  66. package/components/date-time-input/date-time-input.js.map +1 -1
  67. package/components/dialog/dialog.d.ts +69 -0
  68. package/components/dialog/dialog.js +168 -0
  69. package/components/dialog/dialog.js.map +1 -0
  70. package/components/dialog/themes/light/dialog.base.css.d.ts +1 -0
  71. package/components/dialog/themes/light/dialog.base.css.js +3 -0
  72. package/components/dialog/themes/light/dialog.base.css.js.map +1 -0
  73. package/components/dialog/themes/light/dialog.bootstrap.css.d.ts +1 -0
  74. package/components/dialog/themes/light/dialog.bootstrap.css.js +3 -0
  75. package/components/dialog/themes/light/dialog.bootstrap.css.js.map +1 -0
  76. package/components/dialog/themes/light/dialog.fluent.css.d.ts +1 -0
  77. package/components/dialog/themes/light/dialog.fluent.css.js +3 -0
  78. package/components/dialog/themes/light/dialog.fluent.css.js.map +1 -0
  79. package/components/dialog/themes/light/dialog.indigo.css.d.ts +1 -0
  80. package/components/dialog/themes/light/dialog.indigo.css.js +3 -0
  81. package/components/dialog/themes/light/dialog.indigo.css.js.map +1 -0
  82. package/components/dialog/themes/light/dialog.material.css.d.ts +1 -0
  83. package/components/dialog/themes/light/dialog.material.css.js +3 -0
  84. package/components/dialog/themes/light/dialog.material.css.js.map +1 -0
  85. package/components/dropdown/dropdown-group.d.ts +4 -3
  86. package/components/dropdown/dropdown-group.js +8 -11
  87. package/components/dropdown/dropdown-group.js.map +1 -1
  88. package/components/dropdown/dropdown-header.d.ts +1 -1
  89. package/components/dropdown/dropdown-header.js.map +1 -1
  90. package/components/dropdown/dropdown-item.d.ts +1 -1
  91. package/components/dropdown/dropdown-item.js.map +1 -1
  92. package/components/dropdown/dropdown.d.ts +34 -28
  93. package/components/dropdown/dropdown.js +76 -87
  94. package/components/dropdown/dropdown.js.map +1 -1
  95. package/components/dropdown/themes/light/dropdown-group.base.css.js +1 -1
  96. package/components/dropdown/themes/light/dropdown-group.base.css.js.map +1 -1
  97. package/components/dropdown/themes/light/dropdown-group.fluent.css.js +1 -1
  98. package/components/dropdown/themes/light/dropdown-group.fluent.css.js.map +1 -1
  99. package/components/dropdown/themes/light/dropdown-item.base.css.js +1 -1
  100. package/components/dropdown/themes/light/dropdown-item.base.css.js.map +1 -1
  101. package/components/dropdown/themes/light/dropdown.base.css.js +1 -1
  102. package/components/dropdown/themes/light/dropdown.base.css.js.map +1 -1
  103. package/components/dropdown/themes/light/dropdown.fluent.css.js +1 -1
  104. package/components/dropdown/themes/light/dropdown.fluent.css.js.map +1 -1
  105. package/components/expansion-panel/expansion-panel.d.ts +1 -1
  106. package/components/expansion-panel/expansion-panel.js +11 -6
  107. package/components/expansion-panel/expansion-panel.js.map +1 -1
  108. package/components/expansion-panel/themes/light/expansion-panel.base.css.js +1 -1
  109. package/components/expansion-panel/themes/light/expansion-panel.base.css.js.map +1 -1
  110. package/components/form/form.js +4 -3
  111. package/components/form/form.js.map +1 -1
  112. package/components/icon/icon.js +6 -8
  113. package/components/icon/icon.js.map +1 -1
  114. package/components/icon/icon.registry.js +2 -0
  115. package/components/icon/icon.registry.js.map +1 -1
  116. package/components/input/input-base.d.ts +2 -1
  117. package/components/input/input-base.js +9 -6
  118. package/components/input/input-base.js.map +1 -1
  119. package/components/input/input.d.ts +1 -0
  120. package/components/input/input.js +5 -0
  121. package/components/input/input.js.map +1 -1
  122. package/components/input/themes/light/input.base.css.js +1 -1
  123. package/components/input/themes/light/input.base.css.js.map +1 -1
  124. package/components/input/themes/light/input.bootstrap.css.js +1 -1
  125. package/components/input/themes/light/input.bootstrap.css.js.map +1 -1
  126. package/components/input/themes/light/input.fluent.css.js +1 -1
  127. package/components/input/themes/light/input.fluent.css.js.map +1 -1
  128. package/components/input/themes/light/input.indigo.css.js +1 -1
  129. package/components/input/themes/light/input.indigo.css.js.map +1 -1
  130. package/components/list/list.js +4 -0
  131. package/components/list/list.js.map +1 -1
  132. package/components/mask-input/mask-input-base.js +7 -2
  133. package/components/mask-input/mask-input-base.js.map +1 -1
  134. package/components/nav-drawer/nav-drawer.js +4 -0
  135. package/components/nav-drawer/nav-drawer.js.map +1 -1
  136. package/components/progress/circular-progress.d.ts +1 -1
  137. package/components/progress/circular-progress.js +3 -0
  138. package/components/progress/circular-progress.js.map +1 -1
  139. package/components/progress/linear-progress.js +1 -0
  140. package/components/progress/linear-progress.js.map +1 -1
  141. package/components/progress/themes/circular/circular.progress.base.css.js +1 -1
  142. package/components/progress/themes/circular/circular.progress.base.css.js.map +1 -1
  143. package/components/progress/themes/linear/linear.progress.base.css.js +1 -1
  144. package/components/progress/themes/linear/linear.progress.base.css.js.map +1 -1
  145. package/components/progress/themes/linear/linear.progress.bootstrap.css.js +1 -1
  146. package/components/progress/themes/linear/linear.progress.bootstrap.css.js.map +1 -1
  147. package/components/progress/themes/linear/linear.progress.fluent.css.js +1 -1
  148. package/components/progress/themes/linear/linear.progress.fluent.css.js.map +1 -1
  149. package/components/progress/themes/linear/linear.progress.indigo.css.js +1 -1
  150. package/components/progress/themes/linear/linear.progress.indigo.css.js.map +1 -1
  151. package/components/radio/radio.d.ts +1 -0
  152. package/components/radio/radio.js +6 -5
  153. package/components/radio/radio.js.map +1 -1
  154. package/components/radio-group/radio-group.d.ts +0 -1
  155. package/components/radio-group/radio-group.js +7 -6
  156. package/components/radio-group/radio-group.js.map +1 -1
  157. package/components/rating/rating-symbol.base.css.d.ts +1 -0
  158. package/components/rating/rating-symbol.base.css.js +3 -0
  159. package/components/rating/rating-symbol.base.css.js.map +1 -0
  160. package/components/rating/rating-symbol.d.ts +8 -2
  161. package/components/rating/rating-symbol.js +12 -3
  162. package/components/rating/rating-symbol.js.map +1 -1
  163. package/components/rating/rating.base.css.js +1 -1
  164. package/components/rating/rating.base.css.js.map +1 -1
  165. package/components/rating/rating.bootstrap.css.js +1 -1
  166. package/components/rating/rating.bootstrap.css.js.map +1 -1
  167. package/components/rating/rating.d.ts +38 -21
  168. package/components/rating/rating.fluent.css.js +1 -1
  169. package/components/rating/rating.fluent.css.js.map +1 -1
  170. package/components/rating/rating.indigo.css.js +1 -1
  171. package/components/rating/rating.indigo.css.js.map +1 -1
  172. package/components/rating/rating.js +116 -57
  173. package/components/rating/rating.js.map +1 -1
  174. package/components/select/select-group.d.ts +31 -0
  175. package/components/select/select-group.js +69 -0
  176. package/components/select/select-group.js.map +1 -0
  177. package/components/select/select-header.d.ts +15 -0
  178. package/components/select/select-header.js +5 -0
  179. package/components/select/select-header.js.map +1 -0
  180. package/components/select/select-item.d.ts +30 -0
  181. package/components/select/select-item.js +39 -0
  182. package/components/select/select-item.js.map +1 -0
  183. package/components/select/select.d.ts +112 -0
  184. package/components/select/select.js +343 -0
  185. package/components/select/select.js.map +1 -0
  186. package/components/select/themes/dark/select.bootstrap.css.d.ts +1 -0
  187. package/components/select/themes/dark/select.bootstrap.css.js +3 -0
  188. package/components/select/themes/dark/select.bootstrap.css.js.map +1 -0
  189. package/components/select/themes/dark/select.fluent.css.d.ts +1 -0
  190. package/components/select/themes/dark/select.fluent.css.js +3 -0
  191. package/components/select/themes/dark/select.fluent.css.js.map +1 -0
  192. package/components/select/themes/dark/select.indigo.css.d.ts +1 -0
  193. package/components/select/themes/dark/select.indigo.css.js +3 -0
  194. package/components/select/themes/dark/select.indigo.css.js.map +1 -0
  195. package/components/select/themes/dark/select.material.css.d.ts +1 -0
  196. package/components/select/themes/dark/select.material.css.js +3 -0
  197. package/components/select/themes/dark/select.material.css.js.map +1 -0
  198. package/components/select/themes/light/select.base.css.d.ts +1 -0
  199. package/components/select/themes/light/select.base.css.js +3 -0
  200. package/components/select/themes/light/select.base.css.js.map +1 -0
  201. package/components/select/themes/light/select.bootstrap.css.d.ts +1 -0
  202. package/components/select/themes/light/select.bootstrap.css.js +3 -0
  203. package/components/select/themes/light/select.bootstrap.css.js.map +1 -0
  204. package/components/select/themes/light/select.fluent.css.d.ts +1 -0
  205. package/components/select/themes/light/select.fluent.css.js +3 -0
  206. package/components/select/themes/light/select.fluent.css.js.map +1 -0
  207. package/components/select/themes/light/select.indigo.css.d.ts +1 -0
  208. package/components/select/themes/light/select.indigo.css.js +3 -0
  209. package/components/select/themes/light/select.indigo.css.js.map +1 -0
  210. package/components/select/themes/light/select.material.css.d.ts +1 -0
  211. package/components/select/themes/light/select.material.css.js +3 -0
  212. package/components/select/themes/light/select.material.css.js.map +1 -0
  213. package/components/slider/range-slider.js.map +1 -1
  214. package/components/slider/slider-base.d.ts +0 -1
  215. package/components/slider/slider-base.js +12 -9
  216. package/components/slider/slider-base.js.map +1 -1
  217. package/components/slider/themes/light/slider.base.css.js +1 -1
  218. package/components/slider/themes/light/slider.base.css.js.map +1 -1
  219. package/components/slider/themes/light/slider.bootstrap.css.js +1 -1
  220. package/components/slider/themes/light/slider.bootstrap.css.js.map +1 -1
  221. package/components/slider/themes/light/slider.fluent.css.js +1 -1
  222. package/components/slider/themes/light/slider.fluent.css.js.map +1 -1
  223. package/components/slider/themes/light/slider.indigo.css.js +1 -1
  224. package/components/slider/themes/light/slider.indigo.css.js.map +1 -1
  225. package/components/slider/themes/light/slider.material.css.js +1 -1
  226. package/components/slider/themes/light/slider.material.css.js.map +1 -1
  227. package/components/snackbar/snackbar.js +3 -0
  228. package/components/snackbar/snackbar.js.map +1 -1
  229. package/components/tabs/tab-panel.js +2 -3
  230. package/components/tabs/tab-panel.js.map +1 -1
  231. package/components/tabs/tab.js +1 -1
  232. package/components/tabs/tab.js.map +1 -1
  233. package/components/tabs/tabs.d.ts +2 -4
  234. package/components/tabs/tabs.js +17 -11
  235. package/components/tabs/tabs.js.map +1 -1
  236. package/components/tabs/themes/light/tab.base.css.js +1 -1
  237. package/components/tabs/themes/light/tab.base.css.js.map +1 -1
  238. package/components/toast/toast.d.ts +1 -0
  239. package/components/toast/toast.js +9 -0
  240. package/components/toast/toast.js.map +1 -1
  241. package/components/toggle/toggle.controller.d.ts +24 -4
  242. package/components/toggle/toggle.controller.js +36 -30
  243. package/components/toggle/toggle.controller.js.map +1 -1
  244. package/components/toggle/toggle.directive.d.ts +1 -1
  245. package/components/toggle/toggle.directive.js +1 -0
  246. package/components/toggle/toggle.directive.js.map +1 -1
  247. package/components/tree/themes/light/tree.base.css.js +1 -1
  248. package/components/tree/themes/light/tree.base.css.js.map +1 -1
  249. package/components/tree/tree-item.d.ts +0 -1
  250. package/components/tree/tree-item.js +8 -1
  251. package/components/tree/tree-item.js.map +1 -1
  252. package/components/tree/tree.common.js.map +1 -1
  253. package/components/tree/tree.d.ts +2 -2
  254. package/components/tree/tree.js +22 -2
  255. package/components/tree/tree.js.map +1 -1
  256. package/custom-elements.json +738 -42
  257. package/index.d.ts +12 -12
  258. package/index.js +9 -11
  259. package/index.js.map +1 -1
  260. package/package.json +10 -8
  261. package/themes/dark/bootstrap.css +1 -1
  262. package/themes/dark/fluent.css +1 -1
  263. package/themes/dark/indigo.css +1 -1
  264. package/themes/dark/material.css +1 -1
  265. package/vscode-html-custom-data.json +305 -41
@@ -1,3 +1,3 @@
1
1
  import { css } from 'lit';
2
- export const styles = css `[part~=label]{font-family:var(--igc-body-1-font-family);font-weight:var(--igc-body-1-font-weight);font-size:var(--igc-body-1-font-size);font-style:var(--igc-body-1-font-style);letter-spacing:var(--igc-body-1-letter-spacing);text-transform:var(--igc-body-1-text-transform);line-height:var(--igc-body-1-line-height);margin-top:var(--igc-body-1-margin-top);margin-bottom:var(--igc-body-1-margin-bottom);color:hsla(var(--igc-gray-900), var(--igc-gray-a));-webkit-padding-start:.25rem;padding-inline-start:.25rem}`;
2
+ export const styles = css `[part=base]{gap:.4375rem}[part~=label]{font-family:var(--igc-body-1-font-family);font-weight:var(--igc-body-1-font-weight);font-size:var(--igc-body-1-font-size);font-style:var(--igc-body-1-font-style);letter-spacing:var(--igc-body-1-letter-spacing);text-transform:var(--igc-body-1-text-transform);line-height:var(--igc-body-1-line-height);margin-top:var(--igc-body-1-margin-top);margin-bottom:var(--igc-body-1-margin-bottom);color:hsla(var(--igc-gray-900), var(--igc-gray-a))}[part~=value-label]{font-family:var(--igc-body-2-font-family);font-weight:var(--igc-body-2-font-weight);font-size:var(--igc-body-2-font-size);font-style:var(--igc-body-2-font-style);letter-spacing:var(--igc-body-2-letter-spacing);text-transform:var(--igc-body-2-text-transform);line-height:var(--igc-body-2-line-height);margin-top:var(--igc-body-2-margin-top);margin-bottom:var(--igc-body-2-margin-bottom);color:hsla(var(--igc-gray-900), var(--igc-gray-a))}`;
3
3
  //# sourceMappingURL=rating.bootstrap.css.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rating.bootstrap.css.js","sourceRoot":"","sources":["../../../src/components/rating/rating.bootstrap.css.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA,8fAA8f,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const styles = css`[part~=label]{font-family:var(--igc-body-1-font-family);font-weight:var(--igc-body-1-font-weight);font-size:var(--igc-body-1-font-size);font-style:var(--igc-body-1-font-style);letter-spacing:var(--igc-body-1-letter-spacing);text-transform:var(--igc-body-1-text-transform);line-height:var(--igc-body-1-line-height);margin-top:var(--igc-body-1-margin-top);margin-bottom:var(--igc-body-1-margin-bottom);color:hsla(var(--igc-gray-900), var(--igc-gray-a));-webkit-padding-start:.25rem;padding-inline-start:.25rem}`;\n"]}
1
+ {"version":3,"file":"rating.bootstrap.css.js","sourceRoot":"","sources":["../../../src/components/rating/rating.bootstrap.css.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA,u6BAAu6B,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const styles = css`[part=base]{gap:.4375rem}[part~=label]{font-family:var(--igc-body-1-font-family);font-weight:var(--igc-body-1-font-weight);font-size:var(--igc-body-1-font-size);font-style:var(--igc-body-1-font-style);letter-spacing:var(--igc-body-1-letter-spacing);text-transform:var(--igc-body-1-text-transform);line-height:var(--igc-body-1-line-height);margin-top:var(--igc-body-1-margin-top);margin-bottom:var(--igc-body-1-margin-bottom);color:hsla(var(--igc-gray-900), var(--igc-gray-a))}[part~=value-label]{font-family:var(--igc-body-2-font-family);font-weight:var(--igc-body-2-font-weight);font-size:var(--igc-body-2-font-size);font-style:var(--igc-body-2-font-style);letter-spacing:var(--igc-body-2-letter-spacing);text-transform:var(--igc-body-2-text-transform);line-height:var(--igc-body-2-line-height);margin-top:var(--igc-body-2-margin-top);margin-bottom:var(--igc-body-2-margin-bottom);color:hsla(var(--igc-gray-900), var(--igc-gray-a))}`;\n"]}
@@ -1,6 +1,6 @@
1
1
  import { LitElement } from 'lit';
2
2
  import { Constructor } from '../common/mixins/constructor.js';
3
- import type IgcRatingSymbolComponent from './rating-symbol';
3
+ import IgcRatingSymbolComponent from './rating-symbol.js';
4
4
  export interface IgcRatingEventMap {
5
5
  igcChange: CustomEvent<number>;
6
6
  igcHover: CustomEvent<number>;
@@ -17,37 +17,50 @@ declare const IgcRatingComponent_base: Constructor<import("../common/mixins/siza
17
17
  *
18
18
  * @csspart base - The main wrapper which holds all of the rating elements.
19
19
  * @csspart label - The label part.
20
- * @csspart symbol - The part for a single symbol.
21
- * @csspart fraction -The part for the selected symbols.
22
- * @csspart symbols-wrapper - The wrapper that holds all symbols.
23
- * @csspart large - A part responsible for the symbols size.
24
- * @csspart medium - A part responsible for the symbols size.
25
- * @csspart small- A part responsible for the symbols size.
20
+ * @csspart value-label - The value label part.
21
+ * @csspart symbols - A wrapper for all rating symbols.
22
+ * @csspart symbol - The part of the encapsulated default symbol.
23
+ * @csspart full - The part of the encapsulated full symbols.
24
+ * @csspart empty - The part of the encapsulated empty symbols.
25
+ *
26
+ * @cssproperty --symbol-size - The size of the symbols.
27
+ * @cssproperty --symbol-full-color - The color of the filled symbol.
28
+ * @cssproperty --symbol-empty-color - The color of the empty symbol.
29
+ * @cssproperty --symbol-full-filter - The filter(s) used for the filled symbol.
30
+ * @cssproperty --symbol-empty-filter - The filter(s) used for the empty symbol.
26
31
  */
27
32
  export default class IgcRatingComponent extends IgcRatingComponent_base {
28
33
  static readonly tagName = "igc-rating";
29
34
  static styles: import("lit").CSSResult[];
30
- protected container: HTMLElement;
31
35
  protected ratingSymbols: Array<IgcRatingSymbolComponent>;
36
+ protected container: HTMLElement;
37
+ protected valueLabel: Array<Node>;
32
38
  protected hoverValue: number;
33
39
  protected hoverState: boolean;
34
40
  protected get isInteractive(): boolean;
35
41
  protected get hasProjectedSymbols(): boolean;
36
- protected get isLTR(): boolean;
37
- protected get valueText(): string | number;
38
- /** The maximum value for the rating */
42
+ protected get valueText(): string;
43
+ /**
44
+ * The maximum value for the rating.
45
+ *
46
+ * If there are projected symbols, the maximum value will be resolved
47
+ * based on the number of symbols.
48
+ */
39
49
  max: number;
40
- /** The minimum value change allowed. */
50
+ /**
51
+ * The minimum value change allowed.
52
+ *
53
+ * Valid values are in the interval between 0 and 1 inclusive.
54
+ */
41
55
  step: number;
42
- /** The symbol which the rating will display. */
43
- symbol: string;
44
56
  /** The name attribute of the control */
45
57
  name: string;
46
58
  /** The label of the control. */
47
59
  label: string;
48
60
  /**
49
- * A format string which sets aria-valuetext. All instances of '{0}' will be replaced
50
- * with the current value of the control.
61
+ * A format string which sets aria-valuetext. Instances of '{0}' will be replaced
62
+ * with the current value of the control and instances of '{1}' with the maximum value for the control.
63
+ *
51
64
  * Important for screen-readers and useful for localization.
52
65
  */
53
66
  valueFormat: string;
@@ -59,19 +72,26 @@ export default class IgcRatingComponent extends IgcRatingComponent_base {
59
72
  hoverPreview: boolean;
60
73
  /** Sets the readonly state of the component */
61
74
  readonly: boolean;
75
+ /** Toggles single selection visual mode. */
76
+ single: boolean;
62
77
  protected handleMaxChange(): void;
63
78
  protected handleValueChange(): void;
64
79
  protected handlePrecisionChange(): void;
80
+ protected handleSelectionChange(): void;
65
81
  constructor();
66
82
  protected handleClick({ clientX }: MouseEvent): void;
67
83
  protected handleMouseMove({ clientX }: MouseEvent): void;
68
84
  protected handleMouseEnter(): void;
69
85
  protected handleMouseLeave(): void;
70
86
  protected handleKeyDown({ key }: KeyboardEvent): void;
71
- protected handleSlotChange(): void;
87
+ protected handleSlotChange(event: Event): void;
72
88
  protected calcNewValue(x: number): number;
73
89
  protected getPrecision(num: number): number;
74
90
  protected round(value: number): number;
91
+ protected clipSymbol(index: number, isLTR?: boolean): {
92
+ backward: string;
93
+ forward: string;
94
+ };
75
95
  /**
76
96
  * Increments the value of the control by `n` steps multiplied by the
77
97
  * step factor.
@@ -83,10 +103,7 @@ export default class IgcRatingComponent extends IgcRatingComponent_base {
83
103
  */
84
104
  stepDown(n?: number): void;
85
105
  protected renderSymbols(): Generator<import("lit-html").TemplateResult<1>, void, unknown>;
86
- protected renderProjected(): import("lit-html").TemplateResult<1>;
87
- protected renderFractionWrapper(styles: {
88
- width: string;
89
- }): import("lit-html").TemplateResult<1>;
106
+ protected clipProjected(): void;
90
107
  protected render(): import("lit-html").TemplateResult<1>;
91
108
  }
92
109
  declare global {
@@ -1,3 +1,3 @@
1
1
  import { css } from 'lit';
2
- export const styles = css `[part~=label]{font-family:var(--igc-subtitle-2-font-family);font-weight:var(--igc-subtitle-2-font-weight);font-size:var(--igc-subtitle-2-font-size);font-style:var(--igc-subtitle-2-font-style);letter-spacing:var(--igc-subtitle-2-letter-spacing);text-transform:var(--igc-subtitle-2-text-transform);line-height:var(--igc-subtitle-2-line-height);margin-top:var(--igc-subtitle-2-margin-top);margin-bottom:var(--igc-subtitle-2-margin-bottom);color:hsla(var(--igc-gray-900), var(--igc-gray-a));-webkit-padding-start:.375rem;padding-inline-start:.375rem}:host([disabled]) [part~=symbols-wrapper]{color:hsla(var(--igc-gray-200), var(--igc-gray-a))}:host([disabled]) [part~=label]{color:hsla(var(--igc-gray-400), var(--igc-gray-a))}:host([disabled]) [part="symbols-wrapper selected"]{color:hsla(var(--igc-gray-500), var(--igc-gray-a))}`;
2
+ export const styles = css `[part=base],:host{gap:.375rem}[part~=label]{font-family:var(--igc-subtitle-2-font-family);font-weight:var(--igc-subtitle-2-font-weight);font-size:var(--igc-subtitle-2-font-size);font-style:var(--igc-subtitle-2-font-style);letter-spacing:var(--igc-subtitle-2-letter-spacing);text-transform:var(--igc-subtitle-2-text-transform);line-height:var(--igc-subtitle-2-line-height);margin-top:var(--igc-subtitle-2-margin-top);margin-bottom:var(--igc-subtitle-2-margin-bottom);color:hsla(var(--igc-gray-900), var(--igc-gray-a))}[part~=value-label]{font-family:var(--igc-body-2-font-family);font-weight:var(--igc-body-2-font-weight);font-size:var(--igc-body-2-font-size);font-style:var(--igc-body-2-font-style);letter-spacing:var(--igc-body-2-letter-spacing);text-transform:var(--igc-body-2-text-transform);line-height:var(--igc-body-2-line-height);margin-top:var(--igc-body-2-margin-top);margin-bottom:var(--igc-body-2-margin-bottom);color:hsla(var(--igc-gray-900), var(--igc-gray-a))}:host([disabled]) [part~=symbols-wrapper]{color:hsla(var(--igc-gray-200), var(--igc-gray-a))}:host([disabled]) [part~=value-label],:host([disabled]) [part~=label]{color:hsla(var(--igc-gray-400), var(--igc-gray-a))}:host([disabled]) [part="symbols-wrapper selected"]{color:hsla(var(--igc-gray-500), var(--igc-gray-a))}`;
3
3
  //# sourceMappingURL=rating.fluent.css.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rating.fluent.css.js","sourceRoot":"","sources":["../../../src/components/rating/rating.fluent.css.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA,2zBAA2zB,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const styles = css`[part~=label]{font-family:var(--igc-subtitle-2-font-family);font-weight:var(--igc-subtitle-2-font-weight);font-size:var(--igc-subtitle-2-font-size);font-style:var(--igc-subtitle-2-font-style);letter-spacing:var(--igc-subtitle-2-letter-spacing);text-transform:var(--igc-subtitle-2-text-transform);line-height:var(--igc-subtitle-2-line-height);margin-top:var(--igc-subtitle-2-margin-top);margin-bottom:var(--igc-subtitle-2-margin-bottom);color:hsla(var(--igc-gray-900), var(--igc-gray-a));-webkit-padding-start:.375rem;padding-inline-start:.375rem}:host([disabled]) [part~=symbols-wrapper]{color:hsla(var(--igc-gray-200), var(--igc-gray-a))}:host([disabled]) [part~=label]{color:hsla(var(--igc-gray-400), var(--igc-gray-a))}:host([disabled]) [part=\"symbols-wrapper selected\"]{color:hsla(var(--igc-gray-500), var(--igc-gray-a))}`;\n"]}
1
+ {"version":3,"file":"rating.fluent.css.js","sourceRoot":"","sources":["../../../src/components/rating/rating.fluent.css.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA,6wCAA6wC,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const styles = css`[part=base],:host{gap:.375rem}[part~=label]{font-family:var(--igc-subtitle-2-font-family);font-weight:var(--igc-subtitle-2-font-weight);font-size:var(--igc-subtitle-2-font-size);font-style:var(--igc-subtitle-2-font-style);letter-spacing:var(--igc-subtitle-2-letter-spacing);text-transform:var(--igc-subtitle-2-text-transform);line-height:var(--igc-subtitle-2-line-height);margin-top:var(--igc-subtitle-2-margin-top);margin-bottom:var(--igc-subtitle-2-margin-bottom);color:hsla(var(--igc-gray-900), var(--igc-gray-a))}[part~=value-label]{font-family:var(--igc-body-2-font-family);font-weight:var(--igc-body-2-font-weight);font-size:var(--igc-body-2-font-size);font-style:var(--igc-body-2-font-style);letter-spacing:var(--igc-body-2-letter-spacing);text-transform:var(--igc-body-2-text-transform);line-height:var(--igc-body-2-line-height);margin-top:var(--igc-body-2-margin-top);margin-bottom:var(--igc-body-2-margin-bottom);color:hsla(var(--igc-gray-900), var(--igc-gray-a))}:host([disabled]) [part~=symbols-wrapper]{color:hsla(var(--igc-gray-200), var(--igc-gray-a))}:host([disabled]) [part~=value-label],:host([disabled]) [part~=label]{color:hsla(var(--igc-gray-400), var(--igc-gray-a))}:host([disabled]) [part=\"symbols-wrapper selected\"]{color:hsla(var(--igc-gray-500), var(--igc-gray-a))}`;\n"]}
@@ -1,3 +1,3 @@
1
1
  import { css } from 'lit';
2
- export const styles = css `[part~=label]{font-family:var(--igc-body-1-font-family);font-weight:var(--igc-body-1-font-weight);font-size:var(--igc-body-1-font-size);font-style:var(--igc-body-1-font-style);letter-spacing:var(--igc-body-1-letter-spacing);text-transform:var(--igc-body-1-text-transform);line-height:var(--igc-body-1-line-height);margin-top:var(--igc-body-1-margin-top);margin-bottom:var(--igc-body-1-margin-bottom);color:hsla(var(--igc-gray-900), var(--igc-gray-a));-webkit-padding-start:.3125rem;padding-inline-start:.3125rem}`;
2
+ export const styles = css `:host{gap:.3125rem}[part=base]{gap:.5rem}[part~=label]{font-family:var(--igc-body-1-font-family);font-weight:var(--igc-body-1-font-weight);font-size:var(--igc-body-1-font-size);font-style:var(--igc-body-1-font-style);letter-spacing:var(--igc-body-1-letter-spacing);text-transform:var(--igc-body-1-text-transform);line-height:var(--igc-body-1-line-height);margin-top:var(--igc-body-1-margin-top);margin-bottom:var(--igc-body-1-margin-bottom);color:hsla(var(--igc-gray-900), var(--igc-gray-a))}[part~=value-label]{font-family:var(--igc-body-1-font-family);font-weight:var(--igc-body-1-font-weight);font-size:var(--igc-body-1-font-size);font-style:var(--igc-body-1-font-style);letter-spacing:var(--igc-body-1-letter-spacing);text-transform:var(--igc-body-1-text-transform);line-height:var(--igc-body-1-line-height);margin-top:var(--igc-body-1-margin-top);margin-bottom:var(--igc-body-1-margin-bottom);color:hsla(var(--igc-gray-900), var(--igc-gray-a))}`;
3
3
  //# sourceMappingURL=rating.indigo.css.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rating.indigo.css.js","sourceRoot":"","sources":["../../../src/components/rating/rating.indigo.css.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA,kgBAAkgB,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const styles = css`[part~=label]{font-family:var(--igc-body-1-font-family);font-weight:var(--igc-body-1-font-weight);font-size:var(--igc-body-1-font-size);font-style:var(--igc-body-1-font-style);letter-spacing:var(--igc-body-1-letter-spacing);text-transform:var(--igc-body-1-text-transform);line-height:var(--igc-body-1-line-height);margin-top:var(--igc-body-1-margin-top);margin-bottom:var(--igc-body-1-margin-bottom);color:hsla(var(--igc-gray-900), var(--igc-gray-a));-webkit-padding-start:.3125rem;padding-inline-start:.3125rem}`;\n"]}
1
+ {"version":3,"file":"rating.indigo.css.js","sourceRoot":"","sources":["../../../src/components/rating/rating.indigo.css.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA,u7BAAu7B,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const styles = css`:host{gap:.3125rem}[part=base]{gap:.5rem}[part~=label]{font-family:var(--igc-body-1-font-family);font-weight:var(--igc-body-1-font-weight);font-size:var(--igc-body-1-font-size);font-style:var(--igc-body-1-font-style);letter-spacing:var(--igc-body-1-letter-spacing);text-transform:var(--igc-body-1-text-transform);line-height:var(--igc-body-1-line-height);margin-top:var(--igc-body-1-margin-top);margin-bottom:var(--igc-body-1-margin-bottom);color:hsla(var(--igc-gray-900), var(--igc-gray-a))}[part~=value-label]{font-family:var(--igc-body-1-font-family);font-weight:var(--igc-body-1-font-weight);font-size:var(--igc-body-1-font-size);font-style:var(--igc-body-1-font-style);letter-spacing:var(--igc-body-1-letter-spacing);text-transform:var(--igc-body-1-text-transform);line-height:var(--igc-body-1-line-height);margin-top:var(--igc-body-1-margin-top);margin-bottom:var(--igc-body-1-margin-bottom);color:hsla(var(--igc-gray-900), var(--igc-gray-a))}`;\n"]}
@@ -5,30 +5,36 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { html, LitElement, nothing } from 'lit';
8
- import { property, query, queryAssignedElements, state, } from 'lit/decorators.js';
9
- import { styleMap } from 'lit/directives/style-map.js';
8
+ import { property, query, queryAssignedNodes, state } from 'lit/decorators.js';
10
9
  import { ifDefined } from 'lit/directives/if-defined.js';
10
+ import { styleMap } from 'lit/directives/style-map.js';
11
+ import { guard } from 'lit/directives/guard.js';
12
+ import { themes } from '../../theming/theming-decorator.js';
11
13
  import { watch } from '../common/decorators/watch.js';
12
14
  import { EventEmitterMixin } from '../common/mixins/event-emitter.js';
13
15
  import { SizableMixin } from '../common/mixins/sizable.js';
16
+ import { clamp, isLTR } from '../common/util.js';
14
17
  import { styles } from './rating.base.css.js';
15
18
  import { styles as bootstrap } from './rating.bootstrap.css.js';
16
19
  import { styles as fluent } from './rating.fluent.css.js';
17
20
  import { styles as indigo } from './rating.indigo.css.js';
18
- import { clamp } from '../common/util.js';
19
- import { themes } from '../../theming/theming-decorator.js';
21
+ import { defineComponents } from '../common/definitions/defineComponents.js';
22
+ import IgcRatingSymbolComponent from './rating-symbol.js';
23
+ import IgcIconComponent from '../icon/icon.js';
24
+ defineComponents(IgcRatingSymbolComponent, IgcIconComponent);
20
25
  let IgcRatingComponent = class IgcRatingComponent extends SizableMixin(EventEmitterMixin(LitElement)) {
21
26
  constructor() {
22
27
  super();
28
+ this.ratingSymbols = [];
23
29
  this.hoverValue = -1;
24
30
  this.hoverState = false;
25
31
  this.max = 5;
26
32
  this.step = 1;
27
- this.symbol = '⭐';
28
33
  this.value = 0;
29
34
  this.disabled = false;
30
35
  this.hoverPreview = false;
31
36
  this.readonly = false;
37
+ this.single = false;
32
38
  this.addEventListener('keydown', this.handleKeyDown);
33
39
  }
34
40
  get isInteractive() {
@@ -37,13 +43,13 @@ let IgcRatingComponent = class IgcRatingComponent extends SizableMixin(EventEmit
37
43
  get hasProjectedSymbols() {
38
44
  return this.ratingSymbols.length > 0;
39
45
  }
40
- get isLTR() {
41
- return (window.getComputedStyle(this).getPropertyValue('direction') === 'ltr');
42
- }
43
46
  get valueText() {
47
+ const value = this.round(this.value);
44
48
  return this.valueFormat
45
- ? this.valueFormat.replace(/\{0\}/gm, `${this.value}`)
46
- : this.value;
49
+ ? this.valueFormat
50
+ .replace(/\{0\}/gm, `${value}`)
51
+ .replace(/\{1\}/gm, `${this.max}`)
52
+ : `${value} of ${this.max}`;
47
53
  }
48
54
  handleMaxChange() {
49
55
  this.hasProjectedSymbols
@@ -57,7 +63,13 @@ let IgcRatingComponent = class IgcRatingComponent extends SizableMixin(EventEmit
57
63
  this.value = clamp(this.value, 0, this.max);
58
64
  }
59
65
  handlePrecisionChange() {
60
- this.step = clamp(this.step, 0.001, 1);
66
+ this.step = !this.single ? clamp(this.step, 0.001, 1) : 1;
67
+ }
68
+ handleSelectionChange() {
69
+ if (this.single) {
70
+ this.step = 1;
71
+ this.value = Math.ceil(this.value);
72
+ }
61
73
  }
62
74
  handleClick({ clientX }) {
63
75
  if (!this.isInteractive) {
@@ -92,14 +104,15 @@ let IgcRatingComponent = class IgcRatingComponent extends SizableMixin(EventEmit
92
104
  return;
93
105
  }
94
106
  let result = this.value;
107
+ const ltr = isLTR(this);
95
108
  switch (key) {
96
109
  case 'ArrowUp':
97
110
  case 'ArrowRight':
98
- result += this.isLTR ? this.step : -this.step;
111
+ result += ltr ? this.step : -this.step;
99
112
  break;
100
113
  case 'ArrowDown':
101
114
  case 'ArrowLeft':
102
- result -= this.isLTR ? this.step : -this.step;
115
+ result -= ltr ? this.step : -this.step;
103
116
  break;
104
117
  case 'Home':
105
118
  result = this.step;
@@ -115,7 +128,11 @@ let IgcRatingComponent = class IgcRatingComponent extends SizableMixin(EventEmit
115
128
  this.emitEvent('igcChange', { detail: this.value });
116
129
  }
117
130
  }
118
- handleSlotChange() {
131
+ handleSlotChange(event) {
132
+ const slot = event.target;
133
+ this.ratingSymbols = slot
134
+ .assignedElements()
135
+ .filter((el) => el instanceof IgcRatingSymbolComponent);
119
136
  if (this.hasProjectedSymbols) {
120
137
  this.max = this.ratingSymbols.length;
121
138
  }
@@ -123,7 +140,7 @@ let IgcRatingComponent = class IgcRatingComponent extends SizableMixin(EventEmit
123
140
  }
124
141
  calcNewValue(x) {
125
142
  const { width, left, right } = this.container.getBoundingClientRect();
126
- const percent = this.isLTR ? (x - left) / width : (right - x) / width;
143
+ const percent = isLTR(this) ? (x - left) / width : (right - x) / width;
127
144
  const value = this.round(this.max * percent + this.step / 2);
128
145
  return clamp(value, this.step, this.max);
129
146
  }
@@ -135,6 +152,19 @@ let IgcRatingComponent = class IgcRatingComponent extends SizableMixin(EventEmit
135
152
  value = Math.round(value / this.step) * this.step;
136
153
  return Number(value.toFixed(this.getPrecision(this.step)));
137
154
  }
155
+ clipSymbol(index, isLTR = true) {
156
+ const value = this.hoverState ? this.hoverValue : this.value;
157
+ const progress = index + 1 - value;
158
+ const exclusive = progress === 0 || this.value === index + 1 ? 0 : 1;
159
+ const selection = this.single ? exclusive : progress;
160
+ const activate = (p) => clamp(p * 100, 0, 100);
161
+ const forward = `inset(0 ${activate(isLTR ? selection : 1 - selection)}% 0 0)`;
162
+ const backward = `inset(0 0 0 ${activate(isLTR ? 1 - selection : selection)}%)`;
163
+ return {
164
+ backward: isLTR ? backward : forward,
165
+ forward: isLTR ? forward : backward,
166
+ };
167
+ }
138
168
  stepUp(n = 1) {
139
169
  this.value += this.round(n * this.step);
140
170
  }
@@ -142,57 +172,83 @@ let IgcRatingComponent = class IgcRatingComponent extends SizableMixin(EventEmit
142
172
  this.value -= this.round(n * this.step);
143
173
  }
144
174
  *renderSymbols() {
175
+ const ltr = isLTR(this);
145
176
  for (let i = 0; i < this.max; i++) {
146
- yield html `<span part="symbol ${this.size}">${this.symbol}</span>`;
177
+ const { forward, backward } = this.clipSymbol(i, ltr);
178
+ yield html `<igc-rating-symbol exportparts="symbol, full, empty">
179
+ <igc-icon
180
+ collection="internal"
181
+ name="star"
182
+ style=${styleMap({ clipPath: forward })}
183
+ ></igc-icon>
184
+ <igc-icon
185
+ collection="internal"
186
+ name="star_border"
187
+ style=${styleMap({ clipPath: backward })}
188
+ slot="empty"
189
+ ></igc-icon>
190
+ </igc-rating-symbol>`;
147
191
  }
148
192
  }
149
- renderProjected() {
150
- return html `${this.ratingSymbols.map((each) => {
151
- const clone = each.cloneNode(true);
152
- clone.setAttribute('part', `symbol ${this.size}`);
153
- return clone;
154
- })}`;
155
- }
156
- renderFractionWrapper(styles) {
157
- return html `<div
158
- @click=${this.handleClick}
159
- @mouseenter=${this.hoverPreview ? this.handleMouseEnter : nothing}
160
- @mouseleave=${this.hoverPreview ? this.handleMouseLeave : nothing}
161
- @mousemove=${this.hoverPreview ? this.handleMouseMove : nothing}
162
- >
163
- <slot @slotchange=${this.handleSlotChange}></slot>
164
-
165
- <div style=${styleMap(styles)} part="fraction ${this.size}">
166
- <div part="symbols-wrapper selected">
167
- ${this.hasProjectedSymbols
168
- ? this.renderProjected()
169
- : this.renderSymbols()}
170
- </div>
171
- </div>
172
- <div part="symbols-wrapper">
173
- ${this.hasProjectedSymbols
174
- ? this.renderProjected()
175
- : this.renderSymbols()}
176
- </div>
177
- </div>`;
193
+ clipProjected() {
194
+ if (this.hasProjectedSymbols) {
195
+ const ltr = isLTR(this);
196
+ this.ratingSymbols.forEach((symbol, i) => {
197
+ var _a, _b;
198
+ const full = (_a = symbol.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('[part="symbol full"]');
199
+ const empty = (_b = symbol.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('[part="symbol empty"]');
200
+ const { forward, backward } = this.clipSymbol(i, ltr);
201
+ if (full) {
202
+ full.style.clipPath = forward;
203
+ }
204
+ if (empty) {
205
+ empty.style.clipPath = backward;
206
+ }
207
+ });
208
+ }
178
209
  }
179
210
  render() {
180
- var _a;
181
- const value = this.hoverState ? this.hoverValue : this.value;
182
- const styles = { width: `${Math.round((value / this.max) * 100)}%` };
211
+ const props = [
212
+ this.value,
213
+ this.hoverValue,
214
+ this.max,
215
+ this.step,
216
+ this.single,
217
+ this.hoverState,
218
+ this.ratingSymbols,
219
+ ];
183
220
  return html `
184
- <label part="label ${this.size}">${this.label}</label>
221
+ <label part="label" id="rating-label" ?hidden=${!this.label}
222
+ >${this.label}</label
223
+ >
185
224
  <div
186
225
  part="base"
187
226
  role="slider"
188
227
  tabindex=${ifDefined(this.disabled ? undefined : 0)}
189
- aria-label=${(_a = this.label) !== null && _a !== void 0 ? _a : nothing}
228
+ aria-labelledby="rating-label"
190
229
  aria-valuemin="0"
191
230
  aria-valuenow=${this.value}
192
231
  aria-valuemax=${this.max}
193
232
  aria-valuetext=${this.valueText}
194
233
  >
195
- ${this.renderFractionWrapper(styles)}
234
+ <div
235
+ aria-hidden="true"
236
+ part="symbols"
237
+ @click=${this.handleClick}
238
+ @mouseenter=${this.hoverPreview ? this.handleMouseEnter : nothing}
239
+ @mouseleave=${this.hoverPreview ? this.handleMouseLeave : nothing}
240
+ @mousemove=${this.hoverPreview ? this.handleMouseMove : nothing}
241
+ >
242
+ <slot @slotchange=${this.handleSlotChange}>
243
+ ${guard(props, () => {
244
+ this.clipProjected();
245
+ return this.renderSymbols();
246
+ })}
247
+ </slot>
248
+ </div>
249
+ <label part="value-label" ?hidden=${this.valueLabel.length === 0}>
250
+ <slot name="value-label"></slot>
251
+ </label>
196
252
  </div>
197
253
  `;
198
254
  }
@@ -200,11 +256,11 @@ let IgcRatingComponent = class IgcRatingComponent extends SizableMixin(EventEmit
200
256
  IgcRatingComponent.tagName = 'igc-rating';
201
257
  IgcRatingComponent.styles = [styles];
202
258
  __decorate([
203
- query('[part="base"]', true)
259
+ query('[part="symbols"]', true)
204
260
  ], IgcRatingComponent.prototype, "container", void 0);
205
261
  __decorate([
206
- queryAssignedElements({ selector: 'igc-rating-symbol' })
207
- ], IgcRatingComponent.prototype, "ratingSymbols", void 0);
262
+ queryAssignedNodes({ slot: 'value-label', flatten: true })
263
+ ], IgcRatingComponent.prototype, "valueLabel", void 0);
208
264
  __decorate([
209
265
  state()
210
266
  ], IgcRatingComponent.prototype, "hoverValue", void 0);
@@ -217,9 +273,6 @@ __decorate([
217
273
  __decorate([
218
274
  property({ type: Number })
219
275
  ], IgcRatingComponent.prototype, "step", void 0);
220
- __decorate([
221
- property()
222
- ], IgcRatingComponent.prototype, "symbol", void 0);
223
276
  __decorate([
224
277
  property()
225
278
  ], IgcRatingComponent.prototype, "name", void 0);
@@ -241,6 +294,9 @@ __decorate([
241
294
  __decorate([
242
295
  property({ type: Boolean, reflect: true })
243
296
  ], IgcRatingComponent.prototype, "readonly", void 0);
297
+ __decorate([
298
+ property({ type: Boolean })
299
+ ], IgcRatingComponent.prototype, "single", void 0);
244
300
  __decorate([
245
301
  watch('max')
246
302
  ], IgcRatingComponent.prototype, "handleMaxChange", null);
@@ -250,6 +306,9 @@ __decorate([
250
306
  __decorate([
251
307
  watch('step')
252
308
  ], IgcRatingComponent.prototype, "handlePrecisionChange", null);
309
+ __decorate([
310
+ watch('single')
311
+ ], IgcRatingComponent.prototype, "handleSelectionChange", null);
253
312
  IgcRatingComponent = __decorate([
254
313
  themes({ fluent, bootstrap, indigo })
255
314
  ], IgcRatingComponent);
@@ -1 +1 @@
1
- {"version":3,"file":"rating.js","sourceRoot":"","sources":["../../../src/components/rating/rating.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EACL,QAAQ,EACR,KAAK,EACL,qBAAqB,EACrB,KAAK,GACN,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAEtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AA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AE,CAAC;gDACX;AAIhB;IADC,QAAQ,EAAE;kDACS;AAIpB;IADC,QAAQ,EAAE;gDACU;AAIrB;IADC,QAAQ,EAAE;iDACW;AAQtB;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;uDACZ;AAI5B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDACV;AAIjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oDACnB;AAIxB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;wDAC3C;AAI5B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oDACnB;AAGxB;IADC,KAAK,CAAC,KAAK,CAAC;yDAQZ;AAGD;IADC,KAAK,CAAC,OAAO,CAAC;2DAGd;AAGD;IADC,KAAK,CAAC,MAAM,CAAC;+DAGb;AArGkB,kBAAkB;IADtC,MAAM,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;GACjB,kBAAkB,CAqRtC;eArRoB,kBAAkB","sourcesContent":["import { html, LitElement, nothing } from 'lit';\nimport {\n property,\n query,\n queryAssignedElements,\n state,\n} from 'lit/decorators.js';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { watch } from '../common/decorators/watch.js';\nimport { Constructor } from '../common/mixins/constructor.js';\nimport { EventEmitterMixin } from '../common/mixins/event-emitter.js';\nimport { SizableMixin } from '../common/mixins/sizable.js';\nimport { styles } from './rating.base.css.js';\nimport { styles as bootstrap } from './rating.bootstrap.css.js';\nimport { styles as fluent } from './rating.fluent.css.js';\nimport { styles as indigo } from './rating.indigo.css.js';\nimport { clamp } from '../common/util.js';\nimport type IgcRatingSymbolComponent from './rating-symbol';\nimport { themes } from '../../theming/theming-decorator.js';\n\nexport interface IgcRatingEventMap {\n igcChange: CustomEvent<number>;\n igcHover: CustomEvent<number>;\n}\n\n/**\n * Rating provides insight regarding others' opinions and experiences,\n * and can allow the user to submit a rating of their own\n *\n * @element igc-rating\n *\n * @fires igcChange - Emitted when the value of the control changes.\n * @fires igcHover - Emitted when hover is enabled and the user mouses over a symbol of the rating.\n *\n * @csspart base - The main wrapper which holds all of the rating elements.\n * @csspart label - The label part.\n * @csspart symbol - The part for a single symbol.\n * @csspart fraction -The part for the selected symbols.\n * @csspart symbols-wrapper - The wrapper that holds all symbols.\n * @csspart large - A part responsible for the symbols size.\n * @csspart medium - A part responsible for the symbols size.\n * @csspart small- A part responsible for the symbols size.\n */\n@themes({ fluent, bootstrap, indigo })\nexport default class IgcRatingComponent extends SizableMixin(\n EventEmitterMixin<IgcRatingEventMap, Constructor<LitElement>>(LitElement)\n) {\n public static readonly tagName = 'igc-rating';\n\n public static styles = [styles];\n\n @query('[part=\"base\"]', true)\n protected container!: HTMLElement;\n\n @queryAssignedElements({ selector: 'igc-rating-symbol' })\n protected ratingSymbols!: Array<IgcRatingSymbolComponent>;\n\n @state()\n protected hoverValue = -1;\n\n @state()\n protected hoverState = false;\n\n protected get isInteractive() {\n return !(this.readonly || this.disabled);\n }\n\n protected get hasProjectedSymbols() {\n return this.ratingSymbols.length > 0;\n }\n\n protected get isLTR() {\n return (\n window.getComputedStyle(this).getPropertyValue('direction') === 'ltr'\n );\n }\n\n protected get valueText() {\n return this.valueFormat\n ? this.valueFormat.replace(/\\{0\\}/gm, `${this.value}`)\n : this.value;\n }\n\n /** The maximum value for the rating */\n @property({ type: Number })\n public max = 5;\n\n /** The minimum value change allowed. */\n @property({ type: Number })\n public step = 1;\n\n /** The symbol which the rating will display. */\n @property()\n public symbol = '⭐';\n\n /** The name attribute of the control */\n @property()\n public name!: string;\n\n /** The label of the control. */\n @property()\n public label!: string;\n\n /**\n * A format string which sets aria-valuetext. All instances of '{0}' will be replaced\n * with the current value of the control.\n * Important for screen-readers and useful for localization.\n */\n @property({ attribute: 'value-format' })\n public valueFormat!: string;\n\n /** The current value of the component */\n @property({ type: Number })\n public value = 0;\n\n /** Sets the disabled state of the component */\n @property({ type: Boolean, reflect: true })\n public disabled = false;\n\n /** Sets hover preview behavior for the component */\n @property({ type: Boolean, reflect: true, attribute: 'hover-preview' })\n public hoverPreview = false;\n\n /** Sets the readonly state of the component */\n @property({ type: Boolean, reflect: true })\n public readonly = false;\n\n @watch('max')\n protected handleMaxChange() {\n this.hasProjectedSymbols\n ? (this.max = this.ratingSymbols.length)\n : (this.max = Math.max(0, this.max));\n if (this.max < this.value) {\n this.value = this.max;\n }\n }\n\n @watch('value')\n protected handleValueChange() {\n this.value = clamp(this.value, 0, this.max);\n }\n\n @watch('step')\n protected handlePrecisionChange() {\n this.step = clamp(this.step, 0.001, 1);\n }\n\n constructor() {\n super();\n this.addEventListener('keydown', this.handleKeyDown);\n }\n\n protected handleClick({ clientX }: MouseEvent) {\n if (!this.isInteractive) {\n return;\n }\n\n const value = this.calcNewValue(clientX);\n this.value === value ? (this.value = 0) : (this.value = value);\n this.emitEvent('igcChange', { detail: this.value });\n }\n\n protected handleMouseMove({ clientX }: MouseEvent) {\n if (!this.isInteractive) {\n return;\n }\n\n const value = this.calcNewValue(clientX);\n\n if (this.hoverValue !== value) {\n // Since mousemove spams a lot, only emit on a value change\n this.hoverValue = value;\n this.emitEvent('igcHover', { detail: this.hoverValue });\n }\n }\n\n protected handleMouseEnter() {\n if (this.isInteractive) {\n this.hoverState = true;\n }\n }\n\n protected handleMouseLeave() {\n if (this.isInteractive) {\n this.hoverState = false;\n }\n }\n\n protected handleKeyDown({ key }: KeyboardEvent) {\n if (!this.isInteractive) {\n return;\n }\n\n let result = this.value;\n\n switch (key) {\n case 'ArrowUp':\n case 'ArrowRight':\n result += this.isLTR ? this.step : -this.step;\n break;\n case 'ArrowDown':\n case 'ArrowLeft':\n result -= this.isLTR ? this.step : -this.step;\n break;\n case 'Home':\n result = this.step;\n break;\n case 'End':\n result = this.max;\n break;\n default:\n return;\n }\n\n // Verify new value is in bounds and emit\n this.value = clamp(result, 0, this.max);\n\n if (result === this.value) {\n this.emitEvent('igcChange', { detail: this.value });\n }\n }\n\n protected handleSlotChange() {\n if (this.hasProjectedSymbols) {\n this.max = this.ratingSymbols.length;\n }\n this.requestUpdate();\n }\n\n protected calcNewValue(x: number) {\n const { width, left, right } = this.container.getBoundingClientRect();\n const percent = this.isLTR ? (x - left) / width : (right - x) / width;\n const value = this.round(this.max * percent + this.step / 2);\n\n return clamp(value, this.step, this.max);\n }\n\n protected getPrecision(num: number) {\n const [_, decimal] = num.toString().split('.');\n return decimal ? decimal.length : 0;\n }\n\n protected round(value: number) {\n value = Math.round(value / this.step) * this.step;\n return Number(value.toFixed(this.getPrecision(this.step)));\n }\n\n /**\n * Increments the value of the control by `n` steps multiplied by the\n * step factor.\n */\n public stepUp(n = 1) {\n this.value += this.round(n * this.step);\n }\n\n /**\n * Decrements the value of the control by `n` steps multiplied by\n * the step factor.\n */\n public stepDown(n = 1) {\n this.value -= this.round(n * this.step);\n }\n\n protected *renderSymbols() {\n for (let i = 0; i < this.max; i++) {\n yield html`<span part=\"symbol ${this.size}\">${this.symbol}</span>`;\n }\n }\n\n protected renderProjected() {\n return html`${this.ratingSymbols.map((each) => {\n const clone = each.cloneNode(true) as IgcRatingSymbolComponent;\n clone.setAttribute('part', `symbol ${this.size}`);\n return clone;\n })}`;\n }\n\n protected renderFractionWrapper(styles: { width: string }) {\n return html`<div\n @click=${this.handleClick}\n @mouseenter=${this.hoverPreview ? this.handleMouseEnter : nothing}\n @mouseleave=${this.hoverPreview ? this.handleMouseLeave : nothing}\n @mousemove=${this.hoverPreview ? this.handleMouseMove : nothing}\n >\n <slot @slotchange=${this.handleSlotChange}></slot>\n\n <div style=${styleMap(styles)} part=\"fraction ${this.size}\">\n <div part=\"symbols-wrapper selected\">\n ${this.hasProjectedSymbols\n ? this.renderProjected()\n : this.renderSymbols()}\n </div>\n </div>\n <div part=\"symbols-wrapper\">\n ${this.hasProjectedSymbols\n ? this.renderProjected()\n : this.renderSymbols()}\n </div>\n </div>`;\n }\n\n protected override render() {\n const value = this.hoverState ? this.hoverValue : this.value;\n const styles = { width: `${Math.round((value / this.max) * 100)}%` };\n\n return html`\n <label part=\"label ${this.size}\">${this.label}</label>\n <div\n part=\"base\"\n role=\"slider\"\n tabindex=${ifDefined(this.disabled ? undefined : 0)}\n aria-label=${this.label ?? nothing}\n aria-valuemin=\"0\"\n aria-valuenow=${this.value}\n aria-valuemax=${this.max}\n aria-valuetext=${this.valueText}\n >\n ${this.renderFractionWrapper(styles)}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'igc-rating': IgcRatingComponent;\n }\n}\n"]}
1
+ {"version":3,"file":"rating.js","sourceRoot":"","sources":["../../../src/components/rating/rating.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAEtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAA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AAI,EAAE,MAAM,EAAE,CAAC;iDACV;AAIjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oDACnB;AAIxB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;wDAC3C;AAI5B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oDACnB;AAIxB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;kDACN;AAGtB;IADC,KAAK,CAAC,KAAK,CAAC;yDAQZ;AAGD;IADC,KAAK,CAAC,OAAO,CAAC;2DAGd;AAGD;IADC,KAAK,CAAC,MAAM,CAAC;+DAGb;AAGD;IADC,KAAK,CAAC,QAAQ,CAAC;+DAMf;AAxHkB,kBAAkB;IADtC,MAAM,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;GACjB,kBAAkB,CAsWtC;eAtWoB,kBAAkB","sourcesContent":["import { html, LitElement, nothing } from 'lit';\nimport { property, query, queryAssignedNodes, state } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport { guard } from 'lit/directives/guard.js';\nimport { themes } from '../../theming/theming-decorator.js';\nimport { watch } from '../common/decorators/watch.js';\nimport { Constructor } from '../common/mixins/constructor.js';\nimport { EventEmitterMixin } from '../common/mixins/event-emitter.js';\nimport { SizableMixin } from '../common/mixins/sizable.js';\nimport { clamp, isLTR } from '../common/util.js';\nimport { styles } from './rating.base.css.js';\nimport { styles as bootstrap } from './rating.bootstrap.css.js';\nimport { styles as fluent } from './rating.fluent.css.js';\nimport { styles as indigo } from './rating.indigo.css.js';\n\nimport { defineComponents } from '../common/definitions/defineComponents.js';\nimport IgcRatingSymbolComponent from './rating-symbol.js';\nimport IgcIconComponent from '../icon/icon.js';\n\ndefineComponents(IgcRatingSymbolComponent, IgcIconComponent);\n\nexport interface IgcRatingEventMap {\n igcChange: CustomEvent<number>;\n igcHover: CustomEvent<number>;\n}\n\n/**\n * Rating provides insight regarding others' opinions and experiences,\n * and can allow the user to submit a rating of their own\n *\n * @element igc-rating\n *\n * @fires igcChange - Emitted when the value of the control changes.\n * @fires igcHover - Emitted when hover is enabled and the user mouses over a symbol of the rating.\n *\n * @csspart base - The main wrapper which holds all of the rating elements.\n * @csspart label - The label part.\n * @csspart value-label - The value label part.\n * @csspart symbols - A wrapper for all rating symbols.\n * @csspart symbol - The part of the encapsulated default symbol.\n * @csspart full - The part of the encapsulated full symbols.\n * @csspart empty - The part of the encapsulated empty symbols.\n *\n * @cssproperty --symbol-size - The size of the symbols.\n * @cssproperty --symbol-full-color - The color of the filled symbol.\n * @cssproperty --symbol-empty-color - The color of the empty symbol.\n * @cssproperty --symbol-full-filter - The filter(s) used for the filled symbol.\n * @cssproperty --symbol-empty-filter - The filter(s) used for the empty symbol.\n */\n@themes({ fluent, bootstrap, indigo })\nexport default class IgcRatingComponent extends SizableMixin(\n EventEmitterMixin<IgcRatingEventMap, Constructor<LitElement>>(LitElement)\n) {\n public static readonly tagName = 'igc-rating';\n\n public static styles = [styles];\n\n protected ratingSymbols: Array<IgcRatingSymbolComponent> = [];\n\n @query('[part=\"symbols\"]', true)\n protected container!: HTMLElement;\n\n @queryAssignedNodes({ slot: 'value-label', flatten: true })\n protected valueLabel!: Array<Node>;\n\n @state()\n protected hoverValue = -1;\n\n @state()\n protected hoverState = false;\n\n protected get isInteractive() {\n return !(this.readonly || this.disabled);\n }\n\n protected get hasProjectedSymbols() {\n return this.ratingSymbols.length > 0;\n }\n\n protected get valueText() {\n // Skip IEEE 754 representation for screen readers\n const value = this.round(this.value);\n\n return this.valueFormat\n ? this.valueFormat\n .replace(/\\{0\\}/gm, `${value}`)\n .replace(/\\{1\\}/gm, `${this.max}`)\n : `${value} of ${this.max}`;\n }\n\n /**\n * The maximum value for the rating.\n *\n * If there are projected symbols, the maximum value will be resolved\n * based on the number of symbols.\n */\n @property({ type: Number })\n public max = 5;\n\n /**\n * The minimum value change allowed.\n *\n * Valid values are in the interval between 0 and 1 inclusive.\n */\n @property({ type: Number })\n public step = 1;\n\n /** The name attribute of the control */\n @property()\n public name!: string;\n\n /** The label of the control. */\n @property()\n public label!: string;\n\n /**\n * A format string which sets aria-valuetext. Instances of '{0}' will be replaced\n * with the current value of the control and instances of '{1}' with the maximum value for the control.\n *\n * Important for screen-readers and useful for localization.\n */\n @property({ attribute: 'value-format' })\n public valueFormat!: string;\n\n /** The current value of the component */\n @property({ type: Number })\n public value = 0;\n\n /** Sets the disabled state of the component */\n @property({ type: Boolean, reflect: true })\n public disabled = false;\n\n /** Sets hover preview behavior for the component */\n @property({ type: Boolean, reflect: true, attribute: 'hover-preview' })\n public hoverPreview = false;\n\n /** Sets the readonly state of the component */\n @property({ type: Boolean, reflect: true })\n public readonly = false;\n\n /** Toggles single selection visual mode. */\n @property({ type: Boolean })\n public single = false;\n\n @watch('max')\n protected handleMaxChange() {\n this.hasProjectedSymbols\n ? (this.max = this.ratingSymbols.length)\n : (this.max = Math.max(0, this.max));\n if (this.max < this.value) {\n this.value = this.max;\n }\n }\n\n @watch('value')\n protected handleValueChange() {\n this.value = clamp(this.value, 0, this.max);\n }\n\n @watch('step')\n protected handlePrecisionChange() {\n this.step = !this.single ? clamp(this.step, 0.001, 1) : 1;\n }\n\n @watch('single')\n protected handleSelectionChange() {\n if (this.single) {\n this.step = 1;\n this.value = Math.ceil(this.value);\n }\n }\n\n constructor() {\n super();\n this.addEventListener('keydown', this.handleKeyDown);\n }\n\n protected handleClick({ clientX }: MouseEvent) {\n if (!this.isInteractive) {\n return;\n }\n\n const value = this.calcNewValue(clientX);\n this.value === value ? (this.value = 0) : (this.value = value);\n this.emitEvent('igcChange', { detail: this.value });\n }\n\n protected handleMouseMove({ clientX }: MouseEvent) {\n if (!this.isInteractive) {\n return;\n }\n\n const value = this.calcNewValue(clientX);\n\n if (this.hoverValue !== value) {\n // Since mousemove spams a lot, only emit on a value change\n this.hoverValue = value;\n this.emitEvent('igcHover', { detail: this.hoverValue });\n }\n }\n\n protected handleMouseEnter() {\n if (this.isInteractive) {\n this.hoverState = true;\n }\n }\n\n protected handleMouseLeave() {\n if (this.isInteractive) {\n this.hoverState = false;\n }\n }\n\n protected handleKeyDown({ key }: KeyboardEvent) {\n if (!this.isInteractive) {\n return;\n }\n\n let result = this.value;\n const ltr = isLTR(this);\n\n switch (key) {\n case 'ArrowUp':\n case 'ArrowRight':\n result += ltr ? this.step : -this.step;\n break;\n case 'ArrowDown':\n case 'ArrowLeft':\n result -= ltr ? this.step : -this.step;\n break;\n case 'Home':\n result = this.step;\n break;\n case 'End':\n result = this.max;\n break;\n default:\n return;\n }\n\n // Verify new value is in bounds and emit\n this.value = clamp(result, 0, this.max);\n\n if (result === this.value) {\n this.emitEvent('igcChange', { detail: this.value });\n }\n }\n\n protected handleSlotChange(event: Event) {\n const slot = event.target as HTMLSlotElement;\n\n this.ratingSymbols = slot\n .assignedElements()\n .filter(\n (el) => el instanceof IgcRatingSymbolComponent\n ) as IgcRatingSymbolComponent[];\n\n if (this.hasProjectedSymbols) {\n this.max = this.ratingSymbols.length;\n }\n\n this.requestUpdate();\n }\n\n protected calcNewValue(x: number) {\n const { width, left, right } = this.container.getBoundingClientRect();\n const percent = isLTR(this) ? (x - left) / width : (right - x) / width;\n const value = this.round(this.max * percent + this.step / 2);\n\n return clamp(value, this.step, this.max);\n }\n\n protected getPrecision(num: number) {\n const [_, decimal] = num.toString().split('.');\n return decimal ? decimal.length : 0;\n }\n\n protected round(value: number) {\n value = Math.round(value / this.step) * this.step;\n return Number(value.toFixed(this.getPrecision(this.step)));\n }\n\n protected clipSymbol(index: number, isLTR = true) {\n const value = this.hoverState ? this.hoverValue : this.value;\n const progress = index + 1 - value;\n const exclusive = progress === 0 || this.value === index + 1 ? 0 : 1;\n const selection = this.single ? exclusive : progress;\n const activate = (p: number) => clamp(p * 100, 0, 100);\n\n const forward = `inset(0 ${activate(\n isLTR ? selection : 1 - selection\n )}% 0 0)`;\n const backward = `inset(0 0 0 ${activate(\n isLTR ? 1 - selection : selection\n )}%)`;\n\n return {\n backward: isLTR ? backward : forward,\n forward: isLTR ? forward : backward,\n };\n }\n\n /**\n * Increments the value of the control by `n` steps multiplied by the\n * step factor.\n */\n public stepUp(n = 1) {\n this.value += this.round(n * this.step);\n }\n\n /**\n * Decrements the value of the control by `n` steps multiplied by\n * the step factor.\n */\n public stepDown(n = 1) {\n this.value -= this.round(n * this.step);\n }\n\n protected *renderSymbols() {\n const ltr = isLTR(this);\n for (let i = 0; i < this.max; i++) {\n const { forward, backward } = this.clipSymbol(i, ltr);\n yield html`<igc-rating-symbol exportparts=\"symbol, full, empty\">\n <igc-icon\n collection=\"internal\"\n name=\"star\"\n style=${styleMap({ clipPath: forward })}\n ></igc-icon>\n <igc-icon\n collection=\"internal\"\n name=\"star_border\"\n style=${styleMap({ clipPath: backward })}\n slot=\"empty\"\n ></igc-icon>\n </igc-rating-symbol>`;\n }\n }\n\n protected clipProjected() {\n if (this.hasProjectedSymbols) {\n const ltr = isLTR(this);\n this.ratingSymbols.forEach((symbol: IgcRatingSymbolComponent, i) => {\n const full = symbol.shadowRoot?.querySelector(\n '[part=\"symbol full\"]'\n ) as HTMLElement;\n\n const empty = symbol.shadowRoot?.querySelector(\n '[part=\"symbol empty\"]'\n ) as HTMLElement;\n const { forward, backward } = this.clipSymbol(i, ltr);\n\n if (full) {\n full.style.clipPath = forward;\n }\n\n if (empty) {\n empty.style.clipPath = backward;\n }\n });\n }\n }\n\n protected override render() {\n const props = [\n this.value,\n this.hoverValue,\n this.max,\n this.step,\n this.single,\n this.hoverState,\n this.ratingSymbols,\n ];\n\n return html`\n <label part=\"label\" id=\"rating-label\" ?hidden=${!this.label}\n >${this.label}</label\n >\n <div\n part=\"base\"\n role=\"slider\"\n tabindex=${ifDefined(this.disabled ? undefined : 0)}\n aria-labelledby=\"rating-label\"\n aria-valuemin=\"0\"\n aria-valuenow=${this.value}\n aria-valuemax=${this.max}\n aria-valuetext=${this.valueText}\n >\n <div\n aria-hidden=\"true\"\n part=\"symbols\"\n @click=${this.handleClick}\n @mouseenter=${this.hoverPreview ? this.handleMouseEnter : nothing}\n @mouseleave=${this.hoverPreview ? this.handleMouseLeave : nothing}\n @mousemove=${this.hoverPreview ? this.handleMouseMove : nothing}\n >\n <slot @slotchange=${this.handleSlotChange}>\n ${guard(props, () => {\n this.clipProjected();\n return this.renderSymbols();\n })}\n </slot>\n </div>\n <label part=\"value-label\" ?hidden=${this.valueLabel.length === 0}>\n <slot name=\"value-label\"></slot>\n </label>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'igc-rating': IgcRatingComponent;\n }\n}\n"]}
@@ -0,0 +1,31 @@
1
+ import IgcDropdownGroupComponent from '../dropdown/dropdown-group.js';
2
+ import IgcSelectItemComponent from './select-item.js';
3
+ /**
4
+ * @element igc-select-group - A container for a group of `igc-select-item` components.
5
+ *
6
+ * @slot label - Contains the group's label.
7
+ * @slot - Intended to contain the items belonging to this group.
8
+ *
9
+ * @csspart label - The native label element.
10
+ */
11
+ export default class IgcSelectGroupComponent extends IgcDropdownGroupComponent {
12
+ /** @private */
13
+ static readonly tagName = "igc-select-group";
14
+ private observer;
15
+ private controlledItems;
16
+ /** All child `igc-select-item`s. */
17
+ items: Array<IgcSelectItemComponent>;
18
+ protected activeItems: Array<IgcSelectItemComponent>;
19
+ disabled: boolean;
20
+ constructor();
21
+ disconnectedCallback(): void;
22
+ protected getParent(): import("./select.js").default;
23
+ protected firstUpdated(): Promise<void>;
24
+ protected updateControlledItems(mutations: MutationRecord[]): void;
25
+ protected updateDisabled(): void;
26
+ }
27
+ declare global {
28
+ interface HTMLElementTagNameMap {
29
+ 'igc-select-group': IgcSelectGroupComponent;
30
+ }
31
+ }