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/index.js CHANGED
@@ -143,63 +143,69 @@ let TkListItem = class TkListItem extends box/* TkBox */.P {
143
143
  return (0,external_lit_.html) `
144
144
  <slot name="before" @click=${this.handleClick}></slot>
145
145
  <div id="content">
146
- <slot></slot>
146
+ <slot @slotchange=${this.ensureAriaLabel}></slot>
147
147
  </div>
148
148
  <slot name="after" @click=${this.handleClick}></slot>
149
149
  ${this.href
150
150
  ? (0,external_lit_.html) `
151
- <a tabindex="-1" id="ahref" href="${this.href}" target=${(0,if_defined_js_.ifDefined)(this.target)} rel="noreferrer" aria-label=${this.ariaLabel}></a>
151
+ <a tabindex="-1" id="ahref" href=${this.href} target=${(0,if_defined_js_.ifDefined)(this.target)} rel="noreferrer" aria-label=${this.ariaLabel}></a>
152
152
  `
153
- : ""}
153
+ : external_lit_.nothing}
154
154
  `;
155
155
  }
156
156
  constructor() {
157
157
  super();
158
158
  this.href = "";
159
159
  this.target = "";
160
- }
161
- firstUpdated() {
162
- if (!this.ariaLabel && this.innerText)
163
- this.ariaLabel = this.innerText;
160
+ this.ariaLabel = "";
161
+ this.onKeyDown = (e) => {
162
+ if (e.code === "Space" || e.code === "Enter") {
163
+ e.preventDefault();
164
+ e.stopPropagation();
165
+ this.click();
166
+ }
167
+ };
168
+ this.handleClick = (e) => {
169
+ const target = e.target;
170
+ // In case click cames from a slotted element with href attribute we stop propagation
171
+ if (target.tagName == "BUTTON" || target.tagName == "TK-BUTTON" || target.tagName == "TK-SWITCH" || target.tagName == "TK-CHECKBOX") {
172
+ return;
173
+ }
174
+ if (this.href && e.isTrusted && this.$ahref) {
175
+ e.stopPropagation();
176
+ e.preventDefault();
177
+ this.$ahref.click();
178
+ }
179
+ };
164
180
  }
165
181
  connectedCallback() {
166
182
  super.connectedCallback();
167
- this.addEventListener("keydown", this.onKeyDown.bind(this));
168
- this.addEventListener("click", this.handleClick.bind(this));
183
+ this.ensureAriaLabel();
184
+ this.addEventListener("keydown", this.onKeyDown);
185
+ this.addEventListener("click", this.handleClick);
169
186
  }
170
187
  disconnectedCallback() {
171
188
  super.disconnectedCallback();
172
189
  this.removeEventListener("click", this.handleClick);
173
190
  this.removeEventListener("keydown", this.onKeyDown);
174
191
  }
175
- onKeyDown(e) {
176
- if (e.code === "Space" || e.code === "Enter") {
177
- e.preventDefault();
178
- e.stopPropagation();
179
- this.click();
180
- }
181
- }
182
- handleClick(e) {
183
- const target = e.target;
184
- // In case click cames from a slotted element with href attribute we stop propagation
185
- if (target.tagName == "BUTTON" || target.tagName == "TK-BUTTON" || target.tagName == "TK-SWITCH" || target.tagName == "TK-CHECKBOX") {
192
+ ensureAriaLabel() {
193
+ var _a;
194
+ if (this.ariaLabel)
186
195
  return;
187
- }
188
- if (this.href && e.isTrusted) {
189
- e.stopPropagation();
190
- e.preventDefault();
191
- this.$ahref.click();
192
- }
196
+ const text = (_a = this.textContent) === null || _a === void 0 ? void 0 : _a.trim();
197
+ if (text)
198
+ this.ariaLabel = text;
193
199
  }
194
200
  };
195
201
  __decorate([
196
- (0,decorators_js_.property)({ attribute: true })
202
+ (0,decorators_js_.property)({ type: String, reflect: true })
197
203
  ], TkListItem.prototype, "href", void 0);
198
204
  __decorate([
199
- (0,decorators_js_.property)({ attribute: true })
205
+ (0,decorators_js_.property)({ type: String, reflect: true })
200
206
  ], TkListItem.prototype, "target", void 0);
201
207
  __decorate([
202
- (0,decorators_js_.property)({ attribute: "aria-label" })
208
+ (0,decorators_js_.property)({ attribute: "aria-label", reflect: true })
203
209
  ], TkListItem.prototype, "ariaLabel", void 0);
