godown 3.10.1 → 3.11.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 (293) hide show
  1. package/README.md +2 -63
  2. package/alert.d.ts.map +1 -1
  3. package/avatar.d.ts.map +1 -1
  4. package/badge.d.ts.map +1 -1
  5. package/breath.d.ts.map +1 -1
  6. package/build/godown+lit.iife.js +14 -14
  7. package/build/godown+lit.iife.js.map +1 -1
  8. package/build/godown+lit.js +14 -14
  9. package/build/godown+lit.js.map +1 -1
  10. package/build/godown+lit.umd.js +14 -14
  11. package/build/godown+lit.umd.js.map +1 -1
  12. package/build/godown.iife.js +9 -9
  13. package/build/godown.js +7 -7
  14. package/build/godown.js.map +1 -1
  15. package/build/godown.umd.js +10 -10
  16. package/build/godown.umd.js.map +1 -1
  17. package/button.d.ts.map +1 -1
  18. package/card.d.ts.map +1 -1
  19. package/carousel.d.ts.map +1 -1
  20. package/chip.d.ts +2 -0
  21. package/chip.d.ts.map +1 -0
  22. package/chip.js +2 -0
  23. package/chip.js.map +1 -0
  24. package/custom-elements.json +1 -1
  25. package/details.d.ts.map +1 -1
  26. package/dialog.d.ts.map +1 -1
  27. package/divider.d.ts.map +1 -1
  28. package/dragbox.d.ts.map +1 -1
  29. package/flex.d.ts.map +1 -1
  30. package/form.d.ts.map +1 -1
  31. package/grid.d.ts.map +1 -1
  32. package/heading.d.ts.map +1 -1
  33. package/index.d.ts +1 -0
  34. package/index.d.ts.map +1 -1
  35. package/index.js +1 -1
  36. package/input.d.ts.map +1 -1
  37. package/internal/direction.d.ts.map +1 -1
  38. package/internal/direction.js.map +1 -1
  39. package/internal/global-style.d.ts +8 -9
  40. package/internal/global-style.d.ts.map +1 -1
  41. package/internal/global-style.js +1 -1
  42. package/internal/global-style.js.map +1 -1
  43. package/internal/icons/caret-down.d.ts +4 -0
  44. package/internal/icons/caret-down.d.ts.map +1 -0
  45. package/internal/icons/caret-down.js +2 -0
  46. package/internal/icons/caret-down.js.map +1 -0
  47. package/internal/icons/caret-left.d.ts +4 -0
  48. package/internal/icons/caret-left.d.ts.map +1 -0
  49. package/internal/icons/caret-left.js +2 -0
  50. package/internal/icons/caret-left.js.map +1 -0
  51. package/internal/icons/caret-right.d.ts +4 -0
  52. package/internal/icons/caret-right.d.ts.map +1 -0
  53. package/internal/icons/caret-right.js +2 -0
  54. package/internal/icons/caret-right.js.map +1 -0
  55. package/internal/icons/eye-slash.d.ts +4 -0
  56. package/internal/icons/eye-slash.d.ts.map +1 -0
  57. package/internal/icons/eye-slash.js +2 -0
  58. package/internal/icons/eye-slash.js.map +1 -0
  59. package/internal/ring.d.ts +19 -0
  60. package/internal/ring.d.ts.map +1 -0
  61. package/internal/ring.js +2 -0
  62. package/internal/ring.js.map +1 -0
  63. package/internal/super-input.d.ts +2 -2
  64. package/internal/super-input.d.ts.map +1 -1
  65. package/internal/super-input.js +1 -1
  66. package/internal/super-input.js.map +1 -1
  67. package/internal/super-openable.d.ts.map +1 -1
  68. package/internal/super-openable.js.map +1 -1
  69. package/layout.d.ts.map +1 -1
  70. package/link.d.ts.map +1 -1
  71. package/package.json +3 -6
  72. package/progress.d.ts.map +1 -1
  73. package/range.d.ts.map +1 -1
  74. package/rotate.d.ts.map +1 -1
  75. package/router.d.ts.map +1 -1
  76. package/select.d.ts.map +1 -1
  77. package/skeleton.d.ts.map +1 -1
  78. package/split.d.ts.map +1 -1
  79. package/src/chip.ts +1 -0
  80. package/src/index.ts +1 -0
  81. package/src/internal/global-style.ts +40 -37
  82. package/src/internal/icons/caret-down.ts +7 -0
  83. package/src/internal/icons/caret-left.ts +7 -0
  84. package/src/internal/icons/caret-right.ts +7 -0
  85. package/src/internal/icons/eye-slash.ts +7 -0
  86. package/src/internal/ring.ts +57 -0
  87. package/src/internal/super-input.ts +9 -70
  88. package/src/web-components/alert/component.ts +16 -195
  89. package/src/web-components/badge/component.ts +7 -92
  90. package/src/web-components/breath/component.ts +8 -8
  91. package/src/web-components/button/component.ts +9 -139
  92. package/src/web-components/card/component.ts +11 -6
  93. package/src/web-components/carousel/component.ts +6 -6
  94. package/src/web-components/chip/component.ts +115 -0
  95. package/src/web-components/chip/definition.ts +11 -0
  96. package/src/web-components/details/component.ts +2 -2
  97. package/src/web-components/divider/component.ts +2 -17
  98. package/src/web-components/heading/component.ts +12 -16
  99. package/src/web-components/input/component.ts +85 -39
  100. package/src/web-components/link/component.ts +53 -3
  101. package/src/web-components/progress/component.ts +2 -1
  102. package/src/web-components/range/component.ts +19 -25
  103. package/src/web-components/rotate/component.ts +2 -3
  104. package/src/web-components/select/component.ts +14 -18
  105. package/src/web-components/select/definition.ts +1 -1
  106. package/src/web-components/skeleton/component.ts +14 -58
  107. package/src/web-components/split/component.ts +16 -14
  108. package/src/web-components/switch/component.ts +4 -7
  109. package/src/web-components/tabs/component.ts +11 -8
  110. package/src/web-components/text/component.ts +2 -2
  111. package/switch.d.ts.map +1 -1
  112. package/tabs.d.ts.map +1 -1
  113. package/text.d.ts.map +1 -1
  114. package/time.d.ts.map +1 -1
  115. package/tooltip.d.ts.map +1 -1
  116. package/typewriter.d.ts.map +1 -1
  117. package/vscode.html-custom-data.json +1 -1
  118. package/web-components/alert/component.d.ts +5 -32
  119. package/web-components/alert/component.d.ts.map +1 -1
  120. package/web-components/alert/component.js +1 -1
  121. package/web-components/alert/component.js.map +1 -1
  122. package/web-components/alert/definition.d.ts.map +1 -1
  123. package/web-components/alert/definition.js.map +1 -1
  124. package/web-components/avatar/component.d.ts.map +1 -1
  125. package/web-components/avatar/component.js.map +1 -1
  126. package/web-components/avatar/definition.d.ts.map +1 -1
  127. package/web-components/avatar/definition.js.map +1 -1
  128. package/web-components/badge/component.d.ts +4 -21
  129. package/web-components/badge/component.d.ts.map +1 -1
  130. package/web-components/badge/component.js +1 -1
  131. package/web-components/badge/component.js.map +1 -1
  132. package/web-components/badge/definition.d.ts.map +1 -1
  133. package/web-components/badge/definition.js.map +1 -1
  134. package/web-components/breath/component.d.ts.map +1 -1
  135. package/web-components/breath/component.js +1 -1
  136. package/web-components/breath/component.js.map +1 -1
  137. package/web-components/breath/definition.d.ts.map +1 -1
  138. package/web-components/breath/definition.js.map +1 -1
  139. package/web-components/button/component.d.ts +0 -18
  140. package/web-components/button/component.d.ts.map +1 -1
  141. package/web-components/button/component.js +1 -1
  142. package/web-components/button/component.js.map +1 -1
  143. package/web-components/button/definition.d.ts.map +1 -1
  144. package/web-components/button/definition.js.map +1 -1
  145. package/web-components/card/component.d.ts +3 -0
  146. package/web-components/card/component.d.ts.map +1 -1
  147. package/web-components/card/component.js +1 -1
  148. package/web-components/card/component.js.map +1 -1
  149. package/web-components/card/definition.d.ts.map +1 -1
  150. package/web-components/card/definition.js.map +1 -1
  151. package/web-components/carousel/component.d.ts.map +1 -1
  152. package/web-components/carousel/component.js +1 -1
  153. package/web-components/carousel/component.js.map +1 -1
  154. package/web-components/carousel/definition.d.ts.map +1 -1
  155. package/web-components/carousel/definition.js.map +1 -1
  156. package/web-components/chip/component.d.ts +31 -0
  157. package/web-components/chip/component.d.ts.map +1 -0
  158. package/web-components/chip/component.js +2 -0
  159. package/web-components/chip/component.js.map +1 -0
  160. package/web-components/chip/definition.d.ts +8 -0
  161. package/web-components/chip/definition.d.ts.map +1 -0
  162. package/web-components/chip/definition.js +2 -0
  163. package/web-components/chip/definition.js.map +1 -0
  164. package/web-components/details/component.d.ts.map +1 -1
  165. package/web-components/details/component.js +1 -1
  166. package/web-components/details/component.js.map +1 -1
  167. package/web-components/details/definition.d.ts.map +1 -1
  168. package/web-components/details/definition.js.map +1 -1
  169. package/web-components/dialog/component.d.ts.map +1 -1
  170. package/web-components/dialog/component.js.map +1 -1
  171. package/web-components/dialog/definition.d.ts.map +1 -1
  172. package/web-components/dialog/definition.js.map +1 -1
  173. package/web-components/divider/component.d.ts.map +1 -1
  174. package/web-components/divider/component.js +1 -1
  175. package/web-components/divider/component.js.map +1 -1
  176. package/web-components/divider/definition.d.ts.map +1 -1
  177. package/web-components/divider/definition.js.map +1 -1
  178. package/web-components/dragbox/component.d.ts.map +1 -1
  179. package/web-components/dragbox/component.js.map +1 -1
  180. package/web-components/dragbox/definition.d.ts.map +1 -1
  181. package/web-components/dragbox/definition.js.map +1 -1
  182. package/web-components/flex/component.d.ts.map +1 -1
  183. package/web-components/flex/component.js.map +1 -1
  184. package/web-components/flex/definition.d.ts.map +1 -1
  185. package/web-components/flex/definition.js.map +1 -1
  186. package/web-components/form/component.d.ts.map +1 -1
  187. package/web-components/form/component.js.map +1 -1
  188. package/web-components/form/definition.d.ts.map +1 -1
  189. package/web-components/form/definition.js.map +1 -1
  190. package/web-components/grid/component.d.ts.map +1 -1
  191. package/web-components/grid/component.js.map +1 -1
  192. package/web-components/grid/definition.d.ts.map +1 -1
  193. package/web-components/grid/definition.js.map +1 -1
  194. package/web-components/heading/component.d.ts +2 -2
  195. package/web-components/heading/component.d.ts.map +1 -1
  196. package/web-components/heading/component.js +1 -1
  197. package/web-components/heading/component.js.map +1 -1
  198. package/web-components/heading/definition.d.ts.map +1 -1
  199. package/web-components/heading/definition.js.map +1 -1
  200. package/web-components/input/component.d.ts +3 -3
  201. package/web-components/input/component.d.ts.map +1 -1
  202. package/web-components/input/component.js +1 -1
  203. package/web-components/input/component.js.map +1 -1
  204. package/web-components/input/definition.d.ts.map +1 -1
  205. package/web-components/input/definition.js.map +1 -1
  206. package/web-components/layout/component.d.ts.map +1 -1
  207. package/web-components/layout/component.js.map +1 -1
  208. package/web-components/layout/definition.d.ts.map +1 -1
  209. package/web-components/layout/definition.js.map +1 -1
  210. package/web-components/link/component.d.ts +13 -2
  211. package/web-components/link/component.d.ts.map +1 -1
  212. package/web-components/link/component.js +1 -1
  213. package/web-components/link/component.js.map +1 -1
  214. package/web-components/link/definition.d.ts.map +1 -1
  215. package/web-components/link/definition.js.map +1 -1
  216. package/web-components/progress/component.d.ts.map +1 -1
  217. package/web-components/progress/component.js +1 -1
  218. package/web-components/progress/component.js.map +1 -1
  219. package/web-components/progress/definition.d.ts.map +1 -1
  220. package/web-components/progress/definition.js.map +1 -1
  221. package/web-components/range/component.d.ts.map +1 -1
  222. package/web-components/range/component.js +1 -1
  223. package/web-components/range/component.js.map +1 -1
  224. package/web-components/range/definition.d.ts.map +1 -1
  225. package/web-components/range/definition.js.map +1 -1
  226. package/web-components/rotate/component.d.ts.map +1 -1
  227. package/web-components/rotate/component.js +1 -1
  228. package/web-components/rotate/component.js.map +1 -1
  229. package/web-components/rotate/definition.d.ts.map +1 -1
  230. package/web-components/rotate/definition.js.map +1 -1
  231. package/web-components/router/component.d.ts.map +1 -1
  232. package/web-components/router/component.js.map +1 -1
  233. package/web-components/router/definition.d.ts.map +1 -1
  234. package/web-components/router/definition.js.map +1 -1
  235. package/web-components/select/component.d.ts +2 -1
  236. package/web-components/select/component.d.ts.map +1 -1
  237. package/web-components/select/component.js +1 -1
  238. package/web-components/select/component.js.map +1 -1
  239. package/web-components/select/definition.d.ts +1 -1
  240. package/web-components/select/definition.d.ts.map +1 -1
  241. package/web-components/select/definition.js.map +1 -1
  242. package/web-components/skeleton/component.d.ts +0 -9
  243. package/web-components/skeleton/component.d.ts.map +1 -1
  244. package/web-components/skeleton/component.js +1 -1
  245. package/web-components/skeleton/component.js.map +1 -1
  246. package/web-components/skeleton/definition.d.ts.map +1 -1
  247. package/web-components/skeleton/definition.js.map +1 -1
  248. package/web-components/split/component.d.ts +1 -1
  249. package/web-components/split/component.d.ts.map +1 -1
  250. package/web-components/split/component.js +1 -1
  251. package/web-components/split/component.js.map +1 -1
  252. package/web-components/split/definition.d.ts.map +1 -1
  253. package/web-components/split/definition.js.map +1 -1
  254. package/web-components/switch/component.d.ts.map +1 -1
  255. package/web-components/switch/component.js +1 -1
  256. package/web-components/switch/component.js.map +1 -1
  257. package/web-components/switch/definition.d.ts.map +1 -1
  258. package/web-components/switch/definition.js.map +1 -1
  259. package/web-components/tabs/component.d.ts +3 -3
  260. package/web-components/tabs/component.d.ts.map +1 -1
  261. package/web-components/tabs/component.js +1 -1
  262. package/web-components/tabs/component.js.map +1 -1
  263. package/web-components/tabs/definition.d.ts.map +1 -1
  264. package/web-components/tabs/definition.js.map +1 -1
  265. package/web-components/text/component.d.ts +1 -1
  266. package/web-components/text/component.d.ts.map +1 -1
  267. package/web-components/text/component.js +1 -1
  268. package/web-components/text/component.js.map +1 -1
  269. package/web-components/text/definition.d.ts.map +1 -1
  270. package/web-components/text/definition.js.map +1 -1
  271. package/web-components/time/component.d.ts.map +1 -1
  272. package/web-components/time/component.js.map +1 -1
  273. package/web-components/time/definition.d.ts.map +1 -1
  274. package/web-components/time/definition.js.map +1 -1
  275. package/web-components/tooltip/component.d.ts.map +1 -1
  276. package/web-components/tooltip/component.js.map +1 -1
  277. package/web-components/tooltip/definition.d.ts.map +1 -1
  278. package/web-components/tooltip/definition.js.map +1 -1
  279. package/web-components/typewriter/component.d.ts.map +1 -1
  280. package/web-components/typewriter/component.js.map +1 -1
  281. package/web-components/typewriter/definition.d.ts.map +1 -1
  282. package/web-components/typewriter/definition.js.map +1 -1
  283. package/web-types.json +1 -1
  284. package/internal/outline.d.ts +0 -19
  285. package/internal/outline.d.ts.map +0 -1
  286. package/internal/outline.js +0 -2
  287. package/internal/outline.js.map +0 -1
  288. package/internal/super-anchor.d.ts +0 -18
  289. package/internal/super-anchor.d.ts.map +0 -1
  290. package/internal/super-anchor.js +0 -2
  291. package/internal/super-anchor.js.map +0 -1
  292. package/src/internal/outline.ts +0 -58
  293. package/src/internal/super-anchor.ts +0 -60
