godown 3.2.0 → 3.4.0

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 (262) hide show
  1. package/build/godown+lit.iife.js +12 -12
  2. package/build/godown+lit.iife.js.map +1 -1
  3. package/build/godown+lit.js +12 -12
  4. package/build/godown+lit.js.map +1 -1
  5. package/build/godown+lit.umd.js +12 -12
  6. package/build/godown+lit.umd.js.map +1 -1
  7. package/build/godown.iife.js +10 -10
  8. package/build/godown.js +10 -10
  9. package/build/godown.js.map +1 -1
  10. package/build/godown.umd.js +10 -10
  11. package/build/godown.umd.js.map +1 -1
  12. package/components/alert.d.ts +1 -3
  13. package/components/alert.d.ts.map +1 -1
  14. package/components/alert.js +1 -1
  15. package/components/alert.js.map +1 -1
  16. package/components/avatar.d.ts +5 -4
  17. package/components/avatar.d.ts.map +1 -1
  18. package/components/avatar.js +1 -1
  19. package/components/avatar.js.map +1 -1
  20. package/components/badge.d.ts +10 -2
  21. package/components/badge.d.ts.map +1 -1
  22. package/components/badge.js.map +1 -1
  23. package/components/breath.d.ts +2 -3
  24. package/components/breath.d.ts.map +1 -1
  25. package/components/breath.js +1 -1
  26. package/components/breath.js.map +1 -1
  27. package/components/button.d.ts +8 -3
  28. package/components/button.d.ts.map +1 -1
  29. package/components/button.js +1 -1
  30. package/components/button.js.map +1 -1
  31. package/components/card.d.ts +6 -0
  32. package/components/card.d.ts.map +1 -1
  33. package/components/card.js +1 -1
  34. package/components/card.js.map +1 -1
  35. package/components/carousel.d.ts +7 -13
  36. package/components/carousel.d.ts.map +1 -1
  37. package/components/carousel.js +1 -1
  38. package/components/carousel.js.map +1 -1
  39. package/components/details.d.ts +3 -3
  40. package/components/details.d.ts.map +1 -1
  41. package/components/dialog.d.ts +9 -6
  42. package/components/dialog.d.ts.map +1 -1
  43. package/components/dialog.js +1 -1
  44. package/components/dialog.js.map +1 -1
  45. package/components/divider.d.ts +1 -1
  46. package/components/heading.d.ts +2 -0
  47. package/components/heading.d.ts.map +1 -1
  48. package/components/heading.js.map +1 -1
  49. package/components/input.d.ts +2 -2
  50. package/components/input.d.ts.map +1 -1
  51. package/components/input.js +1 -1
  52. package/components/input.js.map +1 -1
  53. package/components/link.d.ts +1 -1
  54. package/components/link.d.ts.map +1 -1
  55. package/components/link.js +1 -1
  56. package/components/link.js.map +1 -1
  57. package/components/progress.d.ts +0 -7
  58. package/components/progress.d.ts.map +1 -1
  59. package/components/progress.js +1 -1
  60. package/components/progress.js.map +1 -1
  61. package/components/range.d.ts +48 -19
  62. package/components/range.d.ts.map +1 -1
  63. package/components/range.js +1 -1
  64. package/components/range.js.map +1 -1
  65. package/components/rotate.d.ts +6 -4
  66. package/components/rotate.d.ts.map +1 -1
  67. package/components/rotate.js.map +1 -1
  68. package/components/router.d.ts.map +1 -1
  69. package/components/router.js +1 -1
  70. package/components/router.js.map +1 -1
  71. package/components/select.d.ts +4 -2
  72. package/components/select.d.ts.map +1 -1
  73. package/components/select.js +1 -1
  74. package/components/select.js.map +1 -1
  75. package/components/split.d.ts +2 -1
  76. package/components/split.d.ts.map +1 -1
  77. package/components/split.js +1 -1
  78. package/components/split.js.map +1 -1
  79. package/components/switch.d.ts +5 -7
  80. package/components/switch.d.ts.map +1 -1
  81. package/components/switch.js +1 -1
  82. package/components/switch.js.map +1 -1
  83. package/components/text.js +1 -1
  84. package/components/text.js.map +1 -1
  85. package/components/time.d.ts +2 -5
  86. package/components/time.d.ts.map +1 -1
  87. package/components/time.js +1 -1
  88. package/components/time.js.map +1 -1
  89. package/components/tooltip.d.ts +3 -2
  90. package/components/tooltip.d.ts.map +1 -1
  91. package/components/tooltip.js +1 -1
  92. package/components/tooltip.js.map +1 -1
  93. package/components/typewriter.d.ts.map +1 -1
  94. package/components/typewriter.js +1 -1
  95. package/components/typewriter.js.map +1 -1
  96. package/core/direction.d.ts +27 -0
  97. package/core/direction.d.ts.map +1 -0
  98. package/core/direction.js +2 -0
  99. package/core/direction.js.map +1 -0
  100. package/core/global-style.d.ts +1 -2
  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/outline.d.ts +20 -0
  105. package/core/outline.d.ts.map +1 -0
  106. package/core/outline.js +2 -0
  107. package/core/outline.js.map +1 -0
  108. package/core/super-anchor.d.ts +2 -2
  109. package/core/super-anchor.d.ts.map +1 -1
  110. package/core/super-anchor.js +1 -1
  111. package/core/super-anchor.js.map +1 -1
  112. package/core/super-input.d.ts +2 -0
  113. package/core/super-input.d.ts.map +1 -1
  114. package/core/super-input.js +1 -1
  115. package/core/super-input.js.map +1 -1
  116. package/core/super-openable.d.ts +0 -4
  117. package/core/super-openable.d.ts.map +1 -1
  118. package/custom-elements.json +1 -1
  119. package/dev/components/alert.d.ts +1 -3
  120. package/dev/components/alert.d.ts.map +1 -1
  121. package/dev/components/alert.js +33 -57
  122. package/dev/components/alert.js.map +1 -1
  123. package/dev/components/avatar.d.ts +5 -4
  124. package/dev/components/avatar.d.ts.map +1 -1
  125. package/dev/components/avatar.js +5 -4
  126. package/dev/components/avatar.js.map +1 -1
  127. package/dev/components/badge.d.ts +10 -2
  128. package/dev/components/badge.d.ts.map +1 -1
  129. package/dev/components/badge.js +8 -0
  130. package/dev/components/badge.js.map +1 -1
  131. package/dev/components/breath.d.ts +2 -3
  132. package/dev/components/breath.d.ts.map +1 -1
  133. package/dev/components/breath.js +3 -14
  134. package/dev/components/breath.js.map +1 -1
  135. package/dev/components/button.d.ts +8 -3
  136. package/dev/components/button.d.ts.map +1 -1
  137. package/dev/components/button.js +19 -5
  138. package/dev/components/button.js.map +1 -1
  139. package/dev/components/card.d.ts +6 -0
  140. package/dev/components/card.d.ts.map +1 -1
  141. package/dev/components/card.js +11 -11
  142. package/dev/components/card.js.map +1 -1
  143. package/dev/components/carousel.d.ts +7 -13
  144. package/dev/components/carousel.d.ts.map +1 -1
  145. package/dev/components/carousel.js +40 -39
  146. package/dev/components/carousel.js.map +1 -1
  147. package/dev/components/details.d.ts +3 -3
  148. package/dev/components/details.d.ts.map +1 -1
  149. package/dev/components/details.js +3 -3
  150. package/dev/components/details.js.map +1 -1
  151. package/dev/components/dialog.d.ts +9 -6
  152. package/dev/components/dialog.d.ts.map +1 -1
  153. package/dev/components/dialog.js +58 -62
  154. package/dev/components/dialog.js.map +1 -1
  155. package/dev/components/divider.d.ts +1 -1
  156. package/dev/components/divider.js +1 -1
  157. package/dev/components/heading.d.ts +2 -0
  158. package/dev/components/heading.d.ts.map +1 -1
  159. package/dev/components/heading.js +2 -0
  160. package/dev/components/heading.js.map +1 -1
  161. package/dev/components/input.d.ts +2 -2
  162. package/dev/components/input.d.ts.map +1 -1
  163. package/dev/components/input.js +30 -9
  164. package/dev/components/input.js.map +1 -1
  165. package/dev/components/link.d.ts +1 -1
  166. package/dev/components/link.d.ts.map +1 -1
  167. package/dev/components/link.js +2 -2
  168. package/dev/components/link.js.map +1 -1
  169. package/dev/components/progress.d.ts +0 -7
  170. package/dev/components/progress.d.ts.map +1 -1
  171. package/dev/components/progress.js +4 -25
  172. package/dev/components/progress.js.map +1 -1
  173. package/dev/components/range.d.ts +48 -19
  174. package/dev/components/range.d.ts.map +1 -1
  175. package/dev/components/range.js +83 -61
  176. package/dev/components/range.js.map +1 -1
  177. package/dev/components/rotate.d.ts +6 -4
  178. package/dev/components/rotate.d.ts.map +1 -1
  179. package/dev/components/rotate.js +6 -4
  180. package/dev/components/rotate.js.map +1 -1
  181. package/dev/components/router.d.ts.map +1 -1
  182. package/dev/components/router.js +2 -3
  183. package/dev/components/router.js.map +1 -1
  184. package/dev/components/select.d.ts +4 -2
  185. package/dev/components/select.d.ts.map +1 -1
  186. package/dev/components/select.js +27 -24
  187. package/dev/components/select.js.map +1 -1
  188. package/dev/components/split.d.ts +2 -1
  189. package/dev/components/split.d.ts.map +1 -1
  190. package/dev/components/split.js +11 -7
  191. package/dev/components/split.js.map +1 -1
  192. package/dev/components/switch.d.ts +5 -7
  193. package/dev/components/switch.d.ts.map +1 -1
  194. package/dev/components/switch.js +23 -45
  195. package/dev/components/switch.js.map +1 -1
  196. package/dev/components/text.js +2 -2
  197. package/dev/components/time.d.ts +2 -5
  198. package/dev/components/time.d.ts.map +1 -1
  199. package/dev/components/time.js +6 -20
  200. package/dev/components/time.js.map +1 -1
  201. package/dev/components/tooltip.d.ts +3 -2
  202. package/dev/components/tooltip.d.ts.map +1 -1
  203. package/dev/components/tooltip.js +7 -19
  204. package/dev/components/tooltip.js.map +1 -1
  205. package/dev/components/typewriter.d.ts.map +1 -1
  206. package/dev/components/typewriter.js +2 -2
  207. package/dev/components/typewriter.js.map +1 -1
  208. package/dev/core/direction.d.ts +27 -0
  209. package/dev/core/direction.d.ts.map +1 -0
  210. package/dev/core/direction.js +56 -0
  211. package/dev/core/direction.js.map +1 -0
  212. package/dev/core/global-style.d.ts +1 -2
  213. package/dev/core/global-style.d.ts.map +1 -1
  214. package/dev/core/global-style.js +11 -11
  215. package/dev/core/global-style.js.map +1 -1
  216. package/dev/core/outline.d.ts +20 -0
  217. package/dev/core/outline.d.ts.map +1 -0
  218. package/dev/core/outline.js +44 -0
  219. package/dev/core/outline.js.map +1 -0
  220. package/dev/core/super-anchor.d.ts +2 -2
  221. package/dev/core/super-anchor.d.ts.map +1 -1
  222. package/dev/core/super-anchor.js +0 -1
  223. package/dev/core/super-anchor.js.map +1 -1
  224. package/dev/core/super-input.d.ts +2 -0
  225. package/dev/core/super-input.d.ts.map +1 -1
  226. package/dev/core/super-input.js +19 -30
  227. package/dev/core/super-input.js.map +1 -1
  228. package/dev/core/super-openable.d.ts +0 -4
  229. package/dev/core/super-openable.d.ts.map +1 -1
  230. package/package.json +3 -3
  231. package/src/components/alert.ts +34 -65
  232. package/src/components/avatar.ts +7 -5
  233. package/src/components/badge.ts +10 -3
  234. package/src/components/breath.ts +5 -17
  235. package/src/components/button.ts +19 -6
  236. package/src/components/card.ts +11 -11
  237. package/src/components/carousel.ts +45 -44
  238. package/src/components/details.ts +3 -3
  239. package/src/components/dialog.ts +66 -65
  240. package/src/components/divider.ts +1 -1
  241. package/src/components/heading.ts +2 -0
  242. package/src/components/input.ts +30 -9
  243. package/src/components/link.ts +2 -2
  244. package/src/components/progress.ts +4 -25
  245. package/src/components/range.ts +92 -70
  246. package/src/components/rotate.ts +6 -4
  247. package/src/components/router.ts +2 -3
  248. package/src/components/select.ts +33 -26
  249. package/src/components/split.ts +12 -7
  250. package/src/components/switch.ts +26 -41
  251. package/src/components/text.ts +2 -2
  252. package/src/components/time.ts +10 -25
  253. package/src/components/tooltip.ts +8 -20
  254. package/src/components/typewriter.ts +9 -7
  255. package/src/core/direction.ts +65 -0
  256. package/src/core/global-style.ts +12 -14
  257. package/src/core/outline.ts +54 -0
  258. package/src/core/super-anchor.ts +3 -2
  259. package/src/core/super-input.ts +22 -30
  260. package/src/core/super-openable.ts +0 -8
  261. package/vscode.html-custom-data.json +1 -1
  262. package/web-types.json +1 -1
