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.
@@ -14,8 +14,8 @@ export declare class TkSwitch extends LitElement {
14
14
  connectedCallback(): void;
15
15
  disconnectedCallback(): void;
16
16
  firstUpdated(): void;
17
- protected onKeyDown(e: KeyboardEvent): void;
18
- protected handleClick(): void;
17
+ protected onKeyDown: (e: KeyboardEvent) => void;
18
+ protected handleClick: () => void;
19
19
  }
20
20
  declare global {
21
21
  interface HTMLElementTagNameMap {
package/theme/index.js CHANGED
@@ -47,8 +47,13 @@ let TkTheme = class TkTheme extends external_lit_.LitElement {
47
47
  this.error = "#B3261E";
48
48
  this.neutral = "#5E5F5C";
49
49
  this.neutralVariant = "#5c6057";
50
- this.forceBody = false;
51
50
  this.inverted = false;
51
+ this.primary_hsl = [];
52
+ this.secondary_hsl = [];
53
+ this.tertiary_hsl = [];
54
+ this.error_hsl = [];
55
+ this.neutral_hsl = [];
56
+ this.neutral_variant_hsl = [];
52
57
  }
53
58
  render() {
54
59
  return (0,external_lit_.html) `
@@ -58,6 +63,17 @@ let TkTheme = class TkTheme extends external_lit_.LitElement {
58
63
  firstUpdated(_changedProperties) {
59
64
  this.setThemeColor();
60
65
  }
66
+ updated(changedProps) {
67
+ if (changedProps.has("primary") ||
68
+ changedProps.has("secondary") ||
69
+ changedProps.has("tertiary") ||
70
+ changedProps.has("error") ||
71
+ changedProps.has("neutral") ||
72
+ changedProps.has("neutralVariant")) {
73
+ this.setThemeColor();
74
+ }
75
+ super.updated(changedProps);
76
+ }
61
77
  hexToHSL(hex) {
62
78
  const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i.exec(hex);
63
79
  if (result == null)
@@ -94,8 +110,11 @@ let TkTheme = class TkTheme extends external_lit_.LitElement {
94
110
  this.error_hsl = this.hexToHSL(this.error);
95
111
  this.neutral_hsl = this.hexToHSL(this.neutral);
96
112
  this.neutral_variant_hsl = this.hexToHSL(this.neutralVariant);
97
- const style = document.createElement("style");
98
- style.innerHTML = `
113
+ if (!this.styleEl) {
114
+ this.styleEl = document.createElement("style");
115
+ document.body.appendChild(this.styleEl);
116
+ }
117
+ this.styleEl.innerHTML = `
99
118
  :root {
100
119
  --primary-h: ${this.primary_hsl[0]};
101
120
  --primary-s: ${this.primary_hsl[1]};
@@ -117,7 +136,6 @@ let TkTheme = class TkTheme extends external_lit_.LitElement {
117
136
  --neutral-variant-l: ${this.neutral_variant_hsl[2]};
118
137
  }
119
138
  `;
120
- document.body.appendChild(style);
121
139
  }
122
140
  };
123
141
  TkTheme.styles = (0,external_lit_.css) `
@@ -141,30 +159,9 @@ __decorate([
141
159
  __decorate([
142
160
  (0,decorators_js_.property)()
143
161
  ], TkTheme.prototype, "neutralVariant", void 0);
144
- __decorate([
145
- (0,decorators_js_.property)({ type: Boolean, attribute: "force-body", reflect: true })
146
- ], TkTheme.prototype, "forceBody", void 0);
147
162
  __decorate([
148
163
  (0,decorators_js_.property)({ type: Boolean, attribute: true, reflect: true })
149
164
  ], TkTheme.prototype, "inverted", void 0);
150
- __decorate([
151
- (0,decorators_js_.state)()
152
- ], TkTheme.prototype, "primary_hsl", void 0);
153
- __decorate([
154
- (0,decorators_js_.state)()
155
- ], TkTheme.prototype, "secondary_hsl", void 0);
156
- __decorate([
157
- (0,decorators_js_.state)()
158
- ], TkTheme.prototype, "tertiary_hsl", void 0);
159
- __decorate([
160
- (0,decorators_js_.state)()
161
- ], TkTheme.prototype, "error_hsl", void 0);
162
- __decorate([
163
- (0,decorators_js_.state)()
164
- ], TkTheme.prototype, "neutral_hsl", void 0);
165
- __decorate([
166
- (0,decorators_js_.state)()
167
- ], TkTheme.prototype, "neutral_variant_hsl", void 0);
168
165
  TkTheme = __decorate([
169
166
  (0,decorators_js_.customElement)("tk-theme")
170
167
  ], TkTheme);
@@ -180,7 +177,7 @@ var x = (y) => {
180
177
  var x = {}; __webpack_require__.d(x, y); return x
181
178
  }
182
179
  var y = (x) => (() => (x))
183
- module.exports = x({ ["customElement"]: () => (__WEBPACK_EXTERNAL_MODULE_lit_decorators_js_226d44c5__.customElement), ["property"]: () => (__WEBPACK_EXTERNAL_MODULE_lit_decorators_js_226d44c5__.property), ["state"]: () => (__WEBPACK_EXTERNAL_MODULE_lit_decorators_js_226d44c5__.state) });
180
+ module.exports = x({ ["customElement"]: () => (__WEBPACK_EXTERNAL_MODULE_lit_decorators_js_226d44c5__.customElement), ["property"]: () => (__WEBPACK_EXTERNAL_MODULE_lit_decorators_js_226d44c5__.property) });
184
181
 
185
182
  /***/ })
186
183
 
package/theme/theme.d.ts CHANGED
@@ -7,7 +7,6 @@ export declare class TkTheme extends LitElement {
7
7
  error: string;
8
8
  neutral: string;
9
9
  neutralVariant: string;
10
- forceBody: boolean;
11
10
  inverted: boolean;
12
11
  private primary_hsl;
13
12
  private secondary_hsl;
@@ -15,8 +14,10 @@ export declare class TkTheme extends LitElement {
15
14
  private error_hsl;
16
15
  private neutral_hsl;
17
16
  private neutral_variant_hsl;
17
+ private styleEl?;
18
18
  render(): import("lit").TemplateResult<1>;
19
19
  protected firstUpdated(_changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void;
20
+ protected updated(changedProps: PropertyValueMap<any> | Map<PropertyKey, unknown>): void;
20
21
  private hexToHSL;
21
22
  private setThemeColor;
22
23
  }
package/topbar/index.js CHANGED
@@ -163,6 +163,61 @@ let TkBox = class TkBox extends external_lit_.LitElement {
163
163
  * Activate ripple
164
164
  */
165
165
  this.ripple = false;
166
+ this.showRipple = (event) => {
167
+ const x = event.clientX;
168
+ const y = event.clientY;
169
+ const { offsetWidth, offsetHeight } = this;
170
+ const container = document.createElement("span");
171
+ container.classList.add("ripple", "open");
172
+ const element = document.createElement("span");
173
+ container.appendChild(element);
174
+ this.shadowRoot.appendChild(container);
175
+ const rect = this.getBoundingClientRect();
176
+ const diameter = Math.max(offsetWidth, offsetWidth) * 2;
177
+ element.style.width = element.style.height = diameter + "px";
178
+ element.style.left = x - rect.left - diameter / 2 + "px";
179
+ element.style.top = y - rect.top - diameter / 2 + "px";
180
+ const inAnimation = element.animate({
181
+ transform: [`scale(0)`, `scale(1)`]
182
+ }, {
183
+ easing: "ease-out",
184
+ fill: "both",
185
+ duration: 500
186
+ });
187
+ inAnimation.onfinish = () => {
188
+ container.classList.remove("open");
189
+ const outAnimation = element.animate({
190
+ opacity: ["0.5", "0"]
191
+ }, {
192
+ easing: "ease-in",
193
+ fill: "both",
194
+ duration: 300
195
+ });
196
+ outAnimation.onfinish = () => {
197
+ requestAnimationFrame(() => {
198
+ container.remove();
199
+ });
200
+ };
201
+ };
202
+ };
203
+ this.hideRipple = (event) => {
204
+ var _a;
205
+ (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".ripple:not([open])").forEach(container => {
206
+ const element = container.querySelector("span");
207
+ const outAnimation = element.animate({
208
+ opacity: ["0.5", "0"]
209
+ }, {
210
+ easing: "ease-out",
211
+ fill: "both",
212
+ duration: 300
213
+ });
214
+ outAnimation.onfinish = () => {
215
+ requestAnimationFrame(() => {
216
+ container.remove();
217
+ });
218
+ };
219
+ });
220
+ };
166
221
  }
167
222
  static get styles() {
168
223
  return [
@@ -178,14 +233,14 @@ let TkBox = class TkBox extends external_lit_.LitElement {
178
233
  }
179
234
  connectedCallback() {
180
235
  if (this.ripple) {
181
- this.addEventListener("mousedown", this.showRipple.bind(this), { passive: true });
182
- this.addEventListener("mouseup", this.hideRipple.bind(this), { passive: true });
236
+ this.addEventListener("mousedown", this.showRipple, { passive: true });
237
+ this.addEventListener("mouseup", this.hideRipple, { passive: true });
183
238
  }
184
239
  super.connectedCallback();
185
240
  }
186
241
  disconnectedCallback() {
187
242
  this.removeEventListener("mousedown", this.showRipple);
188
- this.addEventListener("mouseup", this.hideRipple);
243
+ this.removeEventListener("mouseup", this.hideRipple);
189
244
  super.disconnectedCallback();
190
245
  }
191
246
  updated(props) {
@@ -195,61 +250,6 @@ let TkBox = class TkBox extends external_lit_.LitElement {
195
250
  // this.style.setProperty("color", this.color.toString());
196
251
  super.updated(props);
197
252
  }
198
- showRipple(event) {
199
- const x = event.clientX;
200
- const y = event.clientY;
201
- const { offsetWidth, offsetHeight } = this;
202
- const container = document.createElement("span");
203
- container.classList.add("ripple", "open");
204
- const element = document.createElement("span");
205
- container.appendChild(element);
206
- this.shadowRoot.appendChild(container);
207
- const rect = this.getBoundingClientRect();
208
- const diameter = Math.max(offsetWidth, offsetWidth) * 2;
209
- element.style.width = element.style.height = diameter + "px";
210
- element.style.left = x - rect.left - diameter / 2 + "px";
211
- element.style.top = y - rect.top - diameter / 2 + "px";
212
- const inAnimation = element.animate({
213
- transform: [`scale(0)`, `scale(1)`]
214
- }, {
215
- easing: "ease-out",
216
- fill: "both",
217
- duration: 500
218
- });
219
- inAnimation.onfinish = () => {
220
- container.classList.remove("open");
221
- const outAnimation = element.animate({
222
- opacity: ["0.5", "0"]
223
- }, {
224
- easing: "ease-in",
225
- fill: "both",
226
- duration: 300
227
- });
228
- outAnimation.onfinish = () => {
229
- requestAnimationFrame(() => {
230
- container.remove();
231
- });
232
- };
233
- };
234
- }
235
- hideRipple(event) {
236
- var _a;
237
- (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".ripple:not([open])").forEach(container => {
238
- const element = container.querySelector("span");
239
- const outAnimation = element.animate({
240
- opacity: ["0.5", "0"]
241
- }, {
242
- easing: "ease-out",
243
- fill: "both",
244
- duration: 300
245
- });
246
- outAnimation.onfinish = () => {
247
- requestAnimationFrame(() => {
248
- container.remove();
249
- });
250
- };
251
- });
252
- }
253
253
  };
254
254
  __decorate([
255
255
  (0,decorators_js_.property)({ type: Boolean })