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
@@ -33,8 +33,8 @@ const protoName = "router";
33
33
  */
34
34
  @godown(protoName)
35
35
  @styles(css`:host{display:contents;}`)
36
- class Router<C = unknown> extends GlobalStyle {
37
- static routerInstances = new Set<Router>();
36
+ class Router extends GlobalStyle {
37
+ static routerInstances: Set<Router> = new Set<Router>();
38
38
 
39
39
  private __fieldRouteTree: RouteTree = new RouteTree();
40
40
  private __slottedRouteTree: RouteTree = new RouteTree();
@@ -43,7 +43,7 @@ class Router<C = unknown> extends GlobalStyle {
43
43
  & Record<string, any>
44
44
  & {
45
45
  path: string;
46
- component?: C;
46
+ component?: unknown;
47
47
  }
48
48
  )[];
49
49
 
@@ -51,7 +51,7 @@ class Router<C = unknown> extends GlobalStyle {
51
51
  * Render result.
52
52
  */
53
53
  @state()
54
- component: C | TemplateResult = null;
54
+ component: unknown | TemplateResult = null;
55
55
 
56
56
  /**
57
57
  * Dynamic parameters record.
@@ -107,15 +107,18 @@ class Router<C = unknown> extends GlobalStyle {
107
107
  this.collectFieldRoutes(value);
108
108
  }
109
109
 
110
- get routes() {
110
+ get routes(): (Record<string, any> & {
111
+ path: string;
112
+ component?: unknown;
113
+ })[] {
111
114
  return this.__routes;
112
115
  }
113
116
 
114
- clear() {
117
+ clear(): void {
115
118
  this.__cacheRecord.clear();
116
119
  }
117
120
 
118
- protected render() {
121
+ protected render(): unknown {
119
122
  this.params = {};
120
123
  if (this.cache) {
121
124
  const cached = this.__cacheRecord.get(this.pathname);
@@ -137,7 +140,7 @@ class Router<C = unknown> extends GlobalStyle {
137
140
  return this.component ?? this.default ?? null;
138
141
  }
139
142
 
140
- connectedCallback() {
143
+ connectedCallback(): void {
141
144
  super.connectedCallback();
142
145
  Router.routerInstances.add(this);
143
146
  this.pathname ??= location.pathname;
@@ -153,12 +156,17 @@ class Router<C = unknown> extends GlobalStyle {
153
156
  }
154
157
  }
155
158
 
156
- disconnectedCallback() {
159
+ disconnectedCallback(): void {
157
160
  super.disconnectedCallback();
158
161
  Router.routerInstances.delete(this);
159
162
  }
160
163
 
161
- useRouter() {
164
+ useRouter(): {
165
+ pathname: string;
166
+ params: Record<string, string>;
167
+ path: string;
168
+ component: unknown;
169
+ } {
162
170
  return {
163
171
  pathname: this.pathname,
164
172
  params: this.params,
@@ -174,10 +182,10 @@ class Router<C = unknown> extends GlobalStyle {
174
182
  pathname: string;
175
183
  params: Record<string, string>;
176
184
  path: string;
177
- component: C | TemplateResult;
185
+ component: unknown | TemplateResult;
178
186
  }, first: boolean) => void = null;
179
187
 
180
- protected updated(changedProperties: PropertyValueMap<this>) {
188
+ protected updated(changedProperties: PropertyValueMap<this>): void {
181
189
  const shouldDispatch = changedProperties.has("pathname") || changedProperties.has("path");
182
190
  if (shouldDispatch) {
183
191
  const ur = this.useRouter();
@@ -193,7 +201,7 @@ class Router<C = unknown> extends GlobalStyle {
193
201
  /**
194
202
  * Get component from {@linkcode routes} by query.
195
203
  */
196
- fieldComponent(query?: string) {
204
+ fieldComponent(query?: string): unknown {
197
205
  query ||= this.useWhich(this.pathname);
198
206
  this.path = query;
199
207
 
@@ -212,7 +220,7 @@ class Router<C = unknown> extends GlobalStyle {
212
220
  /**
213
221
  * Get component from slotted elements by query.
214
222
  */
215
- slottedComponent(usedRouteTemplate?: string) {
223
+ slottedComponent(usedRouteTemplate?: string): TemplateResult<1> {
216
224
  const slottedPaths = this._slottedNames;
217
225
  usedRouteTemplate ||= this.__slottedRouteTree.useWhich(this.pathname);
218
226
  this.path = usedRouteTemplate;
@@ -232,7 +240,7 @@ class Router<C = unknown> extends GlobalStyle {
232
240
  /**
233
241
  * Reset the route tree, clear cache, collect routes from child elements.
234
242
  */
235
- collectSlottedRoutes() {
243
+ collectSlottedRoutes(): void {
236
244
  this.__slottedRouteTree = new RouteTree();
237
245
  this.clear();
238
246
  this._slottedNames.forEach(slotName => {
@@ -243,7 +251,7 @@ class Router<C = unknown> extends GlobalStyle {
243
251
  /**
244
252
  * Reset the route tree, clear cache, collect routes from value.
245
253
  */
246
- collectFieldRoutes(value: typeof this.routes) {
254
+ collectFieldRoutes(value: typeof this.routes): void {
247
255
  this.__fieldRouteTree = new RouteTree();
248
256
  this.clear();
249
257
  value.forEach(({ path }) => {
@@ -251,15 +259,15 @@ class Router<C = unknown> extends GlobalStyle {
251
259
  });
252
260
  }
253
261
 
254
- useWhich(path: string) {
262
+ useWhich(path: string): string {
255
263
  return this.__fieldRouteTree.useWhich(this.baseURL + path);
256
264
  }
257
265
 
258
- parseParams(routeTemplate: string, path: string) {
266
+ parseParams(routeTemplate: string, path: string): Record<string, string> {
259
267
  return this.__fieldRouteTree.parseParams(path, routeTemplate);
260
268
  }
261
269
 
262
- static updateAll() {
270
+ static updateAll(): void {
263
271
  this.routerInstances.forEach((i) => {
264
272
  i.handlePopstate();
265
273
  });
@@ -2,9 +2,10 @@ import { 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";
5
+ import { attr } from "@godown/element/directives/attr.js";
5
6
  import { htmlSlot } from "@godown/element/directives/html-slot.js";
6
7
  import svgCaretDown from "@godown/f7-icon/icons/chevron-down.js";
7
- import { css, html, nothing } from "lit";
8
+ import { css, html, nothing, type TemplateResult } from "lit";
8
9
  import { property, state } from "lit/decorators.js";
9
10
  import { ifDefined } from "lit/directives/if-defined.js";
10
11
 
@@ -57,15 +58,20 @@ const protoName = "select";
57
58
  [part=content] {
58
59
  position: absolute;
59
60
  width: 100%;
61
+ visibility: hidden;
60
62
  }
61
63
 
62
- [direction=bottom] {
64
+ [direction=bottom] [part=content] {
63
65
  top: 100%;
64
66
  }
65
67
 
66
- [direction=top] {
68
+ [direction=top] [part=content] {
67
69
  bottom: 100%;
68
70
  }
71
+
72
+ [visible] [part=content] {
73
+ visibility: visible
74
+ }
69
75
  `,
70
76
  )
71
77
  class Select extends Input {
@@ -98,8 +104,13 @@ class Select extends Input {
98
104
  protected defaultChecked: HTMLElement[];
99
105
  private _store: { value: string; text: string; }[] = [];
100
106
 
101
- protected render() {
102
- return html`<div part="root" class="input-field">
107
+ protected render(): TemplateResult<1> {
108
+ return html`<div part="root" ${
109
+ attr({
110
+ ...this.observedRecord,
111
+ direction: this.direction || this.autoDirection,
112
+ })
113
+ } class="input-field">
103
114
  ${[
104
115
  this._renderPrefix(),
105
116
  html`<input
@@ -117,16 +128,18 @@ class Select extends Input {
117
128
  @input="${this._handleInput}"
118
129
  >`,
119
130
  html`<label for="${this.makeId}" part="suffix">
120
- <i part="space"></i><i part="icon">${svgCaretDown()}</i><i part="space"></i>
131
+ <i part="space"></i>
132
+ <i part="icon">${svgCaretDown()}</i>
133
+ <i part="space"></i>
134
+ </label>`,
135
+ html`<label for="${this.makeId}" part="content">
136
+ ${htmlSlot()}
121
137
  </label>`,
122
- html`<label for="${this.makeId}" part="content"
123
- style="visibility:${this.visible ? "visible" : "hidden"}"
124
- direction="${this.direction || this.autoDirection}">${htmlSlot()}</label>`,
125
138
  ]}
126
139
  </div>`;
127
140
  }
128
141
 
129
- protected _handleFocus() {
142
+ protected _handleFocus(): void {
130
143
  if (!this.direction) {
131
144
  const { top, bottom } = this.getBoundingClientRect();
132
145
  if (window.innerHeight - bottom < this._content.clientHeight && top > this._content.clientHeight) {
@@ -138,7 +151,7 @@ class Select extends Input {
138
151
  this.visible = true;
139
152
  }
140
153
 
141
- protected firstUpdated() {
154
+ protected firstUpdated(): void {
142
155
  this.events.add(this._content, "click", (e: HandlerEvent) => {
143
156
  e.preventDefault();
144
157
  e.stopPropagation();
@@ -164,7 +177,7 @@ class Select extends Input {
164
177
  });
165
178
  }
166
179
 
167
- protected _connectedInit() {
180
+ protected _connectedInit(): void {
168
181
  if (!this.value) {
169
182
  const checked = [...this.querySelectorAll<HTMLElement>("[checked]")];
170
183
  const list = this.multiple
@@ -193,7 +206,7 @@ class Select extends Input {
193
206
  this.defaultChecked.forEach(element => updateChecked(element, 1));
194
207
  }
195
208
 
196
- select(value: string, text?: string) {
209
+ select(value: string, text?: string): 0 | 1 {
197
210
  text ||= value;
198
211
  let operation: 0 | 1 = 0;
199
212
  if (this.multiple) {
@@ -221,7 +234,7 @@ class Select extends Input {
221
234
  return operation;
222
235
  }
223
236
 
224
- filter(query?: string) {
237
+ filter(query?: string): void {
225
238
  query = query?.trim();
226
239
  [...this.children].forEach((element: HTMLElement) => {
227
240
  this.filterCallback(
@@ -235,11 +248,11 @@ class Select extends Input {
235
248
  }
236
249
 
237
250
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
238
- filterCallback(element: HTMLElement, match: boolean, query: string) {
251
+ filterCallback(element: HTMLElement, match: boolean, query: string): void {
239
252
  element.style.display = match ? "" : "none";
240
253
  }
241
254
 
242
- protected _handleInput(e: HandlerEvent<HTMLInputElement>) {
255
+ protected _handleInput(e: HandlerEvent<HTMLInputElement>): void {
243
256
  e.stopPropagation();
244
257
  if (this.compositing) {
245
258
  return;
@@ -249,12 +262,12 @@ class Select extends Input {
249
262
  this.dispatchEvent(new CustomEvent("input", { detail: this.namevalue() }));
250
263
  }
251
264
 
252
- focus(options?: FocusOptions) {
265
+ focus(options?: FocusOptions): void {
253
266
  this._input.focus(options);
254
267
  this.visible = true;
255
268
  }
256
269
 
257
- blur() {
270
+ blur(): void {
258
271
  this._input.blur();
259
272
  this.visible = false;
260
273
  super.blur();
@@ -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 iconPhoto from "@godown/f7-icon/icons/photo.js";
5
- import { css, html } from "lit";
6
+ import { css, html, type TemplateResult } from "lit";
6
7
  import { property, state } from "lit/decorators.js";
7
8
 
8
9
  import { cssGlobalVars, GlobalStyle, scopePrefix } from "../core/global-style.js";
@@ -49,7 +50,7 @@ const cssScope = scopePrefix(protoName);
49
50
  margin: calc(var(--size) * 0.05);
50
51
  }
51
52
 
52
- .position {
53
+ [animation=position] {
53
54
  background-image: linear-gradient(
54
55
  var(${cssScope}--deg),
55
56
  var(${cssScope}--from) 36%,
@@ -70,7 +71,7 @@ const cssScope = scopePrefix(protoName);
70
71
  }
71
72
  }
72
73
 
73
- .opacity {
74
+ [animation=opacity] {
74
75
  animation-name: op;
75
76
  animation-direction: alternate;
76
77
  }
@@ -105,11 +106,11 @@ class Skeleton extends GlobalStyle {
105
106
  @state()
106
107
  loading = true;
107
108
 
108
- protected render() {
109
+ protected render(): TemplateResult<1> {
109
110
  if (!this.loading) {
110
111
  return htmlSlot();
111
112
  }
112
- return html`<div part="root" class="${this.animation}">
113
+ return html`<div part="root" ${attr(this.observedRecord)}>
113
114
  ${this.type === "image" ? iconPhoto() : ""}
114
115
  ${htmlSlot("loading")}</div>`;
115
116
  }
@@ -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 { classList } from "@godown/element/directives/class-list.js";
4
5
  import { type HandlerEvent } from "@godown/element/element.js";
5
- import { css, html, nothing } from "lit";
6
+ import { css, html, nothing, type TemplateResult } from "lit";
6
7
  import { property, state } from "lit/decorators.js";
7
8
 
8
9
  import { cssGlobalVars, scopePrefix } from "../core/global-style.js";
@@ -40,6 +41,10 @@ const loop = <T>(len: number, fn: (index?: number) => T) => {
40
41
  ${cssScope}--gap: .25em;
41
42
  }
42
43
 
44
+ :host([contents]) [part=root] {
45
+ width: fit-content;
46
+ }
47
+
43
48
  [part=root] {
44
49
  gap: var(${cssScope}--gap);
45
50
  width: 100%;
@@ -92,9 +97,8 @@ class Split extends SuperInput {
92
97
  @state()
93
98
  currentValue: (string | void)[] = [];
94
99
 
95
- protected render() {
96
- return html`
97
- <div part="root">
100
+ protected render(): TemplateResult<1> {
101
+ return html`<div part="root" ${attr(this.observedRecord)}>
98
102
  ${
99
103
  loop(this.len, (index: number) =>
100
104
  html`<span part="input-box"
@@ -102,16 +106,16 @@ class Split extends SuperInput {
102
106
  class="${classList({ focus: this.current === index }) || nothing}"
103
107
  >${this.currentValue[index]}</span>`)
104
108
  }
105
- <input
106
- part="input"
107
- id="${this.makeId}"
108
- @blur=${this.blur}
109
- @input="${this._handleInput}"
110
- .value="${
109
+ <input
110
+ part="input"
111
+ id="${this.makeId}"
112
+ @blur=${this.blur}
113
+ @input="${this._handleInput}"
114
+ .value="${
111
115
  /* Ensure that input always has a value of length this.len */
112
116
  this.value.padStart(this.len, " ")}"
113
- >
114
- </div>
117
+ >
118
+ </div>
115
119
  `;
116
120
  }
117
121
 
@@ -120,7 +124,7 @@ class Split extends SuperInput {
120
124
  this.reset();
121
125
  }
122
126
 
123
- protected _handleInput(e: HandlerEvent<HTMLInputElement, InputEvent>) {
127
+ protected _handleInput(e: HandlerEvent<HTMLInputElement, InputEvent>): void {
124
128
  e.stopPropagation();
125
129
  if (this.compositing) {
126
130
  return;
@@ -149,7 +153,7 @@ class Split extends SuperInput {
149
153
  *
150
154
  * @param data Input event data.
151
155
  */
152
- protected fillInput(data: string | null) {
156
+ protected fillInput(data: string | null): void {
153
157
  if (data === null) {
154
158
  // delete
155
159
 
@@ -192,23 +196,23 @@ class Split extends SuperInput {
192
196
  }
193
197
  }
194
198
 
195
- focus() {
199
+ focus(): void {
196
200
  this.focusAt(this.current);
197
201
  super.focus();
198
202
  }
199
203
 
200
- focusAt(i: number) {
204
+ focusAt(i: number): void {
201
205
  this.current = i;
202
206
  this._input.focus();
203
207
  }
204
208
 
205
- blur() {
209
+ blur(): void {
206
210
  this._input.blur();
207
211
  this.current = -1;
208
212
  super.blur();
209
213
  }
210
214
 
211
- reset() {
215
+ reset(): void {
212
216
  this.current = -1;
213
217
  this.value = this.default;
214
218
  this.currentValue = this.value.split("").concat(Array(this.len - this.value.length).fill(null));
@@ -1,6 +1,7 @@
1
1
  import { godown } from "@godown/element/decorators/godown.js";
2
2
  import { styles } from "@godown/element/decorators/styles.js";
3
- import { css, html } from "lit";
3
+ import { attr } from "@godown/element/directives/attr.js";
4
+ import { css, html, type TemplateResult } from "lit";
4
5
  import { property, query } from "lit/decorators.js";
5
6
 
6
7
  import { cssGlobalVars, scopePrefix } from "../core/global-style.js";
@@ -20,6 +21,12 @@ const cssScope = scopePrefix(protoName);
20
21
  @godown(protoName)
21
22
  @styles(
22
23
  css`
24
+ :host,
25
+ :host([contents]) [part=root] {
26
+ width: var(${cssScope}-width);
27
+ height: var(${cssScope}-height);
28
+ }
29
+
23
30
  :host {
24
31
  ${cssScope}-width: 3em;
25
32
  ${cssScope}-height: calc(var(${cssScope}-width) / 2);
@@ -27,8 +34,6 @@ const cssScope = scopePrefix(protoName);
27
34
  ${cssScope}-handle-space: .125em;
28
35
  ${cssScope}-transition: .2s ease-in-out;
29
36
  background: var(${cssGlobalVars.input}-background);
30
- width: var(${cssScope}-width);
31
- height: var(${cssScope}-height);
32
37
  display: inline-block;
33
38
  vertical-align: bottom;
34
39
  border-radius: 0;
@@ -44,14 +49,10 @@ const cssScope = scopePrefix(protoName);
44
49
  position: relative;
45
50
  height: inherit;
46
51
  }
47
-
48
- [part=root],
49
- input {
50
- width: 100%;
51
- }
52
-
52
+
53
53
  input {
54
54
  opacity: 0;
55
+ width: 100%;
55
56
  height: 100%;
56
57
  appearance: none;
57
58
  }
@@ -136,8 +137,11 @@ class Switch extends SuperInput {
136
137
  @query("input")
137
138
  protected _input: HTMLInputElement;
138
139
 
139
- protected render() {
140
- return html`<div part="root" class="${this.round ? "round" : "rect"}">
140
+ protected render(): TemplateResult<1> {
141
+ return html`<div part="root"
142
+ ${attr(this.observedRecord)}
143
+ class="${this.round ? "round" : "rect"}"
144
+ >
141
145
  <input
142
146
  part="input"
143
147
  @change="${this._handleChange}"
@@ -151,12 +155,12 @@ class Switch extends SuperInput {
151
155
  </div>`;
152
156
  }
153
157
 
154
- reset() {
158
+ reset(): void {
155
159
  this.checked = this.default === "true";
156
160
  this._input.checked = this.checked;
157
161
  }
158
162
 
159
- connectedCallback() {
163
+ connectedCallback(): void {
160
164
  super.connectedCallback();
161
165
  if (this.checked) {
162
166
  this.default = "true";
@@ -166,7 +170,7 @@ class Switch extends SuperInput {
166
170
  }
167
171
  }
168
172
 
169
- protected _handleChange() {
173
+ protected _handleChange(): void {
170
174
  this.checked = this._input.checked;
171
175
  this.dispatchEvent(new CustomEvent("input", { detail: this.checked, bubbles: true, composed: true }));
172
176
  this.dispatchEvent(new CustomEvent("change", { detail: this.checked, composed: true }));
@@ -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 { classList } from "@godown/element/directives/class-list.js";
4
5
  import { htmlSlot } from "@godown/element/directives/html-slot.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 { cssGlobalVars, GlobalStyle, scopePrefix } from "../core/global-style.js";
@@ -56,7 +57,7 @@ const cssScope = scopePrefix(protoName);
56
57
  text-decoration: none;
57
58
  }
58
59
 
59
- .clip{
60
+ [clip] {
60
61
  background: var(${cssGlobalVars.clipBackground});
61
62
  display: inline-block;
62
63
  color: transparent;
@@ -78,14 +79,11 @@ class Text extends GlobalStyle {
78
79
  @property({ type: Boolean })
79
80
  clip: boolean;
80
81
 
81
- protected render() {
82
+ protected render(): TemplateResult<1> {
82
83
  return html`<span
83
84
  part="root"
84
- class="${
85
- classList(this.underline, {
86
- clip: this.clip,
87
- })
88
- }"
85
+ ${attr(this.observedRecord)}
86
+ class="${classList(this.underline)}"
89
87
  >
90
88
  ${htmlSlot()}
91
89
  </span>`;
@@ -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 fmtime from "fmtime";
4
- import { css, type PropertyValues } from "lit";
5
+ import { css, html, type PropertyValues, TemplateResult } from "lit";
5
6
  import { property } from "lit/decorators.js";
6
7
 
7
8
  import { GlobalStyle } from "../core/global-style.js";
@@ -32,27 +33,29 @@ class Time extends GlobalStyle {
32
33
  * Time.
33
34
  */
34
35
  @property({ type: Object })
35
- time = new Date();
36
+ time: Date = new Date();
36
37
 
37
38
  /**
38
39
  * If there is a value, update every gap or timeout.
39
40
  */
40
41
  @property({ type: Number })
41
- timeout;
42
+ timeout: any;
42
43
 
43
44
  /**
44
45
  * The number of milliseconds that change with each update.
45
46
  */
46
47
  @property({ type: Number })
47
- gap;
48
+ gap: any;
48
49
 
49
50
  protected timeoutId: number;
50
51
 
51
- protected render(): string {
52
- return fmtime(this.format, this.time, this.escape);
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
56
  }
54
57
 
55
- protected firstUpdated() {
58
+ protected firstUpdated(): void {
56
59
  if (this.timeout) {
57
60
  this.timeoutId = this.startTimeout();
58
61
  }
@@ -67,11 +70,11 @@ class Time extends GlobalStyle {
67
70
  }
68
71
  }
69
72
 
70
- disconnectedCallback() {
73
+ disconnectedCallback(): void {
71
74
  clearInterval(this.timeoutId);
72
75
  }
73
76
 
74
- startTimeout() {
77
+ startTimeout(): number {
75
78
  return window.setInterval(() => {
76
79
  this.time = new Date(this.time.getTime() + (this.gap || this.timeout));
77
80
  }, Math.abs(this.timeout));