godown 3.0.0-canary.16 → 3.0.0-canary.17

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/badge.d.ts +9 -0
  2. package/badge.d.ts.map +1 -0
  3. package/badge.js +2 -0
  4. package/badge.js.map +1 -0
  5. package/components/alert.d.ts.map +1 -1
  6. package/components/alert.js +1 -1
  7. package/components/alert.js.map +1 -1
  8. package/components/avatar.d.ts.map +1 -1
  9. package/components/avatar.js +1 -1
  10. package/components/avatar.js.map +1 -1
  11. package/components/badge.d.ts +19 -0
  12. package/components/badge.d.ts.map +1 -0
  13. package/components/badge.js +2 -0
  14. package/components/badge.js.map +1 -0
  15. package/components/breath.d.ts.map +1 -1
  16. package/components/breath.js +1 -1
  17. package/components/breath.js.map +1 -1
  18. package/components/button.d.ts.map +1 -1
  19. package/components/button.js +1 -1
  20. package/components/button.js.map +1 -1
  21. package/components/card.d.ts.map +1 -1
  22. package/components/card.js +1 -1
  23. package/components/card.js.map +1 -1
  24. package/components/carousel.d.ts.map +1 -1
  25. package/components/carousel.js +1 -1
  26. package/components/carousel.js.map +1 -1
  27. package/components/details.d.ts.map +1 -1
  28. package/components/details.js +1 -1
  29. package/components/details.js.map +1 -1
  30. package/components/dialog.d.ts +1 -1
  31. package/components/dialog.d.ts.map +1 -1
  32. package/components/dialog.js +1 -1
  33. package/components/dialog.js.map +1 -1
  34. package/components/divider.d.ts.map +1 -1
  35. package/components/divider.js +1 -1
  36. package/components/divider.js.map +1 -1
  37. package/components/dragbox.d.ts +1 -1
  38. package/components/dragbox.d.ts.map +1 -1
  39. package/components/dragbox.js +1 -1
  40. package/components/dragbox.js.map +1 -1
  41. package/components/flex.d.ts.map +1 -1
  42. package/components/flex.js +1 -1
  43. package/components/flex.js.map +1 -1
  44. package/components/form.d.ts.map +1 -1
  45. package/components/form.js +1 -1
  46. package/components/form.js.map +1 -1
  47. package/components/grid.d.ts.map +1 -1
  48. package/components/grid.js +1 -1
  49. package/components/grid.js.map +1 -1
  50. package/components/heading.d.ts +19 -0
  51. package/components/heading.d.ts.map +1 -0
  52. package/components/heading.js +2 -0
  53. package/components/heading.js.map +1 -0
  54. package/components/input.d.ts.map +1 -1
  55. package/components/input.js +1 -1
  56. package/components/input.js.map +1 -1
  57. package/components/layout.d.ts.map +1 -1
  58. package/components/layout.js +1 -1
  59. package/components/layout.js.map +1 -1
  60. package/components/link.js +1 -1
  61. package/components/link.js.map +1 -1
  62. package/components/progress.d.ts.map +1 -1
  63. package/components/progress.js +1 -1
  64. package/components/progress.js.map +1 -1
  65. package/components/range.d.ts.map +1 -1
  66. package/components/range.js +1 -1
  67. package/components/range.js.map +1 -1
  68. package/components/rotate.d.ts.map +1 -1
  69. package/components/rotate.js +1 -1
  70. package/components/rotate.js.map +1 -1
  71. package/components/router.d.ts.map +1 -1
  72. package/components/router.js +1 -1
  73. package/components/router.js.map +1 -1
  74. package/components/select.d.ts +1 -1
  75. package/components/select.d.ts.map +1 -1
  76. package/components/select.js +1 -1
  77. package/components/select.js.map +1 -1
  78. package/components/skeleton.d.ts.map +1 -1
  79. package/components/skeleton.js +1 -1
  80. package/components/skeleton.js.map +1 -1
  81. package/components/split.d.ts +2 -1
  82. package/components/split.d.ts.map +1 -1
  83. package/components/split.js +1 -1
  84. package/components/split.js.map +1 -1
  85. package/components/switch.d.ts.map +1 -1
  86. package/components/switch.js +1 -1
  87. package/components/switch.js.map +1 -1
  88. package/components/text.d.ts.map +1 -1
  89. package/components/text.js +1 -1
  90. package/components/text.js.map +1 -1
  91. package/components/time.d.ts.map +1 -1
  92. package/components/time.js +1 -1
  93. package/components/time.js.map +1 -1
  94. package/components/tooltip.d.ts.map +1 -1
  95. package/components/tooltip.js +1 -1
  96. package/components/tooltip.js.map +1 -1
  97. package/components/typewriter.d.ts.map +1 -1
  98. package/components/typewriter.js +1 -1
  99. package/components/typewriter.js.map +1 -1
  100. package/core/global-style.d.ts +1 -1
  101. package/core/global-style.d.ts.map +1 -1
  102. package/core/global-style.js +1 -1
  103. package/core/global-style.js.map +1 -1
  104. package/core/super-anchor.d.ts.map +1 -1
  105. package/core/super-anchor.js +1 -1
  106. package/core/super-anchor.js.map +1 -1
  107. package/core/super-input.d.ts +1 -1
  108. package/core/super-input.d.ts.map +1 -1
  109. package/core/super-input.js +1 -1
  110. package/core/super-input.js.map +1 -1
  111. package/custom-elements.json +1 -1
  112. package/dev/badge.d.ts +9 -0
  113. package/dev/badge.d.ts.map +1 -0
  114. package/dev/badge.js +5 -0
  115. package/dev/badge.js.map +1 -0
  116. package/dev/components/alert.d.ts.map +1 -1
  117. package/dev/components/alert.js +1 -6
  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 +1 -5
  121. package/dev/components/avatar.js.map +1 -1
  122. package/dev/components/badge.d.ts +19 -0
  123. package/dev/components/badge.d.ts.map +1 -0
  124. package/dev/components/badge.js +106 -0
  125. package/dev/components/badge.js.map +1 -0
  126. package/dev/components/breath.d.ts.map +1 -1
  127. package/dev/components/breath.js +1 -4
  128. package/dev/components/breath.js.map +1 -1
  129. package/dev/components/button.d.ts.map +1 -1
  130. package/dev/components/button.js +4 -12
  131. package/dev/components/button.js.map +1 -1
  132. package/dev/components/card.d.ts.map +1 -1
  133. package/dev/components/card.js +1 -4
  134. package/dev/components/card.js.map +1 -1
  135. package/dev/components/carousel.d.ts.map +1 -1
  136. package/dev/components/carousel.js +1 -6
  137. package/dev/components/carousel.js.map +1 -1
  138. package/dev/components/details.d.ts.map +1 -1
  139. package/dev/components/details.js +1 -4
  140. package/dev/components/details.js.map +1 -1
  141. package/dev/components/dialog.d.ts +1 -1
  142. package/dev/components/dialog.d.ts.map +1 -1
  143. package/dev/components/dialog.js +1 -4
  144. package/dev/components/dialog.js.map +1 -1
  145. package/dev/components/divider.d.ts.map +1 -1
  146. package/dev/components/divider.js +1 -2
  147. package/dev/components/divider.js.map +1 -1
  148. package/dev/components/dragbox.d.ts +1 -1
  149. package/dev/components/dragbox.d.ts.map +1 -1
  150. package/dev/components/dragbox.js +1 -4
  151. package/dev/components/dragbox.js.map +1 -1
  152. package/dev/components/flex.d.ts.map +1 -1
  153. package/dev/components/flex.js +1 -6
  154. package/dev/components/flex.js.map +1 -1
  155. package/dev/components/form.d.ts.map +1 -1
  156. package/dev/components/form.js +1 -3
  157. package/dev/components/form.js.map +1 -1
  158. package/dev/components/grid.d.ts.map +1 -1
  159. package/dev/components/grid.js +1 -7
  160. package/dev/components/grid.js.map +1 -1
  161. package/dev/components/heading.d.ts +19 -0
  162. package/dev/components/heading.d.ts.map +1 -0
  163. package/dev/components/heading.js +86 -0
  164. package/dev/components/heading.js.map +1 -0
  165. package/dev/components/input.d.ts.map +1 -1
  166. package/dev/components/input.js +1 -5
  167. package/dev/components/input.js.map +1 -1
  168. package/dev/components/layout.d.ts.map +1 -1
  169. package/dev/components/layout.js +1 -4
  170. package/dev/components/layout.js.map +1 -1
  171. package/dev/components/link.js +1 -1
  172. package/dev/components/link.js.map +1 -1
  173. package/dev/components/progress.d.ts.map +1 -1
  174. package/dev/components/progress.js +1 -4
  175. package/dev/components/progress.js.map +1 -1
  176. package/dev/components/range.d.ts.map +1 -1
  177. package/dev/components/range.js +1 -7
  178. package/dev/components/range.js.map +1 -1
  179. package/dev/components/rotate.d.ts.map +1 -1
  180. package/dev/components/rotate.js +1 -4
  181. package/dev/components/rotate.js.map +1 -1
  182. package/dev/components/router.d.ts.map +1 -1
  183. package/dev/components/router.js +1 -4
  184. package/dev/components/router.js.map +1 -1
  185. package/dev/components/select.d.ts +1 -1
  186. package/dev/components/select.d.ts.map +1 -1
  187. package/dev/components/select.js +2 -7
  188. package/dev/components/select.js.map +1 -1
  189. package/dev/components/skeleton.d.ts.map +1 -1
  190. package/dev/components/skeleton.js +1 -4
  191. package/dev/components/skeleton.js.map +1 -1
  192. package/dev/components/split.d.ts +2 -1
  193. package/dev/components/split.d.ts.map +1 -1
  194. package/dev/components/split.js +2 -4
  195. package/dev/components/split.js.map +1 -1
  196. package/dev/components/switch.d.ts.map +1 -1
  197. package/dev/components/switch.js +1 -3
  198. package/dev/components/switch.js.map +1 -1
  199. package/dev/components/text.d.ts.map +1 -1
  200. package/dev/components/text.js +1 -5
  201. package/dev/components/text.js.map +1 -1
  202. package/dev/components/time.d.ts.map +1 -1
  203. package/dev/components/time.js +1 -3
  204. package/dev/components/time.js.map +1 -1
  205. package/dev/components/tooltip.d.ts.map +1 -1
  206. package/dev/components/tooltip.js +1 -4
  207. package/dev/components/tooltip.js.map +1 -1
  208. package/dev/components/typewriter.d.ts.map +1 -1
  209. package/dev/components/typewriter.js +1 -6
  210. package/dev/components/typewriter.js.map +1 -1
  211. package/dev/core/global-style.d.ts +1 -1
  212. package/dev/core/global-style.d.ts.map +1 -1
  213. package/dev/core/global-style.js +1 -3
  214. package/dev/core/global-style.js.map +1 -1
  215. package/dev/core/super-anchor.d.ts.map +1 -1
  216. package/dev/core/super-anchor.js +3 -6
  217. package/dev/core/super-anchor.js.map +1 -1
  218. package/dev/core/super-input.d.ts +1 -1
  219. package/dev/core/super-input.d.ts.map +1 -1
  220. package/dev/core/super-input.js +1 -3
  221. package/dev/core/super-input.js.map +1 -1
  222. package/dev/heading.d.ts +9 -0
  223. package/dev/heading.d.ts.map +1 -0
  224. package/dev/heading.js +5 -0
  225. package/dev/heading.js.map +1 -0
  226. package/dev/index.d.ts +2 -0
  227. package/dev/index.d.ts.map +1 -1
  228. package/dev/index.js +2 -0
  229. package/dev/index.js.map +1 -1
  230. package/heading.d.ts +9 -0
  231. package/heading.d.ts.map +1 -0
  232. package/heading.js +2 -0
  233. package/heading.js.map +1 -0
  234. package/index.d.ts +2 -0
  235. package/index.d.ts.map +1 -1
  236. package/index.js +1 -1
  237. package/package.json +3 -3
  238. package/split.js +1 -1
  239. package/split.js.map +1 -1
  240. package/src/badge.ts +13 -0
  241. package/src/components/alert.ts +1 -6
  242. package/src/components/avatar.ts +1 -5
  243. package/src/components/badge.ts +104 -0
  244. package/src/components/breath.ts +1 -4
  245. package/src/components/button.ts +4 -12
  246. package/src/components/card.ts +1 -4
  247. package/src/components/carousel.ts +1 -6
  248. package/src/components/details.ts +1 -4
  249. package/src/components/dialog.ts +1 -5
  250. package/src/components/divider.ts +1 -2
  251. package/src/components/dragbox.ts +1 -5
  252. package/src/components/flex.ts +1 -6
  253. package/src/components/form.ts +1 -3
  254. package/src/components/grid.ts +1 -7
  255. package/src/components/heading.ts +89 -0
  256. package/src/components/input.ts +1 -5
  257. package/src/components/layout.ts +1 -4
  258. package/src/components/link.ts +1 -1
  259. package/src/components/progress.ts +1 -4
  260. package/src/components/range.ts +1 -7
  261. package/src/components/rotate.ts +1 -4
  262. package/src/components/router.ts +1 -4
  263. package/src/components/select.ts +2 -8
  264. package/src/components/skeleton.ts +1 -4
  265. package/src/components/split.ts +2 -5
  266. package/src/components/switch.ts +1 -3
  267. package/src/components/text.ts +1 -5
  268. package/src/components/time.ts +1 -3
  269. package/src/components/tooltip.ts +1 -4
  270. package/src/components/typewriter.ts +1 -6
  271. package/src/core/global-style.ts +1 -3
  272. package/src/core/super-anchor.ts +3 -6
  273. package/src/core/super-input.ts +1 -4
  274. package/src/heading.ts +13 -0
  275. package/src/index.ts +2 -0
  276. package/vscode.html-custom-data.json +1 -1
  277. package/web-types.json +1 -1