@@ -0,0 +1,7 @@
1
+ import { icon, type IconRenderer } from "@godown/element";
2
+
3
+ const _default: IconRenderer = icon(
4
+ "0 0 256 256",
5
+ )`<path fill="currentColor" d="m181.66 133.66l-80 80a8 8 0 0 1-11.32-11.32L164.69 128L90.34 53.66a8 8 0 0 1 11.32-11.32l80 80a8 8 0 0 1 0 11.32">`;
6
+
7
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import { icon, type IconRenderer } from "@godown/element";
2
+
3
+ const _default: IconRenderer = icon(
4
+ "0 0 256 256",
5
+ )`<path fill="currentColor" d="M53.92 34.62a8 8 0 1 0-11.84 10.76l19.24 21.17C25 88.84 9.38 123.2 8.69 124.76a8 8 0 0 0 0 6.5c.35.79 8.82 19.57 27.65 38.4C61.43 194.74 93.12 208 128 208a127.1 127.1 0 0 0 52.07-10.83l22 24.21a8 8 0 1 0 11.84-10.76Zm47.33 75.84l41.67 45.85a32 32 0 0 1-41.67-45.85M128 192c-30.78 0-57.67-11.19-79.93-33.25A133.2 133.2 0 0 1 25 128c4.69-8.79 19.66-33.39 47.35-49.38l18 19.75a48 48 0 0 0 63.66 70l14.73 16.2A112 112 0 0 1 128 192m6-95.43a8 8 0 0 1 3-15.72a48.16 48.16 0 0 1 38.77 42.64a8 8 0 0 1-7.22 8.71a6 6 0 0 1-.75 0a8 8 0 0 1-8-7.26A32.09 32.09 0 0 0 134 96.57m113.28 34.69c-.42.94-10.55 23.37-33.36 43.8a8 8 0 1 1-10.67-11.92a132.8 132.8 0 0 0 27.8-35.14a133.2 133.2 0 0 0-23.12-30.77C185.67 75.19 158.78 64 128 64a118.4 118.4 0 0 0-19.36 1.57A8 8 0 1 1 106 49.79A134 134 0 0 1 128 48c34.88 0 66.57 13.26 91.66 38.35c18.83 18.83 27.3 37.62 27.65 38.41a8 8 0 0 1 0 6.5Z">`;
6
+
7
+ export default _default;
@@ -0,0 +1,57 @@
1
+ import { toVar } from "@godown/element";
2
+ import { cssGlobalVars } from "./global-style.js";
3
+ import { unsafeCSS, type CSSResult } from "lit";
4
+
5
+ type OutlineOptions = {
6
+ width?: string | CSSResult;
7
+ color?: string | CSSResult;
8
+ selector?: string;
9
+ type?: RingType;
10
+ };
11
+
12
+ const outlineRing = ({ width, color, inset }) =>
13
+ `outline-style:solid;outline-color:${color};outline-width:${width};${inset ? `outline-offset:calc(-1 * ${width});` : ""}`;
14
+
15
+ const borderRing = ({ width, color }) =>
16
+ `border-style:solid;border-color:${color};border-width:${width};border-style:solid;`;
17
+
18
+ const shadowRing = ({ width, color, inset }) => `box-shadow:${inset ? "inset" : ""} 0 0 0 ${width} ${color};`;
19
+
20
+ const ringMap = {
21
+ outline: (width, color) => outlineRing({ width, color, inset: false }),
22
+ "outline-inset": (width, color) => outlineRing({ width, color, inset: true }),
23
+ "box-shadow": (width, color) => shadowRing({ width, color, inset: false }),
24
+ shadow: (width, color) => shadowRing({ width, color, inset: false }),
25
+ "box-shadow-inset": (width, color) => shadowRing({ width, color, inset: true }),
26
+ "shadow-inset": (width, color) => shadowRing({ width, color, inset: true }),
27
+ border: (width, color) => borderRing({ width, color }),
28
+ };
29
+
30
+ /**
31
+ * The {@link RingBuilder} class is responsible for generating CSS styles for various types of outline/border/shadow.
32
+ */
33
+ export class RingBuilder {
34
+ css: string;
35
+
36
+ constructor({
37
+ selector = ":host",
38
+ width = toVar(cssGlobalVars.ringWidth),
39
+ color = toVar(cssGlobalVars.ringColor),
40
+ type,
41
+ }: OutlineOptions = {}) {
42
+ if (type && type in ringMap) {
43
+ const style = ringMap[type](width, color);
44
+ this.css = `${selector}{${style}}`;
45
+ } else {
46
+ this.css = "";
47
+ }
48
+ }
49
+
50
+ get styleSheet(): CSSStyleSheet {
51
+ return unsafeCSS(this.css).styleSheet;
52
+ }
53
+ }
54
+
55
+ export type RingType = "outline" | "outline-inset" | "shadow" | "shadow-inset" | "border" | "none" | undefined;
56
+
57
+ export const isNone = (type: RingType): boolean => !type || type === "none";
@@ -1,67 +1,16 @@
1
- import { type HandlerEvent, htmlSlot, omit, part, styles } from "@godown/element";
1
+ import { type HandlerEvent, htmlSlot, omit, queryPart, styles } from "@godown/element";
2
2
  import { type TemplateResult, css, html } from "lit";