@@ -22,19 +22,13 @@ const cssScope = scopePrefix(protoName);
22
22
  @godown(protoName)
23
23
  @styles(css`
24
24
  :host {
25
- ${cssScope}--background: var(${cssGlobalVars.background});
26
- ${cssScope}--border-width: .0375em;
27
- ${cssScope}--border-color: transparent;
28
- ${cssScope}--border-background: var(${cssGlobalVars.passive});
29
- ${cssScope}--padding: .75em;
30
- color: var(${cssGlobalVars.foreground});
31
- background: var(${cssScope}--background);
25
+ ${cssScope}--border-width: .075em;
26
+ ${cssScope}--border-color: var(${cssGlobalVars.passive});
27
+ ${cssScope}--padding: .5em;
32
28
  border-width: var(${cssScope}--border-width);
33
29
  display: block;
34
30
  flex-shrink: 0;
35
- position: relative;
36
- overflow: hidden;
37
- box-sizing: border-box;
31
+ border-radius: 0.2em;
38
32
  }
39
33
 
40
34
  slot {
@@ -44,7 +38,7 @@ const cssScope = scopePrefix(protoName);
44
38
 
45
39
  :host,
46
40
  slot {
47
- border-color: var(${cssScope}--border-background);
41
+ border-color: var(${cssScope}--border-color);
48
42
  border-style: solid;
49
43
  }
50
44
 
@@ -57,9 +51,15 @@ const cssScope = scopePrefix(protoName);
57
51
  }
58
52
  `)
