godown 3.0.0-canary.7 → 3.0.0-canary.8

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 (142) hide show
  1. package/components/alert.d.ts.map +1 -1
  2. package/components/alert.js +3 -2
  3. package/components/alert.js.map +1 -1
  4. package/components/breath.js +2 -2
  5. package/components/breath.js.map +1 -1
  6. package/components/card.d.ts +1 -1
  7. package/components/card.d.ts.map +1 -1
  8. package/components/card.js +3 -4
  9. package/components/card.js.map +1 -1
  10. package/components/carousel.js +1 -1
  11. package/components/carousel.js.map +1 -1
  12. package/components/input.d.ts +0 -1
  13. package/components/input.d.ts.map +1 -1
  14. package/components/input.js +0 -3
  15. package/components/input.js.map +1 -1
  16. package/components/layout.d.ts +1 -1
  17. package/components/layout.d.ts.map +1 -1
  18. package/components/layout.js +5 -6
  19. package/components/layout.js.map +1 -1
  20. package/components/router.js +1 -1
  21. package/components/router.js.map +1 -1
  22. package/components/select.d.ts +0 -4
  23. package/components/select.d.ts.map +1 -1
  24. package/components/select.js +0 -7
  25. package/components/select.js.map +1 -1
  26. package/components/skeleton.d.ts.map +1 -1
  27. package/components/skeleton.js +1 -2
  28. package/components/skeleton.js.map +1 -1
  29. package/components/split.d.ts +1 -1
  30. package/components/split.d.ts.map +1 -1
  31. package/components/split.js +8 -2
  32. package/components/split.js.map +1 -1
  33. package/components/text.js +1 -1
  34. package/components/text.js.map +1 -1
  35. package/core/super-input.d.ts +0 -1
  36. package/core/super-input.d.ts.map +1 -1
  37. package/core/super-input.js +0 -3
  38. package/core/super-input.js.map +1 -1
  39. package/custom-elements.json +1 -1
  40. package/dev/components/alert.d.ts.map +1 -1
  41. package/dev/components/alert.js +3 -2
  42. package/dev/components/alert.js.map +1 -1
  43. package/dev/components/breath.d.ts.map +1 -1
  44. package/dev/components/breath.js +2 -1
  45. package/dev/components/breath.js.map +1 -1
  46. package/dev/components/card.d.ts +1 -1
  47. package/dev/components/card.d.ts.map +1 -1
  48. package/dev/components/card.js +3 -4
  49. package/dev/components/card.js.map +1 -1
  50. package/dev/components/carousel.d.ts.map +1 -1
  51. package/dev/components/carousel.js +1 -0
  52. package/dev/components/carousel.js.map +1 -1
  53. package/dev/components/input.d.ts +0 -1
  54. package/dev/components/input.d.ts.map +1 -1
  55. package/dev/components/input.js +0 -3
  56. package/dev/components/input.js.map +1 -1
  57. package/dev/components/layout.d.ts +1 -1
  58. package/dev/components/layout.d.ts.map +1 -1
  59. package/dev/components/layout.js +7 -6
  60. package/dev/components/layout.js.map +1 -1
  61. package/dev/components/router.js +1 -1
  62. package/dev/components/router.js.map +1 -1
  63. package/dev/components/select.d.ts +0 -4
  64. package/dev/components/select.d.ts.map +1 -1
  65. package/dev/components/select.js +0 -7
  66. package/dev/components/select.js.map +1 -1
  67. package/dev/components/skeleton.d.ts.map +1 -1
  68. package/dev/components/skeleton.js +1 -2
  69. package/dev/components/skeleton.js.map +1 -1
  70. package/dev/components/split.d.ts +1 -1
  71. package/dev/components/split.d.ts.map +1 -1
  72. package/dev/components/split.js +9 -3
  73. package/dev/components/split.js.map +1 -1
  74. package/dev/components/text.js +3 -3
  75. package/dev/core/super-input.d.ts +0 -1
  76. package/dev/core/super-input.d.ts.map +1 -1
  77. package/dev/core/super-input.js +0 -3
  78. package/dev/core/super-input.js.map +1 -1
  79. package/package.json +7 -6
  80. package/src/alert.ts +11 -0
  81. package/src/avatar.ts +11 -0
  82. package/src/breath.ts +13 -0
  83. package/src/button.ts +11 -0
  84. package/src/card.ts +11 -0
  85. package/src/carousel.ts +11 -0
  86. package/src/components/alert.ts +282 -0
  87. package/src/components/avatar.ts +93 -0
  88. package/src/components/breath.ts +151 -0
  89. package/src/components/button.ts +276 -0
  90. package/src/components/card.ts +85 -0
  91. package/src/components/carousel.ts +166 -0
  92. package/src/components/details.ts +112 -0
  93. package/src/components/dialog.ts +160 -0
  94. package/src/components/divider.ts +44 -0
  95. package/src/components/dragbox.ts +126 -0
  96. package/src/components/flex.ts +65 -0
  97. package/src/components/form.ts +83 -0
  98. package/src/components/grid.ts +66 -0
  99. package/src/components/input.ts +71 -0
  100. package/src/components/layout.ts +84 -0
  101. package/src/components/link.ts +36 -0
  102. package/src/components/progress.ts +101 -0
  103. package/src/components/range.ts +409 -0
  104. package/src/components/rotate.ts +92 -0
  105. package/src/components/router.ts +264 -0
  106. package/src/components/select.ts +268 -0
  107. package/src/components/skeleton.ts +116 -0
  108. package/src/components/split.ts +190 -0
  109. package/src/components/switch.ts +176 -0
  110. package/src/components/text.ts +95 -0
  111. package/src/components/time.ts +77 -0
  112. package/src/components/tooltip.ts +118 -0
  113. package/src/components/typewriter.ts +147 -0
  114. package/src/core/global-style.ts +86 -0
  115. package/src/core/super-anchor.ts +52 -0
  116. package/src/core/super-input.ts +230 -0
  117. package/src/core/super-openable.ts +51 -0
  118. package/src/details.ts +11 -0
  119. package/src/dialog.ts +11 -0
  120. package/src/divider.ts +11 -0
  121. package/src/dragbox.ts +11 -0
  122. package/src/flex.ts +11 -0
  123. package/src/form.ts +11 -0
  124. package/src/grid.ts +11 -0
  125. package/src/index.ts +28 -0
  126. package/src/input.ts +13 -0
  127. package/src/layout.ts +12 -0
  128. package/src/link.ts +13 -0
  129. package/src/progress.ts +12 -0
  130. package/src/range.ts +13 -0
  131. package/src/rotate.ts +13 -0
  132. package/src/router.ts +12 -0
  133. package/src/select.ts +13 -0
  134. package/src/skeleton.ts +13 -0
  135. package/src/split.ts +13 -0
  136. package/src/switch.ts +13 -0
  137. package/src/text.ts +13 -0
  138. package/src/time.ts +13 -0
  139. package/src/tooltip.ts +13 -0
  140. package/src/typewriter.ts +11 -0
  141. package/vscode.html-custom-data.json +1 -1
  142. package/web-types.json +1 -1
