@shortfuse/materialdesignweb 0.9.0 → 0.9.2

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 (282) hide show
  1. package/README.md +50 -206
  2. package/components/Badge.js +5 -2
  3. package/components/Body.js +4 -0
  4. package/components/BottomAppBar.js +6 -2
  5. package/components/BottomSheet.js +62 -14
  6. package/components/Button.js +20 -0
  7. package/components/Card.js +20 -3
  8. package/components/Checkbox.js +8 -0
  9. package/components/CheckboxIcon.js +9 -3
  10. package/components/Chip.js +5 -2
  11. package/components/Dialog.js +22 -3
  12. package/components/DialogActions.js +4 -0
  13. package/components/Display.js +9 -0
  14. package/components/Divider.js +5 -0
  15. package/components/Fab.js +11 -0
  16. package/components/FabContainer.js +9 -0
  17. package/components/FilterChip.js +9 -0
  18. package/components/Grid.js +11 -0
  19. package/components/Headline.js +4 -0
  20. package/components/Icon.js +27 -3
  21. package/components/IconButton.js +8 -2
  22. package/components/Input.js +87 -14
  23. package/components/InputChip.js +33 -1
  24. package/components/Label.js +4 -0
  25. package/components/List.js +10 -0
  26. package/components/ListItem.js +53 -0
  27. package/components/ListOption.js +62 -1
  28. package/components/Listbox.js +44 -13
  29. package/components/Menu.js +31 -9
  30. package/components/MenuItem.js +24 -10
  31. package/components/NavBar.js +14 -3
  32. package/components/NavBarItem.js +5 -0
  33. package/components/NavDrawer.js +17 -0
  34. package/components/NavDrawerItem.js +5 -0
  35. package/components/NavItem.js +22 -2
  36. package/components/NavRail.js +9 -0
  37. package/components/NavRailItem.js +5 -0
  38. package/components/Page.js +15 -1
  39. package/components/Pane.js +7 -1
  40. package/components/Popup.js +6 -0
  41. package/components/Progress.js +25 -5
  42. package/components/Radio.js +6 -2
  43. package/components/RadioIcon.js +14 -1
  44. package/components/Ripple.js +14 -0
  45. package/components/Root.js +16 -0
  46. package/components/Scrim.js +10 -2
  47. package/components/Search.js +18 -5
  48. package/components/SegmentedButton.js +22 -6
  49. package/components/SegmentedButtonGroup.js +7 -10
  50. package/components/Select.js +13 -3
  51. package/components/Shape.js +4 -0
  52. package/components/SideSheet.js +31 -2
  53. package/components/Slider.js +22 -2
  54. package/components/Snackbar.js +30 -4
  55. package/components/SnackbarContainer.js +9 -0
  56. package/components/Surface.js +5 -0
  57. package/components/Switch.js +18 -2
  58. package/components/SwitchIcon.js +22 -1
  59. package/components/Tab.js +21 -0
  60. package/components/TabContent.js +32 -12
  61. package/components/TabList.js +36 -3
  62. package/components/TabPanel.js +9 -0
  63. package/components/Table.js +38 -3
  64. package/components/TextArea.js +32 -1
  65. package/components/Title.js +4 -0
  66. package/components/Tooltip.js +9 -2
  67. package/components/TopAppBar.js +15 -0
  68. package/core/Composition.js +45 -16
  69. package/core/CompositionAdapter.js +24 -6
  70. package/core/CustomElement.js +77 -49
  71. package/core/customTypes.js +43 -26
  72. package/core/dom.js +1 -0
  73. package/core/jsonMergePatch.js +15 -1
  74. package/core/observe.js +28 -21
  75. package/dist/CustomElement.min.js +2 -0
  76. package/dist/CustomElement.min.js.map +7 -0
  77. package/dist/core/CustomElement.min.js +2 -0
  78. package/dist/core/CustomElement.min.js.map +7 -0
  79. package/dist/index.min.js +9 -9
  80. package/dist/index.min.js.map +3 -3
  81. package/dist/meta.json +1 -1
  82. package/dom/HTMLOptionsCollectionProxy.js +5 -3
  83. package/mixins/AriaReflectorMixin.js +22 -13
  84. package/mixins/AriaToolbarMixin.js +3 -0
  85. package/mixins/ControlMixin.js +3 -0
  86. package/mixins/DelegatesFocusMixin.js +9 -1
  87. package/mixins/DensityMixin.js +5 -1
  88. package/mixins/ElevationMixin.js +1 -2
  89. package/mixins/FlexableMixin.js +21 -2
  90. package/mixins/FormAssociatedMixin.js +19 -5
  91. package/mixins/HyperlinkMixin.js +11 -1
  92. package/mixins/InputMixin.js +22 -0
  93. package/mixins/KeyboardNavMixin.js +3 -1
  94. package/mixins/PopupMixin.js +41 -12
  95. package/mixins/RTLObserverMixin.js +2 -0
  96. package/mixins/ResizeObserverMixin.js +2 -0
  97. package/mixins/RippleMixin.js +3 -1
  98. package/mixins/ScrollListenerMixin.js +13 -1
  99. package/mixins/SemiStickyMixin.js +7 -0
  100. package/mixins/ShapeMaskedMixin.js +9 -1
  101. package/mixins/ShapeMixin.js +9 -0
  102. package/mixins/StateMixin.js +4 -0
  103. package/mixins/TextFieldMixin.js +21 -2
  104. package/mixins/ThemableMixin.js +13 -0
  105. package/mixins/TooltipTriggerMixin.js +17 -3
  106. package/mixins/TouchTargetMixin.js +4 -1
  107. package/mixins/TypographyMixin.js +8 -1
  108. package/package.json +53 -45
  109. package/services/theme.js +4 -5
  110. package/types/components/BottomAppBar.d.ts +3 -4
  111. package/types/components/BottomSheet.d.ts +33 -7
  112. package/types/components/BottomSheet.d.ts.map +1 -1
  113. package/types/components/Button.d.ts +3 -472
  114. package/types/components/Button.d.ts.map +1 -1
  115. package/types/components/Card.d.ts +9 -274
  116. package/types/components/Card.d.ts.map +1 -1
  117. package/types/components/Checkbox.d.ts +2 -0
  118. package/types/components/Checkbox.d.ts.map +1 -1
  119. package/types/components/Chip.d.ts +3 -1180
  120. package/types/components/Dialog.d.ts +8 -191
  121. package/types/components/Dialog.d.ts.map +1 -1
  122. package/types/components/Display.d.ts +5 -4
  123. package/types/components/Display.d.ts.map +1 -1
  124. package/types/components/Fab.d.ts +2 -470
  125. package/types/components/FilterChip.d.ts +5 -4032
  126. package/types/components/Grid.d.ts +1 -0
  127. package/types/components/Grid.d.ts.map +1 -1
  128. package/types/components/Headline.d.ts +3 -4
  129. package/types/components/Icon.d.ts +1 -49
  130. package/types/components/Icon.d.ts.map +1 -1
  131. package/types/components/IconButton.d.ts +3 -1205
  132. package/types/components/Input.d.ts +1485 -50245
  133. package/types/components/Input.d.ts.map +1 -1
  134. package/types/components/InputChip.d.ts +2 -160
  135. package/types/components/List.d.ts +8 -4
  136. package/types/components/List.d.ts.map +1 -1
  137. package/types/components/ListItem.d.ts +10 -235
  138. package/types/components/ListItem.d.ts.map +1 -1
  139. package/types/components/ListOption.d.ts +17 -1352
  140. package/types/components/ListOption.d.ts.map +1 -1
  141. package/types/components/Listbox.d.ts +199 -11448
  142. package/types/components/Listbox.d.ts.map +1 -1
  143. package/types/components/Menu.d.ts +21 -10
  144. package/types/components/Menu.d.ts.map +1 -1
  145. package/types/components/MenuItem.d.ts +17 -2894
  146. package/types/components/MenuItem.d.ts.map +1 -1
  147. package/types/components/NavBar.d.ts +2 -0
  148. package/types/components/NavBar.d.ts.map +1 -1
  149. package/types/components/NavBarItem.d.ts +1 -90
  150. package/types/components/NavDrawer.d.ts +3 -4
  151. package/types/components/NavDrawerItem.d.ts +1 -90
  152. package/types/components/NavItem.d.ts +1 -92
  153. package/types/components/NavItem.d.ts.map +1 -1
  154. package/types/components/NavRail.d.ts +3 -4
  155. package/types/components/NavRailItem.d.ts +1 -90
  156. package/types/components/Page.d.ts +1 -0
  157. package/types/components/Page.d.ts.map +1 -1
  158. package/types/components/Popup.d.ts +5 -3
  159. package/types/components/Popup.d.ts.map +1 -1
  160. package/types/components/Progress.d.ts +2 -0
  161. package/types/components/Progress.d.ts.map +1 -1
  162. package/types/components/Radio.d.ts +2 -0
  163. package/types/components/Radio.d.ts.map +1 -1
  164. package/types/components/Ripple.d.ts +1 -0
  165. package/types/components/Ripple.d.ts.map +1 -1
  166. package/types/components/Root.d.ts +1 -1
  167. package/types/components/Root.d.ts.map +1 -1
  168. package/types/components/Search.d.ts +502 -2
  169. package/types/components/Search.d.ts.map +1 -1
  170. package/types/components/SegmentedButton.d.ts +4 -470
  171. package/types/components/SegmentedButton.d.ts.map +1 -1
  172. package/types/components/SegmentedButtonGroup.d.ts +3 -4
  173. package/types/components/SegmentedButtonGroup.d.ts.map +1 -1
  174. package/types/components/Select.d.ts +5 -1208
  175. package/types/components/Select.d.ts.map +1 -1
  176. package/types/components/SideSheet.d.ts +9 -4
  177. package/types/components/SideSheet.d.ts.map +1 -1
  178. package/types/components/Slider.d.ts +10 -189
  179. package/types/components/Slider.d.ts.map +1 -1
  180. package/types/components/Snackbar.d.ts +13 -5
  181. package/types/components/Snackbar.d.ts.map +1 -1
  182. package/types/components/Switch.d.ts +4 -0
  183. package/types/components/Switch.d.ts.map +1 -1
  184. package/types/components/SwitchIcon.d.ts +2 -110
  185. package/types/components/SwitchIcon.d.ts.map +1 -1
  186. package/types/components/Tab.d.ts +12 -752
  187. package/types/components/Tab.d.ts.map +1 -1
  188. package/types/components/TabContent.d.ts +23 -21
  189. package/types/components/TabContent.d.ts.map +1 -1
  190. package/types/components/TabList.d.ts +646 -5801
  191. package/types/components/TabList.d.ts.map +1 -1
  192. package/types/components/TabPanel.d.ts +4 -4
  193. package/types/components/TabPanel.d.ts.map +1 -1
  194. package/types/components/Table.d.ts +24 -1
  195. package/types/components/Table.d.ts.map +1 -1
  196. package/types/components/TextArea.d.ts +15 -1208
  197. package/types/components/TextArea.d.ts.map +1 -1
  198. package/types/components/Title.d.ts +3 -4
  199. package/types/components/Tooltip.d.ts +4 -4
  200. package/types/components/Tooltip.d.ts.map +1 -1
  201. package/types/components/TopAppBar.d.ts +4 -5
  202. package/types/components/TopAppBar.d.ts.map +1 -1
  203. package/types/constants/shapes.d.ts.map +1 -1
  204. package/types/core/Composition.d.ts +19 -11
  205. package/types/core/Composition.d.ts.map +1 -1
  206. package/types/core/CompositionAdapter.d.ts +30 -8
  207. package/types/core/CompositionAdapter.d.ts.map +1 -1
  208. package/types/core/CustomElement.d.ts +27 -25
  209. package/types/core/CustomElement.d.ts.map +1 -1
  210. package/types/core/customTypes.d.ts +2 -6
  211. package/types/core/customTypes.d.ts.map +1 -1
  212. package/types/core/dom.d.ts.map +1 -1
  213. package/types/core/jsonMergePatch.d.ts.map +1 -1
  214. package/types/core/observe.d.ts +20 -19
  215. package/types/core/observe.d.ts.map +1 -1
  216. package/types/core/template.d.ts.map +1 -1
  217. package/types/dom/HTMLOptionsCollectionProxy.d.ts +4 -4
  218. package/types/dom/HTMLOptionsCollectionProxy.d.ts.map +1 -1
  219. package/types/mixins/AriaReflectorMixin.d.ts +18 -10
  220. package/types/mixins/AriaReflectorMixin.d.ts.map +1 -1
  221. package/types/mixins/AriaToolbarMixin.d.ts +6 -4
  222. package/types/mixins/AriaToolbarMixin.d.ts.map +1 -1
  223. package/types/mixins/ControlMixin.d.ts +1 -1
  224. package/types/mixins/ControlMixin.d.ts.map +1 -1
  225. package/types/mixins/DelegatesFocusMixin.d.ts +9 -1
  226. package/types/mixins/DelegatesFocusMixin.d.ts.map +1 -1
  227. package/types/mixins/DensityMixin.d.ts +4 -1
  228. package/types/mixins/DensityMixin.d.ts.map +1 -1
  229. package/types/mixins/ElevationMixin.d.ts +1 -2
  230. package/types/mixins/ElevationMixin.d.ts.map +1 -1
  231. package/types/mixins/FlexableMixin.d.ts +1 -0
  232. package/types/mixins/FlexableMixin.d.ts.map +1 -1
  233. package/types/mixins/FormAssociatedMixin.d.ts +3 -2
  234. package/types/mixins/FormAssociatedMixin.d.ts.map +1 -1
  235. package/types/mixins/HyperlinkMixin.d.ts +4 -1
  236. package/types/mixins/HyperlinkMixin.d.ts.map +1 -1
  237. package/types/mixins/InputMixin.d.ts +1 -7
  238. package/types/mixins/InputMixin.d.ts.map +1 -1
  239. package/types/mixins/KeyboardNavMixin.d.ts +4 -5
  240. package/types/mixins/KeyboardNavMixin.d.ts.map +1 -1
  241. package/types/mixins/PopupMixin.d.ts +22 -6
  242. package/types/mixins/PopupMixin.d.ts.map +1 -1
  243. package/types/mixins/RTLObserverMixin.d.ts +1 -0
  244. package/types/mixins/RTLObserverMixin.d.ts.map +1 -1
  245. package/types/mixins/ResizeObserverMixin.d.ts +1 -0
  246. package/types/mixins/ResizeObserverMixin.d.ts.map +1 -1
  247. package/types/mixins/RippleMixin.d.ts +3 -1
  248. package/types/mixins/RippleMixin.d.ts.map +1 -1
  249. package/types/mixins/ScrollListenerMixin.d.ts +7 -2
  250. package/types/mixins/ScrollListenerMixin.d.ts.map +1 -1
  251. package/types/mixins/SemiStickyMixin.d.ts +1 -1
  252. package/types/mixins/SemiStickyMixin.d.ts.map +1 -1
  253. package/types/mixins/ShapeMaskedMixin.d.ts +4 -1
  254. package/types/mixins/ShapeMaskedMixin.d.ts.map +1 -1
  255. package/types/mixins/ShapeMixin.d.ts +1 -0
  256. package/types/mixins/ShapeMixin.d.ts.map +1 -1
  257. package/types/mixins/StateMixin.d.ts +2 -0
  258. package/types/mixins/StateMixin.d.ts.map +1 -1
  259. package/types/mixins/TextFieldMixin.d.ts +7 -1208
  260. package/types/mixins/TextFieldMixin.d.ts.map +1 -1
  261. package/types/mixins/ThemableMixin.d.ts +1 -0
  262. package/types/mixins/ThemableMixin.d.ts.map +1 -1
  263. package/types/mixins/TooltipTriggerMixin.d.ts +12 -4
  264. package/types/mixins/TooltipTriggerMixin.d.ts.map +1 -1
  265. package/types/mixins/TouchTargetMixin.d.ts +4 -1
  266. package/types/mixins/TouchTargetMixin.d.ts.map +1 -1
  267. package/types/mixins/TypographyMixin.d.ts +4 -1
  268. package/types/mixins/TypographyMixin.d.ts.map +1 -1
  269. package/types/services/theme.d.ts.map +1 -1
  270. package/types/utils/jsx-runtime.d.ts +3 -3
  271. package/types/utils/jsx-runtime.d.ts.map +1 -1
  272. package/types/utils/material-color/hct/Hct.d.ts.map +1 -1
  273. package/types/utils/material-color/palettes/CorePalette.d.ts +1 -1
  274. package/types/utils/material-color/palettes/CorePalette.d.ts.map +1 -1
  275. package/types/utils/material-color/scheme/Scheme.d.ts.map +1 -1
  276. package/types/utils/pixelmatch.d.ts +3 -3
  277. package/types/utils/pixelmatch.d.ts.map +1 -1
  278. package/types/utils/searchParams.d.ts.map +1 -1
  279. package/utils/jsx-runtime.js +9 -4
  280. package/utils/pixelmatch.js +10 -7
  281. package/utils/searchParams.js +3 -0
  282. package/components/Button.md +0 -61
