godown 3.0.0-canary.10 → 3.0.0-canary.11

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 (277) hide show
  1. package/README.md +1 -1
  2. package/components/alert.d.ts +2 -1
  3. package/components/alert.d.ts.map +1 -1
  4. package/components/alert.js +5 -7
  5. package/components/alert.js.map +1 -1
  6. package/components/avatar.d.ts +2 -1
  7. package/components/avatar.d.ts.map +1 -1
  8. package/components/avatar.js +7 -4
  9. package/components/avatar.js.map +1 -1
  10. package/components/breath.d.ts +3 -2
  11. package/components/breath.d.ts.map +1 -1
  12. package/components/breath.js +4 -3
  13. package/components/breath.js.map +1 -1
  14. package/components/button.d.ts +5 -3
  15. package/components/button.d.ts.map +1 -1
  16. package/components/button.js +3 -2
  17. package/components/button.js.map +1 -1
  18. package/components/card.d.ts +2 -1
  19. package/components/card.d.ts.map +1 -1
  20. package/components/card.js +4 -3
  21. package/components/card.js.map +1 -1
  22. package/components/carousel.d.ts +3 -1
  23. package/components/carousel.d.ts.map +1 -1
  24. package/components/carousel.js +15 -9
  25. package/components/carousel.js.map +1 -1
  26. package/components/details.d.ts +2 -1
  27. package/components/details.d.ts.map +1 -1
  28. package/components/details.js +2 -1
  29. package/components/details.js.map +1 -1
  30. package/components/dialog.d.ts +2 -2
  31. package/components/dialog.d.ts.map +1 -1
  32. package/components/dialog.js +3 -2
  33. package/components/dialog.js.map +1 -1
  34. package/components/divider.d.ts +2 -3
  35. package/components/divider.d.ts.map +1 -1
  36. package/components/divider.js +5 -6
  37. package/components/divider.js.map +1 -1
  38. package/components/dragbox.d.ts +2 -1
  39. package/components/dragbox.d.ts.map +1 -1
  40. package/components/dragbox.js +2 -1
  41. package/components/dragbox.js.map +1 -1
  42. package/components/flex.d.ts +2 -1
  43. package/components/flex.d.ts.map +1 -1
  44. package/components/flex.js +5 -4
  45. package/components/flex.js.map +1 -1
  46. package/components/form.d.ts +2 -1
  47. package/components/form.d.ts.map +1 -1
  48. package/components/form.js.map +1 -1
  49. package/components/grid.d.ts +2 -1
  50. package/components/grid.d.ts.map +1 -1
  51. package/components/grid.js +5 -4
  52. package/components/grid.js.map +1 -1
  53. package/components/input.d.ts +2 -1
  54. package/components/input.d.ts.map +1 -1
  55. package/components/input.js +2 -1
  56. package/components/input.js.map +1 -1
  57. package/components/layout.d.ts +2 -1
  58. package/components/layout.d.ts.map +1 -1
  59. package/components/layout.js +5 -5
  60. package/components/layout.js.map +1 -1
  61. package/components/link.d.ts.map +1 -1
  62. package/components/progress.d.ts +2 -1
  63. package/components/progress.d.ts.map +1 -1
  64. package/components/progress.js +3 -2
  65. package/components/progress.js.map +1 -1
  66. package/components/range.d.ts +3 -2
  67. package/components/range.d.ts.map +1 -1
  68. package/components/range.js +3 -6
  69. package/components/range.js.map +1 -1
  70. package/components/rotate.d.ts +2 -1
  71. package/components/rotate.d.ts.map +1 -1
  72. package/components/rotate.js.map +1 -1
  73. package/components/router.d.ts +9 -9
  74. package/components/router.d.ts.map +1 -1
  75. package/components/router.js.map +1 -1
  76. package/components/select.d.ts +2 -1
  77. package/components/select.d.ts.map +1 -1
  78. package/components/select.js +8 -4
  79. package/components/select.js.map +1 -1
  80. package/components/skeleton.d.ts +2 -1
  81. package/components/skeleton.d.ts.map +1 -1
  82. package/components/skeleton.js +3 -2
  83. package/components/skeleton.js.map +1 -1
  84. package/components/split.d.ts +2 -1
  85. package/components/split.d.ts.map +1 -1
  86. package/components/split.js +3 -2
  87. package/components/split.js.map +1 -1
  88. package/components/switch.d.ts +2 -1
  89. package/components/switch.d.ts.map +1 -1
  90. package/components/switch.js +3 -2
  91. package/components/switch.js.map +1 -1
  92. package/components/text.d.ts +2 -1
  93. package/components/text.d.ts.map +1 -1
  94. package/components/text.js +3 -4
  95. package/components/text.js.map +1 -1
  96. package/components/time.d.ts +2 -2
  97. package/components/time.d.ts.map +1 -1
  98. package/components/time.js +3 -2
  99. package/components/time.js.map +1 -1
  100. package/components/tooltip.d.ts +2 -1
  101. package/components/tooltip.d.ts.map +1 -1
  102. package/components/tooltip.js +3 -2
  103. package/components/tooltip.js.map +1 -1
  104. package/components/typewriter.d.ts +2 -2
  105. package/components/typewriter.d.ts.map +1 -1
  106. package/components/typewriter.js +3 -4
  107. package/components/typewriter.js.map +1 -1
  108. package/core/global-style.d.ts.map +1 -1
  109. package/core/global-style.js +1 -1
  110. package/core/global-style.js.map +1 -1
  111. package/core/super-anchor.d.ts +2 -1
  112. package/core/super-anchor.d.ts.map +1 -1
  113. package/core/super-anchor.js +3 -2
  114. package/core/super-anchor.js.map +1 -1
  115. package/core/super-input.d.ts +3 -2
  116. package/core/super-input.d.ts.map +1 -1
  117. package/core/super-input.js.map +1 -1
  118. package/core/super-openable.d.ts.map +1 -1
  119. package/core/super-openable.js +1 -1
  120. package/core/super-openable.js.map +1 -1
  121. package/custom-elements.json +1 -1
  122. package/dev/components/alert.d.ts +2 -1
  123. package/dev/components/alert.d.ts.map +1 -1
  124. package/dev/components/alert.js +12 -10
  125. package/dev/components/alert.js.map +1 -1
  126. package/dev/components/avatar.d.ts +2 -1
  127. package/dev/components/avatar.d.ts.map +1 -1
  128. package/dev/components/avatar.js +21 -7
  129. package/dev/components/avatar.js.map +1 -1
  130. package/dev/components/breath.d.ts +3 -2
  131. package/dev/components/breath.d.ts.map +1 -1
  132. package/dev/components/breath.js +17 -5
  133. package/dev/components/breath.js.map +1 -1
  134. package/dev/components/button.d.ts +5 -3
  135. package/dev/components/button.d.ts.map +1 -1
  136. package/dev/components/button.js +6 -1
  137. package/dev/components/button.js.map +1 -1
  138. package/dev/components/card.d.ts +2 -1
  139. package/dev/components/card.d.ts.map +1 -1
  140. package/dev/components/card.js +8 -5
  141. package/dev/components/card.js.map +1 -1
  142. package/dev/components/carousel.d.ts +3 -1
  143. package/dev/components/carousel.d.ts.map +1 -1
  144. package/dev/components/carousel.js +26 -13
  145. package/dev/components/carousel.js.map +1 -1
  146. package/dev/components/details.d.ts +2 -1
  147. package/dev/components/details.d.ts.map +1 -1
  148. package/dev/components/details.js +8 -3
  149. package/dev/components/details.js.map +1 -1
  150. package/dev/components/dialog.d.ts +2 -2
  151. package/dev/components/dialog.d.ts.map +1 -1
  152. package/dev/components/dialog.js +11 -10
  153. package/dev/components/dialog.js.map +1 -1
  154. package/dev/components/divider.d.ts +2 -3
  155. package/dev/components/divider.d.ts.map +1 -1
  156. package/dev/components/divider.js +19 -7
  157. package/dev/components/divider.js.map +1 -1
  158. package/dev/components/dragbox.d.ts +2 -1
  159. package/dev/components/dragbox.d.ts.map +1 -1
  160. package/dev/components/dragbox.js +8 -1
  161. package/dev/components/dragbox.js.map +1 -1
  162. package/dev/components/flex.d.ts +2 -1
  163. package/dev/components/flex.d.ts.map +1 -1
  164. package/dev/components/flex.js +16 -4
  165. package/dev/components/flex.js.map +1 -1
  166. package/dev/components/form.d.ts +2 -1
  167. package/dev/components/form.d.ts.map +1 -1
  168. package/dev/components/form.js.map +1 -1
  169. package/dev/components/grid.d.ts +2 -1
  170. package/dev/components/grid.d.ts.map +1 -1
  171. package/dev/components/grid.js +16 -4
  172. package/dev/components/grid.js.map +1 -1
  173. package/dev/components/input.d.ts +2 -1
  174. package/dev/components/input.d.ts.map +1 -1
  175. package/dev/components/input.js +2 -1
  176. package/dev/components/input.js.map +1 -1
  177. package/dev/components/layout.d.ts +2 -1
  178. package/dev/components/layout.d.ts.map +1 -1
  179. package/dev/components/layout.js +13 -6
  180. package/dev/components/layout.js.map +1 -1
  181. package/dev/components/link.d.ts.map +1 -1
  182. package/dev/components/progress.d.ts +2 -1
  183. package/dev/components/progress.d.ts.map +1 -1
  184. package/dev/components/progress.js +7 -2
  185. package/dev/components/progress.js.map +1 -1
  186. package/dev/components/range.d.ts +3 -2
  187. package/dev/components/range.d.ts.map +1 -1
  188. package/dev/components/range.js +9 -12
  189. package/dev/components/range.js.map +1 -1
  190. package/dev/components/rotate.d.ts +2 -1
  191. package/dev/components/rotate.d.ts.map +1 -1
  192. package/dev/components/rotate.js +1 -1
  193. package/dev/components/rotate.js.map +1 -1
  194. package/dev/components/router.d.ts +9 -9
  195. package/dev/components/router.d.ts.map +1 -1
  196. package/dev/components/router.js.map +1 -1
  197. package/dev/components/select.d.ts +2 -1
  198. package/dev/components/select.d.ts.map +1 -1
  199. package/dev/components/select.js +18 -7
  200. package/dev/components/select.js.map +1 -1
  201. package/dev/components/skeleton.d.ts +2 -1
  202. package/dev/components/skeleton.d.ts.map +1 -1
  203. package/dev/components/skeleton.js +4 -3
  204. package/dev/components/skeleton.js.map +1 -1
  205. package/dev/components/split.d.ts +2 -1
  206. package/dev/components/split.d.ts.map +1 -1
  207. package/dev/components/split.js +14 -10
  208. package/dev/components/split.js.map +1 -1
  209. package/dev/components/switch.d.ts +2 -1
  210. package/dev/components/switch.d.ts.map +1 -1
  211. package/dev/components/switch.js +13 -9
  212. package/dev/components/switch.js.map +1 -1
  213. package/dev/components/text.d.ts +2 -1
  214. package/dev/components/text.d.ts.map +1 -1
  215. package/dev/components/text.js +4 -4
  216. package/dev/components/text.js.map +1 -1
  217. package/dev/components/time.d.ts +2 -2
  218. package/dev/components/time.d.ts.map +1 -1
  219. package/dev/components/time.js +5 -2
  220. package/dev/components/time.js.map +1 -1
  221. package/dev/components/tooltip.d.ts +2 -1
  222. package/dev/components/tooltip.d.ts.map +1 -1
  223. package/dev/components/tooltip.js +24 -12
  224. package/dev/components/tooltip.js.map +1 -1
  225. package/dev/components/typewriter.d.ts +2 -2
  226. package/dev/components/typewriter.d.ts.map +1 -1
  227. package/dev/components/typewriter.js +11 -4
  228. package/dev/components/typewriter.js.map +1 -1
  229. package/dev/core/global-style.d.ts.map +1 -1
  230. package/dev/core/global-style.js +10 -1
  231. package/dev/core/global-style.js.map +1 -1
  232. package/dev/core/super-anchor.d.ts +2 -1
  233. package/dev/core/super-anchor.d.ts.map +1 -1
  234. package/dev/core/super-anchor.js +8 -5
  235. package/dev/core/super-anchor.js.map +1 -1
  236. package/dev/core/super-input.d.ts +3 -2
  237. package/dev/core/super-input.d.ts.map +1 -1
  238. package/dev/core/super-input.js +1 -1
  239. package/dev/core/super-input.js.map +1 -1
  240. package/dev/core/super-openable.d.ts.map +1 -1
  241. package/dev/core/super-openable.js +1 -1
  242. package/dev/core/super-openable.js.map +1 -1
  243. package/package.json +5 -4
  244. package/src/components/alert.ts +18 -16
  245. package/src/components/avatar.ts +25 -11
  246. package/src/components/breath.ts +22 -10
  247. package/src/components/button.ts +16 -10
  248. package/src/components/card.ts +9 -6
  249. package/src/components/carousel.ts +35 -21
  250. package/src/components/details.ts +10 -5
  251. package/src/components/dialog.ts +18 -17
  252. package/src/components/divider.ts +19 -7
  253. package/src/components/dragbox.ts +15 -8
  254. package/src/components/flex.ts +17 -5
  255. package/src/components/form.ts +4 -4
  256. package/src/components/grid.ts +17 -5
  257. package/src/components/input.ts +5 -4
  258. package/src/components/layout.ts +15 -8
  259. package/src/components/link.ts +1 -1
  260. package/src/components/progress.ts +9 -4
  261. package/src/components/range.ts +29 -34
  262. package/src/components/rotate.ts +9 -6
  263. package/src/components/router.ts +27 -19
  264. package/src/components/select.ts +31 -18
  265. package/src/components/skeleton.ts +6 -5
  266. package/src/components/split.ts +22 -18
  267. package/src/components/switch.ts +18 -14
  268. package/src/components/text.ts +6 -8
  269. package/src/components/time.ts +12 -9
  270. package/src/components/tooltip.ts +26 -14
  271. package/src/components/typewriter.ts +19 -14
  272. package/src/core/global-style.ts +23 -4
  273. package/src/core/super-anchor.ts +11 -8
  274. package/src/core/super-input.ts +14 -14
  275. package/src/core/super-openable.ts +5 -5
  276. package/vscode.html-custom-data.json +1 -1
  277. package/web-types.json +1 -1
