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