@@ -8,8 +8,11 @@ import ThemableMixin from '../mixins/ThemableMixin.js';
8
8
  const DOMString = { nullParser: String, value: '' };
9
9
 
10
10
  /**
11
+ * TextArea is a multi-line text input that auto-resizes and integrates with
12
+ * text-field patterns for labels and validation.
13
+ * implements {HTMLTextAreaElement}
14
+ * @see https://m3.material.io/components/text-fields/specs
11
15
  * @see https://html.spec.whatwg.org/multipage/form-elements.html#the-textarea-element
12
- * -implements {HTMLTextAreaElement}
13
16
  */
14
17
  export default CustomElement
15
18
  .extend()
@@ -19,33 +22,52 @@ export default CustomElement
19
22
  .mixin(TextFieldMixin)
20
23
  .mixin(ResizeObserverMixin)
21
24
  .set({
25
+ /** Whether the UA supports the `lh` CSS unit for line-height. */
22
26
  supportsCSSLineHeightUnit: CSS.supports('height', '1lh'),
27
+ /** The control type used by the component. */
23
28
  type: 'textarea',
29
+ /** Internal flag used while performing auto-resize logic. */
24
30
  _resizing: false,
25
31
  })
26
32
  .overrides({
33
+ /** Tag name used for the native control element. */
27
34
  controlTagName: 'textarea',
35
+ /** Textareas are not void elements. */
28
36
  controlVoidElement: false,
29
37
  })
