godown 3.0.0-canary.0 → 3.0.0-canary.1

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 (246) hide show
  1. package/dev/alert.d.ts +8 -0
  2. package/dev/alert.d.ts.map +1 -0
  3. package/dev/alert.js +4 -0
  4. package/dev/alert.js.map +1 -0
  5. package/dev/avatar.d.ts +8 -0
  6. package/dev/avatar.d.ts.map +1 -0
  7. package/dev/avatar.js +4 -0
  8. package/dev/avatar.js.map +1 -0
  9. package/dev/breath.d.ts +9 -0
  10. package/dev/breath.d.ts.map +1 -0
  11. package/dev/breath.js +5 -0
  12. package/dev/breath.js.map +1 -0
  13. package/dev/button.d.ts +8 -0
  14. package/dev/button.d.ts.map +1 -0
  15. package/dev/button.js +4 -0
  16. package/dev/button.js.map +1 -0
  17. package/dev/card.d.ts +8 -0
  18. package/dev/card.d.ts.map +1 -0
  19. package/dev/card.js +4 -0
  20. package/dev/card.js.map +1 -0
  21. package/dev/carousel.d.ts +8 -0
  22. package/dev/carousel.d.ts.map +1 -0
  23. package/dev/carousel.js +4 -0
  24. package/dev/carousel.js.map +1 -0
  25. package/dev/components/alert.d.ts +50 -0
  26. package/dev/components/alert.d.ts.map +1 -0
  27. package/dev/components/alert.js +234 -0
  28. package/dev/components/alert.js.map +1 -0
  29. package/dev/components/avatar.d.ts +26 -0
  30. package/dev/components/avatar.d.ts.map +1 -0
  31. package/dev/components/avatar.js +91 -0
  32. package/dev/components/avatar.js.map +1 -0
  33. package/dev/components/breath.d.ts +34 -0
  34. package/dev/components/breath.d.ts.map +1 -0
  35. package/dev/components/breath.js +133 -0
  36. package/dev/components/breath.js.map +1 -0
  37. package/dev/components/button.d.ts +45 -0
  38. package/dev/components/button.d.ts.map +1 -0
  39. package/dev/components/button.js +256 -0
  40. package/dev/components/button.js.map +1 -0
  41. package/dev/components/card.d.ts +20 -0
  42. package/dev/components/card.d.ts.map +1 -0
  43. package/dev/components/card.js +89 -0
  44. package/dev/components/card.js.map +1 -0
  45. package/dev/components/carousel.d.ts +40 -0
  46. package/dev/components/carousel.d.ts.map +1 -0
  47. package/dev/components/carousel.js +155 -0
  48. package/dev/components/carousel.js.map +1 -0
  49. package/dev/components/details.d.ts +20 -0
  50. package/dev/components/details.d.ts.map +1 -0
  51. package/dev/components/details.js +115 -0
  52. package/dev/components/details.js.map +1 -0
  53. package/dev/components/dialog.d.ts +33 -0
  54. package/dev/components/dialog.d.ts.map +1 -0
  55. package/dev/components/dialog.js +154 -0
  56. package/dev/components/dialog.js.map +1 -0
  57. package/dev/components/divider.d.ts +17 -0
  58. package/dev/components/divider.d.ts.map +1 -0
  59. package/dev/components/divider.js +46 -0
  60. package/dev/components/divider.js.map +1 -0
  61. package/dev/components/dragbox.d.ts +40 -0
  62. package/dev/components/dragbox.d.ts.map +1 -0
  63. package/dev/components/dragbox.js +117 -0
  64. package/dev/components/dragbox.js.map +1 -0
  65. package/dev/components/flex.d.ts +31 -0
  66. package/dev/components/flex.d.ts.map +1 -0
  67. package/dev/components/flex.js +52 -0
  68. package/dev/components/flex.js.map +1 -0
  69. package/dev/components/form.d.ts +24 -0
  70. package/dev/components/form.d.ts.map +1 -0
  71. package/dev/components/form.js +79 -0
  72. package/dev/components/form.js.map +1 -0
  73. package/dev/components/grid.d.ts +31 -0
  74. package/dev/components/grid.d.ts.map +1 -0
  75. package/dev/components/grid.js +53 -0
  76. package/dev/components/grid.js.map +1 -0
  77. package/dev/components/input.d.ts +20 -0
  78. package/dev/components/input.d.ts.map +1 -0
  79. package/dev/components/input.js +89 -0
  80. package/dev/components/input.js.map +1 -0
  81. package/dev/components/layout.d.ts +29 -0
  82. package/dev/components/layout.d.ts.map +1 -0
  83. package/dev/components/layout.js +69 -0
  84. package/dev/components/layout.js.map +1 -0
  85. package/dev/components/link.d.ts +20 -0
  86. package/dev/components/link.d.ts.map +1 -0
  87. package/dev/components/link.js +40 -0
  88. package/dev/components/link.js.map +1 -0
  89. package/dev/components/progress.d.ts +30 -0
  90. package/dev/components/progress.d.ts.map +1 -0
  91. package/dev/components/progress.js +108 -0
  92. package/dev/components/progress.js.map +1 -0
  93. package/dev/components/range.d.ts +60 -0
  94. package/dev/components/range.d.ts.map +1 -0
  95. package/dev/components/range.js +306 -0
  96. package/dev/components/range.js.map +1 -0
  97. package/dev/components/rotate.d.ts +26 -0
  98. package/dev/components/rotate.d.ts.map +1 -0
  99. package/dev/components/rotate.js +86 -0
  100. package/dev/components/rotate.js.map +1 -0
  101. package/dev/components/router.d.ts +121 -0
  102. package/dev/components/router.d.ts.map +1 -0
  103. package/dev/components/router.js +248 -0
  104. package/dev/components/router.js.map +1 -0
  105. package/dev/components/select.d.ts +50 -0
  106. package/dev/components/select.d.ts.map +1 -0
  107. package/dev/components/select.js +243 -0
  108. package/dev/components/select.js.map +1 -0
  109. package/dev/components/skeleton.d.ts +26 -0
  110. package/dev/components/skeleton.d.ts.map +1 -0
  111. package/dev/components/skeleton.js +119 -0
  112. package/dev/components/skeleton.js.map +1 -0
  113. package/dev/components/split.d.ts +32 -0
  114. package/dev/components/split.d.ts.map +1 -0
  115. package/dev/components/split.js +173 -0
  116. package/dev/components/split.js.map +1 -0
  117. package/dev/components/switch.d.ts +39 -0
  118. package/dev/components/switch.d.ts.map +1 -0
  119. package/dev/components/switch.js +183 -0
  120. package/dev/components/switch.js.map +1 -0
  121. package/dev/components/text.d.ts +19 -0
  122. package/dev/components/text.d.ts.map +1 -0
  123. package/dev/components/text.js +93 -0
  124. package/dev/components/text.js.map +1 -0
  125. package/dev/components/time.d.ts +53 -0
  126. package/dev/components/time.d.ts.map +1 -0
  127. package/dev/components/time.js +136 -0
  128. package/dev/components/time.js.map +1 -0
  129. package/dev/components/tooltip.d.ts +38 -0
  130. package/dev/components/tooltip.d.ts.map +1 -0
  131. package/dev/components/tooltip.js +114 -0
  132. package/dev/components/tooltip.js.map +1 -0
  133. package/dev/components/typewriter.d.ts +55 -0
  134. package/dev/components/typewriter.d.ts.map +1 -0
  135. package/dev/components/typewriter.js +156 -0
  136. package/dev/components/typewriter.js.map +1 -0
  137. package/dev/core/global-style.d.ts +21 -0
  138. package/dev/core/global-style.d.ts.map +1 -0
  139. package/dev/core/global-style.js +77 -0
  140. package/dev/core/global-style.js.map +1 -0
  141. package/dev/core/super-anchor.d.ts +15 -0
  142. package/dev/core/super-anchor.d.ts.map +1 -0
  143. package/dev/core/super-anchor.js +58 -0
  144. package/dev/core/super-anchor.js.map +1 -0
  145. package/dev/core/super-input.d.ts +39 -0
  146. package/dev/core/super-input.d.ts.map +1 -0
  147. package/dev/core/super-input.js +181 -0
  148. package/dev/core/super-input.js.map +1 -0
  149. package/dev/core/super-openable.d.ts +19 -0
  150. package/dev/core/super-openable.d.ts.map +1 -0
  151. package/dev/core/super-openable.js +36 -0
  152. package/dev/core/super-openable.js.map +1 -0
  153. package/dev/details.d.ts +8 -0
  154. package/dev/details.d.ts.map +1 -0
  155. package/dev/details.js +4 -0
  156. package/dev/details.js.map +1 -0
  157. package/dev/dialog.d.ts +8 -0
  158. package/dev/dialog.d.ts.map +1 -0
  159. package/dev/dialog.js +4 -0
  160. package/dev/dialog.js.map +1 -0
  161. package/dev/divider.d.ts +8 -0
  162. package/dev/divider.d.ts.map +1 -0
  163. package/dev/divider.js +4 -0
  164. package/dev/divider.js.map +1 -0
  165. package/dev/dragbox.d.ts +8 -0
  166. package/dev/dragbox.d.ts.map +1 -0
  167. package/dev/dragbox.js +4 -0
  168. package/dev/dragbox.js.map +1 -0
  169. package/dev/flex.d.ts +8 -0
  170. package/dev/flex.d.ts.map +1 -0
  171. package/dev/flex.js +4 -0
  172. package/dev/flex.js.map +1 -0
  173. package/dev/form.d.ts +8 -0
  174. package/dev/form.d.ts.map +1 -0
  175. package/dev/form.js +4 -0
  176. package/dev/form.js.map +1 -0
  177. package/dev/grid.d.ts +8 -0
  178. package/dev/grid.d.ts.map +1 -0
  179. package/dev/grid.js +4 -0
  180. package/dev/grid.js.map +1 -0
  181. package/dev/index.d.ts +29 -0
  182. package/dev/index.d.ts.map +1 -0
  183. package/dev/index.js +29 -0
  184. package/dev/index.js.map +1 -0
  185. package/dev/input.d.ts +9 -0
  186. package/dev/input.d.ts.map +1 -0
  187. package/dev/input.js +5 -0
  188. package/dev/input.js.map +1 -0
  189. package/dev/layout.d.ts +9 -0
  190. package/dev/layout.d.ts.map +1 -0
  191. package/dev/layout.js +5 -0
  192. package/dev/layout.js.map +1 -0
  193. package/dev/link.d.ts +9 -0
  194. package/dev/link.d.ts.map +1 -0
  195. package/dev/link.js +5 -0
  196. package/dev/link.js.map +1 -0
  197. package/dev/progress.d.ts +9 -0
  198. package/dev/progress.d.ts.map +1 -0
  199. package/dev/progress.js +5 -0
  200. package/dev/progress.js.map +1 -0
  201. package/dev/range.d.ts +9 -0
  202. package/dev/range.d.ts.map +1 -0
  203. package/dev/range.js +5 -0
  204. package/dev/range.js.map +1 -0
  205. package/dev/rotate.d.ts +9 -0
  206. package/dev/rotate.d.ts.map +1 -0
  207. package/dev/rotate.js +5 -0
  208. package/dev/rotate.js.map +1 -0
  209. package/dev/router.d.ts +9 -0
  210. package/dev/router.d.ts.map +1 -0
  211. package/dev/router.js +5 -0
  212. package/dev/router.js.map +1 -0
  213. package/dev/select.d.ts +9 -0
  214. package/dev/select.d.ts.map +1 -0
  215. package/dev/select.js +5 -0
  216. package/dev/select.js.map +1 -0
  217. package/dev/skeleton.d.ts +9 -0
  218. package/dev/skeleton.d.ts.map +1 -0
  219. package/dev/skeleton.js +5 -0
  220. package/dev/skeleton.js.map +1 -0
  221. package/dev/split.d.ts +9 -0
  222. package/dev/split.d.ts.map +1 -0
  223. package/dev/split.js +5 -0
  224. package/dev/split.js.map +1 -0
  225. package/dev/switch.d.ts +9 -0
  226. package/dev/switch.d.ts.map +1 -0
  227. package/dev/switch.js +5 -0
  228. package/dev/switch.js.map +1 -0
  229. package/dev/text.d.ts +9 -0
  230. package/dev/text.d.ts.map +1 -0
  231. package/dev/text.js +5 -0
  232. package/dev/text.js.map +1 -0
  233. package/dev/time.d.ts +9 -0
  234. package/dev/time.d.ts.map +1 -0
  235. package/dev/time.js +5 -0
  236. package/dev/time.js.map +1 -0
  237. package/dev/tooltip.d.ts +9 -0
  238. package/dev/tooltip.d.ts.map +1 -0
  239. package/dev/tooltip.js +5 -0
  240. package/dev/tooltip.js.map +1 -0
  241. package/dev/typewriter.d.ts +8 -0
  242. package/dev/typewriter.d.ts.map +1 -0
  243. package/dev/typewriter.js +4 -0
  244. package/dev/typewriter.js.map +1 -0
  245. package/package.json +3 -3
  246. package/web-types.json +1 -1