3
3
  import { property } from "lit/decorators.js";
4
4
 
5
- import { GlobalStyle, cssGlobalVars } from "./global-style.js";
6
- import type { OutlineType } from "./outline.js";
7
-
8
- const fieldStyle = css`
9
- .input-field {
10
- display: flex;
11
- position: relative;
12
- align-items: center;
13
- border-radius: inherit;
14
- height: inherit;
15
- }
16
-
17
- .input-field [part="input"] {
18
- background: none;
19
- height: 100%;
20
- width: 100%;
21
- color: inherit;
22
- padding: var(${cssGlobalVars.input}-space);
23
- }
24
-
25
- .input-field [part="icon"] {
26
- display: flex;
27
- align-items: center;
28
- justify-content: center;
29
- color: var(${cssGlobalVars.input}-icon-color);
30
- }
31
-
32
- .input-field [part="prefix"],
33
- .input-field [part="suffix"] {
34
- height: 100%;
35
- display: flex;
36
- }
37
-
38
- .input-field [part="suffix"] [part="icon"] {
39
- padding-inline-end: var(${cssGlobalVars.input}-space);
40
- }
41
-
42
- .input-field [part="prefix"] [part="icon"] {
43
- padding-inline-start: var(${cssGlobalVars.input}-space);
44
- }
45
- `;
5
+ import { GlobalStyle } from "./global-style.js";
6
+ import type { RingType } from "./ring.js";
46
7
 