30
38
  .observe({
39
+ /** When true the textarea is fixed-size and will not auto-resize. */
31
40
  fixed: { type: 'boolean' },
41
+ /** Minimum number of rows to display. Mirrors the `minrows` attribute. */
32
42
  minRows: { attr: 'minrows', type: 'integer', nullable: false },
43
+ /** Maximum number of rows to allow when auto-resizing. */
33
44
  maxRows: { attr: 'maxrows', type: 'integer', nullable: false },
45
+ /** Computed or measured line-height token used for resizing. */
34
46
  _lineHeight: 'string',
47
+ /** Number of columns (characters) for the control (integer). */
35
48
  cols: { type: 'integer', empty: 0 },
49
+ /** The `dirname` attribute value forwarded to the native control. */
36
50
  dirName: { attr: 'dirname', ...DOMString },
51
+ /** Maximum allowed characters for the control. */
37
52
  maxLength: { attr: 'maxlength', type: 'integer', empty: 0 },
53
+ /** Minimum required characters for the control. */
38
54
  minLength: { attr: 'minlength', type: 'integer', empty: 0 },
55
+ /** Placeholder text forwarded to the native control. */
39
56
  placeholder: DOMString,
57
+ /** Number of rows to render; updated when resizing. */
40
58
  rows: { type: 'integer', empty: 1 },
59
+ /** Wrapping behavior token forwarded to the native control. */
41
60
  wrap: DOMString,
42
61
  // Not in spec, but plays nice with HTML linters
62
+ /** Forwards a `value` attribute to the internal `defaultValue`. */
43
63
  defaultValueAttr: { attr: 'value', ...DOMString },
44
64
  })
