godown 3.3.0 → 3.5.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 (237) hide show
  1. package/build/godown+lit.iife.js +4 -4
  2. package/build/godown+lit.iife.js.map +1 -1
  3. package/build/godown+lit.js +4 -4
  4. package/build/godown+lit.js.map +1 -1
  5. package/build/godown+lit.umd.js +4 -4
  6. package/build/godown+lit.umd.js.map +1 -1
  7. package/build/godown.iife.js +4 -4
  8. package/build/godown.js +4 -4
  9. package/build/godown.js.map +1 -1
  10. package/build/godown.umd.js +4 -4
  11. package/build/godown.umd.js.map +1 -1
  12. package/components/alert.js +1 -1
  13. package/components/alert.js.map +1 -1
  14. package/components/avatar.d.ts +5 -4
  15. package/components/avatar.d.ts.map +1 -1
  16. package/components/avatar.js +1 -1
  17. package/components/avatar.js.map +1 -1
  18. package/components/badge.d.ts +10 -2
  19. package/components/badge.d.ts.map +1 -1
  20. package/components/badge.js.map +1 -1
  21. package/components/breath.d.ts +2 -3
  22. package/components/breath.d.ts.map +1 -1
  23. package/components/breath.js +1 -1
  24. package/components/breath.js.map +1 -1
  25. package/components/button.d.ts +7 -2
  26. package/components/button.d.ts.map +1 -1
  27. package/components/button.js +1 -1
  28. package/components/button.js.map +1 -1
  29. package/components/card.d.ts +6 -0
  30. package/components/card.d.ts.map +1 -1
  31. package/components/card.js +1 -1
  32. package/components/card.js.map +1 -1
  33. package/components/carousel.d.ts +2 -2
  34. package/components/details.d.ts +3 -3
  35. package/components/details.d.ts.map +1 -1
  36. package/components/dialog.d.ts +9 -6
  37. package/components/dialog.d.ts.map +1 -1
  38. package/components/dialog.js +1 -1
  39. package/components/dialog.js.map +1 -1
  40. package/components/divider.d.ts +1 -1
  41. package/components/divider.d.ts.map +1 -1
  42. package/components/divider.js +1 -1
  43. package/components/divider.js.map +1 -1
  44. package/components/heading.d.ts +2 -0
  45. package/components/heading.d.ts.map +1 -1
  46. package/components/heading.js.map +1 -1
  47. package/components/input.d.ts +2 -2
  48. package/components/input.d.ts.map +1 -1
  49. package/components/input.js +1 -1
  50. package/components/input.js.map +1 -1
  51. package/components/link.d.ts +1 -1
  52. package/components/link.d.ts.map +1 -1
  53. package/components/link.js +1 -1
  54. package/components/link.js.map +1 -1
  55. package/components/progress.d.ts +0 -7
  56. package/components/progress.d.ts.map +1 -1
  57. package/components/progress.js +1 -1
  58. package/components/progress.js.map +1 -1
  59. package/components/range.d.ts +50 -15
  60. package/components/range.d.ts.map +1 -1
  61. package/components/range.js +1 -1
  62. package/components/range.js.map +1 -1
  63. package/components/rotate.d.ts +6 -4
  64. package/components/rotate.d.ts.map +1 -1
  65. package/components/rotate.js.map +1 -1
  66. package/components/select.d.ts +4 -2
  67. package/components/select.d.ts.map +1 -1
  68. package/components/select.js +1 -1
  69. package/components/select.js.map +1 -1
  70. package/components/split.d.ts +2 -1
  71. package/components/split.d.ts.map +1 -1
  72. package/components/split.js +1 -1
  73. package/components/split.js.map +1 -1
  74. package/components/switch.d.ts +10 -20
  75. package/components/switch.d.ts.map +1 -1
  76. package/components/switch.js +1 -1
  77. package/components/switch.js.map +1 -1
  78. package/components/time.d.ts +2 -2
  79. package/components/time.d.ts.map +1 -1
  80. package/components/time.js.map +1 -1
  81. package/components/tooltip.d.ts +3 -2
  82. package/components/tooltip.d.ts.map +1 -1
  83. package/components/tooltip.js +1 -1
  84. package/components/tooltip.js.map +1 -1
  85. package/core/direction.d.ts +27 -0
  86. package/core/direction.d.ts.map +1 -0
  87. package/core/direction.js +2 -0
  88. package/core/direction.js.map +1 -0
  89. package/core/global-style.d.ts +0 -2
  90. package/core/global-style.d.ts.map +1 -1
  91. package/core/global-style.js +1 -1
  92. package/core/global-style.js.map +1 -1
  93. package/core/outline.d.ts +20 -0
  94. package/core/outline.d.ts.map +1 -0
  95. package/core/outline.js +2 -0
  96. package/core/outline.js.map +1 -0
  97. package/core/super-anchor.d.ts +2 -2
  98. package/core/super-anchor.d.ts.map +1 -1
  99. package/core/super-anchor.js +1 -1
  100. package/core/super-anchor.js.map +1 -1
  101. package/core/super-input.d.ts +4 -2
  102. package/core/super-input.d.ts.map +1 -1
  103. package/core/super-input.js +1 -1
  104. package/core/super-input.js.map +1 -1
  105. package/core/super-openable.d.ts +0 -4
  106. package/core/super-openable.d.ts.map +1 -1
  107. package/custom-elements.json +1 -1
  108. package/dev/components/alert.js +1 -1
  109. package/dev/components/avatar.d.ts +5 -4
  110. package/dev/components/avatar.d.ts.map +1 -1
  111. package/dev/components/avatar.js +7 -5
  112. package/dev/components/avatar.js.map +1 -1
  113. package/dev/components/badge.d.ts +10 -2
  114. package/dev/components/badge.d.ts.map +1 -1
  115. package/dev/components/badge.js +8 -0
  116. package/dev/components/badge.js.map +1 -1
  117. package/dev/components/breath.d.ts +2 -3
  118. package/dev/components/breath.d.ts.map +1 -1
  119. package/dev/components/breath.js +3 -14
  120. package/dev/components/breath.js.map +1 -1
  121. package/dev/components/button.d.ts +7 -2
  122. package/dev/components/button.d.ts.map +1 -1
  123. package/dev/components/button.js +19 -5
  124. package/dev/components/button.js.map +1 -1
  125. package/dev/components/card.d.ts +6 -0
  126. package/dev/components/card.d.ts.map +1 -1
  127. package/dev/components/card.js +15 -11
  128. package/dev/components/card.js.map +1 -1
  129. package/dev/components/carousel.d.ts +2 -2
  130. package/dev/components/carousel.js +2 -2
  131. package/dev/components/details.d.ts +3 -3
  132. package/dev/components/details.d.ts.map +1 -1
  133. package/dev/components/details.js +3 -3
  134. package/dev/components/details.js.map +1 -1
  135. package/dev/components/dialog.d.ts +9 -6
  136. package/dev/components/dialog.d.ts.map +1 -1
  137. package/dev/components/dialog.js +58 -62
  138. package/dev/components/dialog.js.map +1 -1
  139. package/dev/components/divider.d.ts +1 -1
  140. package/dev/components/divider.d.ts.map +1 -1
  141. package/dev/components/divider.js +3 -2
  142. package/dev/components/divider.js.map +1 -1
  143. package/dev/components/heading.d.ts +2 -0
  144. package/dev/components/heading.d.ts.map +1 -1
  145. package/dev/components/heading.js +2 -0
  146. package/dev/components/heading.js.map +1 -1
  147. package/dev/components/input.d.ts +2 -2
  148. package/dev/components/input.d.ts.map +1 -1
  149. package/dev/components/input.js +29 -8
  150. package/dev/components/input.js.map +1 -1
  151. package/dev/components/link.d.ts +1 -1
  152. package/dev/components/link.d.ts.map +1 -1
  153. package/dev/components/link.js +2 -2
  154. package/dev/components/link.js.map +1 -1
  155. package/dev/components/progress.d.ts +0 -7
  156. package/dev/components/progress.d.ts.map +1 -1
  157. package/dev/components/progress.js +4 -25
  158. package/dev/components/progress.js.map +1 -1
  159. package/dev/components/range.d.ts +50 -15
  160. package/dev/components/range.d.ts.map +1 -1
  161. package/dev/components/range.js +50 -14
  162. package/dev/components/range.js.map +1 -1
  163. package/dev/components/rotate.d.ts +6 -4
  164. package/dev/components/rotate.d.ts.map +1 -1
  165. package/dev/components/rotate.js +6 -4
  166. package/dev/components/rotate.js.map +1 -1
  167. package/dev/components/select.d.ts +4 -2
  168. package/dev/components/select.d.ts.map +1 -1
  169. package/dev/components/select.js +27 -24
  170. package/dev/components/select.js.map +1 -1
  171. package/dev/components/split.d.ts +2 -1
  172. package/dev/components/split.d.ts.map +1 -1
  173. package/dev/components/split.js +12 -7
  174. package/dev/components/split.js.map +1 -1
  175. package/dev/components/switch.d.ts +10 -20
  176. package/dev/components/switch.d.ts.map +1 -1
  177. package/dev/components/switch.js +57 -98
  178. package/dev/components/switch.js.map +1 -1
  179. package/dev/components/time.d.ts +2 -2
  180. package/dev/components/time.d.ts.map +1 -1
  181. package/dev/components/time.js.map +1 -1
  182. package/dev/components/tooltip.d.ts +3 -2
  183. package/dev/components/tooltip.d.ts.map +1 -1
  184. package/dev/components/tooltip.js +7 -19
  185. package/dev/components/tooltip.js.map +1 -1
  186. package/dev/core/direction.d.ts +27 -0
  187. package/dev/core/direction.d.ts.map +1 -0
  188. package/dev/core/direction.js +56 -0
  189. package/dev/core/direction.js.map +1 -0
  190. package/dev/core/global-style.d.ts +0 -2
  191. package/dev/core/global-style.d.ts.map +1 -1
  192. package/dev/core/global-style.js +3 -7
  193. package/dev/core/global-style.js.map +1 -1
  194. package/dev/core/outline.d.ts +20 -0
  195. package/dev/core/outline.d.ts.map +1 -0
  196. package/dev/core/outline.js +44 -0
  197. package/dev/core/outline.js.map +1 -0
  198. package/dev/core/super-anchor.d.ts +2 -2
  199. package/dev/core/super-anchor.d.ts.map +1 -1
  200. package/dev/core/super-anchor.js +0 -1
  201. package/dev/core/super-anchor.js.map +1 -1
  202. package/dev/core/super-input.d.ts +4 -2
  203. package/dev/core/super-input.d.ts.map +1 -1
  204. package/dev/core/super-input.js +25 -30
  205. package/dev/core/super-input.js.map +1 -1
  206. package/dev/core/super-openable.d.ts +0 -4
  207. package/dev/core/super-openable.d.ts.map +1 -1
  208. package/package.json +3 -3
  209. package/src/components/alert.ts +1 -1
  210. package/src/components/avatar.ts +9 -6
  211. package/src/components/badge.ts +10 -3
  212. package/src/components/breath.ts +5 -17
  213. package/src/components/button.ts +18 -5
  214. package/src/components/card.ts +15 -11
  215. package/src/components/carousel.ts +2 -2
  216. package/src/components/details.ts +3 -3
  217. package/src/components/dialog.ts +66 -65
  218. package/src/components/divider.ts +3 -2
  219. package/src/components/heading.ts +2 -0
  220. package/src/components/input.ts +29 -8
  221. package/src/components/link.ts +2 -2
  222. package/src/components/progress.ts +4 -25
  223. package/src/components/range.ts +64 -26
  224. package/src/components/rotate.ts +6 -4
  225. package/src/components/select.ts +33 -26
  226. package/src/components/split.ts +13 -7
  227. package/src/components/switch.ts +62 -94
  228. package/src/components/time.ts +2 -2
  229. package/src/components/tooltip.ts +8 -20
  230. package/src/core/direction.ts +65 -0
  231. package/src/core/global-style.ts +3 -9
  232. package/src/core/outline.ts +54 -0
  233. package/src/core/super-anchor.ts +3 -2
  234. package/src/core/super-input.ts +31 -33
  235. package/src/core/super-openable.ts +0 -8
  236. package/vscode.html-custom-data.json +1 -1
  237. package/web-types.json +1 -1