47
8
  const inputStyle = css`
48
- :host {
49
- ${cssGlobalVars.input}-width: 10em;
50
- ${cssGlobalVars.input}-height: 1.6em;
51
- ${cssGlobalVars.input}-space: 0.2em;
52
- ${cssGlobalVars.input}-control: currentColor;
53
- ${cssGlobalVars.input}-icon-color: var(${cssGlobalVars._colors.darkgray[4]});
54
- }
55
-
56
9
  :host([disabled]) {
57
10
  cursor: not-allowed;
58
11
  filter: brightness(0.85);
59
12
  }
60
13
 
61
- :host(:focus-within) {
62
- ${cssGlobalVars.input}-icon-color: currentColor;
63
- }
64
-
65
14
  input:disabled {
66
15
  cursor: inherit;
67
16
  }
@@ -72,14 +21,14 @@ const inputStyle = css`
72
21
  }
73
22
  `;
74
23
 
75
- @styles(fieldStyle, inputStyle)
24
+ @styles(inputStyle)
76
25
  class SuperInput<V = string> extends GlobalStyle {
77
26
  autofocus = false;
78
27
  @property()
79
28
  autocomplete: string | boolean;
80
29
 
81
- @property({ attribute: "outline-type" })
82
- outlineType: OutlineType = "border";
30
+ @property({ attribute: "ring-type" })
31
+ ringType: RingType = "border";
83
32
 
84
33
  @property({ type: Boolean, reflect: true })
85
34
  disabled = false;
@@ -106,7 +55,7 @@ class SuperInput<V = string> extends GlobalStyle {
106
55
  @property()
107
56
  default: any;
108
57
 
109
- @part("input")
58
+ @queryPart("input")
110
59
  protected _input: HTMLInputElement;
111
60
 
112
61
  /**
@@ -184,23 +133,13 @@ class SuperInput<V = string> extends GlobalStyle {
184
133
 
185
134
  protected _renderPrefix(): TemplateResult<1> {
186
135
  return html`