@@ -0,0 +1,104 @@
1
+ import { attr, godown, htmlSlot, styles } from "@godown/element";
2
+ import { css, html, type TemplateResult } from "lit";
3
+ import { property } from "lit/decorators.js";
4
+
5
+ import { cssGlobalVars, GlobalStyle, scopePrefix } from "../core/global-style.js";
6
+
7
+ type Position = "top-right" | "top-left" | "bottom-right" | "bottom-left";
8
+
9
+ const protoName = "badge";
10
+ const cssScope = scopePrefix(protoName);
11
+
12
+ /**
13
+ * {@linkcode Badge} renders a badge.
14
+ *
15
+ * @category display
16
+ */
17
+ @godown(protoName)
18
+ @styles(
19
+ css`
20
+ :host {
21
+ ${cssScope}--background: var(${cssGlobalVars.active});
22
+ ${cssScope}--offset: 0;
23
+ ${cssScope}--offset-x: var(${cssScope}--offset);
24
+ ${cssScope}--offset-y: var(${cssScope}--offset);
25
+ }
26
+
27
+ :host,
28
+ :host([contents]) [part=root] {
29
+ display: inline-block;
30
+ }
31
+
32
+ [part=root] {
33
+ position: relative;
34
+ }
35
+
36
+ [part=badge] {
37
+ position: absolute;
38
+ border-radius: calc(infinity * 1px);
39
+ background: var(${cssScope}--background);
40
+ font-size: 75%;
41
+ padding: 0 0.5em;
42
+ transform: translate(-50%, -50%);
43
+ }
44
+
45
+ [part=badge]:empty {
46
+ width: 0.5em;
47
+ height: 0.5em;
48
+ font-size: 100%;
49
+ padding: 0;
50
+ border-radius: 50%;
51
+ }
52
+
53
+ [position^=top] {
54
+ --top: calc(0% + var(${cssScope}--offset-y));
55
+ }
56
+
57
+ [position$=right] {
58
+ --left: calc(100% - var(${cssScope}--offset-x));
59
+ }
60
+
61
+ [position^=bottom] {
62
+ --top: calc(100% - var(${cssScope}--offset-y));
63
+ }
64
+
65
+ [position$=left] {
66
+ --left: calc(0% + var(${cssScope}--offset-x));
67
+ }
68
+
69
+ [part=badge] {
70
+ left: var(--left);
71
+ top: var(--top);
72
+ }
73
+ `,
74
+ )
75
+ class Badge extends GlobalStyle {
76
+ @property({ type: String })
77
+ position: Position = "top-right";
78
+
79
+ @property({ type: Number })
80
+ value = 0;
81
+
82
+ @property({ type: Boolean })
83
+ dot = false;
84
+
85
+ @property({ type: Number })
86
+ max = 99;
87
+
88
+ private formatValue(value: number): string {
89
+ return value > this.max ? this.max + "+" : value + "";
90
+ }
91
+
92
+ render(): TemplateResult<1> {
93
+ if (this.value === 0 && !this.dot) {
94
+ return htmlSlot();
95
+ }
96
+ return html`<div part="root" ${attr(this.observedRecord)}>
97
+ ${htmlSlot()}
98
+ <div part="badge">${this.dot ? "" : this.formatValue(this.value)}</div>
99
+ </div>`;
100
+ }
101
+ }
102
+
103
+ export default Badge;
104
+ export { Badge };
@@ -1,7 +1,4 @@
1
- import { godown } from "@godown/element/decorators/godown.js";
2
- import { styles } from "@godown/element/decorators/styles.js";
3
- import { attr } from "@godown/element/directives/attr.js";
4
- import { htmlStyle } from "@godown/element/directives/html-style.js";
1
+ import { attr, godown, htmlStyle, styles } from "@godown/element";
5
2
  import { css, html, type TemplateResult } from "lit";
