tinkiet 0.11.0 → 0.11.4

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.
package/switch/index.js CHANGED
@@ -109,6 +109,61 @@ let TkBox = class TkBox extends external_lit_.LitElement {
109
109
  * Activate ripple
110
110
  */
111
111
  this.ripple = false;
112
+ this.showRipple = (event) => {
113
+ const x = event.clientX;
114
+ const y = event.clientY;
115
+ const { offsetWidth, offsetHeight } = this;
116
+ const container = document.createElement("span");
117
+ container.classList.add("ripple", "open");
118
+ const element = document.createElement("span");
119
+ container.appendChild(element);
120
+ this.shadowRoot.appendChild(container);
121
+ const rect = this.getBoundingClientRect();
122
+ const diameter = Math.max(offsetWidth, offsetWidth) * 2;
123
+ element.style.width = element.style.height = diameter + "px";
124
+ element.style.left = x - rect.left - diameter / 2 + "px";
125
+ element.style.top = y - rect.top - diameter / 2 + "px";
126
+ const inAnimation = element.animate({
127
+ transform: [`scale(0)`, `scale(1)`]
128
+ }, {
129
+ easing: "ease-out",
130
+ fill: "both",
131
+ duration: 500
132
+ });
133
+ inAnimation.onfinish = () => {
134
+ container.classList.remove("open");
135
+ const outAnimation = element.animate({
136
+ opacity: ["0.5", "0"]
137
+ }, {
138
+ easing: "ease-in",
139
+ fill: "both",
140
+ duration: 300
141
+ });
142
+ outAnimation.onfinish = () => {
143
+ requestAnimationFrame(() => {
144
+ container.remove();
145
+ });
146
+ };
147
+ };
148
+ };
149
+ this.hideRipple = (event) => {
150
+ var _a;
151
+ (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".ripple:not([open])").forEach(container => {
152
+ const element = container.querySelector("span");
153
+ const outAnimation = element.animate({
154
+ opacity: ["0.5", "0"]
155
+ }, {
156
+ easing: "ease-out",
157
+ fill: "both",
158
+ duration: 300
159
+ });
160
+ outAnimation.onfinish = () => {
161
+ requestAnimationFrame(() => {
162
+ container.remove();
163
+ });
164
+ };
165
+ });
166
+ };
112
167
  }