187
- <label
188
- for=${this.makeId}
189
- part="prefix"
190
- >
191
- ${htmlSlot("prefix")}
192
- </label>
136
+ <i part="prefix">${htmlSlot("prefix")}</i>
193
137
  `;
194
138
  }
195
139
 
196
140
  protected _renderSuffix(): TemplateResult<1> {
197
141
  return html`
198
- <label
199
- for=${this.makeId}
200
- part="suffix"
201
- >
202
- ${htmlSlot("suffix")}
203
- </label>
142
+ <i part="suffix">${htmlSlot("suffix")}</i>
204
143
  `;
205
144
  }
206
145
  }
@@ -1,91 +1,25 @@
1
- import { attr, godown, htmlSlot, joinRules, StyleController, styles } from "@godown/element";
2
- import iconCheckAltCircle from "@godown/f7-icon/icons/checkmark-alt-circle.js";
3
- import iconExclamationCircle from "@godown/f7-icon/icons/exclamationmark-circle.js";
4
- import iconInfoCircle from "@godown/f7-icon/icons/info-circle.js";
5
- import iconLightbulb from "@godown/f7-icon/icons/lightbulb.js";
6
- import iconQuestionCircle from "@godown/f7-icon/icons/question-circle.js";
7
- import iconSlashCircle from "@godown/f7-icon/icons/slash-circle.js";
8
- import iconXmarkCircle from "@godown/f7-icon/icons/xmark-circle.js";
9
- import iconXmark from "@godown/f7-icon/icons/xmark.js";
1
+ import { attr, godown, htmlSlot, StyleController, styles } from "@godown/element";
10
2
  import { type TemplateResult, css, html } from "lit";
11
3
  import { property } from "lit/decorators.js";
12
4
 
13
- import { GlobalStyle, cssGlobalVars, scopePrefix } from "../../internal/global-style.js";
5
+ import { cssGlobalVars, GlobalStyle } from "../../internal/global-style.js";
6
+ import { RingBuilder, type RingType } from "../../internal/ring.js";
14
7
 
15
8
  const protoName = "alert";
16
- const cssScope = scopePrefix(protoName);
17
-
18
- const genDark = (key: string) => {
19
- return [cssGlobalVars._colors[key][5], cssGlobalVars._colors[key][9]];
20
- };
21
-
22
- const colorDetails = {
23
- green: genDark("green"),
24
- blue: genDark("blue"),
25
- orange: genDark("orange"),
26
- red: genDark("red"),
27
- yellow: genDark("yellow"),
28
- purple: genDark("purple"),
29
- teal: genDark("teal"),
30
- pink: genDark("pink"),
31
- gray: [cssGlobalVars._colors.lightgray[5], cssGlobalVars._colors.darkgray[5]],
32
- white: [cssGlobalVars._colors.lightgray[2], cssGlobalVars._colors.darkgray[7]],
33
- black: [cssGlobalVars._colors.darkgray[8], cssGlobalVars._colors.lightgray[5]],
34
- };
35
-
36
- const calls = {
37
- tip: {
38
- color: "teal",
39
- icon: iconLightbulb,
40
- },
41
- success: {
42
- color: "green",
43
- icon: iconCheckAltCircle,
44
- },
45
- info: {
46
- color: "blue",
47
- icon: iconInfoCircle,
48
- },
49
- warning: {
50
- color: "orange",
51
- icon: iconExclamationCircle,
52
- },
53
- danger: {
54
- color: "red",
55
- icon: iconXmarkCircle,
56
- },
57
- error: {
58
- color: "red",
59
- icon: iconXmarkCircle,
60
- },
61
- help: {
62
- color: "purple",
63
- icon: iconQuestionCircle,
64
- },
65
- deprecated: {
66
- color: "gray",
67
- icon: iconSlashCircle,
68
- },
69
- };
70
9
 
71
10
  /**
72
11
  * {@linkcode Alert} renders a alert.
73
12
  *
74
- * Color defaults to blue.
75
- *
76
13
  * @slot - Alert content.
77
14
  * @slot title - Alert title.
78
- * @slot icon - Alert icon.
79
- * @fires close - Fires when the alert is closed.
15
+ * @slot prefix - Alert prefix.
16
+ * @slot suffix - Alert suffix.
80
17
  * @category feedback
81
18
  */
82
19
  @godown(protoName)
83
20
  @styles(css`
