@5even7/dlc-ui 0.2.4 → 0.2.6

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.mjs CHANGED
@@ -1049,10 +1049,9 @@ function createCapsule(container, options = {}) {
1049
1049
  for (const name of Object.keys(vars)) root.style.setProperty(name, vars[name]);
1050
1050
  if (merged.textRatio !== undefined) {
1051
1051
  root.style.setProperty('--hj-text-width', `${merged.textRatio}%`);
1052
- const userMinWidth = merged.cssVars && merged.cssVars['--hj-text-min-width'];
1053
- if (merged.textRatio === 0) root.style.setProperty('--hj-text-min-width', '0');
1054
- else if (userMinWidth) root.style.setProperty('--hj-text-min-width', userMinWidth);
1055
- else root.style.removeProperty('--hj-text-min-width');
1052
+ // textRatio 是文字区宽度的唯一权威值:min-width 会阻止其缩小到
1053
+ // 164px 以下(--hj-copy-min-width 的历史默认),这里强制归零。
1054
+ root.style.setProperty('--hj-text-min-width', '0');
1056
1055
  }
1057
1056
  renderer.resize();
1058
1057
  };
@@ -1151,10 +1150,7 @@ function createCapsule(container, options = {}) {
1151
1150
  dirty.textRatio = true;
1152
1151
  merged.textRatio = value;
1153
1152
  root.style.setProperty('--hj-text-width', `${value}%`);
1154
- const userMinWidth = merged.cssVars && merged.cssVars['--hj-text-min-width'];
1155
- if (value === 0) root.style.setProperty('--hj-text-min-width', '0');
1156
- else if (userMinWidth) root.style.setProperty('--hj-text-min-width', userMinWidth);
1157
- else root.style.removeProperty('--hj-text-min-width');
1153
+ root.style.setProperty('--hj-text-min-width', '0');
1158
1154
  return this;
1159
1155
  },