@@ -1,5 +1,6 @@
1
1
  import { godown, styles } from "@godown/element/decorators/index.js";
2
- import { css } from "lit";
2
+ import { attr } from "@godown/element/directives/attr.js";
3
+ import { css, html, type TemplateResult } from "lit";
3
4
  import { property } from "lit/decorators.js";
4
5
 
5
6
  import { GlobalStyle } from "../core/global-style.js";
@@ -9,25 +10,36 @@ const protoName = "divider";
9
10
  /**
10
11
  * {@linkcode Divider} similar to `<hr>`.
11
12
  *
12
- * This component does not render content.
13
- *
14
13
  * @category layout
15
14
  */
16
15
  @godown(protoName)
17
16
  @styles(
18
17
  css`
19
- :host{
18
+ :host {
20
19
  width: 100%;
21
20
  height: .05em;
22
21
  margin: auto;
23
22
  display: block;
24
23
  background: currentColor;
25
24
  }
25
+
26
26
  :host([vertical]) {
27
27
  width: .05em;
28
28
  height: max(1em, 100%);
29
29
  }
30
- `,
30
+
31
+ :host([contents]) [part=root] {
32
+ width: 100%;
33
+ height: .05em;
34
+ margin: auto;
35
+ display: block;
36
+ background: currentColor;
37
+ }
38
+
39
+ [part=root] {
40
+ display: contents;
41
+ }
42
+ `,
31
43
  )
32
44
  class Divider extends GlobalStyle {
33
45
  /**
@@ -36,8 +48,8 @@ class Divider extends GlobalStyle {
36
48
  @property({ type: Boolean, reflect: true })
37
49
  vertical = false;
38
50
 
39
- connectedCallback() {
40
- this.createRenderRoot();
51
+ protected render(): TemplateResult<1> {
52
+ return html`<div part="root" ${attr(this.observedRecord)}></div>`;
41
53
  }
42
54
  }
43
55
 
@@ -1,8 +1,9 @@
1
1
  import { godown } from "@godown/element/decorators/godown.js";
2
2
  import { styles } from "@godown/element/decorators/styles.js";
3
+ import { attr } from "@godown/element/directives/attr.js";
3
4
  import { htmlSlot } from "@godown/element/directives/html-slot.js";
4
5
  import { EventListenerFunc } from "@godown/element/tools/events.js";
5
- import { css, html } from "lit";
6
+ import { css, html, type TemplateResult } from "lit";
6
7
  import { property } from "lit/decorators.js";
7
8
 
8
9
  import { GlobalStyle } from "../core/global-style.js";
@@ -61,15 +62,21 @@ class Dragbox extends GlobalStyle {
61
62
  @property()
62
63
  y = "auto";
63
64
 
64
- protected render() {
65
- return html`<div @mousedown="${this._handleDragStart}" @mouseup="${this._handleDragEnd}">${htmlSlot()}</div>`;
65
+ protected render(): TemplateResult<1> {
66
+ return html`<div
67
+ part="root"
68
+ ${attr(this.observedRecord)}
69
+ @mousedown="${this._handleDragStart}"
70
+ @mouseup="${this._handleDragEnd}">
71
+ ${htmlSlot()}
72
+ </div>`;
66
73
  }
67
74
 
68
- protected firstUpdated() {
75
+ protected firstUpdated(): void {
69
76
  this.reset();
70
77
  }
71
78
 
72
- protected _handleDragStart(e: MouseEvent) {
79
+ protected _handleDragStart(e: MouseEvent): void {
73
80
  this.cx = e.clientX;
74
81
  this.cy = e.clientY;
75
82
  this.t = this.offsetTop;
@@ -82,13 +89,13 @@ class Dragbox extends GlobalStyle {
82
89
  protected _handleMouseMove: EventListenerFunc;
83
90
  protected _handleMouseLeave: EventListenerFunc;
84
91
 
85
- protected _handleDragEnd() {
92
+ protected _handleDragEnd(): void {
86
93
  this.drag = false;
87
94
  this.events.remove(document, "mousemove", this._handleMouseMove);
88
95
  this.events.remove(document, "mouseleave", this._handleMouseLeave);
89
96
  }
90
97
 
91
- protected _handleDrag(e: MouseEvent) {
98
+ protected _handleDrag(e: MouseEvent): void {
92
99
  if (!this.drag) {
93
100
  return;
94
101
  }
@@ -111,7 +118,7 @@ class Dragbox extends GlobalStyle {
111
118
  }
112
119
  }
113
120
 
114
- reset() {
121
+ reset(): void {
115
122
  const { x, y, style, offsetsWidth, offsetsHeight, offsetWidth, offsetHeight, offsetLeft, offsetTop } = this;
116
123
  style.left = x || "0";
117
124
  style.top = y || "0";
@@ -1,9 +1,10 @@
1
1
  import { godown } from "@godown/element/decorators/godown.js";
2
2
  import { styles } from "@godown/element/decorators/styles.js";
3
+ import { attr } from "@godown/element/directives/attr.js";
3
4
  import { htmlSlot } from "@godown/element/directives/html-slot.js";
4
5
  import { htmlStyle } from "@godown/element/directives/html-style.js";
5
6
  import { joinRules } from "@godown/element/tools/css.js";
6
- import { css } from "lit";
7
+ import { css, html, type TemplateResult } from "lit";
7
8
  import { property } from "lit/decorators.js";
8
9
 
9
10
  import { GlobalStyle } from "../core/global-style.js";
@@ -17,7 +18,16 @@ const protoName = "flex";
17
18
  * @category layout
18
19
  */
19
20
  @godown(protoName)
20
- @styles(css`:host {display:flex;}`)
21
+ @styles(css`
22
+ :host,
23
+ :host([contents]) [part=root] {
24
+ display: flex;
25
+ }
26
+
27
+ [part=root] {
28
+ display: contents;
29
+ }
30
+ `)
21
31
  class Flex extends GlobalStyle {
22
32
  /**
23
33
  * CSS property `flex-flow` (`flex-direction flex-wrap`).
@@ -49,8 +59,9 @@ class Flex extends GlobalStyle {
49
59
  @property({ type: Boolean })
50
60
  vertical = false;
51
61
 
52
- protected render() {
53
- return [
62
+ protected render(): TemplateResult<1> {
63
+ return html`<div part="root" ${attr(this.observedRecord)}>
64
+ ${[
54
65
  htmlSlot(),
55
66
  htmlStyle(
56
67
  joinRules({
@@ -63,7 +74,8 @@ class Flex extends GlobalStyle {
63
74
  },
64
75
  }),
65
76
  ),
66
- ];
77
+ ]}
78
+ </div>`;
67
79
  }
68
80
  }
69
81
 
@@ -1,7 +1,7 @@
1
1
  import { godown } from "@godown/element/decorators/godown.js";
2
2
  import { styles } from "@godown/element/decorators/styles.js";
3
3
  import { htmlSlot } from "@godown/element/directives/html-slot.js";
4
- import { css } from "lit";
4
+ import { css, type TemplateResult } from "lit";
5
5
  import { property } from "lit/decorators.js";
6
6
 
7
7
  import { GlobalStyle } from "../core/global-style.js";
@@ -30,13 +30,13 @@ class Form<T = object> extends GlobalStyle {
30
30
  return Form.buildValue(this._slot.assignedElements()) as T;
31
31
  }
32
32
 
33
- nameValue = this.namevalue;
33
+ nameValue: () => [string, T] = this.namevalue;
34
34
 
35
- protected render() {
35
+ protected render(): TemplateResult<1> {
36
36
  return htmlSlot();
37
37
  }
38
38
 
39
- reset() {
39
+ reset(): void {
40
40
  this.deepQuerySelectorAll<HTMLElement & { reset?: () => void; }>("*").forEach((el) => {
41
41
  if (el.tagName === this.tagName) {
42
42
  return;
@@ -1,10 +1,11 @@
1
1
  import { godown } from "@godown/element/decorators/godown.js";
2
2
  import { styles } from "@godown/element/decorators/styles.js";
3
+ import { attr } from "@godown/element/directives/attr.js";
3
4
  import { htmlSlot } from "@godown/element/directives/html-slot.js";
4
5
  import { htmlStyle } from "@godown/element/directives/html-style.js";
5
6
  import { joinRules } from "@godown/element/tools/css.js";
6
7
  import { isNumerical } from "@godown/element/tools/lib.js";
7
- import { css } from "lit";
8
+ import { css, html, type TemplateResult } from "lit";
8
9
  import { property } from "lit/decorators.js";
9
10
 
10
11
  import { GlobalStyle } from "../core/global-style.js";
@@ -18,7 +19,16 @@ const protoName = "grid";
18
19
  * @category layout
19
20
  */
20
21
  @godown(protoName)
21
- @styles(css`:host{display:grid;}`)
22
+ @styles(css`
23
+ :host,
24
+ :host([contents]) [part=root] {
25
+ display: grid;
26
+ }
27
+
28
+ [part=root] {
29
+ display: contents;
30
+ }
31
+ `)
22
32
  class Grid extends GlobalStyle {
23
33
  /**
24
34
  * CSS property `gap`.
@@ -54,8 +64,9 @@ class Grid extends GlobalStyle {
54
64
  @property()
55
65
  items: string;
56
66
 
57
- protected render() {
58
- return [
67
+ protected render(): TemplateResult<1> {
68
+ return html`<div part="root" ${attr(this.observedRecord)}>
69
+ ${[
59
70
  htmlSlot(),
60
71
  htmlStyle(
61
72
  joinRules({
@@ -68,7 +79,8 @@ class Grid extends GlobalStyle {
68
79
  },
69
80
  }),
70
81
  ),
71
- ];
82
+ ]}
83
+ </div>`;
72
84
  }
73
85
  }
74
86
 
@@ -1,8 +1,9 @@
1
1
  import { godown } from "@godown/element/decorators/godown.js";
2
2
  import { part } from "@godown/element/decorators/part.js";
3
3
  import { styles } from "@godown/element/decorators/styles.js";
4
+ import { attr } from "@godown/element/directives/attr.js";
4
5
  import { classList } from "@godown/element/directives/class-list.js";
5
- import { css, html, nothing } from "lit";
6
+ import { css, html, nothing, type TemplateResult } from "lit";
6
7
  import { property } from "lit/decorators.js";
7
8
 
8
9
  import { cssGlobalVars } from "../core/global-style.js";
@@ -42,8 +43,8 @@ class Input extends SuperInput {
42
43
  @part("input")
43
44
  protected _input: HTMLInputElement;
44
45
 
45
- protected render() {
46
- return html`<div part="root" class="${classList("input-field", this.variant)}">
46
+ protected render(): TemplateResult<1> {
47
+ return html`<div part="root" ${attr(this.observedRecord)} class="${classList("input-field", this.variant)}">
47
48
  ${[
48
49
  this._renderPrefix(),
49
50
  html`<input
@@ -63,7 +64,7 @@ class Input extends SuperInput {
63
64
  </div>`;
64
65
  }
65
66
 
66
- reset() {
67
+ reset(): void {
67
68
  this._input.value = this.default;
68
69
  this.value = this.default;
69
70
  }
@@ -1,8 +1,8 @@
1
1
  import { godown } from "@godown/element/decorators/godown.js";
2
2
  import { styles } from "@godown/element/decorators/styles.js";
3
- import { classList } from "@godown/element/directives/class-list.js";
3
+ import { attr } from "@godown/element/directives/attr.js";
4
4
  import { htmlSlot } from "@godown/element/directives/html-slot.js";
5
- import { css, html } from "lit";
5
+ import { css, html, type TemplateResult } from "lit";
6
6
  import { property } from "lit/decorators.js";
7
7
 
8
8
  import { GlobalStyle } from "../core/global-style.js";
@@ -20,13 +20,18 @@ const protoName = "layout";
20
20
  @godown(protoName)
21
21
  @styles(
22
22
  css`
23
- :host {
23
+ :host,
24
+ :host([contents]) [part=root] {
24
25
  min-height: 100%;
25
26
  display: flex;
26
27
  flex-direction: column;
27
28
  }
28
29
 
29
- .sticky {
30
+ [part=root] {
31
+ display: contents;
32
+ }
33
+
34
+ [sticky] header {
30
35
  position: sticky;
31
36
  top: 0;
32
37
  z-index: 1;
@@ -64,10 +69,11 @@ class NavLayout extends GlobalStyle {
64
69
  @property({ type: Boolean })
65
70
  sticky = false;
66
71
 
67
- protected render() {
68
- return html`${
72
+ protected render(): TemplateResult<1> {
73
+ return html`<div part="root" ${attr(this.observedRecord)}>
74
+ ${
69
75
  !this.noHeader
70
- ? html`<header part="header" class="${classList({ sticky: this.sticky })}">${htmlSlot("header")}</header>`
76
+ ? html`<header part="header">${htmlSlot("header")}</header>`
71
77
  : ""
72
78
  }
73
79
  <main part="main">${htmlSlot()}</main>
@@ -75,7 +81,8 @@ class NavLayout extends GlobalStyle {
75
81
  !this.noFooter
76
82
  ? html`<footer part="footer">${htmlSlot("footer")}</footer>`
77
83
  : ""
78
- }`;
84
+ }
85
+ </div>`;
79
86
  }
80
87
  }
81
88
 
@@ -26,7 +26,7 @@ class Link extends SuperAnchor {
26
26
  @property()
27
27
  type: "push" | "replace" | "normal" = "normal";
28
28
 
29
- protected _handleClick(e: MouseEvent) {
29
+ protected _handleClick(e: MouseEvent): void {
30
30
  if (this.type === "push" || this.type === "replace") {
31
31
  e.preventDefault();
32
32
  (history[`${this.type}State`])(null, "", this.href);
@@ -1,7 +1,8 @@
1
1
  import { godown } from "@godown/element/decorators/godown.js";
2
2
  import { styles } from "@godown/element/decorators/styles.js";
3
+ import { attr } from "@godown/element/directives/attr.js";
3
4
  import { isNil } from "@godown/element/tools/lib.js";
4
- import { css, html } from "lit";
5
+ import { css, html, type TemplateResult } from "lit";
5
6
  import { property } from "lit/decorators.js";
6
7
 
7
8
  import { cssGlobalVars, GlobalStyle } from "../core/global-style.js";
@@ -18,12 +19,16 @@ const protoName = "progress";
18
19
  :host {
19
20
  width: 100%;
20
21
  height: 0.5em;
21
- display: inline-block;
22
22
  border-radius: 0.25em;
23
23
  background: var(${cssGlobalVars.passive});
24
24
  color: var(${cssGlobalVars.active});
25
25
  }
26
26
 
27
+ :host,
28
+ [part=root] {
29
+ display: block;
30
+ }
31
+
27
32
  [part=root] {
28
33
  height: inherit;
29
34
  z-index: 1;
@@ -66,14 +71,14 @@ class Progress extends GlobalStyle {
66
71
  @property({ type: Number })
67
72
  value: number;
68
73
 
69
- protected render() {
74
+ protected render(): TemplateResult<1> {
70
75
  let width = 20;
71
76
  let className: string;
72
77
  if (!isNil(this.value)) {
73
78
  width = this.parsePercent(this.value);
74
79
  className = "static";
75
80
  }
76
- return html`<div part="root" class="${className}">
81
+ return html`<div part="root" ${attr(this.observedRecord)} class="${className}">
77
82
  <i part="value" style="width:${width}%;"></i>
78
83
  </div>`;
79
84
  }
@@ -1,10 +1,11 @@
1
1
  import { godown } from "@godown/element/decorators/godown.js";
2
2
  import { part } from "@godown/element/decorators/part.js";
3
3
  import { styles } from "@godown/element/decorators/styles.js";
4
+ import { attr } from "@godown/element/directives/attr.js";
4
5
  import { classList } from "@godown/element/directives/class-list.js";
5
6
  import { joinProperties } from "@godown/element/tools/css.js";
6
7
  import { isNil } from "@godown/element/tools/lib.js";
7
- import { css, html } from "lit";
8
+ import { css, html, type TemplateResult } from "lit";
8
9
  import { property, queryAll, state } from "lit/decorators.js";
9
10
 
10
11
  import { cssGlobalVars, scopePrefix } from "../core/global-style.js";
@@ -30,7 +31,7 @@ const cssScope = scopePrefix(protoName);
30
31
  ${cssScope}-track-width: .5em;
31
32
  background: var(${cssGlobalVars.input}-background);
32
33
  width: var(${cssGlobalVars.input}-width);
33
- display: inline-block;
34
+ display: block;
34
35
  margin: 0.25em 0;
35
36
  }
36
37
 
@@ -46,7 +47,7 @@ const cssScope = scopePrefix(protoName);
46
47
  }
47
48
 
48
49
  [part=root] {
49
- min-height:inherit;
50
+ min-height: inherit;
50
51
  position: relative;
51
52
  border-radius: inherit;
52
53
  width: 100%;
@@ -85,16 +86,16 @@ const cssScope = scopePrefix(protoName);
85
86
  }
86
87
  `,
87
88
  css`
88
- .vertical {
89
- height: 100%;
89
+ [vertical] {
90
+ height: inherit;
90
91
  width: var(${cssScope}-track-width);
91
92
  }
92
93
 
93
- .vertical i {
94
+ [vertical] i {
94
95
  transform: translate(-25%, -50%);
95
96
  }
96
97
 
97
- .vertical [part=track] {
98
+ [vertical] [part=track] {
98
99
  width: 100%;
99
100
  height: max(calc(var(--to) - var(--from)), calc(var(--from) - var(--to)));
100
101
  top: min(var(--from), var(--to));
@@ -107,7 +108,7 @@ const cssScope = scopePrefix(protoName);
107
108
  top: 0;
108
109
  }
109
110
 
110
- .vertical [part=handle] {
111
+ [vertical] [part=handle] {
111
112
  top: var(--handle);
112
113
  left: 0;
113
114
  }
@@ -164,7 +165,7 @@ class Range extends SuperInput {
164
165
  /**
165
166
  * Returns true when the second number is greater than the first number.
166
167
  */
167
- get reverse() {
168
+ get reverse(): boolean {
168
169
  return this.range ? this.value[0] > this.value[1] : false;
169
170
  }
170
171
 
@@ -196,7 +197,7 @@ class Range extends SuperInput {
196
197
  return rangeValue;
197
198
  }
198
199
 
199
- protected render() {
200
+ protected render(): TemplateResult<1> {
200
201
  const rangeValue = this.padValue(2);
201
202
  const from = Math.min(...rangeValue);
202
203
  const to = Math.max(...rangeValue);
@@ -204,13 +205,7 @@ class Range extends SuperInput {
204
205
 
205
206
  return html`<div
206
207
  part="root"
207
- class="${
208
- classList({
209
- vertical: this.vertical,
210
- range: this.range,
211
- reverse: this.reverse,
212
- })
213
- }"
208
+ ${attr(this.observedRecord)}
214
209
  @mousedown="${this.disabled ? null : this._handleMousedownRoot}"
215
210
  style="${
216
211
  joinProperties({
@@ -234,7 +229,7 @@ class Range extends SuperInput {
234
229
  </div>`;
235
230
  }
236
231
 
237
- protected renderHandle(index: number) {
232
+ protected renderHandle(index: number): TemplateResult<1> {
238
233
  const { range } = this;
239
234
  const end = !range || index === (this.value as number[]).length - 1;
240
235
  return html`<i
@@ -253,7 +248,7 @@ class Range extends SuperInput {
253
248
 
254
249
  private _keydownEvent: EventListenerOrEventListenerObject;
255
250
 
256
- focusHandle(index: number) {
251
+ focusHandle(index: number): void {
257
252
  this.lastFocus = index;
258
253
  const handleItem = this._handles.item(index);
259
254
  handleItem?.focus();
@@ -262,7 +257,7 @@ class Range extends SuperInput {
262
257
  }
263
258
  }
264
259
 
265
- blurHandle() {
260
+ blurHandle(): void {
266
261
  this.lastFocus = undefined;
267
262
  this._keydownEvent = this.events.remove(document, "keydown", this._keydownEvent);
268
263
  }
@@ -271,7 +266,7 @@ class Range extends SuperInput {
271
266
  if (!this.range) {
272
267
  index = 0;
273
268
  }
274
- return (e: KeyboardEvent) => {
269
+ return (e: KeyboardEvent): void => {
275
270
  if (e.key === "ArrowLeft" || e.key === "ArrowDown") {
276
271
  e.preventDefault();
277
272
  this.createSetValue(index)(old => old - this.step);
@@ -283,20 +278,20 @@ class Range extends SuperInput {
283
278
  }
284
279
 
285
280
  createMouseDown(index: number) {
286
- return (e: MouseEvent) => {
281
+ return (e: MouseEvent): void => {
287
282
  this.focusHandle(index);
288
283
  this.createMousedownListener(this.createSetValue(index))(e);
289
284
  };
290
285
  }
291
286
 
292
- protected _handleMousedownEnd(e: MouseEvent) {
287
+ protected _handleMousedownEnd(e: MouseEvent): void {
293
288
  this.lastFocus = 0;
294
289
  this.createMousedownListener(this.setEnd)(e);
295
290
  this.focusHandle(0);
296
291
  }
297
292
 
298
293
  createSetValue(index: number) {
299
- return (numberOrModifier: number | ((value: number) => number)) => {
294
+ return (numberOrModifier: number | ((value: number) => number)): void => {
300
295
  const number = typeof numberOrModifier === "number"
301
296
  ? this.normalizeValue(numberOrModifier)
302
297
  : numberOrModifier(this.rangeValue[index]);
@@ -309,14 +304,14 @@ class Range extends SuperInput {
309
304
  };
310
305
  }
311
306
 
312
- setEnd(value: number) {
307
+ setEnd(value: number): void {
313
308
  this.createSetValue((this.value as any)?.length - 1 || 0)(value);
314
309
  }
315
310
 
316
311
  /**
317
312
  * Compute value from event.
318
313
  */
319
- protected _computeValue(e: MouseEvent) {
314
+ protected _computeValue(e: MouseEvent): number {
320
315
  const rect = this._root.getBoundingClientRect();
321
316
  const div = this.vertical ? (e.clientY - rect.top) / rect.height : (e.clientX - rect.left) / rect.width;
322
317
  const value = Math.round((div * (this.max - this.min)) / this.step) * this.step;
@@ -326,13 +321,13 @@ class Range extends SuperInput {
326
321
  /**
327
322
  * Ensure that the values do not exceed the range of max and min.
328
323
  */
329
- protected normalizeValue(value: number) {
324
+ protected normalizeValue(value: number): number {
330
325
  if (value > this.max) { value -= this.step; }
331
326
  else if (value < this.min) { value += this.step; }
332
327
  return value;
333
328
  }
334
329
 
335
- protected _handleMousedownRoot(e: MouseEvent) {
330
+ protected _handleMousedownRoot(e: MouseEvent): void {
336
331
  const value = this._computeValue(e);
337
332
  const index = this.range
338
333
  ? this.rangeValue.reduce((acc, item, index) => {
@@ -349,7 +344,7 @@ class Range extends SuperInput {
349
344
  }
350
345
 
351
346
  protected createMousedownListener(mouseMoveCallback: (arg0: number) => void) {
352
- return (e: MouseEvent) => {
347
+ return (e: MouseEvent): void => {
353
348
  e.preventDefault();
354
349
  e.stopPropagation();
355
350
  const move = this.createMousemoveListener(mouseMoveCallback);
@@ -363,7 +358,7 @@ class Range extends SuperInput {
363
358
  }
364
359
 
365
360
  protected createMousemoveListener(callback: (arg0: number) => void) {
366
- return (e: MouseEvent) => {
361
+ return (e: MouseEvent): void => {
367
362
  const value = this._computeValue(e);
368
363
  if (value > this.max || value < this.min) {
369
364
  return;
@@ -372,7 +367,7 @@ class Range extends SuperInput {
372
367
  };
373
368
  }
374
369
 
375
- protected _connectedInit() {
370
+ protected _connectedInit(): void {
376
371
  const gap = this.max - this.min;
377
372
  this.step ||= gap / 100;
378
373
  if (isNil(this.value)) {
@@ -385,15 +380,15 @@ class Range extends SuperInput {
385
380
  this.default ??= this.value;
386
381
  }
387
382
 
388
- reset() {
383
+ reset(): void {
389
384
  this.value = this.default;
390
385
  }
391
386
 
392
- sort() {
387
+ sort(): number | number[] {
393
388
  return this.value = this.toSorted();
394
389
  }
395
390
 
396
- toSorted() {
391
+ toSorted(): number | number[] {
397
392
  if (this.range) {
398
393
  return [...this.value as number[]].sort((a, b) => a - b);
399
394
  }
@@ -2,7 +2,7 @@ import { godown } from "@godown/element/decorators/godown.js";
2
2
  import { part } from "@godown/element/decorators/part.js";
3
3
  import { styles } from "@godown/element/decorators/styles.js";
4
4
  import { htmlSlot } from "@godown/element/directives/html-slot.js";
5
- import { css, html } from "lit";
5
+ import { css, html, type TemplateResult } from "lit";
6
6
 
7
7
  import { GlobalStyle, scopePrefix } from "../core/global-style.js";
8
8
 
@@ -42,7 +42,7 @@ const cssScope = scopePrefix(protoName);
42
42
  margin: calc(-1 * var(${cssScope}--offset));
43
43
  }
44
44
 
45
- [part=slot]{
45
+ [part=slot] {
46
46
  z-index: 2;
47
47
  }
48
48
  `,
@@ -51,19 +51,19 @@ class Rotate extends GlobalStyle {
51
51
  @part("root")
52
52
  protected _root: HTMLElement;
53
53
 
54
- protected render() {
54
+ protected render(): TemplateResult<1> {
55
55
  return html`<div part="root">
56
56
  <div part="slot" @mousemove="${this._handleRotate}">${htmlSlot()}</div>
57
57
  <i @mouseleave="${this.reset}"></i>
58
58
  </div>`;
59
59
  }
60
60
 
61
- reset() {
61
+ reset(): void {
62
62
  this._root.style.removeProperty("transform");
63
63
  this._root.style.removeProperty("transition");
64
64
  }
65
65
 
66
- protected _handleRotate(e: MouseEvent) {
66
+ protected _handleRotate(e: MouseEvent): void {
67
67
  const { rotateX, rotateY } = this._computeOffset(e);
68
68
  this._root.style.setProperty("transform", `rotateX(${rotateX}rad) rotateY(${rotateY}rad)`);
69
69
  this._root.style.setProperty("transition", "0s");
@@ -77,7 +77,10 @@ class Rotate extends GlobalStyle {
77
77
  * @param e Mouse move event.
78
78
  * @returns rotateX, rotateY
79
79
  */
80
- _computeOffset(e: MouseEvent) {
80
+ _computeOffset(e: MouseEvent): {
81
+ rotateX: number;
82
+ rotateY: number;
83
+ } {
81
84
  const { left, top, width, height } = this._root.getBoundingClientRect();
82
85
  const { clientX, clientY } = e;
83
86
  const offsetX = clientX - left;