godown 3.12.0 → 3.13.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 (146) hide show
  1. package/build/godown+lit.iife.js +12 -13
  2. package/build/godown+lit.iife.js.map +1 -1
  3. package/build/godown+lit.js +11 -12
  4. package/build/godown+lit.js.map +1 -1
  5. package/build/godown+lit.umd.js +12 -13
  6. package/build/godown+lit.umd.js.map +1 -1
  7. package/build/godown.iife.js +5 -5
  8. package/build/godown.iife.js.map +1 -1
  9. package/build/godown.js +5 -5
  10. package/build/godown.js.map +1 -1
  11. package/build/godown.umd.js +5 -5
  12. package/build/godown.umd.js.map +1 -1
  13. package/custom-elements.json +1 -1
  14. package/index.d.ts +1 -0
  15. package/index.d.ts.map +1 -1
  16. package/index.js +1 -1
  17. package/internal/global-style.d.ts.map +1 -1
  18. package/internal/global-style.js +1 -1
  19. package/internal/global-style.js.map +1 -1
  20. package/internal/popover.d.ts +3 -0
  21. package/internal/popover.d.ts.map +1 -0
  22. package/internal/popover.js +2 -0
  23. package/internal/popover.js.map +1 -0
  24. package/internal/reset-style.d.ts +3 -0
  25. package/internal/reset-style.d.ts.map +1 -0
  26. package/internal/reset-style.js +2 -0
  27. package/internal/reset-style.js.map +1 -0
  28. package/internal/ring.d.ts +1 -0
  29. package/internal/ring.d.ts.map +1 -1
  30. package/internal/ring.js +1 -1
  31. package/internal/ring.js.map +1 -1
  32. package/internal/super-input.d.ts +1 -1
  33. package/internal/super-input.d.ts.map +1 -1
  34. package/internal/super-input.js +1 -1
  35. package/internal/super-input.js.map +1 -1
  36. package/internal/utils.d.ts +2 -0
  37. package/internal/utils.d.ts.map +1 -0
  38. package/internal/utils.js +2 -0
  39. package/internal/utils.js.map +1 -0
  40. package/package.json +2 -3
  41. package/popover.d.ts +2 -0
  42. package/popover.d.ts.map +1 -0
  43. package/popover.js +2 -0
  44. package/popover.js.map +1 -0
  45. package/src/index.ts +1 -0
  46. package/src/internal/global-style.ts +7 -35
  47. package/src/internal/popover.ts +64 -0
  48. package/src/internal/reset-style.ts +63 -0
  49. package/src/internal/ring.ts +3 -2
  50. package/src/internal/super-input.ts +2 -2
  51. package/src/internal/utils.ts +10 -0
  52. package/src/popover.ts +1 -0
  53. package/src/web-components/alert/component.ts +8 -15
  54. package/src/web-components/avatar/component.ts +1 -0
  55. package/src/web-components/button/component.ts +6 -10
  56. package/src/web-components/card/component.ts +4 -4
  57. package/src/web-components/chip/component.ts +1 -3
  58. package/src/web-components/details/component.ts +27 -16
  59. package/src/web-components/dialog/component.ts +50 -67
  60. package/src/web-components/heading/component.ts +0 -1
  61. package/src/web-components/input/component.ts +5 -7
  62. package/src/web-components/link/component.ts +0 -2
  63. package/src/web-components/popover/component.ts +172 -0
  64. package/src/web-components/popover/definition.ts +11 -0
  65. package/src/web-components/range/component.ts +2 -1
  66. package/src/web-components/rotate/component.ts +0 -1
  67. package/src/web-components/select/component.ts +110 -173
  68. package/src/web-components/split/component.ts +2 -2
  69. package/src/web-components/switch/component.ts +2 -1
  70. package/src/web-components/tabs/component.ts +100 -101
  71. package/src/web-components/tooltip/component.ts +44 -112
  72. package/vscode.css-custom-data.json +1 -1
  73. package/vscode.html-custom-data.json +1 -1
  74. package/web-components/alert/component.d.ts.map +1 -1
  75. package/web-components/alert/component.js +1 -1
  76. package/web-components/alert/component.js.map +1 -1
  77. package/web-components/avatar/component.d.ts.map +1 -1
  78. package/web-components/avatar/component.js +1 -1
  79. package/web-components/avatar/component.js.map +1 -1
  80. package/web-components/button/component.d.ts.map +1 -1
  81. package/web-components/button/component.js +1 -1
  82. package/web-components/button/component.js.map +1 -1
  83. package/web-components/card/component.d.ts.map +1 -1
  84. package/web-components/card/component.js +1 -1
  85. package/web-components/card/component.js.map +1 -1
  86. package/web-components/chip/component.d.ts +1 -3
  87. package/web-components/chip/component.d.ts.map +1 -1
  88. package/web-components/chip/component.js.map +1 -1
  89. package/web-components/details/component.d.ts +9 -13
  90. package/web-components/details/component.d.ts.map +1 -1
  91. package/web-components/details/component.js +1 -1
  92. package/web-components/details/component.js.map +1 -1
  93. package/web-components/dialog/component.d.ts +12 -14
  94. package/web-components/dialog/component.d.ts.map +1 -1
  95. package/web-components/dialog/component.js +1 -1
  96. package/web-components/dialog/component.js.map +1 -1
  97. package/web-components/heading/component.d.ts.map +1 -1
  98. package/web-components/heading/component.js +1 -1
  99. package/web-components/heading/component.js.map +1 -1
  100. package/web-components/input/component.d.ts.map +1 -1
  101. package/web-components/input/component.js +1 -1
  102. package/web-components/input/component.js.map +1 -1
  103. package/web-components/link/component.d.ts.map +1 -1
  104. package/web-components/link/component.js +1 -1
  105. package/web-components/link/component.js.map +1 -1
  106. package/web-components/popover/component.d.ts +35 -0
  107. package/web-components/popover/component.d.ts.map +1 -0
  108. package/web-components/popover/component.js +2 -0
  109. package/web-components/popover/component.js.map +1 -0
  110. package/web-components/popover/definition.d.ts +8 -0
  111. package/web-components/popover/definition.d.ts.map +1 -0
  112. package/web-components/popover/definition.js +2 -0
  113. package/web-components/popover/definition.js.map +1 -0
  114. package/web-components/range/component.d.ts.map +1 -1
  115. package/web-components/range/component.js +1 -1
  116. package/web-components/range/component.js.map +1 -1
  117. package/web-components/rotate/component.d.ts.map +1 -1
  118. package/web-components/rotate/component.js.map +1 -1
  119. package/web-components/select/component.d.ts +11 -27
  120. package/web-components/select/component.d.ts.map +1 -1
  121. package/web-components/select/component.js +1 -1
  122. package/web-components/select/component.js.map +1 -1
  123. package/web-components/split/component.js +1 -1
  124. package/web-components/split/component.js.map +1 -1
  125. package/web-components/switch/component.d.ts.map +1 -1
  126. package/web-components/switch/component.js +1 -1
  127. package/web-components/switch/component.js.map +1 -1
  128. package/web-components/tabs/component.d.ts +18 -25
  129. package/web-components/tabs/component.d.ts.map +1 -1
  130. package/web-components/tabs/component.js +1 -1
  131. package/web-components/tabs/component.js.map +1 -1
  132. package/web-components/tooltip/component.d.ts +15 -39
  133. package/web-components/tooltip/component.d.ts.map +1 -1
  134. package/web-components/tooltip/component.js +1 -1
  135. package/web-components/tooltip/component.js.map +1 -1
  136. package/web-types.json +1 -1
  137. package/internal/direction.d.ts +0 -27
  138. package/internal/direction.d.ts.map +0 -1
  139. package/internal/direction.js +0 -2
  140. package/internal/direction.js.map +0 -1
  141. package/internal/super-openable.d.ts +0 -15
  142. package/internal/super-openable.d.ts.map +0 -1
  143. package/internal/super-openable.js +0 -2
  144. package/internal/super-openable.js.map +0 -1
  145. package/src/internal/direction.ts +0 -65
  146. package/src/internal/super-openable.ts +0 -34
