godown 3.0.0-canary.14 → 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 (189) hide show
  1. package/components/alert.js +1 -1
  2. package/components/alert.js.map +1 -1
  3. package/components/avatar.js.map +1 -1
  4. package/components/breath.d.ts +2 -2
  5. package/components/breath.d.ts.map +1 -1
  6. package/components/breath.js +1 -1
  7. package/components/breath.js.map +1 -1
  8. package/components/button.d.ts +1 -1
  9. package/components/button.d.ts.map +1 -1
  10. package/components/card.d.ts.map +1 -1
  11. package/components/card.js.map +1 -1
  12. package/components/carousel.js.map +1 -1
  13. package/components/details.d.ts +0 -1
  14. package/components/details.d.ts.map +1 -1
  15. package/components/details.js +1 -1
  16. package/components/details.js.map +1 -1
  17. package/components/dialog.d.ts +1 -1
  18. package/components/dialog.d.ts.map +1 -1
  19. package/components/dragbox.d.ts +1 -1
  20. package/components/dragbox.d.ts.map +1 -1
  21. package/components/dragbox.js.map +1 -1
  22. package/components/flex.d.ts.map +1 -1
  23. package/components/flex.js.map +1 -1
  24. package/components/grid.d.ts.map +1 -1
  25. package/components/grid.js.map +1 -1
  26. package/components/input.js.map +1 -1
  27. package/components/layout.d.ts.map +1 -1
  28. package/components/layout.js.map +1 -1
  29. package/components/progress.d.ts.map +1 -1
  30. package/components/progress.js.map +1 -1
  31. package/components/range.d.ts.map +1 -1
  32. package/components/range.js.map +1 -1
  33. package/components/router.d.ts +3 -5
  34. package/components/router.d.ts.map +1 -1
  35. package/components/router.js +1 -1
  36. package/components/router.js.map +1 -1
  37. package/components/select.d.ts +1 -1
  38. package/components/select.d.ts.map +1 -1
  39. package/components/select.js.map +1 -1
  40. package/components/skeleton.js.map +1 -1
  41. package/components/split.d.ts.map +1 -1
  42. package/components/split.js.map +1 -1
  43. package/components/switch.js +1 -1
  44. package/components/switch.js.map +1 -1
  45. package/components/text.d.ts.map +1 -1
  46. package/components/text.js.map +1 -1
  47. package/components/time.d.ts +1 -1
  48. package/components/time.d.ts.map +1 -1
  49. package/components/time.js.map +1 -1
  50. package/components/tooltip.d.ts.map +1 -1
  51. package/components/tooltip.js.map +1 -1
  52. package/components/typewriter.d.ts +1 -1
  53. package/components/typewriter.d.ts.map +1 -1
  54. package/components/typewriter.js.map +1 -1
  55. package/core/global-style.d.ts +1 -1
  56. package/core/global-style.d.ts.map +1 -1
  57. package/core/global-style.js +1 -1
  58. package/core/global-style.js.map +1 -1
  59. package/core/super-anchor.d.ts.map +1 -1
  60. package/core/super-anchor.js.map +1 -1
  61. package/core/super-input.d.ts +1 -1
  62. package/core/super-input.d.ts.map +1 -1
  63. package/core/super-openable.d.ts +1 -1
  64. package/core/super-openable.d.ts.map +1 -1
  65. package/custom-elements.json +1 -1
  66. package/dev/components/alert.d.ts.map +1 -1
  67. package/dev/components/alert.js +5 -7
  68. package/dev/components/alert.js.map +1 -1
  69. package/dev/components/avatar.d.ts.map +1 -1
  70. package/dev/components/avatar.js +3 -5
  71. package/dev/components/avatar.js.map +1 -1
  72. package/dev/components/breath.d.ts +2 -2
  73. package/dev/components/breath.d.ts.map +1 -1
  74. package/dev/components/breath.js +13 -20
  75. package/dev/components/breath.js.map +1 -1
  76. package/dev/components/button.d.ts +1 -1
  77. package/dev/components/button.d.ts.map +1 -1
  78. package/dev/components/button.js +1 -1
  79. package/dev/components/button.js.map +1 -1
  80. package/dev/components/card.d.ts.map +1 -1
  81. package/dev/components/card.js +1 -5
  82. package/dev/components/card.js.map +1 -1
  83. package/dev/components/carousel.d.ts.map +1 -1
  84. package/dev/components/carousel.js +4 -10
  85. package/dev/components/carousel.js.map +1 -1
  86. package/dev/components/details.d.ts +0 -1
  87. package/dev/components/details.d.ts.map +1 -1
  88. package/dev/components/details.js +14 -23
  89. package/dev/components/details.js.map +1 -1
  90. package/dev/components/dialog.d.ts +1 -1
  91. package/dev/components/dialog.d.ts.map +1 -1
  92. package/dev/components/divider.js +22 -22
  93. package/dev/components/divider.js.map +1 -1
  94. package/dev/components/dragbox.d.ts +1 -1
  95. package/dev/components/dragbox.d.ts.map +1 -1
  96. package/dev/components/dragbox.js +2 -1
  97. package/dev/components/dragbox.js.map +1 -1
  98. package/dev/components/flex.d.ts.map +1 -1
  99. package/dev/components/flex.js +1 -1
  100. package/dev/components/flex.js.map +1 -1
  101. package/dev/components/grid.d.ts.map +1 -1
  102. package/dev/components/grid.js +2 -2
  103. package/dev/components/grid.js.map +1 -1
  104. package/dev/components/input.js +12 -12
  105. package/dev/components/input.js.map +1 -1
  106. package/dev/components/layout.d.ts.map +1 -1
  107. package/dev/components/layout.js +3 -7
  108. package/dev/components/layout.js.map +1 -1
  109. package/dev/components/progress.d.ts.map +1 -1
  110. package/dev/components/progress.js +38 -38
  111. package/dev/components/progress.js.map +1 -1
  112. package/dev/components/range.d.ts.map +1 -1
  113. package/dev/components/range.js +6 -9
  114. package/dev/components/range.js.map +1 -1
  115. package/dev/components/router.d.ts +3 -5
  116. package/dev/components/router.d.ts.map +1 -1
  117. package/dev/components/router.js +10 -18
  118. package/dev/components/router.js.map +1 -1
  119. package/dev/components/select.d.ts +1 -1
  120. package/dev/components/select.d.ts.map +1 -1
  121. package/dev/components/select.js +23 -21
  122. package/dev/components/select.js.map +1 -1
  123. package/dev/components/skeleton.d.ts.map +1 -1
  124. package/dev/components/skeleton.js +3 -2
  125. package/dev/components/skeleton.js.map +1 -1
  126. package/dev/components/split.d.ts.map +1 -1
  127. package/dev/components/split.js +7 -6
  128. package/dev/components/split.js.map +1 -1
  129. package/dev/components/switch.d.ts.map +1 -1
  130. package/dev/components/switch.js +6 -9
  131. package/dev/components/switch.js.map +1 -1
  132. package/dev/components/text.d.ts.map +1 -1
  133. package/dev/components/text.js +2 -6
  134. package/dev/components/text.js.map +1 -1
  135. package/dev/components/time.d.ts +1 -1
  136. package/dev/components/time.d.ts.map +1 -1
  137. package/dev/components/time.js +1 -3
  138. package/dev/components/time.js.map +1 -1
  139. package/dev/components/tooltip.d.ts.map +1 -1
  140. package/dev/components/tooltip.js +8 -11
  141. package/dev/components/tooltip.js.map +1 -1
  142. package/dev/components/typewriter.d.ts +1 -1
  143. package/dev/components/typewriter.d.ts.map +1 -1
  144. package/dev/components/typewriter.js.map +1 -1
  145. package/dev/core/global-style.d.ts +1 -1
  146. package/dev/core/global-style.d.ts.map +1 -1
  147. package/dev/core/global-style.js +1 -1
  148. package/dev/core/global-style.js.map +1 -1
  149. package/dev/core/super-anchor.d.ts.map +1 -1
  150. package/dev/core/super-anchor.js +20 -18
  151. package/dev/core/super-anchor.js.map +1 -1
  152. package/dev/core/super-input.d.ts +1 -1
  153. package/dev/core/super-input.d.ts.map +1 -1
  154. package/dev/core/super-input.js +34 -34
  155. package/dev/core/super-input.js.map +1 -1
  156. package/dev/core/super-openable.d.ts +1 -1
  157. package/dev/core/super-openable.d.ts.map +1 -1
  158. package/package.json +3 -3
  159. package/src/components/alert.ts +5 -7
  160. package/src/components/avatar.ts +3 -5
  161. package/src/components/breath.ts +17 -22
  162. package/src/components/button.ts +2 -2
  163. package/src/components/card.ts +1 -5
  164. package/src/components/carousel.ts +4 -10
  165. package/src/components/details.ts +14 -23
  166. package/src/components/dialog.ts +1 -1
  167. package/src/components/divider.ts +25 -25
  168. package/src/components/dragbox.ts +3 -2
  169. package/src/components/flex.ts +4 -2
  170. package/src/components/grid.ts +5 -3
  171. package/src/components/input.ts +12 -12
  172. package/src/components/layout.ts +3 -11
  173. package/src/components/progress.ts +41 -39
  174. package/src/components/range.ts +6 -11
  175. package/src/components/router.ts +14 -14
  176. package/src/components/select.ts +24 -22
  177. package/src/components/skeleton.ts +3 -2
  178. package/src/components/split.ts +12 -8
  179. package/src/components/switch.ts +6 -9
  180. package/src/components/text.ts +5 -7
  181. package/src/components/time.ts +2 -4
  182. package/src/components/tooltip.ts +8 -13
  183. package/src/components/typewriter.ts +5 -3
  184. package/src/core/global-style.ts +2 -2
  185. package/src/core/super-anchor.ts +23 -19
  186. package/src/core/super-input.ts +35 -35
  187. package/src/core/super-openable.ts +1 -1
  188. package/vscode.html-custom-data.json +1 -1
  189. package/web-types.json +1 -1