6
3
  import { property } from "lit/decorators.js";
7
4
 
@@ -1,10 +1,4 @@
1
- import { godown } from "@godown/element/decorators/godown.js";
2
- import { part } from "@godown/element/decorators/part.js";
3
- import { styles } from "@godown/element/decorators/styles.js";
4
- import { attr } from "@godown/element/directives/attr.js";
5
- import { htmlSlot } from "@godown/element/directives/html-slot.js";
6
- import { htmlStyle } from "@godown/element/directives/html-style.js";
7
- import { constructCSSObject, toVar } from "@godown/element/tools/css.js";
1
+ import { attr, constructCSSObject, godown, htmlSlot, htmlStyle, part, styles, toVar } from "@godown/element";
8
2
  import { css, html, type TemplateResult } from "lit";
9
3
  import { property } from "lit/decorators.js";
10
4
 
@@ -134,7 +128,6 @@ const colors: Record<Colors, string> = constructCSSObject(
134
128
  var(${cssScope}--gradients, var(${cssScope}--background))
135
129
  );
136
130
  border-radius: 0.3em;
137
- width: -moz-fit-content;
138
131
  width: fit-content;
139
132
  transition: 0.1s;
140
133
  display: block;
@@ -271,10 +264,9 @@ class Button extends GlobalStyle {
271
264
 
272
265
  protected _handleModal(e: MouseEvent): void {
273
266
  const modal = document.createElement("i");
274
- const rect = this.getBoundingClientRect();
275
- const h = rect.height;
276
- const w = rect.width;
277
- const size = `${Math.sqrt(h * h + w * w) * 2}px`;
267
+ const rect = this._root.getBoundingClientRect();
268
+ const { height, width } = rect;
269
+ const size = `${Math.sqrt(height * height + width * width) * 2}px`;
278
270
  modal.style.height = size;
279
271
  modal.style.width = size;
280
272
  modal.style.left = `${e.clientX - rect.left}px`;
@@ -1,7 +1,4 @@
1
- import { godown } from "@godown/element/decorators/godown.js";
2
- import { styles } from "@godown/element/decorators/styles.js";
3
- import { attr } from "@godown/element/directives/attr.js";
4
- import { htmlSlot } from "@godown/element/directives/html-slot.js";
1
+ import { attr, godown, htmlSlot, styles } from "@godown/element";
5
2
  import { css, html, type TemplateResult } from "lit";
6
3
  import { property } from "lit/decorators.js";
7
4
 
@@ -1,9 +1,4 @@
1
- import { godown } from "@godown/element/decorators/godown.js";
2
- import { part } from "@godown/element/decorators/part.js";
3
- import { styles } from "@godown/element/decorators/styles.js";
4
- import { attr } from "@godown/element/directives/attr.js";
5
- import { htmlSlot } from "@godown/element/directives/html-slot.js";
6
- import { htmlStyle } from "@godown/element/directives/html-style.js";
1
+ import { attr, godown, htmlSlot, htmlStyle, part, styles } from "@godown/element";
7
2
  import iconChevronLeft from "@godown/f7-icon/icons/chevron-left.js";
8
3
  import iconChevronRight from "@godown/f7-icon/icons/chevron-right.js";
9
4
  import { css, html, type TemplateResult } from "lit";
@@ -1,7 +1,4 @@
1
- import { godown } from "@godown/element/decorators/godown.js";
2
- import { styles } from "@godown/element/decorators/styles.js";
3
- import { attr } from "@godown/element/directives/attr.js";
4
- import { htmlSlot } from "@godown/element/directives/html-slot.js";
1
+ import { attr, godown, htmlSlot, styles } from "@godown/element";
5
2
  import svgCaretDown from "@godown/f7-icon/icons/chevron-down.js";
6
3
  import { css, html, type TemplateResult } from "lit";
7
4
  import { property } from "lit/decorators.js";
@@ -1,8 +1,4 @@
1
- import type { HandlerEvent } from "@godown/element";
2
- import { godown } from "@godown/element/decorators/godown.js";
3
- import { styles } from "@godown/element/decorators/styles.js";
4
- import { attr } from "@godown/element/directives/attr.js";
5
- import { htmlSlot } from "@godown/element/directives/html-slot.js";
1
+ import { attr, godown, type HandlerEvent, htmlSlot, styles } from "@godown/element";
6
2
  import { css, html, type PropertyValues, type TemplateResult } from "lit";
7
3
  import { property } from "lit/decorators.js";
8
4
 
@@ -1,5 +1,4 @@
1
- import { godown, styles } from "@godown/element/decorators/index.js";
2
- import { attr } from "@godown/element/directives/attr.js";
1
+ import { attr, godown, styles } from "@godown/element";
3
2
  import { css, html, type TemplateResult } from "lit";
4
3
  import { property } from "lit/decorators.js";
5
4
 
@@ -1,8 +1,4 @@
1
- import { godown } from "@godown/element/decorators/godown.js";
2
- import { styles } from "@godown/element/decorators/styles.js";
3
- import { attr } from "@godown/element/directives/attr.js";
4
- import { htmlSlot } from "@godown/element/directives/html-slot.js";
5
- import type { EventListenerFunc } from "@godown/element/tools/events.js";
1
+ import { attr, type EventListenerFunc, godown, htmlSlot, styles } from "@godown/element";
6
2
  import { css, html, type TemplateResult } from "lit";
7
3
  import { property } from "lit/decorators.js";
8
4
 
@@ -1,9 +1,4 @@
1
- import { godown } from "@godown/element/decorators/godown.js";
2
- import { styles } from "@godown/element/decorators/styles.js";
3
- import { attr } from "@godown/element/directives/attr.js";
4
- import { htmlSlot } from "@godown/element/directives/html-slot.js";
5
- import { htmlStyle } from "@godown/element/directives/html-style.js";
6
- import { joinRules } from "@godown/element/tools/css.js";
1
+ import { attr, godown, htmlSlot, htmlStyle, joinRules, styles } from "@godown/element";
7
2
  import { css, html, type TemplateResult } from "lit";
8
3
  import { property } from "lit/decorators.js";
9
4
 
@@ -1,6 +1,4 @@
1
- import { godown } from "@godown/element/decorators/godown.js";
2
- import { styles } from "@godown/element/decorators/styles.js";
3
- import { htmlSlot } from "@godown/element/directives/html-slot.js";
1
+ import { godown, htmlSlot, styles } from "@godown/element";
4
2
  import { css, type TemplateResult } from "lit";
5
3
  import { property } from "lit/decorators.js";
6
4
 
@@ -1,10 +1,4 @@
1
- import { godown } from "@godown/element/decorators/godown.js";
2
- import { styles } from "@godown/element/decorators/styles.js";
3
- import { attr } from "@godown/element/directives/attr.js";
4
- import { htmlSlot } from "@godown/element/directives/html-slot.js";
5
- import { htmlStyle } from "@godown/element/directives/html-style.js";
6
- import { joinRules } from "@godown/element/tools/css.js";
7
- import { isNumerical } from "@godown/element/tools/lib.js";
1
+ import { attr, godown, htmlSlot, htmlStyle, isNumerical, joinRules, styles } from "@godown/element";
8
2
  import { css, html, type TemplateResult } from "lit";
9
3
  import { property } from "lit/decorators.js";
10
4
 
@@ -0,0 +1,89 @@
1
+ import { attr, godown, htmlSlot, styles } from "@godown/element";
2
+ import { css, html, type TemplateResult } from "lit";
3
+ import { property } from "lit/decorators.js";
4
+
5
+ import { GlobalStyle } from "../core/global-style.js";
6
+
7
+ const protoName = "heading";
8
+
9
+ /**
10
+ * {@linkcode Heading} renders a heading.
11
+ *
12
+ * If the id is provided, the anchor will be displayed.
13
+ *
14
+ * @slot - The content of the heading.
15
+ * @category layout
16
+ */
17
+ @godown(protoName)
18
+ @styles(
19
+ css`
20
+ :host {
21
+ display: block;
22
+ text-align: start;
23
+ }
24
+
25
+ [part=root] {
26
+ position: relative;
27
+ }
28
+
29
+ a {
30
+ color: inherit;
31
+ position: absolute;
32
+ inset: 0;
33
+ }
34
+
35
+ [part=anchor] {
36
+ position: absolute;
37
+ text-align: center;
38
+ min-width: 1.25em;
39
+ right: 100%;
40
+ }
41
+
42
+ h1,
43
+ h2,
44
+ h3,
45
+ h4,
46
+ h5,
47
+ h6 {
48
+ font-size: revert;
49
+ }
50
+ `,
51
+ )
52
+ class Heading extends GlobalStyle {
53
+ @property({ type: String })
54
+ as: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" = "h1";
55
+
56
+ @property({ type: String })
57
+ anchor = "#";
58
+
59
+ protected render(): TemplateResult<1> {
60
+ return html`<div part="root" ${attr(this.observedRecord)}>
61
+ ${
62
+ this.wrapHeading(
63
+ this.id ? html`<a href="#${this.id}"><i part="anchor">${this.anchor}</i></a>` : "",
64
+ html`<p>${htmlSlot()}</p>`,
65
+ )
66
+ }
67
+ </div> `;
68
+ }
69
+
70
+ protected wrapHeading(...children: any[]): TemplateResult<1> {
71
+ switch (this.as) {
72
+ case "h2":
73
+ return html`<h2>${children}</h2>`;
74
+ case "h3":
75
+ return html`<h3>${children}</h3>`;
76
+ case "h4":
77
+ return html`<h4>${children}</h4>`;
78
+ case "h5":
79
+ return html`<h5>${children}</h5>`;
80
+ case "h6":
81
+ return html`<h6>${children}</h6>`;
82
+ default:
83
+ return html`<h1>${children}</h1>`;
84
+ }
85
+ }
86
+ }
87
+
88
+ export default Heading;
89
+ export { Heading };
@@ -1,8 +1,4 @@
1
- import { godown } from "@godown/element/decorators/godown.js";
2
- import { part } from "@godown/element/decorators/part.js";
3
- import { styles } from "@godown/element/decorators/styles.js";
4
- import { attr } from "@godown/element/directives/attr.js";
5
- import { classList } from "@godown/element/directives/class-list.js";
1
+ import { attr, classList, godown, part, styles } from "@godown/element";
6
2
  import { css, html, nothing, type TemplateResult } from "lit";
7
3
  import { property } from "lit/decorators.js";
8
4
 
@@ -1,7 +1,4 @@
1
- import { godown } from "@godown/element/decorators/godown.js";
2
- import { styles } from "@godown/element/decorators/styles.js";
3
- import { attr } from "@godown/element/directives/attr.js";
4
- import { htmlSlot } from "@godown/element/directives/html-slot.js";
1
+ import { attr, godown, htmlSlot, styles } from "@godown/element";
5
2
  import { css, html, type TemplateResult } from "lit";
6
3
  import { property } from "lit/decorators.js";
7
4
 
@@ -1,4 +1,4 @@
1
- import { godown } from "@godown/element/decorators/godown.js";
1
+ import { godown } from "@godown/element";
2
2
  import { property } from "lit/decorators.js";
3
3
 
4
4
  import SuperAnchor from "../core/super-anchor.js";
@@ -1,7 +1,4 @@
1
- import { godown } from "@godown/element/decorators/godown.js";
2
- import { styles } from "@godown/element/decorators/styles.js";
3
- import { attr } from "@godown/element/directives/attr.js";
4
- import { isNil } from "@godown/element/tools/lib.js";
1
+ import { attr, godown, isNil, styles } from "@godown/element";
5
2
  import { css, html, type TemplateResult } from "lit";
6
3
  import { property } from "lit/decorators.js";
7
4
 
@@ -1,10 +1,4 @@
1
- import { godown } from "@godown/element/decorators/godown.js";
2
- import { part } from "@godown/element/decorators/part.js";
3
- import { styles } from "@godown/element/decorators/styles.js";
4
- import { attr } from "@godown/element/directives/attr.js";
5
- import { classList } from "@godown/element/directives/class-list.js";
6
- import { joinProperties } from "@godown/element/tools/css.js";
7
- import { isNil } from "@godown/element/tools/lib.js";
1
+ import { attr, classList, godown, isNil, joinProperties, part, styles } from "@godown/element";
8
2
  import { css, html, type TemplateResult } from "lit";
9
3
  import { property, queryAll, state } from "lit/decorators.js";
10
4
 
@@ -1,7 +1,4 @@
1
- import { godown } from "@godown/element/decorators/godown.js";
2
- import { part } from "@godown/element/decorators/part.js";
3
- import { styles } from "@godown/element/decorators/styles.js";
4
- import { htmlSlot } from "@godown/element/directives/html-slot.js";
1
+ import { godown, htmlSlot, part, styles } from "@godown/element";
5
2
  import { css, html, type TemplateResult } from "lit";
6
3
 
7
4
  import { GlobalStyle, scopePrefix } from "../core/global-style.js";
@@ -1,7 +1,4 @@
1
- import { godown } from "@godown/element/decorators/godown.js";
2
- import { styles } from "@godown/element/decorators/styles.js";
3
- import { htmlSlot } from "@godown/element/directives/html-slot.js";
4
- import { RouteTree } from "@godown/element/tools/route-tree.js";
1
+ import { godown, htmlSlot, RouteTree, styles } from "@godown/element";
5
2
  import { css, type PropertyValueMap, type TemplateResult } from "lit";
6
3
  import { property, state } from "lit/decorators.js";
7
4
 
@@ -1,13 +1,7 @@
1
- import type { HandlerEvent } from "@godown/element";
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 { attr } from "@godown/element/directives/attr.js";
6
- import { htmlSlot } from "@godown/element/directives/html-slot.js";
1
+ import { attr, godown, type HandlerEvent, htmlSlot, part, styles } from "@godown/element";
7
2
  import svgCaretDown from "@godown/f7-icon/icons/chevron-down.js";
8
3
  import { css, html, nothing, type TemplateResult } from "lit";
9
4
  import { property, state } from "lit/decorators.js";
10
- import { ifDefined } from "lit/directives/if-defined.js";
11
5
 
12
6
  import Input from "./input.js";
13
7
 
@@ -122,7 +116,7 @@ class Select extends Input {
122
116
  this._renderPrefix(),
123
117
  html`<input
124
118
  part="input"
125
- dir="${ifDefined(this.dir)}"
119
+ dir="${this.dir || nothing}"
126
120
  id="${this.makeId}"
127
121
  .value="${this.text}"
128
122
  type="${this.type}"
@@ -1,7 +1,4 @@
1
- import { godown } from "@godown/element/decorators/godown.js";
2
- import { styles } from "@godown/element/decorators/styles.js";
3
- import { attr } from "@godown/element/directives/attr.js";
4
- import { htmlSlot } from "@godown/element/directives/html-slot.js";
1
+ import { attr, godown, htmlSlot, styles } from "@godown/element";
5
2
  import iconPhoto from "@godown/f7-icon/icons/photo.js";
6
3
  import { css, html, type TemplateResult } from "lit";
7
4
  import { property, state } from "lit/decorators.js";
@@ -1,8 +1,4 @@
1
- import { godown } from "@godown/element/decorators/godown.js";
2
- import { styles } from "@godown/element/decorators/styles.js";
3
- import { attr } from "@godown/element/directives/attr.js";
4
- import { classList } from "@godown/element/directives/class-list.js";
5
- import type { HandlerEvent } from "@godown/element/element.js";
1
+ import { attr, classList, godown, type HandlerEvent, styles } from "@godown/element";
6
2
  import { css, html, nothing, type TemplateResult } from "lit";
7
3
  import { property, state } from "lit/decorators.js";
8
4
 
@@ -232,3 +228,4 @@ class Split extends SuperInput {
232
228
  }
233
229
 
234
230
  export default Split;
231
+ export { Split };
@@ -1,6 +1,4 @@
1
- import { godown } from "@godown/element/decorators/godown.js";
2
- import { styles } from "@godown/element/decorators/styles.js";
3
- import { attr } from "@godown/element/directives/attr.js";
1
+ import { attr, godown, styles } from "@godown/element";
4
2
  import { css, html, type TemplateResult } from "lit";
5
3
  import { property, query } from "lit/decorators.js";
6
4
 
@@ -1,8 +1,4 @@
1
- import { godown } from "@godown/element/decorators/godown.js";
2
- import { styles } from "@godown/element/decorators/styles.js";
3
- import { attr } from "@godown/element/directives/attr.js";
4
- import { classList } from "@godown/element/directives/class-list.js";
5
- import { htmlSlot } from "@godown/element/directives/html-slot.js";
1
+ import { attr, classList, godown, htmlSlot, styles } from "@godown/element";
6
2
  import { css, html, type TemplateResult } from "lit";
7
3
  import { property } from "lit/decorators.js";
8
4
 
@@ -1,6 +1,4 @@
1
- import { godown } from "@godown/element/decorators/godown.js";
2
- import { styles } from "@godown/element/decorators/styles.js";
3
- import { attr } from "@godown/element/directives/attr.js";
1
+ import { attr, godown, styles } from "@godown/element";
4
2
  import fmtime from "fmtime";
5
3
  import { css, html, type PropertyValues, type TemplateResult } from "lit";
6
4
  import { property } from "lit/decorators.js";
@@ -1,7 +1,4 @@
1
- import { godown } from "@godown/element/decorators/godown.js";
2
- import { styles } from "@godown/element/decorators/styles.js";
3
- import { attr } from "@godown/element/directives/attr.js";
4
- import { htmlSlot } from "@godown/element/directives/html-slot.js";
1
+ import { attr, godown, htmlSlot, styles } from "@godown/element";
5
2
  import { css, html, type TemplateResult } from "lit";
6
3
  import { property } from "lit/decorators.js";
7
4
 
@@ -1,9 +1,4 @@
1
- import { godown } from "@godown/element/decorators/godown.js";
2
- import { styles } from "@godown/element/decorators/styles.js";
3
- import { attr } from "@godown/element/directives/attr.js";
4
- import { classList } from "@godown/element/directives/class-list.js";
5
- import { htmlSlot } from "@godown/element/directives/html-slot.js";
6
- import { random } from "@godown/element/tools/lib.js";
1
+ import { attr, classList, godown, htmlSlot, random, styles } from "@godown/element";
7
2
  import { css, html, type PropertyValueMap, type TemplateResult } from "lit";
8
3
  import { property, query, state } from "lit/decorators.js";
9
4
 
@@ -1,8 +1,6 @@
1
1
  import { type Gradients, presetsRGB } from "@godown/colors/presets-rgb.js";
2
2
  import { travel } from "@godown/colors/travel.js";
3
- import GodownElement from "@godown/element";
4
- import { joinProperties } from "@godown/element/tools/css.js";
5
- import { trim } from "@godown/element/tools/lib.js";
3
+ import { GodownElement, joinProperties, trim } from "@godown/element";
6
4
  import { css, type CSSResult, unsafeCSS } from "lit";
7
5
 
8
6
  export class GlobalStyle extends GodownElement {
@@ -1,9 +1,6 @@
1
- import { styles } from "@godown/element/decorators/index.js";
2
- import { attr } from "@godown/element/directives/attr.js";
3
- import { htmlSlot } from "@godown/element/directives/html-slot.js";
4
- import { css, html, type TemplateResult } from "lit";
1
+ import { attr, htmlSlot, styles } from "@godown/element";
2
+ import { css, html, nothing, type TemplateResult } from "lit";
5
3
  import { property } from "lit/decorators.js";
6
- import { ifDefined } from "lit/directives/if-defined.js";
7
4
 
8
5
  import { GlobalStyle } from "./global-style.js";
9
6
 
@@ -44,7 +41,7 @@ class SuperAnchor extends GlobalStyle {
44
41
  return html`<a
45
42
  part="root"
46
43
  ${attr(this.observedRecord)}
47
- href="${ifDefined(this.href)}"
44
+ href="${this.href || nothing}"
48
45
  target="${this.target}"
49
46
  @click=${this._handleClick}
50
47
  >
@@ -1,7 +1,4 @@
1
- import { part } from "@godown/element/decorators/part.js";
2
- import { styles } from "@godown/element/decorators/styles.js";
3
- import { htmlSlot } from "@godown/element/directives/index.js";
4
- import type { HandlerEvent } from "@godown/element/element.js";
1
+ import { type HandlerEvent, htmlSlot, part, styles } from "@godown/element";
5
2
  import iconEyeSlashFill from "@godown/f7-icon/icons/eye-slash-fill.js";
6
3
  import { css, html, type TemplateResult } from "lit";
7
4
  import { property } from "lit/decorators.js";
package/src/heading.ts ADDED
@@ -0,0 +1,13 @@
1
+ import Heading from "./components/heading.js";
2
+
3
+ Heading.define();
4
+
5
+ export default Heading;
6
+
7
+ export * from "./components/heading.js";
8
+
9
+ declare global {
10
+ interface HTMLElementTagNameMap {
11
+ "godown-heading": Heading;
12
+ }
13
+ }
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { default as Alert } from "./alert.js";
2
2
  export { default as Avatar } from "./avatar.js";
3
+ export { default as Badge } from "./badge.js";
3
4
  export { default as Breath } from "./breath.js";
4
5
  export { default as Button } from "./button.js";
5
6
  export { default as Card } from "./card.js";
@@ -11,6 +12,7 @@ export { default as Dragbox } from "./dragbox.js";
11
12
  export { default as Flex } from "./flex.js";
12
13
  export { default as Form } from "./form.js";
13
14
  export { default as Grid } from "./grid.js";
15
+ export { default as Heading } from "./heading.js";
14
16
  export { default as Input } from "./input.js";
15
17
  export { default as Layout } from "./layout.js";
16
18
  export { default as Link } from "./link.js";