204
210
  __decorate([
205
211
  (0,decorators_js_.query)("#ahref")
@@ -608,13 +614,37 @@ let TkCheckbox = class TkCheckbox extends external_lit_.LitElement {
608
614
  this.onKeyDown = this.onKeyDown.bind(this);
609
615
  }
610
616
  render() {
617
+ var _a, _b;
618
+ const labelId = `${this._id}-label`;
619
+ const ariaChecked = this.indeterminate ? "mixed" : this.checked ? "true" : "false";
611
620
  const containerClasses = {
612
621
  state: true,
613
622
  disabled: this.disabled
614
623
  };
615
624
  return (0,external_lit_.html) `
625
+ <input
626
+ type="checkbox"
627
+ aria-hidden="true"
628
+ tabindex="-1"
629
+ style="display: none"
630
+ .id=${this._id}
631
+ .name=${(_a = this.name) !== null && _a !== void 0 ? _a : ""}
632
+ .value=${(_b = this.value) !== null && _b !== void 0 ? _b : "on"}
633
+ ?checked=${this.checked}
634
+ ?disabled=${this.disabled}
635
+ .indeterminate=${this.indeterminate}
636
+ />
616
637
  <tk-box direction="row" align-items="center" @click=${this.handleClick}>
617
- <tk-box ripple tabindex="${this.disabled ? -1 : 0}" class=${(0,class_map_js_.classMap)(containerClasses)} @keydown=${this.onKeyDown}>
638
+ <tk-box
639
+ ripple
640
+ tabindex="${this.disabled ? -1 : 0}"
641
+ class=${(0,class_map_js_.classMap)(containerClasses)}
642
+ role="checkbox"
643
+ aria-checked=${ariaChecked}
644
+ aria-disabled=${this.disabled ? "true" : "false"}
645
+ aria-labelledby=${labelId}
646
+ @keydown=${this.onKeyDown}
647
+ >
618
648
  <div class="checkbox">
619
649
  <svg id="checkmark" xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" preserveAspectRatio="none" viewBox="0 0 24 24">
620
650
  <path id="checkmark-path" fill="none" d="M1.73,12.91 8.1,19.28 22.79,4.59"></path>
@@ -622,22 +652,15 @@ let TkCheckbox = class TkCheckbox extends external_lit_.LitElement {
622
652
  </svg>
623
653
  </div>
624
654
  </tk-box>
625
- <span class="label"><slot></slot></span>
655
+ <span class="label" id=${labelId}><slot></slot></span>
626
656
  </tk-box>
627
657
  `;
628
658
  }
629
- firstUpdated() {
630
- this.$input = document.createElement("input");
631
- this.$input.type = "checkbox";
632
- this.$input.slot = "none";
633
- this.$input.style.display = "none";
634
- this.$input.setAttribute("aria-hidden", "true");
635
- this.$input.tabIndex = -1;
636
- this.syncInput();
637
- this.appendChild(this.$input);
638
- }
639
- updated() {
640
- this.syncInput();
659
+ updated(changedProps) {
660
+ super.updated(changedProps);
661
+ if (changedProps.has("indeterminate") && this.$input) {
662
+ this.$input.indeterminate = this.indeterminate;
663
+ }
641
664
  }
642
665
  onKeyDown(e) {
643
666
  if (this.disabled)
@@ -645,7 +668,7 @@ let TkCheckbox = class TkCheckbox extends external_lit_.LitElement {
645
668
  if (e.code === "Space" || e.code === "Enter") {
646
669
  e.preventDefault();
647
670
  e.stopPropagation();
648
- this.click();
671
+ this.handleClick();
649
672
  }
650
673
  }
651
674
  handleClick() {
@@ -654,18 +677,11 @@ let TkCheckbox = class TkCheckbox extends external_lit_.LitElement {
654
677
  this.checked = !this.checked;
655
678
  if (this.indeterminate)
656
679
  this.indeterminate = false;
657
- setTimeout(() => this.dispatchEvent(new Event("change", { bubbles: true, composed: true })));
658
- }
659
- syncInput() {
660
- var _a, _b;
661
- if (!this.$input)
662
- return;
663
- this.$input.id = this._id;
664
- this.$input.name = (_a = this.name) !== null && _a !== void 0 ? _a : "";
665
- this.$input.value = (_b = this.value) !== null && _b !== void 0 ? _b : "on";
666
- this.$input.checked = this.checked;
667
- this.$input.disabled = this.disabled;
668
- this.$input.indeterminate = this.indeterminate;
680
+ this.dispatchEvent(new CustomEvent("change", {
681
+ bubbles: true,
682
+ composed: true,
683
+ detail: { checked: this.checked, indeterminate: this.indeterminate }
684
+ }));
669
685
  }
670
686
  };
671
687
  TkCheckbox.styles = (0,external_lit_.css) `
@@ -686,6 +702,9 @@ __decorate([
686
702
  __decorate([
687
703
  (0,decorators_js_.property)({ attribute: true, type: Boolean, reflect: true })
688
704
  ], TkCheckbox.prototype, "indeterminate", void 0);
705
+ __decorate([
706
+ (0,decorators_js_.query)("input[aria-hidden]")
707
+ ], TkCheckbox.prototype, "$input", void 0);
689
708
  TkCheckbox = __decorate([
690
709
  (0,decorators_js_.customElement)("tk-checkbox")
691
710
  ], TkCheckbox);
@@ -741,14 +760,14 @@ class TkFocusableBox extends box_box/* TkBox */.P {
741
760
  }
742
761
  }
743
762
  __decorate([
744
- (0,decorators_js_.property)({ type: Boolean })
763
+ (0,decorators_js_.property)({ type: String })
745
764
  ], TkFocusableBox.prototype, "_id", void 0);
746
765
  __decorate([
747
766
  (0,decorators_js_.property)({ type: Boolean })
748
767
  ], TkFocusableBox.prototype, "disabled", void 0);
749
768
 
750
769
  ;// ./tinkiet/accordion/accordion.scss
751
- /* harmony default export */ const accordion = ("*{-webkit-tap-highlight-color:rgba(0,0,0,0);-webkit-tap-highlight-color:rgba(0,0,0,0);box-sizing:border-box}:host .header{position:relative;overflow:hidden;color:hsl(var(--on-surface));background-color:hsl(var(--surface-container-low));padding:16px;border:1px solid hsl(var(--outline-variant));border-radius:12px;box-shadow:0px 1px 2px 0px rgba(0,0,0,.3),0px 1px 3px 1px rgba(0,0,0,.15);gap:12px;cursor:pointer;transition:background-color var(--transition-duration-medium, 180ms) var(--transition-timing-function-deceleration-curve, cubic-bezier(0, 0, 0.2, 1)),color var(--transition-duration-medium, 180ms) var(--transition-timing-function-deceleration-curve, cubic-bezier(0, 0, 0.2, 1)),box-shadow var(--transition-duration-medium, 180ms) var(--transition-timing-function-deceleration-curve, cubic-bezier(0, 0, 0.2, 1)),border-color var(--transition-duration-medium, 180ms) var(--transition-timing-function-deceleration-curve, cubic-bezier(0, 0, 0.2, 1))}:host .header:after{transition:transform .3s var(--transition-timing-function-deceleration-curve, cubic-bezier(0, 0, 0.2, 1));content:\"▼\";display:inline-block;font-size:12px;margin-inline-start:8px}:host .header:before{content:\"\";position:absolute;inset:0;background:hsl(var(--on-surface));opacity:0;transition:opacity var(--transition-duration-medium, 180ms) var(--transition-timing-function-deceleration-curve, cubic-bezier(0, 0, 0.2, 1));pointer-events:none}:host .header .before{width:fit-content}:host .header .header-content{flex:1}:host .content{width:100%;margin:4px 0 0;padding:0 16px;opacity:0;visibility:hidden;max-height:0;overflow:hidden;transform:translateY(-8px);transition:max-height .28s var(--transition-timing-function-deceleration-curve, cubic-bezier(0, 0, 0.2, 1)),opacity .28s var(--transition-timing-function-deceleration-curve, cubic-bezier(0, 0, 0.2, 1)),transform .28s var(--transition-timing-function-deceleration-curve, cubic-bezier(0, 0, 0.2, 1));background:hsl(var(--surface-container-lowest));border-radius:0 0 12px 12px}:host h3,:host h5{margin:0}:host .header:hover:before{opacity:.08}:host .header:active:before{opacity:.12}:host .header:focus-visible{outline:none;border-color:hsl(var(--primary));box-shadow:0px 1px 2px 0px rgba(0,0,0,.3),0px 2px 6px 2px rgba(0,0,0,.15),0 0 0 3px hsl(var(--primary)/0.2)}:host([checked]) .header{background-color:hsl(var(--primary-container));color:hsl(var(--on-primary-container));border-color:hsl(var(--primary));box-shadow:0px 1px 2px 0px rgba(0,0,0,.3),0px 2px 6px 2px rgba(0,0,0,.15)}:host([checked]) .header:after{transform:rotate(180deg)}:host([checked]) .header:before{background:hsl(var(--on-primary-container))}:host([checked]) .content{opacity:1;visibility:visible;max-height:var(--tk-accordion-max-height, 1000px);padding:12px 16px;transform:translateY(0);transition:max-height .28s var(--transition-timing-function-deceleration-curve, cubic-bezier(0, 0, 0.2, 1)),opacity .28s var(--transition-timing-function-deceleration-curve, cubic-bezier(0, 0, 0.2, 1)),transform .28s var(--transition-timing-function-deceleration-curve, cubic-bezier(0, 0, 0.2, 1))}:host([pill]) .header{border-radius:9999px}@media(prefers-reduced-motion: reduce){:host .header:after{transition:none}:host .header:before{transition:none}:host .header{transition:none}:host .content{transition:none}}");
770
+ /* harmony default export */ const accordion = ("*{-webkit-tap-highlight-color:rgba(0,0,0,0);-webkit-tap-highlight-color:rgba(0,0,0,0);box-sizing:border-box}:host .header{position:relative;overflow:hidden;color:hsl(var(--on-surface));background-color:hsl(var(--surface-container-low));padding:16px;border:1px solid hsl(var(--outline-variant));border-radius:12px;box-shadow:0px 1px 2px 0px rgba(0,0,0,.3),0px 1px 3px 1px rgba(0,0,0,.15);gap:12px;cursor:pointer;transition:background-color var(--transition-duration-medium, 180ms) var(--transition-timing-function-deceleration-curve, cubic-bezier(0, 0, 0.2, 1)),color var(--transition-duration-medium, 180ms) var(--transition-timing-function-deceleration-curve, cubic-bezier(0, 0, 0.2, 1)),box-shadow var(--transition-duration-medium, 180ms) var(--transition-timing-function-deceleration-curve, cubic-bezier(0, 0, 0.2, 1)),border-color var(--transition-duration-medium, 180ms) var(--transition-timing-function-deceleration-curve, cubic-bezier(0, 0, 0.2, 1))}:host .header:after{transition:transform .3s var(--transition-timing-function-deceleration-curve, cubic-bezier(0, 0, 0.2, 1));content:\"▼\";display:inline-block;font-size:12px;margin-inline-start:8px}:host .header:before{content:\"\";position:absolute;inset:0;background:hsl(var(--on-surface));opacity:0;transition:opacity var(--transition-duration-medium, 180ms) var(--transition-timing-function-deceleration-curve, cubic-bezier(0, 0, 0.2, 1));pointer-events:none}:host .header .before{width:fit-content}:host .header .header-content{flex:1}:host .content{width:100%;margin:4px 0 0;padding:0 16px;opacity:0;visibility:hidden;max-height:0;overflow:hidden;transform:translateY(-8px);transition:max-height .28s var(--transition-timing-function-deceleration-curve, cubic-bezier(0, 0, 0.2, 1)),opacity .28s var(--transition-timing-function-deceleration-curve, cubic-bezier(0, 0, 0.2, 1)),transform .28s var(--transition-timing-function-deceleration-curve, cubic-bezier(0, 0, 0.2, 1));background:hsl(var(--surface-container-lowest));border-radius:0 0 12px 12px}:host h3,:host h5{margin:0}:host .header:hover:before{opacity:.08}:host .header:active:before{opacity:.12}:host .header:focus-visible{outline:none;border-color:hsl(var(--primary));box-shadow:0px 1px 2px 0px rgba(0,0,0,.3),0px 2px 6px 2px rgba(0,0,0,.15),0 0 0 3px hsl(var(--primary)/0.2)}:host([checked]) .header{background-color:hsl(var(--primary-container));color:hsl(var(--on-primary-container));border-color:hsl(var(--primary));box-shadow:0px 1px 2px 0px rgba(0,0,0,.3),0px 2px 6px 2px rgba(0,0,0,.15)}:host([checked]) .header:after{transform:rotate(180deg)}:host([checked]) .header:before{background:hsl(var(--on-primary-container))}:host([checked]) .content{opacity:1;visibility:visible;max-height:var(--tk-accordion-max-height, 1000px);overflow-y:scroll;padding:12px 16px;transform:translateY(0);transition:max-height .28s var(--transition-timing-function-deceleration-curve, cubic-bezier(0, 0, 0.2, 1)),opacity .28s var(--transition-timing-function-deceleration-curve, cubic-bezier(0, 0, 0.2, 1)),transform .28s var(--transition-timing-function-deceleration-curve, cubic-bezier(0, 0, 0.2, 1))}:host([pill]) .header{border-radius:9999px}@media(prefers-reduced-motion: reduce){:host .header:after{transition:none}:host .header:before{transition:none}:host .header{transition:none}:host .content{transition:none}}");
752
771
  ;// ./tinkiet/accordion/accordion.ts
753
772
  var accordion_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
754
773
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -772,6 +791,7 @@ let TkAccordion = class TkAccordion extends TkFocusableBox {
772
791
  }
773
792
  constructor() {
774
793
  super();
794
+ this.name = "";
775
795
  this.checked = false;
776
796
  this.rippleHeader = false;
777
797
  this.handleClick = this.handleClick.bind(this);
@@ -781,10 +801,14 @@ let TkAccordion = class TkAccordion extends TkFocusableBox {
781
801
  <tk-box margin="small">
782
802
  <tk-box
783
803
  @click=${this.handleClick}
804
+ @keydown=${this.onKeyDown}
784
805
  ?ripple=${this.rippleHeader}
785
806
  class="header"
786
807
  direction="row"
787
808
  align-items="center"
809
+ role="button"
810
+ tabindex="0"
811
+ aria-expanded=${this.checked}
788
812
  >
789
813
  <tk-box class="before">
790
814
  <slot name="before"></slot>
@@ -812,16 +836,21 @@ let TkAccordion = class TkAccordion extends TkFocusableBox {
812
836
  }
813
837
  updated(changed) {
814
838
  super.updated(changed);
815
- this.syncInput();
839
+ if (changed.has("checked") || changed.has("name") || changed.has("disabled"))
840
+ this.syncInput();
816
841
  }
817
842
  onKeyDown(e) {
843
+ if (this.disabled)
844
+ return;
818
845
  if (e.code === "Space" || e.code === "Enter") {
819
846
  e.preventDefault();
820
847
  e.stopPropagation();
821
- this.click();
848
+ this.handleClick();
822
849
  }
823
850
  }
824
851
  handleClick() {
852
+ if (this.disabled)
853
+ return;
825
854
  this.checked = !this.checked;
826
855
  if (this.checked && this.name)
827
856
  this.getRootNode()
@@ -1012,6 +1041,61 @@ let TkBox = class TkBox extends external_lit_.LitElement {
1012
1041
  * Activate ripple
1013
1042
  */
1014
1043
  this.ripple = false;
1044
+ this.showRipple = (event) => {
1045
+ const x = event.clientX;
1046
+ const y = event.clientY;
1047
+ const { offsetWidth, offsetHeight } = this;
1048
+ const container = document.createElement("span");
1049
+ container.classList.add("ripple", "open");
1050
+ const element = document.createElement("span");
1051
+ container.appendChild(element);
1052
+ this.shadowRoot.appendChild(container);
1053
+ const rect = this.getBoundingClientRect();
1054
+ const diameter = Math.max(offsetWidth, offsetWidth) * 2;
1055
+ element.style.width = element.style.height = diameter + "px";
1056
+ element.style.left = x - rect.left - diameter / 2 + "px";
1057
+ element.style.top = y - rect.top - diameter / 2 + "px";
1058
+ const inAnimation = element.animate({
1059
+ transform: [`scale(0)`, `scale(1)`]
1060
+ }, {
1061
+ easing: "ease-out",
1062
+ fill: "both",
1063
+ duration: 500
1064
+ });
1065
+ inAnimation.onfinish = () => {
1066
+ container.classList.remove("open");
1067
+ const outAnimation = element.animate({
1068
+ opacity: ["0.5", "0"]
1069
+ }, {
1070
+ easing: "ease-in",
1071
+ fill: "both",
1072
+ duration: 300
1073
+ });
1074
+ outAnimation.onfinish = () => {
1075
+ requestAnimationFrame(() => {
1076
+ container.remove();
1077
+ });
1078
+ };
1079
+ };
1080
+ };
1081
+ this.hideRipple = (event) => {
1082
+ var _a;
1083
+ (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".ripple:not([open])").forEach(container => {
1084
+ const element = container.querySelector("span");
1085
+ const outAnimation = element.animate({
1086
+ opacity: ["0.5", "0"]
1087
+ }, {
1088
+ easing: "ease-out",
1089
+ fill: "both",
1090
+ duration: 300
1091
+ });
1092
+ outAnimation.onfinish = () => {
1093
+ requestAnimationFrame(() => {
1094
+ container.remove();
1095
+ });
1096
+ };
1097
+ });
1098
+ };
1015
1099
  }
1016
1100
  static get styles() {
1017
1101
  return [
@@ -1027,14 +1111,14 @@ let TkBox = class TkBox extends external_lit_.LitElement {
1027
1111
  }
1028
1112
  connectedCallback() {
1029
1113
  if (this.ripple) {
1030
- this.addEventListener("mousedown", this.showRipple.bind(this), { passive: true });
1031
- this.addEventListener("mouseup", this.hideRipple.bind(this), { passive: true });
1114
+ this.addEventListener("mousedown", this.showRipple, { passive: true });
1115
+ this.addEventListener("mouseup", this.hideRipple, { passive: true });
1032
1116
  }
1033
1117
  super.connectedCallback();
1034
1118
  }
1035
1119
  disconnectedCallback() {
1036
1120
  this.removeEventListener("mousedown", this.showRipple);
1037
- this.addEventListener("mouseup", this.hideRipple);
1121
+ this.removeEventListener("mouseup", this.hideRipple);
1038
1122
  super.disconnectedCallback();
1039
1123
  }
1040
1124
  updated(props) {
@@ -1044,61 +1128,6 @@ let TkBox = class TkBox extends external_lit_.LitElement {
1044
1128
  // this.style.setProperty("color", this.color.toString());
1045
1129
  super.updated(props);
1046
1130
  }
1047
- showRipple(event) {
1048
- const x = event.clientX;
1049
- const y = event.clientY;
1050
- const { offsetWidth, offsetHeight } = this;
1051
- const container = document.createElement("span");
1052
- container.classList.add("ripple", "open");
1053
- const element = document.createElement("span");
1054
- container.appendChild(element);
1055
- this.shadowRoot.appendChild(container);
1056
- const rect = this.getBoundingClientRect();
1057
- const diameter = Math.max(offsetWidth, offsetWidth) * 2;
1058
- element.style.width = element.style.height = diameter + "px";
1059
- element.style.left = x - rect.left - diameter / 2 + "px";
1060
- element.style.top = y - rect.top - diameter / 2 + "px";
1061
- const inAnimation = element.animate({
1062
- transform: [`scale(0)`, `scale(1)`]
1063
- }, {
1064
- easing: "ease-out",
1065
- fill: "both",
1066
- duration: 500
1067
- });
1068
- inAnimation.onfinish = () => {
1069
- container.classList.remove("open");
1070
- const outAnimation = element.animate({
1071
- opacity: ["0.5", "0"]
1072
- }, {
1073
- easing: "ease-in",
1074
- fill: "both",
1075
- duration: 300
1076
- });
1077
- outAnimation.onfinish = () => {
1078
- requestAnimationFrame(() => {
1079
- container.remove();
1080
- });
1081
- };
1082
- };
1083
- }
1084
- hideRipple(event) {
1085
- var _a;
1086
- (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".ripple:not([open])").forEach(container => {
1087
- const element = container.querySelector("span");
1088
- const outAnimation = element.animate({
1089
- opacity: ["0.5", "0"]
1090
- }, {
1091
- easing: "ease-out",
1092
- fill: "both",
1093
- duration: 300
1094
- });
1095
- outAnimation.onfinish = () => {
1096
- requestAnimationFrame(() => {
1097
- container.remove();
1098
- });
1099
- };
1100
- });
1101
- }
1102
1131
  };
1103
1132
  __decorate([
1104
1133
  (0,decorators_js_.property)({ type: Boolean })
@@ -1159,6 +1188,8 @@ __webpack_require__.d(__webpack_exports__, {
1159
1188
  var external_lit_ = __webpack_require__(2927);
1160
1189
  // EXTERNAL MODULE: external "lit/decorators.js"
1161
1190
  var decorators_js_ = __webpack_require__(8899);
1191
+ // EXTERNAL MODULE: external "lit/directives/class-map.js"
1192
+ var class_map_js_ = __webpack_require__(4955);
1162
1193
  ;// ./tinkiet/chip/chip.scss
1163
1194
  /* harmony default export */ const chip = ("*{-webkit-tap-highlight-color:rgba(0,0,0,0);-webkit-tap-highlight-color:rgba(0,0,0,0);box-sizing:border-box}.chip{display:inline-flex;align-items:center;border-radius:10px;padding:3px 10px;background:hsl(var(--surface-container-highest));border:1px solid hsl(var(--outline-variant));font-size:13px;height:30px;gap:6px;line-height:1;cursor:pointer}.chip.disabled{opacity:.4;pointer-events:none}.chip .leading{display:inline-flex;align-items:center}.chip .leading slot::slotted(*){display:inline-flex;align-items:center}.chip .label{white-space:nowrap;display:inline-flex;align-items:center;line-height:1}.chip .trailing{display:inline-flex;align-items:center}.chip .trailing slot::slotted(*){display:inline-flex;align-items:center}.chip .trailing .remove{background:none;border:none;cursor:pointer;font-size:13px;line-height:1;opacity:.7}.chip .trailing .remove:hover{opacity:1}");
1164
1195
  ;// ./tinkiet/chip/chip.ts
@@ -1171,6 +1202,7 @@ var __decorate = (undefined && undefined.__decorate) || function (decorators, ta
1171
1202
 
1172
1203
 
1173
1204
 
1205
+
1174
1206
  /**
1175
1207
  * Material-style Chip component.
1176
1208
  *
@@ -1188,14 +1220,21 @@ let TkChip = class TkChip extends external_lit_.LitElement {
1188
1220
  super(...arguments);
1189
1221
  this.disabled = false;
1190
1222
  this.removable = false;
1191
- }
1192
- onRemove() {
1193
- this.dispatchEvent(new CustomEvent("remove", { bubbles: true, composed: true }));
1223
+ this.onRemove = (event) => {
1224
+ event.stopPropagation();
1225
+ if (this.disabled)
1226
+ return;
1227
+ this.dispatchEvent(new CustomEvent("remove", { bubbles: true, composed: true }));
1228
+ };
1194
1229
  }
1195
1230
  render() {
1231
+ const classes = {
1232
+ chip: true,
1233
+ disabled: this.disabled
1234
+ };
1196
1235
  return (0,external_lit_.html) `
1197
- <div class="chip ${this.disabled ? "disabled" : ""}">
1198
-
1236
+ <div class=${(0,class_map_js_.classMap)(classes)} aria-disabled=${this.disabled ? "true" : "false"}>
1237
+
1199
1238
  <!-- 3. LEADING ICON (optional) -->
1200
1239
  <span class="leading">
1201
1240
  <slot name="leading"></slot>
@@ -1210,7 +1249,7 @@ let TkChip = class TkChip extends external_lit_.LitElement {
1210
1249
  <span class="trailing">
1211
1250
  <slot name="trailing">
1212
1251
  ${this.removable
1213
- ? (0,external_lit_.html) `<button class="remove" @click=${this.onRemove}>✕</button>`
1252
+ ? (0,external_lit_.html) `<button class="remove" type="button" ?disabled=${this.disabled} aria-label="Remove" @click=${this.onRemove}>✕</button>`
1214
1253
  : ""}
1215
1254
  </slot>
1216
1255
  </span>
@@ -1221,10 +1260,10 @@ let TkChip = class TkChip extends external_lit_.LitElement {
1221
1260
  };
1222
1261
  TkChip.styles = (0,external_lit_.css) `${(0,external_lit_.unsafeCSS)(chip)}`;
1223
1262
  __decorate([
1224
- (0,decorators_js_.property)({ type: Boolean })
1263
+ (0,decorators_js_.property)({ type: Boolean, reflect: true })
1225
1264
  ], TkChip.prototype, "disabled", void 0);
1226
1265
  __decorate([
1227
- (0,decorators_js_.property)({ type: Boolean })
1266
+ (0,decorators_js_.property)({ type: Boolean, reflect: true })
1228
1267
  ], TkChip.prototype, "removable", void 0);
1229
1268
  TkChip = __decorate([
1230
1269
  (0,decorators_js_.customElement)("tk-chip")
@@ -1373,6 +1412,25 @@ let TkRadio = class TkRadio extends external_lit_.LitElement {
1373
1412
  this.required = false;
1374
1413
  this.disabled = false;
1375
1414
  this.readonly = false;
1415
+ this.onKeyDown = (e) => {
1416
+ if (this.disabled)
1417
+ return;
1418
+ if (e.code === "Space" || e.code === "Enter") {
1419
+ e.preventDefault();
1420
+ e.stopPropagation();
1421
+ this.click();
1422
+ }
1423
+ };
1424
+ this.handleClick = () => {
1425
+ if (this.disabled)
1426
+ return;
1427
+ this.checked = !this.checked;
1428
+ if (this.checked && this.name)
1429
+ this.getRootNode()
1430
+ .querySelectorAll(`tk-radio[name="${this.name}"]`)
1431
+ .forEach(el => (el != this ? (el.checked = false) : null));
1432
+ setTimeout(() => this.dispatchEvent(new Event("change", { bubbles: true, composed: true })));
1433
+ };
1376
1434
  }
1377
1435
  render() {
1378
1436
  return (0,external_lit_.html) `
@@ -1402,8 +1460,8 @@ let TkRadio = class TkRadio extends external_lit_.LitElement {
1402
1460
  }
1403
1461
  connectedCallback() {
1404
1462
  super.connectedCallback();
1405
- this.addEventListener("click", this.handleClick.bind(this));
1406
- this.addEventListener("keydown", this.onKeyDown.bind(this));
1463
+ this.addEventListener("click", this.handleClick);
1464
+ this.addEventListener("keydown", this.onKeyDown);
1407
1465
  }
1408
1466
  disconnectedCallback() {
1409
1467
  super.disconnectedCallback();
@@ -1413,25 +1471,6 @@ let TkRadio = class TkRadio extends external_lit_.LitElement {
1413
1471
  firstUpdated() {
1414
1472
  this.appendChild(this.$input);
1415
1473
  }
1416
- onKeyDown(e) {
1417
- if (this.disabled)
1418
- return;
1419
- if (e.code === "Space" || e.code === "Enter") {
1420
- e.preventDefault();
1421
- e.stopPropagation();
1422
- this.click();
1423
- }
1424
- }
1425
- handleClick() {
1426
- if (this.disabled)
1427
- return;
1428
- this.checked = !this.checked;
1429
- if (this.checked && this.name)
1430
- this.getRootNode()
1431
- .querySelectorAll(`tk-radio[name="${this.name}"]`)
1432
- .forEach(el => (el != this ? (el.checked = false) : null));
1433
- setTimeout(() => this.dispatchEvent(new Event("change", { bubbles: true, composed: true })));
1434
- }
1435
1474
  };
1436
1475
  TkRadio.styles = (0,external_lit_.css) `
1437
1476
  ${(0,external_lit_.unsafeCSS)(radio_radio)}
@@ -2009,7 +2048,7 @@ var external_lit_ = __webpack_require__(2927);
2009
2048
  // EXTERNAL MODULE: external "lit/decorators.js"
2010
2049
  var decorators_js_ = __webpack_require__(8899);
2011
2050
  ;// ./tinkiet/drawer/drawer.scss
2012
- /* harmony default export */ const drawer = ("*{-webkit-tap-highlight-color:rgba(0,0,0,0);-webkit-tap-highlight-color:rgba(0,0,0,0);box-sizing:border-box}:host{display:block;height:100%;width:100%;position:relative;overflow:hidden;background-color:hsl(var(--surface))}.drawer{display:grid;grid-template-columns:var(--drawer-width, 256px) 10px;grid-template-rows:auto 1fr auto;grid-template-areas:\"header swipe\" \"content swipe\" \"footer swipe\";position:absolute;top:0;bottom:0;transform:translateX(calc(-100% + 10px));transition:transform cubic-bezier(0.4, 0, 0.2, 1) var(--transition-duration-medium, 180ms);will-change:transform;touch-action:pan-y;z-index:var(--drawer-z-index, 200);background-color:hsl(var(--surface))}.drawer .drawer-header{grid-area:header}.drawer .drawer-content{grid-area:content;overflow:auto}.drawer .drawer-footer{grid-area:footer}.drawer .drawer-swipe{grid-area:swipe;background-color:rgba(0,0,0,0)}:host([right]) .drawer{right:0;transform:translateX(calc(100% + 10px))}.overlay{position:absolute;top:0;left:0;right:0;bottom:0;z-index:var(--drawer-overlay-z-index, 200);background-color:rgba(0,0,0,.5);display:none}.container{transition:padding cubic-bezier(0.4, 0, 0.2, 1) var(--transition-duration-slow, 250ms);overflow:auto;height:100%}:host([open]) .drawer{transform:none}:host([open]) .container{padding-left:var(--drawer-width, 256px)}:host([open][over]) .drawer{background-color:hsl(var(--surface-container-low));box-shadow:0px 1px 2px 0px rgba(0, 0, 0, 0.3), 0px 1px 3px 1px rgba(0, 0, 0, 0.15)}:host([open][over]) .container{padding-left:0}:host([open][over]) .overlay{display:block}@media(max-width: var(--drawer-trigger-width, 400px)){:host([open]) .container{padding-left:0}:host([open]) .overlay{display:block}}");
2051
+ /* harmony default export */ const drawer = ("*{-webkit-tap-highlight-color:rgba(0,0,0,0);-webkit-tap-highlight-color:rgba(0,0,0,0);box-sizing:border-box}:host{display:block;height:100%;width:100%;position:relative;overflow:hidden;background-color:hsl(var(--surface))}.drawer{display:grid;grid-template-columns:var(--drawer-width, 256px) 10px;grid-template-rows:auto 1fr auto;grid-template-areas:\"header swipe\" \"content swipe\" \"footer swipe\";position:absolute;top:0;bottom:0;transform:translateX(calc(-100% + 10px));transition:transform cubic-bezier(0.4, 0, 0.2, 1) var(--transition-duration-medium, 180ms);will-change:transform;touch-action:pan-y;z-index:var(--drawer-z-index, 200);background-color:hsl(var(--surface))}.drawer .drawer-header{grid-area:header}.drawer .drawer-content{grid-area:content;overflow:auto;position:relative;transition:opacity var(--transition-duration-medium, 180ms) ease}.drawer .drawer-content::before,.drawer .drawer-content::after{content:\"\";position:sticky;display:block;height:14px;pointer-events:none;opacity:0;transition:opacity var(--transition-duration-medium, 180ms) ease;left:0;right:0;width:100%;z-index:1}.drawer .drawer-content::before{top:0;margin-top:-14px;background:linear-gradient(180deg, rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0))}.drawer .drawer-content::after{bottom:0;margin-bottom:-14px;background:linear-gradient(0deg, rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0))}.drawer .drawer-content.has-top-shadow::before{opacity:1}.drawer .drawer-content.has-bottom-shadow::after{opacity:1}.drawer .drawer-footer{grid-area:footer}.drawer .drawer-swipe{grid-area:swipe;background-color:rgba(0,0,0,0)}:host([right]) .drawer{right:0;transform:translateX(calc(100% + 10px))}.overlay{position:absolute;top:0;left:0;right:0;bottom:0;z-index:var(--drawer-overlay-z-index, 200);background-color:rgba(0,0,0,.5);display:none}.container{transition:padding cubic-bezier(0.4, 0, 0.2, 1) var(--transition-duration-slow, 250ms);overflow:auto;height:100%}:host([open]) .drawer{transform:none}:host([open]) .container{padding-left:var(--drawer-width, 256px)}:host([open][over]) .drawer{background-color:hsl(var(--surface-container-low));box-shadow:0px 1px 2px 0px rgba(0, 0, 0, 0.3), 0px 1px 3px 1px rgba(0, 0, 0, 0.15)}:host([open][over]) .container{padding-left:0}:host([open][over]) .overlay{display:block}@media(max-width: var(--drawer-trigger-width, 400px)){:host([open]) .container{padding-left:0}:host([open]) .overlay{display:block}}");
2013
2052
  ;// ./tinkiet/drawer/drawer.ts
2014
2053
  var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
2015
2054
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -2020,43 +2059,47 @@ var __decorate = (undefined && undefined.__decorate) || function (decorators, ta
2020
2059
 
2021
2060
 
2022
2061
 
2023
-
2024
2062
  let TkDrawer = class TkDrawer extends external_lit_.LitElement {
2025
2063
  constructor() {
2026
2064
  super(...arguments);
2027
- this._open = false;
2065
+ this.open = false;
2028
2066
  this.over = false;
2029
2067
  this.right = false;
2030
2068
  this.swipeable = false;
2069
+ this.contentScrolled = false;
2070
+ this.contentHasBottomShadow = false;
2071
+ this.overMediaQueryListener = (e) => {
2072
+ e.matches ? this.setAttribute("over", "") : this.removeAttribute("over");
2073
+ };
2074
+ this.handleOverlayClick = () => {
2075
+ this.hide();
2076
+ };
2077
+ this.handleContentScroll = () => {
2078
+ if (!this.$content)
2079
+ return;
2080
+ const { scrollTop, scrollHeight, clientHeight } = this.$content;
2081
+ this.contentScrolled = scrollTop > 0;
2082
+ const atBottom = Math.ceil(scrollTop + clientHeight) >= scrollHeight;
2083
+ this.contentHasBottomShadow = !atBottom && scrollHeight > clientHeight;
2084
+ };
2031
2085
  this.swipeX = 0;
2032
2086
  this.swipeY = 0;
2033
2087
  this.isHorizontalSwipe = false;
2034
2088
  }
2035
- set open(value) {
2036
- if (value === this._open)
2037
- return;
2038
- const oldValue = this._open;
2039
- this._open = value;
2040
- this.requestUpdate("open", oldValue);
2041
- if (this._open)
2042
- this.dispatchEvent(new Event("did-show"));
2043
- if (!this._open)
2044
- this.dispatchEvent(new Event("did-close"));
2045
- }
2046
- get open() {
2047
- return this._open;
2048
- }
2049
2089
  render() {
2050
2090
  return (0,external_lit_.html) `
2051
2091
  <div class="container">
2052
2092
  <slot name="drawer-container"></slot>
2053
2093
  </div>
2054
- <div class="overlay" @click=${() => (this.open = false)}></div>
2094
+ <div class="overlay" @click=${this.handleOverlayClick}></div>
2055
2095
  <div class="drawer" @touchstart=${this.touchStart} @touchmove=${this.touchMove} @touchend=${this.touchEnd}>
2056
2096
  <div class="drawer-header">
2057
2097
  <slot name="drawer-header"></slot>
2058
2098
  </div>
2059
- <div class="drawer-content">
2099
+ <div
2100
+ class="drawer-content ${this.contentScrolled ? "has-top-shadow" : ""} ${this.contentHasBottomShadow ? "has-bottom-shadow" : ""}"
2101
+ @scroll=${this.handleContentScroll}
2102
+ >
2060
2103
  <slot name="drawer-content"></slot>
2061
2104
  </div>
2062
2105
  <div class="drawer-footer">
@@ -2067,28 +2110,39 @@ let TkDrawer = class TkDrawer extends external_lit_.LitElement {
2067
2110
 
2068
2111
  `;
2069
2112
  }
2113
+ firstUpdated() {
2114
+ if (this.overQuery)
2115
+ this.overMediaQuery();
2116
+ if (this.openQuery && window.matchMedia(this.openQuery).matches)
2117
+ this.show();
2118
+ this.handleContentScroll();
2119
+ }
2070
2120
  updated(props) {
2071
- if (props.has("overQuery"))
2121
+ super.updated(props);
2122
+ if (props.has("overQuery") && this.overQuery)
2072
2123
  this.overMediaQuery();
2073
- if (props.has("openQuery")) {
2074
- if (window.matchMedia(this.openQuery).matches)
2075
- this.show();
2076
- }
2077
- if (props.has("open") && this.swipeable) {
2078
- requestAnimationFrame(_ => {
2079
- this.$drawer.removeAttribute('style');
2080
- });
2124
+ if (props.has("openQuery") && this.openQuery && window.matchMedia(this.openQuery).matches)
2125
+ this.show();
2126
+ if (props.has("open")) {
2127
+ if (this.open) {
2128
+ this.dispatchEvent(new CustomEvent("did-show", { bubbles: true }));
2129
+ }
2130
+ else if (props.get("open") === true) {
2131
+ this.dispatchEvent(new CustomEvent("did-close", { bubbles: true }));
2132
+ }
2133
+ if (this.swipeable && this.$drawer) {
2134
+ requestAnimationFrame(() => {
2135
+ this.$drawer.removeAttribute("style");
2136
+ });
2137
+ }
2081
2138
  }
2082
2139
  }
2083
2140
  overMediaQuery() {
2084
2141
  if (this.mql)
2085
- this.mql.removeEventListener("change", this.overMediaQueryListener.bind(this));
2142
+ this.mql.removeEventListener("change", this.overMediaQueryListener);
2086
2143
  this.mql = window.matchMedia(this.overQuery);
2087
2144
  this.mql.matches ? this.setAttribute("over", "") : this.removeAttribute("over");
2088
- this.mql.addEventListener("change", this.overMediaQueryListener.bind(this));
2089
- }
2090
- overMediaQueryListener(e) {
2091
- e.matches ? this.setAttribute("over", "") : this.removeAttribute("over");
2145
+ this.mql.addEventListener("change", this.overMediaQueryListener);
2092
2146
  }
2093
2147
  hideIfOver() {
2094
2148
  var _a;
@@ -2105,53 +2159,59 @@ let TkDrawer = class TkDrawer extends external_lit_.LitElement {
2105
2159
  this.open = !this.open;
2106
2160
  }
2107
2161
  touchStart(event) {
2108
- if (!this.swipeable)
2162
+ if (!this.swipeable || !this.$drawer)
2109
2163
  return;
2110
2164
  this.$drawer.style.transition = "transform 0ms ease";
2111
2165
  this.swipeX = event.touches[0].clientX;
2112
2166
  this.swipeY = event.touches[0].clientY;
2113
2167
  }
2114
2168
  touchMove(event) {
2115
- if (!this.swipeable)
2169
+ if (!this.swipeable || !this.$drawer)
2116
2170
  return;
2117
2171
  const deltaX = event.touches[0].clientX - this.swipeX;
2118
2172
  const deltaY = event.touches[0].clientY - this.swipeY;
2119
2173
  this.isHorizontalSwipe = Math.abs(deltaX) > Math.abs(deltaY);
2120
2174
  if (!this.isHorizontalSwipe)
2121
2175
  return;
2122
- var x = this.open ?
2123
- deltaX > 0 ? 0 : deltaX :
2124
- deltaX < 0 ? 0 : deltaX;
2125
- var transformString;
2126
- this.open ?
2127
- transformString = "translateX(" + x + "px)" :
2128
- transformString = `translateX(min(calc(-100% + 10px + ${x}px), 0px)`;
2129
- requestAnimationFrame(_ => {
2176
+ const x = this.open
2177
+ ? deltaX > 0 ? 0 : deltaX
2178
+ : deltaX < 0 ? 0 : deltaX;
2179
+ const transformString = this.open
2180
+ ? `translateX(${x}px)`
2181
+ : `translateX(min(calc(-100% + 10px + ${x}px), 0px))`;
2182
+ requestAnimationFrame(() => {
2183
+ if (!this.$drawer)
2184
+ return;
2130
2185
  this.$drawer.style.transform = transformString;
2131
2186
  });
2132
2187
  }
2133
2188
  touchEnd(event) {
2134
- if (!this.swipeable)
2189
+ if (!this.swipeable || !this.$drawer)
2135
2190
  return;
2136
- requestAnimationFrame(_ => {
2137
- this.$drawer.removeAttribute('style');
2191
+ requestAnimationFrame(() => {
2192
+ var _a;
2193
+ (_a = this.$drawer) === null || _a === void 0 ? void 0 : _a.removeAttribute("style");
2138
2194
  });
2139
2195
  const deltaX = event.changedTouches[0].clientX - this.swipeX;
2140
2196
  if (this.isHorizontalSwipe && this.open)
2141
2197
  this.open = -50 > deltaX ? false : true;
2142
2198
  else if (this.isHorizontalSwipe && !this.open) {
2143
- console.log("bbb", deltaX, 50 < Math.abs(deltaX) ? true : false);
2144
2199
  this.open = 50 < deltaX ? true : false;
2145
2200
  }
2146
2201
  this.isHorizontalSwipe = false;
2147
2202
  }
2203
+ disconnectedCallback() {
2204
+ if (this.mql)
2205
+ this.mql.removeEventListener("change", this.overMediaQueryListener);
2206
+ super.disconnectedCallback();
2207
+ }
2148
2208
  };
2149
2209
  TkDrawer.styles = (0,external_lit_.css) `
2150
2210
  ${(0,external_lit_.unsafeCSS)(drawer)}
2151
2211
  `;
2152
2212
  __decorate([
2153
2213
  (0,decorators_js_.property)({ type: Boolean, reflect: true })
2154
- ], TkDrawer.prototype, "open", null);
2214
+ ], TkDrawer.prototype, "open", void 0);
2155
2215
  __decorate([
2156
2216
  (0,decorators_js_.property)({ type: Boolean, reflect: true })
2157
2217
  ], TkDrawer.prototype, "over", void 0);
@@ -2170,6 +2230,15 @@ __decorate([
2170
2230
  __decorate([
2171
2231
  (0,decorators_js_.query)("div.drawer")
2172
2232
  ], TkDrawer.prototype, "$drawer", void 0);
2233
+ __decorate([
2234
+ (0,decorators_js_.query)("div.drawer-content")
2235
+ ], TkDrawer.prototype, "$content", void 0);
2236
+ __decorate([
2237
+ (0,decorators_js_.state)()
2238
+ ], TkDrawer.prototype, "contentScrolled", void 0);
2239
+ __decorate([
2240
+ (0,decorators_js_.state)()
2241
+ ], TkDrawer.prototype, "contentHasBottomShadow", void 0);
2173
2242
  __decorate([
2174
2243
  (0,decorators_js_.eventOptions)({ passive: true })
2175
2244
  ], TkDrawer.prototype, "touchStart", null);
@@ -2318,7 +2387,7 @@ var box = __webpack_require__(3433);
2318
2387
  // EXTERNAL MODULE: ./tinkiet/utils/unique.ts
2319
2388
  var unique = __webpack_require__(3770);
2320
2389
  ;// ./tinkiet/button/button.scss
2321
- /* 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))}");
2390
+ /* 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))}");
2322
2391
  ;// ./tinkiet/button/button.ts
2323
2392
  var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
2324
2393
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -2356,6 +2425,33 @@ let TkButton = class TkButton extends box/* TkBox */.P {
2356
2425
  this.disabled = false;
2357
2426
  this.fab = false;
2358
2427
  this.ripple = true;
2428
+ this.onKeyDown = (e) => {
2429
+ if (e.code === "Space" || e.code === "Enter") {
2430
+ e.preventDefault();
2431
+ e.stopPropagation();
2432
+ this.click();
2433
+ }
2434
+ };
2435
+ this.handleClick = (e) => {
2436
+ var _a;
2437
+ if (this.href && e.isTrusted) {
2438
+ e.stopPropagation();
2439
+ e.preventDefault();
2440
+ this.$ahref.click();
2441
+ }
2442
+ else if ((e.isTrusted && this.type == "submit") || this.type == "reset") {
2443
+ (_a = this.querySelector("button")) === null || _a === void 0 ? void 0 : _a.click();
2444
+ }
2445
+ };
2446
+ this.slotChanged = () => {
2447
+ this.toggleAttributeForSlot(this.$defaultSlot, "extended");
2448
+ };
2449
+ this.badgeInChanged = () => {
2450
+ this.toggleAttributeForSlot(this.$badgeInSlot, "has-badge-in");
2451
+ };
2452
+ this.badgeOutChanged = () => {
2453
+ this.toggleAttributeForSlot(this.$badgeOutSlot, "has-badge-out");
2454
+ };
2359
2455
  }
2360
2456
  static get styles() {
2361
2457
  return [
@@ -2365,6 +2461,24 @@ let TkButton = class TkButton extends box/* TkBox */.P {
2365
2461
  `
2366
2462
  ];
2367
2463
  }
2464
+ hasSlotContent(slot) {
2465
+ var _a;
2466
+ const nodes = (_a = slot === null || slot === void 0 ? void 0 : slot.assignedNodes({ flatten: true })) !== null && _a !== void 0 ? _a : [];
2467
+ return nodes.some(node => {
2468
+ var _a;
2469
+ if (node.nodeType === Node.TEXT_NODE)
2470
+ return !!((_a = node.textContent) === null || _a === void 0 ? void 0 : _a.trim());
2471
+ return node.nodeType !== Node.COMMENT_NODE;
2472
+ });
2473
+ }
2474
+ toggleAttributeForSlot(slot, attribute) {
2475
+ if (this.hasSlotContent(slot)) {
2476
+ this.setAttribute(attribute, "");
2477
+ }
2478
+ else {
2479
+ this.removeAttribute(attribute);
2480
+ }
2481
+ }
2368
2482
  render() {
2369
2483
  return (0,external_lit_.html) `
2370
2484
  ${this.iconPath
@@ -2373,8 +2487,14 @@ let TkButton = class TkButton extends box/* TkBox */.P {
2373
2487
  `
2374
2488
  : ""}
2375
2489
 
2376
- <div class="content ${this.iconPath ? "has-icon" : ""}" @slotchange=${this.slotChanged}>
2377
- <slot></slot>
2490
+ <div class="content ${this.iconPath ? "has-icon" : ""}">
2491
+ <slot @slotchange=${this.slotChanged}></slot>
2492
+ </div>
2493
+ <div class="badge-in">
2494
+ <slot name="badge-in" @slotchange=${this.badgeInChanged}></slot>
2495
+ </div>
2496
+ <div class="badge-out">
2497
+ <slot name="badge-out" @slotchange=${this.badgeOutChanged}></slot>
2378
2498
  </div>
2379
2499
 
2380
2500
  ${this.href
@@ -2387,7 +2507,8 @@ let TkButton = class TkButton extends box/* TkBox */.P {
2387
2507
  }
2388
2508
  connectedCallback() {
2389
2509
  super.connectedCallback();
2390
- this.addEventListener("click", this.handleClick.bind(this));
2510
+ this.addEventListener("click", this.handleClick);
2511
+ this.addEventListener("keydown", this.onKeyDown);
2391
2512
  }
2392
2513
  disconnectedCallback() {
2393
2514
  super.disconnectedCallback();
@@ -2398,38 +2519,12 @@ let TkButton = class TkButton extends box/* TkBox */.P {
2398
2519
  this.tabIndex = this.disabled ? -1 : 0;
2399
2520
  super.updated(props);
2400
2521
  }
2401
- onKeyDown(e) {
2402
- if (e.code === "Space" || e.code === "Enter") {
2403
- e.preventDefault();
2404
- e.stopPropagation();
2405
- this.click();
2406
- }
2407
- }
2408
2522
  firstUpdated() {
2409
2523
  if (this.type == "submit" || this.type == "reset")
2410
2524
  this.appendChild(this.$button);
2411
- }
2412
- handleClick(e) {
2413
- var _a;
2414
- if (this.href && e.isTrusted) {
2415
- e.stopPropagation();
2416
- e.preventDefault();
2417
- this.$ahref.click();
2418
- }
2419
- else if ((e.isTrusted && this.type == "submit") || this.type == "reset") {
2420
- (_a = this.querySelector("button")) === null || _a === void 0 ? void 0 : _a.click();
2421
- }
2422
- }
2423
- slotChanged() {
2424
- var _a;
2425
- const slot = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('slot');
2426
- const elements = slot === null || slot === void 0 ? void 0 : slot.assignedNodes({ flatten: true });
2427
- if (elements && elements.length > 0) {
2428
- this.setAttribute('extended', '');
2429
- }
2430
- else {
2431
- this.removeAttribute('extended');
2432
- }
2525
+ this.slotChanged();
2526
+ this.badgeInChanged();
2527
+ this.badgeOutChanged();
2433
2528
  }
2434
2529
  };
2435
2530
  __decorate([
@@ -2451,7 +2546,7 @@ __decorate([
2451
2546
  (0,decorators_js_.property)({ type: String })
2452
2547
  ], TkButton.prototype, "iconPath", void 0);
2453
2548
  __decorate([
2454
- (0,decorators_js_.property)()
2549
+ (0,decorators_js_.property)({ type: Boolean })
2455
2550
  ], TkButton.prototype, "ripple", void 0);
2456
2551
  __decorate([
2457
2552
  (0,decorators_js_.query)("#ahref")
@@ -2459,6 +2554,15 @@ __decorate([
2459
2554
  __decorate([
2460
2555
  (0,decorators_js_.query)("button")
2461
2556
  ], TkButton.prototype, "$button", void 0);
2557
+ __decorate([
2558
+ (0,decorators_js_.query)("slot:not([name])")
2559
+ ], TkButton.prototype, "$defaultSlot", void 0);
2560
+ __decorate([
2561
+ (0,decorators_js_.query)('slot[name="badge-in"]')
2562
+ ], TkButton.prototype, "$badgeInSlot", void 0);
2563
+ __decorate([
2564
+ (0,decorators_js_.query)('slot[name="badge-out"]')
2565
+ ], TkButton.prototype, "$badgeOutSlot", void 0);
2462
2566
  TkButton = __decorate([
2463
2567
  (0,decorators_js_.customElement)("tk-button")
2464
2568
  ], TkButton);
@@ -2509,6 +2613,21 @@ let TkSwitch = class TkSwitch extends external_lit_.LitElement {
2509
2613
  this.required = false;
2510
2614
  this.disabled = false;
2511
2615
  this.readonly = false;
2616
+ this.onKeyDown = (e) => {
2617
+ if (e.code === "Space" || e.code === "Enter") {
2618
+ e.preventDefault();
2619
+ e.stopPropagation();
2620
+ this.click();
2621
+ }
2622
+ };
2623
+ this.handleClick = () => {
2624
+ this.checked = !this.checked;
2625
+ if (this.checked && this.name)
2626
+ this.getRootNode()
2627
+ .querySelectorAll(`tk-radio[name="${this.name}"]`)
2628
+ .forEach(el => (el != this ? (el.checked = false) : null));
2629
+ setTimeout(() => this.dispatchEvent(new Event("change", { bubbles: true, composed: true })));
2630
+ };
2512
2631
  }
2513
2632
  render() {
2514
2633
  return (0,external_lit_.html) `
@@ -2538,8 +2657,8 @@ let TkSwitch = class TkSwitch extends external_lit_.LitElement {
2538
2657
  }
2539
2658
  connectedCallback() {
2540
2659
  super.connectedCallback();
2541
- this.addEventListener("click", this.handleClick.bind(this));
2542
- this.addEventListener("keydown", this.onKeyDown.bind(this));
2660
+ this.addEventListener("click", this.handleClick);
2661
+ this.addEventListener("keydown", this.onKeyDown);
2543
2662
  }
2544
2663
  disconnectedCallback() {
2545
2664
  super.disconnectedCallback();
@@ -2549,21 +2668,6 @@ let TkSwitch = class TkSwitch extends external_lit_.LitElement {
2549
2668
  firstUpdated() {
2550
2669
  this.appendChild(this.$input);
2551
2670
  }
2552
- onKeyDown(e) {
2553
- if (e.code === "Space" || e.code === "Enter") {
2554
- e.preventDefault();
2555
- e.stopPropagation();
2556
- this.click();
2557
- }
2558
- }
2559
- handleClick() {
2560
- this.checked = !this.checked;
2561
- if (this.checked && this.name)
2562
- this.getRootNode()
2563
- .querySelectorAll(`tk-radio[name="${this.name}"]`)
2564
- .forEach(el => (el != this ? (el.checked = false) : null));
2565
- setTimeout(() => this.dispatchEvent(new Event("change", { bubbles: true, composed: true })));
2566
- }
2567
2671
  };
2568
2672
  TkSwitch.styles = (0,external_lit_.css) `
2569
2673
  ${(0,external_lit_.unsafeCSS)(switch_switch)}
@@ -2981,8 +3085,13 @@ let TkTheme = class TkTheme extends external_lit_.LitElement {
2981
3085
  this.error = "#B3261E";
2982
3086
  this.neutral = "#5E5F5C";
2983
3087
  this.neutralVariant = "#5c6057";
2984
- this.forceBody = false;
2985
3088
  this.inverted = false;
3089
+ this.primary_hsl = [];
3090
+ this.secondary_hsl = [];
3091
+ this.tertiary_hsl = [];
3092
+ this.error_hsl = [];
3093
+ this.neutral_hsl = [];
3094
+ this.neutral_variant_hsl = [];
2986
3095
  }
2987
3096
  render() {
2988
3097
  return (0,external_lit_.html) `
@@ -2992,6 +3101,17 @@ let TkTheme = class TkTheme extends external_lit_.LitElement {
2992
3101
  firstUpdated(_changedProperties) {
2993
3102
  this.setThemeColor();
2994
3103
  }
3104
+ updated(changedProps) {
3105
+ if (changedProps.has("primary") ||
3106
+ changedProps.has("secondary") ||
3107
+ changedProps.has("tertiary") ||
3108
+ changedProps.has("error") ||
3109
+ changedProps.has("neutral") ||
3110
+ changedProps.has("neutralVariant")) {
3111
+ this.setThemeColor();
3112
+ }
3113
+ super.updated(changedProps);
3114
+ }
2995
3115
  hexToHSL(hex) {
2996
3116
  const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i.exec(hex);
2997
3117
  if (result == null)
@@ -3028,8 +3148,11 @@ let TkTheme = class TkTheme extends external_lit_.LitElement {
3028
3148
  this.error_hsl = this.hexToHSL(this.error);
3029
3149
  this.neutral_hsl = this.hexToHSL(this.neutral);
3030
3150
  this.neutral_variant_hsl = this.hexToHSL(this.neutralVariant);
3031
- const style = document.createElement("style");
3032
- style.innerHTML = `
3151
+ if (!this.styleEl) {
3152
+ this.styleEl = document.createElement("style");
3153
+ document.body.appendChild(this.styleEl);
3154
+ }
3155
+ this.styleEl.innerHTML = `
3033
3156
  :root {
3034
3157
  --primary-h: ${this.primary_hsl[0]};
3035
3158
  --primary-s: ${this.primary_hsl[1]};
@@ -3051,7 +3174,6 @@ let TkTheme = class TkTheme extends external_lit_.LitElement {
3051
3174
  --neutral-variant-l: ${this.neutral_variant_hsl[2]};
3052
3175
  }
3053
3176
  `;
3054
- document.body.appendChild(style);
3055
3177
  }
3056
3178
  };
3057
3179
  TkTheme.styles = (0,external_lit_.css) `
@@ -3075,30 +3197,9 @@ __decorate([
3075
3197
  __decorate([
3076
3198
  (0,decorators_js_.property)()
3077
3199
  ], TkTheme.prototype, "neutralVariant", void 0);
3078
- __decorate([
3079
- (0,decorators_js_.property)({ type: Boolean, attribute: "force-body", reflect: true })
3080
- ], TkTheme.prototype, "forceBody", void 0);
3081
3200
  __decorate([
3082
3201
  (0,decorators_js_.property)({ type: Boolean, attribute: true, reflect: true })
3083
3202
  ], TkTheme.prototype, "inverted", void 0);
3084
- __decorate([
3085
- (0,decorators_js_.state)()
3086
- ], TkTheme.prototype, "primary_hsl", void 0);
3087
- __decorate([
3088
- (0,decorators_js_.state)()
3089
- ], TkTheme.prototype, "secondary_hsl", void 0);
3090
- __decorate([
3091
- (0,decorators_js_.state)()
3092
- ], TkTheme.prototype, "tertiary_hsl", void 0);
3093
- __decorate([
3094
- (0,decorators_js_.state)()
3095
- ], TkTheme.prototype, "error_hsl", void 0);
3096
- __decorate([
3097
- (0,decorators_js_.state)()
3098
- ], TkTheme.prototype, "neutral_hsl", void 0);
3099
- __decorate([
3100
- (0,decorators_js_.state)()
3101
- ], TkTheme.prototype, "neutral_variant_hsl", void 0);
3102
3203
  TkTheme = __decorate([
3103
3204
  (0,decorators_js_.customElement)("tk-theme")
3104
3205
  ], TkTheme);
@@ -3172,29 +3273,43 @@ let TkIcon = class TkIcon extends box/* TkBox */.P {
3172
3273
  `;
3173
3274
  }
3174
3275
  updated(props) {
3175
- if (props.has("name") && this.name)
3276
+ if ((props.has("name") || props.has("library")) && this.name && !this.path)
3176
3277
  this.loadIcon();
3177
3278
  }
3178
3279
  loadIcon() {
3179
3280
  return __awaiter(this, void 0, void 0, function* () {
3281
+ if (!this.name || this.path) {
3282
+ this.svg = "";
3283
+ return;
3284
+ }
3285
+ const name = this.name;
3286
+ const library = this.library;
3180
3287
  const resolver = this.library
3181
3288
  ? document.querySelector(`tk-icons[library=${this.library}]`)
3182
3289
  : document.querySelector("tk-icons");
3183
- if (resolver) {
3184
- this.svg = yield fetch(resolver.resolve(this.name))
3185
- .then(response => {
3186
- return response.blob().then(blob => {
3187
- return {
3188
- contentType: response.headers.get("Content-Type"),
3189
- raw: blob
3190
- };
3191
- });
3192
- })
3193
- .then(data => {
3194
- if (data.contentType && /svg/.test(data.contentType))
3195
- return data.raw.text();
3196
- return "";
3197
- });
3290
+ if (!resolver) {
3291
+ this.svg = "";
3292
+ return;
3293
+ }
3294
+ try {
3295
+ const response = yield fetch(resolver.resolve(name));
3296
+ if (!response.ok) {
3297
+ this.svg = "";
3298
+ return;
3299
+ }
3300
+ const contentType = response.headers.get("Content-Type") || "";
3301
+ if (!/svg/i.test(contentType)) {
3302
+ this.svg = "";
3303
+ return;
3304
+ }
3305
+ const svg = yield response.text();
3306
+ // Ensure the props are still current to avoid race conditions
3307
+ if (name === this.name && library === this.library && !this.path) {
3308
+ this.svg = svg;
3309
+ }
3310
+ }
3311
+ catch (_e) {
3312
+ this.svg = "";
3198
3313
  }
3199
3314
  });
3200
3315
  }
@@ -3209,7 +3324,7 @@ __decorate([
3209
3324
  (0,decorators_js_.property)()
3210
3325
  ], TkIcon.prototype, "path", void 0);
3211
3326
  __decorate([
3212
- (0,decorators_js_.property)()
3327
+ (0,decorators_js_.state)()
3213
3328
  ], TkIcon.prototype, "svg", void 0);
3214
3329
  TkIcon = __decorate([
3215
3330
  (0,decorators_js_.customElement)("tk-icon")
@@ -3561,24 +3676,44 @@ let TkDialog = class TkDialog extends external_lit_.LitElement {
3561
3676
  this.modal = false;
3562
3677
  this.open = false;
3563
3678
  this.blurOverlay = false;
3679
+ this.handleKeyDown = (event) => {
3680
+ if (event.key === "Escape" && this.open && !this.modal)
3681
+ this.hide();
3682
+ };
3683
+ this.onOverlayClick = () => {
3684
+ if (!this.modal)
3685
+ this.hide();
3686
+ };
3564
3687
  }
3565
3688
  render() {
3566
3689
  return (0,external_lit_.html) `
3567
3690
  ${this.open
3568
3691
  ? (0,external_lit_.html) `
3569
- <div class="overlay ${this.blurOverlay ? "blur" : ""}" @click=${() => (this.modal ? null : this.hide())}></div>
3570
- <div class="container">
3692
+ <div class="overlay ${this.blurOverlay ? "blur" : ""}" @click=${this.onOverlayClick}></div>
3693
+ <div class="container" role="dialog" aria-modal=${this.modal ? "true" : "false"}>
3571
3694
  <slot></slot>
3572
3695
  </div>
3573
3696
  `
3574
- : ""}
3697
+ : external_lit_.nothing}
3575
3698
  `;
3576
3699
  }
3577
- updated(_changedProperties) {
3578
- if (_changedProperties.has("open") && this.open)
3579
- this.dispatchEvent(new Event("did-show"));
3580
- if (_changedProperties.has("open") && _changedProperties.get("open") == true && !this.open)
3581
- this.dispatchEvent(new Event("did-close"));
3700
+ updated(changedProps) {
3701
+ if (changedProps.has("open")) {
3702
+ if (this.open) {
3703
+ this.dispatchEvent(new CustomEvent("did-show", { bubbles: true }));
3704
+ }
3705
+ else if (changedProps.get("open") === true) {
3706
+ this.dispatchEvent(new CustomEvent("did-close", { bubbles: true }));
3707
+ }
3708
+ }
3709
+ }
3710
+ connectedCallback() {
3711
+ super.connectedCallback();
3712
+ window.addEventListener("keydown", this.handleKeyDown);
3713
+ }
3714
+ disconnectedCallback() {
3715
+ window.removeEventListener("keydown", this.handleKeyDown);
3716
+ super.disconnectedCallback();
3582
3717
  }
3583
3718
  show() {
3584
3719
  this.open = true;