@@ -4,6 +4,8 @@ import { type TemplateResult, css, html, nothing } from "lit";
4
4
  import { property, state } from "lit/decorators.js";
5
5
 
6
6
  import Input from "./input.js";
7
+ import { cssGlobalVars } from "../core/global-style.js";
8
+ import { type DirectionCardinalY, directionOutsetPlace } from "../core/direction.js";
7
9
 
8
10
  function contain(a: string, b: string): boolean {
9
11
  return a && b && a.toLowerCase().includes(b.toLowerCase());
@@ -46,29 +48,29 @@ const protoName = "select";
46
48
  * @category input
47
49
  */
48
50
  @godown(protoName)
49
- @styles(css`
50
- [part="input"] {
51
- text-overflow: ellipsis;
52
- }
53
-
54
- [part="content"] {
55
- position: absolute;
56
- width: 100%;
57
- visibility: hidden;
58
- }
51
+ @styles(
52
+ directionOutsetPlace,
53
+ css`
54
+ :host(:focus-within),
55
+ .outline {
56
+ ${cssGlobalVars.input}-outline-color: var(${cssGlobalVars.active});
57
+ }
59
58
 
60
- [direction="bottom"] [part="content"] {
61
- top: 100%;
62
- }
59
+ [part="input"] {
60
+ text-overflow: ellipsis;
61
+ }
63
62
 
64
- [direction="top"] [part="content"] {
65
- bottom: 100%;
66
- }
63
+ [part="content"] {
64
+ position: absolute;
65
+ width: 100%;
66
+ visibility: hidden;
67
+ }
67
68
 
68
- [visible] [part="content"] {
69
- visibility: visible;
70
- }
71
- `)
69
+ [visible] [part="content"] {
70
+ visibility: visible;
71
+ }
72
+ `,
73
+ )
72
74
  class Select extends Input {
73
75
  // @ts-ignore
74
76
  value: string | string[];
@@ -83,7 +85,7 @@ class Select extends Input {
83
85
  protected _content: HTMLElement;
84
86
 
85
87
  @property()
86
- direction: "top" | "bottom" | undefined;
88
+ direction: DirectionCardinalY;
87
89
 
88
90
  @property({ type: Boolean })
89
91
  multiple = false;
@@ -92,21 +94,25 @@ class Select extends Input {
92
94
  visible = false;
93
95
 
94
96
  @state()
95
- protected autoDirection: "top" | "bottom" = "bottom";
97
+ protected autoDirection: DirectionCardinalY = "bottom";
96
98
 
97
99
  protected lastChecked: HTMLElement;
98
100
  protected defaultText: string;
99
101
  protected defaultChecked: HTMLElement[];
100
102
  private __store: { value: string; text: string }[] = [];
101
103
 
104
+ get observedRecord(): Record<string, any> {
105
+ return {
106
+ ...super.observedRecord,
107
+ direction: this.direction || this.autoDirection,
108
+ };
109
+ }
110
+
102
111
  protected render(): TemplateResult<1> {
103
112
  return html`
104
113
  <div
105
114
  part="root"
106
- ${attr({
107
- ...this.observedRecord,
108
- direction: this.direction || this.autoDirection,
109
- })}
115
+ ${attr(this.observedRecord)}
110
116
  class="input-field"
111
117
  >
112
118
  ${[
@@ -138,6 +144,7 @@ class Select extends Input {
138
144
  <label
139
145
  for="${this.makeId}"
140
146
  part="content"
147
+ direction-outset-place
141
148
  >
142
149
  ${htmlSlot()}
143
150
  </label>
@@ -1,9 +1,9 @@
1
- import { type HandlerEvent, attr, tokenList, godown, styles, loop } from "@godown/element";
1
+ import { type HandlerEvent, attr, tokenList, godown, styles, loop, omit } from "@godown/element";
2
2
  import { type TemplateResult, css, html } from "lit";
3
3
  import { property, state } from "lit/decorators.js";
4
4
 
5
5
  import { cssGlobalVars, scopePrefix } from "../core/global-style.js";
6
- import SuperInput from "../core/super-input.js";
6
+ import { SuperInput } from "../core/super-input.js";
7
7
 
8
8
  const protoName = "split";
9
9
  const cssScope = scopePrefix(protoName);
@@ -24,7 +24,6 @@ const cssScope = scopePrefix(protoName);
24
24
  @godown(protoName)
25
25
  @styles(css`
26
26
  :host {
27
- color: var(${cssGlobalVars.foreground});
28
27
  display: block;
29
28
  border-radius: 1px;
30
29
  width: fit-content;
@@ -50,9 +49,10 @@ const cssScope = scopePrefix(protoName);
50
49
  width: var(${cssScope}--size);
51
50
  height: var(${cssScope}--size);
52
51
  vertical-align: top;
53
- text-align: center;
54
- background-color: var(${cssGlobalVars.input}-background);
55
52
  border-radius: inherit;
53
+ display: inline-flex;
54
+ align-items: center;
55
+ justify-content: center;
56
56
  }
57
57
 
58
58
  [part="input"] {
@@ -64,8 +64,9 @@ const cssScope = scopePrefix(protoName);
64
64
  z-index: -1;
65
65
  }
66
66
 
67
- .focus {
68
- box-shadow: var(${cssGlobalVars.input}-box-shadow);
67
+ .focus,
68
+ [part="input-box"]:active {
69
+ ${cssGlobalVars.input}-outline-color: var(${cssGlobalVars.active});
69
70
  }
70
71
  `)
71
72
  class Split extends SuperInput {
@@ -87,6 +88,10 @@ class Split extends SuperInput {
87
88
  @state()
88
89
  currentValue: (string | void)[] = [];
89
90
 
91
+ get observedRecord(): Record<string, any> {
92
+ return omit(super.observedRecord, "outline-type");
93
+ }
94
+
90
95
  protected render(): TemplateResult<1> {
91
96
  return html`
92
97
  <div
@@ -98,6 +103,7 @@ class Split extends SuperInput {
98
103
  (index: number) => html`
99
104
  <span
100
105
  part="input-box"
106
+ outline-type="${this.outlineType}"
101
107
  class="${tokenList({ focus: this.current === index })}"
102
108
  @click="${this.disabled ? null : () => this.focusAt(index)}"
103
109
  >
@@ -1,9 +1,9 @@
1
- import { attr, godown, styles } from "@godown/element";
1
+ import { attr, godown, omit, styles } from "@godown/element";
2
2
  import { type TemplateResult, css, html } from "lit";
3
- import { property, query } from "lit/decorators.js";
3
+ import { property } from "lit/decorators.js";
4
4
 
5
5
  import { cssGlobalVars, scopePrefix } from "../core/global-style.js";
6
- import SuperInput from "../core/super-input.js";
6
+ import { SuperInput } from "../core/super-input.js";
7
7
 
8
8
  const protoName = "switch";
9
9
  const cssScope = scopePrefix(protoName);
@@ -11,9 +11,6 @@ const cssScope = scopePrefix(protoName);
11
11
  /**
12
12
  * {@linkcode Switch} renders a switch.
13
13
  *
14
- * The switch is rectangular by default,
15
- * set the round property to rounded switch.
16
- *
17
14
  * @fires change - Fires when the switch is switched.
18
15
  * @category input
19
16
  */
@@ -30,153 +27,124 @@ const cssScope = scopePrefix(protoName);
30
27
  ${cssScope}-width: 3em;
31
28
  ${cssScope}-height: calc(var(${cssScope}-width) / 2);
32
29
  ${cssScope}-handle-size: 1.25em;
33
- ${cssScope}-handle-space: .125em;
30
+ ${cssScope}-handle-space: calc(var(${cssScope}-width) / 4 - var(${cssScope}-handle-size) / 2);
34
31
  ${cssScope}-transition: .2s ease-in-out;
35
- background: var(${cssGlobalVars.input}-background);
32
+ border-radius: calc(var(${cssScope}-height) / 2);
33
+ background: var(${cssGlobalVars.passive});
36
34
  vertical-align: bottom;
37
- border-radius: 0;
35
+ transition: 0.2s ease-in-out;
36
+ transition-property: background, left;
38
37
  }
39
38
 
40
- [part="root"],
41
- [part="handle"] {
42
- transition: var(${cssScope}-transition);
39
+ :host([checked]) {
40
+ background: var(${cssGlobalVars.active});
43
41
  }
44
42
 
45
43
  [part="root"] {
46
- border-radius: inherit;
47
- position: relative;
48
44
  height: inherit;
49
- }
50
-
51
- [part="input"] {
52
- opacity: 0;
53
- width: 100%;
54
- height: 100%;
55
- appearance: none;
45
+ display: flex;
46
+ align-items: center;
47
+ position: relative;
48
+ transition: inherit;
56
49
  }
57
50
 
58
51
  [part="handle"] {
59
- height: 100%;
60
- display: inline-flex;
52
+ display: flex;
61
53
  align-items: center;
62
54
  justify-content: center;
63
55
  position: absolute;
56
+ transition: inherit;
64
57
  left: 0;
65
- width: 50%;
58
+ top: 50%;
66
59
  pointer-events: none;
67
- border-radius: inherit;
68
- }
69
-
70
- :host([round]) {
71
- border-radius: calc(var(${cssScope}-height) / 2);
72
- background: var(${cssGlobalVars.passive});
60
+ border-radius: 100%;
61
+ background: currentColor;
62
+ --size: var(${cssScope}-handle-size);
63
+ width: var(--size);
64
+ height: var(--size);
65
+ transform: translateY(-50%) translateX(var(${cssScope}-handle-space));
73
66
  }
74
67
 
75
68
  :host([checked]) [part="handle"] {
76
69
  left: 50%;
77
70
  }
78
71
 
79
- .rect .true {
80
- background: var(${cssGlobalVars.active});
81
- }
82
-
83
- .rect .false {
84
- background: var(${cssGlobalVars.passive});
85
- }
86
-
87
- .round [part="handle"] {
88
- --size: var(${cssScope}-handle-size);
89
- border-radius: 100%;
90
- background: var(--godown--input-control);
91
- width: var(--size);
92
- height: var(--size);
93
- margin: var(${cssScope}-handle-space);
94
- }
95
-
96
- :host([checked]) .round {
97
- background: var(${cssGlobalVars.active});
72
+ [part="input"] {
73
+ opacity: 0;
74
+ width: 100%;
75
+ height: 100%;
98
76
  }
99
77
  `)
100
- class Switch extends SuperInput {
78
+ class Switch extends SuperInput<boolean> {
101
79
  /**
102
- * Display rounded.
80
+ * @deprecated
103
81
  */
104
- @property({ type: Boolean, reflect: true })
105
- round = false;
82
+ round: boolean;
106
83
 
107
- /**
108
- * Whether this element is selected or not.
109
- */
110
- @property({ type: Boolean, reflect: true })
111
- checked = false;
84
+ set checked(v: boolean) {
85
+ this.value = v;
86
+ }
112
87
 
113
- /**
114
- * Disable this element.
115
- */
116
- @property({ type: Boolean, reflect: true })
117
- disabled = false;
88
+ get checked(): boolean {
89
+ return this.value;
90
+ }
118
91
 
119
92
  /**
120
93
  * Default checked state.
121
94
  */
122
- @property()
123
- default = "false";
95
+ @property({ type: Boolean })
96
+ default = false;
124
97
 
125
98
  /**
126
- * Input value.
99
+ * The current value of the switch component. Reflects the "checked" attribute.
127
100
  */
128
- @property()
129
- value = "on";
101
+ @property({ type: Boolean, attribute: "checked", reflect: true })
102
+ value = false;
130
103
 
131
- @query("input")
132
- protected _input: HTMLInputElement;
104
+ get observedRecord(): Record<string, any> {
105
+ return omit(super.observedRecord, "outline-type");
106
+ }
133
107
 
134
108
  protected render(): TemplateResult<1> {
135
109
  return html`
136
110
  <div
137
111
  part="root"
138
112
  ${attr(this.observedRecord)}
139
- class="${this.round ? "round" : "rect"}"
113
+ class="round"
140
114
  >
141
115
  <input
142
116
  part="input"
143
117
  type="checkbox"
144
118
  ?disabled="${this.disabled}"
145
- ?checked="${this.checked}"
146
- name="${this.name}"
119
+ ?checked="${this.value}"
147
120
  id="${this.makeId}"
148
121
  @change="${this._handleChange}"
149
122
  />
150
- <span
151
- part="handle"
152
- class="${this.checked}"
153
- ></span>
123
+ <span part="handle"></span>
154
124
  </div>
155
125
  `;
156
126
  }
157
127
 
158
128
  reset(): void {
159
- this.checked = this.default === "true";
160
- this._input.checked = this.checked;
161
- }
162
-
163
- connectedCallback(): void {
164
- super.connectedCallback();
165
- if (this.checked) {
166
- this.default = "true";
167
- }
168
- if (this.default === "true") {
169
- this.checked = true;
129
+ this.value = this.default;
130
+ this._input.checked = this.value;
131
+ }
132
+
133
+ protected _connectedInit(): void {
134
+ if (this.default) {
135
+ this.value = true;
136
+ } else {
137
+ if (this.value) {
138
+ this.value = true;
139
+ this.default = true;
140
+ }
170
141
  }
171
142
  }
172
143
 
173
144
  protected _handleChange(): void {
174
- this.checked = this._input.checked;
175
- this.dispatchEvent(new CustomEvent("change", { detail: this.checked, composed: true }));
176
- }
177
-
178
- namevalue(): [string, boolean] {
179
- return [this.name, this.checked];
145
+ const { checked } = this._input;
146
+ this.value = checked;
147
+ this.dispatchCustomEvent("change", this.value);
180
148
  }
181
149
  }
182
150
 
@@ -42,13 +42,13 @@ class Time extends GlobalStyle {
42
42
  * If there is a value, update every gap or timeout.
43
43
  */
44
44
  @property({ type: Number })
45
- timeout: any;
45
+ timeout: number;
46
46
 
47
47
  /**
48
48
  * The number of milliseconds that change with each update.
49
49
  */
50
50
  @property({ type: Number })
51
- gap: any;
51
+ gap: number;
52
52
 
53
53
  protected timeoutId: number;
54
54
 
@@ -3,7 +3,8 @@ import { type TemplateResult, css, html } from "lit";
3
3
  import { property } from "lit/decorators.js";
4
4
 
5
5
  import { scopePrefix } from "../core/global-style.js";
6
- import SuperOpenable, { type Direction8 } from "../core/super-openable.js";
6
+ import { SuperOpenable } from "../core/super-openable.js";
7
+ import { type DirectionCardinal, type DirectionCorner, directionOutsetPlace } from "../core/direction.js";
7
8
 
8
9
  const protoName = "tooltip";
9
10
  const cssScope = scopePrefix(protoName);
@@ -19,6 +20,7 @@ const cssScope = scopePrefix(protoName);
19
20
  */
20
21
  @godown(protoName)
21
22
  @styles(
23
+ directionOutsetPlace,
22
24
  css`
23
25
  :host {
24
26
  ${cssScope}--tip-background: inherit;
@@ -57,23 +59,6 @@ const cssScope = scopePrefix(protoName);
57
59
  pointer-events: none;
58
60
  }
59
61
  `,
60
- css`
61
- [direction^="top"] [part="tip"] {
62
- bottom: 100%;
63
- }
64
-
65
- [direction^="bottom"] [part="tip"] {
66
- top: 100%;
67
- }
68
-
69
- [direction$="right"] [part="tip"] {
70
- left: 100%;
71
- }
72
-
73
- [direction$="left"] [part="tip"] {
74
- right: 100%;
75
- }
76
- `,
77
62
  )
78
63
  class Tooltip extends SuperOpenable {
79
64
  /**
@@ -86,7 +71,7 @@ class Tooltip extends SuperOpenable {
86
71
  * Direction of opening the tip.
87
72
  */
88
73
  @property()
89
- direction: Direction8 = "top";
74
+ direction: DirectionCardinal | DirectionCorner = "top";
90
75
 
91
76
  /**
92
77
  * Content alignment.
@@ -135,7 +120,10 @@ class Tooltip extends SuperOpenable {
135
120
  style="justify-content:${align};align-items:${align}"
136
121
  >
137
122
  ${htmlSlot()}
138
- <div part="tip">
123
+ <div
124
+ part="tip"
125
+ direction-outset-place
126
+ >
139
127
  ${this.tip
140
128
  ? html`
141
129
  <span class="passive">${this.tip}</span>
@@ -0,0 +1,65 @@
1
+ import { css, unsafeCSS, type CSSResult } from "lit";
2
+
3
+ const insetAlignSelector = unsafeCSS(`[direction-inset-align]`);
4
+
5
+ /**
6
+ * Controls the inset alignment of the element relative to the direction.
7
+ *
8
+ * ```html
9
+ * <div direction="${direction}">
10
+ * <div direction-inset-align></div>
11
+ * </div>
12
+ * ```
13
+ */
14
+ export const directionInsetAlign: CSSResult = css`
15
+ [direction^="top"] ${insetAlignSelector} {
16
+ top: 0;
17
+ }
18
+
19
+ [direction^="bottom"] ${insetAlignSelector} {
20
+ bottom: 0;
21
+ }
22
+
23
+ [direction$="right"] ${insetAlignSelector} {
24
+ right: 0;
25
+ }
26
+
27
+ [direction$="left"] ${insetAlignSelector} {
28
+ left: 0;
29
+ }
30
+ `;
31
+
32
+ const outsetPlaceSelector = unsafeCSS(`[direction-outset-place]`);
33
+
34
+ /**
35
+ * Controls the outset placement of the element relative to the direction.
36
+ *
37
+ * ```html
38
+ * <div direction="${direction}">
39
+ * <div direction-outset-place></div>
40
+ * </div>
41
+ * ```
42
+ */
43
+ export const directionOutsetPlace: CSSResult = css`
44
+ [direction^="top"] ${outsetPlaceSelector} {
45
+ bottom: 100%;
46
+ }
47
+
48
+ [direction^="bottom"] ${outsetPlaceSelector} {
49
+ top: 100%;
50
+ }
51
+
52
+ [direction$="right"] ${outsetPlaceSelector} {
53
+ left: 100%;
54
+ }
55
+
56
+ [direction$="left"] ${outsetPlaceSelector} {
57
+ right: 100%;
58
+ }
59
+ `;
60
+
61
+ export type DirectionCardinalX = "left" | "right";
62
+ export type DirectionCardinalY = "top" | "bottom";
63
+ export type DirectionCardinal = DirectionCardinalX | DirectionCardinalY;
64
+ export type DirectionCorner = "top-left" | "top-right" | "bottom-left" | "bottom-right";
65
+ export type DirectionCenter = "center";
@@ -17,8 +17,6 @@ export function variablePrefix(variable: string): CSSResult {
17
17
  }
18
18
 
19
19
  export const cssGlobalVars: {
20
- foreground: CSSResult;
21
- background: CSSResult;
22
20
  clipBackground: CSSResult;
23
21
  active: CSSResult;
24
22
  passive: CSSResult;
@@ -28,8 +26,6 @@ export const cssGlobalVars: {
28
26
  black: CSSResult;
29
27
  color: CSSResult;
30
28
  } = {
31
- foreground: scopePrefix("foreground", 2),
32
- background: scopePrefix("background", 2),
33
29
  clipBackground: scopePrefix("clip-background", 2),
34
30
  active: scopePrefix("active", 2),
35
31
  passive: scopePrefix("passive", 2),
@@ -54,13 +50,11 @@ GlobalStyle.styles = [
54
50
  return `${colorKey}:rgb(${rgb});`;
55
51
  }, presetsRGB).join("") +
56
52
  joinProperties([
57
- [cssGlobalVars.background, `var(${cssGlobalVars._colors.darkgray[9]})`],
58
- [cssGlobalVars.foreground, `var(${cssGlobalVars._colors.lightgray[0]})`],
59
- [cssGlobalVars.active, `var(${cssGlobalVars._colors.blue[6]})`],
60
- [cssGlobalVars.passive, `var(${cssGlobalVars._colors.darkgray[6]})`],
53
+ [cssGlobalVars.active, `var(${cssGlobalVars._colors.blue[5]})`],
54
+ [cssGlobalVars.passive, `var(${cssGlobalVars._colors.darkgray[5]})`],
61
55
  [
62
56
  cssGlobalVars.clipBackground,
63
- `linear-gradient(to bottom, var(${cssGlobalVars.foreground}), var(${cssGlobalVars.passive}))`,
57
+ `linear-gradient(to bottom, var(${cssGlobalVars._colors.lightgray[0]}), var(${cssGlobalVars._colors.darkgray[5]}))`,
64
58
  ],
65
59
  ]) +
66
60
  "}",
@@ -0,0 +1,54 @@
1
+ import { css, unsafeCSS, type CSSResult } from "lit";
2
+
3
+ type OutlineVars = {
4
+ width: string | CSSResult;
5
+ color: string | CSSResult;
6
+ };
7
+
8
+ /**
9
+ * The `OutlineBuilder` class is responsible for generating CSS styles for various types of outlines.
10
+ */
11
+ export class OutlineBuilder {
12
+ css: CSSResult;
13
+
14
+ /**
15
+ * @param vars.width The width variable of the outline.
16
+ * @param vars.color The color variable of the outline.
17
+ */
18
+ constructor(vars: OutlineVars) {
19
+ const width = unsafeCSS(vars.width);
20
+ const color = unsafeCSS(vars.color);
21
+ this.css = css`
22
+ [outline-type="outline"],
23
+ [outline-type="outline-inset"] {
24
+ outline-width: var(${width});
25
+ outline-color: var(${color});
26
+ outline-style: solid;
27
+ }
28
+
29
+ [outline-type="outline-inset"] {
30
+ outline-offset: calc(-1 * var(${width}));
31
+ }
32
+
33
+ [outline-type="box-shadow"] {
34
+ box-shadow: 0 0 0 var(${width}) var(${color});
35
+ }
36
+
37
+ [outline-type="box-shadow-inset"] {
38
+ box-shadow: inset 0 0 0 var(${width}) var(${color});
39
+ }
40
+
41
+ [outline-type="border"] {
42
+ border-width: var(${width});
43
+ border-color: var(${color});
44
+ border-style: solid;
45
+ }
46
+ `;
47
+ }
48
+
49
+ get styleSheet(): CSSStyleSheet {
50
+ return this.css.styleSheet;
51
+ }
52
+ }
53
+
54
+ export type OutlineType = "outline" | "outline-inset" | "box-shadow" | "box-shadow-inset" | "border";
@@ -23,12 +23,13 @@ import { GlobalStyle } from "./global-style.js";
23
23
  text-decoration: inherit;
24
24
  }
25
25
  `)
26
- class SuperAnchor extends GlobalStyle {
26
+ abstract class SuperAnchor extends GlobalStyle {
27
27
  /**
28
28
  * A element href.
29
29
  */
30
30
  @property()
31
31
  href: string;
32
+
32
33
  /**
33
34
  * A element target.
34
35
  */
@@ -53,7 +54,7 @@ class SuperAnchor extends GlobalStyle {
53
54
  `;
54
55
  }
55
56
 
56
- protected _handleClick(_: MouseEvent): void {}
57
+ protected abstract _handleClick(_: MouseEvent): void;
57
58
  }
58
59
 
59
60
  export default SuperAnchor;