@5even7/dlc-ui 0.2.3 → 0.2.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/dist/vue2.cjs CHANGED
@@ -416,9 +416,13 @@ function getPreset(kind, ref) {
416
416
  var list = kind === 'capsule' ? CAPSULE_PRESETS : kind === 'progress' ? PROGRESS_PRESETS : null;
417
417
  if (!list) throw new Error("Unknown preset kind: ".concat(kind, " (use \"capsule\" or \"progress\")"));
418
418
  var key = String(ref).trim().toLowerCase();
419
- var found = list.find(function (preset) {
420
- return preset.name.toLowerCase() === key;
421
- });
419
+ var found = null;
420
+ for (var index = 0; index < list.length; index += 1) {
421
+ if (list[index].name.toLowerCase() === key) {
422
+ found = list[index];
423
+ break;
424
+ }
425
+ }
422
426
  if (!found) throw new Error("Unknown ".concat(kind, " preset: ").concat(ref));
423
427
  return found;
424
428
  }
@@ -439,7 +443,6 @@ var DEFAULTS = {
439
443
  min: 0,
440
444
  max: 100,
441
445
  draggable: true,
442
- keyboard: true,
443
446
  disabled: false,
444
447
  readonly: false,
445
448
  valueSuffix: '%',
@@ -630,7 +633,7 @@ function normalizeRgbArgs(args) {
630
633
  if (parts.length < 3) return null;
631
634
  var to255 = function to255(value) {
632
635
  if (typeof value !== 'string' || !value) return null;
633
- if (value.endsWith('%')) return clampChannel(parseFloat(value) / 100 * 255);
636
+ if (value.charAt(value.length - 1) === '%') return clampChannel(parseFloat(value) / 100 * 255);
634
637
  var number = Number(value);
635
638
  return Number.isFinite(number) ? clampChannel(number) : null;
636
639
  };
@@ -638,9 +641,11 @@ function normalizeRgbArgs(args) {
638
641
  var green = to255(parts[1]);
639
642
  var blue = to255(parts[2]);
640
643
  if (red === null || green === null || blue === null) return null;
641
- return "#".concat([red, green, blue].map(function (n) {
642
- return n.toString(16).padStart(2, '0');
643
- }).join(''));
644
+ var hex = function hex(n) {
645
+ var text = n.toString(16);
646
+ return text.length === 1 ? "0".concat(text) : text;
647
+ };
648
+ return "#".concat(hex(red)).concat(hex(green)).concat(hex(blue));
644
649
  }
645
650
 
646
651
  /**
@@ -905,6 +910,7 @@ var FallbackRenderer = /*#__PURE__*/function () {
905
910
  this.preset = preset;
906
911
  this.context = canvas.getContext('2d');
907
912
  this.visible = true;
913
+ this.timePhase = 0;
908
914
  }
909
915
  return _createClass(FallbackRenderer, [{
910
916
  key: "resize",
@@ -925,7 +931,7 @@ var FallbackRenderer = /*#__PURE__*/function () {
925
931
  var _this$canvas = this.canvas,
926
932
  width = _this$canvas.width,
927
933
  height = _this$canvas.height;
928
- var t = time * (this.preset.speed || 1);
934
+ var t = (time + this.timePhase) * (this.preset.speed || 1);
929
935
  var phase = (this.preset.seed || 0) * 0.7;
930
936
  var gradient = ctx.createLinearGradient(0, 0, width, height);
931
937
  gradient.addColorStop(0, this.preset.colors[0]);
@@ -962,7 +968,10 @@ var FallbackRenderer = /*#__PURE__*/function () {
962
968
  }, {
963
969
  key: "randomize",
964
970
  value: function randomize() {
965
- if (this.preset) this.preset.seed = Math.random() * 100;
971
+ if (this.preset) {
972
+ this.preset.seed = Math.random() * 100;
973
+ this.timePhase = Math.random() * Math.PI * 2;
974
+ }
966
975
  }
967
976
  }, {
968
977
  key: "setMouseColor",
@@ -1353,8 +1362,14 @@ function createCapsule(container) {
1353
1362
  return this;
1354
1363
  },
1355
1364
  setSize: function setSize(width, height) {
1356
- if (width !== undefined) merged.width = width;
1357
- if (height !== undefined) merged.height = height;
1365
+ if (width !== undefined) {
1366
+ parseSize(width); // 非法尺寸直接抛错前先校验,避免污染内部状态
1367
+ merged.width = width;
1368
+ }
1369
+ if (height !== undefined) {
1370
+ parseSize(height);
1371
+ merged.height = height;
1372
+ }
1358
1373
  applySize();
1359
1374
  return this;
1360
1375
  },
@@ -1383,8 +1398,12 @@ function createCapsule(container) {
1383
1398
  renderer.dispose();
1384
1399
  root.remove();
1385
1400
  },
1386
- textRatio: merged.textRatio,
1387
- cssVars: merged.cssVars,
1401
+ get textRatio() {
1402
+ return merged.textRatio;
1403
+ },
1404
+ get cssVars() {
1405
+ return merged.cssVars;
1406
+ },
1388
1407
  dirty: dirty
1389
1408
  };
1390
1409
  }
@@ -1680,8 +1699,12 @@ function drawCloud(context, x, y, radiusX, radiusY, color, alpha) {
1680
1699
  context.translate(x, y);
1681
1700
  context.scale(1, radiusY / radiusX);
1682
1701
  var gradient = context.createRadialGradient(0, 0, 0, 0, 0, radiusX);
1683
- gradient.addColorStop(0, "".concat(color).concat(Math.round(alpha * 255).toString(16).padStart(2, '0')));
1684
- gradient.addColorStop(0.46, "".concat(color).concat(Math.round(alpha * 0.42 * 255).toString(16).padStart(2, '0')));
1702
+ var alphaHex = function alphaHex(value) {
1703
+ var text = Math.round(value).toString(16);
1704
+ return text.length === 1 ? "0".concat(text) : text;
1705
+ };
1706
+ gradient.addColorStop(0, "".concat(color).concat(alphaHex(alpha * 255)));
1707
+ gradient.addColorStop(0.46, "".concat(color).concat(alphaHex(alpha * 0.42 * 255)));
1685
1708
  gradient.addColorStop(1, "".concat(color, "00"));
1686
1709
  context.fillStyle = gradient;
1687
1710
  context.fillRect(-radiusX, -radiusX, radiusX * 2, radiusX * 2);
@@ -2131,6 +2154,11 @@ var ProgressCapsuleController = /*#__PURE__*/function () {
2131
2154
  }, {
2132
2155
  key: "setRange",
2133
2156
  value: function setRange(min, max) {
2157
+ if (min > max) {
2158
+ var swap = min;
2159
+ min = max;
2160
+ max = swap;
2161
+ }
2134
2162
  this.min = min;
2135
2163
  this.max = max;
2136
2164
  var clamped = clamp(this.value, this.min, this.max);
@@ -2348,32 +2376,6 @@ var ProgressCapsuleController = /*#__PURE__*/function () {
2348
2376
  this.root.addEventListener('pointerup', this.handlers.pointerup);
2349
2377
  this.root.addEventListener('pointercancel', this.handlers.pointercancel);
2350
2378
  }
2351
- if (this.options.keyboard !== false) {
2352
- this.handlers.keydown = function (event) {
2353
- var step = (_this3.max - _this3.min) * 0.02;
2354
- var actions = {
2355
- ArrowLeft: -step,
2356
- ArrowDown: -step,
2357
- ArrowRight: step,
2358
- ArrowUp: step,
2359
- PageDown: -step * 5,
2360
- PageUp: step * 5
2361
- };
2362
- if (event.key === 'Home') {
2363
- event.preventDefault();
2364
- _this3.setProgress(_this3.min, 'keyboard');
2365
- } else if (event.key === 'End') {
2366
- event.preventDefault();
2367
- _this3.setProgress(_this3.max, 'keyboard');
2368
- } else if (actions[event.key]) {
2369
- event.preventDefault();
2370
- _this3.setProgress(_this3.value + actions[event.key], 'keyboard');
2371
- } else {
2372
- return;
2373
- }
2374
- };
2375
- this.root.addEventListener('keydown', this.handlers.keydown);
2376
- }
2377
2379
  }
2378
2380
  }, {
2379
2381
  key: "update",
@@ -2420,7 +2422,7 @@ var ProgressCapsuleController = /*#__PURE__*/function () {
2420
2422
  * Mount a fluid progress capsule into `container`.
2421
2423
  *
2422
2424
  * Options: preset (id/code/name or object), width, height, value, min, max,
2423
- * draggable, keyboard, colors, edgeStyle, textRatio (0-100, text region
2425
+ * draggable, colors, edgeStyle, textRatio (0-100, text region
2424
2426
  * width in percent), text (HTML string or DOM nodes for the text slot),
2425
2427
  * colorContent (HTML string or DOM nodes for the color slot),
2426
2428
  * showValue (show/hide the right-side percentage), quality,
@@ -2434,6 +2436,11 @@ function createProgressCapsule(container) {
2434
2436
  }
2435
2437
  var preset = _objectSpread2({}, getPreset('progress', (_options$preset = options.preset) !== null && _options$preset !== void 0 ? _options$preset : '星火'));
2436
2438
  var merged = normalizeOptions(DEFAULTS.progress, preset, options);
2439
+ if (merged.min > merged.max) {
2440
+ var swap = merged.min;
2441
+ merged.min = merged.max;
2442
+ merged.max = swap;
2443
+ }
2437
2444
  var normalizedColors = merged.colors.map(normalizeColor);
2438
2445
  if (normalizedColors.every(Boolean)) preset.colors = normalizedColors;
2439
2446
  preset.edgeStyle = merged.edgeStyle;
@@ -2445,7 +2452,6 @@ function createProgressCapsule(container) {
2445
2452
  var readonly = merged.readonly === true || merged.readonly === '' || merged.readonly === 'true';
2446
2453
  var locked = disabled || readonly;
2447
2454
  var effectiveDraggable = locked ? false : merged.draggable !== false;
2448
- var effectiveKeyboard = locked ? false : merged.keyboard !== false;
2449
2455
  var dirty = {
2450
2456
  preset: false,
2451
2457
  colors: false,
@@ -2457,7 +2463,6 @@ function createProgressCapsule(container) {
2457
2463
  var root = document.createElement('div');
2458
2464
  root.className = 'hj-capsule-root hj-progress-root';
2459
2465
  root.setAttribute('role', 'slider');
2460
- root.setAttribute('tabindex', '0');
2461
2466
  root.setAttribute('data-draggable', String(effectiveDraggable));
2462
2467
  if (disabled) {
2463
2468
  root.setAttribute('aria-disabled', 'true');
@@ -2467,6 +2472,7 @@ function createProgressCapsule(container) {
2467
2472
  root.setAttribute('aria-readonly', 'true');
2468
2473
  root.classList.add('is-readonly');
2469
2474
  }
2475
+ if (locked) root.setAttribute('tabindex', '-1');
2470
2476
  root.setAttribute('aria-valuemin', String((_merged$min = merged.min) !== null && _merged$min !== void 0 ? _merged$min : 0));
2471
2477
  root.setAttribute('aria-valuemax', String((_merged$max = merged.max) !== null && _merged$max !== void 0 ? _merged$max : 100));
2472
2478
  root.setAttribute('aria-valuenow', String(preset.initialProgress));
@@ -2478,7 +2484,6 @@ function createProgressCapsule(container) {
2478
2484
  }));
2479
2485
  };
2480
2486
  updateAria();
2481
- if (!effectiveKeyboard) root.setAttribute('tabindex', '-1');
2482
2487
  var canvas = document.createElement('canvas');
2483
2488
  canvas.className = 'hj-progress-canvas';
2484
2489
  canvas.setAttribute('aria-hidden', 'true');
@@ -2545,8 +2550,7 @@ function createProgressCapsule(container) {
2545
2550
  preset: preset,
2546
2551
  emitter: emitter,
2547
2552
  options: _objectSpread2(_objectSpread2({}, merged), {}, {
2548
- draggable: effectiveDraggable,
2549
- keyboard: effectiveKeyboard
2553
+ draggable: effectiveDraggable
2550
2554
  }),
2551
2555
  copy: copy,
2552
2556
  dirty: dirty
@@ -2706,8 +2710,14 @@ function createProgressCapsule(container) {
2706
2710
  return this;
2707
2711
  },
2708
2712
  setSize: function setSize(width, height) {
2709
- if (width !== undefined) merged.width = width;
2710
- if (height !== undefined) merged.height = height;
2713
+ if (width !== undefined) {
2714
+ parseSize(width);
2715
+ merged.width = width;
2716
+ }
2717
+ if (height !== undefined) {
2718
+ parseSize(height);
2719
+ merged.height = height;
2720
+ }
2711
2721
  applySize();
2712
2722
  controller.resizeCanvas();
2713
2723
  return this;
@@ -2738,8 +2748,12 @@ function createProgressCapsule(container) {
2738
2748
  controller.dispose();
2739
2749
  root.remove();
2740
2750
  },
2741
- textRatio: merged.textRatio,
2742
- cssVars: merged.cssVars,
2751
+ get textRatio() {
2752
+ return merged.textRatio;
2753
+ },
2754
+ get cssVars() {
2755
+ return merged.cssVars;
2756
+ },
2743
2757
  dirty: dirty
2744
2758
  };
2745
2759
  }
@@ -2944,9 +2958,15 @@ function createColorBackground(host) {
2944
2958
  renderer.dispose();
2945
2959
  layer.remove();
2946
2960
  },
2947
- opacity: merged.opacity,
2948
- fallbackColor: merged.fallbackColor,
2949
- mouseColor: merged.mouseColor,
2961
+ get opacity() {
2962
+ return merged.opacity;
2963
+ },
2964
+ get fallbackColor() {
2965
+ return merged.fallbackColor;
2966
+ },
2967
+ get mouseColor() {
2968
+ return merged.mouseColor;
2969
+ },
2950
2970
  dirty: dirty
2951
2971
  };
2952
2972
  }
@@ -2999,17 +3019,23 @@ function makeWrapper(_ref) {
2999
3019
  this.applyAttrs();
3000
3020
  },
3001
3021
  recreate: function recreate() {
3022
+ var _this2 = this;
3002
3023
  var extraState = this.runtimeState();
3003
3024
  if (this.controller) this.controller.dispose();
3004
3025
  this.mountController(extraState);
3026
+ // 结构属性连续变化时,插槽内容可能在重建后才被 Vue 写入容器,
3027
+ // 补一次搬运确保不丢。
3028
+ this.$nextTick(function () {
3029
+ return _this2.moveSlots();
3030
+ });
3005
3031
  },
3006
3032
  scheduleRecreate: function scheduleRecreate() {
3007
- var _this2 = this;
3033
+ var _this3 = this;
3008
3034
  if (this._recreateQueued) return;
3009
3035
  this._recreateQueued = true;
3010
3036
  this.$nextTick(function () {
3011
- _this2._recreateQueued = false;
3012
- _this2.recreate();
3037
+ _this3._recreateQueued = false;
3038
+ _this3.recreate();
3013
3039
  });
3014
3040
  },
3015
3041
  moveSlots: function moveSlots() {
@@ -3179,7 +3205,7 @@ function makeCapsuleWrapper(createCapsule, render) {
3179
3205
  function makeProgressWrapper(createProgressCapsule, render) {
3180
3206
  return makeWrapper({
3181
3207
  name: 'ProgressCapsule',
3182
- props: ['preset', 'width', 'height', 'value', 'min', 'max', 'draggable', 'keyboard', 'disabled', 'readonly', 'edgeStyle', 'colors', 'textRatio', 'label', 'showValue', 'valueSuffix', 'quality', 'renderer', 'respectReducedMotion', 'cssVars'],
3208
+ props: ['preset', 'width', 'height', 'value', 'min', 'max', 'draggable', 'disabled', 'readonly', 'edgeStyle', 'colors', 'textRatio', 'label', 'showValue', 'valueSuffix', 'quality', 'renderer', 'respectReducedMotion', 'cssVars'],
3183
3209
  events: PROGRESS_EVENTS,
3184
3210
  create: createProgressCapsule,
3185
3211
  render: render,
@@ -3220,9 +3246,6 @@ function makeProgressWrapper(createProgressCapsule, render) {
3220
3246
  draggable: function draggable() {
3221
3247
  this.scheduleRecreate();
3222
3248
  },
3223
- keyboard: function keyboard() {
3224
- this.scheduleRecreate();
3225
- },
3226
3249
  renderer: function renderer() {
3227
3250
  this.scheduleRecreate();
3228
3251
  }
package/dist/vue2.mjs CHANGED
@@ -175,9 +175,13 @@ function getPreset(kind, ref) {
175
175
  const list = kind === 'capsule' ? CAPSULE_PRESETS : kind === 'progress' ? PROGRESS_PRESETS : null;
176
176
  if (!list) throw new Error(`Unknown preset kind: ${kind} (use "capsule" or "progress")`);
177
177
  const key = String(ref).trim().toLowerCase();
178
- const found = list.find(
179
- (preset) => preset.name.toLowerCase() === key
180
- );
178
+ let found = null;
179
+ for (let index = 0; index < list.length; index += 1) {
180
+ if (list[index].name.toLowerCase() === key) {
181
+ found = list[index];
182
+ break;
183
+ }
184
+ }
181
185
  if (!found) throw new Error(`Unknown ${kind} preset: ${ref}`);
182
186
  return found;
183
187
  }
@@ -196,9 +200,8 @@ const DEFAULTS = {
196
200
  width: 454,
197
201
  height: 104,
198
202
  min: 0,
199
- max: 100,
203
+ max: 100,
200
204
  draggable: true,
201
- keyboard: true,
202
205
  disabled: false,
203
206
  readonly: false,
204
207
  valueSuffix: '%',
@@ -391,7 +394,7 @@ function normalizeRgbArgs(args) {
391
394
  if (parts.length < 3) return null;
392
395
  const to255 = (value) => {
393
396
  if (typeof value !== 'string' || !value) return null;
394
- if (value.endsWith('%')) return clampChannel((parseFloat(value) / 100) * 255);
397
+ if (value.charAt(value.length - 1) === '%') return clampChannel((parseFloat(value) / 100) * 255);
395
398
  const number = Number(value);
396
399
  return Number.isFinite(number) ? clampChannel(number) : null;
397
400
  };
@@ -399,7 +402,11 @@ function normalizeRgbArgs(args) {
399
402
  const green = to255(parts[1]);
400
403
  const blue = to255(parts[2]);
401
404
  if (red === null || green === null || blue === null) return null;
402
- return `#${[red, green, blue].map((n) => n.toString(16).padStart(2, '0')).join('')}`;
405
+ const hex = (n) => {
406
+ const text = n.toString(16);
407
+ return text.length === 1 ? `0${text}` : text;
408
+ };
409
+ return `#${hex(red)}${hex(green)}${hex(blue)}`;
403
410
  }
404
411
 
405
412
  /**
@@ -756,12 +763,13 @@ function rgb(color, alpha = 1) {
756
763
  }
757
764
 
758
765
  class FallbackRenderer {
759
- constructor(canvas, preset) {
760
- this.canvas = canvas;
761
- this.preset = preset;
762
- this.context = canvas.getContext('2d');
763
- this.visible = true;
764
- }
766
+ constructor(canvas, preset) {
767
+ this.canvas = canvas;
768
+ this.preset = preset;
769
+ this.context = canvas.getContext('2d');
770
+ this.visible = true;
771
+ this.timePhase = 0;
772
+ }
765
773
 
766
774
  resize() {
767
775
  const rect = this.canvas.getBoundingClientRect();
@@ -777,7 +785,7 @@ class FallbackRenderer {
777
785
  drawNebula(time) {
778
786
  const ctx = this.context;
779
787
  const { width, height } = this.canvas;
780
- const t = time * (this.preset.speed || 1);
788
+ const t = (time + this.timePhase) * (this.preset.speed || 1);
781
789
  const phase = (this.preset.seed || 0) * 0.7;
782
790
  const gradient = ctx.createLinearGradient(0, 0, width, height);
783
791
  gradient.addColorStop(0, this.preset.colors[0]);
@@ -812,7 +820,10 @@ class FallbackRenderer {
812
820
  }
813
821
 
814
822
  randomize() {
815
- if (this.preset) this.preset.seed = Math.random() * 100;
823
+ if (this.preset) {
824
+ this.preset.seed = Math.random() * 100;
825
+ this.timePhase = Math.random() * Math.PI * 2;
826
+ }
816
827
  }
817
828
  setMouseColor() {}
818
829
  dispose() {}
@@ -1159,11 +1170,17 @@ function createCapsule(container, options = {}) {
1159
1170
  return this;
1160
1171
  },
1161
1172
  setSize(width, height) {
1162
- if (width !== undefined) merged.width = width;
1163
- if (height !== undefined) merged.height = height;
1164
- applySize();
1165
- return this;
1166
- },
1173
+ if (width !== undefined) {
1174
+ parseSize(width); // 非法尺寸直接抛错前先校验,避免污染内部状态
1175
+ merged.width = width;
1176
+ }
1177
+ if (height !== undefined) {
1178
+ parseSize(height);
1179
+ merged.height = height;
1180
+ }
1181
+ applySize();
1182
+ return this;
1183
+ },
1167
1184
  randomize() {
1168
1185
  this.setSeed(Math.random() * 100);
1169
1186
  return this;
@@ -1190,8 +1207,8 @@ function createCapsule(container, options = {}) {
1190
1207
  renderer.dispose();
1191
1208
  root.remove();
1192
1209
  },
1193
- textRatio: merged.textRatio,
1194
- cssVars: merged.cssVars,
1210
+ get textRatio() { return merged.textRatio; },
1211
+ get cssVars() { return merged.cssVars; },
1195
1212
  dirty
1196
1213
  };
1197
1214
  }
@@ -1676,13 +1693,17 @@ const PALETTES = {
1676
1693
  'tide': ['#0a2239', '#2e9bff', '#7fe3ff', '#eaf9ff']
1677
1694
  };
1678
1695
 
1679
- function drawCloud(context, x, y, radiusX, radiusY, color, alpha) {
1680
- context.save();
1681
- context.translate(x, y);
1682
- context.scale(1, radiusY / radiusX);
1683
- const gradient = context.createRadialGradient(0, 0, 0, 0, 0, radiusX);
1684
- gradient.addColorStop(0, `${color}${Math.round(alpha * 255).toString(16).padStart(2, '0')}`);
1685
- gradient.addColorStop(0.46, `${color}${Math.round(alpha * 0.42 * 255).toString(16).padStart(2, '0')}`);
1696
+ function drawCloud(context, x, y, radiusX, radiusY, color, alpha) {
1697
+ context.save();
1698
+ context.translate(x, y);
1699
+ context.scale(1, radiusY / radiusX);
1700
+ const gradient = context.createRadialGradient(0, 0, 0, 0, 0, radiusX);
1701
+ const alphaHex = (value) => {
1702
+ const text = Math.round(value).toString(16);
1703
+ return text.length === 1 ? `0${text}` : text;
1704
+ };
1705
+ gradient.addColorStop(0, `${color}${alphaHex(alpha * 255)}`);
1706
+ gradient.addColorStop(0.46, `${color}${alphaHex(alpha * 0.42 * 255)}`);
1686
1707
  gradient.addColorStop(1, `${color}00`);
1687
1708
  context.fillStyle = gradient;
1688
1709
  context.fillRect(-radiusX, -radiusX, radiusX * 2, radiusX * 2);
@@ -2112,9 +2133,14 @@ class ProgressCapsuleController {
2112
2133
  ctx.restore();
2113
2134
  }
2114
2135
 
2115
- setRange(min, max) {
2116
- this.min = min;
2117
- this.max = max;
2136
+ setRange(min, max) {
2137
+ if (min > max) {
2138
+ const swap = min;
2139
+ min = max;
2140
+ max = swap;
2141
+ }
2142
+ this.min = min;
2143
+ this.max = max;
2118
2144
  const clamped = clamp(this.value, this.min, this.max);
2119
2145
  if (clamped !== this.value) this.setProgress(clamped, 'prop');
2120
2146
  }
@@ -2309,33 +2335,7 @@ class ProgressCapsuleController {
2309
2335
  this.root.addEventListener('pointercancel', this.handlers.pointercancel);
2310
2336
  }
2311
2337
 
2312
- if (this.options.keyboard !== false) {
2313
- this.handlers.keydown = (event) => {
2314
- const step = (this.max - this.min) * 0.02;
2315
- const actions = {
2316
- ArrowLeft: -step,
2317
- ArrowDown: -step,
2318
- ArrowRight: step,
2319
- ArrowUp: step,
2320
- PageDown: -step * 5,
2321
- PageUp: step * 5
2322
- };
2323
- if (event.key === 'Home') {
2324
- event.preventDefault();
2325
- this.setProgress(this.min, 'keyboard');
2326
- } else if (event.key === 'End') {
2327
- event.preventDefault();
2328
- this.setProgress(this.max, 'keyboard');
2329
- } else if (actions[event.key]) {
2330
- event.preventDefault();
2331
- this.setProgress(this.value + actions[event.key], 'keyboard');
2332
- } else {
2333
- return;
2334
- }
2335
- };
2336
- this.root.addEventListener('keydown', this.handlers.keydown);
2337
- }
2338
- }
2338
+ }
2339
2339
 
2340
2340
  update(delta, paused) {
2341
2341
  if (!paused) this.flowTime += delta;
@@ -2373,7 +2373,7 @@ class ProgressCapsuleController {
2373
2373
  * Mount a fluid progress capsule into `container`.
2374
2374
  *
2375
2375
  * Options: preset (id/code/name or object), width, height, value, min, max,
2376
- * draggable, keyboard, colors, edgeStyle, textRatio (0-100, text region
2376
+ * draggable, colors, edgeStyle, textRatio (0-100, text region
2377
2377
  * width in percent), text (HTML string or DOM nodes for the text slot),
2378
2378
  * colorContent (HTML string or DOM nodes for the color slot),
2379
2379
  * showValue (show/hide the right-side percentage), quality,
@@ -2386,6 +2386,11 @@ function createProgressCapsule(container, options = {}) {
2386
2386
 
2387
2387
  const preset = { ...getPreset('progress', options.preset ?? '星火') };
2388
2388
  const merged = normalizeOptions(DEFAULTS.progress, preset, options);
2389
+ if (merged.min > merged.max) {
2390
+ const swap = merged.min;
2391
+ merged.min = merged.max;
2392
+ merged.max = swap;
2393
+ }
2389
2394
  const normalizedColors = merged.colors.map(normalizeColor);
2390
2395
  if (normalizedColors.every(Boolean)) preset.colors = normalizedColors;
2391
2396
  preset.edgeStyle = merged.edgeStyle;
@@ -2397,7 +2402,6 @@ function createProgressCapsule(container, options = {}) {
2397
2402
  const readonly = merged.readonly === true || merged.readonly === '' || merged.readonly === 'true';
2398
2403
  const locked = disabled || readonly;
2399
2404
  const effectiveDraggable = locked ? false : merged.draggable !== false;
2400
- const effectiveKeyboard = locked ? false : merged.keyboard !== false;
2401
2405
  const dirty = {
2402
2406
  preset: false,
2403
2407
  colors: false,
@@ -2410,7 +2414,6 @@ function createProgressCapsule(container, options = {}) {
2410
2414
  const root = document.createElement('div');
2411
2415
  root.className = 'hj-capsule-root hj-progress-root';
2412
2416
  root.setAttribute('role', 'slider');
2413
- root.setAttribute('tabindex', '0');
2414
2417
  root.setAttribute('data-draggable', String(effectiveDraggable));
2415
2418
  if (disabled) {
2416
2419
  root.setAttribute('aria-disabled', 'true');
@@ -2420,6 +2423,7 @@ function createProgressCapsule(container, options = {}) {
2420
2423
  root.setAttribute('aria-readonly', 'true');
2421
2424
  root.classList.add('is-readonly');
2422
2425
  }
2426
+ if (locked) root.setAttribute('tabindex', '-1');
2423
2427
  root.setAttribute('aria-valuemin', String(merged.min ?? 0));
2424
2428
  root.setAttribute('aria-valuemax', String(merged.max ?? 100));
2425
2429
  root.setAttribute('aria-valuenow', String(preset.initialProgress));
@@ -2430,8 +2434,6 @@ function createProgressCapsule(container, options = {}) {
2430
2434
  );
2431
2435
  };
2432
2436
  updateAria();
2433
- if (!effectiveKeyboard) root.setAttribute('tabindex', '-1');
2434
-
2435
2437
  const canvas = document.createElement('canvas');
2436
2438
  canvas.className = 'hj-progress-canvas';
2437
2439
  canvas.setAttribute('aria-hidden', 'true');
@@ -2493,7 +2495,7 @@ function createProgressCapsule(container, options = {}) {
2493
2495
  valueElement,
2494
2496
  preset,
2495
2497
  emitter,
2496
- options: { ...merged, draggable: effectiveDraggable, keyboard: effectiveKeyboard },
2498
+ options: { ...merged, draggable: effectiveDraggable },
2497
2499
  copy,
2498
2500
  dirty
2499
2501
  });
@@ -2634,10 +2636,16 @@ function createProgressCapsule(container, options = {}) {
2634
2636
  controller.resizeCanvas();
2635
2637
  return this;
2636
2638
  },
2637
- setSize(width, height) {
2638
- if (width !== undefined) merged.width = width;
2639
- if (height !== undefined) merged.height = height;
2640
- applySize();
2639
+ setSize(width, height) {
2640
+ if (width !== undefined) {
2641
+ parseSize(width);
2642
+ merged.width = width;
2643
+ }
2644
+ if (height !== undefined) {
2645
+ parseSize(height);
2646
+ merged.height = height;
2647
+ }
2648
+ applySize();
2641
2649
  controller.resizeCanvas();
2642
2650
  return this;
2643
2651
  },
@@ -2667,8 +2675,8 @@ function createProgressCapsule(container, options = {}) {
2667
2675
  controller.dispose();
2668
2676
  root.remove();
2669
2677
  },
2670
- textRatio: merged.textRatio,
2671
- cssVars: merged.cssVars,
2678
+ get textRatio() { return merged.textRatio; },
2679
+ get cssVars() { return merged.cssVars; },
2672
2680
  dirty
2673
2681
  };
2674
2682
  }
@@ -2888,9 +2896,9 @@ function createColorBackground(host, options = {}) {
2888
2896
  renderer.dispose();
2889
2897
  layer.remove();
2890
2898
  },
2891
- opacity: merged.opacity,
2892
- fallbackColor: merged.fallbackColor,
2893
- mouseColor: merged.mouseColor,
2899
+ get opacity() { return merged.opacity; },
2900
+ get fallbackColor() { return merged.fallbackColor; },
2901
+ get mouseColor() { return merged.mouseColor; },
2894
2902
  dirty
2895
2903
  };
2896
2904
  }
@@ -2926,6 +2934,9 @@ function makeWrapper({ name, props, events, create, render, methods, watch }) {
2926
2934
  const extraState = this.runtimeState();
2927
2935
  if (this.controller) this.controller.dispose();
2928
2936
  this.mountController(extraState);
2937
+ // 结构属性连续变化时,插槽内容可能在重建后才被 Vue 写入容器,
2938
+ // 补一次搬运确保不丢。
2939
+ this.$nextTick(() => this.moveSlots());
2929
2940
  },
2930
2941
  scheduleRecreate() {
2931
2942
  if (this._recreateQueued) return;
@@ -3075,7 +3086,7 @@ function makeProgressWrapper(createProgressCapsule, render) {
3075
3086
  name: 'ProgressCapsule',
3076
3087
  props: [
3077
3088
  'preset', 'width', 'height', 'value', 'min', 'max',
3078
- 'draggable', 'keyboard', 'disabled', 'readonly', 'edgeStyle', 'colors', 'textRatio', 'label', 'showValue', 'valueSuffix',
3089
+ 'draggable', 'disabled', 'readonly', 'edgeStyle', 'colors', 'textRatio', 'label', 'showValue', 'valueSuffix',
3079
3090
  'quality', 'renderer', 'respectReducedMotion', 'cssVars'
3080
3091
  ],
3081
3092
  events: PROGRESS_EVENTS,
@@ -3118,9 +3129,6 @@ function makeProgressWrapper(createProgressCapsule, render) {
3118
3129
  draggable() {
3119
3130
  this.scheduleRecreate();
3120
3131
  },
3121
- keyboard() {
3122
- this.scheduleRecreate();
3123
- },
3124
3132
  renderer() {
3125
3133
  this.scheduleRecreate();
3126
3134
  }