@@ -4,7 +4,7 @@ import { property } from "lit/decorators.js";
4
4
 
5
5
  import { GlobalStyle, cssGlobalVars, scopePrefix } from "../../internal/global-style.js";
6
6
  import type Layout from "../layout/component.js";
7
- import { RingBuilder, type RingType } from "../../internal/ring.js";
7
+ import { RingBuilder, ringTypeAttribute, type RingType } from "../../internal/ring.js";
8
8
 
9
9
  const protoName = "card";
10
10
  const cssScope = scopePrefix(protoName);
@@ -23,15 +23,15 @@ const cssScope = scopePrefix(protoName);
23
23
  @godown(protoName)
24
24
  @styles(css`
25
25
  :host {
26
- ${cssScope}--padding: .75em;
27
26
  background: var(${cssGlobalVars.background});
27
+ color: var(${cssGlobalVars.foreground});
28
28
  display: block;
29
29
  flex-shrink: 0;
30
30
  }
31
31
 
32
32
  slot {
33
33
  display: block;
34
- padding: var(${cssScope}--padding);
34
+ padding: 1em;
35
35
  }
36
36
 
37
37
  [part="root"] {
@@ -52,7 +52,7 @@ class Card extends GlobalStyle {
52
52
  new StyleController(this, () => new RingBuilder({ type: this.ringType }).css);
53
53
  }
54
54
 
55
- @property({ attribute: "ring-type" })
55
+ @property({ attribute: ringTypeAttribute })
56
56
  ringType: RingType = "border";
57
57
 
58
58
  /**
@@ -3,7 +3,6 @@ import { type TemplateResult, css, html } from "lit";
3
3
  import { property } from "lit/decorators.js";
4
4
 
5
5
  import { GlobalStyle, cssGlobalVars, scopePrefix } from "../../internal/global-style.js";
6
- import type { DirectionCorner } from "../../internal/direction.js";
7
6
 
8
7
  const protoName = "chip";
9
8
  const cssScope = scopePrefix(protoName);
@@ -69,10 +68,9 @@ const cssScope = scopePrefix(protoName);
69
68
  class Chip extends GlobalStyle {
70
69
  /**
71
70
  * The position of the chip relative to its parent element.
72
- * Possible values are `"top-left"`, `"top-right"`, `"bottom-left"`, and `"bottom-right"`.
73
71
  */
74
72
  @property()
75
- position: DirectionCorner = "top-right";
73
+ position: "top-left" | "top-right" | "bottom-left" | "bottom-right" = "top-right";
76
74
 
77
75
  @property({ type: Number })
78
76
  value = 0;
@@ -1,10 +1,9 @@
1
1
  import { attr, godown, htmlSlot, styles } from "@godown/element";
2
2
  import svgCaretDown from "../../internal/icons/caret-down.js";
3
- import { type TemplateResult, css, html } from "lit";
3
+ import { type PropertyValueMap, type TemplateResult, css, html } from "lit";
4
4
  import { property } from "lit/decorators.js";
5
5
 
6
- import { scopePrefix } from "../../internal/global-style.js";
7
- import { SuperOpenable } from "../../internal/super-openable.js";
6
+ import GlobalStyle, { scopePrefix } from "../../internal/global-style.js";
8
7
 
9
8
  const protoName = "details";
10
9
 
@@ -13,7 +12,7 @@ const cssScope = scopePrefix(protoName);
13
12
  /**
14
13
  * {@linkcode Details} similar to `<details>`.
15
14
  *
16
- * @slot summary - Details summary if no `summary` is provided.
15
+ * @slot summary - Details summary (trigger).
17
16
  * @slot - Details content.
18
17
  * @fires change - Fires when the open changes.
19
18
  * @category display
@@ -28,7 +27,6 @@ const cssScope = scopePrefix(protoName);
28
27
  }
29
28
 
30
29
  [part="root"] {
31
- padding: 0.25em;
32
30
  position: relative;
33
31
  }
34
32
 
@@ -75,22 +73,16 @@ const cssScope = scopePrefix(protoName);
75
73
  transform: rotate(var(${cssScope}--icon-deg-open));
76
74
  }
77
75
  `)
