@redvars/peacock 3.4.0 → 3.5.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 (258) hide show
  1. package/dist/BaseButton-DuASuVth.js +219 -0
  2. package/dist/BaseButton-DuASuVth.js.map +1 -0
  3. package/dist/BaseHyperlinkMixin-BNuwbiEf.js +65 -0
  4. package/dist/BaseHyperlinkMixin-BNuwbiEf.js.map +1 -0
  5. package/dist/assets/components.css +1 -1
  6. package/dist/assets/components.css.map +1 -1
  7. package/dist/assets/styles.css +1 -1
  8. package/dist/assets/styles.css.map +1 -1
  9. package/dist/banner.js +187 -0
  10. package/dist/banner.js.map +1 -0
  11. package/dist/bottom-sheet.js +2 -2
  12. package/dist/{button-COYCtuA8.js → button-DouvOfEU.js} +92 -283
  13. package/dist/button-DouvOfEU.js.map +1 -0
  14. package/dist/{button-group-DsXquZQn.js → button-group-CEdMwvJJ.js} +72 -48
  15. package/dist/button-group-CEdMwvJJ.js.map +1 -0
  16. package/dist/button-group.js +8 -5
  17. package/dist/button-group.js.map +1 -1
  18. package/dist/button.js +7 -4
  19. package/dist/button.js.map +1 -1
  20. package/dist/card.js +29 -74
  21. package/dist/card.js.map +1 -1
  22. package/dist/chart-bar.js +2 -2
  23. package/dist/chart-bar.js.map +1 -1
  24. package/dist/chart-doughnut.js +2 -2
  25. package/dist/chart-doughnut.js.map +1 -1
  26. package/dist/chart-pie.js +2 -2
  27. package/dist/chart-pie.js.map +1 -1
  28. package/dist/chart-stacked-bar.js +2 -2
  29. package/dist/chart-stacked-bar.js.map +1 -1
  30. package/dist/{class-map-3TAnCMAX.js → class-map-YU7g0o3B.js} +2 -2
  31. package/dist/{class-map-3TAnCMAX.js.map → class-map-YU7g0o3B.js.map} +1 -1
  32. package/dist/clock.js.map +1 -1
  33. package/dist/code-editor.js +4 -4
  34. package/dist/code-editor.js.map +1 -1
  35. package/dist/code-highlighter.js +5 -4
  36. package/dist/code-highlighter.js.map +1 -1
  37. package/dist/custom-elements-jsdocs.json +6627 -3477
  38. package/dist/custom-elements.json +10954 -7810
  39. package/dist/directive-ZPhl09Yt.js +9 -0
  40. package/dist/directive-ZPhl09Yt.js.map +1 -0
  41. package/dist/dispatch-event-utils-CuEqjlPT.js +127 -0
  42. package/dist/dispatch-event-utils-CuEqjlPT.js.map +1 -0
  43. package/dist/fab.js +423 -0
  44. package/dist/fab.js.map +1 -0
  45. package/dist/index.js +17 -9
  46. package/dist/index.js.map +1 -1
  47. package/dist/{observe-theme-change-DKAIv5BB.js → is-dark-mode-DicqGkCJ.js} +6 -2
  48. package/dist/is-dark-mode-DicqGkCJ.js.map +1 -0
  49. package/dist/{select-C3XAzenC.js → navigation-rail-Lxetd5-Z.js} +2426 -898
  50. package/dist/navigation-rail-Lxetd5-Z.js.map +1 -0
  51. package/dist/notification.js +418 -0
  52. package/dist/notification.js.map +1 -0
  53. package/dist/number-counter.js +2 -2
  54. package/dist/number-counter.js.map +1 -1
  55. package/dist/observe-slot-change-BGJfgg2E.js +31 -0
  56. package/dist/observe-slot-change-BGJfgg2E.js.map +1 -0
  57. package/dist/peacock-loader.js +48 -13
  58. package/dist/peacock-loader.js.map +1 -1
  59. package/dist/search.js +456 -0
  60. package/dist/search.js.map +1 -0
  61. package/dist/side-sheet.js +2 -2
  62. package/dist/src/__mixins/BaseButtonMixin.d.ts +20 -0
  63. package/dist/src/__mixins/BaseHyperlinkMixin.d.ts +18 -0
  64. package/dist/src/__mixins/MixinConstructor.d.ts +1 -0
  65. package/dist/src/__utils/cache-fetch.d.ts +1 -0
  66. package/dist/src/__utils/is-dark-mode.d.ts +1 -0
  67. package/dist/src/__utils/is-in-viewport.d.ts +1 -0
  68. package/dist/src/__utils/observe-slot-change.d.ts +1 -0
  69. package/dist/src/__utils/sanitize-svg.d.ts +1 -0
  70. package/dist/src/__utils/throttle.d.ts +4 -0
  71. package/dist/src/accordion/accordion-item.d.ts +33 -9
  72. package/dist/src/accordion/accordion.d.ts +21 -5
  73. package/dist/src/banner/banner.d.ts +43 -0
  74. package/dist/src/banner/index.d.ts +1 -0
  75. package/dist/src/button/BaseButton.d.ts +7 -57
  76. package/dist/src/button/button/button.d.ts +32 -3
  77. package/dist/src/button/button-group/button-group.d.ts +4 -4
  78. package/dist/src/button/icon-button/icon-button.d.ts +33 -8
  79. package/dist/src/card/card.d.ts +4 -15
  80. package/dist/src/empty-state/empty-state.d.ts +1 -1
  81. package/dist/src/fab/fab.d.ts +80 -0
  82. package/dist/src/fab/index.d.ts +1 -0
  83. package/dist/src/focus-ring/focus-ring.d.ts +11 -5
  84. package/dist/src/index.d.ts +8 -1
  85. package/dist/src/link/link.d.ts +3 -10
  86. package/dist/src/menu/menu/menu.d.ts +3 -2
  87. package/dist/src/menu/sub-menu/sub-menu.d.ts +1 -0
  88. package/dist/src/navigation-rail/index.d.ts +2 -0
  89. package/dist/src/navigation-rail/navigation-rail-item.d.ts +55 -0
  90. package/dist/src/navigation-rail/navigation-rail.d.ts +71 -0
  91. package/dist/src/notification/index.d.ts +1 -0
  92. package/dist/src/notification/notification.d.ts +69 -0
  93. package/dist/src/pagination/pagination.d.ts +8 -1
  94. package/dist/src/search/index.d.ts +1 -0
  95. package/dist/src/search/search.d.ts +76 -0
  96. package/dist/src/select/select.d.ts +3 -5
  97. package/dist/src/sidebar-menu/index.d.ts +3 -0
  98. package/dist/src/sidebar-menu/sidebar-menu-item.d.ts +58 -0
  99. package/dist/src/sidebar-menu/sidebar-menu.d.ts +38 -0
  100. package/dist/src/sidebar-menu/sidebar-sub-menu.d.ts +35 -0
  101. package/dist/src/slider/slider.d.ts +4 -0
  102. package/dist/src/snackbar/snackbar.d.ts +14 -1
  103. package/dist/src/toolbar/index.d.ts +1 -0
  104. package/dist/src/toolbar/toolbar.d.ts +86 -0
  105. package/dist/src/tooltip/tooltip.d.ts +3 -0
  106. package/dist/src/url-field/index.d.ts +1 -0
  107. package/dist/src/url-field/url-field.d.ts +48 -0
  108. package/dist/{style-map-CRFEoCEg.js → style-map-DVmWOuYy.js} +2 -2
  109. package/dist/{style-map-CRFEoCEg.js.map → style-map-DVmWOuYy.js.map} +1 -1
  110. package/dist/test/banner.test.d.ts +1 -0
  111. package/dist/test/search.test.d.ts +1 -0
  112. package/dist/test/sidebar-menu.test.d.ts +1 -0
  113. package/dist/test/toolbar.test.d.ts +1 -0
  114. package/dist/toolbar.js +306 -0
  115. package/dist/toolbar.js.map +1 -0
  116. package/dist/tsconfig.tsbuildinfo +1 -1
  117. package/dist/{unsafe-html-D3GHRaGQ.js → unsafe-html-BsGUjx94.js} +2 -2
  118. package/dist/{unsafe-html-D3GHRaGQ.js.map → unsafe-html-BsGUjx94.js.map} +1 -1
  119. package/package.json +1 -1
  120. package/readme.md +73 -65
  121. package/scss/mixin.scss +16 -0
  122. package/scss/styles.scss +4 -0
  123. package/src/__mixins/BaseButtonMixin.ts +83 -0
  124. package/src/__mixins/BaseHyperlinkMixin.ts +68 -0
  125. package/src/__mixins/MixinConstructor.ts +1 -0
  126. package/src/__mixins/README.md +19 -0
  127. package/src/__utils/cache-fetch.ts +65 -0
  128. package/src/__utils/is-dark-mode.ts +3 -0
  129. package/src/__utils/is-in-viewport.ts +6 -0
  130. package/src/__utils/observe-slot-change.ts +38 -0
  131. package/src/__utils/sanitize-svg.ts +27 -0
  132. package/src/__utils/throttle.ts +27 -0
  133. package/src/accordion/accordion-item.scss +136 -65
  134. package/src/accordion/accordion-item.ts +117 -44
  135. package/src/accordion/accordion.scss +24 -5
  136. package/src/accordion/accordion.ts +29 -23
  137. package/src/accordion/demo/index.html +74 -35
  138. package/src/banner/banner.scss +83 -0
  139. package/src/banner/banner.ts +101 -0
  140. package/src/banner/index.ts +1 -0
  141. package/src/button/BaseButton.ts +13 -115
  142. package/src/button/button/button-colors.scss +14 -14
  143. package/src/button/button/button-sizes.scss +4 -2
  144. package/src/button/button/button.ts +80 -26
  145. package/src/button/button-group/button-group.ts +5 -5
  146. package/src/button/icon-button/icon-button.ts +79 -44
  147. package/src/card/card.ts +50 -100
  148. package/src/chart-bar/chart-bar.ts +10 -15
  149. package/src/chart-bar/chart-stacked-bar.ts +15 -19
  150. package/src/chart-doughnut/chart-doughnut.ts +24 -28
  151. package/src/chart-pie/chart-pie.ts +20 -24
  152. package/src/checkbox/checkbox.scss +17 -34
  153. package/src/checkbox/checkbox.ts +4 -2
  154. package/src/clock/clock.ts +1 -1
  155. package/src/code-editor/code-editor.ts +4 -4
  156. package/src/code-highlighter/code-highlighter.scss +1 -0
  157. package/src/code-highlighter/code-highlighter.ts +3 -3
  158. package/src/date-picker/date-picker.ts +6 -3
  159. package/src/divider/divider.ts +3 -1
  160. package/src/elevation/elevation.scss +5 -5
  161. package/src/empty-state/empty-state.scss +7 -9
  162. package/src/empty-state/empty-state.ts +1 -1
  163. package/src/fab/fab-colors.scss +49 -0
  164. package/src/fab/fab-sizes.scss +47 -0
  165. package/src/fab/fab.scss +137 -0
  166. package/src/fab/fab.ts +214 -0
  167. package/src/fab/index.ts +1 -0
  168. package/src/field/field.ts +3 -1
  169. package/src/focus-ring/focus-ring.ts +47 -40
  170. package/src/icon/datasource.ts +1 -1
  171. package/src/icon/icon.ts +3 -1
  172. package/src/image/image.ts +3 -2
  173. package/src/index.ts +8 -1
  174. package/src/input/input.ts +8 -3
  175. package/src/link/link.ts +2 -15
  176. package/src/menu/menu/menu.scss +7 -0
  177. package/src/menu/menu/menu.ts +7 -4
  178. package/src/menu/menu-item/menu-item.ts +3 -1
  179. package/src/menu/sub-menu/sub-menu.ts +1 -0
  180. package/src/navigation-rail/index.ts +2 -0
  181. package/src/navigation-rail/navigation-rail-item.scss +216 -0
  182. package/src/navigation-rail/navigation-rail-item.ts +223 -0
  183. package/src/navigation-rail/navigation-rail.scss +72 -0
  184. package/src/navigation-rail/navigation-rail.ts +149 -0
  185. package/src/notification/index.ts +1 -0
  186. package/src/notification/notification.scss +201 -0
  187. package/src/notification/notification.ts +207 -0
  188. package/src/number-counter/number-counter.ts +3 -1
  189. package/src/number-field/number-field.ts +10 -6
  190. package/src/pagination/pagination.scss +33 -24
  191. package/src/pagination/pagination.ts +115 -60
  192. package/src/peacock-loader.ts +42 -5
  193. package/src/radio/radio.ts +3 -1
  194. package/src/search/index.ts +1 -0
  195. package/src/search/search-colors.scss +14 -0
  196. package/src/search/search.scss +204 -0
  197. package/src/search/search.ts +244 -0
  198. package/src/select/option.ts +1 -1
  199. package/src/select/select.scss +5 -0
  200. package/src/select/select.ts +71 -37
  201. package/src/sidebar-menu/demo/index.html +68 -0
  202. package/src/sidebar-menu/index.ts +3 -0
  203. package/src/sidebar-menu/sidebar-menu-item.scss +102 -0
  204. package/src/sidebar-menu/sidebar-menu-item.ts +151 -0
  205. package/src/{tree-view/tree-view.scss → sidebar-menu/sidebar-menu.scss} +1 -1
  206. package/src/sidebar-menu/sidebar-menu.ts +182 -0
  207. package/src/sidebar-menu/sidebar-sub-menu.scss +130 -0
  208. package/src/sidebar-menu/sidebar-sub-menu.ts +160 -0
  209. package/src/skeleton/skeleton.scss +18 -24
  210. package/src/slider/slider.scss +19 -0
  211. package/src/slider/slider.ts +30 -19
  212. package/src/snackbar/snackbar.scss +62 -31
  213. package/src/snackbar/snackbar.ts +91 -11
  214. package/src/switch/switch.ts +3 -1
  215. package/src/table/table.ts +3 -1
  216. package/src/tabs/tab.ts +10 -6
  217. package/src/text/text.css-component.scss +7 -1
  218. package/src/textarea/textarea.ts +4 -2
  219. package/src/time-picker/time-picker.ts +5 -3
  220. package/src/toolbar/index.ts +1 -0
  221. package/src/toolbar/toolbar-colors.scss +16 -0
  222. package/src/toolbar/toolbar.scss +165 -0
  223. package/src/toolbar/toolbar.ts +137 -0
  224. package/src/tooltip/tooltip.ts +24 -0
  225. package/src/url-field/index.ts +1 -0
  226. package/src/url-field/url-field.scss +50 -0
  227. package/src/url-field/url-field.ts +239 -0
  228. package/dist/button-COYCtuA8.js.map +0 -1
  229. package/dist/button-group-DsXquZQn.js.map +0 -1
  230. package/dist/directive-Cuw6h7YA.js +0 -9
  231. package/dist/directive-Cuw6h7YA.js.map +0 -1
  232. package/dist/dispatch-event-utils-B4odODQf.js +0 -277
  233. package/dist/dispatch-event-utils-B4odODQf.js.map +0 -1
  234. package/dist/observe-theme-change-DKAIv5BB.js.map +0 -1
  235. package/dist/select-C3XAzenC.js.map +0 -1
  236. package/dist/src/styleMixins.css.d.ts +0 -9
  237. package/dist/src/tree-view/index.d.ts +0 -2
  238. package/dist/src/tree-view/tree-node.d.ts +0 -69
  239. package/dist/src/tree-view/tree-view.d.ts +0 -40
  240. package/dist/src/tree-view/wc-tree-view.d.ts +0 -6
  241. package/dist/src/utils.d.ts +0 -9
  242. package/dist/test/tree-view.test.d.ts +0 -1
  243. package/src/styleMixins.css.ts +0 -55
  244. package/src/tree-view/demo/index.html +0 -57
  245. package/src/tree-view/index.ts +0 -2
  246. package/src/tree-view/tree-node.scss +0 -101
  247. package/src/tree-view/tree-node.ts +0 -268
  248. package/src/tree-view/tree-view.ts +0 -182
  249. package/src/tree-view/wc-tree-view.ts +0 -9
  250. package/src/utils.ts +0 -193
  251. /package/dist/src/{spread.d.ts → __directive/spread.d.ts} +0 -0
  252. /package/dist/src/{utils → __utils}/copy-to-clipboard.d.ts +0 -0
  253. /package/dist/src/{utils → __utils}/dispatch-event-utils.d.ts +0 -0
  254. /package/dist/src/{utils → __utils}/observe-theme-change.d.ts +0 -0
  255. /package/src/{spread.ts → __directive/spread.ts} +0 -0
  256. /package/src/{utils → __utils}/copy-to-clipboard.ts +0 -0
  257. /package/src/{utils → __utils}/dispatch-event-utils.ts +0 -0
  258. /package/src/{utils → __utils}/observe-theme-change.ts +0 -0
