tinkiet 0.10.1 → 0.11.0

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/loading/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as __WEBPACK_EXTERNAL_MODULE_lit__ from "lit";
2
- import { classMap as __WEBPACK_EXTERNAL_MODULE_lit_directives_class_map_js_2f88e643_classMap__ } from "lit/directives/class-map.js";
2
+ import * as __WEBPACK_EXTERNAL_MODULE_lit_directives_if_defined_js_76c6050d__ from "lit/directives/if-defined.js";
3
+ import * as __WEBPACK_EXTERNAL_MODULE_lit_directives_class_map_js_2f88e643__ from "lit/directives/class-map.js";
3
4
  import * as __WEBPACK_EXTERNAL_MODULE_lit_decorators_js_226d44c5__ from "lit/decorators.js";
4
5
  /******/ var __webpack_modules__ = ({
5
6
 
@@ -219,7 +220,7 @@ var x = (y) => {
219
220
  var x = {}; __webpack_require__.d(x, y); return x
220
221
  }
221
222
  var y = (x) => (() => (x))
222
- module.exports = x({ ["LitElement"]: () => (__WEBPACK_EXTERNAL_MODULE_lit__.LitElement), ["css"]: () => (__WEBPACK_EXTERNAL_MODULE_lit__.css), ["html"]: () => (__WEBPACK_EXTERNAL_MODULE_lit__.html), ["unsafeCSS"]: () => (__WEBPACK_EXTERNAL_MODULE_lit__.unsafeCSS) });
223
+ module.exports = x({ ["LitElement"]: () => (__WEBPACK_EXTERNAL_MODULE_lit__.LitElement), ["css"]: () => (__WEBPACK_EXTERNAL_MODULE_lit__.css), ["html"]: () => (__WEBPACK_EXTERNAL_MODULE_lit__.html), ["nothing"]: () => (__WEBPACK_EXTERNAL_MODULE_lit__.nothing), ["unsafeCSS"]: () => (__WEBPACK_EXTERNAL_MODULE_lit__.unsafeCSS) });
223
224
 
224
225
  /***/ }),
225
226
 
@@ -235,7 +236,29 @@ module.exports = x({ ["LitElement"]: () => (__WEBPACK_EXTERNAL_MODULE_lit__.LitE
235
236
 
236
237
  /***/ }),
237
238
 
238
- /***/ 4646:
239
+ /***/ 3517:
240
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
241
+
242
+ var x = (y) => {
243
+ var x = {}; __webpack_require__.d(x, y); return x
244
+ }
245
+ var y = (x) => (() => (x))
246
+ module.exports = x({ ["ifDefined"]: () => (__WEBPACK_EXTERNAL_MODULE_lit_directives_if_defined_js_76c6050d__.ifDefined) });
247
+
248
+ /***/ }),
249
+
250
+ /***/ 4955:
251
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
252
+
253
+ var x = (y) => {
254
+ var x = {}; __webpack_require__.d(x, y); return x
255
+ }
256
+ var y = (x) => (() => (x))
257
+ module.exports = x({ ["classMap"]: () => (__WEBPACK_EXTERNAL_MODULE_lit_directives_class_map_js_2f88e643__.classMap) });
258
+
259
+ /***/ }),
260
+
261
+ /***/ 8895:
239
262
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
240
263
 
241
264
 
