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.
@@ -49,14 +49,14 @@ class TkFocusableBox extends box_box/* TkBox */.P {
49
49
  }
50
50
  }
51
51
  __decorate([
52
- (0,decorators_js_.property)({ type: Boolean })
52
+ (0,decorators_js_.property)({ type: String })
53
53
  ], TkFocusableBox.prototype, "_id", void 0);
54
54
  __decorate([
55
55
  (0,decorators_js_.property)({ type: Boolean })
56
56
  ], TkFocusableBox.prototype, "disabled", void 0);
57
57
 
58
58
  ;// ./tinkiet/accordion/accordion.scss
59
- /* 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}}");
59
+ /* 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}}");
60
60
  ;// ./tinkiet/accordion/accordion.ts
61
61
  var accordion_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
62
62
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -80,6 +80,7 @@ let TkAccordion = class TkAccordion extends TkFocusableBox {
80
80
  }
81
81
  constructor() {
82
82
  super();
83
+ this.name = "";
83
84
  this.checked = false;
84
85
  this.rippleHeader = false;
85
86
  this.handleClick = this.handleClick.bind(this);
@@ -89,10 +90,14 @@ let TkAccordion = class TkAccordion extends TkFocusableBox {
89
90
  <tk-box margin="small">
90
91
  <tk-box
91
92
  @click=${this.handleClick}
93
+ @keydown=${this.onKeyDown}
92
94
  ?ripple=${this.rippleHeader}
93
95
  class="header"
94
96
  direction="row"
95
97
  align-items="center"
98
+ role="button"
99
+ tabindex="0"
100
+ aria-expanded=${this.checked}
96
101
  >
97
102
  <tk-box class="before">
98
103
  <slot name="before"></slot>
@@ -120,16 +125,21 @@ let TkAccordion = class TkAccordion extends TkFocusableBox {
120
125
  }
121
126
  updated(changed) {
122
127
  super.updated(changed);
123
- this.syncInput();
128
+ if (changed.has("checked") || changed.has("name") || changed.has("disabled"))
129
+ this.syncInput();
124
130
  }
125
131
  onKeyDown(e) {
132
+ if (this.disabled)
133
+ return;
126
134
  if (e.code === "Space" || e.code === "Enter") {
127
135
  e.preventDefault();
128
136
  e.stopPropagation();
129
- this.click();
137
+ this.handleClick();
130
138
  }
131
139
  }
132
140
  handleClick() {
141
+ if (this.disabled)
142
+ return;
133
143
  this.checked = !this.checked;
134
144
  if (this.checked && this.name)
135
145
  this.getRootNode()
@@ -268,6 +278,61 @@ let TkBox = class TkBox extends external_lit_.LitElement {
268
278
  * Activate ripple
269
279
  */
270
280
  this.ripple = false;
281
+ this.showRipple = (event) => {
282
+ const x = event.clientX;
283
+ const y = event.clientY;
284
+ const { offsetWidth, offsetHeight } = this;
285
+ const container = document.createElement("span");
286
+ container.classList.add("ripple", "open");
287
+ const element = document.createElement("span");
288
+ container.appendChild(element);
289
+ this.shadowRoot.appendChild(container);
290
+ const rect = this.getBoundingClientRect();
291
+ const diameter = Math.max(offsetWidth, offsetWidth) * 2;
292
+ element.style.width = element.style.height = diameter + "px";
293
+ element.style.left = x - rect.left - diameter / 2 + "px";
294
+ element.style.top = y - rect.top - diameter / 2 + "px";
295
+ const inAnimation = element.animate({
296
+ transform: [`scale(0)`, `scale(1)`]
297
+ }, {
298
+ easing: "ease-out",
299
+ fill: "both",
300
+ duration: 500
301
+ });
302
+ inAnimation.onfinish = () => {
303
+ container.classList.remove("open");
304
+ const outAnimation = element.animate({
305
+ opacity: ["0.5", "0"]
306
+ }, {
307
+ easing: "ease-in",
308
+ fill: "both",
309
+ duration: 300
310
+ });
311
+ outAnimation.onfinish = () => {
312
+ requestAnimationFrame(() => {
313
+ container.remove();
314
+ });
315
+ };
316
+ };
317
+ };
318
+ this.hideRipple = (event) => {
319
+ var _a;
320
+ (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".ripple:not([open])").forEach(container => {
321
+ const element = container.querySelector("span");
322
+ const outAnimation = element.animate({
323
+ opacity: ["0.5", "0"]
324
+ }, {
325
+ easing: "ease-out",
326
+ fill: "both",
327
+ duration: 300
328
+ });
329
+ outAnimation.onfinish = () => {
330
+ requestAnimationFrame(() => {
331
+ container.remove();
332
+ });
333
+ };
334
+ });
335
+ };
271
336
  }