45
65
  .define({
66
+ /** Return the underlying native `HTMLTextAreaElement` control. */
46
67
  _textarea() { return /** @type {HTMLTextAreaElement} */ (this.refs.control); },
47
68
  })
48
69
  .define({
70
+ /** The default value (initial value) of the internal textarea. */
49
71
  defaultValue: {
50
72
  get() { return this._textarea.defaultValue; },
51
73
  set(value) {
@@ -58,7 +80,9 @@ export default CustomElement
58
80
  this.textContent = this._textarea.defaultValue;
59
81
  },
60
82
  },
83
+ /** Number of characters currently in the textarea. */
61
84
  textLength() { return this._textarea.textLength; },
85
+ /** Focus + select helper forwarded to the native control. */
62
86
  select() { return this._textarea.select; },
63
87
 
64
88
  selectionDirection: {
@@ -76,12 +100,18 @@ export default CustomElement
76
100
  set(value) { this._textarea.selectionEnd = value; },
77
101
  },
78
102
 
103
+ /** Convenience passthrough to `HTMLTextAreaElement.setRangeText`. */
79
104
  setRangeText() { return this._textarea.setRangeText; },
80
105
 
106
+ /** Convenience passthrough to `HTMLTextAreaElement.setSelectionRange`. */
81
107
  setSelectionRange() { return this._textarea.setSelectionRange; },
82
108
 
83
109
  })
