aptechka 0.86.0 → 0.87.1
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/css-unit-parser/index.cjs +1 -1
- package/lib/css-unit-parser/index.d.ts +1 -1
- package/lib/css-unit-parser/index.js +5 -1
- package/lib/en3/index.cjs +2 -2
- package/lib/en3/index.d.ts +1 -0
- package/lib/en3/index.js +13 -5
- package/lib/en3/objects/En3ClipHelpers.d.ts +5 -0
- package/lib/layout-box/index.cjs +1 -1
- package/lib/layout-box/index.js +1 -1
- package/lib/notched/NotchedElement.d.ts +11 -0
- package/lib/notched/getSvgPath.d.ts +77 -0
- package/lib/notched/index.d.ts +1 -0
- package/lib/notched.cjs +62 -0
- package/lib/notched.js +470 -0
- package/lib/scroll/index.cjs +1 -1
- package/lib/scroll/index.js +1 -5
- package/package.json +9 -1
package/lib/notched.js
ADDED
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __typeError = (msg) => {
|
|
3
|
+
throw TypeError(msg);
|
|
4
|
+
};
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
6
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
7
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value), __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value), __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
8
|
+
import { cssUnitParser } from "./css-unit-parser/index.js";
|
|
9
|
+
import { elementResizer } from "./element-resizer/index.js";
|
|
10
|
+
import { t as ticker } from "./index-ClTMVKJp.js";
|
|
11
|
+
import { g as generateId } from "./string-B3lm2b7v.js";
|
|
12
|
+
import "construct-style-sheets-polyfill";
|
|
13
|
+
function distributeAndNormalize({
|
|
14
|
+
topLeftCornerRadius,
|
|
15
|
+
topRightCornerRadius,
|
|
16
|
+
bottomRightCornerRadius,
|
|
17
|
+
bottomLeftCornerRadius,
|
|
18
|
+
width,
|
|
19
|
+
height
|
|
20
|
+
}) {
|
|
21
|
+
const roundingAndSmoothingBudgetMap = {
|
|
22
|
+
topLeft: -1,
|
|
23
|
+
topRight: -1,
|
|
24
|
+
bottomLeft: -1,
|
|
25
|
+
bottomRight: -1
|
|
26
|
+
}, cornerRadiusMap = {
|
|
27
|
+
topLeft: topLeftCornerRadius,
|
|
28
|
+
topRight: topRightCornerRadius,
|
|
29
|
+
bottomLeft: bottomLeftCornerRadius,
|
|
30
|
+
bottomRight: bottomRightCornerRadius
|
|
31
|
+
};
|
|
32
|
+
return Object.entries(cornerRadiusMap).sort(([, radius1], [, radius2]) => radius2 - radius1).forEach(([cornerName, radius]) => {
|
|
33
|
+
const corner = cornerName, adjacents = adjacentsByCorner[corner], budget = Math.min(
|
|
34
|
+
...adjacents.map((adjacent) => {
|
|
35
|
+
const adjacentCornerRadius = cornerRadiusMap[adjacent.corner];
|
|
36
|
+
if (radius === 0 && adjacentCornerRadius === 0)
|
|
37
|
+
return 0;
|
|
38
|
+
const adjacentCornerBudget = roundingAndSmoothingBudgetMap[adjacent.corner], sideLength = adjacent.side === "top" || adjacent.side === "bottom" ? width : height;
|
|
39
|
+
return adjacentCornerBudget >= 0 ? sideLength - roundingAndSmoothingBudgetMap[adjacent.corner] : radius / (radius + adjacentCornerRadius) * sideLength;
|
|
40
|
+
})
|
|
41
|
+
);
|
|
42
|
+
roundingAndSmoothingBudgetMap[corner] = budget, cornerRadiusMap[corner] = Math.min(radius, budget);
|
|
43
|
+
}), {
|
|
44
|
+
topLeft: {
|
|
45
|
+
radius: cornerRadiusMap.topLeft,
|
|
46
|
+
roundingAndSmoothingBudget: roundingAndSmoothingBudgetMap.topLeft
|
|
47
|
+
},
|
|
48
|
+
topRight: {
|
|
49
|
+
radius: cornerRadiusMap.topRight,
|
|
50
|
+
roundingAndSmoothingBudget: roundingAndSmoothingBudgetMap.topRight
|
|
51
|
+
},
|
|
52
|
+
bottomLeft: {
|
|
53
|
+
radius: cornerRadiusMap.bottomLeft,
|
|
54
|
+
roundingAndSmoothingBudget: roundingAndSmoothingBudgetMap.bottomLeft
|
|
55
|
+
},
|
|
56
|
+
bottomRight: {
|
|
57
|
+
radius: cornerRadiusMap.bottomRight,
|
|
58
|
+
roundingAndSmoothingBudget: roundingAndSmoothingBudgetMap.bottomRight
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
__name(distributeAndNormalize, "distributeAndNormalize");
|
|
63
|
+
const adjacentsByCorner = {
|
|
64
|
+
topLeft: [
|
|
65
|
+
{
|
|
66
|
+
corner: "topRight",
|
|
67
|
+
side: "top"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
corner: "bottomLeft",
|
|
71
|
+
side: "left"
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
topRight: [
|
|
75
|
+
{
|
|
76
|
+
corner: "topLeft",
|
|
77
|
+
side: "top"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
corner: "bottomRight",
|
|
81
|
+
side: "right"
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
bottomLeft: [
|
|
85
|
+
{
|
|
86
|
+
corner: "bottomRight",
|
|
87
|
+
side: "bottom"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
corner: "topLeft",
|
|
91
|
+
side: "left"
|
|
92
|
+
}
|
|
93
|
+
],
|
|
94
|
+
bottomRight: [
|
|
95
|
+
{
|
|
96
|
+
corner: "bottomLeft",
|
|
97
|
+
side: "bottom"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
corner: "topRight",
|
|
101
|
+
side: "right"
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
};
|
|
105
|
+
function getPathParamsForCorner({
|
|
106
|
+
cornerRadius,
|
|
107
|
+
cornerSmoothing,
|
|
108
|
+
preserveSmoothing,
|
|
109
|
+
roundingAndSmoothingBudget,
|
|
110
|
+
cornerAngleAlpha = 90
|
|
111
|
+
}) {
|
|
112
|
+
let p = (1 + cornerSmoothing) * cornerRadius;
|
|
113
|
+
if (!preserveSmoothing) {
|
|
114
|
+
const maxCornerSmoothing = roundingAndSmoothingBudget / cornerRadius - 1;
|
|
115
|
+
cornerSmoothing = Math.min(cornerSmoothing, maxCornerSmoothing), p = Math.min(p, roundingAndSmoothingBudget);
|
|
116
|
+
}
|
|
117
|
+
const arcMeasure = 90 * (1 - cornerSmoothing), arcSectionLength = Math.sin(toRadians(arcMeasure / 2)) * cornerRadius * Math.sqrt(2), angleAlpha = (cornerAngleAlpha - arcMeasure) / 2, p3ToP4Distance = cornerRadius * Math.tan(toRadians(angleAlpha / 2)), angleBeta = 45 * cornerSmoothing, c = p3ToP4Distance * Math.cos(toRadians(angleBeta)), d = c * Math.tan(toRadians(angleBeta));
|
|
118
|
+
let b = (p - arcSectionLength - c - d) / 3, a = 2 * b;
|
|
119
|
+
if (preserveSmoothing && p > roundingAndSmoothingBudget) {
|
|
120
|
+
const p1ToP3MaxDistance = roundingAndSmoothingBudget - d - arcSectionLength - c, minA = p1ToP3MaxDistance / 6, maxB = p1ToP3MaxDistance - minA;
|
|
121
|
+
b = Math.min(b, maxB), a = p1ToP3MaxDistance - b, p = Math.min(p, roundingAndSmoothingBudget);
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
a,
|
|
125
|
+
b,
|
|
126
|
+
c,
|
|
127
|
+
d,
|
|
128
|
+
p,
|
|
129
|
+
arcSectionLength,
|
|
130
|
+
cornerRadius
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
__name(getPathParamsForCorner, "getPathParamsForCorner");
|
|
134
|
+
function getSVGPathFromPathParams({
|
|
135
|
+
width,
|
|
136
|
+
height,
|
|
137
|
+
topLeftPathParams,
|
|
138
|
+
topRightPathParams,
|
|
139
|
+
bottomLeftPathParams,
|
|
140
|
+
bottomRightPathParams,
|
|
141
|
+
topNotches = [],
|
|
142
|
+
rightNotches = [],
|
|
143
|
+
bottomNotches = [],
|
|
144
|
+
leftNotches = []
|
|
145
|
+
}) {
|
|
146
|
+
let d = `M ${topLeftPathParams.p} 0`;
|
|
147
|
+
return topNotches.forEach((n) => {
|
|
148
|
+
d += drawTopNotch(n);
|
|
149
|
+
}), d += `L ${width - topRightPathParams.p} 0`, d += drawTopRightPath(topRightPathParams), rightNotches.forEach((n) => {
|
|
150
|
+
d += drawRightNotch(n, width);
|
|
151
|
+
}), d += `L ${width} ${height - bottomRightPathParams.p}`, d += drawBottomRightPath(bottomRightPathParams), bottomNotches.forEach((n) => {
|
|
152
|
+
d += drawBottomNotch(n, height);
|
|
153
|
+
}), d += `L ${bottomLeftPathParams.p} ${height}`, d += drawBottomLeftPath(bottomLeftPathParams), leftNotches.forEach((n) => {
|
|
154
|
+
d += drawLeftNotch(n);
|
|
155
|
+
}), d += `L 0 ${topLeftPathParams.p}`, d += drawTopLeftPath(topLeftPathParams), d += "Z", d.replace(/[\t\s\n]+/g, " ").trim();
|
|
156
|
+
}
|
|
157
|
+
__name(getSVGPathFromPathParams, "getSVGPathFromPathParams");
|
|
158
|
+
function drawTopNotch({ start, length, slope, depth }) {
|
|
159
|
+
const end = start + length;
|
|
160
|
+
return `
|
|
161
|
+
L${start} 0
|
|
162
|
+
C ${start + slope * 0.5},0 ${start + slope * 0.5},${depth} ${start + slope},${depth}
|
|
163
|
+
L${end - slope},${depth}
|
|
164
|
+
C ${end - slope * 0.5},${depth} ${end - slope * 0.5},0 ${end},0
|
|
165
|
+
`;
|
|
166
|
+
}
|
|
167
|
+
__name(drawTopNotch, "drawTopNotch");
|
|
168
|
+
function drawBottomNotch({ start, length, slope, depth }, height) {
|
|
169
|
+
const end = start + length;
|
|
170
|
+
return `
|
|
171
|
+
L${end},${height}
|
|
172
|
+
C ${end - slope * 0.5},${height} ${end - slope * 0.5},${height - depth} ${end - slope},${height - depth}
|
|
173
|
+
L${start + slope},${height - depth}
|
|
174
|
+
C ${start + slope * 0.5},${height - depth} ${start + slope * 0.5},${height} ${start},${height}
|
|
175
|
+
`;
|
|
176
|
+
}
|
|
177
|
+
__name(drawBottomNotch, "drawBottomNotch");
|
|
178
|
+
function drawLeftNotch({ start, length, slope, depth }) {
|
|
179
|
+
const end = start + length;
|
|
180
|
+
return `
|
|
181
|
+
L0,${end}
|
|
182
|
+
C 0,${end - slope * 0.5} ${depth},${end - slope * 0.5} ${depth},${end - slope}
|
|
183
|
+
L${depth},${start + slope}
|
|
184
|
+
C ${depth},${start + slope * 0.5} 0,${start + slope * 0.5} 0,${start}
|
|
185
|
+
`;
|
|
186
|
+
}
|
|
187
|
+
__name(drawLeftNotch, "drawLeftNotch");
|
|
188
|
+
function drawRightNotch({ start, length, slope, depth }, width) {
|
|
189
|
+
const end = start + length;
|
|
190
|
+
return `
|
|
191
|
+
L${width},${start}
|
|
192
|
+
C ${width},${start + slope * 0.5} ${width - depth},${start + slope * 0.5} ${width - depth},${start + slope}
|
|
193
|
+
L${width - depth},${end - slope}
|
|
194
|
+
C ${width - depth},${end - slope * 0.5} ${width},${end - slope * 0.5} ${width},${end}
|
|
195
|
+
`;
|
|
196
|
+
}
|
|
197
|
+
__name(drawRightNotch, "drawRightNotch");
|
|
198
|
+
function drawTopRightPath({
|
|
199
|
+
cornerRadius,
|
|
200
|
+
a,
|
|
201
|
+
b,
|
|
202
|
+
c,
|
|
203
|
+
d,
|
|
204
|
+
p,
|
|
205
|
+
arcSectionLength
|
|
206
|
+
}) {
|
|
207
|
+
return cornerRadius ? rounded`
|
|
208
|
+
c ${a} 0 ${a + b} 0 ${a + b + c} ${d}
|
|
209
|
+
a ${cornerRadius} ${cornerRadius} 0 0 1 ${arcSectionLength} ${arcSectionLength}
|
|
210
|
+
c ${d} ${c}
|
|
211
|
+
${d} ${b + c}
|
|
212
|
+
${d} ${a + b + c}` : rounded`l ${p} 0`;
|
|
213
|
+
}
|
|
214
|
+
__name(drawTopRightPath, "drawTopRightPath");
|
|
215
|
+
function drawBottomRightPath({
|
|
216
|
+
cornerRadius,
|
|
217
|
+
a,
|
|
218
|
+
b,
|
|
219
|
+
c,
|
|
220
|
+
d,
|
|
221
|
+
p,
|
|
222
|
+
arcSectionLength
|
|
223
|
+
}) {
|
|
224
|
+
return cornerRadius ? rounded`
|
|
225
|
+
c 0 ${a}
|
|
226
|
+
0 ${a + b}
|
|
227
|
+
${-d} ${a + b + c}
|
|
228
|
+
a ${cornerRadius} ${cornerRadius} 0 0 1 -${arcSectionLength} ${arcSectionLength}
|
|
229
|
+
c ${-c} ${d}
|
|
230
|
+
${-(b + c)} ${d}
|
|
231
|
+
${-(a + b + c)} ${d}` : rounded`l 0 ${p}`;
|
|
232
|
+
}
|
|
233
|
+
__name(drawBottomRightPath, "drawBottomRightPath");
|
|
234
|
+
function drawBottomLeftPath({
|
|
235
|
+
cornerRadius,
|
|
236
|
+
a,
|
|
237
|
+
b,
|
|
238
|
+
c,
|
|
239
|
+
d,
|
|
240
|
+
p,
|
|
241
|
+
arcSectionLength
|
|
242
|
+
}) {
|
|
243
|
+
return cornerRadius ? rounded`
|
|
244
|
+
c ${-a} 0
|
|
245
|
+
${-(a + b)} 0
|
|
246
|
+
${-(a + b + c)} ${-d}
|
|
247
|
+
a ${cornerRadius} ${cornerRadius} 0 0 1 -${arcSectionLength} -${arcSectionLength}
|
|
248
|
+
c ${-d} ${-c}
|
|
249
|
+
${-d} ${-(b + c)}
|
|
250
|
+
${-d} ${-(a + b + c)}` : rounded`l ${-p} 0`;
|
|
251
|
+
}
|
|
252
|
+
__name(drawBottomLeftPath, "drawBottomLeftPath");
|
|
253
|
+
function drawTopLeftPath({
|
|
254
|
+
cornerRadius,
|
|
255
|
+
a,
|
|
256
|
+
b,
|
|
257
|
+
c,
|
|
258
|
+
d,
|
|
259
|
+
p,
|
|
260
|
+
arcSectionLength
|
|
261
|
+
}) {
|
|
262
|
+
return cornerRadius ? rounded`
|
|
263
|
+
c 0 ${-a}
|
|
264
|
+
0 ${-(a + b)}
|
|
265
|
+
${d} ${-(a + b + c)}
|
|
266
|
+
a ${cornerRadius} ${cornerRadius} 0 0 1 ${arcSectionLength} -${arcSectionLength}
|
|
267
|
+
c ${c} ${-d}
|
|
268
|
+
${b + c} ${-d}
|
|
269
|
+
${a + b + c} ${-d}` : rounded`l 0 ${-p}`;
|
|
270
|
+
}
|
|
271
|
+
__name(drawTopLeftPath, "drawTopLeftPath");
|
|
272
|
+
function toRadians(degrees) {
|
|
273
|
+
return degrees * Math.PI / 180;
|
|
274
|
+
}
|
|
275
|
+
__name(toRadians, "toRadians");
|
|
276
|
+
function rounded(strings, ...values) {
|
|
277
|
+
return strings.reduce((acc, str, i) => {
|
|
278
|
+
const value = values[i];
|
|
279
|
+
return typeof value == "number" ? acc + str + value.toFixed(4) : acc + str + (value != null ? value : "");
|
|
280
|
+
}, "");
|
|
281
|
+
}
|
|
282
|
+
__name(rounded, "rounded");
|
|
283
|
+
function getSvgPath({
|
|
284
|
+
cornerRadius = 0,
|
|
285
|
+
topLeftCornerRadius,
|
|
286
|
+
topRightCornerRadius,
|
|
287
|
+
bottomRightCornerRadius,
|
|
288
|
+
bottomLeftCornerRadius,
|
|
289
|
+
cornerAngleAlpha = 90,
|
|
290
|
+
topLeftCornerAngleAlpha,
|
|
291
|
+
topRightCornerAngleAlpha,
|
|
292
|
+
bottomRightCornerAngleAlpha,
|
|
293
|
+
bottomLeftCornerAngleAlpha,
|
|
294
|
+
cornerSmoothing,
|
|
295
|
+
preserveSmoothing = !1,
|
|
296
|
+
topNotches,
|
|
297
|
+
rightNotches,
|
|
298
|
+
bottomNotches,
|
|
299
|
+
leftNotches,
|
|
300
|
+
width,
|
|
301
|
+
height
|
|
302
|
+
}) {
|
|
303
|
+
if (topLeftCornerRadius = topLeftCornerRadius != null ? topLeftCornerRadius : cornerRadius, topRightCornerRadius = topRightCornerRadius != null ? topRightCornerRadius : cornerRadius, bottomLeftCornerRadius = bottomLeftCornerRadius != null ? bottomLeftCornerRadius : cornerRadius, bottomRightCornerRadius = bottomRightCornerRadius != null ? bottomRightCornerRadius : cornerRadius, topLeftCornerAngleAlpha = topLeftCornerAngleAlpha != null ? topLeftCornerAngleAlpha : cornerAngleAlpha, topRightCornerAngleAlpha = topRightCornerAngleAlpha != null ? topRightCornerAngleAlpha : cornerAngleAlpha, bottomLeftCornerAngleAlpha = bottomLeftCornerAngleAlpha != null ? bottomLeftCornerAngleAlpha : cornerAngleAlpha, bottomRightCornerAngleAlpha = bottomRightCornerAngleAlpha != null ? bottomRightCornerAngleAlpha : cornerAngleAlpha, topLeftCornerRadius === topRightCornerRadius && topRightCornerRadius === bottomRightCornerRadius && bottomRightCornerRadius === bottomLeftCornerRadius && bottomLeftCornerRadius === topLeftCornerRadius && topLeftCornerAngleAlpha === topRightCornerAngleAlpha && topRightCornerAngleAlpha === bottomRightCornerAngleAlpha && bottomRightCornerAngleAlpha === bottomLeftCornerAngleAlpha && bottomLeftCornerAngleAlpha === topLeftCornerAngleAlpha) {
|
|
304
|
+
const roundingAndSmoothingBudget = Math.min(width, height) / 2, cornerRadius2 = Math.min(
|
|
305
|
+
topLeftCornerRadius,
|
|
306
|
+
roundingAndSmoothingBudget
|
|
307
|
+
), pathParams = getPathParamsForCorner({
|
|
308
|
+
cornerRadius: cornerRadius2,
|
|
309
|
+
cornerSmoothing,
|
|
310
|
+
cornerAngleAlpha,
|
|
311
|
+
preserveSmoothing,
|
|
312
|
+
roundingAndSmoothingBudget
|
|
313
|
+
});
|
|
314
|
+
return getSVGPathFromPathParams({
|
|
315
|
+
width,
|
|
316
|
+
height,
|
|
317
|
+
topLeftPathParams: pathParams,
|
|
318
|
+
topRightPathParams: pathParams,
|
|
319
|
+
bottomLeftPathParams: pathParams,
|
|
320
|
+
bottomRightPathParams: pathParams,
|
|
321
|
+
topNotches,
|
|
322
|
+
rightNotches,
|
|
323
|
+
bottomNotches,
|
|
324
|
+
leftNotches
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
const { topLeft, topRight, bottomLeft, bottomRight } = distributeAndNormalize(
|
|
328
|
+
{
|
|
329
|
+
topLeftCornerRadius,
|
|
330
|
+
topRightCornerRadius,
|
|
331
|
+
bottomRightCornerRadius,
|
|
332
|
+
bottomLeftCornerRadius,
|
|
333
|
+
width,
|
|
334
|
+
height
|
|
335
|
+
}
|
|
336
|
+
);
|
|
337
|
+
return getSVGPathFromPathParams({
|
|
338
|
+
width,
|
|
339
|
+
height,
|
|
340
|
+
topLeftPathParams: getPathParamsForCorner({
|
|
341
|
+
cornerSmoothing,
|
|
342
|
+
preserveSmoothing,
|
|
343
|
+
cornerRadius: topLeft.radius,
|
|
344
|
+
roundingAndSmoothingBudget: topLeft.roundingAndSmoothingBudget,
|
|
345
|
+
cornerAngleAlpha: topLeftCornerAngleAlpha
|
|
346
|
+
}),
|
|
347
|
+
topRightPathParams: getPathParamsForCorner({
|
|
348
|
+
cornerSmoothing,
|
|
349
|
+
preserveSmoothing,
|
|
350
|
+
cornerRadius: topRight.radius,
|
|
351
|
+
roundingAndSmoothingBudget: topRight.roundingAndSmoothingBudget,
|
|
352
|
+
cornerAngleAlpha: topRightCornerAngleAlpha
|
|
353
|
+
}),
|
|
354
|
+
bottomRightPathParams: getPathParamsForCorner({
|
|
355
|
+
cornerSmoothing,
|
|
356
|
+
preserveSmoothing,
|
|
357
|
+
cornerRadius: bottomRight.radius,
|
|
358
|
+
roundingAndSmoothingBudget: bottomRight.roundingAndSmoothingBudget,
|
|
359
|
+
cornerAngleAlpha: bottomRightCornerAngleAlpha
|
|
360
|
+
}),
|
|
361
|
+
bottomLeftPathParams: getPathParamsForCorner({
|
|
362
|
+
cornerSmoothing,
|
|
363
|
+
preserveSmoothing,
|
|
364
|
+
cornerRadius: bottomLeft.radius,
|
|
365
|
+
roundingAndSmoothingBudget: bottomLeft.roundingAndSmoothingBudget,
|
|
366
|
+
cornerAngleAlpha: bottomLeftCornerAngleAlpha
|
|
367
|
+
}),
|
|
368
|
+
topNotches,
|
|
369
|
+
rightNotches,
|
|
370
|
+
bottomNotches,
|
|
371
|
+
leftNotches
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
__name(getSvgPath, "getSvgPath");
|
|
375
|
+
var _svgElement, _pathElement, _resizeListener, _NotchedElement_instances, parseCSSNotchValue_fn;
|
|
376
|
+
const _NotchedElement = class _NotchedElement extends HTMLElement {
|
|
377
|
+
constructor() {
|
|
378
|
+
super();
|
|
379
|
+
__privateAdd(this, _NotchedElement_instances);
|
|
380
|
+
__privateAdd(this, _svgElement);
|
|
381
|
+
__privateAdd(this, _pathElement);
|
|
382
|
+
__privateAdd(this, _resizeListener, /* @__PURE__ */ __name(() => {
|
|
383
|
+
const width = this.offsetWidth, height = this.offsetHeight, computed = getComputedStyle(this);
|
|
384
|
+
__privateGet(this, _svgElement).setAttributeNS(
|
|
385
|
+
"http://www.w3.org/2000/svg",
|
|
386
|
+
"viewBox",
|
|
387
|
+
`0 0 ${width} ${height}`
|
|
388
|
+
);
|
|
389
|
+
const cornerRadius = cssUnitParser.parse(
|
|
390
|
+
computed.getPropertyValue("--notched-corner-radius")
|
|
391
|
+
), topLeftCornerRadius = cssUnitParser.parse(
|
|
392
|
+
computed.getPropertyValue("--notched-top-left-corner-radius")
|
|
393
|
+
), topRightCornerRadius = cssUnitParser.parse(
|
|
394
|
+
computed.getPropertyValue("--notched-top-right-corner-radius")
|
|
395
|
+
), bottomRightCornerRadius = cssUnitParser.parse(
|
|
396
|
+
computed.getPropertyValue("--notched-bottom-right-corner-radius")
|
|
397
|
+
), bottomLeftCornerRadius = cssUnitParser.parse(
|
|
398
|
+
computed.getPropertyValue("--notched-bottom-left-corner-radius")
|
|
399
|
+
), cornerAngleAlpha = parseFloat(computed.getPropertyValue("--notched-corner-angle-alpha")) || void 0, topLeftCornerAngleAlpha = parseFloat(
|
|
400
|
+
computed.getPropertyValue("--notched-top-left-corner-angle-alpha")
|
|
401
|
+
) || void 0, topRightCornerAngleAlpha = parseFloat(
|
|
402
|
+
computed.getPropertyValue("--notched-top-right-corner-angle-alpha")
|
|
403
|
+
) || void 0, bottomRightCornerAngleAlpha = parseFloat(
|
|
404
|
+
computed.getPropertyValue("--notched-bottom-right-corner-angle-alpha")
|
|
405
|
+
) || void 0, bottomLeftCornerAngleAlpha = parseFloat(
|
|
406
|
+
computed.getPropertyValue("--notched-bottom-left-corner-angle-alpha")
|
|
407
|
+
) || void 0, cornerSmoothing = parseFloat(computed.getPropertyValue("--notched-corner-smoothing")) || 0, preserveSmoothing = computed.getPropertyValue("--notched-preserve-smoothing") !== "false", topNotches = __privateMethod(this, _NotchedElement_instances, parseCSSNotchValue_fn).call(this, computed.getPropertyValue("--notched-top-notches")), rightNotches = __privateMethod(this, _NotchedElement_instances, parseCSSNotchValue_fn).call(this, computed.getPropertyValue("--notched-right-notches")), bottomNotches = __privateMethod(this, _NotchedElement_instances, parseCSSNotchValue_fn).call(this, computed.getPropertyValue("--notched-bottom-notches")), leftNotches = __privateMethod(this, _NotchedElement_instances, parseCSSNotchValue_fn).call(this, computed.getPropertyValue("--notched-left-notches")), color = computed.getPropertyValue("--notched-color"), path = getSvgPath({
|
|
408
|
+
cornerRadius,
|
|
409
|
+
topLeftCornerRadius,
|
|
410
|
+
topRightCornerRadius,
|
|
411
|
+
bottomRightCornerRadius,
|
|
412
|
+
bottomLeftCornerRadius,
|
|
413
|
+
cornerAngleAlpha,
|
|
414
|
+
topLeftCornerAngleAlpha,
|
|
415
|
+
topRightCornerAngleAlpha,
|
|
416
|
+
bottomRightCornerAngleAlpha,
|
|
417
|
+
bottomLeftCornerAngleAlpha,
|
|
418
|
+
cornerSmoothing,
|
|
419
|
+
preserveSmoothing,
|
|
420
|
+
topNotches,
|
|
421
|
+
rightNotches,
|
|
422
|
+
bottomNotches,
|
|
423
|
+
leftNotches,
|
|
424
|
+
width,
|
|
425
|
+
height
|
|
426
|
+
});
|
|
427
|
+
__privateGet(this, _pathElement).setAttribute("d", path), color && __privateGet(this, _pathElement).setAttribute("fill", color);
|
|
428
|
+
}, "#resizeListener"));
|
|
429
|
+
const clipId = this.hasAttribute("clip") ? "clip-" + generateId(10) : null, tmpElement = document.createElement("div");
|
|
430
|
+
tmpElement.innerHTML = `
|
|
431
|
+
<svg xmlns="http://www.w3.org/2000/svg">
|
|
432
|
+
${clipId ? `<clipPath id="${clipId}">` : ""}
|
|
433
|
+
<path></path>
|
|
434
|
+
${clipId ? "</clipPath>" : ""}
|
|
435
|
+
</svg>
|
|
436
|
+
<slot></slot>
|
|
437
|
+
`, clipId && (this.style.clipPath = `url(#${clipId})`), this.style.position = "relative", __privateSet(this, _svgElement, tmpElement.querySelector("svg")), __privateGet(this, _svgElement).style.cssText = `
|
|
438
|
+
position: absolute;
|
|
439
|
+
top: 0;
|
|
440
|
+
left: 0;
|
|
441
|
+
zIndex: -1;
|
|
442
|
+
display: block;
|
|
443
|
+
width: 100%;
|
|
444
|
+
height: 100%;
|
|
445
|
+
`, __privateSet(this, _pathElement, tmpElement.querySelector("path")), this.prepend(tmpElement.firstElementChild);
|
|
446
|
+
}
|
|
447
|
+
connectedCallback() {
|
|
448
|
+
elementResizer.subscribe(this, __privateGet(this, _resizeListener)), ticker.subscribe(__privateGet(this, _resizeListener));
|
|
449
|
+
}
|
|
450
|
+
disconnectedCallback() {
|
|
451
|
+
elementResizer.unsubscribe(__privateGet(this, _resizeListener));
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
_svgElement = new WeakMap(), _pathElement = new WeakMap(), _resizeListener = new WeakMap(), _NotchedElement_instances = new WeakSet(), parseCSSNotchValue_fn = /* @__PURE__ */ __name(function(value) {
|
|
455
|
+
const notchesString = value.split(",").map((v) => v.trim()).filter((v) => !!v), notches = [];
|
|
456
|
+
return notchesString.forEach((notchString) => {
|
|
457
|
+
const valuesStrings = notchString.split(" ").map((v) => v.trim()).filter((v) => !!v);
|
|
458
|
+
notches.push({
|
|
459
|
+
start: cssUnitParser.parse(valuesStrings[0]) || 0,
|
|
460
|
+
length: cssUnitParser.parse(valuesStrings[1]) || 0,
|
|
461
|
+
slope: cssUnitParser.parse(valuesStrings[2]) || 0,
|
|
462
|
+
depth: cssUnitParser.parse(valuesStrings[3]) || 0
|
|
463
|
+
});
|
|
464
|
+
}), notches;
|
|
465
|
+
}, "#parseCSSNotchValue"), __name(_NotchedElement, "NotchedElement");
|
|
466
|
+
let NotchedElement = _NotchedElement;
|
|
467
|
+
customElements.get("e-notched") || customElements.define("e-notched", NotchedElement);
|
|
468
|
+
export {
|
|
469
|
+
NotchedElement
|
|
470
|
+
};
|