@@ -0,0 +1,86 @@
1
+ import { __decorate } from "tslib";
2
+ import { godown } from "@godown/element/decorators/godown.js";
3
+ import { part } from "@godown/element/decorators/part.js";
4
+ import { styles } from "@godown/element/decorators/styles.js";
5
+ import { htmlSlot } from "@godown/element/directives/html-slot.js";
6
+ import { css, html } from "lit";
7
+ import { GlobalStyle, scopePrefix } from "../core/global-style.js";
8
+ const protoName = "rotate";
9
+ const cssScope = scopePrefix(protoName);
10
+ /**
11
+ * {@linkcode Rotate} Make child elements rotate.
12
+ *
13
+ * @category wrapper
14
+ */
15
+ let Rotate = class Rotate extends GlobalStyle {
16
+ render() {
17
+ return html `<div part="root">
18
+ <div part="slot" @mousemove="${this._handleRotate}">${htmlSlot()}</div>
19
+ <i @mouseleave="${this.reset}"></i>
20
+ </div>`;
21
+ }
22
+ reset() {
23
+ this._root.style.removeProperty("transform");
24
+ this._root.style.removeProperty("transition");
25
+ }
26
+ _handleRotate(e) {
27
+ const { rotateX, rotateY } = this._computeOffset(e);
28
+ this._root.style.setProperty("transform", `rotateX(${rotateX}rad) rotateY(${rotateY}rad)`);
29
+ this._root.style.setProperty("transition", "0s");
30
+ }
31
+ /**
32
+ * Compute offset.
33
+ * ```
34
+ * `rotateX(${rotateX}rad) rotateY(${rotateY}rad)`
35
+ * ```
36
+ * @param e Mouse move event.
37
+ * @returns rotateX, rotateY
38
+ */
39
+ _computeOffset(e) {
40
+ const { left, top, width, height } = this._root.getBoundingClientRect();
41
+ const { clientX, clientY } = e;
42
+ const offsetX = clientX - left;
43
+ const offsetY = clientY - top;
44
+ const rotateX = -(offsetY - height / 2) / height / 2;
45
+ const rotateY = (offsetX - width / 2) / width / 2;
46
+ return { rotateX, rotateY };
47
+ }
48
+ };
49
+ __decorate([
50
+ part("root")
51
+ ], Rotate.prototype, "_root", void 0);
52
+ Rotate = __decorate([
53
+ godown(protoName),
54
+ styles(css `
55
+ :host {
56
+ display: block;
57
+ width: -moz-fit-content;
58
+ width: fit-content;
59
+ transition: all 0.5s ease-in-out;
60
+ ${cssScope}--padding: .75em;
61
+ ${cssScope}--offset: .5em;
62
+ }
63
+
64
+ div {
65
+ position: relative;
66
+ transition: inherit;
67
+ transition-property: transform;
68
+ }
69
+
70
+ i {
71
+ width: 100%;
72
+ height: 100%;
73
+ position: absolute;
74
+ top: 0;
75
+ box-sizing: content-box;
76
+ padding: var(${cssScope}--offset);
77
+ margin: calc(-1 * var(${cssScope}--offset));
78
+ }
79
+
80
+ [part="slot"]{
81
+ z-index: 2;
82
+ }
83
+ `)
84
+ ], Rotate);
85
+ export default Rotate;
86
+ //# sourceMappingURL=rotate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rotate.js","sourceRoot":"","sources":["../../src/components/rotate.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,yCAAyC,CAAC;AACnE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAEhC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEnE,MAAM,SAAS,GAAG,QAAQ,CAAC;AAC3B,MAAM,QAAQ,GAAG,WAAW,C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OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;IAC9B,CAAC;CACF,CAAA;AAtCC;IADC,IAAI,CAAC,MAAM,CAAC;qCACM;AAFf,MAAM;IAjCX,MAAM,CAAC,SAAS,CAAC;IACjB,MAAM,CACL,GAAG,CAAA;;;;;;MAMC,QAAQ;MACR,QAAQ;;;;;;;;;;;;;;;mBAeK,QAAQ;4BACC,QAAQ;;;;;;CAMnC,CACA;GACK,MAAM,CAwCX;AAED,eAAe,MAAM,CAAC"}
@@ -0,0 +1,121 @@
1
+ import { type PropertyValueMap, type TemplateResult } from "lit";
2
+ import { GlobalStyle } from "../core/global-style.js";
3
+ /**
4
+ * {@linkcode Router} has basic routing control.
5
+ *
6
+ * To switch routes, use `router-link component`.
7
+ *
8
+ * It has two methods to collect routes.
9
+ *
10
+ * 1. From field `routes`, an array, each elements require "path" and "component".
11
+ * 2. From child elements, which have the slot attribute for matching routes.
12
+ *
13
+ * If only the method 1 is used, set `type` to `"field"`.
14
+ *
15
+ * If only the method 2 is used, set `type` to `"slotted"`.
16
+ *
17
+ * `type` defaults to `"united"`, which will try method 1, then method 2.
18
+ *
19
+ * If no routes are matched, the default value (no named slot) will be rendered.
20
+ *
21
+ * @category navigation
22
+ */
23
+ declare class Router<C = unknown> extends GlobalStyle {
24
+ static routerInstances: Set<Router<unknown>>;
25
+ private __fieldRouteTree;
26
+ private __slottedRouteTree;
27
+ private __cacheRecord;
28
+ private __routes;
29
+ /**
30
+ * Render result.
31
+ */
32
+ component: C | TemplateResult;
33
+ /**
34
+ * Dynamic parameters record.
35
+ */
36
+ params: Record<string, string>;
37
+ /**
38
+ * Value of matched path in routes.
39
+ */
40
+ path: string;
41
+ /**
42
+ * Current pathname (equals to location.pathname).
43
+ */
44
+ pathname: string;
45
+ /**
46
+ * Path prefix.
47
+ */
48
+ baseURL: string;
49
+ /**
50
+ * Rendered content when there is no match.
51
+ */
52
+ default: TemplateResult;
53
+ /**
54
+ * The type of routing sources.
55
+ *
56
+ * If field, it won't collect the slot attribute of the child elements.
57
+ *
58
+ * This property should not be changed after the rendering is complete.
59
+ */
60
+ type: "united" | "slotted" | "field";
61
+ /**
62
+ * Cache accessed records.
63
+ *
64
+ * Emptied at each re-collection.
65
+ */
66
+ cache: boolean;
67
+ set routes(value: (Record<string, any> & {
68
+ path: string;
69
+ component?: C;
70
+ })[]);
71
+ get routes(): (Record<string, any> & {
72
+ path: string;
73
+ component?: C;
74
+ })[];
75
+ clear(): void;
76
+ protected render(): C | TemplateResult;
77
+ connectedCallback(): void;
78
+ disconnectedCallback(): void;
79
+ useRouter(): {
80
+ pathname: string;
81
+ params: Record<string, string>;
82
+ path: string;
83
+ component: C | TemplateResult;
84
+ };
85
+ /**
86
+ * @param params value of useRouter()
87
+ * @param first whether this path is loaded for the first time.
88
+ */
89
+ routeChangeCallback: (params: {
90
+ pathname: string;
91
+ params: Record<string, string>;
92
+ path: string;
93
+ component: C | TemplateResult;
94
+ }, first: boolean) => void;
95
+ protected updated(changedProperties: PropertyValueMap<this>): void;
96
+ /**
97
+ * Find components from {@linkcode __fieldRouteTree} matching query.
98
+ * @param query Query string.
99
+ * @returns Components or null.
100
+ */
101
+ fieldComponent(query?: string): C;
102
+ /**
103
+ * Find components from {@linkcode __slottedRouteTree} matching query.
104
+ * @param query Query string.
105
+ * @returns Named slot element template result or null.
106
+ */
107
+ slottedComponent(usedRouteTemplate?: string): TemplateResult<1>;
108
+ /**
109
+ * Reset the route tree, clear cache, collect routes from child elements.
110
+ */
111
+ collectSlottedRoutes(): void;
112
+ /**
113
+ * Reset the route tree, clear cache, collect routes from value.
114
+ */
115
+ collectFieldRoutes(value: typeof this.routes): void;
116
+ useWhich(path: string): string;
117
+ parseParams(routeTemplate: string, path: string): Record<string, string>;
118
+ static updateAll(): void;
119
+ }
120
+ export default Router;
121
+ //# sourceMappingURL=router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/components/router.ts"],"names":[],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KAAK,IAAI,CAAQ;IAElC,SAAS,CAAC,OAAO,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,IAAI,CAAC;IAa3D;;;;OAIG;IACH,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM;IAgB7B;;;;OAIG;IACH,gBAAgB,CAAC,iBAAiB,CAAC,EAAE,MAAM;IAiB3C;;OAEG;IACH,oBAAoB;IAQpB;;OAEG;IACH,kBAAkB,CAAC,KAAK,EAAE,OAAO,IAAI,CAAC,MAAM;IAQ5C,QAAQ,CAAC,IAAI,EAAE,MAAM;IAIrB,WAAW,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAI/C,MAAM,CAAC,SAAS;CAKjB;AAED,eAAe,MAAM,CAAC"}
@@ -0,0 +1,248 @@
1
+ var Router_1;
2
+ import { __decorate } from "tslib";
3
+ import { godown } from "@godown/element/decorators/godown.js";
4
+ import { styles } from "@godown/element/decorators/styles.js";
5
+ import { htmlSlot } from "@godown/element/directives/html-slot.js";
6
+ import { RouteTree } from "@godown/element/tools/route-tree.js";
7
+ import { css } from "lit";
8
+ import { property, state } from "lit/decorators.js";
9
+ import { GlobalStyle } from "../core/global-style.js";
10
+ const protoName = "router";
11
+ /**
12
+ * {@linkcode Router} has basic routing control.
13
+ *
14
+ * To switch routes, use `router-link component`.
15
+ *
16
+ * It has two methods to collect routes.
17
+ *
18
+ * 1. From field `routes`, an array, each elements require "path" and "component".
19
+ * 2. From child elements, which have the slot attribute for matching routes.
20
+ *
21
+ * If only the method 1 is used, set `type` to `"field"`.
22
+ *
23
+ * If only the method 2 is used, set `type` to `"slotted"`.
24
+ *
25
+ * `type` defaults to `"united"`, which will try method 1, then method 2.
26
+ *
27
+ * If no routes are matched, the default value (no named slot) will be rendered.
28
+ *
29
+ * @category navigation
30
+ */
31
+ let Router = Router_1 = class Router extends GlobalStyle {
32
+ constructor() {
33
+ super(...arguments);
34
+ this.__fieldRouteTree = new RouteTree();
35
+ this.__slottedRouteTree = new RouteTree();
36
+ this.__cacheRecord = new Map();
37
+ /**
38
+ * Render result.
39
+ */
40
+ this.component = null;
41
+ /**
42
+ * Dynamic parameters record.
43
+ */
44
+ this.params = {};
45
+ /**
46
+ * Current pathname (equals to location.pathname).
47
+ */
48
+ this.pathname = "";
49
+ /**
50
+ * Path prefix.
51
+ */
52
+ this.baseURL = "";
53
+ /**
54
+ * Rendered content when there is no match.
55
+ */
56
+ this.default = htmlSlot();
57
+ /**
58
+ * The type of routing sources.
59
+ *
60
+ * If field, it won't collect the slot attribute of the child elements.
61
+ *
62
+ * This property should not be changed after the rendering is complete.
63
+ */
64
+ this.type = "united";
65
+ /**
66
+ * Cache accessed records.
67
+ *
68
+ * Emptied at each re-collection.
69
+ */
70
+ this.cache = false;
71
+ /**
72
+ * @param params value of useRouter()
73
+ * @param first whether this path is loaded for the first time.
74
+ */
75
+ this.routeChangeCallback = null;
76
+ }
77
+ set routes(value) {
78
+ this.__routes = value;
79
+ this.collectFieldRoutes(value);
80
+ }
81
+ get routes() {
82
+ return this.__routes;
83
+ }
84
+ clear() {
85
+ this.__cacheRecord.clear();
86
+ }
87
+ render() {
88
+ this.params = {};
89
+ if (this.cache) {
90
+ const cached = this.__cacheRecord.get(this.pathname);
91
+ if (cached) {
92
+ Object.assign(this, cached);
93
+ return this.component;
94
+ }
95
+ }
96
+ switch (this.type) {
97
+ case "field":
98
+ this.component = this.fieldComponent();
99
+ break;
100
+ case "slotted":
101
+ this.component = this.slottedComponent();
102
+ break;
103
+ default:
104
+ this.component = this.fieldComponent() ?? this.slottedComponent();
105
+ }
106
+ return this.component ?? this.default ?? null;
107
+ }
108
+ connectedCallback() {
109
+ super.connectedCallback();
110
+ Router_1.routerInstances.add(this);
111
+ this.pathname = window.location.pathname;
112
+ if (this.type !== "field") {
113
+ const mutationObserver = new MutationObserver(this.collectSlottedRoutes);
114
+ mutationObserver.observe(this, {
115
+ attributeFilter: ["slot"],
116
+ attributes: true,
117
+ subtree: true,
118
+ });
119
+ this.collectSlottedRoutes();
120
+ }
121
+ }
122
+ disconnectedCallback() {
123
+ super.disconnectedCallback();
124
+ Router_1.routerInstances.delete(this);
125
+ }
126
+ useRouter() {
127
+ return {
128
+ pathname: this.pathname,
129
+ params: this.params,
130
+ path: this.path,
131
+ component: this.component,
132
+ };
133
+ }
134
+ updated(changedProperties) {
135
+ const shouldDispatch = changedProperties.has("pathname") || changedProperties.has("path");
136
+ if (shouldDispatch) {
137
+ const ur = this.useRouter();
138
+ const noRecord = !this.__cacheRecord.has(this.pathname);
139
+ if (noRecord) {
140
+ this.__cacheRecord.set(this.pathname, ur);
141
+ }
142
+ this.routeChangeCallback?.(ur, noRecord);
143
+ this.dispatchEvent(new CustomEvent("change", { detail: ur }));
144
+ }
145
+ }
146
+ /**
147
+ * Find components from {@linkcode __fieldRouteTree} matching query.
148
+ * @param query Query string.
149
+ * @returns Components or null.
150
+ */
151
+ fieldComponent(query) {
152
+ query ||= this.useWhich(this.pathname);
153
+ this.path = query;
154
+ if (!query) {
155
+ return null;
156
+ }
157
+ this.params = this.parseParams(this.path, this.pathname);
158
+ const route = this.routes.find((r) => r.path === query);
159
+ if (!route) {
160
+ return null;
161
+ }
162
+ return route.component;
163
+ }
164
+ /**
165
+ * Find components from {@linkcode __slottedRouteTree} matching query.
166
+ * @param query Query string.
167
+ * @returns Named slot element template result or null.
168
+ */
169
+ slottedComponent(usedRouteTemplate) {
170
+ const slottedPaths = this._slottedNames;
171
+ usedRouteTemplate ||= this.__slottedRouteTree.useWhich(this.pathname);
172
+ this.path = usedRouteTemplate;
173
+ if (!usedRouteTemplate) {
174
+ return null;
175
+ }
176
+ this.path = slottedPaths.find((s) => s === usedRouteTemplate);
177
+ if (!this.path) {
178
+ return null;
179
+ }
180
+ this.params = this.parseParams(usedRouteTemplate, this.pathname);
181
+ return htmlSlot(this.path);
182
+ }
183
+ /**
184
+ * Reset the route tree, clear cache, collect routes from child elements.
185
+ */
186
+ collectSlottedRoutes() {
187
+ this.__slottedRouteTree = new RouteTree();
188
+ this.clear();
189
+ this._slottedNames.forEach(slotName => {
190
+ this.__slottedRouteTree.insert(slotName);
191
+ });
192
+ }
193
+ /**
194
+ * Reset the route tree, clear cache, collect routes from value.
195
+ */
196
+ collectFieldRoutes(value) {
197
+ this.__fieldRouteTree = new RouteTree();
198
+ this.clear();
199
+ value.forEach(({ path }) => {
200
+ this.__fieldRouteTree.insert(path);
201
+ });
202
+ }
203
+ useWhich(path) {
204
+ return this.__fieldRouteTree.useWhich(this.baseURL + path);
205
+ }
206
+ parseParams(routeTemplate, path) {
207
+ return this.__fieldRouteTree.parseParams(path, routeTemplate);
208
+ }
209
+ static updateAll() {
210
+ this.routerInstances.forEach((i) => {
211
+ i.pathname = window.location.pathname;
212
+ });
213
+ }
214
+ };
215
+ Router.routerInstances = new Set();
216
+ __decorate([
217
+ state()
218
+ ], Router.prototype, "component", void 0);
219
+ __decorate([
220
+ state()
221
+ ], Router.prototype, "params", void 0);
222
+ __decorate([
223
+ state()
224
+ ], Router.prototype, "path", void 0);
225
+ __decorate([
226
+ property()
227
+ ], Router.prototype, "pathname", void 0);
228
+ __decorate([
229
+ property()
230
+ ], Router.prototype, "baseURL", void 0);
231
+ __decorate([
232
+ state()
233
+ ], Router.prototype, "default", void 0);
234
+ __decorate([
235
+ property()
236
+ ], Router.prototype, "type", void 0);
237
+ __decorate([
238
+ property({ type: Boolean })
239
+ ], Router.prototype, "cache", void 0);
240
+ __decorate([
241
+ state()
242
+ ], Router.prototype, "routes", null);
243
+ Router = Router_1 = __decorate([
244
+ godown(protoName),
245
+ styles(css `:host{display:contents;}`)
246
+ ], Router);
247
+ export default Router;
248
+ //# sourceMappingURL=router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.js","sourceRoot":"","sources":["../../src/components/router.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,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AAA,0BAA0B,CAAC;GAChC,MAAM,CAoOX;AAED,eAAe,MAAM,CAAC"}
@@ -0,0 +1,50 @@
1
+ import { HandlerEvent } from "@godown/element";
2
+ import Input from "./input.js";
3
+ /**
4
+ * {@linkcode Select} is similar to <select>.
5
+ *
6
+ * Elements with the value attribute/property can be used as options.
7
+ *
8
+ * The checked attribute will be added to the selected element.
9
+ *
10
+ * Multi-selected state looks the same as single-selected.
11
+ *
12
+ * Input will filter the element.
13
+ *
14
+ * @slot - Options.
15
+ * @category input
16
+ */
17
+ declare class Select extends Input {
18
+ _cache: WeakMap<HTMLElement, boolean>;
19
+ value: string | string[];
20
+ /**
21
+ * Open content.
22
+ */
23
+ open: boolean;
24
+ /**
25
+ * Selected texts.
26
+ */
27
+ text: string;
28
+ _content: HTMLElement;
29
+ visible: boolean;
30
+ direction: "top" | "bottom" | undefined;
31
+ multiple: boolean;
32
+ protected autoDirection: "top" | "bottom";
33
+ protected lastChecked: HTMLElement;
34
+ protected defaultText: string;
35
+ protected defaultChecked: HTMLElement[];
36
+ private _store;
37
+ protected render(): import("lit").TemplateResult<1>;
38
+ protected _handleFocus(): void;
39
+ protected _connectedInit(): void;
40
+ reset(): void;
41
+ select(value: string, text?: string): 0 | 1;
42
+ filter(query?: string): void;
43
+ filterCallback(element: HTMLElement, match: boolean, query: string): void;
44
+ protected _handleInput(e: HandlerEvent<HTMLInputElement>): void;
45
+ focus(options?: FocusOptions): void;
46
+ blur(): void;
47
+ optionValue(option: HTMLElement): string;
48
+ }
49
+ export default Select;
50
+ //# sourceMappingURL=select.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../src/components/select.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAU/C,OAAO,KAAK,MAAM,YAAY,CAAC;AAyB/B;;;;;;;;;;;;;GAaG;AACH,cAsBM,MAAO,SAAQ,KAAK;IACxB,MAAM,gCAAuC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