84
21
  :host {
85
- ${cssScope}--border-width: .075em;
86
- ${cssScope}--blockquote-width: .2em;
87
- ${cssScope}--blockquote-background: transparent;
88
- ${cssScope}--gap: .5em;
22
+ background: var(${cssGlobalVars.background});
89
23
  }
90
24
 
91
25
  :host,
@@ -94,94 +28,25 @@ const calls = {
94
28
  }
95
29
 
96
30
  [part="root"] {
97
- color: var(${cssScope}--color, currentColor);
31
+ padding: 0.75em;
98
32
  display: grid;
99
33
  align-items: center;
100
34
  grid-template-columns: auto 1fr auto;
101
35
  grid-template-rows: auto 1fr;
102
- border-color: currentColor;
103
- border-radius: inherit;
104
- border-style: solid;
105
- border-width: var(${cssScope}--border-width);
106
- padding: var(${cssScope}--gap);
107
- background: var(${cssScope}--background);
108
- }
109
-
110
- [variant="blockquote"] {
111
- border-radius: 0;
112
- border-width: 0;
113
- border-left-width: var(${cssScope}--blockquote-width);
114
- background: var(${cssScope}--blockquote-background);
115
- }
116
-
117
- [part~="icon"] {
118
- display: grid;
119
- align-items: center;
120
- height: 2em;
121
- }
122
-
123
- .start svg {
124
- margin-inline-end: var(${cssScope}--gap);
125
- }
126
-
127
- .end svg {
128
- margin-inline-start: var(${cssScope}--gap);
129
- }
130
-
131
- svg {
132
- width: 1.25em;
133
- height: 1.25em;
134
36
  }