84
110
  .methods({
111
+ /**
112
+ * Resize the textarea to fit content up to `maxRows` and not below
113
+ * `minRows`. This updates the `rows` property and internal layout state.
114
+ */
85
115
  resize() {
86
116
  if (this._resizing) return;
87
117
  this._resizing = true;
@@ -135,6 +165,7 @@ export default CustomElement
135
165
  this._resizing = false;
136
166
  // if (this.placeholder) textarea.setAttribute('placeholder', this.placeholder);
137
167
  },
168
+ /** Called by the ResizeObserver mixin; triggers a resize unless active. */
138
169
  onResizeObserved() {
139
170
  if (this.matches(':active')) return;
140
171
  this.resize();
@@ -1,5 +1,9 @@
1
1
  import Display from './Display.js';
2
2
 
3
+ /**
4
+ * Material Design Type scale: Title.
5
+ * @see https://m3.material.io/styles/typography/type-scale-tokens
6
+ */
3
7
  export default Display
4
8
  .extend()
5
9
  .set({
@@ -3,17 +3,24 @@ import AriaReflectorMixin from '../mixins/AriaReflectorMixin.js';
3
3
  import ShapeMixin from '../mixins/ShapeMixin.js';
4
4
  import ThemableMixin from '../mixins/ThemableMixin.js';
5
5
 
6
- /* https://m3.material.io/components/tooltips/specs */
7
-
6
+ /**
7
+ * Tooltip displays brief helper text when hovering or focusing an element.
8
+ * @see https://m3.material.io/components/tooltips/specs
9
+ */
8
10
  export default CustomElement
9
11
  .extend()
10
12
  .mixin(ThemableMixin)
11
13
  .mixin(ShapeMixin)
12
14
  .mixin(AriaReflectorMixin)
13
15
  .set({
16
+ /** ARIA role applied by the AriaReflectorMixin (defaults to `tooltip`). */
14
17
  _ariaRole: 'tooltip',
15
18
  })
16
19
  .observe({
20
+ /**
21
+ * When true the tooltip is visible/open. This also updates ARIA
22
+ * `aria-hidden` for accessibility.
23
+ */
17
24
  open: {
18
25
  type: 'boolean',
19
26
  changedCallback(oldValue, newValue) {
@@ -15,6 +15,11 @@ import ThemableMixin from '../mixins/ThemableMixin.js';
15
15
  * removed when raised
16
16
  */
17
17
 
18
+ /**
19
+ * Top app bar provides a consistent place for navigation and actions at the
20
+ * top of the screen. It supports small, medium, and large variants.
21
+ * @see https://m3.material.io/components/top-app-bar/specs
22
+ */
18
23
  export default CustomElement
19
24
  .extend()
20
25
  .mixin(ThemableMixin)
@@ -23,14 +28,21 @@ export default CustomElement
23
28
  .mixin(SemiStickyMixin)
24
29
  .mixin(DelegatesFocusMixin)
25
30
  .observe({
31
+ /** Whether the bar is currently raised/elevated (scrolled). */
26
32
  _raised: 'boolean',
33
+ /** Headline opacity used when companion region is visible (0..1). */
27
34
  _headlineOpacity: { type: 'float', default: 0 },
35
+ /** Headline text displayed in the center area. */
28
36
  headline: 'string',
37
+ /** Size variant: 'small' | 'medium' | 'large' or `null` to auto-select. */
29
38
  size: { value: /** @type {'small'|'medium'|'large'|null} */ (null) },
39
+ /** Color token name used for ink/background. */
30
40
  color: 'string',
41
+ /** Color token to use when the bar is raised. */
31
42
  raisedColor: 'string',
32
43
  })
33
44
  .observe({
45
+ /** Computed style tokens injected for raised-background when `raisedColor` is set. */
34
46
  _styles: {
35
47
  ...ELEMENT_STYLE_TYPE,
36
48
  get({ raisedColor }) {
@@ -39,8 +51,10 @@ export default CustomElement
39
51
  + `{background-color:rgb(var(--mdw-color__${raisedColor}))`
40
52
  + '}';
41
53
  }
54
+ return null;
42
55
  },
43
56
  },
57
+ /** Animation config for the headline element when companion is visible. */
44
58
  _headlineStyle: {
45
59
  ...ELEMENT_ANIMATION_TYPE,
46
60
  get({ size, _headlineOpacity }) {
@@ -58,6 +72,7 @@ export default CustomElement
58
72
  },
59
73
  })
60
74
  .expressions({
75
+ /** True when the companion region should be rendered (medium/large). */
61
76
  _companionIf({ size }) {
62
77
  return size === 'medium' || size === 'large';
63
78
  },
@@ -30,6 +30,15 @@ import { generateUID } from './uid.js';
30
30
  * @prop {any} [injections]
31
31
  */
32
32
 
33
+ /**
34
+ * @template T
35
+ * @typedef {{
36
+ * target: Element|DocumentFragment,
37
+ * byProp: (prop: keyof T & string, value:any, data?:Partial<T>) => void,
38
+ * state: InitializationState,
39
+ * } & ((changes:Partial<T>, data:T) => void)} RenderDraw
40
+ */
41
+
33
42
  /** @typedef {HTMLElementEventMap & { input: InputEvent; } } HTMLElementEventMapFixed */
34
43
 
35
44
  /**
@@ -74,7 +83,7 @@ import { generateUID } from './uid.js';
74
83
  * @typedef {(
75
84
  * HTMLElementEventMapFixed
76
85
  * & {[P in keyof HTMLElementCancellableEventMap as `~${P}`]: HTMLElementCancellableEventMap[P]}
77
- * & Record<string, Event|CustomEvent>
86
+ * & Record<string, Event|CustomEvent<any>>
78
87
  * )} CompositionEventMap
79
88
  */
80
89
 
@@ -83,7 +92,7 @@ import { generateUID } from './uid.js';
83
92
  * @template {keyof CompositionEventMap} [K = keyof CompositionEventMap]
84
93
  * @typedef {{
85
94
  * type?: K
86
- * tag?: string,
95
+ * tag?: string|symbol,
87
96
  * capture?: boolean;
88
97
  * once?: boolean;
89
98
  * passive?: boolean;
@@ -132,6 +141,8 @@ import { generateUID } from './uid.js';
132
141
  * @prop {number} cacheIndex
133
142
  * @prop {number} searchIndex
134
143
  * @prop {string | Function | string[]} query
144
+ * @prop {boolean} [negate]
145
+ * @prop {boolean} [doubleNegate]
135
146
  * @prop {Function} [expression]
136
147
  * @prop {string} prop
137
148
  * @prop {string[]} deepProp
@@ -150,6 +161,7 @@ import { generateUID } from './uid.js';
150
161
  * @prop {string} [attrName]
151
162
  * @prop {any} [defaultValue]
152
163
  * @prop {RenderGraphSearch} search
164
+ * @prop {InterpolateOptions['injections']} [injections]
153
165
  */
154
166
 
155
167
  /**
@@ -158,8 +170,7 @@ import { generateUID } from './uid.js';
158
170
  */
159
171
  function writeDOMAttribute({ nodes }, value) {
160
172
  const { nodeIndex, attrName } = this;
161
- /** @type {Element} */
162
- const element = nodes[nodeIndex];
173
+ const element = /** @type {Element} */ (nodes[nodeIndex]);
163
174
  switch (value) {
164
175
  case undefined:
165
176
  case null:
@@ -215,7 +226,7 @@ function writeDynamicNode({ nodeStates, comments, nodes }, value) {
215
226
  // eslint-disable-next-line no-bitwise
216
227
  nodeStates[nodeIndex] &= ~0b0010;
217
228
  } else {
218
- node.data = value;
229
+ /** @type {Text} */ (node).data = value;
219
230
  }
220
231
 
221
232
  // Updated, now set hidden state
@@ -361,7 +372,7 @@ function searchWithDeepProp(state, changes, data) {
361
372
  /**
362
373
  * @typedef InterpolateOptions
363
374
  * @prop {Record<string,any>} [defaults] Default values to use for interpolation
364
- * @prop {{iterable:string} & Record<string,any>} [injections] Context-specific injected properties. (Experimental)
375
+ * @prop {{iterable:string} & Record<string,any> & {index:number}} [injections] Context-specific injected properties. (Experimental)
365
376
  */
366
377
 
367
378
  /**
@@ -373,7 +384,7 @@ function searchWithDeepProp(state, changes, data) {
373
384
  * @prop {Comment[]} comments
374
385
  * @prop {Uint8Array} nodeStates
375
386
  * @prop {Uint8Array} searchStates
376
- * @prop {Element[]} refs
387
+ * @prop {HTMLElement[]} refs
377
388
  * @prop {number} lastChildNodeIndex
378
389
  * @prop {RenderOptions<?>} options
379
390
  */
@@ -518,7 +529,7 @@ export default class Composition {
518
529
  * Only store metadata, not actual data. Currently only needs length.
519
530
  * TBD if more is needed later
520
531
  * Referenced by property key (string)
521
- * @type {CompositionAdapter}
532
+ * @type {CompositionAdapter<T>}
522
533
  */
523
534
  adapter;
524
535
 
@@ -661,10 +672,9 @@ export default class Composition {
661
672
  * @param {Partial<T>} changes what specifically
662
673
  * @param {T} [data]
663
674
  * @param {RenderOptions<T>} [options]
664
- * @return {Function & {target:Element}} anchor
675
+ * @return {RenderDraw<T>} anchor
665
676
  */
666
677
  render(changes, data, options = {}) {
667
- // console.log('render', changes, options);
668
678
  if (!this.interpolated) {
669
679
  this.interpolate({
670
680
  defaults: data ?? changes,
@@ -703,20 +713,20 @@ export default class Composition {
703
713
  console.warn('found empty tag??');
704
714
  refs.push(null);
705
715
  nodes.push(null);
706
- textNode = instanceFragment.firstChild;
716
+ textNode = /** @type {Text} */ (instanceFragment.firstChild);
707
717
  } else {
708
718
  const element = instanceFragment.getElementById(tag);
709
719
  refs.push(element);
710
720
  nodes.push(element);
711
721
  this.#bindCompositionEventListeners(tag, element, options.context);
712
722
  if (!textNodes.length) continue;
713
- textNode = element.firstChild;
723
+ textNode = /** @type {Text} */ (element.firstChild);
714
724
  }
715
725
 
716
726
  let currentIndex = 0;
717
727
  for (const index of textNodes) {
718
728
  while (index !== currentIndex) {
719
- textNode = textNode.nextSibling;
729
+ textNode = /** @type {Text} */ (textNode.nextSibling);
720
730
  currentIndex++;
721
731
  }
722
732
  nodes.push(textNode);
@@ -734,6 +744,7 @@ export default class Composition {
734
744
  * @param {T} data
735
745
  */
736
746
  const draw = (changes, data) => {
747
+ if (!changes) return;
737
748
  let ranSearch = false;
738
749
  for (const prop of this.props) {
739
750
  if (!this.actionsByPropsUsed?.has(prop)) continue;
@@ -801,12 +812,14 @@ export default class Composition {
801
812
  searchStates[search.searchIndex] = 0b0011;
802
813
  }
803
814
 
815
+ /** @type {Partial<T>} */
804
816
  let changes;
805
817
  const actions = this.actionsByPropsUsed.get(prop);
806
818
  for (const action of actions) {
807
819
  if (action.search.query === prop) {
808
820
  action.invocation(initState, value);
809
821
  } else {
822
+ // @ts-expect-error Skip cast
810
823
  changes ??= { [prop]: value };
811
824
  data ??= changes;
812
825
  ranSearch = true;
@@ -1150,11 +1163,22 @@ export default class Composition {
1150
1163
  defaultValue,
1151
1164
  search,
1152
1165
  };
1153
- text.data = typeof defaultValue === 'string' ? defaultValue : '';
1166
+ switch (typeof defaultValue) {
1167
+ case 'string':
1168
+ text.data = defaultValue;
1169
+ break;
1170
+ case 'number':
1171
+ // Manually coerce to string (0 will be empty otherwise)
1172
+ text.data = `${defaultValue}`;
1173
+ break;
1174
+ default:
1175
+ text.data = '';
1176
+ break;
1177
+ }
1154
1178
  } else if (subnode) {
1155
1179
  action = {
1156
1180
  nodeIndex: this._interpolationState.nodeIndex,
1157
- attrName: subnode,
1181
+ attrName: /** @type {string} */ (subnode),
1158
1182
  defaultValue,
1159
1183
  invocation: writeDOMAttribute,
1160
1184
  search,
@@ -1255,6 +1279,7 @@ export default class Composition {
1255
1279
  const newComposition = new Composition();
1256
1280
  newComposition.template.append(element);
1257
1281
  // Move uninterpolated element to new composition template.
1282
+ /** @type {InterpolateOptions['injections']} */
1258
1283
  const injections = {
1259
1284
  ...options.injections,
1260
1285
  [valueName]: null,
@@ -1266,6 +1291,9 @@ export default class Composition {
1266
1291
  const search = {
1267
1292
  cacheIndex: this._interpolationState.cacheIndex++,
1268
1293
  searchIndex: this._interpolationState.searchIndex++,
1294
+ query: null,
1295
+ prop: null,
1296
+ deepProp: null,
1269
1297
  propsUsed,
1270
1298
  deepPropsUsed: [[iterableName]],
1271
1299
  defaultValue: {},
@@ -1416,6 +1444,7 @@ export default class Composition {
1416
1444
  this.#interpolateIterable(element, options);
1417
1445
  continue;
1418
1446
  } else {
1447
+ // @ts-expect-error Bad typings
1419
1448
  const idAttr = element.attributes.id;
1420
1449
  if (idAttr) {
1421
1450
  this.#interpolateNode(idAttr, element, options);
@@ -1432,7 +1461,7 @@ export default class Composition {
1432
1461
  element = node.parentElement;
1433
1462
  if (this.#interpolateNode(/** @type {Text} */ (node), element, options)) {
1434
1463
  const nextNode = treeWalker.nextNode();
1435
- node.remove();
1464
+ /** @type {Text} */ (node).remove();
1436
1465
  node = nextNode;
1437
1466
  continue;
1438
1467
  }
@@ -1,9 +1,22 @@
1
1
  import { createEmptyComment } from './optimizations.js';
2
2
 
3
3
  /**
4
+ * @template T
5
+ * @typedef {import('./Composition.js').default<T>} Composition
6
+ */
7
+
8
+ /**
9
+ * @template T
10
+ * @typedef {import('./Composition.js').RenderOptions<T>} RenderOptions
11
+ */
12
+
13
+ /**
14
+ * @template T
4
15
  * @typedef {Object} DomAdapterCreateOptions
5
16
  * @prop {Comment} anchorNode
6
17
  * @prop {(...args:any[]) => HTMLElement} [create]
18
+ * @prop {Composition<T>} composition
19
+ * @prop {RenderOptions<T>} renderOptions
7
20
  */
8
21
 
9
22
  /**
@@ -16,8 +29,9 @@ import { createEmptyComment } from './optimizations.js';
16
29
  * @prop {Comment} [comment]
17
30
  */
18
31
 
32
+ /** @template T */
19
33
  export default class CompositionAdapter {
20
- /** @param {DomAdapterCreateOptions} options */
34
+ /** @param {DomAdapterCreateOptions<T>} options */
21
35
  constructor(options) {
22
36
  this.anchorNode = options.anchorNode;
23
37
 
@@ -37,12 +51,11 @@ export default class CompositionAdapter {
37
51
  */
38
52
  this.needsArrayKeyFastPath = false;
39
53
 
54
+ /** @type {Composition<T>} */
40
55
  this.composition = options.composition;
56
+ /** @type {RenderOptions<T>} */
41
57
  this.renderOptions = options.renderOptions;
42
58
 
43
- this.pendingRemoves = [];
44
- // Batch objects
45
-
46
59
  /** @type {Map<any, ItemMetadata>} */
47
60
  this.metadataCache = null;
48
61
 
@@ -55,6 +68,11 @@ export default class CompositionAdapter {
55
68
  this.batchEndIndex = null;
56
69
  }
57
70
 
71
+ /**
72
+ * @param {Partial<T>} changes
73
+ * @param {T} data
74
+ * @return {import('./Composition.js').RenderDraw<T>}
75
+ */
58
76
  render(changes, data) {
59
77
  return this.composition.render(changes, data, this.renderOptions);
60
78
  }
@@ -66,7 +84,7 @@ export default class CompositionAdapter {
66
84
 
67
85
  writeBatch() {
68
86
  if (!this.queuedElements.length) return;
69
- /** @type {Comment|Element} */
87
+ /** @type {Comment|Element|Document} */
70
88
  const previousSibling = this.metadata[this.batchStartIndex - 1]?.domNode ?? this.anchorNode;
71
89
  previousSibling.after(...this.queuedElements);
72
90
  this.queuedElements.length = 0;
@@ -226,7 +244,7 @@ export default class CompositionAdapter {
226
244
  }
227
245
 
228
246
  const render = this.render(changes, data);
229
- const element = render.target;
247
+ const element = /** @type {Element} */ (render.target);
230
248
 
231
249
  this.metadata[newIndex] = {
232
250
  render,