78
- class Details extends SuperOpenable {
79
- /**
80
- * Determines whether the details component should float.
81
- */
76
+ class Details extends GlobalStyle {
77
+ @property({ type: Boolean, reflect: true })
78
+ open = false;
79
+
82
80
  @property({ type: Boolean })
83
81
  float = false;
84
82
 
85
- /**
86
- * Determines whether the details component should fill the available space.
87
- */
88
83
  @property({ type: Boolean })
89
84
  fill = false;
90
85
 
91
- /**
92
- * The summary text to display in the details component.
93
- */
94
86
  @property()
95
87
  summary = "";
96
88
 
@@ -105,7 +97,7 @@ class Details extends SuperOpenable {
105
97
  @click="${() => this.toggle()}"
106
98
  >
107
99
  <span part="summary">${htmlSlot("summary", this.summary)}</span>
108
- <span part="icon">${svgCaretDown()}</span>
100
+ <span part="icon">${htmlSlot("icon", svgCaretDown())}</span>
109
101
  </dt>
110
102
  <dd
111
103
  part="details"
@@ -116,6 +108,25 @@ class Details extends SuperOpenable {
116
108
  </dl>
117
109
  `;
118
110
  }
111
+
112
+ protected updated(changedProperties: PropertyValueMap<this>): void {
113
+ const open = changedProperties.get("open");
114
+ if (open !== undefined) {
115
+ this.dispatchCustomEvent("change", open);
116
+ }
117
+ }
118
+
119
+ toggle(to?: boolean): void {
120
+ this.open = to ?? !this.open;
121
+ }
122
+
123
+ close(): void {
124
+ this.open = false;
125
+ }
126
+
127
+ show(): void {
128
+ this.open = true;
129
+ }
119
130
  }
120
131
 
121
132
  export default Details;
@@ -1,23 +1,24 @@
1
- import { type HandlerEvent, attr, godown, htmlSlot, styles } from "@godown/element";
1
+ import { type HandlerEvent, godown, htmlSlot, queryPart, styles } from "@godown/element";
2
2
  import { type PropertyValues, type TemplateResult, css, html } from "lit";
3
- import { property, query } from "lit/decorators.js";
3
+ import { property } from "lit/decorators.js";
4
4
 
5
- import { scopePrefix } from "../../internal/global-style.js";
6
- import { SuperOpenable } from "../../internal/super-openable.js";
5
+ import GlobalStyle, { scopePrefix } from "../../internal/global-style.js";
7
6
 
8
7
  const protoName = "dialog";
9
8
  const cssScope = scopePrefix(protoName);
10
9
 
11
- const splitKeysRegexp = /[\s,]+/;
12
-
13
10
  /**
14
11
  * {@linkcode Dialog} similar to `<dialog>`.
15
12
  *
16
13
  * Like dialog, it listens for submit events and closes itself when the target method is "dialog".
17
14
  *
18
- * It listens for the keydown event and also closes itself when the {@linkcode key} contained in the key is pressed.
15
+ * Previous versions of Dialog did not contain triggers.
16
+ * Therefore, unlike Tooltip which uses the default slot as the trigger.
17
+ * Dialog needs to use slot="trigger" as the trigger instead of an element without a slot name.
19
18
  *
20
19
  * @fires change - Fires when the open changes.
20
+ * @slot trigger - The trigger element.
21
+ * @slot - The dialog content.
21
22
  * @category feedback
22
23
  */
23
24
  @godown(protoName)
@@ -27,7 +28,11 @@ const splitKeysRegexp = /[\s,]+/;
27
28
  ${cssScope}--opacity-modal: 0.2;
28
29
  width: fit-content;
29
30
  display: block;
30
- margin: auto;
31
+ background: none;
32
+ }
33
+
34
+ dialog {
35
+ position: relative;
31
36
  background: none;
32
37
  z-index: 1;
33
38
  left: 50%;
@@ -36,58 +41,39 @@ const splitKeysRegexp = /[\s,]+/;
36
41
  transform: translate(-50%, -50%);
37
42
  }
38
43
 
39
- :host(:not([open])) {
40
- visibility: hidden;
41
- }
42
-
43
- :host([contents]) dialog {
44
- position: fixed;
45
- }
46
-
47
- dialog {
48
- position: relative;
49
- background: inherit;
50
- }
51
-
52
44
  ::backdrop {
53
45
  background: var(${cssScope}--background-modal);
54
46
  opacity: var(${cssScope}--opacity-modal);
55
47
  }
56
48
  `)
57
- class Dialog extends SuperOpenable {
58
- /**
59
- * Indicates whether the dialog should be displayed as a modal.
60
- */
49
+ class Dialog extends GlobalStyle {
61
50
  @property({ type: Boolean, reflect: true })
62
- set modal(value: boolean) {
63
- this.contents = value;
64
- }
51
+ open = false;
65
52
 
66
- get modal(): boolean {
67
- return this.contents;
68
- }
69
-
70
- /**
71
- * The keys will close the dialog when pressed.
72
- */
73
- @property()
74
- key = "Escape";
53
+ @property({ type: Boolean, reflect: true })
54
+ modal = false;
75
55
 
76
56
  /**
77
57
  * Indicates whether the modal has been invoked.
78
58
  */
79
59
  private __modalInvoke = false;
80
60
 
81
- @query("dialog")
61
+ @queryPart("dialog")
82
62
  protected _dialog: HTMLDialogElement;
83
63
 
84
64
  protected render(): TemplateResult<1> {
85
65
  return html`
86
- <dialog
66
+ <div
87
67
  part="root"
88
- ${attr(this.observedRecord)}
68
+ @click=${this.show}
89
69
  >
90
- ${htmlSlot()}
70
+ ${htmlSlot("trigger")}
71
+ </div>
72
+ <dialog
73
+ part="dialog"
74
+ role="dialog"
75
+ >
76
+ ${htmlSlot("dialog")}${htmlSlot()}
91
77
  </dialog>
92
78
  `;
93
79
  }
@@ -98,19 +84,16 @@ class Dialog extends SuperOpenable {
98
84
  this.show();
99
85
  }
100
86
 
101
- attributeChangedCallback(name: string, _old: string | null, value: string | null): void {
102
- super.attributeChangedCallback(name, _old, value);
103
- if (name === "open") {
104
- if (this.open) {
105
- if (this.modal) {
106
- this._dialog.showModal();
107
- } else {
108
- this._dialog.show();
109
- }
110
- } else {
111
- this._dialog.close();
112
- }
113
- }
87
+ show(): void {
88
+ this.open = true;
89
+ }
90
+
91
+ close(): void {
92
+ this.open = false;
93
+ }
94
+
95
+ toggle(to?: boolean): void {
96
+ this.open = to ?? !this.open;
114
97
  }
115
98
 
116
99
  private __submitEvent: EventListenerOrEventListenerObject;
@@ -119,11 +102,20 @@ class Dialog extends SuperOpenable {
119
102
  protected updated(changedProperties: PropertyValues): void {
120
103
  if (changedProperties.has("open")) {
121
104
  if (this.open) {
122
- this.__submitEvent = this.events.add(this, "submit", this._handelSubmit);
123
- if (this.key) {
124
- this.__keydownEvent = this.events.add(document, "keydown", this._handleKeydown.bind(this));
105
+ if (this.modal) {
106
+ this._dialog.showModal();
107
+ } else {
108
+ this._dialog.show();
125
109
  }
110
+ this.__submitEvent = this.events.add(this, "submit", this._handelSubmit);
111
+
112
+ this.__keydownEvent = this.events.add(document, "keydown", this._handleKeydown.bind(this));
126
113
  } else {
114
+ if (this.__modalInvoke) {
115
+ this.modal = false;
116
+ this.__modalInvoke = false;
117
+ }
118
+ this._dialog.close();
127
119
  this.events.remove(this, "submit", this.__submitEvent);
128
120
  this.events.remove(document, "keydown", this.__keydownEvent);
129
121
  }
@@ -131,8 +123,7 @@ class Dialog extends SuperOpenable {
131
123
  }
132
124
 
133
125
  protected _handleKeydown(e: KeyboardEvent): void {
134
- const keys = this.key.split(splitKeysRegexp);
135
- if (keys.includes(e.key) || keys.includes(e.code)) {
126
+ if (e.key === "Escape") {
136
127
  e.preventDefault();
137
128
  this.close();
138
129
  }
@@ -144,14 +135,6 @@ class Dialog extends SuperOpenable {
144
135
  this.close();
145
136
  }
146
137
  }
147
-
148
- close(): void {
149
- if (this.__modalInvoke) {
150
- this.modal = false;
151
- this.__modalInvoke = false;
152
- }
153
- this.open = false;
154
- }
155
138
  }
156
139
 
157
140
  export default Dialog;
@@ -43,7 +43,6 @@ const protoName = "heading";
43
43
  h5,
44
44
  h6 {
45
45
  width: fit-content;
46
- font-size: revert;
47
46
  position: relative;
48
47
  }
49
48
  `)
@@ -39,7 +39,6 @@ const protoName = "input";
39
39
  @styles(css`
40
40
  :host {
41
41
  display: block;
42
- ${cssGlobalVars.input}-space: 0.2em;
43
42
  ${cssGlobalVars.input}-icon-color: hsl(0, 0%, 50%);
44
43
  }
45
44
 
@@ -49,8 +48,9 @@ const protoName = "input";
49
48
  ${cssGlobalVars.input}-icon-color: currentColor;
50
49
  }
51
50
 
52
- [part~="root"] {
53
- padding: 0.4em 0.5em;
51
+ [part="root"] {
52
+ padding-inline: 0.75em;
53
+ padding-block: 0.5em;
54
54
  display: flex;
55
55
  position: relative;
56
56
  align-items: center;
@@ -61,8 +61,6 @@ const protoName = "input";
61
61
  width: 100%;
62
62
  height: 100%;
63
63
  flex-grow: 1;
64
- color: currentColor;
65
- background: none;
66
64
  }
67
65
 
68
66
  [part="prefix"],
@@ -75,11 +73,11 @@ const protoName = "input";
75
73
  }
76
74
 
77
75
  [part="suffix"] slot svg {
78
- margin-inline-start: var(${cssGlobalVars.input}-space);
76
+ margin-inline-start: 0.25em;
79
77
  }
80
78
 
81
79
  [part="prefix"] slot svg {
82
- margin-inline-end: var(${cssGlobalVars.input}-space);
80
+ margin-inline-end: 0.25em;
83
81
  }
84
82
  `)
85
83
  class Input extends SuperInput {
@@ -39,7 +39,6 @@ type LinkType = keyof typeof linkTypes;
39
39
  @styles(css`
40
40
  :host {
41
41
  display: inline-block;
42
- color: currentColor;
43
42
  cursor: default;
44
43
  }
45
44
 
@@ -48,7 +47,6 @@ type LinkType = keyof typeof linkTypes;
48
47
  }
49
48
 
50
49
  a {
51
- color: currentColor;
52
50
  display: contents;
53
51
  }
54
52
  `)
@@ -0,0 +1,172 @@
1
+ import { property } from "lit/decorators.js";
2
+ import GlobalStyle from "../../internal/global-style.js";
3
+ import { css, html, type PropertyValues, type TemplateResult } from "lit";
4
+ import { godown, htmlSlot, joinRules, part, StyleController, styles } from "@godown/element";
5
+ import { hidePopover, showPopover } from "../../internal/popover.js";
6
+
7
+ const POPOVER = "popover";
8
+ const protoName = POPOVER;
9
+
10
+ /**
11
+ * {@link Popover} renders a popover.
12
+ *
13
+ * This requires the support of the popover API and CSS position-area.
14
+ *
15
+ * @fires toggle - Fired when the popover is toggled.
16
+ * @slot popover - Popover content.
17
+ * @slot - Popover trigger.
18
+ * @category display
19
+ */
20
+ @godown(protoName)
21
+ @styles(css`
22
+ :host {
23
+ display: inline-block;
24
+ }
25
+
26
+ [part="trigger"] {
27
+ display: contents;
28
+ }
29
+
30
+ [part="root"] {
31
+ display: inherit;
32
+ }
33
+
34
+ [part="popover"] {
35
+ inset: unset;
36
+ z-index: 1;
37
+ overflow: visible;
38
+ position: absolute;
39
+ position-try-fallbacks: flip-block;
40
+ }
41
+ `)
42
+ class Popover extends GlobalStyle {
43
+ anchorName = `--${POPOVER}-${Math.random().toString(36).slice(2)}`;
44
+
45
+ @property({ type: Boolean, reflect: true })
46
+ open = false;
47
+
48
+ @property()
49
+ action: "hide" | "show" | "toggle" | "none" = "show";
50
+
51
+ @property()
52
+ span: "span" | "spread" | "isolated" = "span";
53
+
54
+ /**
55
+ * The position refers to the spatial location of the popover in relation to the trigger,
56
+ * rather than the alignment property between them.
57
+ */
58
+ @property()
59
+ position:
60
+ | "center"
61
+ | "left"
62
+ | "left-top"
63
+ | "left-bottom"
64
+ | "right"
65
+ | "right-top"
66
+ | "right-bottom"
67
+ | "top"
68
+ | "top-left"
69
+ | "top-right"
70
+ | "bottom"
71
+ | "bottom-left"
72
+ | "bottom-right"
73
+ | "start"
74
+ | "start-start"
75
+ | "start-end"
76
+ | "end"
77
+ | "end-start"
78
+ | "end-end" = "bottom";
79
+
80
+ @part(POPOVER)
81
+ protected _popover: HTMLElement;
82
+
83
+ constructor() {
84
+ super();
85
+ new StyleController(this, () => {
86
+ return joinRules({
87
+ "[part=root],slot:not([name])::slotted(*)": {
88
+ "anchor-name": this.anchorName,
89
+ },
90
+ "[part=popover]": {
91
+ "position-anchor": this.anchorName,
92
+ "position-area": this.resolveArea(),
93
+ },
94
+ });
95
+ });
96
+ }
97
+ protected render(): TemplateResult<1> {
98
+ return html`
99
+ <div part="root">
100
+ <div
101
+ part="trigger"
102
+ @click=${this._handleClick}
103
+ >
104
+ ${htmlSlot()}
105
+ </div>
106
+ <div
107
+ part="popover"
108
+ popover="manual"
109
+ >
110
+ ${htmlSlot("popover")}
111
+ </div>
112
+ </div>
113
+ `;
114
+ }
115
+
116
+ protected _handleClick(): void {
117
+ const { action } = this;
118
+ switch (action) {
119
+ case "show":
120
+ case "hide":
121
+ case "toggle":
122
+ this[action]();
123
+ }
124
+ }
125
+
126
+ show(): void {
127
+ this.toggle(true);
128
+ }
129
+
130
+ hide(): void {
131
+ this.toggle(false);
132
+ }
133
+
134
+ toggle(force?: boolean): void {
135
+ this.open = force ?? !this.open;
136
+ }
137
+
138
+ protected updated(_changedProperties: PropertyValues): void {
139
+ if (_changedProperties.has("open")) {
140
+ this._openChange();
141
+ }
142
+ }
143
+
144
+ protected _openChange(): void {
145
+ const { open } = this;
146
+ if (open) {
147
+ showPopover.call(this, this._popover);
148
+ const listener = (e) => {
149
+ if (!this.contains(e.target)) {
150
+ this.events.remove(document, "click", listener);
151
+ this.open = false;
152
+ }
153
+ };
154
+ this.events.add(document, "click", listener);
155
+ } else {
156
+ hidePopover(this._popover);
157
+ }
158
+ this.dispatchCustomEvent("toggle", open);
159
+ }
160
+
161
+ resolveArea(): string {
162
+ const split = this.position.split("-");
163
+ const firstValue = this.span === "spread" ? `span-${split[0]}` : split[0];
164
+ if (split.length < 2) {
165
+ return `${firstValue} center`;
166
+ }
167
+ const secondValue = this.span === "isolated" ? split[1] : `span-${split[1]}`;
168
+ return `${firstValue} ${secondValue}`;
169
+ }
170
+ }
171
+
172
+ export { Popover, Popover as default };
@@ -0,0 +1,11 @@
1
+ import Popover from "./component.js";
2
+
3
+ Popover.define();
4
+
5
+ export default Popover;
6
+
7
+ declare global {
8
+ interface HTMLElementTagNameMap {
9
+ "godown-popover": Popover;
10
+ }
11
+ }
@@ -15,6 +15,7 @@ import { property, queryAll, state } from "lit/decorators.js";
15
15
 
16
16
  import { cssGlobalVars, scopePrefix } from "../../internal/global-style.js";
17
17
  import { SuperInput } from "../../internal/super-input.js";
18
+ import { ringTypeAttribute } from "../../internal/ring.js";
18
19
 
19
20
  const protoName = "range";
20
21
  const cssScope = scopePrefix(protoName);
@@ -203,7 +204,7 @@ class Range<V extends RangeValue = RangeValue> extends SuperInput<RangeValue> {
203
204
  }
204
205
 
205
206
  get observedRecord(): Record<string, any> {
206
- return omit(super.observedRecord, "ring-type");
207
+ return omit(super.observedRecord, ringTypeAttribute);
207
208
  }
208
209
 
209
210
  protected render(): TemplateResult<1> {
@@ -15,7 +15,6 @@ const cssScope = scopePrefix(protoName);
15
15
  @styles(css`
16
16
  :host {
17
17
  display: block;
18
- width: -moz-fit-content;
19
18
  width: fit-content;
20
19
  transition: all 0.5s ease-in-out;
21
20
  ${cssScope}--offset: .5em;