135
37
 
136
38
  [part="content"] {
137
- grid-row: span 2 / span 2;
39
+ display: grid;
138
40
  }
139
41
  `)
140
42
  class Alert extends GlobalStyle {
141
- private __colorSC = new StyleController(this, () => {
142
- const color = calls[this.call]?.color || this.color;
143
- if (color in colorDetails) {
144
- const [fg, bg] = colorDetails[color];
145
- return joinRules({
146
- ":host": [
147
- [`${cssScope}--color`, `var(${fg})`],
148
- [`${cssScope}--background`, `var(${bg})`],
149
- ],
150
- });
151
- }
152
- return null;
153
- });
154
-
155
- /**
156
- * If it is a legal value, the icon and preset color will be rendered.
157
- */
158
- @property()
159
- call: "tip" | "success" | "info" | "warning" | "danger" | "error" | "help" | "deprecated";
160
-
161
- /**
162
- * The tone of the component.
163
- * Overrides the color of the call.
164
- */
165
- @property()
166
- color:
167
- | "white"
168
- | "black"
169
- | "gray"
170
- | "green"
171
- | "teal"
172
- | "blue"
173
- | "red"
174
- | "purple"
175
- | "orange"
176
- | "yellow"
177
- | "pink"
178
- | "none" = "blue";
43
+ constructor() {
44
+ super();
45
+ new StyleController(this, () => new RingBuilder({ type: this.ringType }).css);
46
+ }
179
47
 
180
- /**
181
- * Close delay, if 0, it will not be closed automatically.
182
- */
183
- @property({ type: Number })
184
- autoclose = 0;
48
+ @property({ attribute: "ring-type" })
49
+ ringType: RingType = "border";
185
50
 
186
51
  /**
187
52
  * The title is bold and the icon height is the same as it.
@@ -195,66 +60,22 @@ class Alert extends GlobalStyle {
195
60
  @property()
196
61
  content: string;
197
62
 
198
- /**
199
- * Set true to hide the close button.
200
- *
201
- * The behavior may change due to the {@linkcode variant} property.
202
- */
203
- @property({ type: Boolean })
204
- hideClose = false;
205
-
206
- /**
207
- * Alert variant, if set to `blockquote`, the alert will be rendered as a blockquote.
208
- *
209
- * If variant is `"blockquote"`, hide the close button.
210
- */
211
- @property()
212
- variant: "blockquote" | "dark" = "dark";
213
-
214
63
  protected render(): TemplateResult<1> {
215
- const icon = this.call ? calls[this.call].icon() : htmlSlot("icon");
216
64
  return html`
217
65
  <div
218
66
  part="root"
219
67
  ${attr(this.observedRecord)}
220
68
  >
221
- <div
222
- part="icon"
223
- class="start"
224
- >
225
- ${icon}
226
- </div>
69
+ <div>${htmlSlot("prefix")}</div>
227
70
  <div part="content">
228
71
  <strong part="title">${this.title || htmlSlot("title")}</strong>
229
72
  ${this.content || htmlSlot()}
230
73
  </div>
231
- ${this.hideClose || this.variant === "blockquote"
232
- ? ""
233
- : html`
234
- <div
235
- part="icon close"
236
- class="end"
237
- tabindex="0"
238
- @click="${this.close}"
239
- >
240
- ${iconXmark()}
241
- </div>
242
- `}
74
+ <div>${htmlSlot("suffix")}</div>
243
75
  </div>
244
76
  `;
245
77
  }
246
78
 
247
- close(): void {
248
- this.remove();
249
- this.dispatchCustomEvent("close", undefined, { bubbles: true });
250
- }
251
-
252
- protected firstUpdated(): void {
253
- if (this.autoclose) {
254
- this.timeouts.add(setTimeout(() => this.close(), this.autoclose));
255
- }
256
- }
257
-
258
79
  static alert(root: HTMLElement, option: Partial<Alert>): Alert {
259
80
  const ai = new this();
260
81
  Object.assign(ai, option);
@@ -1,12 +1,9 @@
1
- import { attr, godown, htmlSlot, styles } from "@godown/element";
2
- import { type TemplateResult, css, html } from "lit";
3
- import { property } from "lit/decorators.js";
1
+ import { godown, styles } from "@godown/element";
4
2
 
5
- import { GlobalStyle, cssGlobalVars, scopePrefix } from "../../internal/global-style.js";
6
- import type { DirectionCorner } from "../../internal/direction.js";
3
+ import Button from "../button/component.js";
4
+ import { css } from "lit";
7
5
 
8
6
  const protoName = "badge";
9
- const cssScope = scopePrefix(protoName);
10
7
 
11
8
  /**
12
9
  * {@linkcode Badge} renders a badge.
@@ -17,98 +14,16 @@ const cssScope = scopePrefix(protoName);
17
14
  @godown(protoName)
18
15
  @styles(css`
