aptechka 0.78.2 → 0.78.3
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/lib/slicer/index.cjs +1 -1
- package/lib/slicer/index.js +96 -74
- package/package.json +1 -1
package/lib/slicer/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var S=
|
|
1
|
+
"use strict";var S=n=>{throw TypeError(n)};var C=(n,e,s)=>e.has(n)||S("Cannot "+s);var t=(n,e,s)=>(C(n,e,"read from private field"),s?s.call(n):e.get(n)),l=(n,e,s)=>e.has(n)?S("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,s),o=(n,e,s,p)=>(C(n,e,"write to private field"),p?p.call(n,s):e.set(n,s),s),m=(n,e,s)=>(C(n,e,"access private method"),s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("../media/index.cjs"),q=require("../index-DekP7OZe.cjs");require("construct-style-sheets-polyfill");var y,d;class H{constructor(e){l(this,y);l(this,d);o(this,y,e.index),o(this,d,document.createElement("span")),t(this,d).classList.add("letter"),e.clone?t(this,d).innerHTML=`<span class="original"><span class="value">${e.text}</span></span><span class="clone" aria-hidden><span class="value">${e.text}</span></span>`:t(this,d).innerHTML=`<span class="original"><span class="value">${e.text}</span></span>`}get index(){return t(this,y)}get element(){return t(this,d)}}y=new WeakMap,d=new WeakMap;var L,h,f,E;class P{constructor(e){l(this,L);l(this,h);l(this,f);l(this,E);if(o(this,L,e.index),o(this,h,document.createElement("span")),o(this,f,[]),o(this,E,e.text.endsWith("\\n")),t(this,E)&&(e.text=e.text.replace("\\n","")),e.letters&&e.lettersAcc!==void 0){let s=0;const p=e.text.split("").map(c=>{if(c!==" ")return new H({index:e.lettersAcc+s++,text:c,clone:e.clone})});o(this,f,p.filter(c=>c instanceof H)),t(this,h).append(...t(this,f).map(c=>c.element))}else e.clone?t(this,h).innerHTML=`<span class="original"><span class="value">${e.text}</span></span><span class="clone" aria-hidden><span class="value">${e.text}</span></span>`:t(this,h).innerHTML=`<span class="original"><span class="value">${e.text}</span></span>`;t(this,h).classList.add("word")}get index(){return t(this,L)}get element(){return t(this,h)}get letters(){return t(this,f)}get hasNewLine(){return t(this,E)}}L=new WeakMap,h=new WeakMap,f=new WeakMap,E=new WeakMap;var N,a,x,T,u,D,_;class $ extends HTMLElement{constructor(){super(...arguments);l(this,u);l(this,N,"");l(this,a,[]);l(this,x,[]);l(this,T,null)}get wordsArray(){return t(this,a)}get lettersArray(){return t(this,x)}get originalHTML(){return t(this,N)}connectedCallback(){o(this,N,this.innerHTML.trim()),this.hasAttribute("media")?(o(this,T,new k.Media(this.getAttribute("media"))),t(this,T).subscribe(s=>{s.current?m(this,u,D).call(this):!s.current&&s.previous&&m(this,u,_).call(this)})):m(this,u,D).call(this)}disconnectedCallback(){var s;m(this,u,_).call(this),(s=t(this,T))==null||s.close()}}N=new WeakMap,a=new WeakMap,x=new WeakMap,T=new WeakMap,u=new WeakSet,D=function(){const s=[];o(this,a,[]);let p=0,c=0;const F=i=>{var g;const r=(g=i.textContent)==null?void 0:g.trim();if(!r)return document.createDocumentFragment();const M=document.createDocumentFragment();return r.replace(/ +/g," ").split(" ").forEach((A,b,v)=>{if(!A)return;const w=new P({index:p,text:A+(b<v.length-1?" ":""),letters:this.hasAttribute("letters"),lettersAcc:c,clone:this.hasAttribute("clone")});c+=w.letters.length,p+=1,t(this,x).push(...w.letters),t(this,a).push(w),M.appendChild(w.element)}),M},O=i=>{if(i.nodeType===Node.TEXT_NODE)return F(i);if(i.nodeType===Node.ELEMENT_NODE){const r=i.cloneNode(!1);return Array.from(i.childNodes).forEach(M=>{const g=O(M);g&&(g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?Array.from(g.childNodes).forEach((A,b,v)=>{r.append(A),b!==v.length-1&&r.append(new Text(" "))}):r.appendChild(g))}),r}return i.cloneNode()};Array.from(this.childNodes).forEach(i=>{const r=O(i);r.nodeType===Node.DOCUMENT_FRAGMENT_NODE?s.push(...Array.from(r.childNodes)):s.push(r)}),this.hasAttribute("index")&&(t(this,a).forEach(i=>{i.element.style.setProperty("--word-index",i.index.toString())}),t(this,x).forEach(i=>{i.element.style.setProperty("--letter-index",i.index.toString())})),this.innerHTML="",s.forEach((i,r)=>{this.appendChild(i),r<s.length-1&&i.nodeType===Node.ELEMENT_NODE&&this.appendChild(new Text(" "))}),this.style.setProperty("--words-length",t(this,a).length.toString()),this.style.setProperty("--letters-length",t(this,x).length.toString())},_=function(){o(this,a,[]),this.innerHTML=t(this,N),this.style.removeProperty("--words-length"),this.style.removeProperty("--letters-length")};q.isBrowser&&!customElements.get("e-slicer")&&customElements.define("e-slicer",$);exports.Letter=H;exports.SlicerElement=$;exports.Word=P;
|
package/lib/slicer/index.js
CHANGED
|
@@ -1,124 +1,146 @@
|
|
|
1
|
-
var
|
|
2
|
-
throw TypeError(
|
|
1
|
+
var _ = (n) => {
|
|
2
|
+
throw TypeError(n);
|
|
3
3
|
};
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
import { Media as
|
|
7
|
-
import { i as
|
|
4
|
+
var H = (n, e, s) => e.has(n) || _("Cannot " + s);
|
|
5
|
+
var t = (n, e, s) => (H(n, e, "read from private field"), s ? s.call(n) : e.get(n)), r = (n, e, s) => e.has(n) ? _("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, s), o = (n, e, s, u) => (H(n, e, "write to private field"), u ? u.call(n, s) : e.set(n, s), s), T = (n, e, s) => (H(n, e, "access private method"), s);
|
|
6
|
+
import { Media as S } from "../media/index.js";
|
|
7
|
+
import { i as F } from "../index-Bv9zgfdb.js";
|
|
8
8
|
import "construct-style-sheets-polyfill";
|
|
9
|
-
var
|
|
10
|
-
class
|
|
11
|
-
constructor(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
var y, d;
|
|
10
|
+
class P {
|
|
11
|
+
constructor(e) {
|
|
12
|
+
r(this, y);
|
|
13
|
+
r(this, d);
|
|
14
|
+
o(this, y, e.index), o(this, d, document.createElement("span")), t(this, d).classList.add("letter"), e.clone ? t(this, d).innerHTML = `<span class="original"><span class="value">${e.text}</span></span><span class="clone" aria-hidden><span class="value">${e.text}</span></span>` : t(this, d).innerHTML = `<span class="original"><span class="value">${e.text}</span></span>`;
|
|
15
15
|
}
|
|
16
16
|
get index() {
|
|
17
|
-
return
|
|
17
|
+
return t(this, y);
|
|
18
18
|
}
|
|
19
19
|
get element() {
|
|
20
|
-
return
|
|
20
|
+
return t(this, d);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
var
|
|
25
|
-
class
|
|
26
|
-
constructor(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (
|
|
23
|
+
y = new WeakMap(), d = new WeakMap();
|
|
24
|
+
var A, c, g, E;
|
|
25
|
+
class k {
|
|
26
|
+
constructor(e) {
|
|
27
|
+
r(this, A);
|
|
28
|
+
r(this, c);
|
|
29
|
+
r(this, g);
|
|
30
|
+
r(this, E);
|
|
31
|
+
if (o(this, A, e.index), o(this, c, document.createElement("span")), o(this, g, []), o(this, E, e.text.endsWith("\\n")), t(this, E) && (e.text = e.text.replace("\\n", "")), e.letters && e.lettersAcc !== void 0) {
|
|
32
32
|
let s = 0;
|
|
33
|
-
const
|
|
33
|
+
const u = e.text.split("").map((h) => {
|
|
34
34
|
if (h !== " ")
|
|
35
|
-
return new
|
|
36
|
-
index:
|
|
35
|
+
return new P({
|
|
36
|
+
index: e.lettersAcc + s++,
|
|
37
37
|
text: h,
|
|
38
|
-
clone:
|
|
38
|
+
clone: e.clone
|
|
39
39
|
});
|
|
40
40
|
});
|
|
41
|
-
|
|
42
|
-
...
|
|
41
|
+
o(this, g, u.filter((h) => h instanceof P)), t(this, c).append(
|
|
42
|
+
...t(this, g).map((h) => h.element)
|
|
43
43
|
);
|
|
44
44
|
} else
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
e.clone ? t(this, c).innerHTML = `<span class="original"><span class="value">${e.text}</span></span><span class="clone" aria-hidden><span class="value">${e.text}</span></span>` : t(this, c).innerHTML = `<span class="original"><span class="value">${e.text}</span></span>`;
|
|
46
|
+
t(this, c).classList.add("word");
|
|
47
47
|
}
|
|
48
48
|
get index() {
|
|
49
|
-
return
|
|
49
|
+
return t(this, A);
|
|
50
50
|
}
|
|
51
51
|
get element() {
|
|
52
|
-
return
|
|
52
|
+
return t(this, c);
|
|
53
53
|
}
|
|
54
54
|
get letters() {
|
|
55
|
-
return
|
|
55
|
+
return t(this, g);
|
|
56
56
|
}
|
|
57
57
|
get hasNewLine() {
|
|
58
|
-
return
|
|
58
|
+
return t(this, E);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
|
|
62
|
-
var
|
|
63
|
-
class
|
|
61
|
+
A = new WeakMap(), c = new WeakMap(), g = new WeakMap(), E = new WeakMap();
|
|
62
|
+
var m, a, x, N, p, b, D;
|
|
63
|
+
class G extends HTMLElement {
|
|
64
64
|
constructor() {
|
|
65
65
|
super(...arguments);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
r(this, p);
|
|
67
|
+
r(this, m, "");
|
|
68
|
+
r(this, a, []);
|
|
69
|
+
r(this, x, []);
|
|
70
|
+
r(this, N, null);
|
|
71
71
|
}
|
|
72
72
|
get wordsArray() {
|
|
73
|
-
return
|
|
73
|
+
return t(this, a);
|
|
74
74
|
}
|
|
75
75
|
get lettersArray() {
|
|
76
|
-
return
|
|
76
|
+
return t(this, x);
|
|
77
77
|
}
|
|
78
78
|
get originalHTML() {
|
|
79
|
-
return
|
|
79
|
+
return t(this, m);
|
|
80
80
|
}
|
|
81
81
|
connectedCallback() {
|
|
82
|
-
|
|
83
|
-
s.current ?
|
|
84
|
-
})) :
|
|
82
|
+
o(this, m, this.innerHTML.trim()), this.hasAttribute("media") ? (o(this, N, new S(this.getAttribute("media"))), t(this, N).subscribe((s) => {
|
|
83
|
+
s.current ? T(this, p, b).call(this) : !s.current && s.previous && T(this, p, D).call(this);
|
|
84
|
+
})) : T(this, p, b).call(this);
|
|
85
85
|
}
|
|
86
86
|
disconnectedCallback() {
|
|
87
87
|
var s;
|
|
88
|
-
|
|
88
|
+
T(this, p, D).call(this), (s = t(this, N)) == null || s.close();
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
|
|
91
|
+
m = new WeakMap(), a = new WeakMap(), x = new WeakMap(), N = new WeakMap(), p = new WeakSet(), b = function() {
|
|
92
92
|
const s = [];
|
|
93
|
-
|
|
94
|
-
let
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
93
|
+
o(this, a, []);
|
|
94
|
+
let u = 0, h = 0;
|
|
95
|
+
const $ = (i) => {
|
|
96
|
+
var f;
|
|
97
|
+
const l = (f = i.textContent) == null ? void 0 : f.trim();
|
|
98
|
+
if (!l) return document.createDocumentFragment();
|
|
99
|
+
const L = document.createDocumentFragment();
|
|
100
|
+
return l.replace(/ +/g, " ").split(" ").forEach((M, v, C) => {
|
|
101
|
+
if (!M) return;
|
|
102
|
+
const w = new k({
|
|
103
|
+
index: u,
|
|
104
|
+
text: M + (v < C.length - 1 ? " " : ""),
|
|
100
105
|
letters: this.hasAttribute("letters"),
|
|
101
106
|
lettersAcc: h,
|
|
102
107
|
clone: this.hasAttribute("clone")
|
|
103
108
|
});
|
|
104
|
-
h +=
|
|
105
|
-
})
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
h += w.letters.length, u += 1, t(this, x).push(...w.letters), t(this, a).push(w), L.appendChild(w.element);
|
|
110
|
+
}), L;
|
|
111
|
+
}, O = (i) => {
|
|
112
|
+
if (i.nodeType === Node.TEXT_NODE)
|
|
113
|
+
return $(i);
|
|
114
|
+
if (i.nodeType === Node.ELEMENT_NODE) {
|
|
115
|
+
const l = i.cloneNode(!1);
|
|
116
|
+
return Array.from(i.childNodes).forEach((L) => {
|
|
117
|
+
const f = O(L);
|
|
118
|
+
f && (f.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? Array.from(f.childNodes).forEach((M, v, C) => {
|
|
119
|
+
l.append(M), v !== C.length - 1 && l.append(new Text(" "));
|
|
120
|
+
}) : l.appendChild(f));
|
|
121
|
+
}), l;
|
|
122
|
+
}
|
|
123
|
+
return i.cloneNode();
|
|
124
|
+
};
|
|
125
|
+
Array.from(this.childNodes).forEach((i) => {
|
|
126
|
+
const l = O(i);
|
|
127
|
+
l.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? s.push(...Array.from(l.childNodes)) : s.push(l);
|
|
128
|
+
}), this.hasAttribute("index") && (t(this, a).forEach((i) => {
|
|
129
|
+
i.element.style.setProperty("--word-index", i.index.toString());
|
|
130
|
+
}), t(this, x).forEach((i) => {
|
|
131
|
+
i.element.style.setProperty(
|
|
110
132
|
"--letter-index",
|
|
111
|
-
|
|
133
|
+
i.index.toString()
|
|
112
134
|
);
|
|
113
|
-
})), this.innerHTML = "", s.forEach((
|
|
114
|
-
this.appendChild(
|
|
115
|
-
}), this.style.setProperty("--words-length",
|
|
116
|
-
},
|
|
117
|
-
|
|
135
|
+
})), this.innerHTML = "", s.forEach((i, l) => {
|
|
136
|
+
this.appendChild(i), l < s.length - 1 && i.nodeType === Node.ELEMENT_NODE && this.appendChild(new Text(" "));
|
|
137
|
+
}), this.style.setProperty("--words-length", t(this, a).length.toString()), this.style.setProperty("--letters-length", t(this, x).length.toString());
|
|
138
|
+
}, D = function() {
|
|
139
|
+
o(this, a, []), this.innerHTML = t(this, m), this.style.removeProperty("--words-length"), this.style.removeProperty("--letters-length");
|
|
118
140
|
};
|
|
119
|
-
|
|
141
|
+
F && !customElements.get("e-slicer") && customElements.define("e-slicer", G);
|
|
120
142
|
export {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
143
|
+
P as Letter,
|
|
144
|
+
G as SlicerElement,
|
|
145
|
+
k as Word
|
|
124
146
|
};
|