@@ -1,8 +1,10 @@
1
1
  import { html, LitElement } from 'lit';
2
2
  import { property, state } from 'lit/decorators.js';
3
3
  import { classMap } from 'lit/directives/class-map.js';
4
+
5
+ import { observerSlotChangesWithCallback } from '@/__utils/observe-slot-change.js';
6
+
4
7
  import styles from './divider.scss';
5
- import { observerSlotChangesWithCallback } from '../utils.js';
6
8
 
7
9
  /**
8
10
  * @label Divider
@@ -1,3 +1,7 @@
1
+ @use '../../scss/mixin';
2
+
3
+ @include mixin.base-styles;
4
+
1
5
  /**
2
6
  * Derived from Material Design Elevation
3
7
  * https://github.com/material-components/material-web/blob/main/elevation/internal/_elevation.scss
@@ -7,11 +11,7 @@
7
11
  .shadow,
8
12
  .shadow::before,
9
13
  .shadow::after {
10
- border-start-start-radius: var(--elevation-container-shape-start-start, var(--elevation-container-shape));
11
- border-start-end-radius: var(--elevation-container-shape-start-end, var(--elevation-container-shape));
12
- border-end-start-radius: var(--elevation-container-shape-end-start, var(--elevation-container-shape));
13
- border-end-end-radius: var(--elevation-container-shape-end-end, var(--elevation-container-shape));
14
- corner-shape: var(--elevation-container-shape-variant);
14
+ @include mixin.apply-container-shape(elevation);
15
15
 
16
16
  inset: 0;
17
17
  position: absolute;
@@ -38,8 +38,8 @@
38
38
  flex-direction: column;
39
39
  justify-content: center;
40
40
 
41
- .title {
42
- @include mixin.get-typography(headline-medium-emphasized);
41
+ .headline {
42
+ @include mixin.get-typography(headline-medium);
43
43
  margin-bottom: var(--spacing-200);
44
44
  color: var(--color-on-surface)
45
45
  }
@@ -64,10 +64,6 @@
64
64
  .content {
65
65
  width: 50%;
66
66
  }
67
-
68
- .headline {
69
- @include mixin.get-typography(title-medium);
70
- }
71
67
  }
72
68
  }
73
69
 
@@ -75,7 +71,7 @@
75
71
  .empty-state {
76
72
  .empty-state-container {
77
73
  flex-direction: column;
78
- gap: var(--spacing-200);
74
+ gap: var(--spacing-150);
79
75
 
80
76
  .illustration {
81
77
  height: auto;
@@ -84,8 +80,10 @@
84
80
  }
85
81
  }
86
82
 
87
- .headline {
88
- @include mixin.get-typography(title-small);
83
+ .content {
84
+ .headline {
85
+ @include mixin.get-typography(headline-small);
86
+ }
89
87
  }
90
88
  }
91
89
  }
@@ -12,7 +12,7 @@ import styles from './empty-state.scss';
12
12
  *
13
13
  * @example
14
14
  * ```html
15
- * <wc-empty-state width="80%" headline="No items found"></wc-empty-state>
15
+ * <wc-empty-state style="width:100%" headline="No items found"></wc-empty-state>
16
16
  * ```
17
17
  */
18
18
  export class EmptyState extends LitElement {
@@ -0,0 +1,49 @@
1
+ :host {
2
+ --tonal-fab-container-color: var(--color-surface-container-high);
3
+ --tonal-fab-label-text-color: var(--color-on-surface);
4
+
5
+ --filled-fab-container-color: var(--color-surface);
6
+ --filled-fab-label-text-color: var(--color-on-surface);
7
+ }
8
+
9
+ :host([color='surface']) {
10
+ --tonal-fab-container-color: var(--color-surface-container-high);
11
+ --tonal-fab-label-text-color: var(--color-on-surface);
12
+
13
+ --filled-fab-container-color: var(--color-surface);
14
+ --filled-fab-label-text-color: var(--color-on-surface);
15
+ }
16
+
17
+ :host([color='primary']) {
18
+ --tonal-fab-container-color: var(--color-primary-container);
19
+ --tonal-fab-label-text-color: var(--color-on-primary-container);
20
+
21
+ --filled-fab-container-color: var(--color-primary);
22
+ --filled-fab-label-text-color: var(--color-on-primary);
23
+ }
24
+
25
+ :host([color='secondary']) {
26
+ --tonal-fab-container-color: var(--color-secondary-container);
27
+ --tonal-fab-label-text-color: var(--color-on-secondary-container);
28
+
29
+ --filled-fab-container-color: var(--color-secondary);
30
+ --filled-fab-label-text-color: var(--color-on-secondary);
31
+ }
32
+
33
+ :host([color='tertiary']) {
34
+ --tonal-fab-container-color: var(--color-tertiary-container);
35
+ --tonal-fab-label-text-color: var(--color-on-tertiary-container);
36
+
37
+ --filled-fab-container-color: var(--color-tertiary);
38
+ --filled-fab-label-text-color: var(--color-on-tertiary);
39
+ }
40
+
41
+ .fab.variant-tonal {
42
+ --_fab-container-color: var(--tonal-fab-container-color);
43
+ --_fab-label-text-color: var(--tonal-fab-label-text-color);
44
+ }
45
+
46
+ .fab.variant-filled {
47
+ --_fab-container-color: var(--filled-fab-container-color);
48
+ --_fab-label-text-color: var(--filled-fab-label-text-color);
49
+ }
@@ -0,0 +1,47 @@
1
+ /* Small FAB: 40x40dp, shape-corner-medium */
2
+ :host([size='sm']) {
3
+ --fab-container-shape: var(--shape-corner-medium);
4
+ }
5
+
6
+ :host([size='sm']) .fab {
7
+ width: 2.5rem;
8
+ height: 2.5rem;
9
+ --_fab-icon-size: 1.5rem;
10
+ }
11
+
12
+ /* Standard/Medium FAB: 56x56dp, shape-corner-large (default) */
13
+ :host([size='md']) .fab {
14
+ width: 3.5rem;
15
+ height: 3.5rem;
16
+ --_fab-icon-size: 1.5rem;
17
+ }
18
+
19
+ /* Large FAB: 96x96dp, shape-corner-extra-large */
20
+ :host([size='lg']) {
21
+ --fab-container-shape: var(--shape-corner-extra-large);
22
+ }
23
+
24
+ :host([size='lg']) .fab {
25
+ width: 6rem;
26
+ height: 6rem;
27
+ --_fab-icon-size: 2.25rem;
28
+ }
29
+
30
+ /* Extended FAB overrides (height fixed, width auto) */
31
+ :host([size='sm']) .fab.extended {
32
+ width: auto;
33
+ min-width: 4rem;
34
+ height: 2.5rem;
35
+ }
36
+
37
+ :host([size='md']) .fab.extended {
38
+ width: auto;
39
+ min-width: 5rem;
40
+ height: 3.5rem;
41
+ }
42
+
43
+ :host([size='lg']) .fab.extended {
44
+ width: auto;
45
+ min-width: 6rem;
46
+ height: 6rem;
47
+ }
@@ -0,0 +1,137 @@
1
+ @use '../../scss/mixin';
2
+
3
+ @include mixin.base-styles;
4
+
5
+ :host {
6
+ display: inline-flex;
7
+
8
+ --fab-container-shape: var(--shape-corner-large);
9
+ --fab-container-elevation-level: 3;
10
+ }
11
+
12
+ /*
13
+ * Reset native button/link styles
14
+ */
15
+ .fab-element {
16
+ background: transparent;
17
+ border: none;
18
+ appearance: none;
19
+ margin: 0;
20
+ outline: none;
21
+ text-decoration: none;
22
+ cursor: pointer;
23
+ }
24
+
25
+ .fab {
26
+ position: relative;
27
+ display: inline-flex;
28
+ align-items: center;
29
+ justify-content: center;
30
+ border-radius: var(--fab-container-shape);
31
+ font-family: var(--font-family-sans) !important;
32
+
33
+ .fab-content {
34
+ display: flex;
35
+ align-items: center;
36
+ justify-content: center;
37
+ pointer-events: none;
38
+ z-index: 0;
39
+ gap: 0.75rem;
40
+
41
+ color: var(--_fab-label-text-color);
42
+ --icon-size: var(--_fab-icon-size);
43
+ --icon-color: var(--_fab-label-text-color);
44
+ }
45
+
46
+ .fab-label {
47
+ font-size: 0.875rem;
48
+ font-weight: var(--font-weight-medium);
49
+ line-height: 1.25rem;
50
+ letter-spacing: 0.00625em;
51
+ white-space: nowrap;
52
+ }
53
+
54
+ &.disabled {
55
+ cursor: not-allowed;
56
+ }
57
+
58
+ /*
59
+ Background layers
60
+ */
61
+ .focus-ring {
62
+ z-index: 2;
63
+ --focus-ring-container-shape-start-start: var(--fab-container-shape);
64
+ --focus-ring-container-shape-start-end: var(--fab-container-shape);
65
+ --focus-ring-container-shape-end-start: var(--fab-container-shape);
66
+ --focus-ring-container-shape-end-end: var(--fab-container-shape);
67
+ }
68
+
69
+ .ripple {
70
+ border-radius: var(--fab-container-shape);
71
+ --ripple-state-opacity: var(--_fab-container-state-opacity, 0);
72
+ --ripple-pressed-color: var(--_fab-label-text-color);
73
+ }
74
+
75
+ .background {
76
+ display: block;
77
+ position: absolute;
78
+ inset: 0;
79
+ background-color: var(--_fab-container-color);
80
+ opacity: var(--_fab-container-opacity, 1);
81
+ border-radius: var(--fab-container-shape);
82
+ pointer-events: none;
83
+ }
84
+
85
+ .elevation {
86
+ --elevation-level: var(--_fab-container-elevation-level, var(--fab-container-elevation-level));
87
+ transition-duration: 280ms;
88
+ --elevation-container-shape-start-start: var(--fab-container-shape);
89
+ --elevation-container-shape-start-end: var(--fab-container-shape);
90
+ --elevation-container-shape-end-start: var(--fab-container-shape);
91
+ --elevation-container-shape-end-end: var(--fab-container-shape);
92
+ }
93
+
94
+ &:hover:not(.disabled) {
95
+ --_fab-container-elevation-level: 4;
96
+ --_fab-container-state-opacity: 0.08;
97
+ }
98
+
99
+ &.pressed:not(.disabled) {
100
+ --_fab-container-elevation-level: 3;
101
+ --_fab-container-state-opacity: 0.12;
102
+ }
103
+
104
+ &.lowered {
105
+ --fab-container-elevation-level: 1;
106
+
107
+ &:hover:not(.disabled) {
108
+ --_fab-container-elevation-level: 2;
109
+ }
110
+
111
+ &.pressed:not(.disabled) {
112
+ --_fab-container-elevation-level: 1;
113
+ }
114
+ }
115
+
116
+ &.disabled {
117
+ --_fab-container-color: var(--color-on-surface);
118
+ --_fab-container-opacity: 0.12;
119
+ --_fab-label-text-color: var(--color-on-surface);
120
+ --_fab-label-text-opacity: 0.38;
121
+ --_fab-container-elevation-level: 0;
122
+
123
+ .ripple {
124
+ display: none;
125
+ }
126
+
127
+ .fab-content {
128
+ opacity: 0.38;
129
+ }
130
+ }
131
+ }
132
+
133
+ /* Extended FAB */
134
+ .fab.extended {
135
+ padding: 0 1rem;
136
+ border-radius: var(--fab-container-shape);
137
+ }
package/src/fab/fab.ts ADDED
@@ -0,0 +1,214 @@
1
+ import { html, nothing } from 'lit';
2
+ import { property, state } from 'lit/decorators.js';
3
+ import { classMap } from 'lit/directives/class-map.js';
4
+ import { ifDefined } from 'lit/directives/if-defined.js';
5
+
6
+ import IndividualComponent from '@/IndividualComponent.js';
7
+ import { dispatchActivationClick, isActivationClick } from '@/__utils/dispatch-event-utils.js';
8
+ import { throttle } from '@/__utils/throttle.js';
9
+ import { spread } from '@/__directive/spread.js';
10
+
11
+ import styles from './fab.scss';
12
+ import colorStyles from './fab-colors.scss';
13
+ import sizeStyles from './fab-sizes.scss';
14
+ import { BaseButton } from '@/button/BaseButton.js';
15
+
16
+ /**
17
+ * @label FAB
18
+ * @tag wc-fab
19
+ * @rawTag fab
20
+ *
21
+ * @summary The FAB (Floating Action Button) represents the primary action on a screen.
22
+ * @overview
23
+ * <p>A Floating Action Button (FAB) is a circular button that represents the primary action on a screen. It follows the Material Design 3 specification and supports four color roles and two variants.</p>
24
+ *
25
+ * @cssprop --fab-container-color: Background color of the FAB container.
26
+ * @cssprop --fab-label-text-color: Text and icon color of the FAB label.
27
+ * @cssprop --fab-container-shape: Corner radius of the FAB. Defaults to var(--shape-corner-large).
28
+ * @cssprop --fab-container-elevation-level: Elevation level of the FAB. Defaults to 3.
29
+ *
30
+ * @fires {MouseEvent} click - Dispatched when the FAB is clicked.
31
+ *
32
+ * @example
33
+ * ```html
34
+ * <wc-fab><wc-icon name="add"></wc-icon></wc-fab>
35
+ * ```
36
+ * @tags controls
37
+ */
38
+ @IndividualComponent
39
+ export class Fab extends BaseButton {
40
+ static override styles = [styles, colorStyles, sizeStyles];
41
+
42
+ #id = crypto.randomUUID();
43
+
44
+
45
+
46
+ /**
47
+ * Optional label text for the extended FAB variant.
48
+ * When set, the FAB displays both the icon and a text label.
49
+ */
50
+ @property({ type: String }) label?: string;
51
+
52
+ /**
53
+ * The color role of the FAB.
54
+ * `"surface"` uses the surface color role.
55
+ * `"primary"` uses the primary color role.
56
+ * `"secondary"` uses the secondary color role.
57
+ * `"tertiary"` uses the tertiary color role.
58
+ */
59
+ @property({ reflect: true }) color: 'surface' | 'primary' | 'secondary' | 'tertiary' = 'surface';
60
+
61
+ /**
62
+ * The style variant of the FAB.
63
+ * `"tonal"` uses container colors.
64
+ * `"filled"` uses solid role colors.
65
+ */
66
+ @property({ reflect: true }) variant: 'tonal' | 'filled' = 'tonal';
67
+
68
+ /**
69
+ * The size of the FAB.
70
+ * `"sm"` renders a small FAB (40×40dp).
71
+ * `"md"` renders a standard FAB (56×56dp). This is the default.
72
+ * `"lg"` renders a large FAB (96×96dp).
73
+ */
74
+ @property({ reflect: true }) size: 'sm' | 'md' | 'lg' = 'md';
75
+
76
+ /**
77
+ * If `true`, the FAB is in a lowered (resting) state with reduced elevation.
78
+ */
79
+ @property({ type: Boolean, reflect: true }) lowered: boolean = false;
80
+
81
+ /**
82
+ * Additional ARIA attributes to pass to the inner button/anchor element.
83
+ */
84
+ @property({ reflect: true })
85
+ configAria?: { [key: string]: any };
86
+
87
+ /**
88
+ * Sets the delay for throttle in milliseconds. Defaults to 200 milliseconds.
89
+ */
90
+ @property() throttleDelay = 200;
91
+
92
+ /**
93
+ * Tooltip text shown on hover.
94
+ */
95
+ @property() tooltip?: string;
96
+
97
+ @state()
98
+ isPressed = false;
99
+
100
+ override focus() {
101
+ this.buttonElement?.focus();
102
+ }
103
+
104
+ override blur() {
105
+ this.buttonElement?.blur();
106
+ }
107
+
108
+ override firstUpdated() {
109
+ this.__dispatchClickWithThrottle = throttle(
110
+ this.__dispatchClick,
111
+ this.throttleDelay,
112
+ );
113
+ }
114
+
115
+ __dispatchClick = (event: MouseEvent | KeyboardEvent) => {
116
+ if (this.disabled && this.href) {
117
+ event.stopImmediatePropagation();
118
+ event.preventDefault();
119
+ return;
120
+ }
121
+
122
+ if (!isActivationClick(event) || !this.buttonElement) {
123
+ return;
124
+ }
125
+
126
+ this.focus();
127
+ dispatchActivationClick(this.buttonElement);
128
+ };
129
+
130
+ __getDisabledReasonID() {
131
+ return this.disabled ? `disabled-reason-${this.#id}` : nothing;
132
+ }
133
+
134
+ override render() {
135
+ const isLink = this.__isLink();
136
+ const isExtended = !!this.label;
137
+
138
+ const cssClasses = {
139
+ button: true,
140
+ fab: true,
141
+ 'fab-element': true,
142
+ [`size-${this.size}`]: true,
143
+ [`color-${this.color}`]: true,
144
+ [`variant-${this.variant}`]: true,
145
+ extended: isExtended,
146
+ lowered: this.lowered,
147
+ disabled: this.disabled,
148
+ pressed: this.isPressed,
149
+ };
150
+
151
+ if (!isLink) {
152
+ return html`<button
153
+ class=${classMap(cssClasses)}
154
+ id="button"
155
+ type="button"
156
+ @click=${this.__dispatchClickWithThrottle}
157
+ @mousedown=${this.__handlePress}
158
+ @keydown=${this.__handlePress}
159
+ @keyup=${this.__handlePress}
160
+
161
+ aria-describedby=${ifDefined(this.softDisabled ? BaseButton.DISABLED_REASON_ID : undefined)}
162
+ ?aria-disabled=${this.softDisabled}
163
+
164
+ ?disabled=${this.disabled}
165
+ ${spread(this.configAria)}
166
+ >
167
+ ${this.__renderFabContent(isExtended)}
168
+ </button>
169
+ ${this.__renderTooltip()}`;
170
+ }
171
+
172
+ return html`<a
173
+ class=${classMap(cssClasses)}
174
+ id="button"
175
+ tabindex=${this.disabled ? '-1' : '0'}
176
+ href=${ifDefined(this.href)}
177
+ target=${this.target}
178
+ @click=${this.__dispatchClick}
179
+ @mousedown=${this.__handlePress}
180
+ @keydown=${this.__handlePress}
181
+ @keyup=${this.__handlePress}
182
+ role="button"
183
+
184
+ aria-describedby=${ifDefined(this.softDisabled ? BaseButton.DISABLED_REASON_ID : undefined)}
185
+ ?aria-disabled=${this.softDisabled}
186
+
187
+ ${spread(this.configAria)}
188
+ >
189
+ ${this.__renderFabContent(isExtended)}
190
+ </a>
191
+ ${this.__renderTooltip()}`;
192
+ }
193
+
194
+ __renderFabContent(isExtended: boolean) {
195
+ return html`
196
+ <wc-focus-ring class="focus-ring" for='button'></wc-focus-ring>
197
+ <wc-elevation class="elevation"></wc-elevation>
198
+ <div class="background"></div>
199
+ <wc-ripple class="ripple"></wc-ripple>
200
+ <wc-skeleton class="skeleton"></wc-skeleton>
201
+
202
+ <div class="fab-content">
203
+
204
+ <slot></slot>
205
+ ${isExtended
206
+ ? html`<span class="fab-label">${this.label}</span>`
207
+ : nothing}
208
+ </div>
209
+
210
+ ${this.__renderDisabledReason(this.softDisabled)}
211
+ `;
212
+ }
213
+
214
+ }
@@ -0,0 +1 @@
1
+ export { Fab } from './fab.js';
@@ -1,8 +1,10 @@
1
1
  import { html, LitElement, nothing } from 'lit';
2
2
  import { property, state } from 'lit/decorators.js';
3
3
  import { classMap } from 'lit/directives/class-map.js';
4
+
5
+ import { observerSlotChangesWithCallback } from '@/__utils/observe-slot-change.js';
6
+
4
7
  import styles from './field.scss';
5
- import { observerSlotChangesWithCallback } from '../utils.js';
6
8
 
7
9
  /**
8
10
  * @label Field
@@ -20,34 +20,14 @@ export class FocusRing extends LitElement {
20
20
 
21
21
  @property({ type: String }) for = '';
22
22
 
23
+ private __boundFocusin = this.__focusin.bind(this);
23
24
 
24
- render() {
25
- return nothing;
26
- }
27
-
28
- _control?: HTMLElement;
29
-
30
- _focusTarget?: HTMLElement;
25
+ private __boundFocusout = this.__focusout.bind(this);
31
26
 
32
- get control() {
33
- return this._control || null;
34
- }
35
-
36
- set control(control: HTMLElement | null) {
37
- if (control) {
38
- this._control = control;
39
- } else {
40
- this.detach();
41
- }
42
- }
27
+ private __boundPointerdown = this.__pointerdown.bind(this);
43
28
 
44
- set forElement(value: HTMLElement | null) {
45
- if (value) {
46
- this._focusTarget = value;
47
- this.attach();
48
- } else {
49
- this.detach();
50
- }
29
+ render() {
30
+ return nothing;
51
31
  }
52
32
 
53
33
  connectedCallback() {
@@ -60,6 +40,22 @@ export class FocusRing extends LitElement {
60
40
  super.disconnectedCallback();
61
41
  }
62
42
 
43
+ updated(changed: Map<string, unknown>) {
44
+ if (changed.has('for')) {
45
+ const prevId = changed.get('for') as string;
46
+ if (prevId) {
47
+ const root = this.parentElement?.getRootNode() as ShadowRoot | Document;
48
+ const prevEl = root?.getElementById(prevId) ?? document.getElementById(prevId);
49
+ if (prevEl) {
50
+ prevEl.removeEventListener('focusin', this.__boundFocusin);
51
+ prevEl.removeEventListener('focusout', this.__boundFocusout);
52
+ prevEl.removeEventListener('pointerdown', this.__boundPointerdown);
53
+ }
54
+ }
55
+ this.attach();
56
+ }
57
+ }
58
+
63
59
  __focusin() {
64
60
  const focusTarget = this.__getFocusTarget();
65
61
  this.visible = focusTarget?.matches(':focus-visible') ?? false;
@@ -73,35 +69,46 @@ export class FocusRing extends LitElement {
73
69
  this.visible = false;
74
70
  }
75
71
 
72
+ /**
73
+ * Resolves the element that should receive focus-ring event listeners by id.
74
+ * Prefers lookup from the current control's root node, then falls back to a
75
+ * document-level lookup.
76
+ *
77
+ * @returns The resolved focus target, if one can be found.
78
+ */
76
79
  __getFocusTarget(): HTMLElement | undefined {
77
-
78
- if (this._focusTarget) {
79
- return this._focusTarget;
80
+ if (this.for) {
81
+ const root = this.parentElement?.getRootNode() as ShadowRoot | Document;
82
+ if (root) {
83
+ const focusTarget = root.getElementById(this.for);
84
+ if (focusTarget) {
85
+ return focusTarget;
86
+ }
87
+ }
88
+ const focusTarget = document.getElementById(this.for);
89
+ if (focusTarget) {
90
+ return focusTarget;
91
+ }
80
92
  }
81
93
 
82
- const focusTarget = document.getElementById(this.for);
83
- if (focusTarget) {
84
- return focusTarget
85
- }
86
- return undefined;
94
+ return undefined;
87
95
  }
88
96
 
89
97
  attach() {
90
98
  const focusTarget = this.__getFocusTarget();
91
99
  if (focusTarget) {
92
- focusTarget.addEventListener('focusin', this.__focusin.bind(this));
93
- focusTarget.addEventListener('focusout', this.__focusout.bind(this));
94
- focusTarget.addEventListener('pointerdown', this.__pointerdown.bind(this));
100
+ focusTarget.addEventListener('focusin', this.__boundFocusin);
101
+ focusTarget.addEventListener('focusout', this.__boundFocusout);
102
+ focusTarget.addEventListener('pointerdown', this.__boundPointerdown);
95
103
  }
96
104
  }
97
105
 
98
106
  detach() {
99
107
  const focusTarget = this.__getFocusTarget();
100
108
  if (focusTarget) {
101
- focusTarget.removeEventListener('focusin', this.__focusin.bind(this));
102
- focusTarget.removeEventListener('focusout', this.__focusout.bind(this));
103
- focusTarget.removeEventListener('pointerdown', this.__pointerdown.bind(this));
109
+ focusTarget.removeEventListener('focusin', this.__boundFocusin);
110
+ focusTarget.removeEventListener('focusout', this.__boundFocusout);
111
+ focusTarget.removeEventListener('pointerdown', this.__boundPointerdown);
104
112
  }
105
- this._control = undefined;
106
113
  }
107
114
  }
@@ -1,4 +1,4 @@
1
- import { createCacheFetch } from '../utils.js';
1
+ import { createCacheFetch } from '@/__utils/cache-fetch.js';
2
2
 
3
3
  const PROVIDERS: Record<string, (name: string) => string> = {
4
4
  'material-symbols': (name: string) =>
package/src/icon/icon.ts CHANGED
@@ -1,8 +1,10 @@
1
1
  import { html, LitElement } from 'lit';
2
2
  import { property, state } from 'lit/decorators.js';
3
3
  import { unsafeSVG } from 'lit/directives/unsafe-svg.js';
4
+
5
+ import { sanitizeSvg } from '@/__utils/sanitize-svg.js';
6
+
4
7
  import { fetchIcon, fetchSVG } from './datasource.js';
5
- import { sanitizeSvg } from '../utils.js';
6
8
  import styles from './icon.scss';
7
9
 
8
10
  export type IconProvider = 'material-symbols' | 'material-icons';