@5even7/dlc-ui 0.2.5 → 0.2.7
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 +10 -0
- package/README.md +13 -16
- package/dist/capsule.cjs +5 -0
- package/dist/capsule.mjs +5 -0
- package/dist/index.cjs +20 -6
- package/dist/index.mjs +19 -6
- package/dist/index.umd.js +20 -6
- package/dist/index.umd.min.js +1 -1
- package/dist/progress.cjs +15 -6
- package/dist/progress.mjs +14 -6
- package/dist/vue2.cjs +52 -26
- package/dist/vue2.mjs +47 -28
- package/dist/vue3.cjs +52 -26
- package/dist/vue3.mjs +47 -28
- package/package.json +1 -1
- package/types/vue2.d.ts +9 -1
- package/types/vue3.d.ts +9 -0
package/dist/vue2.mjs
CHANGED
|
@@ -1165,6 +1165,11 @@ function createCapsule(container, options = {}) {
|
|
|
1165
1165
|
updateAria();
|
|
1166
1166
|
return this;
|
|
1167
1167
|
},
|
|
1168
|
+
setMouseColor(value) {
|
|
1169
|
+
merged.mouseColor = value !== false;
|
|
1170
|
+
if (typeof renderer.setMouseColor === 'function') renderer.setMouseColor(merged.mouseColor);
|
|
1171
|
+
return this;
|
|
1172
|
+
},
|
|
1168
1173
|
setSize(width, height) {
|
|
1169
1174
|
if (width !== undefined) {
|
|
1170
1175
|
parseSize(width); // 非法尺寸直接抛错前先校验,避免污染内部状态
|
|
@@ -1964,6 +1969,11 @@ class ProgressCapsuleController {
|
|
|
1964
1969
|
this.root.setAttribute('aria-valuetext', `${rounded}${this.valueSuffix}`);
|
|
1965
1970
|
return this;
|
|
1966
1971
|
}
|
|
1972
|
+
|
|
1973
|
+
setShowValue(show) {
|
|
1974
|
+
if (this.valueElement) this.valueElement.hidden = show === false;
|
|
1975
|
+
return this;
|
|
1976
|
+
}
|
|
1967
1977
|
|
|
1968
1978
|
resizeCanvas() {
|
|
1969
1979
|
const bounds = this.root.getBoundingClientRect();
|
|
@@ -2458,16 +2468,15 @@ function createProgressCapsule(container, options = {}) {
|
|
|
2458
2468
|
fillContent(textLayer, options.text);
|
|
2459
2469
|
fillContent(visualLayer, options.colorContent);
|
|
2460
2470
|
|
|
2461
|
-
const valueElement =
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
}
|
|
2471
|
+
const valueElement = document.createElement('div');
|
|
2472
|
+
valueElement.className = 'hj-progress-value';
|
|
2473
|
+
valueElement.setAttribute('aria-hidden', 'true');
|
|
2474
|
+
valueElement.hidden = merged.showValue === false;
|
|
2466
2475
|
|
|
2467
2476
|
root.appendChild(canvas);
|
|
2468
2477
|
root.appendChild(textLayer);
|
|
2469
2478
|
root.appendChild(visualLayer);
|
|
2470
|
-
|
|
2479
|
+
root.appendChild(valueElement);
|
|
2471
2480
|
container.appendChild(root);
|
|
2472
2481
|
|
|
2473
2482
|
const emitter = createEmitter();
|
|
@@ -2623,6 +2632,10 @@ function createProgressCapsule(container, options = {}) {
|
|
|
2623
2632
|
controller.setValueSuffix(suffix);
|
|
2624
2633
|
return this;
|
|
2625
2634
|
},
|
|
2635
|
+
setShowValue(show) {
|
|
2636
|
+
controller.setShowValue(show);
|
|
2637
|
+
return this;
|
|
2638
|
+
},
|
|
2626
2639
|
setColors(colors) {
|
|
2627
2640
|
const next = Array.isArray(colors) ? colors.map(normalizeColor) : [];
|
|
2628
2641
|
if (next.length !== 4 || next.some((color) => !color)) return this;
|
|
@@ -2947,15 +2960,13 @@ function makeWrapper({ name, props, events, create, render, methods, watch }) {
|
|
|
2947
2960
|
const root = this.controller.element;
|
|
2948
2961
|
const textLayer = root.querySelector('.hj-capsule-text, .hj-progress-text');
|
|
2949
2962
|
const visualLayer = root.querySelector('.hj-capsule-visual, .hj-progress-visual');
|
|
2963
|
+
const move = (wrapper, layer) => {
|
|
2964
|
+
if (!wrapper || !layer) return;
|
|
2965
|
+
for (const node of Array.from(wrapper.childNodes)) layer.appendChild(node);
|
|
2966
|
+
};
|
|
2950
2967
|
const refs = this.$refs || {};
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
if (refs.slotText && textLayer && refs.slotText.parentElement !== textLayer) {
|
|
2954
|
-
textLayer.appendChild(refs.slotText);
|
|
2955
|
-
}
|
|
2956
|
-
if (refs.slotColor && visualLayer && refs.slotColor.parentElement !== visualLayer) {
|
|
2957
|
-
visualLayer.appendChild(refs.slotColor);
|
|
2958
|
-
}
|
|
2968
|
+
move(refs.slotText, textLayer);
|
|
2969
|
+
move(refs.slotColor, visualLayer);
|
|
2959
2970
|
},
|
|
2960
2971
|
applyAttrs() {
|
|
2961
2972
|
if (!this.controller || !this.controller.element || !this.$attrs) return;
|
|
@@ -3020,9 +3031,9 @@ function makeWrapper({ name, props, events, create, render, methods, watch }) {
|
|
|
3020
3031
|
};
|
|
3021
3032
|
}
|
|
3022
3033
|
|
|
3023
|
-
function makeCapsuleWrapper(createCapsule, render) {
|
|
3024
|
-
return makeWrapper({
|
|
3025
|
-
name: '
|
|
3034
|
+
function makeCapsuleWrapper(createCapsule, render) {
|
|
3035
|
+
return makeWrapper({
|
|
3036
|
+
name: 'dlc-capsule',
|
|
3026
3037
|
props: [
|
|
3027
3038
|
'preset', 'width', 'height', 'colors', 'seed', 'speed',
|
|
3028
3039
|
'textRatio', 'label', 'mouseColor', 'renderer', 'quality', 'respectReducedMotion', 'cssVars'
|
|
@@ -3052,8 +3063,8 @@ function makeCapsuleWrapper(createCapsule, render) {
|
|
|
3052
3063
|
label(value) {
|
|
3053
3064
|
if (this.controller) this.controller.setLabel(value);
|
|
3054
3065
|
},
|
|
3055
|
-
mouseColor() {
|
|
3056
|
-
this.
|
|
3066
|
+
mouseColor(value) {
|
|
3067
|
+
if (this.controller) this.controller.setMouseColor(value);
|
|
3057
3068
|
},
|
|
3058
3069
|
renderer() {
|
|
3059
3070
|
this.scheduleRecreate();
|
|
@@ -3078,8 +3089,8 @@ function makeCapsuleWrapper(createCapsule, render) {
|
|
|
3078
3089
|
}
|
|
3079
3090
|
|
|
3080
3091
|
function makeProgressWrapper(createProgressCapsule, render) {
|
|
3081
|
-
return makeWrapper({
|
|
3082
|
-
name: '
|
|
3092
|
+
return makeWrapper({
|
|
3093
|
+
name: 'dlc-progress',
|
|
3083
3094
|
props: [
|
|
3084
3095
|
'preset', 'width', 'height', 'value', 'min', 'max',
|
|
3085
3096
|
'draggable', 'disabled', 'readonly', 'edgeStyle', 'colors', 'textRatio', 'label', 'showValue', 'valueSuffix',
|
|
@@ -3113,8 +3124,8 @@ function makeProgressWrapper(createProgressCapsule, render) {
|
|
|
3113
3124
|
valueSuffix(value) {
|
|
3114
3125
|
if (value !== undefined && this.controller) this.controller.setValueSuffix(value);
|
|
3115
3126
|
},
|
|
3116
|
-
showValue() {
|
|
3117
|
-
this.
|
|
3127
|
+
showValue(value) {
|
|
3128
|
+
if (this.controller) this.controller.setShowValue(value);
|
|
3118
3129
|
},
|
|
3119
3130
|
disabled() {
|
|
3120
3131
|
this.scheduleRecreate();
|
|
@@ -3153,7 +3164,7 @@ function makeProgressWrapper(createProgressCapsule, render) {
|
|
|
3153
3164
|
|
|
3154
3165
|
function makeColorWrapper(createColorBackground, render) {
|
|
3155
3166
|
return makeWrapper({
|
|
3156
|
-
name: '
|
|
3167
|
+
name: 'dlc-color',
|
|
3157
3168
|
props: [
|
|
3158
3169
|
'preset', 'colors', 'seed', 'speed', 'quality', 'renderer',
|
|
3159
3170
|
'mouseColor', 'respectReducedMotion', 'opacity', 'fallbackColor'
|
|
@@ -3218,14 +3229,22 @@ const renderColor = function renderColor(h) {
|
|
|
3218
3229
|
return h('div', { class: 'hj-vue-host' }, this.$slots.default);
|
|
3219
3230
|
};
|
|
3220
3231
|
|
|
3221
|
-
const
|
|
3222
|
-
const
|
|
3223
|
-
const
|
|
3232
|
+
const DlcCapsule = makeCapsuleWrapper(createCapsule, render);
|
|
3233
|
+
const DlcProgress = makeProgressWrapper(createProgressCapsule, render);
|
|
3234
|
+
const DlcColor = makeColorWrapper(createColorBackground, renderColor);
|
|
3235
|
+
|
|
3236
|
+
// 旧名兼容别名(deprecated)
|
|
3237
|
+
const CosmicCapsule = DlcCapsule;
|
|
3238
|
+
const ProgressCapsule = DlcProgress;
|
|
3239
|
+
const ColorBackground = DlcColor;
|
|
3224
3240
|
|
|
3225
3241
|
var vue2 = {
|
|
3242
|
+
'dlc-capsule': DlcCapsule,
|
|
3243
|
+
'dlc-progress': DlcProgress,
|
|
3244
|
+
'dlc-color': DlcColor,
|
|
3226
3245
|
CosmicCapsule,
|
|
3227
3246
|
ProgressCapsule,
|
|
3228
3247
|
ColorBackground
|
|
3229
3248
|
};
|
|
3230
3249
|
|
|
3231
|
-
export { ColorBackground, CosmicCapsule, ProgressCapsule, vue2 as default };
|
|
3250
|
+
export { ColorBackground, CosmicCapsule, DlcCapsule, DlcColor, DlcProgress, ProgressCapsule, vue2 as default, DlcCapsule as "dlc-capsule", DlcColor as "dlc-color", DlcProgress as "dlc-progress" };
|
package/dist/vue3.cjs
CHANGED
|
@@ -1363,6 +1363,11 @@ function createCapsule(container) {
|
|
|
1363
1363
|
updateAria();
|
|
1364
1364
|
return this;
|
|
1365
1365
|
},
|
|
1366
|
+
setMouseColor: function setMouseColor(value) {
|
|
1367
|
+
merged.mouseColor = value !== false;
|
|
1368
|
+
if (typeof renderer.setMouseColor === 'function') renderer.setMouseColor(merged.mouseColor);
|
|
1369
|
+
return this;
|
|
1370
|
+
},
|
|
1366
1371
|
setSize: function setSize(width, height) {
|
|
1367
1372
|
if (width !== undefined) {
|
|
1368
1373
|
parseSize(width); // 非法尺寸直接抛错前先校验,避免污染内部状态
|
|
@@ -1995,6 +2000,12 @@ var ProgressCapsuleController = /*#__PURE__*/function () {
|
|
|
1995
2000
|
this.root.setAttribute('aria-valuetext', "".concat(rounded).concat(this.valueSuffix));
|
|
1996
2001
|
return this;
|
|
1997
2002
|
}
|
|
2003
|
+
}, {
|
|
2004
|
+
key: "setShowValue",
|
|
2005
|
+
value: function setShowValue(show) {
|
|
2006
|
+
if (this.valueElement) this.valueElement.hidden = show === false;
|
|
2007
|
+
return this;
|
|
2008
|
+
}
|
|
1998
2009
|
}, {
|
|
1999
2010
|
key: "resizeCanvas",
|
|
2000
2011
|
value: function resizeCanvas() {
|
|
@@ -2519,15 +2530,14 @@ function createProgressCapsule(container) {
|
|
|
2519
2530
|
visualLayer.className = 'hj-progress-visual';
|
|
2520
2531
|
fillContent(textLayer, options.text);
|
|
2521
2532
|
fillContent(visualLayer, options.colorContent);
|
|
2522
|
-
var valueElement =
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
}
|
|
2533
|
+
var valueElement = document.createElement('div');
|
|
2534
|
+
valueElement.className = 'hj-progress-value';
|
|
2535
|
+
valueElement.setAttribute('aria-hidden', 'true');
|
|
2536
|
+
valueElement.hidden = merged.showValue === false;
|
|
2527
2537
|
root.appendChild(canvas);
|
|
2528
2538
|
root.appendChild(textLayer);
|
|
2529
2539
|
root.appendChild(visualLayer);
|
|
2530
|
-
|
|
2540
|
+
root.appendChild(valueElement);
|
|
2531
2541
|
container.appendChild(root);
|
|
2532
2542
|
var emitter = createEmitter();
|
|
2533
2543
|
var paused = merged.respectReducedMotion && prefersReducedMotion$1();
|
|
@@ -2700,6 +2710,10 @@ function createProgressCapsule(container) {
|
|
|
2700
2710
|
controller.setValueSuffix(suffix);
|
|
2701
2711
|
return this;
|
|
2702
2712
|
},
|
|
2713
|
+
setShowValue: function setShowValue(show) {
|
|
2714
|
+
controller.setShowValue(show);
|
|
2715
|
+
return this;
|
|
2716
|
+
},
|
|
2703
2717
|
setColors: function setColors(colors) {
|
|
2704
2718
|
var next = Array.isArray(colors) ? colors.map(normalizeColor) : [];
|
|
2705
2719
|
if (next.length !== 4 || next.some(function (color) {
|
|
@@ -3045,21 +3059,22 @@ function makeWrapper(_ref) {
|
|
|
3045
3059
|
var root = this.controller.element;
|
|
3046
3060
|
var textLayer = root.querySelector('.hj-capsule-text, .hj-progress-text');
|
|
3047
3061
|
var visualLayer = root.querySelector('.hj-capsule-visual, .hj-progress-visual');
|
|
3062
|
+
var move = function move(wrapper, layer) {
|
|
3063
|
+
if (!wrapper || !layer) return;
|
|
3064
|
+
for (var _i = 0, _Array$from = Array.from(wrapper.childNodes); _i < _Array$from.length; _i++) {
|
|
3065
|
+
var node = _Array$from[_i];
|
|
3066
|
+
layer.appendChild(node);
|
|
3067
|
+
}
|
|
3068
|
+
};
|
|
3048
3069
|
var refs = this.$refs || {};
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
if (refs.slotText && textLayer && refs.slotText.parentElement !== textLayer) {
|
|
3052
|
-
textLayer.appendChild(refs.slotText);
|
|
3053
|
-
}
|
|
3054
|
-
if (refs.slotColor && visualLayer && refs.slotColor.parentElement !== visualLayer) {
|
|
3055
|
-
visualLayer.appendChild(refs.slotColor);
|
|
3056
|
-
}
|
|
3070
|
+
move(refs.slotText, textLayer);
|
|
3071
|
+
move(refs.slotColor, visualLayer);
|
|
3057
3072
|
},
|
|
3058
3073
|
applyAttrs: function applyAttrs() {
|
|
3059
3074
|
if (!this.controller || !this.controller.element || !this.$attrs) return;
|
|
3060
3075
|
var root = this.controller.element;
|
|
3061
|
-
for (var
|
|
3062
|
-
var key = _Object$keys[
|
|
3076
|
+
for (var _i2 = 0, _Object$keys = Object.keys(this.$attrs); _i2 < _Object$keys.length; _i2++) {
|
|
3077
|
+
var key = _Object$keys[_i2];
|
|
3063
3078
|
if (key === 'class' || key === 'style') continue;
|
|
3064
3079
|
var value = this.$attrs[key];
|
|
3065
3080
|
if (value == null || value === false) root.removeAttribute(key);else root.setAttribute(key, String(value));
|
|
@@ -3127,7 +3142,7 @@ function makeWrapper(_ref) {
|
|
|
3127
3142
|
}
|
|
3128
3143
|
function makeCapsuleWrapper(createCapsule, render) {
|
|
3129
3144
|
return makeWrapper({
|
|
3130
|
-
name: '
|
|
3145
|
+
name: 'dlc-capsule',
|
|
3131
3146
|
props: ['preset', 'width', 'height', 'colors', 'seed', 'speed', 'textRatio', 'label', 'mouseColor', 'renderer', 'quality', 'respectReducedMotion', 'cssVars'],
|
|
3132
3147
|
events: CAPSULE_EVENTS,
|
|
3133
3148
|
create: createCapsule,
|
|
@@ -3154,8 +3169,8 @@ function makeCapsuleWrapper(createCapsule, render) {
|
|
|
3154
3169
|
label: function label(value) {
|
|
3155
3170
|
if (this.controller) this.controller.setLabel(value);
|
|
3156
3171
|
},
|
|
3157
|
-
mouseColor: function mouseColor() {
|
|
3158
|
-
this.
|
|
3172
|
+
mouseColor: function mouseColor(value) {
|
|
3173
|
+
if (this.controller) this.controller.setMouseColor(value);
|
|
3159
3174
|
},
|
|
3160
3175
|
renderer: function renderer() {
|
|
3161
3176
|
this.scheduleRecreate();
|
|
@@ -3206,7 +3221,7 @@ function makeCapsuleWrapper(createCapsule, render) {
|
|
|
3206
3221
|
}
|
|
3207
3222
|
function makeProgressWrapper(createProgressCapsule, render) {
|
|
3208
3223
|
return makeWrapper({
|
|
3209
|
-
name: '
|
|
3224
|
+
name: 'dlc-progress',
|
|
3210
3225
|
props: ['preset', 'width', 'height', 'value', 'min', 'max', 'draggable', 'disabled', 'readonly', 'edgeStyle', 'colors', 'textRatio', 'label', 'showValue', 'valueSuffix', 'quality', 'renderer', 'respectReducedMotion', 'cssVars'],
|
|
3211
3226
|
events: PROGRESS_EVENTS,
|
|
3212
3227
|
create: createProgressCapsule,
|
|
@@ -3236,8 +3251,8 @@ function makeProgressWrapper(createProgressCapsule, render) {
|
|
|
3236
3251
|
valueSuffix: function valueSuffix(value) {
|
|
3237
3252
|
if (value !== undefined && this.controller) this.controller.setValueSuffix(value);
|
|
3238
3253
|
},
|
|
3239
|
-
showValue: function showValue() {
|
|
3240
|
-
this.
|
|
3254
|
+
showValue: function showValue(value) {
|
|
3255
|
+
if (this.controller) this.controller.setShowValue(value);
|
|
3241
3256
|
},
|
|
3242
3257
|
disabled: function disabled() {
|
|
3243
3258
|
this.scheduleRecreate();
|
|
@@ -3309,7 +3324,7 @@ function makeProgressWrapper(createProgressCapsule, render) {
|
|
|
3309
3324
|
}
|
|
3310
3325
|
function makeColorWrapper(createColorBackground, render) {
|
|
3311
3326
|
return makeWrapper({
|
|
3312
|
-
name: '
|
|
3327
|
+
name: 'dlc-color',
|
|
3313
3328
|
props: ['preset', 'colors', 'seed', 'speed', 'quality', 'renderer', 'mouseColor', 'respectReducedMotion', 'opacity', 'fallbackColor'],
|
|
3314
3329
|
events: COLOR_EVENTS,
|
|
3315
3330
|
create: createColorBackground,
|
|
@@ -3401,10 +3416,21 @@ var renderColor = function renderColor() {
|
|
|
3401
3416
|
class: 'hj-vue-host'
|
|
3402
3417
|
}, this.$slots.default ? this.$slots.default() : []);
|
|
3403
3418
|
};
|
|
3404
|
-
var
|
|
3405
|
-
var
|
|
3406
|
-
var
|
|
3419
|
+
var DlcCapsule = makeCapsuleWrapper(createCapsule, render);
|
|
3420
|
+
var DlcProgress = makeProgressWrapper(createProgressCapsule, render);
|
|
3421
|
+
var DlcColor = makeColorWrapper(createColorBackground, renderColor);
|
|
3422
|
+
|
|
3423
|
+
// 旧名兼容别名(deprecated)
|
|
3424
|
+
var CosmicCapsule = DlcCapsule;
|
|
3425
|
+
var ProgressCapsule = DlcProgress;
|
|
3426
|
+
var ColorBackground = DlcColor;
|
|
3407
3427
|
|
|
3408
3428
|
exports.ColorBackground = ColorBackground;
|
|
3409
3429
|
exports.CosmicCapsule = CosmicCapsule;
|
|
3430
|
+
exports.DlcCapsule = DlcCapsule;
|
|
3431
|
+
exports.DlcColor = DlcColor;
|
|
3432
|
+
exports.DlcProgress = DlcProgress;
|
|
3410
3433
|
exports.ProgressCapsule = ProgressCapsule;
|
|
3434
|
+
exports["dlc-capsule"] = DlcCapsule;
|
|
3435
|
+
exports["dlc-color"] = DlcColor;
|
|
3436
|
+
exports["dlc-progress"] = DlcProgress;
|
package/dist/vue3.mjs
CHANGED
|
@@ -1167,6 +1167,11 @@ function createCapsule(container, options = {}) {
|
|
|
1167
1167
|
updateAria();
|
|
1168
1168
|
return this;
|
|
1169
1169
|
},
|
|
1170
|
+
setMouseColor(value) {
|
|
1171
|
+
merged.mouseColor = value !== false;
|
|
1172
|
+
if (typeof renderer.setMouseColor === 'function') renderer.setMouseColor(merged.mouseColor);
|
|
1173
|
+
return this;
|
|
1174
|
+
},
|
|
1170
1175
|
setSize(width, height) {
|
|
1171
1176
|
if (width !== undefined) {
|
|
1172
1177
|
parseSize(width); // 非法尺寸直接抛错前先校验,避免污染内部状态
|
|
@@ -1966,6 +1971,11 @@ class ProgressCapsuleController {
|
|
|
1966
1971
|
this.root.setAttribute('aria-valuetext', `${rounded}${this.valueSuffix}`);
|
|
1967
1972
|
return this;
|
|
1968
1973
|
}
|
|
1974
|
+
|
|
1975
|
+
setShowValue(show) {
|
|
1976
|
+
if (this.valueElement) this.valueElement.hidden = show === false;
|
|
1977
|
+
return this;
|
|
1978
|
+
}
|
|
1969
1979
|
|
|
1970
1980
|
resizeCanvas() {
|
|
1971
1981
|
const bounds = this.root.getBoundingClientRect();
|
|
@@ -2460,16 +2470,15 @@ function createProgressCapsule(container, options = {}) {
|
|
|
2460
2470
|
fillContent(textLayer, options.text);
|
|
2461
2471
|
fillContent(visualLayer, options.colorContent);
|
|
2462
2472
|
|
|
2463
|
-
const valueElement =
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
}
|
|
2473
|
+
const valueElement = document.createElement('div');
|
|
2474
|
+
valueElement.className = 'hj-progress-value';
|
|
2475
|
+
valueElement.setAttribute('aria-hidden', 'true');
|
|
2476
|
+
valueElement.hidden = merged.showValue === false;
|
|
2468
2477
|
|
|
2469
2478
|
root.appendChild(canvas);
|
|
2470
2479
|
root.appendChild(textLayer);
|
|
2471
2480
|
root.appendChild(visualLayer);
|
|
2472
|
-
|
|
2481
|
+
root.appendChild(valueElement);
|
|
2473
2482
|
container.appendChild(root);
|
|
2474
2483
|
|
|
2475
2484
|
const emitter = createEmitter();
|
|
@@ -2625,6 +2634,10 @@ function createProgressCapsule(container, options = {}) {
|
|
|
2625
2634
|
controller.setValueSuffix(suffix);
|
|
2626
2635
|
return this;
|
|
2627
2636
|
},
|
|
2637
|
+
setShowValue(show) {
|
|
2638
|
+
controller.setShowValue(show);
|
|
2639
|
+
return this;
|
|
2640
|
+
},
|
|
2628
2641
|
setColors(colors) {
|
|
2629
2642
|
const next = Array.isArray(colors) ? colors.map(normalizeColor) : [];
|
|
2630
2643
|
if (next.length !== 4 || next.some((color) => !color)) return this;
|
|
@@ -2949,15 +2962,13 @@ function makeWrapper({ name, props, events, create, render, methods, watch }) {
|
|
|
2949
2962
|
const root = this.controller.element;
|
|
2950
2963
|
const textLayer = root.querySelector('.hj-capsule-text, .hj-progress-text');
|
|
2951
2964
|
const visualLayer = root.querySelector('.hj-capsule-visual, .hj-progress-visual');
|
|
2965
|
+
const move = (wrapper, layer) => {
|
|
2966
|
+
if (!wrapper || !layer) return;
|
|
2967
|
+
for (const node of Array.from(wrapper.childNodes)) layer.appendChild(node);
|
|
2968
|
+
};
|
|
2952
2969
|
const refs = this.$refs || {};
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
if (refs.slotText && textLayer && refs.slotText.parentElement !== textLayer) {
|
|
2956
|
-
textLayer.appendChild(refs.slotText);
|
|
2957
|
-
}
|
|
2958
|
-
if (refs.slotColor && visualLayer && refs.slotColor.parentElement !== visualLayer) {
|
|
2959
|
-
visualLayer.appendChild(refs.slotColor);
|
|
2960
|
-
}
|
|
2970
|
+
move(refs.slotText, textLayer);
|
|
2971
|
+
move(refs.slotColor, visualLayer);
|
|
2961
2972
|
},
|
|
2962
2973
|
applyAttrs() {
|
|
2963
2974
|
if (!this.controller || !this.controller.element || !this.$attrs) return;
|
|
@@ -3022,9 +3033,9 @@ function makeWrapper({ name, props, events, create, render, methods, watch }) {
|
|
|
3022
3033
|
};
|
|
3023
3034
|
}
|
|
3024
3035
|
|
|
3025
|
-
function makeCapsuleWrapper(createCapsule, render) {
|
|
3026
|
-
return makeWrapper({
|
|
3027
|
-
name: '
|
|
3036
|
+
function makeCapsuleWrapper(createCapsule, render) {
|
|
3037
|
+
return makeWrapper({
|
|
3038
|
+
name: 'dlc-capsule',
|
|
3028
3039
|
props: [
|
|
3029
3040
|
'preset', 'width', 'height', 'colors', 'seed', 'speed',
|
|
3030
3041
|
'textRatio', 'label', 'mouseColor', 'renderer', 'quality', 'respectReducedMotion', 'cssVars'
|
|
@@ -3054,8 +3065,8 @@ function makeCapsuleWrapper(createCapsule, render) {
|
|
|
3054
3065
|
label(value) {
|
|
3055
3066
|
if (this.controller) this.controller.setLabel(value);
|
|
3056
3067
|
},
|
|
3057
|
-
mouseColor() {
|
|
3058
|
-
this.
|
|
3068
|
+
mouseColor(value) {
|
|
3069
|
+
if (this.controller) this.controller.setMouseColor(value);
|
|
3059
3070
|
},
|
|
3060
3071
|
renderer() {
|
|
3061
3072
|
this.scheduleRecreate();
|
|
@@ -3080,8 +3091,8 @@ function makeCapsuleWrapper(createCapsule, render) {
|
|
|
3080
3091
|
}
|
|
3081
3092
|
|
|
3082
3093
|
function makeProgressWrapper(createProgressCapsule, render) {
|
|
3083
|
-
return makeWrapper({
|
|
3084
|
-
name: '
|
|
3094
|
+
return makeWrapper({
|
|
3095
|
+
name: 'dlc-progress',
|
|
3085
3096
|
props: [
|
|
3086
3097
|
'preset', 'width', 'height', 'value', 'min', 'max',
|
|
3087
3098
|
'draggable', 'disabled', 'readonly', 'edgeStyle', 'colors', 'textRatio', 'label', 'showValue', 'valueSuffix',
|
|
@@ -3115,8 +3126,8 @@ function makeProgressWrapper(createProgressCapsule, render) {
|
|
|
3115
3126
|
valueSuffix(value) {
|
|
3116
3127
|
if (value !== undefined && this.controller) this.controller.setValueSuffix(value);
|
|
3117
3128
|
},
|
|
3118
|
-
showValue() {
|
|
3119
|
-
this.
|
|
3129
|
+
showValue(value) {
|
|
3130
|
+
if (this.controller) this.controller.setShowValue(value);
|
|
3120
3131
|
},
|
|
3121
3132
|
disabled() {
|
|
3122
3133
|
this.scheduleRecreate();
|
|
@@ -3155,7 +3166,7 @@ function makeProgressWrapper(createProgressCapsule, render) {
|
|
|
3155
3166
|
|
|
3156
3167
|
function makeColorWrapper(createColorBackground, render) {
|
|
3157
3168
|
return makeWrapper({
|
|
3158
|
-
name: '
|
|
3169
|
+
name: 'dlc-color',
|
|
3159
3170
|
props: [
|
|
3160
3171
|
'preset', 'colors', 'seed', 'speed', 'quality', 'renderer',
|
|
3161
3172
|
'mouseColor', 'respectReducedMotion', 'opacity', 'fallbackColor'
|
|
@@ -3220,14 +3231,22 @@ const renderColor = function renderColor() {
|
|
|
3220
3231
|
return h('div', { class: 'hj-vue-host' }, this.$slots.default ? this.$slots.default() : []);
|
|
3221
3232
|
};
|
|
3222
3233
|
|
|
3223
|
-
const
|
|
3224
|
-
const
|
|
3225
|
-
const
|
|
3234
|
+
const DlcCapsule = makeCapsuleWrapper(createCapsule, render);
|
|
3235
|
+
const DlcProgress = makeProgressWrapper(createProgressCapsule, render);
|
|
3236
|
+
const DlcColor = makeColorWrapper(createColorBackground, renderColor);
|
|
3237
|
+
|
|
3238
|
+
// 旧名兼容别名(deprecated)
|
|
3239
|
+
const CosmicCapsule = DlcCapsule;
|
|
3240
|
+
const ProgressCapsule = DlcProgress;
|
|
3241
|
+
const ColorBackground = DlcColor;
|
|
3226
3242
|
|
|
3227
3243
|
var vue3 = {
|
|
3244
|
+
'dlc-capsule': DlcCapsule,
|
|
3245
|
+
'dlc-progress': DlcProgress,
|
|
3246
|
+
'dlc-color': DlcColor,
|
|
3228
3247
|
CosmicCapsule,
|
|
3229
3248
|
ProgressCapsule,
|
|
3230
3249
|
ColorBackground
|
|
3231
3250
|
};
|
|
3232
3251
|
|
|
3233
|
-
export { ColorBackground, CosmicCapsule, ProgressCapsule, vue3 as default };
|
|
3252
|
+
export { ColorBackground, CosmicCapsule, DlcCapsule, DlcColor, DlcProgress, ProgressCapsule, vue3 as default, DlcCapsule as "dlc-capsule", DlcColor as "dlc-color", DlcProgress as "dlc-progress" };
|
package/package.json
CHANGED
package/types/vue2.d.ts
CHANGED
package/types/vue3.d.ts
CHANGED
|
@@ -75,10 +75,19 @@ export interface ColorBackgroundComponent {
|
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
export declare const DlcCapsule: CosmicCapsuleComponent;
|
|
79
|
+
export declare const DlcProgress: ProgressCapsuleComponent;
|
|
80
|
+
export declare const DlcColor: ColorBackgroundComponent;
|
|
81
|
+
export { DlcCapsule as 'dlc-capsule', DlcProgress as 'dlc-progress', DlcColor as 'dlc-color' };
|
|
82
|
+
|
|
83
|
+
// 旧名兼容别名(deprecated)
|
|
78
84
|
export declare const CosmicCapsule: CosmicCapsuleComponent;
|
|
79
85
|
export declare const ProgressCapsule: ProgressCapsuleComponent;
|
|
80
86
|
export declare const ColorBackground: ColorBackgroundComponent;
|
|
81
87
|
declare const _default: {
|
|
88
|
+
'dlc-capsule': CosmicCapsuleComponent;
|
|
89
|
+
'dlc-progress': ProgressCapsuleComponent;
|
|
90
|
+
'dlc-color': ColorBackgroundComponent;
|
|
82
91
|
CosmicCapsule: CosmicCapsuleComponent;
|
|
83
92
|
ProgressCapsule: ProgressCapsuleComponent;
|
|
84
93
|
ColorBackground: ColorBackgroundComponent;
|