godown 3.0.0-canary.13 → 3.0.0-canary.15

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 (284) hide show
  1. package/README.md +1 -1
  2. package/alert.js +1 -5
  3. package/alert.js.map +1 -1
  4. package/avatar.js +1 -5
  5. package/avatar.js.map +1 -1
  6. package/breath.js +1 -5
  7. package/breath.js.map +1 -1
  8. package/button.js +1 -5
  9. package/button.js.map +1 -1
  10. package/card.js +1 -5
  11. package/card.js.map +1 -1
  12. package/carousel.js +1 -5
  13. package/carousel.js.map +1 -1
  14. package/components/alert.js +1 -174
  15. package/components/alert.js.map +1 -1
  16. package/components/avatar.js +1 -68
  17. package/components/avatar.js.map +1 -1
  18. package/components/breath.d.ts +2 -2
  19. package/components/breath.d.ts.map +1 -1
  20. package/components/breath.js +1 -81
  21. package/components/breath.js.map +1 -1
  22. package/components/button.d.ts +1 -1
  23. package/components/button.d.ts.map +1 -1
  24. package/components/button.js +1 -185
  25. package/components/button.js.map +1 -1
  26. package/components/card.d.ts.map +1 -1
  27. package/components/card.js +1 -49
  28. package/components/card.js.map +1 -1
  29. package/components/carousel.js +1 -119
  30. package/components/carousel.js.map +1 -1
  31. package/components/details.d.ts +0 -1
  32. package/components/details.d.ts.map +1 -1
  33. package/components/details.js +1 -53
  34. package/components/details.js.map +1 -1
  35. package/components/dialog.d.ts +1 -1
  36. package/components/dialog.d.ts.map +1 -1
  37. package/components/dialog.js +1 -98
  38. package/components/dialog.js.map +1 -1
  39. package/components/divider.js +1 -35
  40. package/components/divider.js.map +1 -1
  41. package/components/dragbox.d.ts +1 -1
  42. package/components/dragbox.d.ts.map +1 -1
  43. package/components/dragbox.js +1 -111
  44. package/components/dragbox.js.map +1 -1
  45. package/components/flex.d.ts.map +1 -1
  46. package/components/flex.js +1 -63
  47. package/components/flex.js.map +1 -1
  48. package/components/form.js +1 -75
  49. package/components/form.js.map +1 -1
  50. package/components/grid.d.ts.map +1 -1
  51. package/components/grid.js +1 -57
  52. package/components/grid.js.map +1 -1
  53. package/components/input.js +1 -51
  54. package/components/input.js.map +1 -1
  55. package/components/layout.d.ts.map +1 -1
  56. package/components/layout.js +1 -58
  57. package/components/layout.js.map +1 -1
  58. package/components/link.js +1 -53
  59. package/components/link.js.map +1 -1
  60. package/components/progress.d.ts.map +1 -1
  61. package/components/progress.js +1 -59
  62. package/components/progress.js.map +1 -1
  63. package/components/range.d.ts +1 -0
  64. package/components/range.d.ts.map +1 -1
  65. package/components/range.js +1 -267
  66. package/components/range.js.map +1 -1
  67. package/components/rotate.js +1 -56
  68. package/components/rotate.js.map +1 -1
  69. package/components/router.d.ts +3 -5
  70. package/components/router.d.ts.map +1 -1
  71. package/components/router.js +1 -247
  72. package/components/router.js.map +1 -1
  73. package/components/select.d.ts +1 -1
  74. package/components/select.d.ts.map +1 -1
  75. package/components/select.js +1 -217
  76. package/components/select.js.map +1 -1
  77. package/components/skeleton.js +1 -55
  78. package/components/skeleton.js.map +1 -1
  79. package/components/split.d.ts.map +1 -1
  80. package/components/split.js +1 -154
  81. package/components/split.js.map +1 -1
  82. package/components/switch.js +1 -93
  83. package/components/switch.js.map +1 -1
  84. package/components/text.d.ts.map +1 -1
  85. package/components/text.js +1 -46
  86. package/components/text.js.map +1 -1
  87. package/components/time.d.ts +1 -1
  88. package/components/time.d.ts.map +1 -1
  89. package/components/time.js +1 -78
  90. package/components/time.js.map +1 -1
  91. package/components/tooltip.d.ts.map +1 -1
  92. package/components/tooltip.js +1 -85
  93. package/components/tooltip.js.map +1 -1
  94. package/components/typewriter.d.ts +1 -1
  95. package/components/typewriter.d.ts.map +1 -1
  96. package/components/typewriter.js +1 -128
  97. package/components/typewriter.js.map +1 -1
  98. package/core/global-style.d.ts +1 -1
  99. package/core/global-style.d.ts.map +1 -1
  100. package/core/global-style.js +1 -52
  101. package/core/global-style.js.map +1 -1
  102. package/core/super-anchor.d.ts.map +1 -1
  103. package/core/super-anchor.js +1 -39
  104. package/core/super-anchor.js.map +1 -1
  105. package/core/super-input.d.ts +1 -1
  106. package/core/super-input.d.ts.map +1 -1
  107. package/core/super-input.js +1 -117
  108. package/core/super-input.js.map +1 -1
  109. package/core/super-openable.d.ts +1 -1
  110. package/core/super-openable.d.ts.map +1 -1
  111. package/core/super-openable.js +1 -37
  112. package/core/super-openable.js.map +1 -1
  113. package/custom-elements.json +1 -1
  114. package/details.js +1 -5
  115. package/details.js.map +1 -1
  116. package/dev/components/alert.d.ts.map +1 -1
  117. package/dev/components/alert.js +5 -7
  118. package/dev/components/alert.js.map +1 -1
  119. package/dev/components/avatar.d.ts.map +1 -1
  120. package/dev/components/avatar.js +3 -5
  121. package/dev/components/avatar.js.map +1 -1
  122. package/dev/components/breath.d.ts +2 -2
  123. package/dev/components/breath.d.ts.map +1 -1
  124. package/dev/components/breath.js +13 -20
  125. package/dev/components/breath.js.map +1 -1
  126. package/dev/components/button.d.ts +1 -1
  127. package/dev/components/button.d.ts.map +1 -1
  128. package/dev/components/button.js +1 -1
  129. package/dev/components/button.js.map +1 -1
  130. package/dev/components/card.d.ts.map +1 -1
  131. package/dev/components/card.js +1 -5
  132. package/dev/components/card.js.map +1 -1
  133. package/dev/components/carousel.d.ts.map +1 -1
  134. package/dev/components/carousel.js +4 -10
  135. package/dev/components/carousel.js.map +1 -1
  136. package/dev/components/details.d.ts +0 -1
  137. package/dev/components/details.d.ts.map +1 -1
  138. package/dev/components/details.js +14 -23
  139. package/dev/components/details.js.map +1 -1
  140. package/dev/components/dialog.d.ts +1 -1
  141. package/dev/components/dialog.d.ts.map +1 -1
  142. package/dev/components/divider.js +22 -22
  143. package/dev/components/divider.js.map +1 -1
  144. package/dev/components/dragbox.d.ts +1 -1
  145. package/dev/components/dragbox.d.ts.map +1 -1
  146. package/dev/components/dragbox.js +2 -1
  147. package/dev/components/dragbox.js.map +1 -1
  148. package/dev/components/flex.d.ts.map +1 -1
  149. package/dev/components/flex.js +1 -1
  150. package/dev/components/flex.js.map +1 -1
  151. package/dev/components/grid.d.ts.map +1 -1
  152. package/dev/components/grid.js +2 -2
  153. package/dev/components/grid.js.map +1 -1
  154. package/dev/components/input.js +12 -12
  155. package/dev/components/input.js.map +1 -1
  156. package/dev/components/layout.d.ts.map +1 -1
  157. package/dev/components/layout.js +3 -7
  158. package/dev/components/layout.js.map +1 -1
  159. package/dev/components/progress.d.ts.map +1 -1
  160. package/dev/components/progress.js +38 -38
  161. package/dev/components/progress.js.map +1 -1
  162. package/dev/components/range.d.ts +1 -0
  163. package/dev/components/range.d.ts.map +1 -1
  164. package/dev/components/range.js +14 -12
  165. package/dev/components/range.js.map +1 -1
  166. package/dev/components/router.d.ts +3 -5
  167. package/dev/components/router.d.ts.map +1 -1
  168. package/dev/components/router.js +10 -18
  169. package/dev/components/router.js.map +1 -1
  170. package/dev/components/select.d.ts +1 -1
  171. package/dev/components/select.d.ts.map +1 -1
  172. package/dev/components/select.js +23 -21
  173. package/dev/components/select.js.map +1 -1
  174. package/dev/components/skeleton.d.ts.map +1 -1
  175. package/dev/components/skeleton.js +3 -2
  176. package/dev/components/skeleton.js.map +1 -1
  177. package/dev/components/split.d.ts.map +1 -1
  178. package/dev/components/split.js +7 -6
  179. package/dev/components/split.js.map +1 -1
  180. package/dev/components/switch.d.ts.map +1 -1
  181. package/dev/components/switch.js +6 -9
  182. package/dev/components/switch.js.map +1 -1
  183. package/dev/components/text.d.ts.map +1 -1
  184. package/dev/components/text.js +2 -6
  185. package/dev/components/text.js.map +1 -1
  186. package/dev/components/time.d.ts +1 -1
  187. package/dev/components/time.d.ts.map +1 -1
  188. package/dev/components/time.js +1 -3
  189. package/dev/components/time.js.map +1 -1
  190. package/dev/components/tooltip.d.ts.map +1 -1
  191. package/dev/components/tooltip.js +8 -11
  192. package/dev/components/tooltip.js.map +1 -1
  193. package/dev/components/typewriter.d.ts +1 -1
  194. package/dev/components/typewriter.d.ts.map +1 -1
  195. package/dev/components/typewriter.js.map +1 -1
  196. package/dev/core/global-style.d.ts +1 -1
  197. package/dev/core/global-style.d.ts.map +1 -1
  198. package/dev/core/global-style.js +1 -1
  199. package/dev/core/global-style.js.map +1 -1
  200. package/dev/core/super-anchor.d.ts.map +1 -1
  201. package/dev/core/super-anchor.js +20 -18
  202. package/dev/core/super-anchor.js.map +1 -1
  203. package/dev/core/super-input.d.ts +1 -1
  204. package/dev/core/super-input.d.ts.map +1 -1
  205. package/dev/core/super-input.js +34 -34
  206. package/dev/core/super-input.js.map +1 -1
  207. package/dev/core/super-openable.d.ts +1 -1
  208. package/dev/core/super-openable.d.ts.map +1 -1
  209. package/dialog.js +1 -5
  210. package/dialog.js.map +1 -1
  211. package/divider.js +1 -5
  212. package/divider.js.map +1 -1
  213. package/dragbox.js +1 -5
  214. package/dragbox.js.map +1 -1
  215. package/flex.js +1 -5
  216. package/flex.js.map +1 -1
  217. package/form.js +1 -5
  218. package/form.js.map +1 -1
  219. package/grid.js +1 -5
  220. package/grid.js.map +1 -1
  221. package/index.js +1 -56
  222. package/index.js.map +1 -1
  223. package/input.js +1 -5
  224. package/input.js.map +1 -1
  225. package/layout.js +1 -5
  226. package/layout.js.map +1 -1
  227. package/link.js +1 -5
  228. package/link.js.map +1 -1
  229. package/package.json +3 -3
  230. package/progress.js +1 -5
  231. package/progress.js.map +1 -1
  232. package/range.js +1 -5
  233. package/range.js.map +1 -1
  234. package/rotate.js +1 -5
  235. package/rotate.js.map +1 -1
  236. package/router.js +1 -5
  237. package/router.js.map +1 -1
  238. package/select.js +1 -5
  239. package/select.js.map +1 -1
  240. package/skeleton.js +1 -5
  241. package/skeleton.js.map +1 -1
  242. package/split.js +1 -5
  243. package/split.js.map +1 -1
  244. package/src/components/alert.ts +5 -7
  245. package/src/components/avatar.ts +3 -5
  246. package/src/components/breath.ts +17 -22
  247. package/src/components/button.ts +2 -2
  248. package/src/components/card.ts +1 -5
  249. package/src/components/carousel.ts +4 -10
  250. package/src/components/details.ts +14 -23
  251. package/src/components/dialog.ts +1 -1
  252. package/src/components/divider.ts +25 -25
  253. package/src/components/dragbox.ts +3 -2
  254. package/src/components/flex.ts +4 -2
  255. package/src/components/grid.ts +5 -3
  256. package/src/components/input.ts +12 -12
  257. package/src/components/layout.ts +3 -11
  258. package/src/components/progress.ts +41 -39
  259. package/src/components/range.ts +15 -14
  260. package/src/components/router.ts +14 -14
  261. package/src/components/select.ts +24 -22
  262. package/src/components/skeleton.ts +3 -2
  263. package/src/components/split.ts +12 -8
  264. package/src/components/switch.ts +6 -9
  265. package/src/components/text.ts +5 -7
  266. package/src/components/time.ts +2 -4
  267. package/src/components/tooltip.ts +8 -13
  268. package/src/components/typewriter.ts +5 -3
  269. package/src/core/global-style.ts +2 -2
  270. package/src/core/super-anchor.ts +23 -19
  271. package/src/core/super-input.ts +35 -35
  272. package/src/core/super-openable.ts +1 -1
  273. package/switch.js +1 -5
  274. package/switch.js.map +1 -1
  275. package/text.js +1 -5
  276. package/text.js.map +1 -1
  277. package/time.js +1 -5
  278. package/time.js.map +1 -1
  279. package/tooltip.js +1 -5
  280. package/tooltip.js.map +1 -1
  281. package/typewriter.js +1 -5
  282. package/typewriter.js.map +1 -1
  283. package/vscode.html-custom-data.json +1 -1
  284. package/web-types.json +1 -1