1160
1156
  setCssVars(vars) {
@@ -1169,6 +1165,11 @@ function createCapsule(container, options = {}) {
1169
1165
  updateAria();
1170
1166
  return this;
1171
1167
  },
1168
+ setMouseColor(value) {
1169
+ merged.mouseColor = value !== false;
1170
+ if (typeof renderer.setMouseColor === 'function') renderer.setMouseColor(merged.mouseColor);
1171
+ return this;
1172
+ },
1172
1173
  setSize(width, height) {
1173
1174
  if (width !== undefined) {
1174
1175
  parseSize(width); // 非法尺寸直接抛错前先校验,避免污染内部状态
@@ -1968,6 +1969,11 @@ class ProgressCapsuleController {
1968
1969
  this.root.setAttribute('aria-valuetext', `${rounded}${this.valueSuffix}`);
1969
1970
  return this;
1970
1971
  }
1972
+
1973
+ setShowValue(show) {
1974
+ if (this.valueElement) this.valueElement.hidden = show === false;
1975
+ return this;
1976
+ }
1971
1977
 
1972
1978
  resizeCanvas() {
1973
1979
  const bounds = this.root.getBoundingClientRect();
@@ -2462,16 +2468,15 @@ function createProgressCapsule(container, options = {}) {
2462
2468
  fillContent(textLayer, options.text);
2463
2469
  fillContent(visualLayer, options.colorContent);
2464
2470
 
2465
- const valueElement = merged.showValue === false ? null : document.createElement('div');
2466
- if (valueElement) {
2467
- valueElement.className = 'hj-progress-value';
2468
- valueElement.setAttribute('aria-hidden', 'true');
2469
- }
2471
+ const valueElement = document.createElement('div');
2472
+ valueElement.className = 'hj-progress-value';
2473
+ valueElement.setAttribute('aria-hidden', 'true');
2474
+ valueElement.hidden = merged.showValue === false;
2470
2475
 
2471
2476
  root.appendChild(canvas);
2472
2477
  root.appendChild(textLayer);
2473
2478
  root.appendChild(visualLayer);
2474
- if (valueElement) root.appendChild(valueElement);
2479
+ root.appendChild(valueElement);
2475
2480
  container.appendChild(root);
2476
2481
 
2477
2482
  const emitter = createEmitter();
@@ -2627,6 +2632,10 @@ function createProgressCapsule(container, options = {}) {
2627
2632
  controller.setValueSuffix(suffix);
2628
2633
  return this;
2629
2634
  },
2635
+ setShowValue(show) {
2636
+ controller.setShowValue(show);
2637
+ return this;
2638
+ },
2630
2639
  setColors(colors) {
2631
2640
  const next = Array.isArray(colors) ? colors.map(normalizeColor) : [];
2632
2641
  if (next.length !== 4 || next.some((color) => !color)) return this;
@@ -2951,15 +2960,13 @@ function makeWrapper({ name, props, events, create, render, methods, watch }) {
2951
2960
  const root = this.controller.element;
2952
2961
  const textLayer = root.querySelector('.hj-capsule-text, .hj-progress-text');
2953
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
+ };
2954
2967
  const refs = this.$refs || {};
2955
- // 把插槽容器整体搬进对应区域,而不是搬子节点:Vue 重渲染/重建组件时
2956
- // 内容始终留在区域内,不会丢(子节点搬运会在 recreate 时序下丢失)。
2957
- if (refs.slotText && textLayer && refs.slotText.parentElement !== textLayer) {
2958
- textLayer.appendChild(refs.slotText);
2959
- }
2960
- if (refs.slotColor && visualLayer && refs.slotColor.parentElement !== visualLayer) {
2961
- visualLayer.appendChild(refs.slotColor);
2962
- }
2968
+ move(refs.slotText, textLayer);
2969
+ move(refs.slotColor, visualLayer);
2963
2970
  },
2964
2971
  applyAttrs() {
2965
2972
  if (!this.controller || !this.controller.element || !this.$attrs) return;
@@ -3056,8 +3063,8 @@ function makeCapsuleWrapper(createCapsule, render) {
3056
3063
  label(value) {
3057
3064
  if (this.controller) this.controller.setLabel(value);
3058
3065
  },
3059
- mouseColor() {
3060
- this.scheduleRecreate();
3066
+ mouseColor(value) {
3067
+ if (this.controller) this.controller.setMouseColor(value);
3061
3068
  },
3062
3069
  renderer() {
3063
3070
  this.scheduleRecreate();
@@ -3117,8 +3124,8 @@ function makeProgressWrapper(createProgressCapsule, render) {
3117
3124
  valueSuffix(value) {
3118
3125
  if (value !== undefined && this.controller) this.controller.setValueSuffix(value);
3119
3126
  },
3120
- showValue() {
3121
- this.scheduleRecreate();
3127
+ showValue(value) {
3128
+ if (this.controller) this.controller.setShowValue(value);
3122
3129
  },
3123
3130
  disabled() {
3124
3131
  this.scheduleRecreate();
package/dist/vue3.cjs CHANGED
@@ -1219,8 +1219,9 @@ function createCapsule(container) {
1219
1219
  }
1220
1220
  if (merged.textRatio !== undefined) {
1221
1221
  root.style.setProperty('--hj-text-width', "".concat(merged.textRatio, "%"));
1222
- var userMinWidth = merged.cssVars && merged.cssVars['--hj-text-min-width'];
1223
- if (merged.textRatio === 0) root.style.setProperty('--hj-text-min-width', '0');else if (userMinWidth) root.style.setProperty('--hj-text-min-width', userMinWidth);else root.style.removeProperty('--hj-text-min-width');
1222
+ // textRatio 是文字区宽度的唯一权威值:min-width 会阻止其缩小到
1223
+ // 164px 以下(--hj-copy-min-width 的历史默认),这里强制归零。
1224
+ root.style.setProperty('--hj-text-min-width', '0');
1224
1225
  }
1225
1226
  renderer.resize();
1226
1227
  };
@@ -1344,8 +1345,7 @@ function createCapsule(container) {
1344
1345
  dirty.textRatio = true;
1345
1346
  merged.textRatio = value;
1346
1347
  root.style.setProperty('--hj-text-width', "".concat(value, "%"));
1347
- var userMinWidth = merged.cssVars && merged.cssVars['--hj-text-min-width'];
1348
- if (value === 0) root.style.setProperty('--hj-text-min-width', '0');else if (userMinWidth) root.style.setProperty('--hj-text-min-width', userMinWidth);else root.style.removeProperty('--hj-text-min-width');
1348
+ root.style.setProperty('--hj-text-min-width', '0');
1349
1349
  return this;
1350
1350
  },
1351
1351
  setCssVars: function setCssVars(vars) {
@@ -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 = merged.showValue === false ? null : document.createElement('div');
2523
- if (valueElement) {
2524
- valueElement.className = 'hj-progress-value';
2525
- valueElement.setAttribute('aria-hidden', 'true');
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
- if (valueElement) root.appendChild(valueElement);
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
- // 把插槽容器整体搬进对应区域,而不是搬子节点:Vue 重渲染/重建组件时
3050
- // 内容始终留在区域内,不会丢(子节点搬运会在 recreate 时序下丢失)。
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 _i = 0, _Object$keys = Object.keys(this.$attrs); _i < _Object$keys.length; _i++) {
3062
- var key = _Object$keys[_i];
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));
@@ -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.scheduleRecreate();
3172
+ mouseColor: function mouseColor(value) {
3173
+ if (this.controller) this.controller.setMouseColor(value);
3159
3174
  },
3160
3175
  renderer: function renderer() {
3161
3176
  this.scheduleRecreate();
@@ -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.scheduleRecreate();
3254
+ showValue: function showValue(value) {
3255
+ if (this.controller) this.controller.setShowValue(value);
3241
3256
  },
3242
3257
  disabled: function disabled() {
3243
3258
  this.scheduleRecreate();
package/dist/vue3.mjs CHANGED
@@ -1051,10 +1051,9 @@ function createCapsule(container, options = {}) {
1051
1051
  for (const name of Object.keys(vars)) root.style.setProperty(name, vars[name]);
1052
1052
  if (merged.textRatio !== undefined) {
1053
1053
  root.style.setProperty('--hj-text-width', `${merged.textRatio}%`);
1054
- const userMinWidth = merged.cssVars && merged.cssVars['--hj-text-min-width'];
1055
- if (merged.textRatio === 0) root.style.setProperty('--hj-text-min-width', '0');
1056
- else if (userMinWidth) root.style.setProperty('--hj-text-min-width', userMinWidth);
1057
- else root.style.removeProperty('--hj-text-min-width');
1054
+ // textRatio 是文字区宽度的唯一权威值:min-width 会阻止其缩小到
1055
+ // 164px 以下(--hj-copy-min-width 的历史默认),这里强制归零。
1056
+ root.style.setProperty('--hj-text-min-width', '0');
1058
1057
  }
1059
1058
  renderer.resize();
1060
1059
  };
@@ -1153,10 +1152,7 @@ function createCapsule(container, options = {}) {
1153
1152
  dirty.textRatio = true;
1154
1153
  merged.textRatio = value;
1155
1154
  root.style.setProperty('--hj-text-width', `${value}%`);
1156
- const userMinWidth = merged.cssVars && merged.cssVars['--hj-text-min-width'];
1157
- if (value === 0) root.style.setProperty('--hj-text-min-width', '0');
1158
- else if (userMinWidth) root.style.setProperty('--hj-text-min-width', userMinWidth);
1159
- else root.style.removeProperty('--hj-text-min-width');
1155
+ root.style.setProperty('--hj-text-min-width', '0');
1160
1156
  return this;
1161
1157
  },
1162
1158
  setCssVars(vars) {
@@ -1171,6 +1167,11 @@ function createCapsule(container, options = {}) {
1171
1167
  updateAria();
1172
1168
  return this;
1173
1169
  },
1170
+ setMouseColor(value) {
1171
+ merged.mouseColor = value !== false;
1172
+ if (typeof renderer.setMouseColor === 'function') renderer.setMouseColor(merged.mouseColor);
1173
+ return this;
1174
+ },
1174
1175
  setSize(width, height) {
1175
1176
  if (width !== undefined) {
1176
1177
  parseSize(width); // 非法尺寸直接抛错前先校验,避免污染内部状态
@@ -1970,6 +1971,11 @@ class ProgressCapsuleController {
1970
1971
  this.root.setAttribute('aria-valuetext', `${rounded}${this.valueSuffix}`);
1971
1972
  return this;
1972
1973
  }
1974
+
1975
+ setShowValue(show) {
1976
+ if (this.valueElement) this.valueElement.hidden = show === false;
1977
+ return this;
1978
+ }
1973
1979
 
1974
1980
  resizeCanvas() {
1975
1981
  const bounds = this.root.getBoundingClientRect();
@@ -2464,16 +2470,15 @@ function createProgressCapsule(container, options = {}) {
2464
2470
  fillContent(textLayer, options.text);
2465
2471
  fillContent(visualLayer, options.colorContent);
2466
2472
 
2467
- const valueElement = merged.showValue === false ? null : document.createElement('div');
2468
- if (valueElement) {
2469
- valueElement.className = 'hj-progress-value';
2470
- valueElement.setAttribute('aria-hidden', 'true');
2471
- }
2473
+ const valueElement = document.createElement('div');
2474
+ valueElement.className = 'hj-progress-value';
2475
+ valueElement.setAttribute('aria-hidden', 'true');
2476
+ valueElement.hidden = merged.showValue === false;
2472
2477
 
2473
2478
  root.appendChild(canvas);
2474
2479
  root.appendChild(textLayer);
2475
2480
  root.appendChild(visualLayer);
2476
- if (valueElement) root.appendChild(valueElement);
2481
+ root.appendChild(valueElement);
2477
2482
  container.appendChild(root);
2478
2483
 
2479
2484
  const emitter = createEmitter();
@@ -2629,6 +2634,10 @@ function createProgressCapsule(container, options = {}) {
2629
2634
  controller.setValueSuffix(suffix);
2630
2635
  return this;
2631
2636
  },
2637
+ setShowValue(show) {
2638
+ controller.setShowValue(show);
2639
+ return this;
2640
+ },
2632
2641
  setColors(colors) {
2633
2642
  const next = Array.isArray(colors) ? colors.map(normalizeColor) : [];
2634
2643
  if (next.length !== 4 || next.some((color) => !color)) return this;
@@ -2953,15 +2962,13 @@ function makeWrapper({ name, props, events, create, render, methods, watch }) {
2953
2962
  const root = this.controller.element;
2954
2963
  const textLayer = root.querySelector('.hj-capsule-text, .hj-progress-text');
2955
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
+ };
2956
2969
  const refs = this.$refs || {};
2957
- // 把插槽容器整体搬进对应区域,而不是搬子节点:Vue 重渲染/重建组件时
2958
- // 内容始终留在区域内,不会丢(子节点搬运会在 recreate 时序下丢失)。
2959
- if (refs.slotText && textLayer && refs.slotText.parentElement !== textLayer) {
2960
- textLayer.appendChild(refs.slotText);
2961
- }
2962
- if (refs.slotColor && visualLayer && refs.slotColor.parentElement !== visualLayer) {
2963
- visualLayer.appendChild(refs.slotColor);
2964
- }
2970
+ move(refs.slotText, textLayer);
2971
+ move(refs.slotColor, visualLayer);
2965
2972
  },
2966
2973
  applyAttrs() {
2967
2974
  if (!this.controller || !this.controller.element || !this.$attrs) return;
@@ -3058,8 +3065,8 @@ function makeCapsuleWrapper(createCapsule, render) {
3058
3065
  label(value) {
3059
3066
  if (this.controller) this.controller.setLabel(value);
3060
3067
  },
3061
- mouseColor() {
3062
- this.scheduleRecreate();
3068
+ mouseColor(value) {
3069
+ if (this.controller) this.controller.setMouseColor(value);
3063
3070
  },
3064
3071
  renderer() {
3065
3072
  this.scheduleRecreate();
@@ -3119,8 +3126,8 @@ function makeProgressWrapper(createProgressCapsule, render) {
3119
3126
  valueSuffix(value) {
3120
3127
  if (value !== undefined && this.controller) this.controller.setValueSuffix(value);
3121
3128
  },
3122
- showValue() {
3123
- this.scheduleRecreate();
3129
+ showValue(value) {
3130
+ if (this.controller) this.controller.setShowValue(value);
3124
3131
  },
3125
3132
  disabled() {
3126
3133
  this.scheduleRecreate();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@5even7/dlc-ui",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },