@webtides/element-library 0.1.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 (238) hide show
  1. package/CHANGELOG.md +109 -0
  2. package/LICENSE +21 -0
  3. package/README.md +125 -0
  4. package/all.js +26 -0
  5. package/custom-elements.json +7683 -0
  6. package/index.js +3 -0
  7. package/package.json +132 -0
  8. package/patches/@glidejs+glide+3.6.2.patch +11 -0
  9. package/src/components/accordion/accordion.changelog.md +47 -0
  10. package/src/components/accordion/accordion.define.js +3 -0
  11. package/src/components/accordion/accordion.events.js +3 -0
  12. package/src/components/accordion/accordion.js +144 -0
  13. package/src/components/accordion/accordion.readme.md +71 -0
  14. package/src/components/accordion/accordion.style.js +64 -0
  15. package/src/components/accordion-group/accordion-group.changelog.md +35 -0
  16. package/src/components/accordion-group/accordion-group.define.js +3 -0
  17. package/src/components/accordion-group/accordion-group.js +63 -0
  18. package/src/components/accordion-group/accordion-group.readme.md +56 -0
  19. package/src/components/amount-field/amount-field.changelog.md +40 -0
  20. package/src/components/amount-field/amount-field.define.js +3 -0
  21. package/src/components/amount-field/amount-field.js +91 -0
  22. package/src/components/amount-field/amount-field.readme.md +65 -0
  23. package/src/components/amount-field/amount-field.style.js +58 -0
  24. package/src/components/button/button.changelog.md +19 -0
  25. package/src/components/button/button.define.js +3 -0
  26. package/src/components/button/button.js +174 -0
  27. package/src/components/button/button.readme.md +91 -0
  28. package/src/components/button/button.style.js +251 -0
  29. package/src/components/carousel/carousel.changelog.md +58 -0
  30. package/src/components/carousel/carousel.define.js +3 -0
  31. package/src/components/carousel/carousel.events.js +3 -0
  32. package/src/components/carousel/carousel.js +232 -0
  33. package/src/components/carousel/carousel.readme.md +78 -0
  34. package/src/components/carousel/carousel.style.js +142 -0
  35. package/src/components/carousel/glide/components/ShadowAnchors.js +12 -0
  36. package/src/components/carousel/glide/components/ShadowClones.js +41 -0
  37. package/src/components/carousel/glide/components/ShadowGaps.js +28 -0
  38. package/src/components/carousel/glide/components/ShadowHtml.js +32 -0
  39. package/src/components/checkbox-field/checkbox-field.changelog.md +47 -0
  40. package/src/components/checkbox-field/checkbox-field.define.js +3 -0
  41. package/src/components/checkbox-field/checkbox-field.js +102 -0
  42. package/src/components/checkbox-field/checkbox-field.readme.md +66 -0
  43. package/src/components/checkbox-field/checkbox-field.style.js +69 -0
  44. package/src/components/dialog/dialog.changelog.md +24 -0
  45. package/src/components/dialog/dialog.define.js +3 -0
  46. package/src/components/dialog/dialog.events.js +8 -0
  47. package/src/components/dialog/dialog.js +271 -0
  48. package/src/components/dialog/dialog.readme.md +122 -0
  49. package/src/components/dialog/dialog.style.js +124 -0
  50. package/src/components/dropdown/dropdown.changelog.md +39 -0
  51. package/src/components/dropdown/dropdown.define.js +3 -0
  52. package/src/components/dropdown/dropdown.js +98 -0
  53. package/src/components/dropdown/dropdown.readme.md +69 -0
  54. package/src/components/dropdown/dropdown.style.js +17 -0
  55. package/src/components/form-field/form-field.changelog.md +35 -0
  56. package/src/components/form-field/form-field.define.js +3 -0
  57. package/src/components/form-field/form-field.events.js +4 -0
  58. package/src/components/form-field/form-field.js +210 -0
  59. package/src/components/form-field/form-field.readme.md +80 -0
  60. package/src/components/form-field/form-field.style.js +25 -0
  61. package/src/components/input-field/input-field.changelog.md +39 -0
  62. package/src/components/input-field/input-field.define.js +3 -0
  63. package/src/components/input-field/input-field.js +71 -0
  64. package/src/components/input-field/input-field.readme.md +90 -0
  65. package/src/components/input-field/input-field.style.js +33 -0
  66. package/src/components/lazy-src/lazy-src.changelog.md +57 -0
  67. package/src/components/lazy-src/lazy-src.define.js +3 -0
  68. package/src/components/lazy-src/lazy-src.events.js +5 -0
  69. package/src/components/lazy-src/lazy-src.js +100 -0
  70. package/src/components/lazy-src/lazy-src.readme.md +63 -0
  71. package/src/components/notification/notification.changelog.md +22 -0
  72. package/src/components/notification/notification.define.js +3 -0
  73. package/src/components/notification/notification.events.js +6 -0
  74. package/src/components/notification/notification.js +280 -0
  75. package/src/components/notification/notification.readme.md +98 -0
  76. package/src/components/notification/notification.style.js +113 -0
  77. package/src/components/password-field/password-field.changelog.md +22 -0
  78. package/src/components/password-field/password-field.define.js +3 -0
  79. package/src/components/password-field/password-field.js +113 -0
  80. package/src/components/password-field/password-field.readme.md +60 -0
  81. package/src/components/password-field/password-field.style.js +62 -0
  82. package/src/components/radio-field/radio-field.changelog.md +21 -0
  83. package/src/components/radio-field/radio-field.define.js +3 -0
  84. package/src/components/radio-field/radio-field.js +140 -0
  85. package/src/components/radio-field/radio-field.readme.md +72 -0
  86. package/src/components/radio-field/radio-field.style.js +108 -0
  87. package/src/components/scroll-to/scroll-to.changelog.md +39 -0
  88. package/src/components/scroll-to/scroll-to.define.js +3 -0
  89. package/src/components/scroll-to/scroll-to.js +40 -0
  90. package/src/components/scroll-to/scroll-to.readme.md +50 -0
  91. package/src/components/scroll-to-top/scroll-to-top.changelog.md +39 -0
  92. package/src/components/scroll-to-top/scroll-to-top.define.js +3 -0
  93. package/src/components/scroll-to-top/scroll-to-top.js +78 -0
  94. package/src/components/scroll-to-top/scroll-to-top.readme.md +48 -0
  95. package/src/components/scroll-to-top/scroll-to-top.style.js +9 -0
  96. package/src/components/select-field/select-field.changelog.md +30 -0
  97. package/src/components/select-field/select-field.define.js +3 -0
  98. package/src/components/select-field/select-field.js +83 -0
  99. package/src/components/select-field/select-field.readme.md +131 -0
  100. package/src/components/select-field/select-field.style.js +24 -0
  101. package/src/components/slider/slider.changelog.md +177 -0
  102. package/src/components/slider/slider.define.js +3 -0
  103. package/src/components/slider/slider.events.js +4 -0
  104. package/src/components/slider/slider.js +338 -0
  105. package/src/components/slider/slider.readme.md +87 -0
  106. package/src/components/slider/slider.style.js +107 -0
  107. package/src/components/sticky/sticky.changelog.md +43 -0
  108. package/src/components/sticky/sticky.define.js +3 -0
  109. package/src/components/sticky/sticky.js +105 -0
  110. package/src/components/sticky/sticky.readme.md +63 -0
  111. package/src/components/sticky/sticky.style.js +21 -0
  112. package/src/components/svg-use/svg-use.changelog.md +41 -0
  113. package/src/components/svg-use/svg-use.define.js +3 -0
  114. package/src/components/svg-use/svg-use.js +39 -0
  115. package/src/components/svg-use/svg-use.readme.md +50 -0
  116. package/src/components/svg-use/svg-use.style.js +20 -0
  117. package/src/components/switch-field/switch-field.changelog.md +21 -0
  118. package/src/components/switch-field/switch-field.define.js +3 -0
  119. package/src/components/switch-field/switch-field.js +99 -0
  120. package/src/components/switch-field/switch-field.readme.md +58 -0
  121. package/src/components/switch-field/switch-field.style.js +98 -0
  122. package/src/components/tab-group/tab-group.changelog.md +35 -0
  123. package/src/components/tab-group/tab-group.define.js +3 -0
  124. package/src/components/tab-group/tab-group.js +109 -0
  125. package/src/components/tab-group/tab-group.readme.md +61 -0
  126. package/src/components/tab-group/tab-group.style.js +7 -0
  127. package/src/components/tab-link/tab-link.changelog.md +35 -0
  128. package/src/components/tab-link/tab-link.define.js +3 -0
  129. package/src/components/tab-link/tab-link.js +50 -0
  130. package/src/components/tab-link/tab-link.readme.md +66 -0
  131. package/src/components/tab-link/tab-link.style.js +32 -0
  132. package/src/components/tab-panel/tab-panel.changelog.md +39 -0
  133. package/src/components/tab-panel/tab-panel.define.js +3 -0
  134. package/src/components/tab-panel/tab-panel.js +30 -0
  135. package/src/components/tab-panel/tab-panel.readme.md +57 -0
  136. package/src/components/tab-panel/tab-panel.style.js +7 -0
  137. package/src/components/textarea-field/textarea-field.changelog.md +39 -0
  138. package/src/components/textarea-field/textarea-field.define.js +3 -0
  139. package/src/components/textarea-field/textarea-field.js +62 -0
  140. package/src/components/textarea-field/textarea-field.readme.md +102 -0
  141. package/src/components/textarea-field/textarea-field.style.js +7 -0
  142. package/src/components/transition-classes/transition-classes.changelog.md +39 -0
  143. package/src/components/transition-classes/transition-classes.define.js +3 -0
  144. package/src/components/transition-classes/transition-classes.js +154 -0
  145. package/src/components/transition-classes/transition-classes.readme.md +71 -0
  146. package/src/themes/default.css +165 -0
  147. package/src/themes/high-contrast.css +147 -0
  148. package/src/themes/sketchy.css +238 -0
  149. package/types/all.d.ts +1 -0
  150. package/types/index.d.ts +1 -0
  151. package/types/src/components/accordion/accordion.d.ts +60 -0
  152. package/types/src/components/accordion/accordion.define.d.ts +1 -0
  153. package/types/src/components/accordion/accordion.events.d.ts +4 -0
  154. package/types/src/components/accordion/accordion.style.d.ts +2 -0
  155. package/types/src/components/accordion-group/accordion-group.d.ts +28 -0
  156. package/types/src/components/accordion-group/accordion-group.define.d.ts +1 -0
  157. package/types/src/components/amount-field/amount-field.d.ts +53 -0
  158. package/types/src/components/amount-field/amount-field.define.d.ts +1 -0
  159. package/types/src/components/amount-field/amount-field.style.d.ts +2 -0
  160. package/types/src/components/button/button.d.ts +73 -0
  161. package/types/src/components/button/button.define.d.ts +1 -0
  162. package/types/src/components/button/button.style.d.ts +2 -0
  163. package/types/src/components/carousel/carousel.d.ts +79 -0
  164. package/types/src/components/carousel/carousel.define.d.ts +1 -0
  165. package/types/src/components/carousel/carousel.events.d.ts +4 -0
  166. package/types/src/components/carousel/carousel.style.d.ts +2 -0
  167. package/types/src/components/carousel/glide/components/ShadowAnchors.d.ts +1 -0
  168. package/types/src/components/carousel/glide/components/ShadowClones.d.ts +1 -0
  169. package/types/src/components/carousel/glide/components/ShadowGaps.d.ts +1 -0
  170. package/types/src/components/carousel/glide/components/ShadowHtml.d.ts +1 -0
  171. package/types/src/components/checkbox-field/checkbox-field.d.ts +69 -0
  172. package/types/src/components/checkbox-field/checkbox-field.define.d.ts +1 -0
  173. package/types/src/components/checkbox-field/checkbox-field.style.d.ts +2 -0
  174. package/types/src/components/dialog/dialog.d.ts +103 -0
  175. package/types/src/components/dialog/dialog.define.d.ts +1 -0
  176. package/types/src/components/dialog/dialog.events.d.ts +9 -0
  177. package/types/src/components/dialog/dialog.style.d.ts +2 -0
  178. package/types/src/components/dropdown/dropdown.d.ts +45 -0
  179. package/types/src/components/dropdown/dropdown.define.d.ts +1 -0
  180. package/types/src/components/dropdown/dropdown.style.d.ts +2 -0
  181. package/types/src/components/form-field/form-field.d.ts +110 -0
  182. package/types/src/components/form-field/form-field.define.d.ts +1 -0
  183. package/types/src/components/form-field/form-field.events.d.ts +5 -0
  184. package/types/src/components/form-field/form-field.style.d.ts +2 -0
  185. package/types/src/components/input-field/input-field.d.ts +38 -0
  186. package/types/src/components/input-field/input-field.define.d.ts +1 -0
  187. package/types/src/components/input-field/input-field.style.d.ts +2 -0
  188. package/types/src/components/lazy-src/lazy-src.d.ts +46 -0
  189. package/types/src/components/lazy-src/lazy-src.define.d.ts +1 -0
  190. package/types/src/components/lazy-src/lazy-src.events.d.ts +6 -0
  191. package/types/src/components/notification/notification.d.ts +92 -0
  192. package/types/src/components/notification/notification.define.d.ts +1 -0
  193. package/types/src/components/notification/notification.events.d.ts +7 -0
  194. package/types/src/components/notification/notification.style.d.ts +2 -0
  195. package/types/src/components/password-field/password-field.d.ts +66 -0
  196. package/types/src/components/password-field/password-field.define.d.ts +1 -0
  197. package/types/src/components/password-field/password-field.style.d.ts +2 -0
  198. package/types/src/components/radio-field/radio-field.d.ts +62 -0
  199. package/types/src/components/radio-field/radio-field.define.d.ts +1 -0
  200. package/types/src/components/radio-field/radio-field.style.d.ts +2 -0
  201. package/types/src/components/scroll-to/scroll-to.d.ts +24 -0
  202. package/types/src/components/scroll-to/scroll-to.define.d.ts +1 -0
  203. package/types/src/components/scroll-to-top/scroll-to-top.d.ts +32 -0
  204. package/types/src/components/scroll-to-top/scroll-to-top.define.d.ts +1 -0
  205. package/types/src/components/scroll-to-top/scroll-to-top.style.d.ts +2 -0
  206. package/types/src/components/select-field/select-field.d.ts +39 -0
  207. package/types/src/components/select-field/select-field.define.d.ts +1 -0
  208. package/types/src/components/select-field/select-field.style.d.ts +2 -0
  209. package/types/src/components/slider/slider.d.ts +129 -0
  210. package/types/src/components/slider/slider.define.d.ts +1 -0
  211. package/types/src/components/slider/slider.events.d.ts +5 -0
  212. package/types/src/components/slider/slider.style.d.ts +2 -0
  213. package/types/src/components/sticky/sticky.d.ts +47 -0
  214. package/types/src/components/sticky/sticky.define.d.ts +1 -0
  215. package/types/src/components/sticky/sticky.style.d.ts +2 -0
  216. package/types/src/components/svg-use/svg-use.d.ts +18 -0
  217. package/types/src/components/svg-use/svg-use.define.d.ts +1 -0
  218. package/types/src/components/svg-use/svg-use.style.d.ts +2 -0
  219. package/types/src/components/switch-field/switch-field.d.ts +67 -0
  220. package/types/src/components/switch-field/switch-field.define.d.ts +1 -0
  221. package/types/src/components/switch-field/switch-field.style.d.ts +2 -0
  222. package/types/src/components/tab-group/tab-group.d.ts +48 -0
  223. package/types/src/components/tab-group/tab-group.define.d.ts +1 -0
  224. package/types/src/components/tab-group/tab-group.style.d.ts +2 -0
  225. package/types/src/components/tab-link/tab-link.d.ts +30 -0
  226. package/types/src/components/tab-link/tab-link.define.d.ts +1 -0
  227. package/types/src/components/tab-link/tab-link.style.d.ts +2 -0
  228. package/types/src/components/tab-panel/tab-panel.d.ts +18 -0
  229. package/types/src/components/tab-panel/tab-panel.define.d.ts +1 -0
  230. package/types/src/components/tab-panel/tab-panel.style.d.ts +2 -0
  231. package/types/src/components/textarea-field/textarea-field.d.ts +34 -0
  232. package/types/src/components/textarea-field/textarea-field.define.d.ts +1 -0
  233. package/types/src/components/textarea-field/textarea-field.style.d.ts +2 -0
  234. package/types/src/components/transition-classes/transition-classes.d.ts +52 -0
  235. package/types/src/components/transition-classes/transition-classes.define.d.ts +1 -0
  236. package/types/src/utils/body-scroll.d.ts +4 -0
  237. package/types/src/utils/transitions.d.ts +9 -0
  238. package/web-types.json +3956 -0
@@ -0,0 +1,33 @@
1
+ const css = String.raw;
2
+
3
+ export default css`
4
+ el-input-field {
5
+ display: flex;
6
+ flex-direction: column;
7
+ gap: var(--el-space-1, 4px);
8
+
9
+ .field {
10
+ display: flex;
11
+ align-items: center;
12
+ gap: var(--el-space-2, 8px);
13
+
14
+ .validity {
15
+ .valid {
16
+ color: var(--el-color-success, green);
17
+ }
18
+
19
+ .invalid {
20
+ color: var(--el-color-danger, red);
21
+ }
22
+ }
23
+ }
24
+
25
+ .message {
26
+ font-size: var(--el-font-size-sm, 14px);
27
+
28
+ &.error-message {
29
+ color: var(--el-color-danger, red);
30
+ }
31
+ }
32
+ }
33
+ `;
@@ -0,0 +1,57 @@
1
+ # Change Log
2
+
3
+ All notable changes to this component live here. Versions refer to the parent `@webtides/element-library` release (see root [`CHANGELOG.md`](../../../CHANGELOG.md)); components no longer version independently.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/).
6
+
7
+ <!--
8
+ When your PR touches this component, add an entry under Unreleased and
9
+ mirror it (prefixed with the component name) in root CHANGELOG.md.
10
+ Uncomment headings as needed.
11
+ -->
12
+
13
+ ## Unreleased
14
+
15
+ ## [0.1.0] - 2026-06-03
16
+
17
+ ### Added
18
+
19
+ - `loaded` custom state on the host, set once the child has been swapped in. Style with `el-lazy-src:state(loaded) { … }`. The reflected `loaded` attribute is unchanged.
20
+
21
+ ## Legacy (pre-merge)
22
+
23
+ The version numbers below predate the single-package merge and refer to the component's former standalone npm package, not the current `@webtides/element-library` version. Kept for historical reference.
24
+
25
+ ## 0.2.2 (2021-07-21)
26
+
27
+ ### Changed
28
+
29
+ update element-js version
30
+
31
+ ## 0.2.1 (2021-12-9)
32
+
33
+ <!-- ### Added -->
34
+
35
+ api getter to return lozad instance
36
+
37
+ ## 0.2.0 (2020-03-15)
38
+
39
+ <!-- ### Added -->
40
+
41
+ lozad.js as external dependecy imgClass pproperty to add CSS classes to generated imgs in picture EVENTS (LOAD, IMG_LOAD, IMG_ERROR) Tests
42
+
43
+ <!-- ### Changed -->
44
+
45
+ 'src-loaded' EVENT -> LOAD
46
+
47
+ <!-- ### Removed -->
48
+
49
+ 'src-loaded' EVENT
50
+
51
+ IntersectionObserver per instance Property Test
52
+
53
+ ## 0.1.0 (2020-03-15)
54
+
55
+ ### Added
56
+
57
+ - initial release
@@ -0,0 +1,3 @@
1
+ import { define } from './lazy-src.js';
2
+
3
+ define();
@@ -0,0 +1,5 @@
1
+ export default {
2
+ LOAD: 'LazySrcLoad',
3
+ IMG_LOAD: 'LazySrcImgLoad',
4
+ IMG_ERROR: 'LazySrcImgError',
5
+ };
@@ -0,0 +1,100 @@
1
+ import { BaseElement, defineElement } from '@webtides/element-js';
2
+ import lozad from 'lozad';
3
+ import Events from './lazy-src.events.js';
4
+
5
+ /**
6
+ * Lazy-loads child `<img>` / `<picture>` / `<iframe>` / `<video>` elements that use a
7
+ * `data-src` attribute. Backed by lozad's `IntersectionObserver`; promotes `data-src` to
8
+ * `src` once the child intersects the viewport.
9
+ *
10
+ * @element el-lazy-src
11
+ *
12
+ * @fires {CustomEvent<LazySrc>} LazySrcLoad - Fired once the child first intersects the
13
+ * viewport and lozad swaps in the real source. `detail` is the host element. Bubbles.
14
+ * @fires {CustomEvent<LazySrc>} LazySrcImgLoad - Fired when an inner `<img>` finishes
15
+ * loading. `detail` is the host element. Bubbles.
16
+ * @fires {CustomEvent<LazySrc>} LazySrcImgError - Fired when an inner `<img>` fails to
17
+ * load. `detail` is the host element. Bubbles.
18
+ *
19
+ * @property {string} rootMargin - `IntersectionObserver` `rootMargin` forwarded to lozad.
20
+ * @property {number | number[]} threshold - `IntersectionObserver` `threshold` forwarded to
21
+ * lozad.
22
+ * @cssstate loaded - Set once the child has been swapped in. Equivalent to the reflected
23
+ * `loaded` attribute; prefer `el-lazy-src:state(loaded) { … }` going forward.
24
+ *
25
+ * @property {boolean} loaded - `true` once the child has been swapped in. Reflected to the
26
+ * `loaded` attribute so consumers can target the loaded state from CSS.
27
+ * @property {string} imgClass - Class to apply to the inner `<img>` once it is loaded.
28
+ * @property {string} imgAlt - `alt` text to apply to the inner `<img>` once it is loaded.
29
+ */
30
+ export default class LazySrc extends BaseElement {
31
+ /** @private */
32
+ #observer = null;
33
+
34
+ constructor() {
35
+ super({
36
+ propertyOptions: {
37
+ loaded: {
38
+ reflect: true,
39
+ },
40
+ },
41
+ });
42
+ }
43
+
44
+ properties() {
45
+ return {
46
+ rootMargin: '0px',
47
+ threshold: 0.01,
48
+ loaded: false,
49
+ imgClass: '',
50
+ imgAlt: '',
51
+ };
52
+ }
53
+
54
+ connected() {
55
+ this.#observer = lozad(this.firstElementChild, {
56
+ rootMargin: this.rootMargin,
57
+ threshold: this.threshold,
58
+ loaded: this.afterIntersection.bind(this),
59
+ });
60
+
61
+ this.#observer.observe();
62
+ }
63
+
64
+ /**
65
+ * Returns the underlying lozad observer instance.
66
+ */
67
+ get api() {
68
+ return this.#observer;
69
+ }
70
+
71
+ /** @private */
72
+ afterIntersection(target) {
73
+ this.dispatch(Events.LOAD, this);
74
+ this.loaded = true;
75
+ this._internals.states.add('loaded');
76
+
77
+ const img = target.querySelector('img');
78
+ if (img) {
79
+ //pass classes to generated img element
80
+ if (this.imgClass !== '') {
81
+ img.setAttribute('class', this.imgClass);
82
+ }
83
+ if (this.imgAlt !== '') {
84
+ img.setAttribute('alt', this.imgAlt);
85
+ }
86
+ img.onload = () => {
87
+ this.dispatch(Events.IMG_LOAD, this);
88
+ };
89
+ img.onerror = () => {
90
+ this.dispatch(Events.IMG_ERROR, this);
91
+ };
92
+ }
93
+ }
94
+ }
95
+
96
+ export function define() {
97
+ defineElement('el-lazy-src', LazySrc);
98
+ }
99
+
100
+ export { Events };
@@ -0,0 +1,63 @@
1
+ # LazySrc
2
+
3
+ `lazy-src` is a lazy-loading wrapper for media elements. Place any `<img>`, `<picture>`, `<iframe>`, or `<video>` inside with a `data-src` attribute instead of `src`, and it loads the resource on demand once the element scrolls into view. It is backed by [lozad](https://github.com/ApoorvSaxena/lozad).
4
+
5
+ ## How to use
6
+
7
+ #### Install
8
+
9
+ ```sh
10
+ npm i --save @webtides/element-library
11
+ ```
12
+
13
+ #### Use
14
+
15
+ ```js
16
+ import '@webtides/element-library/lazy-src/define';
17
+ ```
18
+
19
+ ```html
20
+ <el-lazy-src>
21
+ <img data-src="url-to-image" />
22
+ </el-lazy-src>
23
+ ```
24
+
25
+ ## API
26
+
27
+ #### Properties/Attributes
28
+
29
+ | Name | Type | Default | Description |
30
+ | --- | --- | --- | --- |
31
+ | `rootMargin` | `string` | `'0px'` | Delegated to the internal [`IntersectionObserver`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/IntersectionObserver). |
32
+ | `threshold` | `number \| array` | `0.01` | Delegated to the internal [`IntersectionObserver`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/IntersectionObserver). |
33
+ | `loaded` | `boolean` | `false` | Indicates whether the element has been loaded or not. |
34
+ | `imgClass` | `string` | `''` | When set, the value is applied as the `class` attribute on the inner `<img>` once it loads. |
35
+ | `imgAlt` | `string` | `''` | When set, the value is applied as the `alt` attribute on the inner `<img>` once it loads. |
36
+
37
+ #### Methods
38
+
39
+ | Name | Parameters | Description |
40
+ | ---------------- | ---------- | ----------------------------------------------- |
41
+ | `api` _(getter)_ | None | Returns the underlying lozad observer instance. |
42
+
43
+ #### Events
44
+
45
+ | Name | Detail | Description |
46
+ | --- | --- | --- |
47
+ | `LazySrcLoad` | `this` | Fired when the element intersects the viewport and loading is triggered. Bubbles up through the DOM. |
48
+ | `LazySrcImgLoad` | `this` | Fired when the inner `<img>` has finished loading. Bubbles up through the DOM. |
49
+ | `LazySrcImgError` | `this` | Fired when the inner `<img>` fails to load. Bubbles up through the DOM. |
50
+
51
+ #### CSS States
52
+
53
+ | Name | Description |
54
+ | -------- | ---------------------------------------------------------------------------------- |
55
+ | `loaded` | Present once the lazy resource has loaded. Style with `el-lazy-src:state(loaded)`. |
56
+
57
+ #### CSS Custom Properties
58
+
59
+ _None_
60
+
61
+ #### Slots
62
+
63
+ _None_
@@ -0,0 +1,22 @@
1
+ # Change Log
2
+
3
+ All notable changes to this component live here. Versions refer to the parent `@webtides/element-library` release (see root [`CHANGELOG.md`](../../../CHANGELOG.md)); components no longer version independently.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/).
6
+
7
+ <!--
8
+ When your PR touches this component, add an entry under Unreleased and
9
+ mirror it (prefixed with the component name) in root CHANGELOG.md.
10
+ Uncomment headings as needed.
11
+ -->
12
+
13
+ ## Unreleased
14
+
15
+ ## [0.1.0] - 2026-06-03
16
+
17
+ ### Added
18
+
19
+ - Initial release of `el-notification` — an alert/notification that can be shown inline or as a transient toast (`toast()` floats it into a shared top-right stack). API modelled on Shoelace's `<sl-alert>`.
20
+ - Semantic `variant` (`default` / `primary` / `success` / `neutral` / `warning` / `danger`) with per-variant accent + default icon, optional `closable` close button, and optional auto-dismiss (`duration`, default `Infinity`) that pauses while the pointer/focus is inside.
21
+ - `show()` / `hide()` (promise-returning) and `toast()` methods; `notification-show` / `-after-show` / `-hide` / `-after-hide` events; `open` reflected attribute + custom state.
22
+ - The host is exposed as an ARIA live region — `role="alert"` (assertive) for `danger` / `warning`, `role="status"` (polite) otherwise — so toasts are announced when they appear.
@@ -0,0 +1,3 @@
1
+ import { define } from './notification.js';
2
+
3
+ define();
@@ -0,0 +1,6 @@
1
+ export default {
2
+ SHOW: 'notification-show',
3
+ AFTER_SHOW: 'notification-after-show',
4
+ HIDE: 'notification-hide',
5
+ AFTER_HIDE: 'notification-after-hide',
6
+ };
@@ -0,0 +1,280 @@
1
+ import { TemplateElement, html, defineElement } from '@webtides/element-js';
2
+ import style from './notification.style.js';
3
+ import Events from './notification.events.js';
4
+ import { afterTransition, nextFrame } from '../../utils/transitions.js';
5
+
6
+ /**
7
+ * Lazily-created, shared toast container pinned to the top-right of the viewport. Toasts append
8
+ * themselves to it; it is removed again once the last toast leaves.
9
+ */
10
+ let toastStack = null;
11
+
12
+ function getToastStack() {
13
+ if (!toastStack) {
14
+ toastStack = document.createElement('div');
15
+ toastStack.className = 'el-toast-stack';
16
+ Object.assign(toastStack.style, {
17
+ position: 'fixed',
18
+ top: '1rem',
19
+ insetInlineEnd: '1rem',
20
+ zIndex: '9999',
21
+ display: 'flex',
22
+ flexDirection: 'column',
23
+ gap: '0.5rem',
24
+ pointerEvents: 'none',
25
+ });
26
+ document.body.append(toastStack);
27
+ }
28
+ return toastStack;
29
+ }
30
+
31
+ /**
32
+ * A notification / alert that can be shown inline or as a transient toast. Built for both feedback
33
+ * after an action and inline status messages. Semantic variants, an optional close button, and
34
+ * optional auto-dismiss. API modelled on Shoelace's `<sl-alert>`.
35
+ *
36
+ * The host is exposed as an ARIA live region — `role="alert"` (assertive) for `danger` / `warning`
37
+ * variants, `role="status"` (polite) otherwise — so toasts are announced when they appear.
38
+ *
39
+ * @element el-notification
40
+ *
41
+ * @fires {CustomEvent} notification-show - Fired when the notification starts to open.
42
+ * @fires {CustomEvent} notification-after-show - Fired once the open transition has finished.
43
+ * @fires {CustomEvent} notification-hide - Fired when the notification starts to close.
44
+ * @fires {CustomEvent} notification-after-hide - Fired once the close transition has finished.
45
+ *
46
+ * @slot - The notification's message.
47
+ * @slot icon - A leading icon. Falls back to a variant-appropriate default icon.
48
+ *
49
+ * @csspart base - The animated outer wrapper.
50
+ * @csspart panel - The visual surface (background, border, variant accent).
51
+ * @csspart icon - The leading icon container.
52
+ * @csspart message - The message wrapper around the default slot.
53
+ * @csspart close-button - The optional close button.
54
+ *
55
+ * @cssstate open - Set while the notification is shown.
56
+ *
57
+ * @property {boolean} open - Whether the notification is shown. Reflected to the `open` attribute.
58
+ * @property {'default'|'primary'|'success'|'neutral'|'warning'|'danger'} variant - Visual + semantic
59
+ * variant. Default `'default'`.
60
+ * @property {boolean} closable - Whether to render a close button. Default `false`.
61
+ * @property {number} duration - Auto-dismiss delay in milliseconds; `Infinity` (default) never
62
+ * auto-dismisses. The countdown pauses while the pointer or focus is inside the notification.
63
+ */
64
+ export default class Notification extends TemplateElement {
65
+ constructor() {
66
+ super({ shadowRender: true, styles: [style], propertyOptions: { open: { reflect: true } } });
67
+ }
68
+
69
+ properties() {
70
+ return {
71
+ open: false,
72
+ variant: 'default',
73
+ closable: false,
74
+ duration: Infinity,
75
+ };
76
+ }
77
+
78
+ connected() {
79
+ // Expose the host as a live region so toasts are announced. Assertive for danger/warning.
80
+ const assertive = this.variant === 'danger' || this.variant === 'warning';
81
+ this.setAttribute('role', assertive ? 'alert' : 'status');
82
+ this.setAttribute('aria-live', assertive ? 'assertive' : 'polite');
83
+ this.setAttribute('aria-atomic', 'true');
84
+
85
+ if (this.open) {
86
+ this._internals.states.add('open');
87
+ this._applyOpen();
88
+ } else {
89
+ this.$refs.base?.classList.add('is-hidden');
90
+ }
91
+ }
92
+
93
+ disconnected() {
94
+ clearTimeout(this._autoHideTimer);
95
+ }
96
+
97
+ watch() {
98
+ return {
99
+ open: (open) => {
100
+ if (open) this._applyOpen();
101
+ else this._applyClose();
102
+ },
103
+ };
104
+ }
105
+
106
+ events() {
107
+ return {
108
+ '[data-close]': {
109
+ click: () => this.hide(),
110
+ },
111
+ "[part~='base']": {
112
+ // Pause the auto-dismiss countdown while the user is interacting with the toast.
113
+ mouseenter: () => clearTimeout(this._autoHideTimer),
114
+ mouseleave: () => this._startAutoHide(),
115
+ focusin: () => clearTimeout(this._autoHideTimer),
116
+ focusout: () => this._startAutoHide(),
117
+ },
118
+ };
119
+ }
120
+
121
+ /**
122
+ * Shows the notification.
123
+ * @returns {Promise<void>} Resolves after the open transition has finished.
124
+ */
125
+ show() {
126
+ if (this.open) return Promise.resolve();
127
+ const done = this._once(Events.AFTER_SHOW);
128
+ this.open = true;
129
+ return done;
130
+ }
131
+
132
+ /**
133
+ * Hides the notification.
134
+ * @returns {Promise<void>} Resolves after the close transition has finished.
135
+ */
136
+ hide() {
137
+ if (!this.open) return Promise.resolve();
138
+ const done = this._once(Events.AFTER_HIDE);
139
+ this.open = false;
140
+ return done;
141
+ }
142
+
143
+ /**
144
+ * Moves the notification into the shared top-right toast stack and shows it.
145
+ * @returns {Promise<void>} Resolves after the open transition has finished.
146
+ */
147
+ toast() {
148
+ getToastStack().append(this);
149
+ return this.show();
150
+ }
151
+
152
+ /** @private */
153
+ async _applyOpen() {
154
+ const base = this.$refs.base;
155
+ if (!base) return;
156
+
157
+ this._internals.states.add('open');
158
+ this.dispatch(Events.SHOW);
159
+
160
+ base.classList.remove('is-hidden');
161
+ // Commit the hidden start state before transitioning in.
162
+ void base.offsetWidth;
163
+ base.classList.add('showing');
164
+ await afterTransition(base);
165
+
166
+ this.dispatch(Events.AFTER_SHOW);
167
+ this._startAutoHide();
168
+ }
169
+
170
+ /** @private */
171
+ async _applyClose() {
172
+ const base = this.$refs.base;
173
+ if (!base) return;
174
+
175
+ clearTimeout(this._autoHideTimer);
176
+ this.dispatch(Events.HIDE);
177
+
178
+ base.classList.remove('showing');
179
+ await afterTransition(base);
180
+ base.classList.add('is-hidden');
181
+
182
+ this._internals.states.delete('open');
183
+ this.dispatch(Events.AFTER_HIDE);
184
+ this._removeFromToastStack();
185
+ }
186
+
187
+ /** @private */
188
+ _startAutoHide() {
189
+ clearTimeout(this._autoHideTimer);
190
+ if (this.open && Number.isFinite(this.duration)) {
191
+ this._autoHideTimer = setTimeout(() => this.hide(), this.duration);
192
+ }
193
+ }
194
+
195
+ /** @private */
196
+ _removeFromToastStack() {
197
+ if (toastStack && this.parentElement === toastStack) {
198
+ this.remove();
199
+ if (toastStack.childElementCount === 0) {
200
+ toastStack.remove();
201
+ toastStack = null;
202
+ }
203
+ }
204
+ }
205
+
206
+ /** @private */
207
+ _once(name) {
208
+ return new Promise((resolve) => this.addEventListener(name, () => resolve(), { once: true }));
209
+ }
210
+
211
+ /** @private */
212
+ closeButtonTemplate() {
213
+ return html`
214
+ <button part="close-button" type="button" class="close-button" aria-label="Close" data-close>
215
+ <svg
216
+ viewBox="0 0 24 24"
217
+ fill="none"
218
+ stroke="currentColor"
219
+ stroke-width="2"
220
+ stroke-linecap="round"
221
+ stroke-linejoin="round"
222
+ aria-hidden="true"
223
+ >
224
+ <line x1="18" y1="6" x2="6" y2="18"></line>
225
+ <line x1="6" y1="6" x2="18" y2="18"></line>
226
+ </svg>
227
+ </button>
228
+ `;
229
+ }
230
+
231
+ template() {
232
+ return html`
233
+ <div part="base" ref="base">
234
+ <div part="panel" class="panel notification--${this.variant}">
235
+ <span part="icon" class="icon"><slot name="icon">${this.variantIconTemplate()}</slot></span>
236
+ <div part="message" class="message"><slot></slot></div>
237
+ ${this.closable ? this.closeButtonTemplate() : ''}
238
+ </div>
239
+ </div>
240
+ `;
241
+ }
242
+
243
+ /** @private */
244
+ variantIconTemplate() {
245
+ const paths = {
246
+ success: html`<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path>
247
+ <polyline points="22 4 12 14.01 9 11.01"></polyline>`,
248
+ danger: html`<circle cx="12" cy="12" r="10"></circle>
249
+ <line x1="12" y1="8" x2="12" y2="12"></line>
250
+ <line x1="12" y1="16" x2="12.01" y2="16"></line>`,
251
+ warning: html`<path
252
+ d="M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"
253
+ ></path>
254
+ <line x1="12" y1="9" x2="12" y2="13"></line>
255
+ <line x1="12" y1="17" x2="12.01" y2="17"></line>`,
256
+ };
257
+ const info = html`<circle cx="12" cy="12" r="10"></circle>
258
+ <line x1="12" y1="16" x2="12" y2="12"></line>
259
+ <line x1="12" y1="8" x2="12.01" y2="8"></line>`;
260
+ return html`
261
+ <svg
262
+ viewBox="0 0 24 24"
263
+ fill="none"
264
+ stroke="currentColor"
265
+ stroke-width="2"
266
+ stroke-linecap="round"
267
+ stroke-linejoin="round"
268
+ aria-hidden="true"
269
+ >
270
+ ${paths[this.variant] ?? info}
271
+ </svg>
272
+ `;
273
+ }
274
+ }
275
+
276
+ export function define() {
277
+ defineElement('el-notification', Notification);
278
+ }
279
+
280
+ export { Events };
@@ -0,0 +1,98 @@
1
+ # Notification
2
+
3
+ `notification` is an alert / notification that can be shown **inline** or as a transient **toast**. It carries a semantic variant, a leading icon, an optional close button and optional auto-dismiss. The host is exposed as an ARIA live region, so toasts are announced when they appear. API modelled on Shoelace's `<sl-alert>`.
4
+
5
+ It is headless-leaning by default: colors come from the `--el-*` tokens, with system-color fallbacks (`Canvas` / `CanvasText`) so an unthemed floating toast is still readable.
6
+
7
+ ## How to use
8
+
9
+ #### Install
10
+
11
+ ```sh
12
+ npm i --save @webtides/element-library
13
+ ```
14
+
15
+ #### Use
16
+
17
+ ```js
18
+ import '@webtides/element-library/notification/define';
19
+ ```
20
+
21
+ #### Inline
22
+
23
+ ```html
24
+ <el-notification variant="success" open="true" closable="true"> Your changes have been saved. </el-notification>
25
+ ```
26
+
27
+ #### As a toast
28
+
29
+ ```js
30
+ const note = document.createElement('el-notification');
31
+ note.variant = 'success';
32
+ note.closable = true;
33
+ note.duration = 3000;
34
+ note.textContent = 'Saved to your library.';
35
+ note.toast(); // floats it into the shared top-right stack and shows it
36
+ ```
37
+
38
+ ## API
39
+
40
+ #### Properties/Attributes
41
+
42
+ | Name | Type | Default | Description |
43
+ | --- | --- | --- | --- |
44
+ | `open` | `boolean` | `false` | Whether the notification is shown. Reflected to the `open` attribute. |
45
+ | `variant` | `'default' \| 'primary' \| 'success' \| 'neutral' \| 'warning' \| 'danger'` | `'default'` | Visual + semantic variant. |
46
+ | `closable` | `boolean` | `false` | Whether to render a close button. |
47
+ | `duration` | `number` | `Infinity` | Auto-dismiss delay in ms. Pauses while pointer/focus is inside. |
48
+
49
+ #### Methods
50
+
51
+ | Name | Returns | Description |
52
+ | --------- | --------------- | ------------------------------------------------------------ |
53
+ | `show()` | `Promise<void>` | Shows the notification; resolves after the open transition. |
54
+ | `hide()` | `Promise<void>` | Hides the notification; resolves after the close transition. |
55
+ | `toast()` | `Promise<void>` | Moves it into the shared top-right toast stack and shows it. |
56
+
57
+ #### Events
58
+
59
+ | Name | Description |
60
+ | ------------------------- | ---------------------------------- |
61
+ | `notification-show` | The notification starts to open. |
62
+ | `notification-after-show` | The open transition has finished. |
63
+ | `notification-hide` | The notification starts to close. |
64
+ | `notification-after-hide` | The close transition has finished. |
65
+
66
+ #### Slots
67
+
68
+ | Name | Description |
69
+ | ----------- | ----------------------------------------------------- |
70
+ | _(default)_ | The notification's message. |
71
+ | `icon` | A leading icon. Falls back to a variant default icon. |
72
+
73
+ #### CSS Parts
74
+
75
+ | Name | Description |
76
+ | -------------- | ------------------------------------------------ |
77
+ | `base` | The animated outer wrapper. |
78
+ | `panel` | The visual surface (background, border, accent). |
79
+ | `icon` | The leading icon container. |
80
+ | `message` | The message wrapper around the default slot. |
81
+ | `close-button` | The optional close button. |
82
+
83
+ #### CSS States
84
+
85
+ | Name | Description |
86
+ | ------ | ---------------------------------------------------------------------------------------------- |
87
+ | `open` | Present on the host while the notification is shown. Style with `el-notification:state(open)`. |
88
+
89
+ #### CSS Custom Properties
90
+
91
+ Reads `--el-color-bg` / `--el-color-fg`, `--el-color-border`, the variant colors (`--el-color-accent` / `--el-color-success` / `--el-color-danger` / `--el-color-warning` / `--el-color-fg-muted`), `--el-radius-md`, `--el-shadow-lg`, `--el-space-*`, `--el-duration-md` and `--el-ease`. See the Storybook _Docs / Theming_ page.
92
+
93
+ ## Accessibility
94
+
95
+ - The host is a live region: `role="alert"` + `aria-live="assertive"` for `danger` / `warning`, `role="status"` + `aria-live="polite"` otherwise — so a toast is announced when it appears.
96
+ - The auto-dismiss countdown pauses while the pointer or keyboard focus is inside the notification, so it can't disappear out from under someone reading or interacting with it.
97
+ - The close button is a real `<button>` with an accessible name.
98
+ - The transition collapses under `prefers-reduced-motion: reduce`.