59
53
  class Card extends GlobalStyle {
54
+ /**
55
+ * Whether to display the header.
56
+ */
60
57
  @property({ type: Boolean })
61
58
  footer = false;
62
59
 
60
+ /**
61
+ * Whether to display the footer.
62
+ */
63
63
  @property({ type: Boolean })
64
64
  header = false;
65
65
 
@@ -1,4 +1,4 @@
1
- import { attr, godown, htmlSlot, htmlStyle, part, styles } from "@godown/element";
1
+ import { attr, godown, htmlSlot, part, styles } from "@godown/element";
2
2
  import iconChevronLeft from "@godown/f7-icon/icons/chevron-left.js";
3
3
  import iconChevronRight from "@godown/f7-icon/icons/chevron-right.js";
4
4
  import { type TemplateResult, css, html } from "lit";
@@ -8,16 +8,16 @@ import { GlobalStyle } from "../core/global-style.js";
8
8
 
9
9
  const protoName = "carousel";
10
10
 
11
+ function getWidth(e) {
12
+ return e.getBoundingClientRect().width;
13
+ }
14
+
11
15
  /**
12
16
  * {@linkcode Carousel} make the content display as a carousel.
13
17
  *
14
18
  * When this component is `firstUpdated`,
15
19
  * clone the first and last element and make the matching element visible when switching index.
16
20
  *
17
- * Child elements should maintain the same size.
18
- *
19
- * If no width, it will be the width of the first element.
20
- *
21
21
  * @slot - Carousel items, should maintain the same size.
22
22
  * @fires change - Fires when the index changes.
23
23
  * @category display
@@ -69,23 +69,17 @@ const protoName = "carousel";
69
69
  `)
70
70
  class Carousel extends GlobalStyle {
71
71
  /**
72
- * The index of the element is displayed for the first time.
72
+ * The index of the current item.
73
73
  */
74
74
  @property({ type: Number })
75
75
  index = 0;
76
76
 
77
77
  /**
78
- * If autoChange > 0, the rotation will be automated.
78
+ * The duration of the transition.
79
79
  */
80
80
  @property({ type: Number })
81
81
  autoChange = 0;
82
82
 
83
- /**
84
- * Element width.
85
- */
86
- @property()
87
- width: string;
88
-
89
83
  @part("move-root")
90
84
  protected _moveRoot: HTMLElement;
91
85
 
@@ -95,6 +89,8 @@ class Carousel extends GlobalStyle {
95
89
 
96
90
  private __cloneLast: HTMLElement | undefined;
97
91
 
92
+ protected _offset: number;
93
+
98
94
  protected render(): TemplateResult<1> {
99
95
  return html`
100
96
  <div
@@ -107,47 +103,59 @@ class Carousel extends GlobalStyle {
107
103
  >
108
104
  ${iconChevronLeft()}
109
105
  </i>
110
- <div
111
- part="move-root"
112
- style="transform:${`translateX(-${this.index + 1}00%)`}"
113
- >
114
- ${htmlSlot()}
115
- </div>
106
+ <div part="move-root">${htmlSlot()}</div>
116
107
  <i
117
108
  part="next"
118
109
  @click="${this.next}"
119
110
  >
120
111
  ${iconChevronRight()}
121
112
  </i>
122
- ${htmlStyle(`:host,:host([contents]) [part=root]{width:${this.width};}`)}
123
113
  </div>
124
114
  `;
125
115
  }
126
116
 
127
- protected async firstUpdated(): Promise<void> {
128
- await this.updateComplete;
129
-
117
+ connectedCallback(): void {
118
+ super.connectedCallback();
130
119
  if (this.children.length) {
131
- this.width ||= `${(this.firstElementChild as HTMLElement).offsetWidth}px`;
132
-
133
120
  this.__cloneFirst?.remove();
134
121
  this.__cloneLast?.remove();
135
122
  this.__cloneLast = this.firstElementChild.cloneNode(true) as HTMLElement;
136
123
  this.__cloneFirst = this.lastElementChild.cloneNode(true) as HTMLElement;
137
124
  this.appendChild(this.__cloneLast);
138
125
  this.insertBefore(this.__cloneFirst, this.firstElementChild);
139
- this.show(this.index);
140
126
  }
141
- this.checkInterval();
142
127
  }
143
128
 
144
- disconnectedCallback(): void {
145
- clearInterval(this.intervalID);
129
+ protected async firstUpdated(): Promise<void> {
130
+ await this.updateComplete;
131
+ this.show(this.index, true);
146
132
  }
147
133
 
148
- show(i: number): void {
134
+ attributeChangedCallback(name: string, _old: string | null, value: string | null): void {
135
+ super.attributeChangedCallback(name, _old, value);
136
+ if (name === "index" && this.isConnected) {
137
+ this.show(this.index);
138
+ }
139
+ }
140
+
141
+ show(i: number, n?: boolean): void {
142
+ i = this.normalizeIndex(i);
149
143
  this.index = i;
144
+ this._offset = 0;
145
+ for (let childIndex = 0; childIndex <= i; childIndex++) {
146
+ this._offset -= getWidth(this.children[childIndex]);
147
+ }
148
+ this._offset += (getWidth(this) - getWidth(this.children[i + 1])) / 2;
150
149
  this.dispatchEvent(new CustomEvent("change", { detail: i, composed: true }));
150
+ this._doTranslateX(`${this._offset}px`, n);
151
+ this.timeouts.remove(this.intervalID);
152
+ if (this.autoChange > 0) {
153
+ this.intervalID = this.timeouts.add(
154
+ setInterval(() => {
155
+ this.next();
156
+ }, this.autoChange),
157
+ );
158
+ }
151
159
  }
152
160
 
153
161
  next(): void {
@@ -157,7 +165,6 @@ class Carousel extends GlobalStyle {
157
165
  } else {
158
166
  this.show(this.index + 1);
159
167
  }
160
- this.checkInterval();
161
168
  }
162
169
 
163
170
  prev(): void {
@@ -167,26 +174,20 @@ class Carousel extends GlobalStyle {
167
174
  } else {
168
175
  this.show(this.index - 1);
169
176
  }
170
- this.checkInterval();
171
177
  }
172
178
 
173
179
  protected _doTranslateX(xValue: string, noTransition?: boolean): void {
174
180
  this._moveRoot.style.transform = `translateX(${xValue})`;
175
- if (noTransition) {
176
- this._moveRoot.style.transition = "none";
177
- }
178
- this._moveRoot.getBoundingClientRect();
181
+ this._moveRoot.style.transition = noTransition ? "none" : "";
179
182
  }
180
183
 
181
- checkInterval(): void {
182
- if (this.autoChange) {
183
- if (this.intervalID) {
184
- clearInterval(this.intervalID);
185
- }
186
- this.intervalID = setInterval(() => {
187
- this.next();
188
- }, this.autoChange);
184
+ normalizeIndex(i: number): number {
185
+ if (i < 0) {
186
+ return 0;
187
+ } else if (i > this.children.length - 3) {
188
+ return this.children.length - 3;
189
189
  }
190
+ return i;
190
191
  }
191
192
  }
192
193
 
@@ -4,7 +4,7 @@ import { type TemplateResult, css, html } from "lit";
4
4
  import { property } from "lit/decorators.js";
5
5
 
6
6
  import { scopePrefix } from "../core/global-style.js";
7
- import SuperOpenable from "../core/super-openable.js";
7
+ import { SuperOpenable } from "../core/super-openable.js";
8
8
 
9
9
  const protoName = "details";
10
10
 
@@ -79,13 +79,13 @@ const cssScope = scopePrefix(protoName);
79
79
  `)
80
80
  class Details extends SuperOpenable {
81
81
  /**
82
- * If it is true, the summary event scope will fill the element.
82
+ * Determines whether the details component should fill the available space.
83
83
  */
84
84
  @property({ type: Boolean })
85
85
  fill = false;
86
86
 
87
87
  /**
88
- * Summary text.
88
+ * The summary text to display in the details component.
89
89
  */
90
90
  @property()
91
91
  summary = "";
@@ -2,8 +2,14 @@ import { type HandlerEvent, attr, godown, htmlSlot, styles } from "@godown/eleme
2
2
  import { type PropertyValues, type TemplateResult, css, html } from "lit";
3
3
  import { property } from "lit/decorators.js";
4
4
 
5
- import { cssGlobalVars, scopePrefix } from "../core/global-style.js";
6
- import SuperOpenable from "../core/super-openable.js";
5
+ import { scopePrefix } from "../core/global-style.js";
6
+ import { SuperOpenable } from "../core/super-openable.js";
7
+ import {
8
+ type DirectionCardinal,
9
+ type DirectionCenter,
10
+ type DirectionCorner,
11
+ directionInsetAlign,
12
+ } from "../core/direction.js";
7
13
 
8
14
  const protoName = "dialog";
9
15
  const cssScope = scopePrefix(protoName);
@@ -19,87 +25,77 @@ const cssScope = scopePrefix(protoName);
19
25
  * @category feedback
20
26
  */
21
27
  @godown(protoName)
22
- @styles(css`
23
- :host {
24
- ${cssScope}--background: none;
25
- ${cssScope}--background-modal: var(${cssGlobalVars.background});
26
- ${cssScope}--opacity-modal: 0.2;
27
- background: var(${cssScope}--background);
28
- pointer-events: none;
29
- visibility: hidden;
30
- position: fixed;
31
- z-index: 1;
32
- inset: 0;
33
- }
34
-
35
- :host([open]) {
36
- visibility: visible;
37
- }
38
-
39
- :host([open][modal]) [part="modal"] {
40
- pointer-events: all;
41
- visibility: visible;
42
- opacity: var(${cssScope}--opacity-modal);
43
- }
44
-
45
- [part="modal"] {
46
- visibility: hidden;
47
- opacity: 0;
48
- width: 100%;
49
- height: 100%;
50
- position: absolute;
51
- background: var(${cssScope}--background-modal);
52
- }
53
-
54
- [part="root"] {
55
- width: 100%;
56
- height: 100%;
57
- display: flex;
58
- position: relative;
59
- align-items: center;
60
- justify-content: center;
61
- }
28
+ @styles(
29
+ directionInsetAlign,
30
+ css`
31
+ :host {
32
+ ${cssScope}--background: none;
33
+ ${cssScope}--background-modal: black;
34
+ ${cssScope}--opacity-modal: 0.2;
35
+ background: var(${cssScope}--background);
36
+ pointer-events: none;
37
+ visibility: hidden;
38
+ position: fixed;
39
+ z-index: 1;
40
+ inset: 0;
41
+ }
62
42
 
63
- [part="container"] {
64
- pointer-events: all;
65
- position: absolute;
66
- }
43
+ :host([open]) {
44
+ visibility: visible;
45
+ }
67
46
 
68
- [direction^="top"] [part="container"] {
69
- top: 0;
70
- }
47
+ :host([open][modal]) [part="modal"] {
48
+ pointer-events: all;
49
+ visibility: visible;
50
+ opacity: var(${cssScope}--opacity-modal);
51
+ }
71
52
 
72
- [direction^="bottom"] [part="container"] {
73
- bottom: 0;
74
- }
53
+ [part="modal"] {
54
+ visibility: hidden;
55
+ opacity: 0;
56
+ width: 100%;
57
+ height: 100%;
58
+ position: absolute;
59
+ background: var(${cssScope}--background-modal);
60
+ }
75
61
 
76
- [direction$="right"] [part="container"] {
77
- right: 0;
78
- }
62
+ [part="root"] {
63
+ width: 100%;
64
+ height: 100%;
65
+ display: flex;
66
+ position: relative;
67
+ align-items: center;
68
+ justify-content: center;
69
+ }
79
70
 
80
- [direction$="left"] [part="container"] {
81
- left: 0;
82
- }
83
- `)
71
+ [part="container"] {
72
+ pointer-events: all;
73
+ position: absolute;
74
+ }
75
+ `,
76
+ )
84
77
  class Dialog extends SuperOpenable {
85
78
  /**
86
- * Direction of the opening animation.
87
- * @deprecated
79
+ * The direction of the dialog container.
88
80
  */
89
- direction: string;
81
+ @property()
82
+ direction: DirectionCardinal | DirectionCorner | DirectionCenter;
90
83
 
91
84
  /**
92
- * Enable modal, blocking event penetration.
85
+ * Indicates whether the dialog should be displayed as a modal.
93
86
  */
94
87
  @property({ type: Boolean, reflect: true })
95
88
  modal = false;
96
89
 
97
90
  /**
98
- * Close key.
91
+ * The keys will close the dialog when pressed.
99
92
  */
100
93
  @property()
101
94
  key = "Escape";
102
95
 
96
+ /**
97
+ * Indicates whether the modal has been invoked.
98
+ */
103
99
  private __modalInvoke = false;
104
100
 
105
101
  protected render(): TemplateResult<1> {
@@ -109,7 +105,12 @@ class Dialog extends SuperOpenable {
109
105
  ${attr(this.observedRecord)}
110
106
  >
111
107
  <div part="modal"></div>
112
- <div part="container">${htmlSlot()}</div>
108
+ <div
109
+ part="container"
110
+ direction-inset-align
111
+ >
112
+ ${htmlSlot()}
113
+ </div>
113
114
  </div>
114
115
  `;
115
116
  }
@@ -40,7 +40,7 @@ const protoName = "divider";
40
40
  `)
41
41
  class Divider extends GlobalStyle {
42
42
  /**
43
- * Vertical display.
43
+ * Whether to display the divider vertically.
44
44
  */
45
45
  @property({ type: Boolean, reflect: true })
46
46
  vertical = false;
@@ -60,6 +60,8 @@ class Heading extends GlobalStyle {
60
60
 
61
61
  /**
62
62
  * The anchor prefix.
63
+ *
64
+ * Element must have an id to be displayed.
63
65
  */
64
66
  @property()
65
67
  anchor = "#";
@@ -1,9 +1,10 @@
1
- import { attr, classList, godown, part, styles } from "@godown/element";
1
+ import { attr, tokenList, godown, part, styles, htmlSlot } from "@godown/element";
2
+ import iconEyeSlashFill from "@godown/f7-icon/icons/eye-slash-fill.js";
2
3
  import { type TemplateResult, css, html, nothing } from "lit";
3
4
  import { property } from "lit/decorators.js";
4
5
 
5
6
  import { cssGlobalVars } from "../core/global-style.js";
6
- import SuperInput from "../core/super-input.js";
7
+ import { SuperInput } from "../core/super-input.js";
7
8
 
8
9
  const protoName = "input";
9
10
 
@@ -19,11 +20,13 @@ const protoName = "input";
19
20
  :host {
20
21
  width: var(${cssGlobalVars.input}-width);
21
22
  height: var(${cssGlobalVars.input}-height);
22
- color: var(${cssGlobalVars.foreground});
23
- background: var(${cssGlobalVars.input}-background);
24
- border-radius: var(${cssGlobalVars.input}-radius);
25
23
  display: block;
26
24
  }
25
+
26
+ :host(:focus-within),
27
+ .outline {
28
+ ${cssGlobalVars.input}-outline-color: var(${cssGlobalVars.active});
29
+ }
27
30
  `)
28
31
  class Input extends SuperInput {
29
32
  type: "text" | "search" | "tel" | "url" | "email" | "password" = "text";
@@ -44,7 +47,7 @@ class Input extends SuperInput {
44
47
  <div
45
48
  part="root"
46
49
  ${attr(this.observedRecord)}
47
- class="${classList("input-field", this.variant)}"
50
+ class="${tokenList("input-field", this.variant)}"
48
51
  >
49
52
  ${[
50
53
  this._renderPrefix(),
@@ -68,9 +71,27 @@ class Input extends SuperInput {
68
71
  `;
69
72
  }
70
73
 
71
- reset(): void {
72
- this._input.value = this.default;
73
- this.value = this.default;
74
+ protected _renderSuffix(): TemplateResult<1> {
75
+ const PASSWORD = "password";
76
+ return html`
77
+ <label
78
+ for=${this.makeId}
79
+ part="suffix"
80
+ >
81
+ ${this.type === PASSWORD
82
+ ? html`
83
+ <i
84
+ part="icon"
85
+ @mousedown="${() => this._changeInputType("text")}"
86
+ @mouseup="${() => this._changeInputType(PASSWORD)}"
87
+ @mouseleave="${() => this._changeInputType(PASSWORD)}"
88
+ >
89
+ ${iconEyeSlashFill()}
90
+ </i>
91
+ `
92
+ : htmlSlot("suffix")}
93
+ </label>
94
+ `;
74
95
  }
75
96
  }
76
97
 
@@ -1,7 +1,7 @@
1
1
  import { godown } from "@godown/element";
2
2
  import { property } from "lit/decorators.js";
3
3
 
4
- import SuperAnchor from "../core/super-anchor.js";
4
+ import { SuperAnchor } from "../core/super-anchor.js";
5
5
  import Router from "./router.js";
6
6
 
7
7
  const protoName = "link";
@@ -92,13 +92,13 @@ class Link extends SuperAnchor {
92
92
  handleState: () => void = () => {
93
93
  switch (this.type) {
94
94
  case linkTypes.auto:
95
- // biome-ignore lint: if replace is true, fallthrough to replace case
96
95
  case linkTypes.push:
97
96
  if (!this.replace) {
98
97
  // type is auto or push and replace is false
99
98
  history.pushState(this.state, "", this.href);
100
99
  break;
101
100
  }
101
+ // fallthrough to replace
102
102
  case linkTypes.replace:
103
103
  history.replaceState(this.state, "", this.href);
104
104
  break;
@@ -1,4 +1,4 @@
1
- import { attr, godown, isNil, styles } from "@godown/element";
1
+ import { attr, godown, isNil, Ranger, styles } from "@godown/element";
2
2
  import { type TemplateResult, css, html } from "lit";
3
3
  import { property } from "lit/decorators.js";
4
4
 
@@ -31,6 +31,7 @@ const protoName = "progress";
31
31
  z-index: 1;
32
32
  position: relative;
33
33
  border-radius: inherit;
34
+ overflow: hidden;
34
35
  }
35
36
 
36
37
  [part="value"] {
@@ -72,12 +73,8 @@ class Progress extends GlobalStyle {
72
73
  let width = 20;
73
74
  let className: string;
74
75
  if (!isNil(this.value)) {
75
- width = this.parsePercent(this.value);
76
- if (width > 100) {
77
- width = 100;
78
- } else if (width < 0) {
79
- width = 0;
80
- }
76
+ const ranger = new Ranger(this.min, this.max);
77
+ width = ranger.restrict(this.value / ranger.diff) * 100;
81
78
  className = "static";
82
79
  }
83
80
  return html`
@@ -93,24 +90,6 @@ class Progress extends GlobalStyle {
93
90
  </div>
94
91
  `;
95
92
  }
96
-
97
- /**
98
- * Convert s to a percentage without a percent sign.
99
- *
100
- * @param s String or number to convert.
101
- * @returns Percentage without a percent sign.
102
- */
103
- parsePercent(s: string | number = "0"): number {
104
- s = String(s);
105
- if (s.includes("%")) {
106
- return parseFloat(s);
107
- }
108
- const diff = this.max - this.min;
109
- if (diff === 0) {
110
- return 100;
111
- }
112
- return (parseFloat(s) / diff) * 100;
113
- }
114
93
  }
115
94
 
116
95
  export default Progress;