tinkiet 0.11.2 → 0.11.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.
package/button/index.js CHANGED
@@ -107,6 +107,61 @@ let TkBox = class TkBox extends external_lit_.LitElement {
107
107
  * Activate ripple
108
108
  */
109
109
  this.ripple = false;
110
+ this.showRipple = (event) => {
111
+ const x = event.clientX;
112
+ const y = event.clientY;
113
+ const { offsetWidth, offsetHeight } = this;
114
+ const container = document.createElement("span");
115
+ container.classList.add("ripple", "open");
116
+ const element = document.createElement("span");
117
+ container.appendChild(element);
118
+ this.shadowRoot.appendChild(container);
119
+ const rect = this.getBoundingClientRect();
120
+ const diameter = Math.max(offsetWidth, offsetWidth) * 2;
121
+ element.style.width = element.style.height = diameter + "px";
122
+ element.style.left = x - rect.left - diameter / 2 + "px";
123
+ element.style.top = y - rect.top - diameter / 2 + "px";
124
+ const inAnimation = element.animate({
125
+ transform: [`scale(0)`, `scale(1)`]
126
+ }, {
127
+ easing: "ease-out",
128
+ fill: "both",
129
+ duration: 500
130
+ });
131
+ inAnimation.onfinish = () => {
132
+ container.classList.remove("open");
133
+ const outAnimation = element.animate({
134
+ opacity: ["0.5", "0"]
135
+ }, {
136
+ easing: "ease-in",
137
+ fill: "both",
138
+ duration: 300
139
+ });
140
+ outAnimation.onfinish = () => {
141
+ requestAnimationFrame(() => {
142
+ container.remove();
143
+ });
144
+ };
145
+ };
146
+ };
147
+ this.hideRipple = (event) => {
148
+ var _a;
149
+ (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".ripple:not([open])").forEach(container => {
150
+ const element = container.querySelector("span");
151
+ const outAnimation = element.animate({
152
+ opacity: ["0.5", "0"]
153
+ }, {
154
+ easing: "ease-out",
155
+ fill: "both",
156
+ duration: 300
157
+ });
158
+ outAnimation.onfinish = () => {
159
+ requestAnimationFrame(() => {
160
+ container.remove();
161
+ });
162
+ };
163
+ });
164
+ };
110
165
  }
