@decidables/discountable-elements 0.6.3 → 0.6.5
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/CHANGELOG.md +19 -0
- package/lib/discountableElements.esm.js +48 -71
- package/lib/discountableElements.esm.js.map +1 -1
- package/lib/discountableElements.esm.min.js +64 -47
- package/lib/discountableElements.esm.min.js.map +1 -1
- package/lib/discountableElements.umd.js +48 -71
- package/lib/discountableElements.umd.js.map +1 -1
- package/lib/discountableElements.umd.min.js +64 -47
- package/lib/discountableElements.umd.min.js.map +1 -1
- package/package.json +5 -5
- package/src/components/discountable-control.js +1 -1
- package/src/components/discountable-response.js +1 -1
- package/src/components/htd-calculation.js +1 -1
- package/src/components/htd-curves.js +31 -7
- package/src/components/htd-fit.js +1 -1
- package/src/components/htd-parameters.js +1 -1
- package/src/components/itc-choice.js +1 -1
- package/src/components/itc-option.js +1 -1
- package/src/components/itc-task.js +1 -1
- package/src/examples/htd-example.js +1 -1
|
@@ -10356,54 +10356,12 @@
|
|
|
10356
10356
|
const ambientS = rotate ? `${-ambientM.y}px ${ambientM.y / 2}px ${ambientM.b}px ${ambientM.s}px` : `${ambientM.y / 2}px ${ambientM.y}px ${ambientM.b}px ${ambientM.s}px`;
|
|
10357
10357
|
return `${umbraS} ${umbraC}, ${penumbraS} ${penumbraC}, ${ambientS} ${ambientC}`;
|
|
10358
10358
|
}
|
|
10359
|
-
static get svgDefs() {
|
|
10360
|
-
const shadows = DecidablesElement.shadows; /* eslint-disable-line prefer-destructuring */
|
|
10361
|
-
|
|
10362
|
-
const filters = shadows.elevations.map(z => {
|
|
10363
|
-
return `
|
|
10364
|
-
<filter id=${`shadow-${z}`} filterUnits="userSpaceOnUse" x="-100%" y="-100%" width="200%" height="200%">
|
|
10365
|
-
<feComponentTransfer in="SourceAlpha" result="solid">
|
|
10366
|
-
<feFuncA type="table" tableValues="0 1 1"/>
|
|
10367
|
-
</feComponentTransfer>
|
|
10368
|
-
<feOffset in="solid" result="offU" dx=${shadows.mapUmbra[z].y / 2} dy=${shadows.mapUmbra[z].y} />
|
|
10369
|
-
<feOffset in="solid" result="offP" dx=${shadows.mapPenumbra[z].y / 2} dy=${shadows.mapPenumbra[z].y} />
|
|
10370
|
-
<feOffset in="solid" result="offA" dx=${shadows.mapAmbient[z].y / 2} dy=${shadows.mapAmbient[z].y} />
|
|
10371
|
-
${shadows.mapUmbra[z].s === 0 ? '' : `<feMorphology in="offU" result="spreadU" operator=${shadows.mapUmbra[z].s > 0 ? 'dilate' : 'erode'} radius=${Math.abs(shadows.mapUmbra[z].s)} />`}
|
|
10372
|
-
${shadows.mapPenumbra[z].s === 0 ? '' : `<feMorphology in="offP" result="spreadP" operator=${shadows.mapPenumbra[z].s > 0 ? 'dilate' : 'erode'} radius=${Math.abs(shadows.mapPenumbra[z].s)} />`}
|
|
10373
|
-
${shadows.mapAmbient[z].s === 0 ? '' : `<feMorphology in="offA" result="spreadA" operator=${shadows.mapAmbient[z].s > 0 ? 'dilate' : 'erode'} radius=${Math.abs(shadows.mapAmbient[z].s)} />`}
|
|
10374
|
-
<feGaussianBlur in=${shadows.mapUmbra[z].s === 0 ? 'offU' : 'spreadU'} result="blurU" stdDeviation=${shadows.mapUmbra[z].b / 2} />
|
|
10375
|
-
<feGaussianBlur in=${shadows.mapPenumbra[z].s === 0 ? 'offP' : 'spreadP'} result="blurP" stdDeviation=${shadows.mapPenumbra[z].b / 2} />
|
|
10376
|
-
<feGaussianBlur in=${shadows.mapAmbient[z].s === 0 ? 'offA' : 'spreadA'} result="blurA" stdDeviation=${shadows.mapAmbient[z].b / 2} />
|
|
10377
|
-
<feFlood in="SourceGraphic" result="opU" flood-color=${shadows.baselineColor} flood-opacity=${shadows.opacityUmbra + shadows.opacityBoost} />
|
|
10378
|
-
<feFlood in="SourceGraphic" result="opP" flood-color=${shadows.baselineColor} flood-opacity=${shadows.opacityPenumbra + shadows.opacityBoost} />
|
|
10379
|
-
<feFlood in="SourceGraphic" result="opA" flood-color=${shadows.baselineColor} flood-opacity=${shadows.opacityAmbient + shadows.opacityBoost} />
|
|
10380
|
-
<feComposite in="opU" in2="blurU" result="shU" operator="in" />
|
|
10381
|
-
<feComposite in="opP" in2="blurP" result="shP" operator="in" />
|
|
10382
|
-
<feComposite in="opA" in2="blurA" result="shA" operator="in" />
|
|
10383
|
-
<feMorphology in="solid" result="smaller" operator="erode" radius="1" />
|
|
10384
|
-
<feComposite in="shU" in2="smaller" result="finalU" operator="out" />
|
|
10385
|
-
<feComposite in="shP" in2="smaller" result="finalP" operator="out" />
|
|
10386
|
-
<feComposite in="shA" in2="smaller" result="finalA" operator="out" />
|
|
10387
|
-
<feMerge>
|
|
10388
|
-
<feMergeNode in="finalU" />
|
|
10389
|
-
<feMergeNode in="finalP" />
|
|
10390
|
-
<feMergeNode in="finalA" />
|
|
10391
|
-
<feMergeNode in="SourceGraphic" />
|
|
10392
|
-
</feMerge>
|
|
10393
|
-
</filter>`;
|
|
10394
|
-
});
|
|
10395
|
-
return `
|
|
10396
|
-
<defs>
|
|
10397
|
-
${filters}
|
|
10398
|
-
</defs>
|
|
10399
|
-
`;
|
|
10400
|
-
}
|
|
10401
10359
|
static get svgFilters() {
|
|
10402
10360
|
const shadows = DecidablesElement.shadows; /* eslint-disable-line prefer-destructuring */
|
|
10403
10361
|
|
|
10404
10362
|
const filters = shadows.elevations.map(z => {
|
|
10405
10363
|
return b$1`
|
|
10406
|
-
<filter id=${`shadow-${z}`} x="-
|
|
10364
|
+
<filter id=${`shadow-${z}`} filterUnits="userSpaceOnUse" x="-100%" y="-100%" width="200%" height="200%">
|
|
10407
10365
|
<feComponentTransfer in="SourceAlpha" result="solid">
|
|
10408
10366
|
<feFuncA type="table" tableValues="0 1 1"/>
|
|
10409
10367
|
</feComponentTransfer>
|
|
@@ -10435,11 +10393,9 @@
|
|
|
10435
10393
|
</filter>`;
|
|
10436
10394
|
});
|
|
10437
10395
|
return b$1`
|
|
10438
|
-
<
|
|
10439
|
-
|
|
10440
|
-
|
|
10441
|
-
</defs>
|
|
10442
|
-
</svg>
|
|
10396
|
+
<defs class="filtersUser">
|
|
10397
|
+
${filters}
|
|
10398
|
+
</defs>
|
|
10443
10399
|
`;
|
|
10444
10400
|
}
|
|
10445
10401
|
static get styles() {
|
|
@@ -12214,9 +12170,9 @@
|
|
|
12214
12170
|
}
|
|
12215
12171
|
update(t, [i]) {
|
|
12216
12172
|
const s = void 0 === this.u;
|
|
12217
|
-
return s && (this.u = t.options?.host, this.u.addController(this), this.u.updateComplete.then(t => this.t = true), this.element = t.element, j.set(this.element, this)), this.optionsOrCallback = i, (s || "function" != typeof i) && this.
|
|
12173
|
+
return s && (this.u = t.options?.host, this.u.addController(this), this.u.updateComplete.then(t => this.t = true), this.element = t.element, j.set(this.element, this)), this.optionsOrCallback = i, (s || "function" != typeof i) && this.m(i), this.render(i);
|
|
12218
12174
|
}
|
|
12219
|
-
|
|
12175
|
+
m(t) {
|
|
12220
12176
|
t = t ?? {};
|
|
12221
12177
|
const i = this.getController();
|
|
12222
12178
|
void 0 !== i && ((t = {
|
|
@@ -12227,7 +12183,7 @@
|
|
|
12227
12183
|
...t.keyframeOptions
|
|
12228
12184
|
}), t.properties ??= b, this.options = t;
|
|
12229
12185
|
}
|
|
12230
|
-
|
|
12186
|
+
p() {
|
|
12231
12187
|
const t = {},
|
|
12232
12188
|
i = this.element.getBoundingClientRect(),
|
|
12233
12189
|
s = getComputedStyle(this.element);
|
|
@@ -12248,20 +12204,20 @@
|
|
|
12248
12204
|
})(t, this._)), this.h = this.t && !this.isDisabled() && !this.isAnimating() && i && this.element.isConnected, this.h && (this._ = Array.isArray(t) ? Array.from(t) : t), this.h;
|
|
12249
12205
|
}
|
|
12250
12206
|
hostUpdate() {
|
|
12251
|
-
"function" == typeof this.optionsOrCallback && this.
|
|
12207
|
+
"function" == typeof this.optionsOrCallback && this.m(this.optionsOrCallback()), this.v() && (this.A = this.p(), this.i = this.i ?? this.element.parentNode, this.o = this.element.nextSibling);
|
|
12252
12208
|
}
|
|
12253
12209
|
async hostUpdated() {
|
|
12254
12210
|
if (!this.h || !this.element.isConnected || this.options.skipInitial && !this.isHostRendered) return;
|
|
12255
12211
|
let t;
|
|
12256
12212
|
this.prepare(), await a;
|
|
12257
|
-
const i = this.
|
|
12258
|
-
s = this.
|
|
12259
|
-
e = this.
|
|
12213
|
+
const i = this.P(),
|
|
12214
|
+
s = this.V(this.options.keyframeOptions, i),
|
|
12215
|
+
e = this.p();
|
|
12260
12216
|
if (void 0 !== this.A) {
|
|
12261
12217
|
const {
|
|
12262
12218
|
from: s,
|
|
12263
12219
|
to: h
|
|
12264
|
-
} = this.
|
|
12220
|
+
} = this.O(this.A, e, i);
|
|
12265
12221
|
this.log("measured", [this.A, e, s, h]), t = this.calculateKeyframes(s, h);
|
|
12266
12222
|
} else {
|
|
12267
12223
|
const s = r.get(this.options.inId);
|
|
@@ -12270,7 +12226,7 @@
|
|
|
12270
12226
|
const {
|
|
12271
12227
|
from: h,
|
|
12272
12228
|
to: n
|
|
12273
|
-
} = this.
|
|
12229
|
+
} = this.O(s, e, i);
|
|
12274
12230
|
t = this.calculateKeyframes(h, n), t = this.options.in ? [{
|
|
12275
12231
|
...this.options.in[0],
|
|
12276
12232
|
...t[0]
|
|
@@ -12280,10 +12236,10 @@
|
|
|
12280
12236
|
this.animate(t, s);
|
|
12281
12237
|
}
|
|
12282
12238
|
resetStyles() {
|
|
12283
|
-
void 0 !== this.
|
|
12239
|
+
void 0 !== this.j && (this.element.setAttribute("style", this.j ?? ""), this.j = void 0);
|
|
12284
12240
|
}
|
|
12285
12241
|
commitStyles() {
|
|
12286
|
-
this.
|
|
12242
|
+
this.j = this.element.getAttribute("style"), this.webAnimation?.commitStyles(), this.webAnimation?.cancel();
|
|
12287
12243
|
}
|
|
12288
12244
|
reconnected() {}
|
|
12289
12245
|
async disconnected() {
|
|
@@ -12292,14 +12248,14 @@
|
|
|
12292
12248
|
if (this.prepare(), await a(), this.i?.isConnected) {
|
|
12293
12249
|
const t = this.o && this.o.parentNode === this.i ? this.o : null;
|
|
12294
12250
|
if (this.i.insertBefore(this.element, t), this.options.stabilizeOut) {
|
|
12295
|
-
const t = this.
|
|
12251
|
+
const t = this.p();
|
|
12296
12252
|
this.log("stabilizing out");
|
|
12297
12253
|
const i = this.A.left - t.left,
|
|
12298
12254
|
s = this.A.top - t.top;
|
|
12299
12255
|
!("static" === getComputedStyle(this.element).position) || 0 === i && 0 === s || (this.element.style.position = "relative"), 0 !== i && (this.element.style.left = i + "px"), 0 !== s && (this.element.style.top = s + "px");
|
|
12300
12256
|
}
|
|
12301
12257
|
}
|
|
12302
|
-
const t = this.
|
|
12258
|
+
const t = this.V(this.options.keyframeOptions);
|
|
12303
12259
|
await this.animate(this.options.out, t), this.element.remove();
|
|
12304
12260
|
}
|
|
12305
12261
|
prepare() {
|
|
@@ -12311,7 +12267,7 @@
|
|
|
12311
12267
|
didFinish(t) {
|
|
12312
12268
|
t && this.options.onComplete?.(this), this.A = void 0, this.animatingProperties = void 0, this.frames = void 0, this.resolveFinished();
|
|
12313
12269
|
}
|
|
12314
|
-
|
|
12270
|
+
P() {
|
|
12315
12271
|
const t = [];
|
|
12316
12272
|
for (let i = this.element.parentNode; i; i = i?.parentNode) {
|
|
12317
12273
|
const s = j.get(i);
|
|
@@ -12325,13 +12281,13 @@
|
|
|
12325
12281
|
n.add(this.u);
|
|
12326
12282
|
}), t;
|
|
12327
12283
|
}
|
|
12328
|
-
|
|
12284
|
+
V(t, i = this.P()) {
|
|
12329
12285
|
const s = {
|
|
12330
12286
|
...A
|
|
12331
12287
|
};
|
|
12332
12288
|
return i.forEach(t => Object.assign(s, t.options.keyframeOptions)), Object.assign(s, t), s;
|
|
12333
12289
|
}
|
|
12334
|
-
|
|
12290
|
+
O(t, i, s) {
|
|
12335
12291
|
t = {
|
|
12336
12292
|
...t
|
|
12337
12293
|
}, i = {
|
|
@@ -13072,26 +13028,45 @@
|
|
|
13072
13028
|
|
|
13073
13029
|
.option .interactive:hover {
|
|
13074
13030
|
filter: url("#shadow-4");
|
|
13031
|
+
|
|
13032
|
+
/* HACK: This gets Safari to correctly apply the filter! */
|
|
13033
|
+
/* https://github.com/emilbjorklund/svg-weirdness/issues/27 */
|
|
13034
|
+
transform: translateX(0);
|
|
13075
13035
|
}
|
|
13076
13036
|
|
|
13077
13037
|
.option .interactive:active {
|
|
13078
13038
|
filter: url("#shadow-8");
|
|
13039
|
+
|
|
13040
|
+
/* HACK: This gets Safari to correctly apply the filter! */
|
|
13041
|
+
transform: translateY(0);
|
|
13079
13042
|
}
|
|
13080
13043
|
|
|
13081
13044
|
:host(.keyboard) .option .interactive:focus-within {
|
|
13082
13045
|
filter: url("#shadow-8");
|
|
13046
|
+
|
|
13047
|
+
/* HACK: This gets Safari to correctly apply the filter! */
|
|
13048
|
+
transform: translateZ(0);
|
|
13083
13049
|
}
|
|
13084
13050
|
|
|
13085
13051
|
.option .body.interactive:has(~ .point:hover) {
|
|
13086
13052
|
filter: url("#shadow-4");
|
|
13053
|
+
|
|
13054
|
+
/* HACK: This gets Safari to correctly apply the filter! */
|
|
13055
|
+
transform: translateX(0);
|
|
13087
13056
|
}
|
|
13088
13057
|
|
|
13089
13058
|
.option .body.interactive:has(~ .point:active) {
|
|
13090
13059
|
filter: url("#shadow-8");
|
|
13060
|
+
|
|
13061
|
+
/* HACK: This gets Safari to correctly apply the filter! */
|
|
13062
|
+
transform: translateY(0);
|
|
13091
13063
|
}
|
|
13092
13064
|
|
|
13093
|
-
:host(.keyboard) .
|
|
13065
|
+
:host(.keyboard) .body.interactive:has(~ .point:focus-within) {
|
|
13094
13066
|
filter: url("#shadow-8");
|
|
13067
|
+
|
|
13068
|
+
/* HACK: This gets Safari to correctly apply the filter! */
|
|
13069
|
+
transform: translateZ(0);
|
|
13095
13070
|
}
|
|
13096
13071
|
|
|
13097
13072
|
.gradient.sooner stop {
|
|
@@ -13257,16 +13232,18 @@
|
|
|
13257
13232
|
rem: this.rem
|
|
13258
13233
|
}]);
|
|
13259
13234
|
// ENTER
|
|
13260
|
-
const svgEnter = svgUpdate.enter().append('svg').classed('main', true)
|
|
13261
|
-
|
|
13235
|
+
const svgEnter = svgUpdate.enter().append('svg').classed('main', true).each((datum, index, nodes) => {
|
|
13236
|
+
// Filters for shadows
|
|
13237
|
+
B$1(DiscountableElement.svgFilters, nodes[index]);
|
|
13238
|
+
});
|
|
13262
13239
|
// Gradients for fill animations
|
|
13263
|
-
const
|
|
13264
|
-
const soonerGradient =
|
|
13240
|
+
const svgGradients = svgEnter.append('defs').classed('gradients', true);
|
|
13241
|
+
const soonerGradient = svgGradients.append('linearGradient').classed('gradient sooner', true).attr('id', 'sooner-gradient');
|
|
13265
13242
|
soonerGradient.append('stop').classed('stop-0', true).attr('offset', '0');
|
|
13266
13243
|
soonerGradient.append('stop').classed('stop-before animation', true).attr('offset', '1');
|
|
13267
13244
|
soonerGradient.append('stop').classed('stop-after animation', true).attr('offset', '1');
|
|
13268
13245
|
soonerGradient.append('stop').classed('stop-100', true).attr('offset', '1');
|
|
13269
|
-
const laterGradient =
|
|
13246
|
+
const laterGradient = svgGradients.append('linearGradient').classed('gradient later', true).attr('id', 'later-gradient');
|
|
13270
13247
|
laterGradient.append('stop').classed('stop-0', true).attr('offset', '0');
|
|
13271
13248
|
laterGradient.append('stop').classed('stop-before animation', true).attr('offset', '1');
|
|
13272
13249
|
laterGradient.append('stop').classed('stop-after animation', true).attr('offset', '1');
|
|
@@ -13814,7 +13791,7 @@
|
|
|
13814
13791
|
element.d = interpolateD(time);
|
|
13815
13792
|
return `${xScale(element.d)}`;
|
|
13816
13793
|
};
|
|
13817
|
-
}).attrTween('y2', (datum, index, elements) => {
|
|
13794
|
+
}).attr('y1', yScale(0)).attrTween('y2', (datum, index, elements) => {
|
|
13818
13795
|
const element = elements[index];
|
|
13819
13796
|
const interpolateA = interpolate$1(element.a !== undefined ? element.a : datum.a, datum.a);
|
|
13820
13797
|
return time => {
|