@@ -23,7 +23,7 @@ const cssScope = scopePrefix(protoName);
23
23
  @godown(protoName)
24
24
  @styles(
25
25
  css`
26
- :host{
26
+ :host {
27
27
  ${cssScope}--size: 2em;
28
28
  width: var(${cssScope}--size);
29
29
  height: var(${cssScope}--size);
@@ -82,14 +82,12 @@ class Avatar extends GlobalStyle {
82
82
  round = false;
83
83
 
84
84
  protected render(): TemplateResult<1> {
85
- return html`<div part="root" ${attr(omit(this.observedRecord, "src"))}>
86
- ${this._renderAvatar()}
87
- </div>`;
85
+ return html`<div part="root" ${attr(omit(this.observedRecord, "src"))}>${this._renderAvatar()}</div>`;
88
86
  }
89
87
 
90
88
  private _renderAvatar() {
91
89
  if (this.src) {
92
- return html`<img part="image" src="${this.src}" @error=${this._handleError} alt="${this.name}">`;
90
+ return html`<img part="image" src="${this.src}" @error=${this._handleError} alt="${this.name}" />`;
93
91
  }
94
92
  if (this.name) {
95
93
  return html`<span part="name">${this.format()}</span>`;
@@ -112,10 +112,7 @@ class Breath extends GlobalStyle {
112
112
  protected render(): TemplateResult<1> {
113
113
  const texts = this.getTexts();
114
114
  return html`<div part="root" ${attr(this.observedRecord)}>
115
- ${[
116
- texts.map(this.renderText),
117
- htmlStyle(this.computeStyle(texts.length)),
118
- ]}
115
+ ${[texts.map(this.renderText), htmlStyle(this._computeStyle(texts.length))]}
119
116
  </div>`;
120
117
  }
121
118
 
@@ -130,33 +127,31 @@ class Breath extends GlobalStyle {
130
127
  return Array.isArray(this.text) ? this.text : (this.text || this.textContent).split(/\s+/).filter((x) => x);
131
128
  }
132
129
 
133
- protected computeStyle(len: number): string {
130
+ protected _computeStyle(len: number): string {
134
131
  const gap = 100 / 2 / len;
135
132
  const duration = this.parseDuration() || len * 2 + 2;
136
-
133
+ let style1 = "";
134
+ for (let number = 1; number <= len; number++) {
135
+ const delay = -duration / len * (len - number + 1);
136
+ const defaultNumber = ((number - 1) % 3) + 1;
137
+ style1 +=
138
+ `.rel:nth-child(${number}) .colorful{animation-delay:${delay}s;background:var(${cssScope}--${number},var(${cssScope}--${defaultNumber}));}`;
139
+ }
137
140
  return (
138
- `.colorful{animation-duration:${duration}s;}`
139
- + `@keyframes colorfulN{0%,${gap * 3}%{opacity:0;}${gap}%,${gap * 2}%{opacity:1;}}`
140
- + (() => {
141
- let style1 = "";
142
- for (let number = 1; number <= len; number++) {
143
- const delay = -duration / len * (len - number + 1);
144
- const defaultNumber = ((number - 1) % 3) + 1;
145
- style1 +=
146
- `.rel:nth-child(${number}) .colorful{animation-delay:${delay}s;background:var(${cssScope}--${number},var(${cssScope}--${defaultNumber}));}`;
147
- }
148
- return style1;
149
- })()
141
+ `.colorful{animation-duration:${duration}s;}@keyframes colorfulN{0%,${gap * 3}%{opacity:0;}${gap}%,${
142
+ gap * 2
143
+ }%{opacity:1;}}${style1}`
150
144
  );
151
145
  }
152
146
 
153
- protected parseDuration(): number {
147
+ protected parseDuration(): number | undefined {
154
148
  const { duration } = this;
155
149
  if (duration) {
156
150
  if (duration.endsWith("s")) {
157
- return parseFloat(duration.slice(0, -1));
158
- } else if (duration.endsWith("ms")) {
159
- return parseFloat(duration.slice(0, -2)) / 1000;
151
+ return Number.parseFloat(duration.slice(0, -1));
152
+ }
153
+ if (duration.endsWith("ms")) {
154
+ return Number.parseFloat(duration.slice(0, -2)) / 1000;
160
155
  }
161
156
  }
162
157
  }
@@ -5,7 +5,7 @@ import { attr } from "@godown/element/directives/attr.js";
5
5
  import { htmlSlot } from "@godown/element/directives/html-slot.js";
6
6
  import { htmlStyle } from "@godown/element/directives/html-style.js";
7
7
  import { constructCSSObject, toVar } from "@godown/element/tools/css.js";
8
- import { css, html, TemplateResult } from "lit";
8
+ import { css, html, type TemplateResult } from "lit";
9
9
  import { property } from "lit/decorators.js";
10
10
 
11
11
  import { cssGlobalVars, GlobalStyle, scopePrefix } from "../core/global-style.js";
@@ -76,7 +76,7 @@ const colors: Record<Colors, string> = constructCSSObject(
76
76
  cssGlobalVars._colors.teal[4], // gradients
77
77
  ],
78
78
  },
79
- () => `:host`,
79
+ () => ":host",
80
80
  (prop) => toVar(prop),
81
81
  );
82
82
 
@@ -71,11 +71,7 @@ class Card extends GlobalStyle {
71
71
 
72
72
  protected render(): TemplateResult<1> {
73
73
  return html`<div part="root" ${attr(this.observedRecord)}>
74
- ${[
75
- this.header ? htmlSlot("header") : "",
76
- htmlSlot(),
77
- this.footer ? htmlSlot("footer") : "",
78
- ]}
74
+ ${[this.header ? htmlSlot("header") : "", htmlSlot(), this.footer ? htmlSlot("footer") : ""]}
79
75
  </div>`;
80
76
  }
81
77
  }
@@ -103,15 +103,9 @@ class Carousel extends GlobalStyle {
103
103
 
104
104
  protected render(): TemplateResult<1> {
105
105
  return html`<div part="root" ${attr(this.observedRecord)}>
106
- <i part="prev" @click="${this.prev}">
107
- ${iconChevronLeft()}
108
- </i>
109
- <div part="move-root" style="transform:${`translateX(-${this.index + 1}00%)`}">
110
- ${htmlSlot()}
111
- </div>
112
- <i part="next" @click="${this.next}">
113
- ${iconChevronRight()}
114
- </i>
106
+ <i part="prev" @click="${this.prev}"> ${iconChevronLeft()} </i>
107
+ <div part="move-root" style="transform:${`translateX(-${this.index + 1}00%)`}">${htmlSlot()}</div>
108
+ <i part="next" @click="${this.next}"> ${iconChevronRight()} </i>
115
109
  ${htmlStyle(`:host,:host([contents]) [part=root]{width:${this.width};}`)}
116
110
  </div>`;
117
111
  }
@@ -164,7 +158,7 @@ class Carousel extends GlobalStyle {
164
158
  protected _doTranslateX(xValue: string, noTransition?: boolean): void {
165
159
  this._moveRoot.style.transform = `translateX(${xValue})`;
166
160
  if (noTransition) {
167
- this._moveRoot.style.transition = `none`;
161
+ this._moveRoot.style.transition = "none";
168
162
  }
169
163
  this._moveRoot.getBoundingClientRect();
170
164
  }
@@ -4,7 +4,7 @@ import { attr } from "@godown/element/directives/attr.js";
4
4
  import { htmlSlot } from "@godown/element/directives/html-slot.js";
5
5
  import svgCaretDown from "@godown/f7-icon/icons/chevron-down.js";
6
6
  import { css, html, type TemplateResult } from "lit";
7
- import { property, query } from "lit/decorators.js";
7
+ import { property } from "lit/decorators.js";
8
8
 
9
9
  import { scopePrefix } from "../core/global-style.js";
10
10
  import SuperOpenable from "../core/super-openable.js";
@@ -27,7 +27,6 @@ const cssScope = scopePrefix(protoName);
27
27
  :host {
28
28
  ${cssScope}--icon-deg-open: 0deg;
29
29
  ${cssScope}--icon-deg-close: 90deg;
30
- ${cssScope}--icon-deg: 0deg;
31
30
  ${cssScope}--icon-space: 0.3em;
32
31
  ${cssScope}--summary-direction: row;
33
32
  ${cssScope}--transition: .3s;
@@ -36,13 +35,13 @@ const cssScope = scopePrefix(protoName);
36
35
  transition: var(${cssScope}--transition);
37
36
  }
38
37
 
39
- dl {
38
+ [part=root] {
40
39
  height: 100%;
41
40
  position: relative;
42
41
  overflow: hidden;
43
42
  }
44
43
 
45
- dt {
44
+ [part=title] {
46
45
  height: 100%;
47
46
  display: flex;
48
47
  flex-wrap: nowrap;
@@ -52,7 +51,7 @@ const cssScope = scopePrefix(protoName);
52
51
  flex-direction: var(${cssScope}--summary-direction);
53
52
  }
54
53
 
55
- dd {
54
+ [part=details] {
56
55
  display: grid;
57
56
  overflow: hidden;
58
57
  grid-template-rows: 0fr;
@@ -60,27 +59,24 @@ const cssScope = scopePrefix(protoName);
60
59
  transition-property: grid-template-rows;
61
60
  }
62
61
 
63
- i {
64
- display: flex;
65
- backface-visibility: hidden;
66
- padding: var(${cssScope}--icon-space);
67
- transition: var(${cssScope}--transition);
68
- transform: rotate(var(${cssScope}--icon-deg));
69
- }
70
-
71
- :host([open]) dd {
62
+ :host([open]) [part=details] {
72
63
  grid-template-rows: 1fr;
73
64
  }
74
65
 
75
- :host([float]) dd {
66
+ :host([float]) [part=details] {
76
67
  top: 100%;
77
68
  position: absolute;
78
69
  }
79
70
 
80
- i {
71
+ [part=icon] {
72
+ display: flex;
73
+ backface-visibility: hidden;
74
+ padding: var(${cssScope}--icon-space);
75
+ transition: var(${cssScope}--transition);
81
76
  transform: rotate(var(${cssScope}--icon-deg-close));
82
77
  }
83
- :host([open]) i {
78
+
79
+ :host([open]) [part=icon] {
84
80
  transform: rotate(var(${cssScope}--icon-deg-open));
85
81
  }
86
82
  `,
@@ -98,15 +94,10 @@ class Details extends SuperOpenable {
98
94
  @property()
99
95
  summary = "";
100
96
 
101
- @query("dd")
102
- protected _dd: HTMLDataListElement;
103
-
104
97
  protected render(): TemplateResult<1> {
105
98
  return html`<dl part="root" ${attr(this.observedRecord)}>
106
99
  <dt part="title" @click="${this._handelClick}">
107
- <span part="summary">
108
- ${this.summary || htmlSlot("summary")}
109
- </span>
100
+ <span part="summary">${this.summary || htmlSlot("summary")}</span>
110
101
  <span>
111
102
  <i part="icon">${svgCaretDown()}</i>
112
103
  </span>
@@ -1,4 +1,4 @@
1
- import { type HandlerEvent } from "@godown/element";
1
+ import type { HandlerEvent } from "@godown/element";
2
2
  import { godown } from "@godown/element/decorators/godown.js";
3
3
  import { styles } from "@godown/element/decorators/styles.js";
4
4
  import { attr } from "@godown/element/directives/attr.js";
@@ -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;
@@ -218,19 +218,14 @@ class Range extends SuperInput {
218
218
  "--to": `${((to - this.min) / gap) * 100}%`,
219
219
  ...(this.range
220
220
  ? Object.fromEntries(
221
- rangeValue.map((value, index) => [
222
- `--handle-${index}`,
223
- `${((value - this.min) / gap) * 100}%`,
224
- ]),
221
+ rangeValue.map((value, index) => [`--handle-${index}`, `${((value - this.min) / gap) * 100}%`]),
225
222
  )
226
223
  : {}),
227
224
  })
228
- }"><div part="track"></div>
229
- ${
230
- this.range
231
- ? (this.value as number[]).map((_, index) => this.renderHandle(index))
232
- : this.renderHandle(0)
233
- }
225
+ }"
226
+ >
227
+ <div part="track"></div>
228
+ ${this.range ? (this.value as number[]).map((_, index) => this.renderHandle(index)) : this.renderHandle(0)}
234
229
  </div>`;
235
230
  }
236
231
 
@@ -246,7 +241,7 @@ class Range extends SuperInput {
246
241
  @blur="${this.disabled ? null : this.blurHandle}"
247
242
  style="z-index:${this._focusStack.indexOf(index) + 1};--handle:var(--${
248
243
  /* In single-handle mod or end, it is max value */
249
- (!range && end) ? `to` : `handle-${index}`})"
244
+ (!range && end) ? "to" : `handle-${index}`})"
250
245
  ></i>
251
246
  `;
252
247
  }
@@ -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