aptechka 0.78.2 → 0.78.4
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 +97 -72
- package/package.json +1 -1
package/lib/slicer/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var O=n=>{throw TypeError(n)};var C=(n,e,s)=>e.has(n)||O("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)?O("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 F{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 A,h,f,E;class S{constructor(e){l(this,A);l(this,h);l(this,f);l(this,E);if(o(this,A,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 F({index:e.lettersAcc+s++,text:c,clone:e.clone})});o(this,f,p.filter(c=>c instanceof F)),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,A)}get element(){return t(this,h)}get letters(){return t(this,f)}get hasNewLine(){return t(this,E)}}A=new WeakMap,h=new WeakMap,f=new WeakMap,E=new WeakMap;var N,a,x,T,u,H,D;class P 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,H).call(this):!s.current&&s.previous&&m(this,u,D).call(this)})):m(this,u,H).call(this)}disconnectedCallback(){var s;m(this,u,D).call(this),(s=t(this,T))==null||s.close()}}N=new WeakMap,a=new WeakMap,x=new WeakMap,T=new WeakMap,u=new WeakSet,H=function(){const s=[];o(this,a,[]);let p=0,c=0;const $=i=>{var g;const r=(g=i.textContent)==null?void 0:g.trim();if(!r)return document.createDocumentFragment();const L=document.createDocumentFragment();return r.replace(/[\s\u00A0\u1680\u2000-\u200F\u2028\u2029\u202F\u205F\u3000\uFEFF]+/g," ").split(" ").forEach((M,b,v)=>{if(!M)return;const w=new S({index:p,text:M+(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),L.appendChild(w.element)}),L},_=i=>{if(i.nodeType===Node.TEXT_NODE)return $(i);if(i.nodeType===Node.ELEMENT_NODE){const r=i.cloneNode(!1);return Array.from(i.childNodes).forEach(L=>{const g=_(L);g&&(g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?Array.from(g.childNodes).forEach((M,b,v)=>{r.append(M),b!==v.length-1&&r.append(new Text(" "))}):r.appendChild(g))}),r}return i.cloneNode()};Array.from(this.childNodes).forEach(i=>{const r=_(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())},D=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",P);exports.Letter=F;exports.SlicerElement=P;exports.Word=S;
|
package/lib/slicer/index.js
CHANGED
|
@@ -1,124 +1,149 @@
|
|
|
1
|
-
var
|
|
2
|
-
throw TypeError(
|
|
1
|
+
var O = (n) => {
|
|
2
|
+
throw TypeError(n);
|
|
3
3
|
};
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
import { Media as
|
|
7
|
-
import { i as
|
|
4
|
+
var F = (n, e, s) => e.has(n) || O("Cannot " + s);
|
|
5
|
+
var t = (n, e, s) => (F(n, e, "read from private field"), s ? s.call(n) : e.get(n)), r = (n, e, s) => e.has(n) ? O("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, s), o = (n, e, s, p) => (F(n, e, "write to private field"), p ? p.call(n, s) : e.set(n, s), s), T = (n, e, s) => (F(n, e, "access private method"), s);
|
|
6
|
+
import { Media as $ } from "../media/index.js";
|
|
7
|
+
import { i as S } 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 _ {
|
|
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 p =
|
|
33
|
+
const p = e.text.split("").map((h) => {
|
|
34
34
|
if (h !== " ")
|
|
35
|
-
return new
|
|
36
|
-
index:
|
|
35
|
+
return new _({
|
|
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, p.filter((h) => h instanceof _)), 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, u, H, b;
|
|
63
|
+
class G extends HTMLElement {
|
|
64
64
|
constructor() {
|
|
65
65
|
super(...arguments);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
r(this, u);
|
|
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 $(this.getAttribute("media"))), t(this, N).subscribe((s) => {
|
|
83
|
+
s.current ? T(this, u, H).call(this) : !s.current && s.previous && T(this, u, b).call(this);
|
|
84
|
+
})) : T(this, u, H).call(this);
|
|
85
85
|
}
|
|
86
86
|
disconnectedCallback() {
|
|
87
87
|
var s;
|
|
88
|
-
|
|
88
|
+
T(this, u, b).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(), u = new WeakSet(), H = function() {
|
|
92
92
|
const s = [];
|
|
93
|
-
|
|
93
|
+
o(this, a, []);
|
|
94
94
|
let p = 0, h = 0;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
const P = (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(
|
|
101
|
+
/[\s\u00A0\u1680\u2000-\u200F\u2028\u2029\u202F\u205F\u3000\uFEFF]+/g,
|
|
102
|
+
" "
|
|
103
|
+
).split(" ").forEach((M, v, C) => {
|
|
104
|
+
if (!M) return;
|
|
105
|
+
const w = new k({
|
|
98
106
|
index: p,
|
|
99
|
-
text: M + " ",
|
|
107
|
+
text: M + (v < C.length - 1 ? " " : ""),
|
|
100
108
|
letters: this.hasAttribute("letters"),
|
|
101
109
|
lettersAcc: h,
|
|
102
110
|
clone: this.hasAttribute("clone")
|
|
103
111
|
});
|
|
104
|
-
h +=
|
|
105
|
-
})
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
112
|
+
h += w.letters.length, p += 1, t(this, x).push(...w.letters), t(this, a).push(w), L.appendChild(w.element);
|
|
113
|
+
}), L;
|
|
114
|
+
}, D = (i) => {
|
|
115
|
+
if (i.nodeType === Node.TEXT_NODE)
|
|
116
|
+
return P(i);
|
|
117
|
+
if (i.nodeType === Node.ELEMENT_NODE) {
|
|
118
|
+
const l = i.cloneNode(!1);
|
|
119
|
+
return Array.from(i.childNodes).forEach((L) => {
|
|
120
|
+
const f = D(L);
|
|
121
|
+
f && (f.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? Array.from(f.childNodes).forEach((M, v, C) => {
|
|
122
|
+
l.append(M), v !== C.length - 1 && l.append(new Text(" "));
|
|
123
|
+
}) : l.appendChild(f));
|
|
124
|
+
}), l;
|
|
125
|
+
}
|
|
126
|
+
return i.cloneNode();
|
|
127
|
+
};
|
|
128
|
+
Array.from(this.childNodes).forEach((i) => {
|
|
129
|
+
const l = D(i);
|
|
130
|
+
l.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? s.push(...Array.from(l.childNodes)) : s.push(l);
|
|
131
|
+
}), this.hasAttribute("index") && (t(this, a).forEach((i) => {
|
|
132
|
+
i.element.style.setProperty("--word-index", i.index.toString());
|
|
133
|
+
}), t(this, x).forEach((i) => {
|
|
134
|
+
i.element.style.setProperty(
|
|
110
135
|
"--letter-index",
|
|
111
|
-
|
|
136
|
+
i.index.toString()
|
|
112
137
|
);
|
|
113
|
-
})), this.innerHTML = "", s.forEach((
|
|
114
|
-
this.appendChild(
|
|
115
|
-
}), this.style.setProperty("--words-length",
|
|
116
|
-
},
|
|
117
|
-
|
|
138
|
+
})), this.innerHTML = "", s.forEach((i, l) => {
|
|
139
|
+
this.appendChild(i), l < s.length - 1 && i.nodeType === Node.ELEMENT_NODE && this.appendChild(new Text(" "));
|
|
140
|
+
}), this.style.setProperty("--words-length", t(this, a).length.toString()), this.style.setProperty("--letters-length", t(this, x).length.toString());
|
|
141
|
+
}, b = function() {
|
|
142
|
+
o(this, a, []), this.innerHTML = t(this, m), this.style.removeProperty("--words-length"), this.style.removeProperty("--letters-length");
|
|
118
143
|
};
|
|
119
|
-
|
|
144
|
+
S && !customElements.get("e-slicer") && customElements.define("e-slicer", G);
|
|
120
145
|
export {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
146
|
+
_ as Letter,
|
|
147
|
+
G as SlicerElement,
|
|
148
|
+
k as Word
|
|
124
149
|
};
|