@@ -15,31 +15,31 @@ const protoName = "divider";
15
15
  @godown(protoName)
16
16
  @styles(
17
17
  css`
18
- :host {
19
- width: 100%;
20
- height: .05em;
21
- margin: auto;
22
- display: block;
23
- background: currentColor;
24
- }
25
-
26
- :host([vertical]) {
27
- width: .05em;
28
- height: max(1em, 100%);
29
- }
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
- `,
18
+ :host {
19
+ width: 100%;
20
+ height: .05em;
21
+ margin: auto;
22
+ display: block;
23
+ background: currentColor;
24
+ }
25
+
26
+ :host([vertical]) {
27
+ width: .05em;
28
+ height: max(1em, 100%);
29
+ }
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
+ `,
43
43
  )
44
44
  class Divider extends GlobalStyle {
45
45
  /**
@@ -2,7 +2,7 @@ import { godown } from "@godown/element/decorators/godown.js";
2
2
  import { styles } from "@godown/element/decorators/styles.js";
3
3
  import { attr } from "@godown/element/directives/attr.js";
4
4
  import { htmlSlot } from "@godown/element/directives/html-slot.js";
5
- import { EventListenerFunc } from "@godown/element/tools/events.js";
5
+ import type { EventListenerFunc } from "@godown/element/tools/events.js";
6
6
  import { css, html, type TemplateResult } from "lit";
7
7
  import { property } from "lit/decorators.js";
8
8
 
@@ -67,7 +67,8 @@ class Dragbox extends GlobalStyle {
67
67
  part="root"
68
68
  ${attr(this.observedRecord)}
69
69
  @mousedown="${this._handleDragStart}"
70
- @mouseup="${this._handleDragEnd}">
70
+ @mouseup="${this._handleDragEnd}"
71
+ >
71
72
  ${htmlSlot()}
72
73
  </div>`;
73
74
  }