111
166
  static get styles() {
112
167
  return [
@@ -122,14 +177,14 @@ let TkBox = class TkBox extends external_lit_.LitElement {
122
177
  }
123
178
  connectedCallback() {
124
179
  if (this.ripple) {
125
- this.addEventListener("mousedown", this.showRipple.bind(this), { passive: true });
126
- this.addEventListener("mouseup", this.hideRipple.bind(this), { passive: true });
180
+ this.addEventListener("mousedown", this.showRipple, { passive: true });
181
+ this.addEventListener("mouseup", this.hideRipple, { passive: true });
127
182
  }
128
183
  super.connectedCallback();
129
184
  }
130
185
  disconnectedCallback() {
131
186
  this.removeEventListener("mousedown", this.showRipple);
132
- this.addEventListener("mouseup", this.hideRipple);
187
+ this.removeEventListener("mouseup", this.hideRipple);
133
188
  super.disconnectedCallback();
134
189
  }
135
190
  updated(props) {
@@ -139,61 +194,6 @@ let TkBox = class TkBox extends external_lit_.LitElement {
139
194
  // this.style.setProperty("color", this.color.toString());
140
195
  super.updated(props);
141
196
  }
142
- showRipple(event) {
143
- const x = event.clientX;
144
- const y = event.clientY;
145
- const { offsetWidth, offsetHeight } = this;
146
- const container = document.createElement("span");
147
- container.classList.add("ripple", "open");
148
- const element = document.createElement("span");
149
- container.appendChild(element);
150
- this.shadowRoot.appendChild(container);
151
- const rect = this.getBoundingClientRect();
152
- const diameter = Math.max(offsetWidth, offsetWidth) * 2;
153
- element.style.width = element.style.height = diameter + "px";
154
- element.style.left = x - rect.left - diameter / 2 + "px";
155
- element.style.top = y - rect.top - diameter / 2 + "px";
156
- const inAnimation = element.animate({
157
- transform: [`scale(0)`, `scale(1)`]
158
- }, {
159
- easing: "ease-out",
160
- fill: "both",
161
- duration: 500
162
- });
163
- inAnimation.onfinish = () => {
164
- container.classList.remove("open");
165
- const outAnimation = element.animate({
166
- opacity: ["0.5", "0"]
167
- }, {
168
- easing: "ease-in",
169
- fill: "both",
170
- duration: 300
171
- });
172
- outAnimation.onfinish = () => {
173
- requestAnimationFrame(() => {
174
- container.remove();
175
- });
176
- };
177
- };
178
- }
179
- hideRipple(event) {
180
- var _a;
181
- (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".ripple:not([open])").forEach(container => {
182
- const element = container.querySelector("span");
183
- const outAnimation = element.animate({
184
- opacity: ["0.5", "0"]
185
- }, {
186
- easing: "ease-out",
187
- fill: "both",
188
- duration: 300
189
- });
190
- outAnimation.onfinish = () => {
191
- requestAnimationFrame(() => {
192
- container.remove();
193
- });
194
- };
195
- });
196
- }
197
197
  };
198
198
  __decorate([
199
199
  (0,decorators_js_.property)({ type: Boolean })
@@ -286,7 +286,7 @@ var box = __webpack_require__(3433);
286
286
  // EXTERNAL MODULE: ./tinkiet/utils/unique.ts
287
287
  var unique = __webpack_require__(3770);
288
288
  ;// ./tinkiet/button/button.scss
289
- /* harmony default export */ const button_button = ("*{-webkit-tap-highlight-color:rgba(0,0,0,0);-webkit-tap-highlight-color:rgba(0,0,0,0);box-sizing:border-box}:host{display:inline-flex;justify-content:center;flex-shrink:0;flex-direction:row;align-items:center;position:relative;cursor:pointer;text-align:center;text-decoration:none;vertical-align:middle;text-overflow:ellipsis;user-select:none;overflow:hidden;border-radius:20px;height:40px;width:40px;color:hsl(var(--primary))}:host tk-icon{width:24px;height:24px}:host([extended]){width:auto}:host([extended]) .content{display:flex;align-items:center;pointer-events:none;font-family:Roboto,sans-serif;line-height:20px;font-size:var(--font-size, 14px);font-weight:500;margin:0 24px}:host([extended]) .content.has-icon{margin:0 24px 0 8px}:host([extended]) tk-icon{margin-left:16px;width:18px;height:18px}:host(:hover),:host(:focus){background-color:hsla(var(--primary), 0.3);outline:none}:host([elevated]){background-color:hsl(var(--surface-container-low));color:hsl(var(--primary));box-shadow:0px 1px 2px 0px rgba(0,0,0,.3),0px 1px 3px 1px rgba(0,0,0,.15)}:host([elevated]:hover),:host([elevated]:focus){box-shadow:0px 1px 2px 0px rgba(0,0,0,.3),0px 2px 6px 2px rgba(0,0,0,.15);background-color:hsl(var(--surface-container-high));outline:none}:host([filled]){background-color:hsl(var(--primary));color:hsl(var(--on-primary))}:host([filled]:hover){box-shadow:0px 1px 2px 0px rgba(0,0,0,.3),0px 1px 3px 1px rgba(0,0,0,.15);background-color:hsla(var(--primary), 0.6)}:host([filled]:focus){background-color:hsla(var(--primary), 0.6);outline:none}:host([tonal]){background-color:hsl(var(--secondary-container));color:hsl(var(--on-secondary-container))}:host([tonal]:hover){box-shadow:0px 1px 2px 0px rgba(0,0,0,.3),0px 1px 3px 1px rgba(0,0,0,.15);background-color:hsla(var(--on-secondary-container), 0.3)}:host([tonal]:focus){background-color:hsla(var(--on-secondary-container), 0.3);outline:none}:host([outlined]){background-color:rgba(0,0,0,0);border:solid 1px hsl(var(--outline));color:hsl(var(--primary))}:host([outlined]:hover){background-color:hsla(var(--primary), 0.08);color:hsl(var(--primary))}:host([outlined]:focus){background-color:hsla(var(--primary), 0.12);border-color:hsl(var(--primary));outline:none}:host([fab]){background-color:hsl(var(--primary));display:inline-flex;justify-content:center;align-items:center;color:hsl(var(--on-primary));box-shadow:0px 1px 3px 0px rgba(0,0,0,.3),0px 4px 8px 3px rgba(0,0,0,.15);width:56px;height:56px;padding:12px;border-radius:16px}:host([fab]) tk-icon{margin-left:0;width:24px;height:24px}:host([fab]) .content{margin:0}:host([fab][extended]){width:auto;min-width:80px}:host([fab][extended]) .content{margin:0 24px}:host([fab][extended]) .content.has-icon{margin:0 24px 0 8px}:host([fab][extended]) tk-icon{margin-left:16px}:host([fab]:hover){background-color:hsla(var(--on-primary-container), 0.3)}:host([fab]:focus){box-shadow:0px 1px 3px 0px rgba(0,0,0,.3),0px 4px 8px 3px rgba(0,0,0,.15);background-color:hsla(var(--on-primary-container), 0.3);outline:none}:host([fab][small]){width:40px;height:40px;border-radius:12px}:host([fab][small]) tk-icon{width:24px;height:24px}:host([fab][large]){width:96px;height:96px;border-radius:28px}:host([fab][large]) tk-icon{width:36px;height:36px}:host([disabled]){pointer-events:none;cursor:not-allowed;background-color:hsla(var(--on-surface), 0.12);box-shadow:none;opacity:.5;color:hsl(var(--on-surface))}");
289
+ /* harmony default export */ const button_button = ("*{-webkit-tap-highlight-color:rgba(0,0,0,0);-webkit-tap-highlight-color:rgba(0,0,0,0);box-sizing:border-box}:host{display:inline-flex;justify-content:center;flex-shrink:0;flex-direction:row;align-items:center;position:relative;cursor:pointer;text-align:center;text-decoration:none;vertical-align:middle;text-overflow:ellipsis;user-select:none;overflow:hidden;border-radius:20px;height:40px;width:40px;color:hsl(var(--primary))}:host tk-icon{width:24px;height:24px}.badge-in,.badge-out{display:none}:host([has-badge-in]) .badge-in,:host([has-badge-out]) .badge-out{display:inline-flex;align-items:center}.badge-in{align-items:center;margin:0 12px 0 8px}.badge-out{position:absolute;top:0;right:0;transform:translate(50%, -50%);pointer-events:none}:host([extended]){width:auto}:host([extended]) .content{display:flex;align-items:center;pointer-events:none;font-family:Roboto,sans-serif;line-height:20px;font-size:var(--font-size, 14px);font-weight:500;margin:0 24px}:host([extended]) .content.has-icon{margin:0 24px 0 8px}:host([extended]) tk-icon{margin-left:16px;width:18px;height:18px}:host(:hover),:host(:focus){background-color:hsla(var(--primary), 0.3);outline:none}:host([elevated]){background-color:hsl(var(--surface-container-low));color:hsl(var(--primary));box-shadow:0px 1px 2px 0px rgba(0,0,0,.3),0px 1px 3px 1px rgba(0,0,0,.15)}:host([elevated]:hover),:host([elevated]:focus){box-shadow:0px 1px 2px 0px rgba(0,0,0,.3),0px 2px 6px 2px rgba(0,0,0,.15);background-color:hsl(var(--surface-container-high));outline:none}:host([filled]){background-color:hsl(var(--primary));color:hsl(var(--on-primary))}:host([filled]:hover){box-shadow:0px 1px 2px 0px rgba(0,0,0,.3),0px 1px 3px 1px rgba(0,0,0,.15);background-color:hsla(var(--primary), 0.6)}:host([filled]:focus){background-color:hsla(var(--primary), 0.6);outline:none}:host([tonal]){background-color:hsl(var(--secondary-container));color:hsl(var(--on-secondary-container))}:host([tonal]:hover){box-shadow:0px 1px 2px 0px rgba(0,0,0,.3),0px 1px 3px 1px rgba(0,0,0,.15);background-color:hsla(var(--on-secondary-container), 0.3)}:host([tonal]:focus){background-color:hsla(var(--on-secondary-container), 0.3);outline:none}:host([outlined]){background-color:rgba(0,0,0,0);border:solid 1px hsl(var(--outline));color:hsl(var(--primary))}:host([outlined]:hover){background-color:hsla(var(--primary), 0.08);color:hsl(var(--primary))}:host([outlined]:focus){background-color:hsla(var(--primary), 0.12);border-color:hsl(var(--primary));outline:none}:host([fab]){background-color:hsl(var(--primary));display:inline-flex;justify-content:center;align-items:center;color:hsl(var(--on-primary));box-shadow:0px 1px 3px 0px rgba(0,0,0,.3),0px 4px 8px 3px rgba(0,0,0,.15);width:56px;height:56px;padding:12px;border-radius:16px}:host([fab]) tk-icon{margin-left:0;width:24px;height:24px}:host([fab]) .content{margin:0}:host([fab][extended]){width:auto;min-width:80px}:host([fab][extended]) .content{margin:0 24px}:host([fab][extended]) .content.has-icon{margin:0 24px 0 8px}:host([fab][extended]) tk-icon{margin-left:16px}:host([fab]:hover){background-color:hsla(var(--on-primary-container), 0.3)}:host([fab]:focus){box-shadow:0px 1px 3px 0px rgba(0,0,0,.3),0px 4px 8px 3px rgba(0,0,0,.15);background-color:hsla(var(--on-primary-container), 0.3);outline:none}:host([fab][small]){width:40px;height:40px;border-radius:12px}:host([fab][small]) tk-icon{width:24px;height:24px}:host([fab][large]){width:96px;height:96px;border-radius:28px}:host([fab][large]) tk-icon{width:36px;height:36px}:host([disabled]){pointer-events:none;cursor:not-allowed;background-color:hsla(var(--on-surface), 0.12);box-shadow:none;opacity:.5;color:hsl(var(--on-surface))}");
290
290
  ;// ./tinkiet/button/button.ts
291
291
  var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
292
292
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -324,6 +324,33 @@ let TkButton = class TkButton extends box/* TkBox */.P {
324
324
  this.disabled = false;
325
325
  this.fab = false;
326
326
  this.ripple = true;
327
+ this.onKeyDown = (e) => {
328
+ if (e.code === "Space" || e.code === "Enter") {
329
+ e.preventDefault();
330
+ e.stopPropagation();
331
+ this.click();
332
+ }
333
+ };
334
+ this.handleClick = (e) => {
335
+ var _a;
336
+ if (this.href && e.isTrusted) {
337
+ e.stopPropagation();
338
+ e.preventDefault();
339
+ this.$ahref.click();
340
+ }
341
+ else if ((e.isTrusted && this.type == "submit") || this.type == "reset") {
342
+ (_a = this.querySelector("button")) === null || _a === void 0 ? void 0 : _a.click();
343
+ }
344
+ };
345
+ this.slotChanged = () => {
346
+ this.toggleAttributeForSlot(this.$defaultSlot, "extended");
347
+ };
348
+ this.badgeInChanged = () => {
349
+ this.toggleAttributeForSlot(this.$badgeInSlot, "has-badge-in");
350
+ };
351
+ this.badgeOutChanged = () => {
352
+ this.toggleAttributeForSlot(this.$badgeOutSlot, "has-badge-out");
353
+ };
327
354
  }
328
355
  static get styles() {
329
356
  return [
@@ -333,6 +360,24 @@ let TkButton = class TkButton extends box/* TkBox */.P {
333
360
  `
334
361
  ];
335
362
  }
363
+ hasSlotContent(slot) {
364
+ var _a;
365
+ const nodes = (_a = slot === null || slot === void 0 ? void 0 : slot.assignedNodes({ flatten: true })) !== null && _a !== void 0 ? _a : [];
366
+ return nodes.some(node => {
367
+ var _a;
368
+ if (node.nodeType === Node.TEXT_NODE)
369
+ return !!((_a = node.textContent) === null || _a === void 0 ? void 0 : _a.trim());
370
+ return node.nodeType !== Node.COMMENT_NODE;
371
+ });
372
+ }
373
+ toggleAttributeForSlot(slot, attribute) {
374
+ if (this.hasSlotContent(slot)) {
375
+ this.setAttribute(attribute, "");
376
+ }
377
+ else {
378
+ this.removeAttribute(attribute);
379
+ }
380
+ }
336
381
  render() {
337
382
  return (0,external_lit_.html) `
338
383
  ${this.iconPath
@@ -341,8 +386,14 @@ let TkButton = class TkButton extends box/* TkBox */.P {
341
386
  `
342
387
  : ""}
343
388
 
344
- <div class="content ${this.iconPath ? "has-icon" : ""}" @slotchange=${this.slotChanged}>
345
- <slot></slot>
389
+ <div class="content ${this.iconPath ? "has-icon" : ""}">
390
+ <slot @slotchange=${this.slotChanged}></slot>
391
+ </div>
392
+ <div class="badge-in">
393
+ <slot name="badge-in" @slotchange=${this.badgeInChanged}></slot>
394
+ </div>
395
+ <div class="badge-out">
396
+ <slot name="badge-out" @slotchange=${this.badgeOutChanged}></slot>
346
397
  </div>
347
398
 
348
399
  ${this.href
@@ -355,7 +406,8 @@ let TkButton = class TkButton extends box/* TkBox */.P {
355
406
  }
356
407
  connectedCallback() {
357
408
  super.connectedCallback();
358
- this.addEventListener("click", this.handleClick.bind(this));
409
+ this.addEventListener("click", this.handleClick);
410
+ this.addEventListener("keydown", this.onKeyDown);
359
411
  }
360
412
  disconnectedCallback() {
361
413
  super.disconnectedCallback();
@@ -366,38 +418,12 @@ let TkButton = class TkButton extends box/* TkBox */.P {
366
418
  this.tabIndex = this.disabled ? -1 : 0;
367
419
  super.updated(props);
368
420
  }
369
- onKeyDown(e) {
370
- if (e.code === "Space" || e.code === "Enter") {
371
- e.preventDefault();
372
- e.stopPropagation();
373
- this.click();
374
- }
375
- }
376
421
  firstUpdated() {
377
422
  if (this.type == "submit" || this.type == "reset")
378
423
  this.appendChild(this.$button);
379
- }
380
- handleClick(e) {
381
- var _a;
382
- if (this.href && e.isTrusted) {
383
- e.stopPropagation();
384
- e.preventDefault();
385
- this.$ahref.click();
386
- }
387
- else if ((e.isTrusted && this.type == "submit") || this.type == "reset") {
388
- (_a = this.querySelector("button")) === null || _a === void 0 ? void 0 : _a.click();
389
- }
390
- }
391
- slotChanged() {
392
- var _a;
393
- const slot = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('slot');
394
- const elements = slot === null || slot === void 0 ? void 0 : slot.assignedNodes({ flatten: true });
395
- if (elements && elements.length > 0) {
396
- this.setAttribute('extended', '');
397
- }
398
- else {
399
- this.removeAttribute('extended');
400
- }
424
+ this.slotChanged();
425
+ this.badgeInChanged();
426
+ this.badgeOutChanged();
401
427
  }
402
428
  };
403
429
  __decorate([
@@ -419,7 +445,7 @@ __decorate([
419
445
  (0,decorators_js_.property)({ type: String })
420
446
  ], TkButton.prototype, "iconPath", void 0);
421
447
  __decorate([
422
- (0,decorators_js_.property)()
448
+ (0,decorators_js_.property)({ type: Boolean })
423
449
  ], TkButton.prototype, "ripple", void 0);
424
450
  __decorate([
425
451
  (0,decorators_js_.query)("#ahref")
@@ -427,6 +453,15 @@ __decorate([
427
453
  __decorate([
428
454
  (0,decorators_js_.query)("button")
429
455
  ], TkButton.prototype, "$button", void 0);
456
+ __decorate([
457
+ (0,decorators_js_.query)("slot:not([name])")
458
+ ], TkButton.prototype, "$defaultSlot", void 0);
459
+ __decorate([
460
+ (0,decorators_js_.query)('slot[name="badge-in"]')
461
+ ], TkButton.prototype, "$badgeInSlot", void 0);
462
+ __decorate([
463
+ (0,decorators_js_.query)('slot[name="badge-out"]')
464
+ ], TkButton.prototype, "$badgeOutSlot", void 0);
430
465
  TkButton = __decorate([
431
466
  (0,decorators_js_.customElement)("tk-button")
432
467
  ], TkButton);
@@ -1,4 +1,4 @@
1
- import { LitElement } from "lit";
1
+ import { LitElement, PropertyValues } from "lit";
2
2
  import "../box";
3
3
  export declare class TkCheckbox extends LitElement {
4
4
  static styles: import("lit").CSSResult;
@@ -11,11 +11,9 @@ export declare class TkCheckbox extends LitElement {
11
11
  private $input;
12
12
  constructor();
13
13
  render(): import("lit").TemplateResult<1>;
14
- protected firstUpdated(): void;
15
- protected updated(): void;
14
+ protected updated(changedProps: PropertyValues<this>): void;
16
15
  protected onKeyDown(e: KeyboardEvent): void;
17
16
  protected handleClick(): void;
18
- private syncInput;
19
17
  }
20
18
  declare global {
21
19
  interface HTMLElementTagNameMap {
package/checkbox/index.js CHANGED
@@ -48,13 +48,37 @@ let TkCheckbox = class TkCheckbox extends external_lit_.LitElement {
48
48
  this.onKeyDown = this.onKeyDown.bind(this);
49
49
  }
50
50
  render() {
51
+ var _a, _b;
52
+ const labelId = `${this._id}-label`;
53
+ const ariaChecked = this.indeterminate ? "mixed" : this.checked ? "true" : "false";
51
54
  const containerClasses = {
52
55
  state: true,
53
56
  disabled: this.disabled
54
57
  };
55
58
  return (0,external_lit_.html) `
59
+ <input
60
+ type="checkbox"
61
+ aria-hidden="true"
62
+ tabindex="-1"
63
+ style="display: none"
64
+ .id=${this._id}
65
+ .name=${(_a = this.name) !== null && _a !== void 0 ? _a : ""}
66
+ .value=${(_b = this.value) !== null && _b !== void 0 ? _b : "on"}
67
+ ?checked=${this.checked}
68
+ ?disabled=${this.disabled}
69
+ .indeterminate=${this.indeterminate}
70
+ />
56
71
  <tk-box direction="row" align-items="center" @click=${this.handleClick}>
57
- <tk-box ripple tabindex="${this.disabled ? -1 : 0}" class=${(0,class_map_js_.classMap)(containerClasses)} @keydown=${this.onKeyDown}>
72
+ <tk-box
73
+ ripple
74
+ tabindex="${this.disabled ? -1 : 0}"
75
+ class=${(0,class_map_js_.classMap)(containerClasses)}
76
+ role="checkbox"
77
+ aria-checked=${ariaChecked}
78
+ aria-disabled=${this.disabled ? "true" : "false"}
79
+ aria-labelledby=${labelId}
80
+ @keydown=${this.onKeyDown}
81
+ >
58
82
  <div class="checkbox">
59
83
  <svg id="checkmark" xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" preserveAspectRatio="none" viewBox="0 0 24 24">
60
84
  <path id="checkmark-path" fill="none" d="M1.73,12.91 8.1,19.28 22.79,4.59"></path>
@@ -62,22 +86,15 @@ let TkCheckbox = class TkCheckbox extends external_lit_.LitElement {
62
86
  </svg>
63
87
  </div>
64
88
  </tk-box>
65
- <span class="label"><slot></slot></span>
89
+ <span class="label" id=${labelId}><slot></slot></span>
66
90
  </tk-box>
67
91
  `;
68
92
  }
69
- firstUpdated() {
70
- this.$input = document.createElement("input");
71
- this.$input.type = "checkbox";
72
- this.$input.slot = "none";
73
- this.$input.style.display = "none";
74
- this.$input.setAttribute("aria-hidden", "true");
75
- this.$input.tabIndex = -1;
76
- this.syncInput();
77
- this.appendChild(this.$input);
78
- }
79
- updated() {
80
- this.syncInput();
93
+ updated(changedProps) {
94
+ super.updated(changedProps);
95
+ if (changedProps.has("indeterminate") && this.$input) {
96
+ this.$input.indeterminate = this.indeterminate;
97
+ }
81
98
  }
82
99
  onKeyDown(e) {
83
100
  if (this.disabled)
@@ -85,7 +102,7 @@ let TkCheckbox = class TkCheckbox extends external_lit_.LitElement {
85
102
  if (e.code === "Space" || e.code === "Enter") {
86
103
  e.preventDefault();
87
104
  e.stopPropagation();
88
- this.click();
105
+ this.handleClick();
89
106
  }
90
107
  }
91
108
  handleClick() {
@@ -94,18 +111,11 @@ let TkCheckbox = class TkCheckbox extends external_lit_.LitElement {
94
111
  this.checked = !this.checked;
95
112
  if (this.indeterminate)
96
113
  this.indeterminate = false;
97
- setTimeout(() => this.dispatchEvent(new Event("change", { bubbles: true, composed: true })));
98
- }
99
- syncInput() {
100
- var _a, _b;
101
- if (!this.$input)
102
- return;
103
- this.$input.id = this._id;
104
- this.$input.name = (_a = this.name) !== null && _a !== void 0 ? _a : "";
105
- this.$input.value = (_b = this.value) !== null && _b !== void 0 ? _b : "on";
106
- this.$input.checked = this.checked;
107
- this.$input.disabled = this.disabled;
108
- this.$input.indeterminate = this.indeterminate;
114
+ this.dispatchEvent(new CustomEvent("change", {
115
+ bubbles: true,
116
+ composed: true,
117
+ detail: { checked: this.checked, indeterminate: this.indeterminate }
118
+ }));
109
119
  }
110
120
  };
111
121
  TkCheckbox.styles = (0,external_lit_.css) `
@@ -126,6 +136,9 @@ __decorate([
126
136
  __decorate([
127
137
  (0,decorators_js_.property)({ attribute: true, type: Boolean, reflect: true })
128
138
  ], TkCheckbox.prototype, "indeterminate", void 0);
139
+ __decorate([
140
+ (0,decorators_js_.query)("input[aria-hidden]")
141
+ ], TkCheckbox.prototype, "$input", void 0);
129
142
  TkCheckbox = __decorate([
130
143
  (0,decorators_js_.customElement)("tk-checkbox")
131
144
  ], TkCheckbox);
@@ -240,6 +253,61 @@ let TkBox = class TkBox extends external_lit_.LitElement {
240
253
  * Activate ripple
241
254
  */
242
255
  this.ripple = false;
256
+ this.showRipple = (event) => {
257
+ const x = event.clientX;
258
+ const y = event.clientY;
259
+ const { offsetWidth, offsetHeight } = this;
260
+ const container = document.createElement("span");
261
+ container.classList.add("ripple", "open");
262
+ const element = document.createElement("span");
263
+ container.appendChild(element);
264
+ this.shadowRoot.appendChild(container);
265
+ const rect = this.getBoundingClientRect();
266
+ const diameter = Math.max(offsetWidth, offsetWidth) * 2;
267
+ element.style.width = element.style.height = diameter + "px";
268
+ element.style.left = x - rect.left - diameter / 2 + "px";
269
+ element.style.top = y - rect.top - diameter / 2 + "px";
270
+ const inAnimation = element.animate({
271
+ transform: [`scale(0)`, `scale(1)`]
272
+ }, {
273
+ easing: "ease-out",
274
+ fill: "both",
275
+ duration: 500
276
+ });
277
+ inAnimation.onfinish = () => {
278
+ container.classList.remove("open");
279
+ const outAnimation = element.animate({
280
+ opacity: ["0.5", "0"]
281
+ }, {
282
+ easing: "ease-in",
283
+ fill: "both",
284
+ duration: 300
285
+ });
286
+ outAnimation.onfinish = () => {
287
+ requestAnimationFrame(() => {
288
+ container.remove();
289
+ });
290
+ };
291
+ };
292
+ };
293
+ this.hideRipple = (event) => {
294
+ var _a;
295
+ (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".ripple:not([open])").forEach(container => {
296
+ const element = container.querySelector("span");
297
+ const outAnimation = element.animate({
298
+ opacity: ["0.5", "0"]
299
+ }, {
300
+ easing: "ease-out",
301
+ fill: "both",
302
+ duration: 300
303
+ });
304
+ outAnimation.onfinish = () => {
305
+ requestAnimationFrame(() => {
306
+ container.remove();
307
+ });
308
+ };
309
+ });
310
+ };
243
311
  }
244
312
  static get styles() {
245
313
  return [
@@ -255,14 +323,14 @@ let TkBox = class TkBox extends external_lit_.LitElement {
255
323
  }
256
324
  connectedCallback() {
257
325
  if (this.ripple) {
258
- this.addEventListener("mousedown", this.showRipple.bind(this), { passive: true });
259
- this.addEventListener("mouseup", this.hideRipple.bind(this), { passive: true });
326
+ this.addEventListener("mousedown", this.showRipple, { passive: true });
327
+ this.addEventListener("mouseup", this.hideRipple, { passive: true });
260
328
  }
261
329
  super.connectedCallback();
262
330
  }
263
331
  disconnectedCallback() {
264
332
  this.removeEventListener("mousedown", this.showRipple);
265
- this.addEventListener("mouseup", this.hideRipple);
333
+ this.removeEventListener("mouseup", this.hideRipple);
266
334
  super.disconnectedCallback();
267
335
  }
268
336
  updated(props) {
@@ -272,61 +340,6 @@ let TkBox = class TkBox extends external_lit_.LitElement {
272
340
  // this.style.setProperty("color", this.color.toString());
273
341
  super.updated(props);
274
342
  }
275
- showRipple(event) {
276
- const x = event.clientX;
277
- const y = event.clientY;
278
- const { offsetWidth, offsetHeight } = this;
279
- const container = document.createElement("span");
280
- container.classList.add("ripple", "open");
281
- const element = document.createElement("span");
282
- container.appendChild(element);
283
- this.shadowRoot.appendChild(container);
284
- const rect = this.getBoundingClientRect();
285
- const diameter = Math.max(offsetWidth, offsetWidth) * 2;
286
- element.style.width = element.style.height = diameter + "px";
287
- element.style.left = x - rect.left - diameter / 2 + "px";
288
- element.style.top = y - rect.top - diameter / 2 + "px";
289
- const inAnimation = element.animate({
290
- transform: [`scale(0)`, `scale(1)`]
291
- }, {
292
- easing: "ease-out",
293
- fill: "both",
294
- duration: 500
295
- });
296
- inAnimation.onfinish = () => {
297
- container.classList.remove("open");
298
- const outAnimation = element.animate({
299
- opacity: ["0.5", "0"]
300
- }, {
301
- easing: "ease-in",
302
- fill: "both",
303
- duration: 300
304
- });
305
- outAnimation.onfinish = () => {
306
- requestAnimationFrame(() => {
307
- container.remove();
308
- });
309
- };
310
- };
311
- }
312
- hideRipple(event) {
313
- var _a;
314
- (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".ripple:not([open])").forEach(container => {
315
- const element = container.querySelector("span");
316
- const outAnimation = element.animate({
317
- opacity: ["0.5", "0"]
318
- }, {
319
- easing: "ease-out",
320
- fill: "both",
321
- duration: 300
322
- });
323
- outAnimation.onfinish = () => {
324
- requestAnimationFrame(() => {
325
- container.remove();
326
- });
327
- };
328
- });
329
- }
330
343
  };
331
344
  __decorate([
332
345
  (0,decorators_js_.property)({ type: Boolean })
@@ -403,7 +416,7 @@ var x = (y) => {
403
416
  var x = {}; __webpack_require__.d(x, y); return x
404
417
  }
405
418
  var y = (x) => (() => (x))
406
- module.exports = x({ ["customElement"]: () => (__WEBPACK_EXTERNAL_MODULE_lit_decorators_js_226d44c5__.customElement), ["property"]: () => (__WEBPACK_EXTERNAL_MODULE_lit_decorators_js_226d44c5__.property) });
419
+ module.exports = x({ ["customElement"]: () => (__WEBPACK_EXTERNAL_MODULE_lit_decorators_js_226d44c5__.customElement), ["property"]: () => (__WEBPACK_EXTERNAL_MODULE_lit_decorators_js_226d44c5__.property), ["query"]: () => (__WEBPACK_EXTERNAL_MODULE_lit_decorators_js_226d44c5__.query) });
407
420
 
408
421
  /***/ })
409
422
 
package/chip/chip.d.ts CHANGED
@@ -15,7 +15,7 @@ export declare class TkChip extends LitElement {
15
15
  disabled: boolean;
16
16
  removable: boolean;
17
17
  static styles: import("lit").CSSResult;
18
- private onRemove;
18
+ private readonly onRemove;
19
19
  render(): import("lit").TemplateResult<1>;
20
20
  }
21
21
  declare global {