272
337
  static get styles() {
273
338
  return [
@@ -283,14 +348,14 @@ let TkBox = class TkBox extends external_lit_.LitElement {
283
348
  }
284
349
  connectedCallback() {
285
350
  if (this.ripple) {
286
- this.addEventListener("mousedown", this.showRipple.bind(this), { passive: true });
287
- this.addEventListener("mouseup", this.hideRipple.bind(this), { passive: true });
351
+ this.addEventListener("mousedown", this.showRipple, { passive: true });
352
+ this.addEventListener("mouseup", this.hideRipple, { passive: true });
288
353
  }
289
354
  super.connectedCallback();
290
355
  }
291
356
  disconnectedCallback() {
292
357
  this.removeEventListener("mousedown", this.showRipple);
293
- this.addEventListener("mouseup", this.hideRipple);
358
+ this.removeEventListener("mouseup", this.hideRipple);
294
359
  super.disconnectedCallback();
295
360
  }
296
361
  updated(props) {
@@ -300,61 +365,6 @@ let TkBox = class TkBox extends external_lit_.LitElement {
300
365
  // this.style.setProperty("color", this.color.toString());
301
366
  super.updated(props);
302
367
  }
303
- showRipple(event) {
304
- const x = event.clientX;
305
- const y = event.clientY;
306
- const { offsetWidth, offsetHeight } = this;
307
- const container = document.createElement("span");
308
- container.classList.add("ripple", "open");
309
- const element = document.createElement("span");
310
- container.appendChild(element);
311
- this.shadowRoot.appendChild(container);
312
- const rect = this.getBoundingClientRect();
313
- const diameter = Math.max(offsetWidth, offsetWidth) * 2;
314
- element.style.width = element.style.height = diameter + "px";
315
- element.style.left = x - rect.left - diameter / 2 + "px";
316
- element.style.top = y - rect.top - diameter / 2 + "px";
317
- const inAnimation = element.animate({
318
- transform: [`scale(0)`, `scale(1)`]
319
- }, {
320
- easing: "ease-out",
321
- fill: "both",
322
- duration: 500
323
- });
324
- inAnimation.onfinish = () => {
325
- container.classList.remove("open");
326
- const outAnimation = element.animate({
327
- opacity: ["0.5", "0"]
328
- }, {
329
- easing: "ease-in",
330
- fill: "both",
331
- duration: 300
332
- });
333
- outAnimation.onfinish = () => {
334
- requestAnimationFrame(() => {
335
- container.remove();
336
- });
337
- };
338
- };
339
- }
340
- hideRipple(event) {
341
- var _a;
342
- (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".ripple:not([open])").forEach(container => {
343
- const element = container.querySelector("span");
344
- const outAnimation = element.animate({
345
- opacity: ["0.5", "0"]
346
- }, {
347
- easing: "ease-out",
348
- fill: "both",
349
- duration: 300
350
- });
351
- outAnimation.onfinish = () => {
352
- requestAnimationFrame(() => {
353
- container.remove();
354
- });
355
- };
356
- });
357
- }
358
368
  };
359
369
  __decorate([
360
370
  (0,decorators_js_.property)({ type: Boolean })
package/box/index.js CHANGED
@@ -106,6 +106,61 @@ let TkBox = class TkBox extends external_lit_.LitElement {
106
106
  * Activate ripple
107
107
  */
108
108
  this.ripple = false;
109
+ this.showRipple = (event) => {
110
+ const x = event.clientX;
111
+ const y = event.clientY;
112
+ const { offsetWidth, offsetHeight } = this;
113
+ const container = document.createElement("span");
114
+ container.classList.add("ripple", "open");
115
+ const element = document.createElement("span");
116
+ container.appendChild(element);
117
+ this.shadowRoot.appendChild(container);
118
+ const rect = this.getBoundingClientRect();
119
+ const diameter = Math.max(offsetWidth, offsetWidth) * 2;
120
+ element.style.width = element.style.height = diameter + "px";
121
+ element.style.left = x - rect.left - diameter / 2 + "px";
122
+ element.style.top = y - rect.top - diameter / 2 + "px";
123
+ const inAnimation = element.animate({
124
+ transform: [`scale(0)`, `scale(1)`]
125
+ }, {
126
+ easing: "ease-out",
127
+ fill: "both",
128
+ duration: 500
129
+ });
130
+ inAnimation.onfinish = () => {
131
+ container.classList.remove("open");
132
+ const outAnimation = element.animate({
133
+ opacity: ["0.5", "0"]
134
+ }, {
135
+ easing: "ease-in",
136
+ fill: "both",
137
+ duration: 300
138
+ });
139
+ outAnimation.onfinish = () => {
140
+ requestAnimationFrame(() => {
141
+ container.remove();
142
+ });
143
+ };
144
+ };
145
+ };
146
+ this.hideRipple = (event) => {
147
+ var _a;
148
+ (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".ripple:not([open])").forEach(container => {
149
+ const element = container.querySelector("span");
150
+ const outAnimation = element.animate({
151
+ opacity: ["0.5", "0"]
152
+ }, {
153
+ easing: "ease-out",
154
+ fill: "both",
155
+ duration: 300
156
+ });
157
+ outAnimation.onfinish = () => {
158
+ requestAnimationFrame(() => {
159
+ container.remove();
160
+ });
161
+ };
162
+ });
163
+ };
109
164
  }
110
165
  static get styles() {
111
166
  return [
@@ -121,14 +176,14 @@ let TkBox = class TkBox extends external_lit_.LitElement {
121
176
  }
122
177
  connectedCallback() {
123
178
  if (this.ripple) {
124
- this.addEventListener("mousedown", this.showRipple.bind(this), { passive: true });
125
- this.addEventListener("mouseup", this.hideRipple.bind(this), { passive: true });
179
+ this.addEventListener("mousedown", this.showRipple, { passive: true });
180
+ this.addEventListener("mouseup", this.hideRipple, { passive: true });
126
181
  }
127
182
  super.connectedCallback();
128
183
  }
129
184
  disconnectedCallback() {
130
185
  this.removeEventListener("mousedown", this.showRipple);
131
- this.addEventListener("mouseup", this.hideRipple);
186
+ this.removeEventListener("mouseup", this.hideRipple);
132
187
  super.disconnectedCallback();
133
188
  }
134
189
  updated(props) {
@@ -138,61 +193,6 @@ let TkBox = class TkBox extends external_lit_.LitElement {
138
193
  // this.style.setProperty("color", this.color.toString());
139
194
  super.updated(props);
140
195
  }
141
- showRipple(event) {
142
- const x = event.clientX;
143
- const y = event.clientY;
144
- const { offsetWidth, offsetHeight } = this;
145
- const container = document.createElement("span");
146
- container.classList.add("ripple", "open");
147
- const element = document.createElement("span");
148
- container.appendChild(element);
149
- this.shadowRoot.appendChild(container);
150
- const rect = this.getBoundingClientRect();
151
- const diameter = Math.max(offsetWidth, offsetWidth) * 2;
152
- element.style.width = element.style.height = diameter + "px";
153
- element.style.left = x - rect.left - diameter / 2 + "px";
154
- element.style.top = y - rect.top - diameter / 2 + "px";
155
- const inAnimation = element.animate({
156
- transform: [`scale(0)`, `scale(1)`]
157
- }, {
158
- easing: "ease-out",
159
- fill: "both",
160
- duration: 500
161
- });
162
- inAnimation.onfinish = () => {
163
- container.classList.remove("open");
164
- const outAnimation = element.animate({
165
- opacity: ["0.5", "0"]
166
- }, {
167
- easing: "ease-in",
168
- fill: "both",
169
- duration: 300
170
- });
171
- outAnimation.onfinish = () => {
172
- requestAnimationFrame(() => {
173
- container.remove();
174
- });
175
- };
176
- };
177
- }
178
- hideRipple(event) {
179
- var _a;
180
- (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".ripple:not([open])").forEach(container => {
181
- const element = container.querySelector("span");
182
- const outAnimation = element.animate({
183
- opacity: ["0.5", "0"]
184
- }, {
185
- easing: "ease-out",
186
- fill: "both",
187
- duration: 300
188
- });
189
- outAnimation.onfinish = () => {
190
- requestAnimationFrame(() => {
191
- container.remove();
192
- });
193
- };
194
- });
195
- }
196
196
  };
197
197
  __decorate([
198
198
  (0,decorators_js_.property)({ type: Boolean })
@@ -26,14 +26,21 @@ export declare class TkButton extends TkBox {
26
26
  ripple: boolean;
27
27
  protected $ahref: HTMLAnchorElement;
28
28
  protected $button: HTMLButtonElement;
29
+ protected $defaultSlot: HTMLSlotElement;
30
+ protected $badgeInSlot: HTMLSlotElement;
31
+ protected $badgeOutSlot: HTMLSlotElement;
32
+ private hasSlotContent;
33
+ private toggleAttributeForSlot;
29
34
  render(): import("lit").TemplateResult<1>;
30
35
  connectedCallback(): void;
31
36
  disconnectedCallback(): void;
32
37
  updated(props: any): void;
33
- protected onKeyDown(e: KeyboardEvent): void;
38
+ protected onKeyDown: (e: KeyboardEvent) => void;
34
39
  firstUpdated(): void;
35
- protected handleClick(e: Event): void;
36
- slotChanged(): void;
40
+ protected handleClick: (e: Event) => void;
41
+ slotChanged: () => void;
42
+ protected badgeInChanged: () => void;
43
+ protected badgeOutChanged: () => void;
37
44
  }
38
45
  declare global {
39
46
  interface HTMLElementTagNameMap {