@@ -18,7 +18,8 @@ const protoName = "flex";
18
18
  * @category layout
19
19
  */
20
20
  @godown(protoName)
21
- @styles(css`
21
+ @styles(
22
+ css`
22
23
  :host,
23
24
  :host([contents]) [part=root] {
24
25
  display: flex;
@@ -27,7 +28,8 @@ const protoName = "flex";
27
28
  [part=root] {
28
29
  display: contents;
29
30
  }
30
- `)
31
+ `,
32
+ )
31
33
  class Flex extends GlobalStyle {
32
34
  /**
33
35
  * CSS property `flex-flow` (`flex-direction flex-wrap`).
@@ -19,7 +19,8 @@ const protoName = "grid";
19
19
  * @category layout
20
20
  */
21
21
  @godown(protoName)
22
- @styles(css`
22
+ @styles(
23
+ css`
23
24
  :host,
24
25
  :host([contents]) [part=root] {
25
26
  display: grid;
@@ -28,7 +29,8 @@ const protoName = "grid";
28
29
  [part=root] {
29
30
  display: contents;
30
31
  }
31
- `)
32
+ `,
33
+ )
32
34
  class Grid extends GlobalStyle {
33
35
  /**
34
36
  * CSS property `gap`.
@@ -66,7 +68,7 @@ class Grid extends GlobalStyle {
66
68
 
67
69
  protected render(): TemplateResult<1> {
68
70
  return html`<div part="root" ${attr(this.observedRecord)}>
69
- ${[
71
+ ${[
70
72
  htmlSlot(),
71
73
  htmlStyle(
72
74
  joinRules({
@@ -45,20 +45,20 @@ class Input extends SuperInput {
45
45
 
46
46
  protected render(): TemplateResult<1> {
47
47
  return html`<div part="root" ${attr(this.observedRecord)} class="${classList("input-field", this.variant)}">
48
- ${[
48
+ ${[
49
49
  this._renderPrefix(),
50
50
  html`<input
51
- part="input"
52
- type="${this.type}"
53
- id="${this.makeId}"
54
- .value="${this.value}"
55
- placeholder="${this.placeholder || nothing}"
56
- ?autofocus="${this.autofocus}"
57
- autocapitalize="${this.autocapitalize || nothing}"
58
- autocomplete="${this.autocomplete || nothing}"
59
- ?disabled="${this.disabled}"
60
- @input="${this._handleInput}"
61
- >`,
51
+ part="input"
52
+ type="${this.type}"
53
+ id="${this.makeId}"
54
+ .value="${this.value}"
55
+ placeholder="${this.placeholder || nothing}"
56
+ ?autofocus="${this.autofocus}"
57
+ autocapitalize="${this.autocapitalize || nothing}"
58
+ autocomplete="${this.autocomplete || nothing}"
59
+ ?disabled="${this.disabled}"
60
+ @input="${this._handleInput}"
61
+ >`,
62
62
  this._renderSuffix(),
63
63
  ]}
64
64
  </div>`;
@@ -71,17 +71,9 @@ class NavLayout extends GlobalStyle {
71
71
 
72
72
  protected render(): TemplateResult<1> {
73
73
  return html`<div part="root" ${attr(this.observedRecord)}>
74
- ${
75
- !this.noHeader
76
- ? html`<header part="header">${htmlSlot("header")}</header>`
77
- : ""
78
- }
79
- <main part="main">${htmlSlot()}</main>
80
- ${
81
- !this.noFooter
82
- ? html`<footer part="footer">${htmlSlot("footer")}</footer>`
83
- : ""
84
- }
74
+ ${!this.noHeader ? html`<header part="header">${htmlSlot("header")}</header>` : ""}
75
+ <main part="main">${htmlSlot()}</main>
76
+ ${!this.noFooter ? html`<footer part="footer">${htmlSlot("footer")}</footer>` : ""}
85
77
  </div>`;
86
78
  }
87
79
  }
@@ -15,52 +15,54 @@ const protoName = "progress";
15
15
  * @category feedback
16
16
  */
17
17
  @godown(protoName)
18
- @styles(css`
19
- :host {
20
- width: 100%;
21
- height: 0.5em;
22
- border-radius: 0.25em;
23
- background: var(${cssGlobalVars.passive});
24
- color: var(${cssGlobalVars.active});
25
- }
26
-
27
- :host,
28
- [part=root] {
29
- display: block;
30
- }
18
+ @styles(
19
+ css`
20
+ :host {
21
+ width: 100%;
22
+ height: 0.5em;
23
+ border-radius: 0.25em;
24
+ background: var(${cssGlobalVars.passive});
25
+ color: var(${cssGlobalVars.active});
26
+ }
31
27
 
32
- [part=root] {
33
- height: inherit;
34
- z-index: 1;
35
- position: relative;
36
- border-radius: inherit;
37
- }
28
+ :host,
29
+ [part=root] {
30
+ display: block;
31
+ }
38
32
 
39
- [part=value] {
40
- position: absolute;
41
- z-index: 2;
42
- top: 0;
43
- left: 0;
44
- height: 100%;
45
- border-radius: inherit;
46
- transition: all 0.3s;
47
- animation: progress 1.8s ease-in-out infinite alternate;
48
- background: currentColor;
49
- }
33
+ [part=root] {
34
+ height: inherit;
35
+ z-index: 1;
36
+ position: relative;
37
+ border-radius: inherit;
38
+ }
50
39
 
51
- @keyframes progress {
52
- from {
40
+ [part=value] {
41
+ position: absolute;
42
+ z-index: 2;
43
+ top: 0;
53
44
  left: 0;
45
+ height: 100%;
46
+ border-radius: inherit;
47
+ transition: all 0.3s;
48
+ animation: progress 1.8s ease-in-out infinite alternate;
49
+ background: currentColor;
54
50
  }
55
- to {
56
- left: 80%;
51
+
52
+ @keyframes progress {
53
+ from {
54
+ left: 0;
55
+ }
56
+ to {
57
+ left: 80%;
58
+ }
57
59
  }
58
- }
59
60
 
60
- .static [part=value] {
61
- animation: none;
62
- }
63
- `)
61
+ .static [part=value] {
62
+ animation: none;
63
+ }
64
+ `,
65
+ )
64
66
  class Progress extends GlobalStyle {
65
67
  @property({ type: Number })
66
68
  max = 1;
@@ -45,8 +45,7 @@ const cssScope = scopePrefix(protoName);
45
45
  }
46
46
 
47
47
  :host(:not([disabled])) .last-focus {
48
- z-index: 1;
49
- ${cssScope}--handle-scale:1.05;
48
+ ${cssScope}--handle-scale: 1.05;
50
49
  background: var(${cssScope}--handle-active);
51
50
  }
52
51
 
@@ -166,6 +165,8 @@ class Range extends SuperInput {
166
165
  @state()
167
166
  lastFocus?: number;
168
167
 
168
+ protected _focusStack: number[] = [];
169
+
169
170
  /**
170
171
  * Returns true when the second number is greater than the first number.
171
172
  */
@@ -217,19 +218,14 @@ class Range extends SuperInput {
217
218
  "--to": `${((to - this.min) / gap) * 100}%`,
218
219
  ...(this.range
219
220
  ? Object.fromEntries(
220
- rangeValue.map((value, index) => [
221
- `--handle-${index}`,
222
- `${((value - this.min) / gap) * 100}%`,
223
- ]),
221
+ rangeValue.map((value, index) => [`--handle-${index}`, `${((value - this.min) / gap) * 100}%`]),
224
222
  )
225
223
  : {}),
226
224
  })
227
- }"><div part="track"></div>
228
- ${
229
- this.range
230
- ? (this.value as number[]).map((_, index) => this.renderHandle(index))
231
- : this.renderHandle(0)
232
- }
225
+ }"
226
+ >
227
+ <div part="track"></div>
228
+ ${this.range ? (this.value as number[]).map((_, index) => this.renderHandle(index)) : this.renderHandle(0)}
233
229
  </div>`;
234
230
  }
235
231
 
@@ -243,9 +239,9 @@ class Range extends SuperInput {
243
239
  @mousedown="${this.disabled ? null : this.createMouseDown(index)}"
244
240
  @focus="${this.disabled ? null : () => this.focusHandle(index)}"
245
241
  @blur="${this.disabled ? null : this.blurHandle}"
246
- style="--handle:var(--${
242
+ style="z-index:${this._focusStack.indexOf(index) + 1};--handle:var(--${
247
243
  /* In single-handle mod or end, it is max value */
248
- (!range && end) ? `to` : `handle-${index}`})"
244
+ (!range && end) ? "to" : `handle-${index}`})"
249
245
  ></i>
250
246
  `;
251
247
  }
@@ -254,6 +250,11 @@ class Range extends SuperInput {
254
250
 
255
251
  focusHandle(index: number): void {
256
252
  this.lastFocus = index;
253
+ const indexOfFocusStack = this._focusStack.indexOf(index);
254
+ if (indexOfFocusStack !== -1) {
255
+ this._focusStack.splice(indexOfFocusStack, 1);
256
+ }
257
+ this._focusStack.push(index);
257
258
  const handleItem = this._handles.item(index);
258
259
  handleItem?.focus();
259
260
  if (!this._keydownEvent) {
@@ -69,13 +69,7 @@ class Router extends GlobalStyle {
69
69
  * Current pathname (equals to location.pathname).
70
70
  */
71
71
  @property()
72
- pathname = "";
73
-
74
- /**
75
- * Path prefix.
76
- */
77
- @property()
78
- baseURL = "";
72
+ pathname: string;
79
73
 
80
74
  /**
81
75
  * Rendered content when there is no match.
@@ -109,6 +103,7 @@ class Router extends GlobalStyle {
109
103
 
110
104
  get routes(): (Record<string, any> & {
111
105
  path: string;
106
+ render?: (ur: ReturnType<Router["useRouter"]>) => unknown;
112
107
  component?: unknown;
113
108
  })[] {
114
109
  return this.__routes;
@@ -202,7 +197,7 @@ class Router extends GlobalStyle {
202
197
  * Get component from {@linkcode routes} by query.
203
198
  */
204
199
  fieldComponent(query?: string): unknown {
205
- query ||= this.__fieldRouteTree.search(RouteTree.split(this.pathname)).pattern || null;
200
+ query ||= this.__fieldRouteTree.search(this.pathname)?.pattern;
206
201
  this.path = query;
207
202
 
208
203
  if (!query) {
@@ -214,26 +209,31 @@ class Router extends GlobalStyle {
214
209
  if (!route) {
215
210
  return null;
216
211
  }
212
+
213
+ if ("render" in route) {
214
+ return route.render?.(this.useRouter()) || null;
215
+ }
216
+
217
217
  return route.component;
218
218
  }
219
219
 
220
220
  /**
221
221
  * Get component from slotted elements by query.
222
222
  */
223
- slottedComponent(usedRouteTemplate?: string): TemplateResult<1> {
223
+ slottedComponent(query?: string): TemplateResult<1> {
224
224
  const slottedPaths = this._slottedNames;
225
- usedRouteTemplate ||= this.__slottedRouteTree.search(RouteTree.split(this.pathname)).pattern || null;
226
- this.path = usedRouteTemplate;
225
+ query ||= this.__slottedRouteTree.search(this.pathname)?.pattern;
226
+ this.path = query;
227
227
 
228
- if (!usedRouteTemplate) {
228
+ if (!query) {
229
229
  return null;
230
230
  }
231
231
 
232
- this.path = slottedPaths.find((s) => s === usedRouteTemplate);
232
+ this.path = slottedPaths.find((s) => s === query);
233
233
  if (!this.path) {
234
234
  return null;
235
235
  }
236
- this.params = this.parseParams(usedRouteTemplate, this.pathname);
236
+ this.params = this.parseParams(query, this.pathname);
237
237
  return htmlSlot(this.path);
238
238
  }
239
239
 
@@ -1,4 +1,4 @@
1
- import { HandlerEvent } from "@godown/element";
1
+ import type { HandlerEvent } from "@godown/element";
2
2
  import { godown } from "@godown/element/decorators/godown.js";
3
3
  import { part } from "@godown/element/decorators/part.js";
4
4
  import { styles } from "@godown/element/decorators/styles.js";
@@ -105,34 +105,36 @@ class Select extends Input {
105
105
  private _store: { value: string; text: string; }[] = [];
106
106
 
107
107
  protected render(): TemplateResult<1> {
108
- return html`<div part="root" ${
108
+ return html`<div
109
+ part="root"
110
+ ${
109
111
  attr({
110
112
  ...this.observedRecord,
111
113
  direction: this.direction || this.autoDirection,
112
114
  })
113
- } class="input-field">
114
- ${[
115
+ }
116
+ class="input-field"
117
+ >
118
+ ${[
115
119
  this._renderPrefix(),
116
120
  html`<input
117
- part="input"
118
- dir="${ifDefined(this.dir)}"
119
- id="${this.makeId}"
120
- .value="${this.text}"
121
- type="${this.type}"
122
- placeholder="${this.placeholder || nothing}"
123
- ?autofocus="${this.autofocus}"
124
- autocapitalize="${this.autocapitalize || nothing}"
125
- autocomplete="${this.autocomplete || nothing}"
126
- ?disabled="${this.disabled}"
127
- @focus="${this._handleFocus}"
128
- @input="${this._handleInput}"
129
- >`,
121
+ part="input"
122
+ dir="${ifDefined(this.dir)}"
123
+ id="${this.makeId}"
124
+ .value="${this.text}"
125
+ type="${this.type}"
126
+ placeholder="${this.placeholder || nothing}"
127
+ ?autofocus="${this.autofocus}"
128
+ autocapitalize="${this.autocapitalize || nothing}"
129
+ autocomplete="${this.autocomplete || nothing}"
130
+ ?disabled="${this.disabled}"
131
+ @focus="${this._handleFocus}"
132
+ @input="${this._handleInput}"
133
+ >`,
130
134
  html`<label for="${this.makeId}" part="suffix">
131
- <i part="icon">${svgCaretDown()}</i>
132
- </label>`,
133
- html`<label for="${this.makeId}" part="content">
134
- ${htmlSlot()}
135
- </label>`,
135
+ <i part="icon">${svgCaretDown()}</i>
136
+ </label>`,
137
+ html`<label for="${this.makeId}" part="content"> ${htmlSlot()} </label>`,
136
138
  ]}
137
139
  </div>`;
138
140
  }
@@ -111,8 +111,9 @@ class Skeleton extends GlobalStyle {
111
111
  return htmlSlot();
112
112
  }
113
113
  return html`<div part="root" ${attr(this.observedRecord)}>
114
- ${this.type === "image" ? iconPhoto() : ""}
115
- ${htmlSlot("loading")}</div>`;
114
+ ${this.type === "image" ? iconPhoto() : ""}
115
+ ${htmlSlot("loading")}
116
+ </div>`;
116
117
  }
117
118
  }
118
119
 
@@ -99,12 +99,17 @@ class Split extends SuperInput {
99
99
 
100
100
  protected render(): TemplateResult<1> {
101
101
  return html`<div part="root" ${attr(this.observedRecord)}>
102
- ${
103
- loop(this.len, (index: number) =>
104
- html`<span part="input-box"
105
- @click="${this.disabled ? null : () => this.focusAt(index)}"
106
- class="${classList({ focus: this.current === index }) || nothing}"
107
- >${this.currentValue[index]}</span>`)
102
+ ${
103
+ loop(
104
+ this.len,
105
+ (index: number) =>
106
+ html`<span
107
+ part="input-box"
108
+ @click="${this.disabled ? null : () => this.focusAt(index)}"
109
+ class="${classList({ focus: this.current === index }) || nothing}"
110
+ >${this.currentValue[index]}</span
111
+ >`,
112
+ )
108
113
  }
109
114
  <input
110
115
  part="input"
@@ -115,8 +120,7 @@ class Split extends SuperInput {
115
120
  /* Ensure that input always has a value of length this.len */
116
121
  this.value.padStart(this.len, " ")}"
117
122
  >
118
- </div>
119
- `;
123
+ </div> `;
120
124
  }
121
125
 
122
126
  connectedCallback(): void {
@@ -40,7 +40,7 @@ const cssScope = scopePrefix(protoName);
40
40
  }
41
41
 
42
42
  [part=root],
43
- span {
43
+ [part=handle] {
44
44
  transition: var(${cssScope}-transition);
45
45
  }
46
46
 
@@ -50,14 +50,14 @@ const cssScope = scopePrefix(protoName);
50
50
  height: inherit;
51
51
  }
52
52
 
53
- input {
53
+ [part=input] {
54
54
  opacity: 0;
55
55
  width: 100%;
56
56
  height: 100%;
57
57
  appearance: none;
58
58
  }
59
59
 
60
- span {
60
+ [part=handle] {
61
61
  height: 100%;
62
62
  display: inline-flex;
63
63
  align-items: center;
@@ -74,7 +74,7 @@ const cssScope = scopePrefix(protoName);
74
74
  background: var(${cssGlobalVars.passive});
75
75
  }
76
76
 
77
- :host([checked]) span {
77
+ :host([checked]) [part=handle] {
78
78
  left: 50%;
79
79
  }
80
80
 
@@ -86,7 +86,7 @@ const cssScope = scopePrefix(protoName);
86
86
  background: var(${cssGlobalVars.passive});
87
87
  }
88
88
 
89
- .round span{
89
+ .round [part=handle] {
90
90
  --size: var(${cssScope}-handle-size);
91
91
  border-radius: 100%;
92
92
  background: var(--godown--input-control);
@@ -135,10 +135,7 @@ class Switch extends SuperInput {
135
135
  protected _input: HTMLInputElement;
136
136
 
137
137
  protected render(): TemplateResult<1> {
138
- return html`<div part="root"
139
- ${attr(this.observedRecord)}
140
- class="${this.round ? "round" : "rect"}"
141
- >
138
+ return html`<div part="root" ${attr(this.observedRecord)} class="${this.round ? "round" : "rect"}">
142
139
  <input
143
140
  part="input"
144
141
  @change="${this._handleChange}"
@@ -18,7 +18,8 @@ const cssScope = scopePrefix(protoName);
18
18
  * @category display
19
19
  */
20
20
  @godown(protoName)
21
- @styles(css`
21
+ @styles(
22
+ css`
22
23
  :host {
23
24
  ${cssScope}--color: currentColor;
24
25
  ${cssScope}--color-hover: currentColor;
@@ -65,7 +66,8 @@ const cssScope = scopePrefix(protoName);
65
66
  background-clip: text;
66
67
  -webkit-background-clip: text;
67
68
  }
68
- `)
69
+ `,
70
+ )
69
71
  class Text extends GlobalStyle {
70
72
  /**
71
73
  * Underline behavior.
@@ -80,11 +82,7 @@ class Text extends GlobalStyle {
80
82
  clip = false;
81
83
 
82
84
  protected render(): TemplateResult<1> {
83
- return html`<span
84
- part="root"
85
- ${attr(this.observedRecord)}
86
- class="${classList(this.underline)}"
87
- >
85
+ return html`<span part="root" ${attr(this.observedRecord)} class="${classList(this.underline)}">
88
86
  ${htmlSlot()}
89
87
  </span>`;
90
88
  }
@@ -2,7 +2,7 @@ import { godown } from "@godown/element/decorators/godown.js";
2
2
  import { styles } from "@godown/element/decorators/styles.js";
3
3
  import { attr } from "@godown/element/directives/attr.js";
4
4
  import fmtime from "fmtime";
5
- import { css, html, type PropertyValues, TemplateResult } from "lit";
5
+ import { css, html, type PropertyValues, type TemplateResult } from "lit";
6
6
  import { property } from "lit/decorators.js";
7
7
 
8
8
  import { GlobalStyle } from "../core/global-style.js";
@@ -50,9 +50,7 @@ class Time extends GlobalStyle {
50
50
  protected timeoutId: number;
51
51
 
52
52
  protected render(): TemplateResult<1> {
53
- return html`<span part="root" ${attr(this.observedRecord)}>
54
- ${fmtime(this.format, this.time, this.escape)}
55
- </span>`;
53
+ return html`<span part="root" ${attr(this.observedRecord)}> ${fmtime(this.format, this.time, this.escape)} </span>`;
56
54
  }
57
55
 
58
56
  protected firstUpdated(): void {
@@ -126,23 +126,18 @@ class Tooltip extends SuperOpenable {
126
126
  protected render(): TemplateResult<1> {
127
127
  const align = Tooltip.aligns[this.align] || "inherit";
128
128
  const isFocusable = this.type === "focus";
129
- return html`<div
129
+ return html`<div
130
130
  part="root"
131
131
  ${attr(this.observedRecord)}
132
132
  tabindex="${isFocusable ? 0 : -1}"
133
- @focus="${isFocusable ? () => this.open = true : null}"
134
- @blur="${isFocusable ? () => this.open = false : null}"
135
- @mouseenter="${isFocusable ? null : () => this.open = true}"
136
- @mouseleave="${isFocusable ? null : () => this.open = false}"
137
- style="justify-content:${align};align-items:${align}">
133
+ @focus="${isFocusable ? () => (this.open = true) : null}"
134
+ @blur="${isFocusable ? () => (this.open = false) : null}"
135
+ @mouseenter="${isFocusable ? null : () => (this.open = true)}"
136
+ @mouseleave="${isFocusable ? null : () => (this.open = false)}"
137
+ style="justify-content:${align};align-items:${align}"
138
+ >
138
139
  ${htmlSlot()}
139
- <div part="tip">
140
- ${
141
- this.tip
142
- ? html`<span class="passive">${this.tip}</span>`
143
- : htmlSlot("tip")
144
- }
145
- </div>
140
+ <div part="tip">${this.tip ? html`<span class="passive">${this.tip}</span>` : htmlSlot("tip")}</div>
146
141
  </div>`;
147
142
  }
148
143
  }