@@ -0,0 +1,276 @@
1
+ import { godown } from "@godown/element/decorators/godown.js";
2
+ import { part } from "@godown/element/decorators/part.js";
3
+ import { styles } from "@godown/element/decorators/styles.js";
4
+ import { htmlSlot } from "@godown/element/directives/html-slot.js";
5
+ import { htmlStyle } from "@godown/element/directives/html-style.js";
6
+ import { constructCSSObject, toVar } from "@godown/element/tools/css.js";
7
+ import { css, html } from "lit";
8
+ import { property } from "lit/decorators.js";
9
+
10
+ import { cssGlobalVars, GlobalStyle, scopePrefix } from "../core/global-style.js";
11
+
12
+ const protoName = "button";
13
+ const cssScope = scopePrefix(protoName);
14
+
15
+ const whiteFont = cssGlobalVars._colors.lightgray[0];
16
+ const blackFont = cssGlobalVars._colors.darkgray[6];
17
+
18
+ const colors = constructCSSObject(
19
+ ["color", "background", "gradients"].map((k) => `${cssScope}--${k}`),
20
+ {
21
+ black: [
22
+ whiteFont, // color
23
+ cssGlobalVars._colors.darkgray[7], // background
24
+ cssGlobalVars._colors.darkgray[4], // gradients
25
+ ],
26
+ gray: [
27
+ whiteFont, // color
28
+ cssGlobalVars._colors.darkgray[1], // background
29
+ cssGlobalVars._colors.lightgray[8], // gradients
30
+ ],
31
+ white: [
32
+ blackFont, // color
33
+ cssGlobalVars._colors.lightgray[3], // background
34
+ cssGlobalVars._colors.lightgray[0], // gradients
35
+ ],
36
+ blue: [
37
+ whiteFont, // color
38
+ cssGlobalVars._colors.blue[6], // background
39
+ cssGlobalVars._colors.blue[4], // gradients
40
+ ],
41
+ green: [
42
+ whiteFont, // color
43
+ cssGlobalVars._colors.green[6], // background
44
+ cssGlobalVars._colors.green[4], // gradients
45
+ ],
46
+ red: [
47
+ whiteFont, // color
48
+ cssGlobalVars._colors.red[6], // background
49
+ cssGlobalVars._colors.red[4], // gradients
50
+ ],
51
+ orange: [
52
+ whiteFont, // color
53
+ cssGlobalVars._colors.orange[6], // background
54
+ cssGlobalVars._colors.orange[4], // gradients
55
+ ],
56
+ pink: [
57
+ whiteFont, // color
58
+ cssGlobalVars._colors.pink[6], // background
59
+ cssGlobalVars._colors.pink[4], // gradients
60
+ ],
61
+ purple: [
62
+ whiteFont, // color
63
+ cssGlobalVars._colors.purple[6], // background
64
+ cssGlobalVars._colors.purple[4], // gradients
65
+ ],
66
+ yellow: [
67
+ blackFont, // color
68
+ cssGlobalVars._colors.yellow[6], // background
69
+ cssGlobalVars._colors.yellow[4], // gradients
70
+ ],
71
+ teal: [
72
+ whiteFont, // color
73
+ cssGlobalVars._colors.teal[6], // background
74
+ cssGlobalVars._colors.teal[4], // gradients
75
+ ],
76
+ },
77
+ () => `:host`,
78
+ (prop) => toVar(prop),
79
+ );
80
+
81
+ /**
82
+ * {@linkcode Button} renders a button.
83
+ *
84
+ * Color defaults to black.
85
+ *
86
+ * @category input
87
+ */
88
+ @godown(protoName)
89
+ @styles(
90
+ css`
91
+ :host(:not([disabled]):active) {
92
+ transform: scale(var(${cssScope}--focus-scale));
93
+ }
94
+
95
+ :host([round]) {
96
+ ${cssScope}--padding-x: .75em;
97
+ border-radius: calc(infinity * 1px);
98
+ }
99
+
100
+ :host([disabled]) {
101
+ cursor: not-allowed;
102
+ filter: brightness(0.85);
103
+ }
104
+
105
+ :host([ghost]) {
106
+ ${cssScope}--modal-background: var(${cssScope}--ghost-color);
107
+ box-shadow:inset 0px 0px 0px var(${cssScope}--ghost-width) var(${cssScope}--ghost-color);
108
+ color: var(${cssScope}--ghost-color);
109
+ background: transparent;
110
+ }
111
+ `,
112
+ css`
113
+ :host {
114
+ ${cssScope}--padding-x: .5em;
115
+ ${cssScope}--padding-y: .15em;
116
+ ${cssScope}--padding: var(${cssScope}--padding-y) var(${cssScope}--padding-x);
117
+ ${cssScope}--modal-animation-duration: 1s;
118
+ ${cssScope}--ghost-width: .08em;
119
+ ${cssScope}--focus-scale: .97;
120
+ ${cssScope}--deg: 45deg;
121
+ ${cssScope}--ghost-color:var(${cssScope}--background);
122
+ color: var(${cssScope}--color, inherit);
123
+ background: linear-gradient(
124
+ var(${cssScope}--deg),
125
+ var(${cssScope}--background),
126
+ var(${cssScope}--gradients, var(${cssScope}--background))
127
+ );
128
+ border-radius: 0.3em;
129
+ width: -moz-fit-content;
130
+ width: fit-content;
131
+ transition: 0.1s;
132
+ display: block;
133
+ overflow: hidden;
134
+ text-align: center;
135
+ padding: 0 !important;
136
+ cursor: pointer;
137
+ }
138
+
139
+ [part="root"] {
140
+ width: 100%;
141
+ height: 100%;
142
+ overflow: hidden;
143
+ position: relative;
144
+ transition: none;
145
+ user-select: none;
146
+ border-radius: inherit;
147
+ transition-duration: inherit;
148
+ }
149
+
150
+ [part="slot"] {
151
+ padding: var(${cssScope}--padding);
152
+ }
153
+
154
+ i {
155
+ position: absolute;
156
+ inset: 0;
157
+ opacity: 0;
158
+ width: 100%;
159
+ height: 100%;
160
+ border-radius: 50%;
161
+ visibility: visible;
162
+ pointer-events: none;
163
+ transform-origin: 0 0;
164
+ background: var(${cssScope}--modal-background, currentColor);
165
+ animation-duration: var(${cssScope}--modal-animation-duration);
166
+ }
167
+
168
+ @keyframes kf {
169
+ 0% {
170
+ transform: scale(0) translate(-50%, -50%);
171
+ opacity: var(${cssScope}--modal-opacity, 0.18);
172
+ }
173
+ 80% {
174
+ transform: scale(1) translate(-50%, -50%);
175
+ }
176
+ to {
177
+ opacity: 0;
178
+ }
179
+ }
180
+ `,
181
+ )
182
+ class Button extends GlobalStyle {
183
+ /**
184
+ * Whether to disable this element.
185
+ */
186
+ @property({ type: Boolean, reflect: true })
187
+ disabled: boolean;
188
+ /**
189
+ * Invert font and background color.
190
+ */
191
+ @property({ type: Boolean, reflect: true })
192
+ ghost: boolean;
193
+ /**
194
+ * Whether this element is active or not.
195
+ */
196
+ @property({ type: Boolean, reflect: true })
197
+ active: boolean;
198
+ /**
199
+ * Enables rounded corners to appear capsule shaped.
200
+ */
201
+ @property({ type: Boolean, reflect: true })
202
+ round: boolean;
203
+ /**
204
+ * The primary color.
205
+ */
206
+ @property({ reflect: true })
207
+ color: "none" | keyof typeof colors = "black";
208
+ /**
209
+ * Text inside.
210
+ */
211
+ @property()
212
+ text: string;
213
+
214
+ @part("modal-root")
215
+ _modalRoot: HTMLElement;
216
+ @part("root")
217
+ _root: HTMLElement;
218
+
219
+ protected render() {
220
+ const color = this.nextColor();
221
+ return [
222
+ html`<div part="root">
223
+ <span part="modal-root"></span>
224
+ <div part="slot">${this.text || htmlSlot()}</div>
225
+ </div>`,
226
+ htmlStyle(colors[color]),
227
+ ];
228
+ }
229
+
230
+ focus() {
231
+ if (this.disabled) {
232
+ return;
233
+ }
234
+ this.active = true;
235
+ super.focus();
236
+ }
237
+
238
+ blur() {
239
+ this.active = false;
240
+ super.blur();
241
+ }
242
+
243
+ firstUpdated() {
244
+ this.events.add(this, "click", this._handelClick, true);
245
+ }
246
+
247
+ protected _handelClick(e: MouseEvent) {
248
+ if (this.disabled) {
249
+ e.stopPropagation();
250
+ e.preventDefault();
251
+ return;
252
+ }
253
+ this._handleModal(e);
254
+ }
255
+
256
+ protected _handleModal(e: MouseEvent) {
257
+ const modal = document.createElement("i");
258
+ const rect = this.getBoundingClientRect();
259
+ const h = rect.height;
260
+ const w = rect.width;
261
+ const size = `${Math.sqrt(h * h + w * w) * 2}px`;
262
+ modal.style.height = size;
263
+ modal.style.width = size;
264
+ modal.style.left = `${e.clientX - rect.left}px`;
265
+ modal.style.top = `${e.clientY - rect.y}px`;
266
+ modal.style.animationName = "kf";
267
+ this._modalRoot.appendChild(modal);
268
+ modal.addEventListener("animationend", () => modal.remove(), { once: true });
269
+ }
270
+
271
+ nextColor() {
272
+ return this.color;
273
+ }
274
+ }
275
+
276
+ export default Button;
@@ -0,0 +1,85 @@
1
+ import { godown } from "@godown/element/decorators/godown.js";
2
+ import { styles } from "@godown/element/decorators/styles.js";
3
+ import { htmlSlot } from "@godown/element/directives/html-slot.js";
4
+ import { css, html } from "lit";
5
+ import { property } from "lit/decorators.js";
6
+
7
+ import { cssGlobalVars, GlobalStyle, scopePrefix } from "../core/global-style.js";
8
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
9
+ import type Layout from "../layout.js";
10
+
11
+ const protoName = "card";
12
+ const cssScope = scopePrefix(protoName);
13
+
14
+ /**
15
+ * {@linkcode Card} renders a card.
16
+ *
17
+ * This may be similar to {@linkcode Layout},
18
+ * but it needs to be specified to enable header and footer.
19
+ *
20
+ * @slot - The main content of the card.
21
+ * @slot header - The header of the card.
22
+ * @slot footer - The footer of the card.
23
+ * @category display
24
+ */
25
+ @godown(protoName)
26
+ @styles(
27
+ css`
28
+ :host {
29
+ ${cssScope}--shadow-width: .0375em;
30
+ ${cssScope}--shadow-color: transparent;
31
+ ${cssScope}--background: var(${cssGlobalVars.background});
32
+ ${cssScope}--divider-width: 100%;
33
+ ${cssScope}--divider-height: var(${cssScope}--shadow-width);
34
+ ${cssScope}--divider-background: var(${cssGlobalVars.passive});
35
+ ${cssScope}--padding: .75em;
36
+ color: var(${cssGlobalVars.foreground});
37
+ background: var(${cssScope}--background);
38
+ display: block;
39
+ flex-shrink: 0;
40
+ position: relative;
41
+ overflow: hidden;
42
+ box-sizing: border-box;
43
+ border-radius: 0.25em;
44
+ transition: box-shadow .1s ease-in-out;
45
+ }
46
+
47
+ :host([shadow="hover"]:hover),
48
+ :host([shadow="always"]) {
49
+ ${cssScope}--shadow-color: var(${cssScope}--divider-background);
50
+ box-shadow: inset 0 0 0px var(${cssScope}--shadow-width) var(${cssScope}--shadow-color);
51
+ }
52
+
53
+ [part="divider"] {
54
+ margin: auto;
55
+ width: var(${cssScope}--divider-width);
56
+ height: var(${cssScope}--divider-height);
57
+ background: var(${cssScope}--divider-background);
58
+ }
59
+
60
+ slot {
61
+ display: block;
62
+ padding: var(${cssScope}--padding);
63
+ }
64
+ `,
65
+ )
66
+ class Card extends GlobalStyle {
67
+ @property({ reflect: true })
68
+ shadow: "none" | "always" | "hover" = "hover";
69
+
70
+ @property({ type: Boolean })
71
+ footer = false;
72
+ @property({ type: Boolean })
73
+ header = false;
74
+
75
+ protected render() {
76
+ const hr = html`<hr part="divider">`;
77
+ return [
78
+ this.header ? [htmlSlot("header"), hr] : "",
79
+ htmlSlot(),
80
+ this.footer ? [hr, htmlSlot("footer")] : "",
81
+ ];
82
+ }
83
+ }
84
+
85
+ export default Card;
@@ -0,0 +1,166 @@
1
+ import { godown } from "@godown/element/decorators/godown.js";
2
+ import { part } from "@godown/element/decorators/part.js";
3
+ import { styles } from "@godown/element/decorators/styles.js";
4
+ import { htmlSlot } from "@godown/element/directives/html-slot.js";
5
+ import { htmlStyle } from "@godown/element/directives/html-style.js";
6
+ import iconChevronLeft from "@godown/f7-icon/icons/chevron-left.js";
7
+ import iconChevronRight from "@godown/f7-icon/icons/chevron-right.js";
8
+ import { css, html } from "lit";
9
+ import { property } from "lit/decorators.js";
10
+
11
+ import { GlobalStyle } from "../core/global-style.js";
12
+
13
+ const protoName = "carousel";
14
+
15
+ /**
16
+ * {@linkcode Carousel} make the content display as a carousel.
17
+ *
18
+ * When this component is `firstUpdated`,
19
+ * clone the first and last element and make the matching element visible when switching index.
20
+ *
21
+ * Child elements should maintain the same size.
22
+ *
23
+ * If no width, it will be the width of the first element.
24
+ *
25
+ * @category display
26
+ */
27
+ @godown(protoName)
28
+ @styles(
29
+ css`
30
+ :host {
31
+ display: block;
32
+ transition: .3s;
33
+ }
34
+
35
+ [part="root"] {
36
+ overflow: hidden;
37
+ }
38
+
39
+ [part="root"],
40
+ [part="move-root"] {
41
+ height: 100%;
42
+ width: 100%;
43
+ display: flex;
44
+ position: relative;
45
+ transition: inherit;
46
+ }
47
+
48
+ [part="prev"],
49
+ [part="next"] {
50
+ height: 100%;
51
+ width: 1.5em;
52
+ z-index: 1;
53
+ position: absolute;
54
+ display: flex;
55
+ align-items: center;
56
+ justify-content: center;
57
+ user-select: none;
58
+ }
59
+
60
+ [part="prev"] {
61
+ left: 0;
62
+ }
63
+
64
+ [part="next"] {
65
+ right: 0;
66
+ }
67
+
68
+ slot::slotted(*) {
69
+ flex-shrink: 0 !important;
70
+ }
71
+ `,
72
+ )
73
+ class Carousel extends GlobalStyle {
74
+ /**
75
+ * The index of the element is displayed for the first time.
76
+ */
77
+ @property({ type: Number })
78
+ index = 0;
79
+ /**
80
+ * If autoChange > 0, the rotation will be automated.
81
+ */
82
+ @property({ type: Number })
83
+ autoChange = 0;
84
+ /**
85
+ * Element width.
86
+ */
87
+ @property()
88
+ width: string;
89
+
90
+ @part("move-root")
91
+ _moveRoot: HTMLElement;
92
+
93
+ intervalID: number;
94
+
95
+ _cloneFirst: HTMLElement | undefined;
96
+
97
+ _cloneLast: HTMLElement | undefined;
98
+
99
+ protected render() {
100
+ return [
101
+ html`<div part="root">
102
+ <i part="prev" @click="${this.prev}">${iconChevronLeft()}</i>
103
+ <div part="move-root" style="transform:${`translateX(-${this.index + 1}00%)`}">${htmlSlot()}</div>
104
+ <i part="next" @click="${this.next}">${iconChevronRight()}</i>
105
+ </div>`,
106
+ htmlStyle(`:host{width:${this.width};}`),
107
+ ];
108
+ }
109
+
110
+ protected async firstUpdated() {
111
+ await this.updateComplete;
112
+
113
+ if (this.children.length) {
114
+ this.width ||= `${(this.firstElementChild as HTMLElement).offsetWidth}px`;
115
+
116
+ this._cloneFirst?.remove();
117
+ this._cloneLast?.remove();
118
+ this._cloneLast = this.firstElementChild.cloneNode(true) as HTMLElement;
119
+ this._cloneFirst = this.lastElementChild.cloneNode(true) as HTMLElement;
120
+ this.appendChild(this._cloneLast);
121
+ this.insertBefore(this._cloneFirst, this.firstElementChild);
122
+ this.show(this.index);
123
+ }
124
+ if (this.autoChange) {
125
+ this.intervalID = window.setInterval(() => {
126
+ this.next();
127
+ }, this.autoChange);
128
+ }
129
+ }
130
+
131
+ disconnectedCallback() {
132
+ clearInterval(this.intervalID);
133
+ }
134
+
135
+ show(i: number) {
136
+ this.index = i;
137
+ }
138
+
139
+ next() {
140
+ if (this.index === this.childElementCount - 3) {
141
+ this._doTranslateX("0", true);
142
+ this.show(0);
143
+ } else {
144
+ this.show(this.index + 1);
145
+ }
146
+ }
147
+
148
+ prev() {
149
+ if (this.index === 0) {
150
+ this._doTranslateX(`-${this.childElementCount - 1}00%`, true);
151
+ this.show(this.children.length - 3);
152
+ } else {
153
+ this.show(this.index - 1);
154
+ }
155
+ }
156
+
157
+ protected _doTranslateX(xValue: string, noTransition?: boolean) {
158
+ this._moveRoot.style.transform = `translateX(${xValue})`;
159
+ if (noTransition) {
160
+ this._moveRoot.style.transition = `none`;
161
+ }
162
+ this._moveRoot.getBoundingClientRect();
163
+ }
164
+ }
165
+
166
+ export default Carousel;
@@ -0,0 +1,112 @@
1
+ import { godown } from "@godown/element/decorators/godown.js";
2
+ import { styles } from "@godown/element/decorators/styles.js";
3
+ import { htmlSlot } from "@godown/element/directives/html-slot.js";
4
+ import svgCaretDown from "@godown/f7-icon/icons/chevron-down.js";
5
+ import { css, html } from "lit";
6
+ import { property, query } from "lit/decorators.js";
7
+
8
+ import { scopePrefix } from "../core/global-style.js";
9
+ import SuperOpenable from "../core/super-openable.js";
10
+
11
+ const protoName = "details";
12
+
13
+ const cssScope = scopePrefix(protoName);
14
+
15
+ /**
16
+ * {@linkcode Details} similar to `<details>`.
17
+ *
18
+ * @category display
19
+ */
20
+ @godown(protoName)
21
+ @styles(
22
+ css`
23
+ :host {
24
+ ${cssScope}--icon-deg-open: 0deg;
25
+ ${cssScope}--icon-deg-close: 90deg;
26
+ ${cssScope}--icon-deg: 0deg;
27
+ ${cssScope}--icon-space: 0.3em;
28
+ ${cssScope}--summary-direction: row;
29
+ ${cssScope}--transition: .3s;
30
+ height: fit-content;
31
+ display: block;
32
+ transition: var(${cssScope}--transition);
33
+ }
34
+
35
+ dl {
36
+ height: 100%;
37
+ position: relative;
38
+ overflow: hidden;
39
+ }
40
+
41
+ dt {
42
+ height: 100%;
43
+ display: flex;
44
+ flex-wrap: nowrap;
45
+ justify-content: space-between;
46
+ background: inherit;
47
+ align-items: center;
48
+ flex-direction: var(${cssScope}--summary-direction);
49
+ }
50
+
51
+ dd {
52
+ display: grid;
53
+ overflow: hidden;
54
+ grid-template-rows: 0fr;
55
+ transition: var(${cssScope}--transition);
56
+ transition-property: grid-template-rows;
57
+ }
58
+
59
+ i {
60
+ display: flex;
61
+ backface-visibility: hidden;
62
+ padding: var(${cssScope}--icon-space);
63
+ transition: var(${cssScope}--transition);
64
+ transform: rotate(var(${cssScope}--icon-deg));
65
+ }
66
+
67
+ :host([open]) dd {
68
+ grid-template-rows: 1fr;
69
+ }
70
+
71
+ :host([float]) dd {
72
+ top: 100%;
73
+ position: absolute;
74
+ }
75
+
76
+ i {
77
+ transform: rotate(var(${cssScope}--icon-deg-close));
78
+ }
79
+ :host([open]) i {
80
+ transform: rotate(var(${cssScope}--icon-deg-open));
81
+ }
82
+ `,
83
+ )
84
+ class Details extends SuperOpenable {
85
+ /**
86
+ * If it is true, the summary event scope will fill the element.
87
+ */
88
+ @property({ type: Boolean })
89
+ fill = false;
90
+ /**
91
+ * Summary text.
92
+ */
93
+ @property()
94
+ summary = "";
95
+
96
+ @query("dd")
97
+ _dd: HTMLDataListElement;
98
+
99
+ protected render() {
100
+ return html`<dl part="root">
101
+ <dt part="title" @click="${this._handelClick}">
102
+ <span part="summary">${this.summary || htmlSlot("summary")} </span>
103
+ <span><i part="icon">${svgCaretDown()}</i></span>
104
+ </dt>
105
+ <dd part="details" @click=${this.fill ? () => this.toggle() : null}>
106
+ <div style="min-height: 0;">${htmlSlot()}</div>
107
+ </dd>
108
+ </dl>`;
109
+ }
110
+ }
111
+
112
+ export default Details;