113
168
  static get styles() {
114
169
  return [
@@ -124,14 +179,14 @@ let TkBox = class TkBox extends external_lit_.LitElement {
124
179
  }
125
180
  connectedCallback() {
126
181
  if (this.ripple) {
127
- this.addEventListener("mousedown", this.showRipple.bind(this), { passive: true });
128
- this.addEventListener("mouseup", this.hideRipple.bind(this), { passive: true });
182
+ this.addEventListener("mousedown", this.showRipple, { passive: true });
183
+ this.addEventListener("mouseup", this.hideRipple, { passive: true });
129
184
  }
130
185
  super.connectedCallback();
131
186
  }
132
187
  disconnectedCallback() {
133
188
  this.removeEventListener("mousedown", this.showRipple);
134
- this.addEventListener("mouseup", this.hideRipple);
189
+ this.removeEventListener("mouseup", this.hideRipple);
135
190
  super.disconnectedCallback();
136
191
  }
137
192
  updated(props) {
@@ -141,61 +196,6 @@ let TkBox = class TkBox extends external_lit_.LitElement {
141
196
  // this.style.setProperty("color", this.color.toString());
142
197
  super.updated(props);
143
198
  }
144
- showRipple(event) {
145
- const x = event.clientX;
146
- const y = event.clientY;
147
- const { offsetWidth, offsetHeight } = this;
148
- const container = document.createElement("span");
149
- container.classList.add("ripple", "open");
150
- const element = document.createElement("span");
151
- container.appendChild(element);
152
- this.shadowRoot.appendChild(container);
153
- const rect = this.getBoundingClientRect();
154
- const diameter = Math.max(offsetWidth, offsetWidth) * 2;
155
- element.style.width = element.style.height = diameter + "px";
156
- element.style.left = x - rect.left - diameter / 2 + "px";
157
- element.style.top = y - rect.top - diameter / 2 + "px";
158
- const inAnimation = element.animate({
159
- transform: [`scale(0)`, `scale(1)`]
160
- }, {
161
- easing: "ease-out",
162
- fill: "both",
163
- duration: 500
164
- });
165
- inAnimation.onfinish = () => {
166
- container.classList.remove("open");
167
- const outAnimation = element.animate({
168
- opacity: ["0.5", "0"]
169
- }, {
170
- easing: "ease-in",
171
- fill: "both",
172
- duration: 300
173
- });
174
- outAnimation.onfinish = () => {
175
- requestAnimationFrame(() => {
176
- container.remove();
177
- });
178
- };
179
- };
180
- }
181
- hideRipple(event) {
182
- var _a;
183
- (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".ripple:not([open])").forEach(container => {
184
- const element = container.querySelector("span");
185
- const outAnimation = element.animate({
186
- opacity: ["0.5", "0"]
187
- }, {
188
- easing: "ease-out",
189
- fill: "both",
190
- duration: 300
191
- });
192
- outAnimation.onfinish = () => {
193
- requestAnimationFrame(() => {
194
- container.remove();
195
- });
196
- };
197
- });
198
- }
199
199
  };
200
200
  __decorate([
201
201
  (0,decorators_js_.property)({ type: Boolean })
@@ -307,6 +307,21 @@ let TkSwitch = class TkSwitch extends external_lit_.LitElement {
307
307
  this.required = false;
308
308
  this.disabled = false;
309
309
  this.readonly = false;
310
+ this.onKeyDown = (e) => {
311
+ if (e.code === "Space" || e.code === "Enter") {
312
+ e.preventDefault();
313
+ e.stopPropagation();
314
+ this.click();
315
+ }
316
+ };
317
+ this.handleClick = () => {
318
+ this.checked = !this.checked;
319
+ if (this.checked && this.name)
320
+ this.getRootNode()
321
+ .querySelectorAll(`tk-radio[name="${this.name}"]`)
322
+ .forEach(el => (el != this ? (el.checked = false) : null));
323
+ setTimeout(() => this.dispatchEvent(new Event("change", { bubbles: true, composed: true })));
324
+ };
310
325
  }
311
326
  render() {
312
327
  return (0,external_lit_.html) `
@@ -336,8 +351,8 @@ let TkSwitch = class TkSwitch extends external_lit_.LitElement {
336
351
  }
337
352
  connectedCallback() {
338
353
  super.connectedCallback();
339
- this.addEventListener("click", this.handleClick.bind(this));
340
- this.addEventListener("keydown", this.onKeyDown.bind(this));
354
+ this.addEventListener("click", this.handleClick);
355
+ this.addEventListener("keydown", this.onKeyDown);
341
356
  }
342
357
  disconnectedCallback() {
343
358
  super.disconnectedCallback();
@@ -347,21 +362,6 @@ let TkSwitch = class TkSwitch extends external_lit_.LitElement {
347
362
  firstUpdated() {
348
363
  this.appendChild(this.$input);
349
364
  }
350
- onKeyDown(e) {
351
- if (e.code === "Space" || e.code === "Enter") {
352
- e.preventDefault();
353
- e.stopPropagation();
354
- this.click();
355
- }
356
- }
357
- handleClick() {
358
- this.checked = !this.checked;
359
- if (this.checked && this.name)
360
- this.getRootNode()
361
- .querySelectorAll(`tk-radio[name="${this.name}"]`)
362
- .forEach(el => (el != this ? (el.checked = false) : null));
363
- setTimeout(() => this.dispatchEvent(new Event("change", { bubbles: true, composed: true })));
364
- }
365
365
  };
366
366
  TkSwitch.styles = (0,external_lit_.css) `
367
367
  ${(0,external_lit_.unsafeCSS)(switch_switch)}
@@ -14,8 +14,8 @@ export declare class TkSwitch extends LitElement {
14
14
  connectedCallback(): void;
15
15
  disconnectedCallback(): void;
16
16
  firstUpdated(): void;
17
- protected onKeyDown(e: KeyboardEvent): void;
18
- protected handleClick(): void;
17
+ protected onKeyDown: (e: KeyboardEvent) => void;
18
+ protected handleClick: () => void;
19
19
  }
20
20
  declare global {
21
21
  interface HTMLElementTagNameMap {
package/topbar/index.js CHANGED
@@ -163,6 +163,61 @@ let TkBox = class TkBox extends external_lit_.LitElement {
163
163
  * Activate ripple
164
164
  */
165
165
  this.ripple = false;
166
+ this.showRipple = (event) => {
167
+ const x = event.clientX;
168
+ const y = event.clientY;
169
+ const { offsetWidth, offsetHeight } = this;
170
+ const container = document.createElement("span");
171
+ container.classList.add("ripple", "open");
172
+ const element = document.createElement("span");
173
+ container.appendChild(element);
174
+ this.shadowRoot.appendChild(container);
175
+ const rect = this.getBoundingClientRect();
176
+ const diameter = Math.max(offsetWidth, offsetWidth) * 2;
177
+ element.style.width = element.style.height = diameter + "px";
178
+ element.style.left = x - rect.left - diameter / 2 + "px";
179
+ element.style.top = y - rect.top - diameter / 2 + "px";
180
+ const inAnimation = element.animate({
181
+ transform: [`scale(0)`, `scale(1)`]
182
+ }, {
183
+ easing: "ease-out",
184
+ fill: "both",
185
+ duration: 500
186
+ });
187
+ inAnimation.onfinish = () => {
188
+ container.classList.remove("open");
189
+ const outAnimation = element.animate({
190
+ opacity: ["0.5", "0"]
191
+ }, {
192
+ easing: "ease-in",
193
+ fill: "both",
194
+ duration: 300
195
+ });
196
+ outAnimation.onfinish = () => {
197
+ requestAnimationFrame(() => {
198
+ container.remove();
199
+ });
200
+ };
201
+ };
202
+ };
203
+ this.hideRipple = (event) => {
204
+ var _a;
205
+ (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".ripple:not([open])").forEach(container => {
206
+ const element = container.querySelector("span");
207
+ const outAnimation = element.animate({
208
+ opacity: ["0.5", "0"]
209
+ }, {
210
+ easing: "ease-out",
211
+ fill: "both",
212
+ duration: 300
213
+ });
214
+ outAnimation.onfinish = () => {
215
+ requestAnimationFrame(() => {
216
+ container.remove();
217
+ });
218
+ };
219
+ });
220
+ };
166
221
  }
167
222
  static get styles() {
168
223
  return [
@@ -178,14 +233,14 @@ let TkBox = class TkBox extends external_lit_.LitElement {
178
233
  }
179
234
  connectedCallback() {
180
235
  if (this.ripple) {
181
- this.addEventListener("mousedown", this.showRipple.bind(this), { passive: true });
182
- this.addEventListener("mouseup", this.hideRipple.bind(this), { passive: true });
236
+ this.addEventListener("mousedown", this.showRipple, { passive: true });
237
+ this.addEventListener("mouseup", this.hideRipple, { passive: true });
183
238
  }
184
239
  super.connectedCallback();
185
240
  }
186
241
  disconnectedCallback() {
187
242
  this.removeEventListener("mousedown", this.showRipple);
188
- this.addEventListener("mouseup", this.hideRipple);
243
+ this.removeEventListener("mouseup", this.hideRipple);
189
244
  super.disconnectedCallback();
190
245
  }
191
246
  updated(props) {
@@ -195,61 +250,6 @@ let TkBox = class TkBox extends external_lit_.LitElement {
195
250
  // this.style.setProperty("color", this.color.toString());
196
251
  super.updated(props);
197
252
  }
198
- showRipple(event) {
199
- const x = event.clientX;
200
- const y = event.clientY;
201
- const { offsetWidth, offsetHeight } = this;
202
- const container = document.createElement("span");
203
- container.classList.add("ripple", "open");
204
- const element = document.createElement("span");
205
- container.appendChild(element);
206
- this.shadowRoot.appendChild(container);
207
- const rect = this.getBoundingClientRect();
208
- const diameter = Math.max(offsetWidth, offsetWidth) * 2;
209
- element.style.width = element.style.height = diameter + "px";
210
- element.style.left = x - rect.left - diameter / 2 + "px";
211
- element.style.top = y - rect.top - diameter / 2 + "px";
212
- const inAnimation = element.animate({
213
- transform: [`scale(0)`, `scale(1)`]
214
- }, {
215
- easing: "ease-out",
216
- fill: "both",
217
- duration: 500
218
- });
219
- inAnimation.onfinish = () => {
220
- container.classList.remove("open");
221
- const outAnimation = element.animate({
222
- opacity: ["0.5", "0"]
223
- }, {
224
- easing: "ease-in",
225
- fill: "both",
226
- duration: 300
227
- });
228
- outAnimation.onfinish = () => {
229
- requestAnimationFrame(() => {
230
- container.remove();
231
- });
232
- };
233
- };
234
- }
235
- hideRipple(event) {
236
- var _a;
237
- (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".ripple:not([open])").forEach(container => {
238
- const element = container.querySelector("span");
239
- const outAnimation = element.animate({
240
- opacity: ["0.5", "0"]
241
- }, {
242
- easing: "ease-out",
243
- fill: "both",
244
- duration: 300
245
- });
246
- outAnimation.onfinish = () => {
247
- requestAnimationFrame(() => {
248
- container.remove();
249
- });
250
- };
251
- });
252
- }
253
253
  };
254
254
  __decorate([
255
255
  (0,decorators_js_.property)({ type: Boolean })