@@ -248,12 +271,45 @@ __webpack_require__.d(__webpack_exports__, {
248
271
  var external_lit_ = __webpack_require__(2927);
249
272
  // EXTERNAL MODULE: external "lit/decorators.js"
250
273
  var decorators_js_ = __webpack_require__(8899);
251
- ;// external "lit/directives/class-map.js"
274
+ // EXTERNAL MODULE: external "lit/directives/class-map.js"
275
+ var class_map_js_ = __webpack_require__(4955);
276
+ ;// ./node_modules/lit-html/lit-html.js
277
+ /**
278
+ * @license
279
+ * Copyright 2017 Google LLC
280
+ * SPDX-License-Identifier: BSD-3-Clause
281
+ */
282
+ const t=globalThis,i=t.trustedTypes,s=i?i.createPolicy("lit-html",{createHTML:t=>t}):void 0,e="$lit$",h=`lit$${Math.random().toFixed(9).slice(2)}$`,o="?"+h,n=`<${o}>`,r=document,l=()=>r.createComment(""),c=t=>null===t||"object"!=typeof t&&"function"!=typeof t,a=Array.isArray,u=t=>a(t)||"function"==typeof t?.[Symbol.iterator],d="[ \t\n\f\r]",f=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,v=/-->/g,_=/>/g,m=RegExp(`>|${d}(?:([^\\s"'>=/]+)(${d}*=${d}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),p=/'/g,g=/"/g,$=/^(?:script|style|textarea|title)$/i,y=t=>(i,...s)=>({_$litType$:t,strings:i,values:s}),x=y(1),b=y(2),w=y(3),T=Symbol.for("lit-noChange"),E=Symbol.for("lit-nothing"),A=new WeakMap,C=r.createTreeWalker(r,129);function P(t,i){if(!a(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==s?s.createHTML(i):i}const V=(t,i)=>{const s=t.length-1,o=[];let r,l=2===i?"<svg>":3===i?"<math>":"",c=f;for(let i=0;i<s;i++){const s=t[i];let a,u,d=-1,y=0;for(;y<s.length&&(c.lastIndex=y,u=c.exec(s),null!==u);)y=c.lastIndex,c===f?"!--"===u[1]?c=v:void 0!==u[1]?c=_:void 0!==u[2]?($.test(u[2])&&(r=RegExp("</"+u[2],"g")),c=m):void 0!==u[3]&&(c=m):c===m?">"===u[0]?(c=r??f,d=-1):void 0===u[1]?d=-2:(d=c.lastIndex-u[2].length,a=u[1],c=void 0===u[3]?m:'"'===u[3]?g:p):c===g||c===p?c=m:c===v||c===_?c=f:(c=m,r=void 0);const x=c===m&&t[i+1].startsWith("/>")?" ":"";l+=c===f?s+n:d>=0?(o.push(a),s.slice(0,d)+e+s.slice(d)+h+x):s+h+(-2===d?i:x)}return[P(t,l+(t[s]||"<?>")+(2===i?"</svg>":3===i?"</math>":"")),o]};class N{constructor({strings:t,_$litType$:s},n){let r;this.parts=[];let c=0,a=0;const u=t.length-1,d=this.parts,[f,v]=V(t,s);if(this.el=N.createElement(f,n),C.currentNode=this.el.content,2===s||3===s){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(r=C.nextNode())&&d.length<u;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(e)){const i=v[a++],s=r.getAttribute(t).split(h),e=/([.?@])?(.*)/.exec(i);d.push({type:1,index:c,name:e[2],strings:s,ctor:"."===e[1]?H:"?"===e[1]?I:"@"===e[1]?L:k}),r.removeAttribute(t)}else t.startsWith(h)&&(d.push({type:6,index:c}),r.removeAttribute(t));if($.test(r.tagName)){const t=r.textContent.split(h),s=t.length-1;if(s>0){r.textContent=i?i.emptyScript:"";for(let i=0;i<s;i++)r.append(t[i],l()),C.nextNode(),d.push({type:2,index:++c});r.append(t[s],l())}}}else if(8===r.nodeType)if(r.data===o)d.push({type:2,index:c});else{let t=-1;for(;-1!==(t=r.data.indexOf(h,t+1));)d.push({type:7,index:c}),t+=h.length-1}c++}}static createElement(t,i){const s=r.createElement("template");return s.innerHTML=t,s}}function S(t,i,s=t,e){if(i===T)return i;let h=void 0!==e?s._$Co?.[e]:s._$Cl;const o=c(i)?void 0:i._$litDirective$;return h?.constructor!==o&&(h?._$AO?.(!1),void 0===o?h=void 0:(h=new o(t),h._$AT(t,s,e)),void 0!==e?(s._$Co??=[])[e]=h:s._$Cl=h),void 0!==h&&(i=S(t,h._$AS(t,i.values),h,e)),i}class M{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:i},parts:s}=this._$AD,e=(t?.creationScope??r).importNode(i,!0);C.currentNode=e;let h=C.nextNode(),o=0,n=0,l=s[0];for(;void 0!==l;){if(o===l.index){let i;2===l.type?i=new R(h,h.nextSibling,this,t):1===l.type?i=new l.ctor(h,l.name,l.strings,this,t):6===l.type&&(i=new z(h,this,t)),this._$AV.push(i),l=s[++n]}o!==l?.index&&(h=C.nextNode(),o++)}return C.currentNode=r,e}p(t){let i=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++}}class R{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,i,s,e){this.type=2,this._$AH=E,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=e,this._$Cv=e?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===t?.nodeType&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=S(this,t,i),c(t)?t===E||null==t||""===t?(this._$AH!==E&&this._$AR(),this._$AH=E):t!==this._$AH&&t!==T&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):u(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==E&&c(this._$AH)?this._$AA.nextSibling.data=t:this.T(r.createTextNode(t)),this._$AH=t}$(t){const{values:i,_$litType$:s}=t,e="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=N.createElement(P(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===e)this._$AH.p(i);else{const t=new M(e,this),s=t.u(this.options);t.p(i),this.T(s),this._$AH=t}}_$AC(t){let i=A.get(t.strings);return void 0===i&&A.set(t.strings,i=new N(t)),i}k(t){a(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,e=0;for(const h of t)e===i.length?i.push(s=new R(this.O(l()),this.O(l()),this,this.options)):s=i[e],s._$AI(h),e++;e<i.length&&(this._$AR(s&&s._$AB.nextSibling,e),i.length=e)}_$AR(t=this._$AA.nextSibling,i){for(this._$AP?.(!1,!0,i);t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class k{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,i,s,e,h){this.type=1,this._$AH=E,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=h,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=E}_$AI(t,i=this,s,e){const h=this.strings;let o=!1;if(void 0===h)t=S(this,t,i,0),o=!c(t)||t!==this._$AH&&t!==T,o&&(this._$AH=t);else{const e=t;let n,r;for(t=h[0],n=0;n<h.length-1;n++)r=S(this,e[s+n],i,n),r===T&&(r=this._$AH[n]),o||=!c(r)||r!==this._$AH[n],r===E?t=E:t!==E&&(t+=(r??"")+h[n+1]),this._$AH[n]=r}o&&!e&&this.j(t)}j(t){t===E?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class H extends k{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===E?void 0:t}}class I extends k{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==E)}}class L extends k{constructor(t,i,s,e,h){super(t,i,s,e,h),this.type=5}_$AI(t,i=this){if((t=S(this,t,i,0)??E)===T)return;const s=this._$AH,e=t===E&&s!==E||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,h=t!==E&&(s===E||e);e&&this.element.removeEventListener(this.name,this,s),h&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class z{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){S(this,t)}}const Z={M:e,P:h,A:o,C:1,L:V,R:M,D:u,V:S,I:R,H:k,N:I,U:L,B:H,F:z},j=t.litHtmlPolyfillSupport;j?.(N,R),(t.litHtmlVersions??=[]).push("3.3.1");const B=(t,i,s)=>{const e=s?.renderBefore??i;let h=e._$litPart$;if(void 0===h){const t=s?.renderBefore??null;e._$litPart$=h=new R(i.insertBefore(l(),t),t,void 0,s??{})}return h._$AI(t),h};
283
+ //# sourceMappingURL=lit-html.js.map
284
+
285
+ ;// ./node_modules/lit-html/directive.js
286
+ /**
287
+ * @license
288
+ * Copyright 2017 Google LLC
289
+ * SPDX-License-Identifier: BSD-3-Clause
290
+ */
291
+ const directive_t={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},directive_e=t=>(...e)=>({_$litDirective$:t,values:e});class directive_i{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}
292
+ //# sourceMappingURL=directive.js.map
293
+
294
+ ;// ./node_modules/lit-html/directives/style-map.js
252
295
 
296
+ /**
297
+ * @license
298
+ * Copyright 2018 Google LLC
299
+ * SPDX-License-Identifier: BSD-3-Clause
300
+ */const style_map_n="important",style_map_i=" !"+style_map_n,style_map_o=directive_e(class extends directive_i{constructor(t){if(super(t),t.type!==directive_t.ATTRIBUTE||"style"!==t.name||t.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(t){return Object.keys(t).reduce(((e,r)=>{const s=t[r];return null==s?e:e+`${r=r.includes("-")?r:r.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${s};`}),"")}update(e,[r]){const{style:s}=e.element;if(void 0===this.ft)return this.ft=new Set(Object.keys(r)),this.render(r);for(const t of this.ft)null==r[t]&&(this.ft.delete(t),t.includes("-")?s.removeProperty(t):s[t]=null);for(const t in r){const e=r[t];if(null!=e){this.ft.add(t);const r="string"==typeof e&&e.endsWith(style_map_i);t.includes("-")||r?s.setProperty(t,r?e.slice(0,-11):e,r?style_map_n:""):s[t]=e}}return T}});
301
+ //# sourceMappingURL=style-map.js.map
302
+
303
+ ;// ./node_modules/lit/directives/style-map.js
304
+
305
+ //# sourceMappingURL=style-map.js.map
306
+
307
+ // EXTERNAL MODULE: external "lit/directives/if-defined.js"
308
+ var if_defined_js_ = __webpack_require__(3517);
253
309
  // EXTERNAL MODULE: ./tinkiet/box/index.ts
254
310
  var box = __webpack_require__(3433);
255
311
  ;// ./tinkiet/loading/loading.scss
256
- /* harmony default export */ const loading = ("*{-webkit-tap-highlight-color:rgba(0,0,0,0);-webkit-tap-highlight-color:rgba(0,0,0,0);box-sizing:border-box}:host{--color: hsl(var(--primary));--background-color: var(--tk-loading-background-color, hsl(var(--surface-dim)))}:host([secondary]){--color: hsl(var(--secondary))}:host([error]){--color: hsl(var(--error))}.circle{display:inline-flex;animation:rotator 3s linear infinite;transform-origin:center;width:56px;height:56px}.circle .path{stroke-dasharray:265;stroke-dashoffset:0;transform-origin:center;stroke:var(--color);animation:dash 3s ease-in-out infinite}@keyframes rotator{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}@keyframes dash{0%{stroke-dashoffset:265}50%{stroke-dashoffset:65;transform:rotate(90deg)}100%{stroke-dashoffset:265;transform:rotate(360deg)}}:host([small]) .circle{width:20px;height:20px}:host([small]) .line{height:2px}:host([large]) .circle{width:96px;height:96px}:host([large]) .line{height:14px}.line{position:relative;background-color:var(--background-color);overflow:hidden;height:6px}.line .progress{background-color:var(--color);height:100%}.line .indeterminate{background-color:var(--color)}.line .indeterminate:before{content:\"\";position:absolute;background-color:inherit;top:0;left:0;bottom:0;will-change:left,right;animation:indeterminate 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite}.line .indeterminate:after{content:\"\";position:absolute;background-color:inherit;top:0;left:0;bottom:0;will-change:left,right;animation:indeterminate-short 2.1s cubic-bezier(0.165, 0.84, 0.44, 1) infinite;animation-delay:1.15s}@keyframes indeterminate{0%{left:-35%;right:100%}60%{left:100%;right:-90%}100%{left:100%;right:-90%}}@keyframes indeterminate-short{0%{left:-200%;right:100%}60%{left:107%;right:-8%}100%{left:107%;right:-8%}}");
312
+ /* harmony default export */ const loading = ("*{-webkit-tap-highlight-color:rgba(0,0,0,0);-webkit-tap-highlight-color:rgba(0,0,0,0);box-sizing:border-box}:host{--color: hsl(var(--primary));--background-color: var(--tk-loading-background-color, hsl(var(--surface-dim)))}:host([secondary]){--color: hsl(var(--secondary))}:host([error]){--color: hsl(var(--error))}.circle{display:inline-flex;animation:rotator 3s linear infinite;transform-origin:center;width:56px;height:56px}.circle .track{stroke:var(--background-color);opacity:.4}.circle .path{stroke-dasharray:265;stroke-dashoffset:0;transform-origin:center;stroke:var(--color);animation:dash 3s ease-in-out infinite}@keyframes rotator{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}@keyframes dash{0%{stroke-dashoffset:265}50%{stroke-dashoffset:65;transform:rotate(90deg)}100%{stroke-dashoffset:265;transform:rotate(360deg)}}:host([small]) .circle{width:20px;height:20px}:host([small]) .line{height:2px}:host([large]) .circle{width:96px;height:96px}:host([large]) .line{height:14px}.line{position:relative;background-color:var(--background-color);overflow:hidden;height:6px}.line .progress{background-color:var(--color);height:100%;position:relative;width:100%}.line .indeterminate{background-color:rgba(0,0,0,0);position:absolute;top:0;left:0;right:0;bottom:0}.line .indeterminate:before{content:\"\";position:absolute;background-color:var(--color);top:0;left:0;bottom:0;will-change:left,right;animation:indeterminate 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite}.line .indeterminate:after{content:\"\";position:absolute;background-color:var(--color);top:0;left:0;bottom:0;will-change:left,right;animation:indeterminate-short 2.1s cubic-bezier(0.165, 0.84, 0.44, 1) infinite;animation-delay:1.15s}@keyframes indeterminate{0%{left:-35%;right:100%}60%{left:100%;right:-90%}100%{left:100%;right:-90%}}@keyframes indeterminate-short{0%{left:-200%;right:100%}60%{left:107%;right:-8%}100%{left:107%;right:-8%}}");
257
313
  ;// ./tinkiet/loading/loading.ts
258
314
  var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
259
315
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -266,6 +322,8 @@ var __decorate = (undefined && undefined.__decorate) || function (decorators, ta
266
322
 
267
323
 
268
324
 
325
+
326
+
269
327
  let TkLoading = class TkLoading extends box/* TkBox */.P {
270
328
  constructor() {
271
329
  super(...arguments);
@@ -282,28 +340,65 @@ let TkLoading = class TkLoading extends box/* TkBox */.P {
282
340
  ];
283
341
  }
284
342
  render() {
343
+ const percent = this.normalizePercent(this.percent);
344
+ const radius = 40;
345
+ const circumference = 2 * Math.PI * radius;
346
+ const dashOffset = circumference * (1 - percent / 100);
347
+ const isDeterminateCircle = this.circle && !this.indeterminate && this.hasAttribute("percent");
348
+ const ariaValueNow = this.indeterminate ? undefined : percent;
349
+ const circleStyle = isDeterminateCircle ? style_map_o({ animation: "none" }) : external_lit_.nothing;
350
+ const progressStyle = isDeterminateCircle
351
+ ? style_map_o({
352
+ animation: "none",
353
+ strokeDasharray: `${circumference}`,
354
+ strokeDashoffset: `${dashOffset}`
355
+ })
356
+ : external_lit_.nothing;
285
357
  return (0,external_lit_.html) `
286
358
  ${this.circle
287
359
  ? (0,external_lit_.html) `
288
- <svg class="circle" viewBox="0 0 100 100">
360
+ <svg
361
+ class="circle"
362
+ viewBox="0 0 100 100"
363
+ role="progressbar"
364
+ aria-valuemin="0"
365
+ aria-valuemax="100"
366
+ aria-valuenow=${(0,if_defined_js_.ifDefined)(ariaValueNow)}
367
+ style=${circleStyle}
368
+ >
369
+ <circle class="track" fill="none" stroke-width="1em" cx="50" cy="50" r="40"></circle>
289
370
  <circle
290
- class=${__WEBPACK_EXTERNAL_MODULE_lit_directives_class_map_js_2f88e643_classMap__({ indeterminate: this.indeterminate, path: true })}
371
+ class=${(0,class_map_js_.classMap)({ indeterminate: this.indeterminate, path: true })}
291
372
  fill="none"
292
373
  stroke-width="1em"
293
374
  stroke-linecap="butt"
294
375
  cx="50"
295
376
  cy="50"
296
377
  r="40"
378
+ style=${progressStyle}
297
379
  ></circle>
298
380
  </svg>
299
- `
381
+ `
300
382
  : (0,external_lit_.html) `
301
- <div class="line">
302
- <div class=${__WEBPACK_EXTERNAL_MODULE_lit_directives_class_map_js_2f88e643_classMap__({ progress: true, indeterminate: this.indeterminate })} style="${`width:${this.percent}%;`}"></div>
383
+ <div
384
+ class="line"
385
+ role="progressbar"
386
+ aria-valuemin="0"
387
+ aria-valuemax="100"
388
+ aria-valuenow=${(0,if_defined_js_.ifDefined)(ariaValueNow)}
389
+ >
390
+ <div class=${(0,class_map_js_.classMap)({ progress: true, indeterminate: this.indeterminate })} style=${style_map_o(this.indeterminate ? { width: "100%" } : { width: `${percent}%` })}>
391
+ ${this.indeterminate ? (0,external_lit_.html) `<span class="visually-hidden">Loading</span>` : external_lit_.nothing}
392
+ </div>
303
393
  </div>
304
- `}
394
+ `}
305
395
  `;
306
396
  }
397
+ normalizePercent(value) {
398
+ if (!Number.isFinite(value))
399
+ return 0;
400
+ return Math.min(100, Math.max(0, value));
401
+ }
307
402
  };
308
403
  __decorate([
309
404
  (0,decorators_js_.property)({ attribute: true, type: Boolean })
@@ -382,7 +477,7 @@ var __webpack_exports__ = {};
382
477
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
383
478
  /* harmony export */ k: () => (/* reexport safe */ _loading__WEBPACK_IMPORTED_MODULE_0__.k)
384
479
  /* harmony export */ });
385
- /* harmony import */ var _loading__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4646);
480
+ /* harmony import */ var _loading__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8895);
386
481
 
387
482
 
388
483
  const __webpack_exports__TkLoading = __webpack_exports__.k;
@@ -5,6 +5,7 @@ export declare class TkLoading extends TkBox {
5
5
  indeterminate: boolean;
6
6
  percent: number;
7
7
  render(): import("lit").TemplateResult<1>;
8
+ private normalizePercent;
8
9
  }
9
10
  declare global {
10
11
  interface HTMLElementTagNameMap {
package/package.json CHANGED
@@ -1,11 +1,21 @@
1
1
  {
2
2
  "name": "tinkiet",
3
- "version": "0.10.1",
3
+ "version": "0.11.0",
4
4
  "description": "Pragmatic UI Web Components",
5
5
  "type": "module",
6
6
  "main": "index.js",
7
7
  "module": "index.js",
8
8
  "types": "index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./index.js",
12
+ "types": "./index.d.ts"
13
+ },
14
+ "./router": {
15
+ "import": "./router/index.js",
16
+ "types": "./router/index.d.ts"
17
+ }
18
+ },
9
19
  "keywords": [
10
20
  "web",
11
21
  "components",
package/pages/index.js CHANGED
@@ -27,7 +27,7 @@ var external_lit_ = __webpack_require__(2927);
27
27
  // EXTERNAL MODULE: external "lit/decorators.js"
28
28
  var decorators_js_ = __webpack_require__(8899);
29
29
  ;// ./tinkiet/pages/pages.scss
30
- /* harmony default export */ const pages = ("*{-webkit-tap-highlight-color:rgba(0,0,0,0);-webkit-tap-highlight-color:rgba(0,0,0,0);box-sizing:border-box}");
30
+ /* harmony default export */ const pages = ("*{-webkit-tap-highlight-color:rgba(0,0,0,0);-webkit-tap-highlight-color:rgba(0,0,0,0);box-sizing:border-box}:host ::slotted([hidden]){display:none !important}");
31
31
  ;// ./tinkiet/pages/pages.ts
32
32
  var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
33
33
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -47,7 +47,9 @@ let TkPages = class TkPages extends external_lit_.LitElement {
47
47
  this.scrollHistory = {};
48
48
  }
49
49
  set page(val) {
50
- let oldVal = this._page;
50
+ const oldVal = this._page;
51
+ if (oldVal === val)
52
+ return;
51
53
  this._page = val;
52
54
  if (oldVal && this.handleScroll) {
53
55
  const el = this.querySelector(`[page=${oldVal}]`);
@@ -61,6 +63,17 @@ let TkPages = class TkPages extends external_lit_.LitElement {
61
63
  get page() {
62
64
  return this._page;
63
65
  }
66
+ firstUpdated() {
67
+ var _a, _b;
68
+ // If no page is set, pick the first child with a page attr or default to "default"
69
+ if (!this.page) {
70
+ const first = (_a = this.querySelector("[page]")) !== null && _a !== void 0 ? _a : this.querySelector(":scope > *");
71
+ if (first) {
72
+ this.page = (_b = first.getAttribute("page")) !== null && _b !== void 0 ? _b : "default";
73
+ }
74
+ }
75
+ this.updatePages();
76
+ }
64
77
  render() {
65
78
  return (0,external_lit_.html) `
66
79
  <slot></slot>
@@ -68,34 +81,37 @@ let TkPages = class TkPages extends external_lit_.LitElement {
68
81
  }
69
82
  updated(props) {
70
83
  if (props.has("page")) {
71
- this.querySelectorAll(":scope > *").forEach(el => {
72
- var _a;
73
- const elPageAttribute = (_a = el.getAttribute("page")) !== null && _a !== void 0 ? _a : "default";
74
- const scrollElement = document.scrollingElement || document.documentElement;
75
- if (elPageAttribute == this.page) {
76
- el.removeAttribute("hidden");
77
- if (this.selected != "") {
78
- el.setAttribute(this.selected, "");
79
- }
80
- if (this.handleScroll && !el.hasAttribute("no-scroll")) {
81
- scrollElement.scrollTop = this.scrollHistory[elPageAttribute] ? this.scrollHistory[elPageAttribute] : 0;
82
- }
84
+ this.updatePages();
85
+ }
86
+ }
87
+ updatePages() {
88
+ const scrollElement = document.scrollingElement || document.documentElement;
89
+ this.querySelectorAll(":scope > *").forEach(el => {
90
+ var _a, _b;
91
+ const elPageAttribute = (_a = el.getAttribute("page")) !== null && _a !== void 0 ? _a : "default";
92
+ if (elPageAttribute === this.page) {
93
+ el.removeAttribute("hidden");
94
+ if (this.selected) {
95
+ el.setAttribute(this.selected, "");
83
96
  }
84
- else {
85
- el.setAttribute("hidden", "");
86
- if (this.selected != "") {
87
- el.removeAttribute(this.selected);
88
- }
97
+ if (this.handleScroll && !el.hasAttribute("no-scroll")) {
98
+ scrollElement.scrollTop = (_b = this.scrollHistory[elPageAttribute]) !== null && _b !== void 0 ? _b : 0;
89
99
  }
90
- });
91
- }
100
+ }
101
+ else {
102
+ el.setAttribute("hidden", "");
103
+ if (this.selected) {
104
+ el.removeAttribute(this.selected);
105
+ }
106
+ }
107
+ });
92
108
  }
93
109
  };
94
110
  TkPages.styles = (0,external_lit_.css) `
95
111
  ${(0,external_lit_.unsafeCSS)(pages)}
96
112
  `;
97
113
  __decorate([
98
- (0,decorators_js_.property)({ attribute: "page", type: String })
114
+ (0,decorators_js_.property)({ attribute: "page", type: String, reflect: true })
99
115
  ], TkPages.prototype, "page", null);
100
116
  __decorate([
101
117
  (0,decorators_js_.property)({ attribute: true, type: String })
package/pages/pages.d.ts CHANGED
@@ -7,8 +7,10 @@ export declare class TkPages extends LitElement {
7
7
  selected: string;
8
8
  handleScroll: boolean;
9
9
  private scrollHistory;
10
+ firstUpdated(): void;
10
11
  render(): import("lit").TemplateResult<1>;
11
12
  updated(props: any): void;
13
+ private updatePages;
12
14
  }
13
15
  declare global {
14
16
  interface HTMLElementTagNameMap {
@@ -0,0 +1,48 @@
1
+ export interface RouteContext {
2
+ /** Pathname without query/hash, e.g. /tk/page1 */
3
+ path: string;
4
+ /** Full path with query/hash, e.g. /tk/page1?foo=bar#hash */
5
+ fullPath: string;
6
+ /** Matched params from pattern (:id, :section*, ...) */
7
+ params: Record<string, string>;
8
+ /** Query parameters */
9
+ query: URLSearchParams;
10
+ /** Matched route pattern (if any) */
11
+ route: string | null;
12
+ /** Shared mutable state for middlewares */
13
+ state: Record<string, unknown>;
14
+ }
15
+ export type NextFunction = () => Promise<void>;
16
+ export type Middleware = (ctx: RouteContext, next: NextFunction) => void | Promise<void>;
17
+ export interface NavigateOptions {
18
+ replace?: boolean;
19
+ silent?: boolean;
20
+ }
21
+ export declare class Router {
22
+ private layers;
23
+ private started;
24
+ /**
25
+ * Global middleware:
26
+ * router.use((ctx, next) => { ... })
27
+ *
28
+ * Pattern-scoped middleware:
29
+ * router.use('/tk/:page', (ctx, next) => { ... })
30
+ */
31
+ use(handler: Middleware): void;
32
+ use(pattern: string, handler: Middleware): void;
33
+ /**
34
+ * Programmatic navigation.
35
+ * Example: router.navigate('/tk/home');
36
+ */
37
+ navigate(path: string, options?: NavigateOptions): void;
38
+ /**
39
+ * Start listening to history and link clicks, and dispatch initial URL.
40
+ */
41
+ start(): void;
42
+ /**
43
+ * Shortcut to go back in history.
44
+ */
45
+ back(): void;
46
+ private createMatcher;
47
+ private dispatch;
48
+ }
@@ -0,0 +1,246 @@
1
+ /******/ // The require scope
2
+ /******/ var __webpack_require__ = {};
3
+ /******/
4
+ /************************************************************************/
5
+ /******/ /* webpack/runtime/define property getters */
6
+ /******/ (() => {
7
+ /******/ // define getter functions for harmony exports
8
+ /******/ __webpack_require__.d = (exports, definition) => {
9
+ /******/ for(var key in definition) {
10
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
11
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
12
+ /******/ }
13
+ /******/ }
14
+ /******/ };
15
+ /******/ })();
16
+ /******/
17
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
18
+ /******/ (() => {
19
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
20
+ /******/ })();
21
+ /******/
22
+ /************************************************************************/
23
+ var __webpack_exports__ = {};
24
+
25
+ ;// ./tinkiet/router/route-matcher.ts
26
+ function matchPath(pattern, pathname) {
27
+ if (pattern === '*') {
28
+ return { params: {} };
29
+ }
30
+ const patternParts = pattern.split('/').filter(Boolean);
31
+ const pathParts = pathname.split('/').filter(Boolean);
32
+ const params = {};
33
+ for (let i = 0; i < patternParts.length; i++) {
34
+ const pat = patternParts[i];
35
+ const isLastPatternSegment = i === patternParts.length - 1;
36
+ const segment = pathParts[i];
37
+ // Wildcard "rest" param: :name*
38
+ if (pat.startsWith(':') && pat.endsWith('*')) {
39
+ const name = pat.slice(1, -1); // remove ':' and '*'
40
+ params[name] = decodeURIComponent(pathParts.slice(i).join('/'));
41
+ return { params };
42
+ }
43
+ // Simple param :name
44
+ if (pat.startsWith(':')) {
45
+ if (segment == null)
46
+ return null;
47
+ const name = pat.slice(1);
48
+ params[name] = decodeURIComponent(segment);
49
+ continue;
50
+ }
51
+ // Plain wildcard "*"
52
+ if (pat === '*') {
53
+ return { params };
54
+ }
55
+ // Static segment
56
+ if (segment !== pat) {
57
+ return null;
58
+ }
59
+ // If we are at end of pattern but still have more path segments
60
+ if (isLastPatternSegment && pathParts.length > patternParts.length) {
61
+ return null;
62
+ }
63
+ }
64
+ // Extra segments in path not matched by a rest param => no match
65
+ if (pathParts.length > patternParts.length) {
66
+ return null;
67
+ }
68
+ return { params };
69
+ }
70
+
71
+ ;// ./tinkiet/router/index.ts
72
+ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
73
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
74
+ return new (P || (P = Promise))(function (resolve, reject) {
75
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
76
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
77
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
78
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
79
+ });
80
+ };
81
+ // router.ts
82
+
83
+ class Router {
84
+ constructor() {
85
+ this.layers = [];
86
+ this.started = false;
87
+ }
88
+ use(patternOrHandler, handler) {
89
+ if (typeof patternOrHandler === 'string') {
90
+ if (!handler) {
91
+ throw new Error('router.use(pattern, handler) requires a handler');
92
+ }
93
+ const pattern = patternOrHandler;
94
+ this.layers.push({
95
+ pattern,
96
+ matcher: this.createMatcher(pattern),
97
+ stack: [handler]
98
+ });
99
+ }
100
+ else {
101
+ const globalHandler = patternOrHandler;
102
+ this.layers.push({
103
+ pattern: null,
104
+ matcher: null,
105
+ stack: [globalHandler]
106
+ });
107
+ }
108
+ }
109
+ /**
110
+ * Programmatic navigation.
111
+ * Example: router.navigate('/tk/home');
112
+ */
113
+ navigate(path, options = {}) {
114
+ if (!this.started)
115
+ return;
116
+ const url = new URL(path, window.location.origin);
117
+ const href = url.pathname + url.search + url.hash;
118
+ if (options.replace) {
119
+ history.replaceState(null, '', href);
120
+ }
121
+ else {
122
+ history.pushState(null, '', href);
123
+ }
124
+ if (!options.silent) {
125
+ void this.dispatch(url);
126
+ }
127
+ }
128
+ /**
129
+ * Start listening to history and link clicks, and dispatch initial URL.
130
+ */
131
+ start() {
132
+ if (this.started)
133
+ return;
134
+ this.started = true;
135
+ // Back/forward
136
+ window.addEventListener('popstate', () => {
137
+ const url = new URL(window.location.href);
138
+ void this.dispatch(url);
139
+ });
140
+ // Intercept <a> clicks for SPA navigation
141
+ document.addEventListener('click', (event) => {
142
+ var _a, _b;
143
+ const path = event.composedPath();
144
+ // Find first element in the composed path that exposes an href
145
+ let linkEl = null;
146
+ let href = null;
147
+ for (const el of path) {
148
+ if (!(el instanceof HTMLElement))
149
+ continue;
150
+ const elHref = (_a = el.href) !== null && _a !== void 0 ? _a : el.getAttribute('href');
151
+ if (elHref) {
152
+ linkEl = el;
153
+ href = elHref;
154
+ break;
155
+ }
156
+ }
157
+ if (!linkEl || !href)
158
+ return;
159
+ const url = new URL(href, window.location.origin);
160
+ const sameOrigin = url.origin === window.location.origin;
161
+ const targetAttr = (_b = linkEl.target) !== null && _b !== void 0 ? _b : linkEl.getAttribute('target');
162
+ const isModifiedClick = event.metaKey ||
163
+ event.ctrlKey ||
164
+ event.shiftKey ||
165
+ event.altKey ||
166
+ event.button !== 0;
167
+ if (!sameOrigin || isModifiedClick || targetAttr === '_blank')
168
+ return;
169
+ if (linkEl.hasAttribute('download'))
170
+ return;
171
+ // Let browser handle hash-only navigation on same path
172
+ if (url.pathname === window.location.pathname && url.hash !== '')
173
+ return;
174
+ event.preventDefault();
175
+ this.navigate(url.pathname + url.search + url.hash);
176
+ });
177
+ const initialUrl = new URL(window.location.href);
178
+ void this.dispatch(initialUrl);
179
+ }
180
+ /**
181
+ * Shortcut to go back in history.
182
+ */
183
+ back() {
184
+ window.history.back();
185
+ }
186
+ // ---------- Internals ----------
187
+ createMatcher(pattern) {
188
+ if (pattern === '*') {
189
+ return () => ({ params: {} });
190
+ }
191
+ return (pathname) => matchPath(pattern, pathname);
192
+ }
193
+ dispatch(url) {
194
+ return __awaiter(this, void 0, void 0, function* () {
195
+ const pathname = url.pathname;
196
+ const fullPath = url.pathname + url.search + url.hash;
197
+ const ctx = {
198
+ path: pathname,
199
+ fullPath,
200
+ params: {},
201
+ query: url.searchParams,
202
+ route: null,
203
+ state: {}
204
+ };
205
+ let layerIndex = -1;
206
+ const runLayer = (index) => __awaiter(this, void 0, void 0, function* () {
207
+ if (index <= layerIndex) {
208
+ throw new Error('next() called multiple times for the same layer');
209
+ }
210
+ layerIndex = index;
211
+ if (index >= this.layers.length) {
212
+ return;
213
+ }
214
+ const layer = this.layers[index];
215
+ const { matcher, pattern, stack } = layer;
216
+ const matchResult = matcher ? matcher(pathname) : { params: {} };
217
+ if (!matchResult) {
218
+ return runLayer(index + 1);
219
+ }
220
+ ctx.route = pattern;
221
+ ctx.params = Object.assign(Object.assign({}, ctx.params), matchResult.params);
222
+ let stackIndex = -1;
223
+ const runMiddleware = (mwIndex) => __awaiter(this, void 0, void 0, function* () {
224
+ if (mwIndex <= stackIndex) {
225
+ throw new Error('next() called multiple times inside a layer');
226
+ }
227
+ stackIndex = mwIndex;
228
+ if (mwIndex >= stack.length) {
229
+ return runLayer(index + 1);
230
+ }
231
+ const mw = stack[mwIndex];
232
+ yield mw(ctx, () => runMiddleware(mwIndex + 1));
233
+ });
234
+ yield runMiddleware(0);
235
+ });
236
+ try {
237
+ yield runLayer(0);
238
+ }
239
+ catch (err) {
240
+ console.error('[router] Unhandled error during dispatch', err);
241
+ }
242
+ });
243
+ }
244
+ }
245
+
246
+ export { Router };
@@ -0,0 +1,4 @@
1
+ export interface MatchResult {
2
+ params: Record<string, string>;
3
+ }
4
+ export declare function matchPath(pattern: string, pathname: string): MatchResult | null;