19
16
  :host {
20
- ${cssScope}--background: var(${cssGlobalVars.active});
21
- ${cssScope}--offset: 0%;
22
- ${cssScope}--offset-x: var(${cssScope}--offset);
23
- ${cssScope}--offset-y: var(${cssScope}--offset);
24
- }
25
-
26
- :host,
27
- :host([contents]) [part="root"] {
28
- display: inline-block;
17
+ font-size: 0.75em;
29
18
  }
30
19
 
31
20
  [part="root"] {
32
- position: relative;
33
- }
34
-
35
- [part="badge"] {
36
- position: absolute;
37
- font-size: 75%;
38
21
  padding: 0 0.5em;
39
- user-select: none;
40
- border-radius: calc(infinity * 1px);
41
- transform: translate(-50%, -50%);
42
- background: var(${cssScope}--background);
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"] [part="badge"] {
54
- top: calc(0% + var(${cssScope}--offset-y));
55
- }
56
-
57
- [position$="right"] [part="badge"] {
58
- left: calc(100% - var(${cssScope}--offset-x));
59
- }
60
-
61
- [position^="bottom"] [part="badge"] {
62
- top: calc(100% - var(${cssScope}--offset-y));
63
- }
64
-
65
- [position$="left"] [part="badge"] {
66
- left: calc(0% + var(${cssScope}--offset-x));
67
22
  }
68
23
  `)
69
- class Badge extends GlobalStyle {
70
- /**
71
- * The position of the badge relative to its parent element.
72
- * Possible values are `"top-left"`, `"top-right"`, `"bottom-left"`, and `"bottom-right"`.
73
- */
74
- @property()
75
- position: DirectionCorner = "top-right";
76
-
77
- @property({ type: Number })
78
- value = 0;
79
-
80
- /**
81
- * If `true`, render a dot badge.
82
- */
83
- @property({ type: Boolean })
84
- dot = false;
85
-
86
- /**
87
- * The maximum value that can be displayed in the badge
88
- * Values greater than this will be displayed as `max+` by default.
89
- */
90
- @property({ type: Number })
91
- max = 99;
92
-
93
- formatValue(value: number): string {
94
- return value > this.max ? this.max + "+" : value + "";
95
- }
96
-
97
- render(): TemplateResult<1> {
98
- return html`
99
- <div
100
- part="root"
101
- ${attr(this.observedRecord)}
102
- >
103
- ${htmlSlot()}
104
- ${this.value || this.dot
105
- ? html`
106
- <div part="badge">${this.dot ? "" : this.formatValue(this.value)}</div>
107
- `
108
- : ""}
109
- </div>
110
- `;
111
- }
24
+ class Badge extends Button {
25
+ plain: never = true as never;
26
+ round: Button["round"] = true;
112
27
  }
113
28
 
114
29
  export default Badge;
@@ -1,5 +1,5 @@
1
1
  import { attr, godown, htmlStyle, styles } from "@godown/element";
2
- import { type TemplateResult, css, html } from "lit";
2
+ import { type TemplateResult, css, html, unsafeCSS } from "lit";
3
3
  import { property } from "lit/decorators.js";
4
4
 
5
5
  import { GlobalStyle, cssGlobalVars, scopePrefix } from "../../internal/global-style.js";
@@ -29,12 +29,12 @@ const splitTextRegexp = /[\s,]+/;
29
29
  css`
30
30
  :host {
31
31
  ${cssScope}--deg: 60deg;
32
- ${cssScope}--1-1: var(${cssGlobalVars._colors.red[5]});
33
- ${cssScope}--1-2: var(${cssGlobalVars._colors.yellow[5]});
34
- ${cssScope}--2-1: var(${cssGlobalVars._colors.green[5]});
35
- ${cssScope}--2-2: var(${cssGlobalVars._colors.purple[5]});
36
- ${cssScope}--3-1: var(${cssGlobalVars._colors.blue[5]});
37
- ${cssScope}--3-2: var(${cssGlobalVars._colors.pink[5]});
32
+ ${cssScope}--1-1: hsl(0 70% 55%);
33
+ ${cssScope}--1-2: hsl(30 90% 60%);
34
+ ${cssScope}--2-1: hsl(130 70% 50%);
35
+ ${cssScope}--2-2: hsl(180 60% 40%);
36
+ ${cssScope}--3-1: hsl(270 80% 55%);
37
+ ${cssScope}--3-2: hsl(210 90% 50%);
38
38
  ${cssScope}--1: linear-gradient(var(${cssScope}--deg), var(${cssScope}--1-1), var(${cssScope}--1-2));
39
39
  ${cssScope}--2: linear-gradient(var(${cssScope}--deg), var(${cssScope}--2-1), var(${cssScope}--2-2));
40
40
  ${cssScope}--3: linear-gradient(var(${cssScope}--deg), var(${cssScope}--3-1), var(${cssScope}--3-2));
@@ -89,7 +89,7 @@ const splitTextRegexp = /[\s,]+/;
89
89
  .nocolor {
90
90
  position: absolute;
91
91
  top: 0;
92
- background: var(${cssGlobalVars.clipBackground});
92
+ background: var(${cssGlobalVars.backgroundClip});
93
93
  }
94
94
  `,
95
95
  )